ar71xx: add support for gl-mifi
[openwrt/openwrt.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-mr16.c
1 /*
2 * Cisco Meraki MR16 board support
3 *
4 * Copyright (C) 2015 Chris Blake <chrisrblake93@gmail.com>
5 *
6 * Based on Atheros AP96 board support configuration
7 *
8 * Copyright (C) 2009 Marco Porsch
9 * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
10 * Copyright (C) 2010 Atheros Communications
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License version 2 as published
14 * by the Free Software Foundation.
15 */
16
17 #include <linux/platform_device.h>
18 #include <linux/delay.h>
19
20 #include <asm/mach-ath79/ath79.h>
21
22 #include "dev-ap9x-pci.h"
23 #include "dev-eth.h"
24 #include "dev-gpio-buttons.h"
25 #include "dev-leds-gpio.h"
26 #include "dev-m25p80.h"
27 #include "machtypes.h"
28
29 #define MR16_GPIO_LED_W4_GREEN 3
30 #define MR16_GPIO_LED_W3_GREEN 2
31 #define MR16_GPIO_LED_W2_GREEN 1
32 #define MR16_GPIO_LED_W1_GREEN 0
33
34 #define MR16_GPIO_LED_WAN 4
35
36 #define MR16_GPIO_LED_POWER_ORANGE 5
37 #define MR16_GPIO_LED_POWER_GREEN 6
38
39 #define MR16_GPIO_BTN_RESET 7
40 #define MR16_KEYS_POLL_INTERVAL 20 /* msecs */
41 #define MR16_KEYS_DEBOUNCE_INTERVAL (3 * MR16_KEYS_POLL_INTERVAL)
42
43 #define MR16_WAN_PHYMASK BIT(0)
44
45 #define MR16_WMAC0_MAC_OFFSET 0x120c
46 #define MR16_WMAC1_MAC_OFFSET 0x520c
47 #define MR16_CALDATA0_OFFSET 0x1000
48 #define MR16_CALDATA1_OFFSET 0x5000
49
50 static struct gpio_led MR16_leds_gpio[] __initdata = {
51 {
52 .name = "mr16:green:wan",
53 .gpio = MR16_GPIO_LED_WAN,
54 .active_low = 1,
55 }, {
56 .name = "mr16:orange:power",
57 .gpio = MR16_GPIO_LED_POWER_ORANGE,
58 .active_low = 1,
59 }, {
60 .name = "mr16:green:power",
61 .gpio = MR16_GPIO_LED_POWER_GREEN,
62 .active_low = 1,
63 }, {
64 .name = "mr16:green:wifi4",
65 .gpio = MR16_GPIO_LED_W4_GREEN,
66 .active_low = 1,
67 }, {
68 .name = "mr16:green:wifi3",
69 .gpio = MR16_GPIO_LED_W3_GREEN,
70 .active_low = 1,
71 }, {
72 .name = "mr16:green:wifi2",
73 .gpio = MR16_GPIO_LED_W2_GREEN,
74 .active_low = 1,
75 }, {
76 .name = "mr16:green:wifi1",
77 .gpio = MR16_GPIO_LED_W1_GREEN,
78 .active_low = 1,
79 }
80 };
81
82 static struct gpio_keys_button MR16_gpio_keys[] __initdata = {
83 {
84 .desc = "reset",
85 .type = EV_KEY,
86 .code = KEY_RESTART,
87 .debounce_interval = MR16_KEYS_DEBOUNCE_INTERVAL,
88 .gpio = MR16_GPIO_BTN_RESET,
89 .active_low = 1,
90 }
91 };
92
93 static void __init MR16_setup(void)
94 {
95 u8 *mac = (u8 *) KSEG1ADDR(0xbfff0000);
96
97 ath79_register_mdio(0,0x0);
98
99 ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
100 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
101 ath79_eth0_data.phy_mask = MR16_WAN_PHYMASK;
102 ath79_register_eth(0);
103
104 ath79_register_m25p80(NULL);
105
106 ath79_register_leds_gpio(-1, ARRAY_SIZE(MR16_leds_gpio),
107 MR16_leds_gpio);
108 ath79_register_gpio_keys_polled(-1, MR16_KEYS_POLL_INTERVAL,
109 ARRAY_SIZE(MR16_gpio_keys),
110 MR16_gpio_keys);
111
112 ap94_pci_init(mac + MR16_CALDATA0_OFFSET,
113 mac + MR16_WMAC0_MAC_OFFSET,
114 mac + MR16_CALDATA1_OFFSET,
115 mac + MR16_WMAC1_MAC_OFFSET);
116 }
117
118 MIPS_MACHINE(ATH79_MACH_MR16, "MR16", "Meraki MR16", MR16_setup);