OpenWrt – Blame information for rev 4
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
4 | office | 1 | /* |
2 | * Nokia WI2A-AC200i support |
||
3 | * |
||
4 | * Copyright (c) 2012 Qualcomm Atheros |
||
5 | * Copyright (c) 2012-2013 Gabor Juhos <juhosg@openwrt.org> |
||
6 | * Copyright (c) 2017 Felix Fietkau <nbd@nbd.name> |
||
7 | * |
||
8 | * Permission to use, copy, modify, and/or distribute this software for any |
||
9 | * purpose with or without fee is hereby granted, provided that the above |
||
10 | * copyright notice and this permission notice appear in all copies. |
||
11 | * |
||
12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
||
13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
||
14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
||
15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
||
16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
||
17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
||
18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
||
19 | * |
||
20 | */ |
||
21 | |||
22 | #include <linux/platform_device.h> |
||
23 | #include <linux/mtd/mtd.h> |
||
24 | #include <linux/mtd/partitions.h> |
||
25 | #include <linux/platform/ar934x_nfc.h> |
||
26 | |||
27 | #include <asm/mach-ath79/ar71xx_regs.h> |
||
28 | #include <asm/fw/fw.h> |
||
29 | |||
30 | #include "common.h" |
||
31 | #include "pci.h" |
||
32 | #include "dev-ap9x-pci.h" |
||
33 | #include "dev-gpio-buttons.h" |
||
34 | #include "dev-eth.h" |
||
35 | #include "dev-leds-gpio.h" |
||
36 | #include "dev-m25p80.h" |
||
37 | #include "dev-nfc.h" |
||
38 | #include "dev-usb.h" |
||
39 | #include "dev-wmac.h" |
||
40 | #include "machtypes.h" |
||
41 | |||
42 | #define AC200I_GPIO_BTN_RESET 17 |
||
43 | |||
44 | #define AC200I_KEYS_POLL_INTERVAL 20 /* msecs */ |
||
45 | #define AC200I_KEYS_DEBOUNCE_INTERVAL (3 * AC200I_KEYS_POLL_INTERVAL) |
||
46 | |||
47 | #define AC200I_MAC_ADDR 0x1f040249 |
||
48 | #define AC200I_MAC1_OFFSET 6 |
||
49 | #define AC200I_WMAC_CALDATA_ADDR 0x1f061000 |
||
50 | |||
51 | static struct gpio_led ac200i_leds_gpio[] __initdata = { |
||
52 | { |
||
53 | .name = "nokia:red:wlan-2g", |
||
54 | .gpio = 0, |
||
55 | .active_low = 1, |
||
56 | }, |
||
57 | { |
||
58 | .name = "nokia:green:power", |
||
59 | .gpio = 1, |
||
60 | .active_low = 1, |
||
61 | }, |
||
62 | { |
||
63 | .name = "nokia:green:wlan-2g", |
||
64 | .gpio = 2, |
||
65 | .active_low = 1, |
||
66 | }, |
||
67 | { |
||
68 | .name = "nokia:green:ctrl", |
||
69 | .gpio = 3, |
||
70 | .active_low = 1, |
||
71 | }, |
||
72 | { |
||
73 | .name = "nokia:green:eth", |
||
74 | .gpio = 4, |
||
75 | .active_low = 1, |
||
76 | }, |
||
77 | { |
||
78 | .name = "nokia:red:power", |
||
79 | .gpio = 13, |
||
80 | .active_low = 1, |
||
81 | }, |
||
82 | { |
||
83 | .name = "nokia:red:eth", |
||
84 | .gpio = 14, |
||
85 | .active_low = 1, |
||
86 | }, |
||
87 | { |
||
88 | .name = "nokia:red:wlan-5g", |
||
89 | .gpio = 18, |
||
90 | .active_low = 1, |
||
91 | }, |
||
92 | { |
||
93 | .name = "nokia:green:wlan-5g", |
||
94 | .gpio = 19, |
||
95 | .active_low = 1, |
||
96 | }, |
||
97 | { |
||
98 | .name = "nokia:red:ctrl", |
||
99 | .gpio = 20, |
||
100 | .active_low = 1, |
||
101 | }, |
||
102 | }; |
||
103 | |||
104 | static struct gpio_keys_button ac200i_gpio_keys[] __initdata = { |
||
105 | { |
||
106 | .desc = "Reset button", |
||
107 | .type = EV_KEY, |
||
108 | .code = KEY_RESTART, |
||
109 | .debounce_interval = AC200I_KEYS_DEBOUNCE_INTERVAL, |
||
110 | .gpio = AC200I_GPIO_BTN_RESET, |
||
111 | .active_low = 1, |
||
112 | }, |
||
113 | }; |
||
114 | |||
115 | static struct mtd_partition ac200i_nand_partitions[] = { |
||
116 | { |
||
117 | .name = "cfg", |
||
118 | .offset = 0x0100000, |
||
119 | .size = 0x1800000, |
||
120 | .mask_flags = MTD_WRITEABLE, |
||
121 | }, |
||
122 | { |
||
123 | .name = "kernel", |
||
124 | .offset = 0x2000000, |
||
125 | .size = 0x0400000, |
||
126 | }, |
||
127 | { |
||
128 | .name = "ubi", |
||
129 | .offset = 0x2400000, |
||
130 | .size = 0x2000000, |
||
131 | }, |
||
132 | { |
||
133 | .name = "kernel", |
||
134 | .offset = 0x5000000, |
||
135 | .size = 0x0400000, |
||
136 | }, |
||
137 | { |
||
138 | .name = "ubi", |
||
139 | .offset = 0x5400000, |
||
140 | .size = 0x2000000, |
||
141 | }, |
||
142 | }; |
||
143 | |||
144 | static const char *boot_getenv(const char *key) |
||
145 | { |
||
146 | const char *start = (const char *) KSEG1ADDR(0x1f070000); |
||
147 | const char *end = start + 0x20000; |
||
148 | const char *addr; |
||
149 | |||
150 | for (addr = start + 4; |
||
151 | *addr && *addr != 0xff && addr < end && |
||
152 | strnlen(addr, end - addr) < end - addr; |
||
153 | addr += strnlen(addr, end - addr) + 1) { |
||
154 | const char *val; |
||
155 | |||
156 | val = strchr(addr, '='); |
||
157 | if (!val) |
||
158 | continue; |
||
159 | |||
160 | if (strncmp(addr, key, val - addr)) |
||
161 | continue; |
||
162 | |||
163 | return val + 1; |
||
164 | } |
||
165 | return NULL; |
||
166 | } |
||
167 | |||
168 | static void __init ac200i_setup(void) |
||
169 | { |
||
170 | const char *img; |
||
171 | u8 *wmac = (u8 *) KSEG1ADDR(AC200I_WMAC_CALDATA_ADDR); |
||
172 | u8 *mac_addr = (u8 *) KSEG1ADDR(AC200I_MAC_ADDR); |
||
173 | |||
174 | ath79_register_m25p80(NULL); |
||
175 | |||
176 | ath79_register_leds_gpio(-1, ARRAY_SIZE(ac200i_leds_gpio), |
||
177 | ac200i_leds_gpio); |
||
178 | ath79_register_gpio_keys_polled(-1, AC200I_KEYS_POLL_INTERVAL, |
||
179 | ARRAY_SIZE(ac200i_gpio_keys), |
||
180 | ac200i_gpio_keys); |
||
181 | |||
182 | ath79_register_usb(); |
||
183 | ath79_nfc_set_parts(ac200i_nand_partitions, |
||
184 | ARRAY_SIZE(ac200i_nand_partitions)); |
||
185 | ath79_nfc_set_ecc_mode(AR934X_NFC_ECC_HW); |
||
186 | ath79_register_nfc(); |
||
187 | |||
188 | ath79_register_wmac(wmac, NULL); |
||
189 | |||
190 | ath79_register_mdio(0, 0x0); |
||
191 | ath79_init_mac(ath79_eth0_data.mac_addr, mac_addr, 0); |
||
192 | |||
193 | /* GMAC0 is connected to the SGMII interface */ |
||
194 | ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII; |
||
195 | ath79_eth0_data.phy_mask = BIT(4); |
||
196 | ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev; |
||
197 | ath79_eth0_pll_data.pll_1000 = 0x03000101; |
||
198 | ath79_eth0_pll_data.pll_100 = 0x80000101; |
||
199 | ath79_eth0_pll_data.pll_10 = 0x80001313; |
||
200 | |||
201 | img = boot_getenv("dualPartition"); |
||
202 | if (img && !strcmp(img, "imgA")) { |
||
203 | ac200i_nand_partitions[3].name = "kernel_alt"; |
||
204 | ac200i_nand_partitions[4].name = "ubi_alt"; |
||
205 | } else { |
||
206 | ac200i_nand_partitions[1].name = "kernel_alt"; |
||
207 | ac200i_nand_partitions[2].name = "ubi_alt"; |
||
208 | } |
||
209 | |||
210 | ath79_register_eth(0); |
||
211 | |||
212 | ath79_register_pci(); |
||
213 | } |
||
214 | |||
215 | MIPS_MACHINE(ATH79_MACH_WI2A_AC200I, "WI2A-AC200i", |
||
216 | "Nokia WI2A-AC200i", |
||
217 | ac200i_setup); |