| 1 | /* |
| 2 | * This program is free software; you can redistribute it and/or modify it |
| 3 | * under the terms of the GNU General Public License version 2 as published |
| 4 | * by the Free Software Foundation. |
| 5 | * |
| 6 | * Copyright (C) 2010 John Crispin <blogic@openwrt.org> |
| 7 | */ |
| 8 | |
| 9 | #include <linux/init.h> |
| 10 | #include <linux/platform_device.h> |
| 11 | #include <linux/leds.h> |
| 12 | #include <linux/gpio.h> |
| 13 | #include <linux/gpio_buttons.h> |
| 14 | #include <linux/mtd/mtd.h> |
| 15 | #include <linux/mtd/partitions.h> |
| 16 | #include <linux/mtd/physmap.h> |
| 17 | #include <linux/input.h> |
| 18 | #include <linux/etherdevice.h> |
| 19 | #include <linux/ath5k_platform.h> |
| 20 | #include <linux/ath9k_platform.h> |
| 21 | #include <linux/pci.h> |
| 22 | |
| 23 | #include <lantiq_soc.h> |
| 24 | #include <lantiq_platform.h> |
| 25 | #include <dev-gpio-leds.h> |
| 26 | #include <dev-gpio-buttons.h> |
| 27 | |
| 28 | #include "../machtypes.h" |
| 29 | #include "dev-wifi-rt2x00.h" |
| 30 | #include "dev-wifi-athxk.h" |
| 31 | #include "devices.h" |
| 32 | #include "dev-dwc_otg.h" |
| 33 | #include "pci-ath-fixup.h" |
| 34 | |
| 35 | static struct mtd_partition arv45xx_brnboot_partitions[] = |
| 36 | { |
| 37 | { |
| 38 | .name = "brn-boot", |
| 39 | .offset = 0x0, |
| 40 | .size = 0x20000, |
| 41 | }, |
| 42 | { |
| 43 | .name = "config", |
| 44 | .offset = 0x20000, |
| 45 | .size = 0x30000, |
| 46 | }, |
| 47 | { |
| 48 | .name = "linux", |
| 49 | .offset = 0x50000, |
| 50 | .size = 0x390000, |
| 51 | }, |
| 52 | { |
| 53 | .name = "reserved", /* 12-byte signature at 0x3efff4 :/ */ |
| 54 | .offset = 0x3e0000, |
| 55 | .size = 0x010000, |
| 56 | }, |
| 57 | { |
| 58 | .name = "eeprom", |
| 59 | .offset = 0x3f0000, |
| 60 | .size = 0x10000, |
| 61 | }, |
| 62 | }; |
| 63 | |
| 64 | static struct mtd_partition arv75xx_brnboot_partitions[] = |
| 65 | { |
| 66 | { |
| 67 | .name = "brn-boot", |
| 68 | .offset = 0x0, |
| 69 | .size = 0x20000, |
| 70 | }, |
| 71 | { |
| 72 | .name = "config", |
| 73 | .offset = 0x20000, |
| 74 | .size = 0x40000, |
| 75 | }, |
| 76 | { |
| 77 | .name = "linux", |
| 78 | .offset = 0x440000, |
| 79 | .size = 0x3a0000, |
| 80 | }, |
| 81 | { |
| 82 | .name = "reserved", /* 12-byte signature at 0x7efff4 :/ */ |
| 83 | .offset = 0x7e0000, |
| 84 | .size = 0x010000, |
| 85 | }, |
| 86 | { |
| 87 | .name = "board_config", |
| 88 | .offset = 0x7f0000, |
| 89 | .size = 0x10000, |
| 90 | }, |
| 91 | }; |
| 92 | |
| 93 | /* |
| 94 | * this is generic configuration for all arv based boards, note that it can be |
| 95 | * rewriten in arv_load_nor() |
| 96 | */ |
| 97 | static struct mtd_partition arv_partitions[] = |
| 98 | { |
| 99 | { |
| 100 | .name = "uboot", |
| 101 | .offset = 0x0, |
| 102 | .size = 0x20000, |
| 103 | }, |
| 104 | { |
| 105 | .name = "uboot_env", |
| 106 | .offset = 0x20000, |
| 107 | .size = 0x10000, |
| 108 | }, |
| 109 | { |
| 110 | .name = "linux", |
| 111 | .offset = 0x30000, |
| 112 | .size = 0x3c0000, |
| 113 | }, |
| 114 | { |
| 115 | .name = "board_config", |
| 116 | .offset = 0x3f0000, |
| 117 | .size = 0x10000, |
| 118 | }, |
| 119 | }; |
| 120 | |
| 121 | static struct physmap_flash_data arv45xx_brnboot_flash_data = { |
| 122 | .nr_parts = ARRAY_SIZE(arv45xx_brnboot_partitions), |
| 123 | .parts = arv45xx_brnboot_partitions, |
| 124 | }; |
| 125 | |
| 126 | static struct physmap_flash_data arv75xx_brnboot_flash_data = { |
| 127 | .nr_parts = ARRAY_SIZE(arv75xx_brnboot_partitions), |
| 128 | .parts = arv75xx_brnboot_partitions, |
| 129 | }; |
| 130 | |
| 131 | static struct physmap_flash_data arv_flash_data = { |
| 132 | .nr_parts = ARRAY_SIZE(arv_partitions), |
| 133 | .parts = arv_partitions, |
| 134 | }; |
| 135 | |
| 136 | static struct ltq_pci_data ltq_pci_data = { |
| 137 | .clock = PCI_CLOCK_EXT, |
| 138 | .gpio = PCI_GNT1 | PCI_REQ1, |
| 139 | .irq = { |
| 140 | [14] = INT_NUM_IM0_IRL0 + 22, |
| 141 | }, |
| 142 | }; |
| 143 | |
| 144 | static struct ltq_eth_data ltq_eth_data = { |
| 145 | .mii_mode = PHY_INTERFACE_MODE_RMII, |
| 146 | }; |
| 147 | |
| 148 | static struct gpio_led |
| 149 | arv4510pw_gpio_leds[] __initdata = { |
| 150 | { .name = "soc:green:foo", .gpio = 4, .active_low = 1, }, |
| 151 | }; |
| 152 | |
| 153 | static struct gpio_led |
| 154 | arv4518pw_gpio_leds[] __initdata = { |
| 155 | { .name = "soc:green:power", .gpio = 3, .active_low = 1, .default_trigger = "default-on" }, |
| 156 | { .name = "soc:green:adsl", .gpio = 4, .active_low = 1, .default_trigger = "default-on" }, |
| 157 | { .name = "soc:green:internet", .gpio = 5, .active_low = 1, .default_trigger = "default-on" }, |
| 158 | { .name = "soc:green:wifi", .gpio = 6, .active_low = 1, .default_trigger = "default-on" }, |
| 159 | { .name = "soc:yellow:wps", .gpio = 7, .active_low = 1, .default_trigger = "default-on" }, |
| 160 | { .name = "soc:red:fail", .gpio = 8, .active_low = 1, .default_trigger = "default-on" }, |
| 161 | { .name = "soc:green:usb", .gpio = 19, .active_low = 1, .default_trigger = "default-on" }, |
| 162 | { .name = "soc:green:voip", .gpio = 100, .active_low = 1, .default_trigger = "default-on" }, |
| 163 | { .name = "soc:green:fxs1", .gpio = 101, .active_low = 1, .default_trigger = "default-on" }, |
| 164 | { .name = "soc:green:fxs2", .gpio = 102, .active_low = 1, .default_trigger = "default-on" }, |
| 165 | { .name = "soc:green:fxo", .gpio = 103, .active_low = 1, .default_trigger = "default-on" }, |
| 166 | }; |
| 167 | |
| 168 | static struct gpio_keys_button |
| 169 | arv4518pw_gpio_keys[] __initdata = { |
| 170 | { |
| 171 | .desc = "wifi", |
| 172 | .type = EV_KEY, |
| 173 | .code = BTN_0, |
| 174 | .debounce_interval = LTQ_KEYS_DEBOUNCE_INTERVAL, |
| 175 | .gpio = 28, |
| 176 | .active_low = 1, |
| 177 | }, |
| 178 | { |
| 179 | .desc = "reset", |
| 180 | .type = EV_KEY, |
| 181 | .code = BTN_1, |
| 182 | .debounce_interval = LTQ_KEYS_DEBOUNCE_INTERVAL, |
| 183 | .gpio = 30, |
| 184 | .active_low = 1, |
| 185 | }, |
| 186 | { |
| 187 | .desc = "wps", |
| 188 | .type = EV_KEY, |
| 189 | .code = BTN_2, |
| 190 | .debounce_interval = LTQ_KEYS_DEBOUNCE_INTERVAL, |
| 191 | .gpio = 29, |
| 192 | .active_low = 1, |
| 193 | }, |
| 194 | }; |
| 195 | |
| 196 | static struct gpio_led |
| 197 | arv4519pw_gpio_leds[] __initdata = { |
| 198 | { .name = "soc:red:power", .gpio = 7, .active_low = 1, }, |
| 199 | { .name = "soc:green:power", .gpio = 2, .active_low = 1, .default_trigger = "default-on" }, |
| 200 | { .name = "soc:green:wifi", .gpio = 6, .active_low = 1, }, |
| 201 | { .name = "soc:green:adsl", .gpio = 4, .active_low = 1, }, |
| 202 | { .name = "soc:green:internet", .gpio = 5, .active_low = 1, }, |
| 203 | { .name = "soc:red:internet", .gpio = 8, .active_low = 1, }, |
| 204 | { .name = "soc:green:voip", .gpio = 100, .active_low = 1, }, |
| 205 | { .name = "soc:green:phone1", .gpio = 101, .active_low = 1, }, |
| 206 | { .name = "soc:green:phone2", .gpio = 102, .active_low = 1, }, |
| 207 | { .name = "soc:green:fxo", .gpio = 103, .active_low = 1, }, |
| 208 | { .name = "soc:green:usb", .gpio = 19, .active_low = 1, }, |
| 209 | { .name = "soc:orange:wps", .gpio = 104, .active_low = 1, }, |
| 210 | { .name = "soc:green:wps", .gpio = 105, .active_low = 1, }, |
| 211 | { .name = "soc:red:wps", .gpio = 106, .active_low = 1, }, |
| 212 | |
| 213 | }; |
| 214 | |
| 215 | static struct gpio_keys_button |
| 216 | arv4519pw_gpio_keys[] __initdata = { |
| 217 | { |
| 218 | .desc = "reset", |
| 219 | .type = EV_KEY, |
| 220 | .code = BTN_1, |
| 221 | .debounce_interval = LTQ_KEYS_DEBOUNCE_INTERVAL, |
| 222 | .gpio = 30, |
| 223 | .active_low = 1, |
| 224 | }, |
| 225 | { |
| 226 | .desc = "wlan", |
| 227 | .type = EV_KEY, |
| 228 | .code = BTN_2, |
| 229 | .debounce_interval = LTQ_KEYS_DEBOUNCE_INTERVAL, |
| 230 | .gpio = 28, |
| 231 | .active_low = 1, |
| 232 | }, |
| 233 | }; |
| 234 | |
| 235 | static struct gpio_led |
| 236 | arv4520pw_gpio_leds[] __initdata = { |
| 237 | { .name = "soc:blue:power", .gpio = 3, .active_low = 1, }, |
| 238 | { .name = "soc:blue:adsl", .gpio = 4, .active_low = 1, }, |
| 239 | { .name = "soc:blue:internet", .gpio = 5, .active_low = 1, }, |
| 240 | { .name = "soc:red:power", .gpio = 6, .active_low = 1, }, |
| 241 | { .name = "soc:yellow:wps", .gpio = 7, .active_low = 1, }, |
| 242 | { .name = "soc:red:wps", .gpio = 9, .active_low = 1, }, |
| 243 | { .name = "soc:blue:voip", .gpio = 100, .active_low = 1, }, |
| 244 | { .name = "soc:blue:fxs1", .gpio = 101, .active_low = 1, }, |
| 245 | { .name = "soc:blue:fxs2", .gpio = 102, .active_low = 1, }, |
| 246 | { .name = "soc:blue:fxo", .gpio = 103, .active_low = 1, }, |
| 247 | { .name = "soc:blue:voice", .gpio = 104, .active_low = 1, }, |
| 248 | { .name = "soc:blue:usb", .gpio = 105, .active_low = 1, }, |
| 249 | { .name = "soc:blue:wifi", .gpio = 106, .active_low = 1, }, |
| 250 | }; |
| 251 | |
| 252 | static struct gpio_led |
| 253 | arv452cpw_gpio_leds[] __initdata = { |
| 254 | { .name = "soc:blue:power", .gpio = 3, .active_low = 1, .default_trigger = "default-on" }, |
| 255 | { .name = "soc:blue:adsl", .gpio = 4, .active_low = 1, .default_trigger = "default-on" }, |
| 256 | { .name = "soc:blue:isdn", .gpio = 5, .active_low = 1, .default_trigger = "default-on" }, |
| 257 | { .name = "soc:red:power", .gpio = 6, .active_low = 1, .default_trigger = "default-on" }, |
| 258 | { .name = "soc:yellow:wps", .gpio = 7, .active_low = 1, .default_trigger = "default-on" }, |
| 259 | { .name = "soc:red:wps", .gpio = 9, .active_low = 1, .default_trigger = "default-on" }, |
| 260 | { .name = "soc:blue:fxs1", .gpio = 100, .active_low = 1, .default_trigger = "default-on" }, |
| 261 | { .name = "soc:blue:fxs2", .gpio = 101, .active_low = 1, .default_trigger = "default-on" }, |
| 262 | { .name = "soc:blue:wps", .gpio = 102, .active_low = 1, .default_trigger = "default-on" }, |
| 263 | { .name = "soc:blue:fxo", .gpio = 103, .active_low = 1, .default_trigger = "default-on" }, |
| 264 | { .name = "soc:blue:voice", .gpio = 104, .active_low = 1, .default_trigger = "default-on" }, |
| 265 | { .name = "soc:blue:usb", .gpio = 105, .active_low = 1, .default_trigger = "default-on" }, |
| 266 | { .name = "soc:blue:wifi", .gpio = 106, .active_low = 1, .default_trigger = "default-on" }, |
| 267 | { .name = "soc:blue:internet", .gpio = 108, .active_low = 1, .default_trigger = "default-on" }, |
| 268 | { .name = "soc:red:internet", .gpio = 109, .active_low = 1, .default_trigger = "default-on" }, |
| 269 | }; |
| 270 | |
| 271 | static struct gpio_led |
| 272 | arv4525pw_gpio_leds[] __initdata = { |
| 273 | { .name = "soc:green:dsl", .gpio = 6, .active_low = 1, .default_trigger = "default-on" }, |
| 274 | { .name = "soc:green:wifi", .gpio = 8, .active_low = 1, .default_trigger = "default-on" }, |
| 275 | { .name = "soc:green:online", .gpio = 9, .active_low = 1, .default_trigger = "default-on" }, |
| 276 | { .name = "soc:green:fxs-internet", .gpio = 5, .active_low = 1, .default_trigger = "default-on" }, |
| 277 | { .name = "soc:green:fxs-festnetz", .gpio = 4, .active_low = 1, .default_trigger = "default-on" }, |
| 278 | }; |
| 279 | |
| 280 | #define ARV4525PW_PHYRESET 13 |
| 281 | #define ARV4525PW_RELAY 31 |
| 282 | |
| 283 | static struct gpio |
| 284 | arv4525pw_gpios[] __initdata = { |
| 285 | { ARV4525PW_PHYRESET, GPIOF_OUT_INIT_HIGH, "phyreset" }, |
| 286 | { ARV4525PW_RELAY, GPIOF_OUT_INIT_HIGH, "relay" }, |
| 287 | }; |
| 288 | |
| 289 | |
| 290 | static struct gpio_led |
| 291 | arv752dpw22_gpio_leds[] __initdata = { |
| 292 | { .name = "soc:blue:power", .gpio = 3, .active_low = 1, .default_trigger = "default-on" }, |
| 293 | { .name = "soc:red:internet", .gpio = 5, .active_low = 1, .default_trigger = "default-on" }, |
| 294 | { .name = "soc:red:power", .gpio = 6, .active_low = 1, .default_trigger = "default-on" }, |
| 295 | { .name = "soc:red:wps", .gpio = 8, .active_low = 1, .default_trigger = "default-on" }, |
| 296 | { .name = "soc:red:fxo", .gpio = 103, .active_low = 1, .default_trigger = "default-on" }, |
| 297 | { .name = "soc:red:voice", .gpio = 104, .active_low = 1, .default_trigger = "default-on" }, |
| 298 | { .name = "soc:green:usb", .gpio = 105, .active_low = 1, .default_trigger = "default-on" }, |
| 299 | { .name = "soc:green:wifi", .gpio = 106, .active_low = 1, .default_trigger = "default-on" }, |
| 300 | { .name = "soc:green:wifi1", .gpio = 107, .active_low = 1, .default_trigger = "default-on" }, |
| 301 | { .name = "soc:blue:wifi", .gpio = 108, .active_low = 1, .default_trigger = "default-on" }, |
| 302 | { .name = "soc:blue:wifi1", .gpio = 109, .active_low = 1, .default_trigger = "default-on" }, |
| 303 | { .name = "soc:green:eth1", .gpio = 111, .active_low = 1, .default_trigger = "default-on" }, |
| 304 | { .name = "soc:green:eth2", .gpio = 112, .active_low = 1, .default_trigger = "default-on" }, |
| 305 | { .name = "soc:green:eth3", .gpio = 113, .active_low = 1, .default_trigger = "default-on" }, |
| 306 | { .name = "soc:green:eth4", .gpio = 114, .active_low = 1, .default_trigger = "default-on", }, |
| 307 | }; |
| 308 | |
| 309 | static struct gpio_keys_button |
| 310 | arv752dpw22_gpio_keys[] __initdata = { |
| 311 | { |
| 312 | .desc = "btn0", |
| 313 | .type = EV_KEY, |
| 314 | .code = BTN_0, |
| 315 | .debounce_interval = LTQ_KEYS_DEBOUNCE_INTERVAL, |
| 316 | .gpio = 12, |
| 317 | .active_low = 1, |
| 318 | }, |
| 319 | { |
| 320 | .desc = "btn1", |
| 321 | .type = EV_KEY, |
| 322 | .code = BTN_1, |
| 323 | .debounce_interval = LTQ_KEYS_DEBOUNCE_INTERVAL, |
| 324 | .gpio = 13, |
| 325 | .active_low = 1, |
| 326 | }, |
| 327 | { |
| 328 | .desc = "btn2", |
| 329 | .type = EV_KEY, |
| 330 | .code = BTN_2, |
| 331 | .debounce_interval = LTQ_KEYS_DEBOUNCE_INTERVAL, |
| 332 | .gpio = 28, |
| 333 | .active_low = 1, |
| 334 | }, |
| 335 | }; |
| 336 | |
| 337 | static struct gpio_led |
| 338 | arv7518pw_gpio_leds[] __initdata = { |
| 339 | { .name = "soc:red:power", .gpio = 7, .active_low = 1, }, |
| 340 | { .name = "soc:green:power", .gpio = 2, .active_low = 1, .default_trigger = "default-on" }, |
| 341 | { .name = "soc:green:wifi", .gpio = 6, .active_low = 1, }, |
| 342 | { .name = "soc:green:adsl", .gpio = 4, .active_low = 1, }, |
| 343 | { .name = "soc:green:internet", .gpio = 5, .active_low = 1, }, |
| 344 | { .name = "soc:red:internet", .gpio = 8, .active_low = 1, }, |
| 345 | { .name = "soc:green:voip", .gpio = 100, .active_low = 1, }, |
| 346 | { .name = "soc:green:phone1", .gpio = 101, .active_low = 1, }, |
| 347 | { .name = "soc:green:phone2", .gpio = 102, .active_low = 1, }, |
| 348 | { .name = "soc:orange:fail", .gpio = 103, .active_low = 1, }, |
| 349 | { .name = "soc:green:usb", .gpio = 19, .active_low = 1, }, |
| 350 | { .name = "soc:orange:wps", .gpio = 104, .active_low = 1, }, |
| 351 | { .name = "soc:green:wps", .gpio = 105, .active_low = 1, }, |
| 352 | { .name = "soc:red:wps", .gpio = 106, .active_low = 1, }, |
| 353 | |
| 354 | }; |
| 355 | |
| 356 | static struct gpio_keys_button |
| 357 | arv7518pw_gpio_keys[] __initdata = { |
| 358 | /*{ |
| 359 | .desc = "reset", |
| 360 | .type = EV_KEY, |
| 361 | .code = BTN_1, |
| 362 | .debounce_interval = LTQ_KEYS_DEBOUNCE_INTERVAL, |
| 363 | .gpio = 23, |
| 364 | .active_low = 1, |
| 365 | },*/ |
| 366 | { |
| 367 | .desc = "wifi", |
| 368 | .type = EV_KEY, |
| 369 | .code = BTN_2, |
| 370 | .debounce_interval = LTQ_KEYS_DEBOUNCE_INTERVAL, |
| 371 | .gpio = 25, |
| 372 | .active_low = 1, |
| 373 | }, |
| 374 | }; |
| 375 | |
| 376 | static struct gpio_keys_button |
| 377 | arv7525pw_gpio_keys[] __initdata = { |
| 378 | { |
| 379 | .desc = "restart", |
| 380 | .type = EV_KEY, |
| 381 | .code = BTN_0, |
| 382 | .debounce_interval = LTQ_KEYS_DEBOUNCE_INTERVAL, |
| 383 | .gpio = 29, |
| 384 | .active_low = 1, |
| 385 | }, |
| 386 | }; |
| 387 | |
| 388 | static void __init |
| 389 | arv_load_nor(unsigned int max) |
| 390 | { |
| 391 | #define UBOOT_MAGIC 0x27051956 |
| 392 | |
| 393 | int i; |
| 394 | int sector = -1; |
| 395 | |
| 396 | if (ltq_brn_boot) { |
| 397 | if (max == 0x800000) |
| 398 | ltq_register_nor(&arv75xx_brnboot_flash_data); |
| 399 | else |
| 400 | ltq_register_nor(&arv45xx_brnboot_flash_data); |
| 401 | return; |
| 402 | } |
| 403 | |
| 404 | for (i = 1; i < 4 && sector < 0; i++) { |
| 405 | unsigned int uboot_magic; |
| 406 | memcpy_fromio(&uboot_magic, (void *)KSEG1ADDR(LTQ_FLASH_START) + (i * 0x10000), 4); |
| 407 | if (uboot_magic == UBOOT_MAGIC) |
| 408 | sector = i; |
| 409 | } |
| 410 | |
| 411 | if (sector < 0) |
| 412 | return; |
| 413 | |
| 414 | arv_partitions[0].size = arv_partitions[1].offset = (sector - 1) * 0x10000; |
| 415 | arv_partitions[2].offset = arv_partitions[0].size + 0x10000; |
| 416 | arv_partitions[2].size = max - arv_partitions[2].offset - 0x10000; |
| 417 | arv_partitions[3].offset = max - 0x10000; |
| 418 | ltq_register_nor(&arv_flash_data); |
| 419 | } |
| 420 | |
| 421 | static void __init |
| 422 | arv_register_ethernet(unsigned int mac_addr) |
| 423 | { |
| 424 | memcpy_fromio(<q_eth_data.mac.sa_data, |
| 425 | (void *)KSEG1ADDR(LTQ_FLASH_START + mac_addr), 6); |
| 426 | ltq_register_etop(<q_eth_data); |
| 427 | } |
| 428 | |
| 429 | static u16 arv_ath5k_eeprom_data[ATH5K_PLAT_EEP_MAX_WORDS]; |
| 430 | static u16 arv_ath9k_eeprom_data[ATH9K_PLAT_EEP_MAX_WORDS]; |
| 431 | static u8 arv_athxk_eeprom_mac[6]; |
| 432 | |
| 433 | static void __init |
| 434 | arv_register_ath5k(unsigned int ath_addr, unsigned int mac_addr) |
| 435 | { |
| 436 | int i; |
| 437 | |
| 438 | memcpy_fromio(arv_athxk_eeprom_mac, |
| 439 | (void *)KSEG1ADDR(LTQ_FLASH_START + mac_addr), 6); |
| 440 | arv_athxk_eeprom_mac[5]++; |
| 441 | memcpy_fromio(arv_ath5k_eeprom_data, |
| 442 | (void *)KSEG1ADDR(LTQ_FLASH_START + ath_addr), ATH5K_PLAT_EEP_MAX_WORDS); |
| 443 | // swap eeprom bytes |
| 444 | for (i = 0; i < ATH5K_PLAT_EEP_MAX_WORDS>>1; i++) { |
| 445 | arv_ath5k_eeprom_data[i] = swab16(arv_ath5k_eeprom_data[i]); |
| 446 | if (i == 0x17e>>1) { |
| 447 | /* |
| 448 | * regdomain is invalid. it's unknown how did original |
| 449 | * fw convered value to 0x82d4 so for now force to 0x67 |
| 450 | */ |
| 451 | arv_ath5k_eeprom_data[i] &= 0x0000; |
| 452 | arv_ath5k_eeprom_data[i] |= 0x67; |
| 453 | } |
| 454 | } |
| 455 | } |
| 456 | |
| 457 | static void __init |
| 458 | arv_register_ath9k(unsigned int ath_addr, unsigned int mac_addr) |
| 459 | { |
| 460 | int i; |
| 461 | u16 *eepdata, sum, el; |
| 462 | |
| 463 | memcpy_fromio(arv_athxk_eeprom_mac, |
| 464 | (void *)KSEG1ADDR(LTQ_FLASH_START + mac_addr), 6); |
| 465 | arv_athxk_eeprom_mac[5]++; |
| 466 | memcpy_fromio(arv_ath9k_eeprom_data, |
| 467 | (void *)KSEG1ADDR(LTQ_FLASH_START + ath_addr), ATH9K_PLAT_EEP_MAX_WORDS); |
| 468 | |
| 469 | // force regdomain to 0x67 |
| 470 | arv_ath9k_eeprom_data[0x208>>1] = 0x67; |
| 471 | |
| 472 | // calculate new checksum |
| 473 | sum = arv_ath9k_eeprom_data[0x200>>1]; |
| 474 | el = sum / sizeof(u16) - 2; /* skip length and (old) checksum */ |
| 475 | eepdata = (u16 *) (&arv_ath9k_eeprom_data[0x204>>1]); /* after checksum */ |
| 476 | for (i = 0; i < el; i++) |
| 477 | sum ^= *eepdata++; |
| 478 | sum ^= 0xffff; |
| 479 | arv_ath9k_eeprom_data[0x202>>1] = sum; |
| 480 | } |
| 481 | |
| 482 | static void __init |
| 483 | arv3527p_init(void) |
| 484 | { |
| 485 | #define ARV3527P_MAC_ADDR 0x3f0016 |
| 486 | |
| 487 | ltq_register_gpio_stp(); |
| 488 | // ltq_add_device_gpio_leds(arv3527p_gpio_leds, ARRAY_SIZE(arv3527p_gpio_leds)); |
| 489 | arv_load_nor(0x400000); |
| 490 | arv_register_ethernet(ARV3527P_MAC_ADDR); |
| 491 | } |
| 492 | |
| 493 | MIPS_MACHINE(LANTIQ_MACH_ARV3527P, |
| 494 | "ARV3527P", |
| 495 | "ARV3527P - Arcor Easybox 401", |
| 496 | arv3527p_init); |
| 497 | |
| 498 | static void __init |
| 499 | arv4510pw_init(void) |
| 500 | { |
| 501 | #define ARV4510PW_MAC_ADDR 0x3f0014 |
| 502 | |
| 503 | ltq_register_gpio_stp(); |
| 504 | ltq_add_device_gpio_leds(-1, ARRAY_SIZE(arv4510pw_gpio_leds), arv4510pw_gpio_leds); |
| 505 | arv_load_nor(0x400000); |
| 506 | ltq_pci_data.irq[12] = (INT_NUM_IM2_IRL0 + 31); |
| 507 | ltq_pci_data.irq[15] = (INT_NUM_IM0_IRL0 + 26); |
| 508 | ltq_pci_data.gpio |= PCI_EXIN2 | PCI_REQ2; |
| 509 | ltq_register_pci(<q_pci_data); |
| 510 | arv_register_ethernet(ARV4510PW_MAC_ADDR); |
| 511 | } |
| 512 | |
| 513 | MIPS_MACHINE(LANTIQ_MACH_ARV4510PW, |
| 514 | "ARV4510PW", |
| 515 | "ARV4510PW - Wippies Homebox", |
| 516 | arv4510pw_init); |
| 517 | |
| 518 | static void __init |
| 519 | arv4518pw_init(void) |
| 520 | { |
| 521 | #define ARV4518PW_EBU 0 |
| 522 | #define ARV4518PW_USB 14 |
| 523 | #define ARV4518PW_SWITCH_RESET 13 |
| 524 | #define ARV4518PW_ATH_ADDR 0x3f0400 |
| 525 | #define ARV4518PW_MAC_ADDR 0x3f0016 |
| 526 | |
| 527 | ltq_register_gpio_ebu(ARV4518PW_EBU); |
| 528 | ltq_add_device_gpio_leds(-1, ARRAY_SIZE(arv4518pw_gpio_leds), arv4518pw_gpio_leds); |
| 529 | ltq_register_gpio_keys_polled(-1, LTQ_KEYS_POLL_INTERVAL, |
| 530 | ARRAY_SIZE(arv4518pw_gpio_keys), arv4518pw_gpio_keys); |
| 531 | arv_load_nor(0x400000); |
| 532 | ltq_pci_data.gpio = PCI_GNT2 | PCI_REQ2; |
| 533 | ltq_register_pci(<q_pci_data); |
| 534 | xway_register_dwc(ARV4518PW_USB); |
| 535 | arv_register_ethernet(ARV4518PW_MAC_ADDR); |
| 536 | arv_register_ath5k(ARV4518PW_ATH_ADDR, ARV4518PW_MAC_ADDR); |
| 537 | ltq_register_ath5k(arv_ath5k_eeprom_data, arv_athxk_eeprom_mac); |
| 538 | ltq_register_tapi(); |
| 539 | |
| 540 | gpio_request(ARV4518PW_SWITCH_RESET, "switch"); |
| 541 | gpio_direction_output(ARV4518PW_SWITCH_RESET, 1); |
| 542 | gpio_export(ARV4518PW_SWITCH_RESET, 0); |
| 543 | } |
| 544 | |
| 545 | MIPS_MACHINE(LANTIQ_MACH_ARV4518PW, |
| 546 | "ARV4518PW", |
| 547 | "ARV4518PW - SMC7908A-ISP, Airties WAV-221", |
| 548 | arv4518pw_init); |
| 549 | |
| 550 | static void __init |
| 551 | arv4519pw_init(void) |
| 552 | { |
| 553 | #define ARV4519PW_EBU 0 |
| 554 | #define ARV4519PW_USB 14 |
| 555 | #define ARV4519PW_RELAY 31 |
| 556 | #define ARV4519PW_SWITCH_RESET 13 |
| 557 | #define ARV4519PW_ATH_ADDR 0x3f0400 |
| 558 | #define ARV4519PW_MAC_ADDR 0x3f0016 |
| 559 | |
| 560 | arv_load_nor(0x400000); |
| 561 | ltq_register_gpio_ebu(ARV4519PW_EBU); |
| 562 | ltq_add_device_gpio_leds(-1, ARRAY_SIZE(arv4519pw_gpio_leds), arv4519pw_gpio_leds); |
| 563 | ltq_register_gpio_keys_polled(-1, LTQ_KEYS_POLL_INTERVAL, |
| 564 | ARRAY_SIZE(arv4519pw_gpio_keys), arv4519pw_gpio_keys); |
| 565 | ltq_pci_data.gpio = PCI_GNT2 | PCI_REQ1; |
| 566 | ltq_register_pci(<q_pci_data); |
| 567 | xway_register_dwc(ARV4519PW_USB); |
| 568 | arv_register_ethernet(ARV4519PW_MAC_ADDR); |
| 569 | arv_register_ath5k(ARV4519PW_ATH_ADDR, ARV4519PW_MAC_ADDR); |
| 570 | ltq_register_ath5k(arv_ath5k_eeprom_data, arv_athxk_eeprom_mac); |
| 571 | ltq_register_tapi(); |
| 572 | |
| 573 | gpio_request(ARV4519PW_RELAY, "relay"); |
| 574 | gpio_direction_output(ARV4519PW_RELAY, 1); |
| 575 | gpio_export(ARV4519PW_RELAY, 0); |
| 576 | |
| 577 | gpio_request(ARV4519PW_SWITCH_RESET, "switch"); |
| 578 | gpio_set_value(ARV4519PW_SWITCH_RESET, 1); |
| 579 | gpio_export(ARV4519PW_SWITCH_RESET, 0); |
| 580 | } |
| 581 | |
| 582 | MIPS_MACHINE(LANTIQ_MACH_ARV4519PW, |
| 583 | "ARV4519PW", |
| 584 | "ARV4519PW - Vodafone, Pirelli", |
| 585 | arv4519pw_init); |
| 586 | |
| 587 | static void __init |
| 588 | arv4520pw_init(void) |
| 589 | { |
| 590 | #define ARV4520PW_EBU 0x400 |
| 591 | #define ARV4520PW_USB 28 |
| 592 | #define ARV4520PW_SWITCH_RESET 110 |
| 593 | #define ARV4520PW_MAC_ADDR 0x3f0016 |
| 594 | |
| 595 | ltq_register_gpio_ebu(ARV4520PW_EBU); |
| 596 | ltq_add_device_gpio_leds(-1, ARRAY_SIZE(arv4520pw_gpio_leds), arv4520pw_gpio_leds); |
| 597 | arv_load_nor(0x400000); |
| 598 | ltq_register_pci(<q_pci_data); |
| 599 | ltq_register_tapi(); |
| 600 | arv_register_ethernet(ARV4520PW_MAC_ADDR); |
| 601 | ltq_register_rt2x00(NULL, (const u8 *) ltq_eth_data.mac.sa_data); |
| 602 | xway_register_dwc(ARV4520PW_USB); |
| 603 | ltq_register_tapi(); |
| 604 | |
| 605 | gpio_request(ARV4520PW_SWITCH_RESET, "switch"); |
| 606 | gpio_set_value(ARV4520PW_SWITCH_RESET, 1); |
| 607 | } |
| 608 | |
| 609 | MIPS_MACHINE(LANTIQ_MACH_ARV4520PW, |
| 610 | "ARV4520PW", |
| 611 | "ARV4520PW - Airties WAV-281, Arcor A800", |
| 612 | arv4520pw_init); |
| 613 | |
| 614 | static void __init |
| 615 | arv452Cpw_init(void) |
| 616 | { |
| 617 | #define ARV452CPW_EBU 0x77f |
| 618 | #define ARV452CPW_USB 28 |
| 619 | #define ARV452CPW_RELAY1 31 |
| 620 | #define ARV452CPW_RELAY2 107 |
| 621 | #define ARV452CPW_SWITCH_RESET 110 |
| 622 | #define ARV452CPW_ATH_ADDR 0x3f0400 |
| 623 | #define ARV452CPW_MAC_ADDR 0x3f0016 |
| 624 | |
| 625 | ltq_register_gpio_ebu(ARV452CPW_EBU); |
| 626 | ltq_add_device_gpio_leds(-1, ARRAY_SIZE(arv452cpw_gpio_leds), arv452cpw_gpio_leds); |
| 627 | arv_load_nor(0x400000); |
| 628 | ltq_register_pci(<q_pci_data); |
| 629 | xway_register_dwc(ARV452CPW_USB); |
| 630 | arv_register_ethernet(ARV452CPW_MAC_ADDR); |
| 631 | arv_register_ath5k(ARV452CPW_ATH_ADDR, ARV452CPW_MAC_ADDR); |
| 632 | ltq_register_ath5k(arv_ath5k_eeprom_data, arv_athxk_eeprom_mac); |
| 633 | ltq_register_tapi(); |
| 634 | |
| 635 | gpio_request(ARV452CPW_SWITCH_RESET, "switch"); |
| 636 | gpio_set_value(ARV452CPW_SWITCH_RESET, 1); |
| 637 | gpio_export(ARV452CPW_SWITCH_RESET, 0); |
| 638 | |
| 639 | gpio_request(ARV452CPW_RELAY1, "relay1"); |
| 640 | gpio_direction_output(ARV452CPW_RELAY1, 1); |
| 641 | gpio_export(ARV452CPW_RELAY1, 0); |
| 642 | |
| 643 | gpio_request(ARV452CPW_RELAY2, "relay2"); |
| 644 | gpio_set_value(ARV452CPW_RELAY2, 1); |
| 645 | gpio_export(ARV452CPW_RELAY2, 0); |
| 646 | } |
| 647 | |
| 648 | MIPS_MACHINE(LANTIQ_MACH_ARV452CPW, |
| 649 | "ARV452CPW", |
| 650 | "ARV452CPW - Arcor A801", |
| 651 | arv452Cpw_init); |
| 652 | |
| 653 | static void __init |
| 654 | arv4525pw_init(void) |
| 655 | { |
| 656 | #define ARV4525PW_ATH_ADDR 0x3f0400 |
| 657 | #define ARV4525PW_MAC_ADDR 0x3f0016 |
| 658 | |
| 659 | arv_load_nor(0x400000); |
| 660 | ltq_add_device_gpio_leds(-1, ARRAY_SIZE(arv4525pw_gpio_leds), arv4525pw_gpio_leds); |
| 661 | gpio_request_array(arv4525pw_gpios, ARRAY_SIZE(arv4525pw_gpios)); |
| 662 | gpio_export(ARV4525PW_RELAY, false); |
| 663 | gpio_export(ARV4525PW_PHYRESET, false); |
| 664 | ltq_pci_data.clock = PCI_CLOCK_INT; |
| 665 | ltq_register_pci(<q_pci_data); |
| 666 | arv_register_ath5k(ARV4525PW_ATH_ADDR, ARV4525PW_MAC_ADDR); |
| 667 | ltq_register_ath5k(arv_ath5k_eeprom_data, arv_athxk_eeprom_mac); |
| 668 | ltq_eth_data.mii_mode = PHY_INTERFACE_MODE_MII; |
| 669 | arv_register_ethernet(ARV4525PW_MAC_ADDR); |
| 670 | ltq_register_tapi(); |
| 671 | } |
| 672 | |
| 673 | MIPS_MACHINE(LANTIQ_MACH_ARV4525PW, |
| 674 | "ARV4525PW", |
| 675 | "ARV4525PW - Speedport W502V", |
| 676 | arv4525pw_init); |
| 677 | |
| 678 | static void __init |
| 679 | arv7525pw_init(void) |
| 680 | { |
| 681 | #define ARV7525P_MAC_ADDR 0x3f0016 |
| 682 | |
| 683 | arv_load_nor(0x400000); |
| 684 | ltq_add_device_gpio_leds(-1, ARRAY_SIZE(arv4525pw_gpio_leds), arv4525pw_gpio_leds); |
| 685 | ltq_register_gpio_keys_polled(-1, LTQ_KEYS_POLL_INTERVAL, |
| 686 | ARRAY_SIZE(arv7525pw_gpio_keys), arv7525pw_gpio_keys); |
| 687 | ltq_pci_data.clock = PCI_CLOCK_INT; |
| 688 | ltq_pci_data.gpio = PCI_GNT1 | PCI_EXIN1; |
| 689 | ltq_pci_data.irq[14] = (INT_NUM_IM3_IRL0 + 31); |
| 690 | ltq_register_pci(<q_pci_data); |
| 691 | ltq_eth_data.mii_mode = PHY_INTERFACE_MODE_MII; |
| 692 | ltq_register_rt2x00("RT2860.eeprom", NULL); |
| 693 | ltq_register_tapi(); |
| 694 | arv_register_ethernet(ARV7525P_MAC_ADDR); |
| 695 | } |
| 696 | |
| 697 | MIPS_MACHINE(LANTIQ_MACH_ARV7525PW, |
| 698 | "ARV7525PW", |
| 699 | "ARV7525PW - Speedport W303V", |
| 700 | arv7525pw_init); |
| 701 | |
| 702 | static void __init |
| 703 | arv7518pw_init(void) |
| 704 | { |
| 705 | #define ARV7518PW_EBU 0x2 |
| 706 | #define ARV7518PW_USB 14 |
| 707 | #define ARV7518PW_SWITCH_RESET 13 |
| 708 | #define ARV7518PW_ATH_ADDR 0x7f0400 |
| 709 | #define ARV7518PW_MAC_ADDR 0x7f0016 |
| 710 | |
| 711 | arv_load_nor(0x800000); |
| 712 | ltq_register_gpio_ebu(ARV7518PW_EBU); |
| 713 | ltq_add_device_gpio_leds(-1, ARRAY_SIZE(arv7518pw_gpio_leds), arv7518pw_gpio_leds); |
| 714 | ltq_register_gpio_keys_polled(-1, LTQ_KEYS_POLL_INTERVAL, |
| 715 | ARRAY_SIZE(arv7518pw_gpio_keys), arv7518pw_gpio_keys); |
| 716 | ltq_register_pci(<q_pci_data); |
| 717 | ltq_register_tapi(); |
| 718 | xway_register_dwc(ARV7518PW_USB); |
| 719 | arv_register_ethernet(ARV7518PW_MAC_ADDR); |
| 720 | arv_register_ath9k(ARV7518PW_ATH_ADDR, ARV7518PW_MAC_ADDR); |
| 721 | ltq_register_ath9k(arv_ath9k_eeprom_data, arv_athxk_eeprom_mac); |
| 722 | ltq_pci_ath_fixup(14, arv_ath9k_eeprom_data); |
| 723 | ltq_register_tapi(); |
| 724 | |
| 725 | gpio_request(ARV7518PW_SWITCH_RESET, "switch"); |
| 726 | gpio_direction_output(ARV7518PW_SWITCH_RESET, 1); |
| 727 | gpio_export(ARV7518PW_SWITCH_RESET, 0); |
| 728 | } |
| 729 | |
| 730 | MIPS_MACHINE(LANTIQ_MACH_ARV7518PW, |
| 731 | "ARV7518PW", |
| 732 | "ARV7518PW - ASTORIA", |
| 733 | arv7518pw_init); |
| 734 | |
| 735 | static void __init |
| 736 | arv752dpw22_init(void) |
| 737 | { |
| 738 | #define ARV752DPW22_EBU 0x2 |
| 739 | #define ARV752DPW22_USB 100 |
| 740 | #define ARV752DPW22_RELAY 101 |
| 741 | #define ARV752DPW22_MAC_ADDR 0x7f0016 |
| 742 | |
| 743 | arv_load_nor(0x800000); |
| 744 | ltq_register_gpio_ebu(ARV752DPW22_EBU); |
| 745 | ltq_add_device_gpio_leds(-1, ARRAY_SIZE(arv752dpw22_gpio_leds), arv752dpw22_gpio_leds); |
| 746 | ltq_register_gpio_keys_polled(-1, LTQ_KEYS_POLL_INTERVAL, |
| 747 | ARRAY_SIZE(arv752dpw22_gpio_keys), arv752dpw22_gpio_keys); |
| 748 | ltq_pci_data.irq[15] = (INT_NUM_IM3_IRL0 + 31); |
| 749 | ltq_pci_data.gpio |= PCI_EXIN1 | PCI_REQ2; |
| 750 | ltq_register_pci(<q_pci_data); |
| 751 | xway_register_dwc(ARV752DPW22_USB); |
| 752 | arv_register_ethernet(ARV752DPW22_MAC_ADDR); |
| 753 | ltq_register_tapi(); |
| 754 | |
| 755 | gpio_request(ARV752DPW22_RELAY, "relay"); |
| 756 | gpio_set_value(ARV752DPW22_RELAY, 1); |
| 757 | gpio_export(ARV752DPW22_RELAY, 0); |
| 758 | } |
| 759 | |
| 760 | MIPS_MACHINE(LANTIQ_MACH_ARV752DPW22, |
| 761 | "ARV752DPW22", |
| 762 | "ARV752DPW22 - Arcor A803", |
| 763 | arv752dpw22_init); |
| 764 | |
| 765 | static void __init |
| 766 | arv752dpw_init(void) |
| 767 | { |
| 768 | #define ARV752DPW22_EBU 0x2 |
| 769 | #define ARV752DPW22_USB 100 |
| 770 | #define ARV752DPW22_RELAY 101 |
| 771 | #define ARV752DPW22_MAC_ADDR 0x7f0016 |
| 772 | |
| 773 | arv_load_nor(0x800000); |
| 774 | ltq_register_gpio_ebu(ARV752DPW22_EBU); |
| 775 | ltq_add_device_gpio_leds(-1, ARRAY_SIZE(arv752dpw22_gpio_leds), arv752dpw22_gpio_leds); |
| 776 | ltq_register_gpio_keys_polled(-1, LTQ_KEYS_POLL_INTERVAL, ARRAY_SIZE(arv752dpw22_gpio_keys), arv752dpw22_gpio_keys); |
| 777 | ltq_pci_data.irq[14] = (INT_NUM_IM3_IRL0 + 31); |
| 778 | ltq_pci_data.gpio |= PCI_EXIN1 | PCI_REQ2; |
| 779 | ltq_register_pci(<q_pci_data); |
| 780 | ltq_register_tapi(); |
| 781 | xway_register_dwc(ARV752DPW22_USB); |
| 782 | ltq_register_rt2x00("RT2860.eeprom", NULL); |
| 783 | arv_register_ethernet(ARV752DPW22_MAC_ADDR); |
| 784 | gpio_request(ARV752DPW22_RELAY, "relay"); |
| 785 | gpio_set_value(ARV752DPW22_RELAY, 1); |
| 786 | gpio_export(ARV752DPW22_RELAY, 0); |
| 787 | |
| 788 | } |
| 789 | |
| 790 | MIPS_MACHINE(LANTIQ_MACH_ARV752DPW, |
| 791 | "ARV752DPW", |
| 792 | "ARV752DPW - Arcor A802", |
| 793 | arv752dpw_init); |
| 794 | |