Florian Fainelli | 7ca5dc1 | 2009-06-24 11:12:57 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006,2007 Felix Fietkau <nbd@openwrt.org> |
| 3 | * Copyright (C) 2006,2007 Eugene Konev <ejka@openwrt.org> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | */ |
| 19 | |
| 20 | #include <linux/init.h> |
| 21 | #include <linux/types.h> |
| 22 | #include <linux/module.h> |
| 23 | #include <linux/delay.h> |
| 24 | #include <linux/dma-mapping.h> |
| 25 | #include <linux/platform_device.h> |
| 26 | #include <linux/mtd/physmap.h> |
| 27 | #include <linux/serial.h> |
| 28 | #include <linux/serial_8250.h> |
| 29 | #include <linux/ioport.h> |
| 30 | #include <linux/io.h> |
Florian Fainelli | 7ca5dc1 | 2009-06-24 11:12:57 +0200 | [diff] [blame] | 31 | #include <linux/vlynq.h> |
| 32 | #include <linux/leds.h> |
| 33 | #include <linux/string.h> |
| 34 | #include <linux/etherdevice.h> |
Florian Fainelli | 1e2c8d8 | 2009-08-04 10:52:47 +0000 | [diff] [blame] | 35 | #include <linux/phy.h> |
| 36 | #include <linux/phy_fixed.h> |
Florian Fainelli | 5f3c909 | 2010-01-03 21:16:51 +0100 | [diff] [blame] | 37 | #include <linux/gpio.h> |
Florian Fainelli | 780019d | 2010-01-27 09:10:06 +0100 | [diff] [blame^] | 38 | #include <linux/clk.h> |
Florian Fainelli | 7ca5dc1 | 2009-06-24 11:12:57 +0200 | [diff] [blame] | 39 | |
| 40 | #include <asm/addrspace.h> |
| 41 | #include <asm/mach-ar7/ar7.h> |
| 42 | #include <asm/mach-ar7/gpio.h> |
| 43 | #include <asm/mach-ar7/prom.h> |
| 44 | |
| 45 | struct plat_vlynq_data { |
| 46 | struct plat_vlynq_ops ops; |
| 47 | int gpio_bit; |
| 48 | int reset_bit; |
| 49 | }; |
| 50 | |
| 51 | |
| 52 | static int vlynq_on(struct vlynq_device *dev) |
| 53 | { |
| 54 | int result; |
| 55 | struct plat_vlynq_data *pdata = dev->dev.platform_data; |
| 56 | |
| 57 | result = gpio_request(pdata->gpio_bit, "vlynq"); |
| 58 | if (result) |
| 59 | goto out; |
| 60 | |
| 61 | ar7_device_reset(pdata->reset_bit); |
| 62 | |
| 63 | result = ar7_gpio_disable(pdata->gpio_bit); |
| 64 | if (result) |
| 65 | goto out_enabled; |
| 66 | |
| 67 | result = ar7_gpio_enable(pdata->gpio_bit); |
| 68 | if (result) |
| 69 | goto out_enabled; |
| 70 | |
| 71 | result = gpio_direction_output(pdata->gpio_bit, 0); |
| 72 | if (result) |
| 73 | goto out_gpio_enabled; |
| 74 | |
| 75 | msleep(50); |
| 76 | |
| 77 | gpio_set_value(pdata->gpio_bit, 1); |
| 78 | msleep(50); |
| 79 | |
| 80 | return 0; |
| 81 | |
| 82 | out_gpio_enabled: |
| 83 | ar7_gpio_disable(pdata->gpio_bit); |
| 84 | out_enabled: |
| 85 | ar7_device_disable(pdata->reset_bit); |
| 86 | gpio_free(pdata->gpio_bit); |
| 87 | out: |
| 88 | return result; |
| 89 | } |
| 90 | |
| 91 | static void vlynq_off(struct vlynq_device *dev) |
| 92 | { |
| 93 | struct plat_vlynq_data *pdata = dev->dev.platform_data; |
| 94 | ar7_gpio_disable(pdata->gpio_bit); |
| 95 | gpio_free(pdata->gpio_bit); |
| 96 | ar7_device_disable(pdata->reset_bit); |
| 97 | } |
| 98 | |
| 99 | static struct resource physmap_flash_resource = { |
| 100 | .name = "mem", |
| 101 | .flags = IORESOURCE_MEM, |
| 102 | .start = 0x10000000, |
| 103 | .end = 0x107fffff, |
| 104 | }; |
| 105 | |
| 106 | static struct resource cpmac_low_res[] = { |
| 107 | { |
| 108 | .name = "regs", |
| 109 | .flags = IORESOURCE_MEM, |
| 110 | .start = AR7_REGS_MAC0, |
| 111 | .end = AR7_REGS_MAC0 + 0x7ff, |
| 112 | }, |
| 113 | { |
| 114 | .name = "irq", |
| 115 | .flags = IORESOURCE_IRQ, |
| 116 | .start = 27, |
| 117 | .end = 27, |
| 118 | }, |
| 119 | }; |
| 120 | |
| 121 | static struct resource cpmac_high_res[] = { |
| 122 | { |
| 123 | .name = "regs", |
| 124 | .flags = IORESOURCE_MEM, |
| 125 | .start = AR7_REGS_MAC1, |
| 126 | .end = AR7_REGS_MAC1 + 0x7ff, |
| 127 | }, |
| 128 | { |
| 129 | .name = "irq", |
| 130 | .flags = IORESOURCE_IRQ, |
| 131 | .start = 41, |
| 132 | .end = 41, |
| 133 | }, |
| 134 | }; |
| 135 | |
| 136 | static struct resource vlynq_low_res[] = { |
| 137 | { |
| 138 | .name = "regs", |
| 139 | .flags = IORESOURCE_MEM, |
| 140 | .start = AR7_REGS_VLYNQ0, |
| 141 | .end = AR7_REGS_VLYNQ0 + 0xff, |
| 142 | }, |
| 143 | { |
| 144 | .name = "irq", |
| 145 | .flags = IORESOURCE_IRQ, |
| 146 | .start = 29, |
| 147 | .end = 29, |
| 148 | }, |
| 149 | { |
| 150 | .name = "mem", |
| 151 | .flags = IORESOURCE_MEM, |
| 152 | .start = 0x04000000, |
| 153 | .end = 0x04ffffff, |
| 154 | }, |
| 155 | { |
| 156 | .name = "devirq", |
| 157 | .flags = IORESOURCE_IRQ, |
| 158 | .start = 80, |
| 159 | .end = 111, |
| 160 | }, |
| 161 | }; |
| 162 | |
| 163 | static struct resource vlynq_high_res[] = { |
| 164 | { |
| 165 | .name = "regs", |
| 166 | .flags = IORESOURCE_MEM, |
| 167 | .start = AR7_REGS_VLYNQ1, |
| 168 | .end = AR7_REGS_VLYNQ1 + 0xff, |
| 169 | }, |
| 170 | { |
| 171 | .name = "irq", |
| 172 | .flags = IORESOURCE_IRQ, |
| 173 | .start = 33, |
| 174 | .end = 33, |
| 175 | }, |
| 176 | { |
| 177 | .name = "mem", |
| 178 | .flags = IORESOURCE_MEM, |
| 179 | .start = 0x0c000000, |
| 180 | .end = 0x0cffffff, |
| 181 | }, |
| 182 | { |
| 183 | .name = "devirq", |
| 184 | .flags = IORESOURCE_IRQ, |
| 185 | .start = 112, |
| 186 | .end = 143, |
| 187 | }, |
| 188 | }; |
| 189 | |
| 190 | static struct resource usb_res[] = { |
| 191 | { |
| 192 | .name = "regs", |
| 193 | .flags = IORESOURCE_MEM, |
| 194 | .start = AR7_REGS_USB, |
| 195 | .end = AR7_REGS_USB + 0xff, |
| 196 | }, |
| 197 | { |
| 198 | .name = "irq", |
| 199 | .flags = IORESOURCE_IRQ, |
| 200 | .start = 32, |
| 201 | .end = 32, |
| 202 | }, |
| 203 | { |
| 204 | .name = "mem", |
| 205 | .flags = IORESOURCE_MEM, |
| 206 | .start = 0x03400000, |
Alexander Clouter | ba284b1 | 2010-01-31 19:38:52 +0000 | [diff] [blame] | 207 | .end = 0x03401fff, |
Florian Fainelli | 7ca5dc1 | 2009-06-24 11:12:57 +0200 | [diff] [blame] | 208 | }, |
| 209 | }; |
| 210 | |
| 211 | static struct physmap_flash_data physmap_flash_data = { |
| 212 | .width = 2, |
| 213 | }; |
| 214 | |
Florian Fainelli | 1e2c8d8 | 2009-08-04 10:52:47 +0000 | [diff] [blame] | 215 | static struct fixed_phy_status fixed_phy_status __initdata = { |
| 216 | .link = 1, |
| 217 | .speed = 100, |
| 218 | .duplex = 1, |
| 219 | }; |
| 220 | |
Florian Fainelli | 7ca5dc1 | 2009-06-24 11:12:57 +0200 | [diff] [blame] | 221 | static struct plat_cpmac_data cpmac_low_data = { |
| 222 | .reset_bit = 17, |
| 223 | .power_bit = 20, |
| 224 | .phy_mask = 0x80000000, |
| 225 | }; |
| 226 | |
| 227 | static struct plat_cpmac_data cpmac_high_data = { |
| 228 | .reset_bit = 21, |
| 229 | .power_bit = 22, |
| 230 | .phy_mask = 0x7fffffff, |
| 231 | }; |
| 232 | |
| 233 | static struct plat_vlynq_data vlynq_low_data = { |
| 234 | .ops.on = vlynq_on, |
| 235 | .ops.off = vlynq_off, |
| 236 | .reset_bit = 20, |
| 237 | .gpio_bit = 18, |
| 238 | }; |
| 239 | |
| 240 | static struct plat_vlynq_data vlynq_high_data = { |
| 241 | .ops.on = vlynq_on, |
| 242 | .ops.off = vlynq_off, |
| 243 | .reset_bit = 16, |
| 244 | .gpio_bit = 19, |
| 245 | }; |
| 246 | |
| 247 | static struct platform_device physmap_flash = { |
| 248 | .id = 0, |
| 249 | .name = "physmap-flash", |
| 250 | .dev.platform_data = &physmap_flash_data, |
| 251 | .resource = &physmap_flash_resource, |
| 252 | .num_resources = 1, |
| 253 | }; |
| 254 | |
Florian Fainelli | 8e84c14 | 2009-07-24 13:18:16 +0200 | [diff] [blame] | 255 | static u64 cpmac_dma_mask = DMA_BIT_MASK(32); |
Florian Fainelli | 7ca5dc1 | 2009-06-24 11:12:57 +0200 | [diff] [blame] | 256 | static struct platform_device cpmac_low = { |
| 257 | .id = 0, |
| 258 | .name = "cpmac", |
| 259 | .dev = { |
| 260 | .dma_mask = &cpmac_dma_mask, |
Florian Fainelli | 8e84c14 | 2009-07-24 13:18:16 +0200 | [diff] [blame] | 261 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Florian Fainelli | 7ca5dc1 | 2009-06-24 11:12:57 +0200 | [diff] [blame] | 262 | .platform_data = &cpmac_low_data, |
| 263 | }, |
| 264 | .resource = cpmac_low_res, |
| 265 | .num_resources = ARRAY_SIZE(cpmac_low_res), |
| 266 | }; |
| 267 | |
| 268 | static struct platform_device cpmac_high = { |
| 269 | .id = 1, |
| 270 | .name = "cpmac", |
| 271 | .dev = { |
| 272 | .dma_mask = &cpmac_dma_mask, |
Florian Fainelli | 8e84c14 | 2009-07-24 13:18:16 +0200 | [diff] [blame] | 273 | .coherent_dma_mask = DMA_BIT_MASK(32), |
Florian Fainelli | 7ca5dc1 | 2009-06-24 11:12:57 +0200 | [diff] [blame] | 274 | .platform_data = &cpmac_high_data, |
| 275 | }, |
| 276 | .resource = cpmac_high_res, |
| 277 | .num_resources = ARRAY_SIZE(cpmac_high_res), |
| 278 | }; |
| 279 | |
| 280 | static struct platform_device vlynq_low = { |
| 281 | .id = 0, |
| 282 | .name = "vlynq", |
| 283 | .dev.platform_data = &vlynq_low_data, |
| 284 | .resource = vlynq_low_res, |
| 285 | .num_resources = ARRAY_SIZE(vlynq_low_res), |
| 286 | }; |
| 287 | |
| 288 | static struct platform_device vlynq_high = { |
| 289 | .id = 1, |
| 290 | .name = "vlynq", |
| 291 | .dev.platform_data = &vlynq_high_data, |
| 292 | .resource = vlynq_high_res, |
| 293 | .num_resources = ARRAY_SIZE(vlynq_high_res), |
| 294 | }; |
| 295 | |
| 296 | |
| 297 | static struct gpio_led default_leds[] = { |
| 298 | { |
| 299 | .name = "status", |
| 300 | .gpio = 8, |
| 301 | .active_low = 1, |
| 302 | }, |
| 303 | }; |
| 304 | |
| 305 | static struct gpio_led dsl502t_leds[] = { |
| 306 | { |
| 307 | .name = "status", |
| 308 | .gpio = 9, |
| 309 | .active_low = 1, |
| 310 | }, |
| 311 | { |
| 312 | .name = "ethernet", |
| 313 | .gpio = 7, |
| 314 | .active_low = 1, |
| 315 | }, |
| 316 | { |
| 317 | .name = "usb", |
| 318 | .gpio = 12, |
| 319 | .active_low = 1, |
| 320 | }, |
| 321 | }; |
| 322 | |
| 323 | static struct gpio_led dg834g_leds[] = { |
| 324 | { |
| 325 | .name = "ppp", |
| 326 | .gpio = 6, |
| 327 | .active_low = 1, |
| 328 | }, |
| 329 | { |
| 330 | .name = "status", |
| 331 | .gpio = 7, |
| 332 | .active_low = 1, |
| 333 | }, |
| 334 | { |
| 335 | .name = "adsl", |
| 336 | .gpio = 8, |
| 337 | .active_low = 1, |
| 338 | }, |
| 339 | { |
| 340 | .name = "wifi", |
| 341 | .gpio = 12, |
| 342 | .active_low = 1, |
| 343 | }, |
| 344 | { |
| 345 | .name = "power", |
| 346 | .gpio = 14, |
| 347 | .active_low = 1, |
| 348 | .default_trigger = "default-on", |
| 349 | }, |
| 350 | }; |
| 351 | |
| 352 | static struct gpio_led fb_sl_leds[] = { |
| 353 | { |
| 354 | .name = "1", |
| 355 | .gpio = 7, |
| 356 | }, |
| 357 | { |
| 358 | .name = "2", |
| 359 | .gpio = 13, |
| 360 | .active_low = 1, |
| 361 | }, |
| 362 | { |
| 363 | .name = "3", |
| 364 | .gpio = 10, |
| 365 | .active_low = 1, |
| 366 | }, |
| 367 | { |
| 368 | .name = "4", |
| 369 | .gpio = 12, |
| 370 | .active_low = 1, |
| 371 | }, |
| 372 | { |
| 373 | .name = "5", |
| 374 | .gpio = 9, |
| 375 | .active_low = 1, |
| 376 | }, |
| 377 | }; |
| 378 | |
| 379 | static struct gpio_led fb_fon_leds[] = { |
| 380 | { |
| 381 | .name = "1", |
| 382 | .gpio = 8, |
| 383 | }, |
| 384 | { |
| 385 | .name = "2", |
| 386 | .gpio = 3, |
| 387 | .active_low = 1, |
| 388 | }, |
| 389 | { |
| 390 | .name = "3", |
| 391 | .gpio = 5, |
| 392 | }, |
| 393 | { |
| 394 | .name = "4", |
| 395 | .gpio = 4, |
| 396 | .active_low = 1, |
| 397 | }, |
| 398 | { |
| 399 | .name = "5", |
| 400 | .gpio = 11, |
| 401 | .active_low = 1, |
| 402 | }, |
| 403 | }; |
| 404 | |
| 405 | static struct gpio_led_platform_data ar7_led_data; |
| 406 | |
| 407 | static struct platform_device ar7_gpio_leds = { |
| 408 | .name = "leds-gpio", |
| 409 | .id = -1, |
| 410 | .dev = { |
| 411 | .platform_data = &ar7_led_data, |
| 412 | } |
| 413 | }; |
| 414 | |
| 415 | static struct platform_device ar7_udc = { |
| 416 | .id = -1, |
| 417 | .name = "ar7_udc", |
| 418 | .resource = usb_res, |
| 419 | .num_resources = ARRAY_SIZE(usb_res), |
| 420 | }; |
| 421 | |
Florian Fainelli | d47fbb5 | 2009-07-15 12:09:34 +0200 | [diff] [blame] | 422 | static struct resource ar7_wdt_res = { |
| 423 | .name = "regs", |
| 424 | .start = -1, /* Filled at runtime */ |
| 425 | .end = -1, /* Filled at runtime */ |
| 426 | .flags = IORESOURCE_MEM, |
| 427 | }; |
| 428 | |
| 429 | static struct platform_device ar7_wdt = { |
| 430 | .id = -1, |
| 431 | .name = "ar7_wdt", |
| 432 | .resource = &ar7_wdt_res, |
| 433 | .num_resources = 1, |
| 434 | }; |
| 435 | |
Florian Fainelli | 7ca5dc1 | 2009-06-24 11:12:57 +0200 | [diff] [blame] | 436 | static inline unsigned char char2hex(char h) |
| 437 | { |
| 438 | switch (h) { |
| 439 | case '0': case '1': case '2': case '3': case '4': |
| 440 | case '5': case '6': case '7': case '8': case '9': |
| 441 | return h - '0'; |
| 442 | case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': |
| 443 | return h - 'A' + 10; |
| 444 | case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': |
| 445 | return h - 'a' + 10; |
| 446 | default: |
| 447 | return 0; |
| 448 | } |
| 449 | } |
| 450 | |
| 451 | static void cpmac_get_mac(int instance, unsigned char *dev_addr) |
| 452 | { |
| 453 | int i; |
| 454 | char name[5], default_mac[ETH_ALEN], *mac; |
| 455 | |
| 456 | mac = NULL; |
| 457 | sprintf(name, "mac%c", 'a' + instance); |
| 458 | mac = prom_getenv(name); |
| 459 | if (!mac) { |
| 460 | sprintf(name, "mac%c", 'a'); |
| 461 | mac = prom_getenv(name); |
| 462 | } |
| 463 | if (!mac) { |
| 464 | random_ether_addr(default_mac); |
| 465 | mac = default_mac; |
| 466 | } |
| 467 | for (i = 0; i < 6; i++) |
| 468 | dev_addr[i] = (char2hex(mac[i * 3]) << 4) + |
| 469 | char2hex(mac[i * 3 + 1]); |
| 470 | } |
| 471 | |
| 472 | static void __init detect_leds(void) |
| 473 | { |
| 474 | char *prid, *usb_prod; |
| 475 | |
| 476 | /* Default LEDs */ |
| 477 | ar7_led_data.num_leds = ARRAY_SIZE(default_leds); |
| 478 | ar7_led_data.leds = default_leds; |
| 479 | |
| 480 | /* FIXME: the whole thing is unreliable */ |
| 481 | prid = prom_getenv("ProductID"); |
| 482 | usb_prod = prom_getenv("usb_prod"); |
| 483 | |
| 484 | /* If we can't get the product id from PROM, use the default LEDs */ |
| 485 | if (!prid) |
| 486 | return; |
| 487 | |
| 488 | if (strstr(prid, "Fritz_Box_FON")) { |
| 489 | ar7_led_data.num_leds = ARRAY_SIZE(fb_fon_leds); |
| 490 | ar7_led_data.leds = fb_fon_leds; |
| 491 | } else if (strstr(prid, "Fritz_Box_")) { |
| 492 | ar7_led_data.num_leds = ARRAY_SIZE(fb_sl_leds); |
| 493 | ar7_led_data.leds = fb_sl_leds; |
| 494 | } else if ((!strcmp(prid, "AR7RD") || !strcmp(prid, "AR7DB")) |
| 495 | && usb_prod != NULL && strstr(usb_prod, "DSL-502T")) { |
| 496 | ar7_led_data.num_leds = ARRAY_SIZE(dsl502t_leds); |
| 497 | ar7_led_data.leds = dsl502t_leds; |
| 498 | } else if (strstr(prid, "DG834")) { |
| 499 | ar7_led_data.num_leds = ARRAY_SIZE(dg834g_leds); |
| 500 | ar7_led_data.leds = dg834g_leds; |
| 501 | } |
| 502 | } |
| 503 | |
| 504 | static int __init ar7_register_devices(void) |
| 505 | { |
Florian Fainelli | d47fbb5 | 2009-07-15 12:09:34 +0200 | [diff] [blame] | 506 | u16 chip_id; |
Florian Fainelli | 7ca5dc1 | 2009-06-24 11:12:57 +0200 | [diff] [blame] | 507 | int res; |
Florian Fainelli | 72838a1 | 2009-08-04 23:09:36 +0200 | [diff] [blame] | 508 | u32 *bootcr, val; |
Florian Fainelli | 50ca961 | 2009-07-24 13:24:15 +0200 | [diff] [blame] | 509 | #ifdef CONFIG_SERIAL_8250 |
Dmitri Vorobiev | 599a894 | 2009-11-23 13:53:37 +0200 | [diff] [blame] | 510 | static struct uart_port uart_port[2] __initdata; |
Florian Fainelli | 780019d | 2010-01-27 09:10:06 +0100 | [diff] [blame^] | 511 | struct clk *bus_clk; |
Florian Fainelli | 7ca5dc1 | 2009-06-24 11:12:57 +0200 | [diff] [blame] | 512 | |
| 513 | memset(uart_port, 0, sizeof(struct uart_port) * 2); |
| 514 | |
Florian Fainelli | 780019d | 2010-01-27 09:10:06 +0100 | [diff] [blame^] | 515 | bus_clk = clk_get(NULL, "bus"); |
| 516 | if (IS_ERR(bus_clk)) |
| 517 | panic("unable to get bus clk\n"); |
| 518 | |
Florian Fainelli | 7ca5dc1 | 2009-06-24 11:12:57 +0200 | [diff] [blame] | 519 | uart_port[0].type = PORT_16550A; |
| 520 | uart_port[0].line = 0; |
| 521 | uart_port[0].irq = AR7_IRQ_UART0; |
Florian Fainelli | 780019d | 2010-01-27 09:10:06 +0100 | [diff] [blame^] | 522 | uart_port[0].uartclk = clk_get_rate(bus_clk) / 2; |
Florian Fainelli | 7ca5dc1 | 2009-06-24 11:12:57 +0200 | [diff] [blame] | 523 | uart_port[0].iotype = UPIO_MEM32; |
| 524 | uart_port[0].mapbase = AR7_REGS_UART0; |
| 525 | uart_port[0].membase = ioremap(uart_port[0].mapbase, 256); |
| 526 | uart_port[0].regshift = 2; |
| 527 | res = early_serial_setup(&uart_port[0]); |
| 528 | if (res) |
| 529 | return res; |
| 530 | |
| 531 | |
| 532 | /* Only TNETD73xx have a second serial port */ |
| 533 | if (ar7_has_second_uart()) { |
| 534 | uart_port[1].type = PORT_16550A; |
| 535 | uart_port[1].line = 1; |
| 536 | uart_port[1].irq = AR7_IRQ_UART1; |
Florian Fainelli | 780019d | 2010-01-27 09:10:06 +0100 | [diff] [blame^] | 537 | uart_port[1].uartclk = clk_get_rate(bus_clk) / 2; |
Florian Fainelli | 7ca5dc1 | 2009-06-24 11:12:57 +0200 | [diff] [blame] | 538 | uart_port[1].iotype = UPIO_MEM32; |
| 539 | uart_port[1].mapbase = UR8_REGS_UART1; |
| 540 | uart_port[1].membase = ioremap(uart_port[1].mapbase, 256); |
| 541 | uart_port[1].regshift = 2; |
| 542 | res = early_serial_setup(&uart_port[1]); |
| 543 | if (res) |
| 544 | return res; |
| 545 | } |
Florian Fainelli | 50ca961 | 2009-07-24 13:24:15 +0200 | [diff] [blame] | 546 | #endif /* CONFIG_SERIAL_8250 */ |
Florian Fainelli | 7ca5dc1 | 2009-06-24 11:12:57 +0200 | [diff] [blame] | 547 | res = platform_device_register(&physmap_flash); |
| 548 | if (res) |
| 549 | return res; |
| 550 | |
| 551 | ar7_device_disable(vlynq_low_data.reset_bit); |
| 552 | res = platform_device_register(&vlynq_low); |
| 553 | if (res) |
| 554 | return res; |
| 555 | |
| 556 | if (ar7_has_high_vlynq()) { |
| 557 | ar7_device_disable(vlynq_high_data.reset_bit); |
| 558 | res = platform_device_register(&vlynq_high); |
| 559 | if (res) |
| 560 | return res; |
| 561 | } |
| 562 | |
| 563 | if (ar7_has_high_cpmac()) { |
Florian Fainelli | 1e2c8d8 | 2009-08-04 10:52:47 +0000 | [diff] [blame] | 564 | res = fixed_phy_add(PHY_POLL, cpmac_high.id, &fixed_phy_status); |
| 565 | if (res && res != -ENODEV) |
| 566 | return res; |
Florian Fainelli | 7ca5dc1 | 2009-06-24 11:12:57 +0200 | [diff] [blame] | 567 | cpmac_get_mac(1, cpmac_high_data.dev_addr); |
| 568 | res = platform_device_register(&cpmac_high); |
| 569 | if (res) |
| 570 | return res; |
| 571 | } else { |
| 572 | cpmac_low_data.phy_mask = 0xffffffff; |
| 573 | } |
| 574 | |
Florian Fainelli | 1e2c8d8 | 2009-08-04 10:52:47 +0000 | [diff] [blame] | 575 | res = fixed_phy_add(PHY_POLL, cpmac_low.id, &fixed_phy_status); |
| 576 | if (res && res != -ENODEV) |
| 577 | return res; |
| 578 | |
Florian Fainelli | 7ca5dc1 | 2009-06-24 11:12:57 +0200 | [diff] [blame] | 579 | cpmac_get_mac(0, cpmac_low_data.dev_addr); |
| 580 | res = platform_device_register(&cpmac_low); |
| 581 | if (res) |
| 582 | return res; |
| 583 | |
| 584 | detect_leds(); |
| 585 | res = platform_device_register(&ar7_gpio_leds); |
| 586 | if (res) |
| 587 | return res; |
| 588 | |
| 589 | res = platform_device_register(&ar7_udc); |
| 590 | |
Florian Fainelli | d47fbb5 | 2009-07-15 12:09:34 +0200 | [diff] [blame] | 591 | chip_id = ar7_chip_id(); |
| 592 | switch (chip_id) { |
| 593 | case AR7_CHIP_7100: |
| 594 | case AR7_CHIP_7200: |
| 595 | ar7_wdt_res.start = AR7_REGS_WDT; |
| 596 | break; |
| 597 | case AR7_CHIP_7300: |
| 598 | ar7_wdt_res.start = UR8_REGS_WDT; |
| 599 | break; |
| 600 | default: |
| 601 | break; |
| 602 | } |
| 603 | |
| 604 | ar7_wdt_res.end = ar7_wdt_res.start + 0x20; |
| 605 | |
Florian Fainelli | 72838a1 | 2009-08-04 23:09:36 +0200 | [diff] [blame] | 606 | bootcr = (u32 *)ioremap_nocache(AR7_REGS_DCL, 4); |
| 607 | val = *bootcr; |
| 608 | iounmap(bootcr); |
| 609 | |
| 610 | /* Register watchdog only if enabled in hardware */ |
| 611 | if (val & AR7_WDT_HW_ENA) |
| 612 | res = platform_device_register(&ar7_wdt); |
Florian Fainelli | d47fbb5 | 2009-07-15 12:09:34 +0200 | [diff] [blame] | 613 | |
Florian Fainelli | 7ca5dc1 | 2009-06-24 11:12:57 +0200 | [diff] [blame] | 614 | return res; |
| 615 | } |
| 616 | arch_initcall(ar7_register_devices); |