diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-03 17:31:24 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-03 17:31:24 -0400 |
commit | be82ae0238b0453afcf4a76f0512b7dde34ba500 (patch) | |
tree | aaa3f5f11fd51fd73365ee1a2164aad9a03de060 /arch/arm/mach-orion5x | |
parent | 4b4fd27c0b5ec638a1f06ced9226fd95229dbbf0 (diff) | |
parent | 7b70c4275f28702b76b273c8534c38f8313812e9 (diff) |
Merge branch 'devel' of master.kernel.org:/home/rmk/linux-2.6-arm
* 'devel' of master.kernel.org:/home/rmk/linux-2.6-arm: (291 commits)
ARM: AMBA: Add pclk support to AMBA bus infrastructure
ARM: 6278/2: fix regression in RealView after the introduction of pclk
ARM: 6277/1: mach-shmobile: Allow users to select HZ, default to 128
ARM: 6276/1: mach-shmobile: remove duplicate NR_IRQS_LEGACY
ARM: 6246/1: mmci: support larger MMCIDATALENGTH register
ARM: 6245/1: mmci: enable hardware flow control on Ux500 variants
ARM: 6244/1: mmci: add variant data and default MCICLOCK support
ARM: 6243/1: mmci: pass power_mode to the translate_vdd callback
ARM: 6274/1: add global control registers definition header file for nuc900
mx2_camera: fix type of dma buffer virtual address pointer
mx2_camera: Add soc_camera support for i.MX25/i.MX27
arm/imx/gpio: add spinlock protection
ARM: Add support for the LPC32XX arch
ARM: LPC32XX: Arch config menu supoport and makefiles
ARM: LPC32XX: Phytec 3250 platform support
ARM: LPC32XX: Misc support functions
ARM: LPC32XX: Serial support code
ARM: LPC32XX: System suspend support
ARM: LPC32XX: GPIO, timer, and IRQ drivers
ARM: LPC32XX: Clock driver
...
Diffstat (limited to 'arch/arm/mach-orion5x')
-rw-r--r-- | arch/arm/mach-orion5x/Kconfig | 1 | ||||
-rw-r--r-- | arch/arm/mach-orion5x/dns323-setup.c | 370 | ||||
-rw-r--r-- | arch/arm/mach-orion5x/include/mach/system.h | 2 |
3 files changed, 309 insertions, 64 deletions
diff --git a/arch/arm/mach-orion5x/Kconfig b/arch/arm/mach-orion5x/Kconfig index 905719a677ae..c897e03e413d 100644 --- a/arch/arm/mach-orion5x/Kconfig +++ b/arch/arm/mach-orion5x/Kconfig | |||
@@ -26,6 +26,7 @@ config MACH_KUROBOX_PRO | |||
26 | config MACH_DNS323 | 26 | config MACH_DNS323 |
27 | bool "D-Link DNS-323" | 27 | bool "D-Link DNS-323" |
28 | select I2C_BOARDINFO | 28 | select I2C_BOARDINFO |
29 | select PHYLIB | ||
29 | help | 30 | help |
30 | Say 'Y' here if you want your kernel to support the | 31 | Say 'Y' here if you want your kernel to support the |
31 | D-Link DNS-323 platform. | 32 | D-Link DNS-323 platform. |
diff --git a/arch/arm/mach-orion5x/dns323-setup.c b/arch/arm/mach-orion5x/dns323-setup.c index fe0de1698edc..a47100d46a4e 100644 --- a/arch/arm/mach-orion5x/dns323-setup.c +++ b/arch/arm/mach-orion5x/dns323-setup.c | |||
@@ -3,6 +3,10 @@ | |||
3 | * | 3 | * |
4 | * Copyright (C) 2007 Herbert Valerio Riedel <hvr@gnu.org> | 4 | * Copyright (C) 2007 Herbert Valerio Riedel <hvr@gnu.org> |
5 | * | 5 | * |
6 | * Support for HW Rev C1: | ||
7 | * | ||
8 | * Copyright (C) 2010 Benjamin Herrenschmidt <benh@kernel.crashing.org> | ||
9 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | 10 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU Lesser General Public License as | 11 | * it under the terms of the GNU Lesser General Public License as |
8 | * published by the Free Software Foundation; either version 2 of the | 12 | * published by the Free Software Foundation; either version 2 of the |
@@ -23,6 +27,8 @@ | |||
23 | #include <linux/input.h> | 27 | #include <linux/input.h> |
24 | #include <linux/i2c.h> | 28 | #include <linux/i2c.h> |
25 | #include <linux/ata_platform.h> | 29 | #include <linux/ata_platform.h> |
30 | #include <linux/phy.h> | ||
31 | #include <linux/marvell_phy.h> | ||
26 | #include <asm/mach-types.h> | 32 | #include <asm/mach-types.h> |
27 | #include <asm/gpio.h> | 33 | #include <asm/gpio.h> |
28 | #include <asm/mach/arch.h> | 34 | #include <asm/mach/arch.h> |
@@ -31,6 +37,7 @@ | |||
31 | #include "common.h" | 37 | #include "common.h" |
32 | #include "mpp.h" | 38 | #include "mpp.h" |
33 | 39 | ||
40 | /* Rev A1 and B1 */ | ||
34 | #define DNS323_GPIO_LED_RIGHT_AMBER 1 | 41 | #define DNS323_GPIO_LED_RIGHT_AMBER 1 |
35 | #define DNS323_GPIO_LED_LEFT_AMBER 2 | 42 | #define DNS323_GPIO_LED_LEFT_AMBER 2 |
36 | #define DNS323_GPIO_SYSTEM_UP 3 | 43 | #define DNS323_GPIO_SYSTEM_UP 3 |
@@ -42,6 +49,23 @@ | |||
42 | #define DNS323_GPIO_KEY_POWER 9 | 49 | #define DNS323_GPIO_KEY_POWER 9 |
43 | #define DNS323_GPIO_KEY_RESET 10 | 50 | #define DNS323_GPIO_KEY_RESET 10 |
44 | 51 | ||
52 | /* Rev C1 */ | ||
53 | #define DNS323C_GPIO_KEY_POWER 1 | ||
54 | #define DNS323C_GPIO_POWER_OFF 2 | ||
55 | #define DNS323C_GPIO_LED_RIGHT_AMBER 8 | ||
56 | #define DNS323C_GPIO_LED_LEFT_AMBER 9 | ||
57 | #define DNS323C_GPIO_LED_POWER 17 | ||
58 | #define DNS323C_GPIO_FAN_BIT1 18 | ||
59 | #define DNS323C_GPIO_FAN_BIT0 19 | ||
60 | |||
61 | /* Exposed to userspace, do not change */ | ||
62 | enum { | ||
63 | DNS323_REV_A1, /* 0 */ | ||
64 | DNS323_REV_B1, /* 1 */ | ||
65 | DNS323_REV_C1, /* 2 */ | ||
66 | }; | ||
67 | |||
68 | |||
45 | /**************************************************************************** | 69 | /**************************************************************************** |
46 | * PCI setup | 70 | * PCI setup |
47 | */ | 71 | */ |
@@ -68,21 +92,12 @@ static struct hw_pci dns323_pci __initdata = { | |||
68 | .map_irq = dns323_pci_map_irq, | 92 | .map_irq = dns323_pci_map_irq, |
69 | }; | 93 | }; |
70 | 94 | ||
71 | static int __init dns323_dev_id(void) | ||
72 | { | ||
73 | u32 dev, rev; | ||
74 | |||
75 | orion5x_pcie_id(&dev, &rev); | ||
76 | |||
77 | return dev; | ||
78 | } | ||
79 | |||
80 | static int __init dns323_pci_init(void) | 95 | static int __init dns323_pci_init(void) |
81 | { | 96 | { |
82 | /* The 5182 doesn't really use its PCI bus, and initialising PCI | 97 | /* Rev B1 and C1 doesn't really use its PCI bus, and initialising PCI |
83 | * gets in the way of initialising the SATA controller. | 98 | * gets in the way of initialising the SATA controller. |
84 | */ | 99 | */ |
85 | if (machine_is_dns323() && dns323_dev_id() != MV88F5182_DEV_ID) | 100 | if (machine_is_dns323() && system_rev == DNS323_REV_A1) |
86 | pci_common_init(&dns323_pci); | 101 | pci_common_init(&dns323_pci); |
87 | 102 | ||
88 | return 0; | 103 | return 0; |
@@ -221,7 +236,7 @@ static int __init dns323_read_mac_addr(void) | |||
221 | } | 236 | } |
222 | 237 | ||
223 | iounmap(mac_page); | 238 | iounmap(mac_page); |
224 | printk("DNS323: Found ethernet MAC address: "); | 239 | printk("DNS-323: Found ethernet MAC address: "); |
225 | for (i = 0; i < 6; i++) | 240 | for (i = 0; i < 6; i++) |
226 | printk("%.2x%s", addr[i], (i < 5) ? ":" : ".\n"); | 241 | printk("%.2x%s", addr[i], (i < 5) ? ":" : ".\n"); |
227 | 242 | ||
@@ -259,12 +274,11 @@ static int dns323_gpio_blink_set(unsigned gpio, int state, | |||
259 | return 0; | 274 | return 0; |
260 | } | 275 | } |
261 | 276 | ||
262 | static struct gpio_led dns323_leds[] = { | 277 | static struct gpio_led dns323ab_leds[] = { |
263 | { | 278 | { |
264 | .name = "power:blue", | 279 | .name = "power:blue", |
265 | .gpio = DNS323_GPIO_LED_POWER2, | 280 | .gpio = DNS323_GPIO_LED_POWER2, |
266 | .default_trigger = "timer", | 281 | .default_trigger = "default-on", |
267 | .active_low = 1, | ||
268 | }, { | 282 | }, { |
269 | .name = "right:amber", | 283 | .name = "right:amber", |
270 | .gpio = DNS323_GPIO_LED_RIGHT_AMBER, | 284 | .gpio = DNS323_GPIO_LED_RIGHT_AMBER, |
@@ -276,9 +290,34 @@ static struct gpio_led dns323_leds[] = { | |||
276 | }, | 290 | }, |
277 | }; | 291 | }; |
278 | 292 | ||
279 | static struct gpio_led_platform_data dns323_led_data = { | 293 | |
280 | .num_leds = ARRAY_SIZE(dns323_leds), | 294 | static struct gpio_led dns323c_leds[] = { |
281 | .leds = dns323_leds, | 295 | { |
296 | .name = "power:blue", | ||
297 | .gpio = DNS323C_GPIO_LED_POWER, | ||
298 | .default_trigger = "timer", | ||
299 | .active_low = 1, | ||
300 | }, { | ||
301 | .name = "right:amber", | ||
302 | .gpio = DNS323C_GPIO_LED_RIGHT_AMBER, | ||
303 | .active_low = 1, | ||
304 | }, { | ||
305 | .name = "left:amber", | ||
306 | .gpio = DNS323C_GPIO_LED_LEFT_AMBER, | ||
307 | .active_low = 1, | ||
308 | }, | ||
309 | }; | ||
310 | |||
311 | |||
312 | static struct gpio_led_platform_data dns323ab_led_data = { | ||
313 | .num_leds = ARRAY_SIZE(dns323ab_leds), | ||
314 | .leds = dns323ab_leds, | ||
315 | .gpio_blink_set = dns323_gpio_blink_set, | ||
316 | }; | ||
317 | |||
318 | static struct gpio_led_platform_data dns323c_led_data = { | ||
319 | .num_leds = ARRAY_SIZE(dns323c_leds), | ||
320 | .leds = dns323c_leds, | ||
282 | .gpio_blink_set = dns323_gpio_blink_set, | 321 | .gpio_blink_set = dns323_gpio_blink_set, |
283 | }; | 322 | }; |
284 | 323 | ||
@@ -286,7 +325,7 @@ static struct platform_device dns323_gpio_leds = { | |||
286 | .name = "leds-gpio", | 325 | .name = "leds-gpio", |
287 | .id = -1, | 326 | .id = -1, |
288 | .dev = { | 327 | .dev = { |
289 | .platform_data = &dns323_led_data, | 328 | .platform_data = &dns323ab_led_data, |
290 | }, | 329 | }, |
291 | }; | 330 | }; |
292 | 331 | ||
@@ -294,7 +333,7 @@ static struct platform_device dns323_gpio_leds = { | |||
294 | * GPIO Attached Keys | 333 | * GPIO Attached Keys |
295 | */ | 334 | */ |
296 | 335 | ||
297 | static struct gpio_keys_button dns323_buttons[] = { | 336 | static struct gpio_keys_button dns323ab_buttons[] = { |
298 | { | 337 | { |
299 | .code = KEY_RESTART, | 338 | .code = KEY_RESTART, |
300 | .gpio = DNS323_GPIO_KEY_RESET, | 339 | .gpio = DNS323_GPIO_KEY_RESET, |
@@ -308,9 +347,23 @@ static struct gpio_keys_button dns323_buttons[] = { | |||
308 | }, | 347 | }, |
309 | }; | 348 | }; |
310 | 349 | ||
311 | static struct gpio_keys_platform_data dns323_button_data = { | 350 | static struct gpio_keys_platform_data dns323ab_button_data = { |
312 | .buttons = dns323_buttons, | 351 | .buttons = dns323ab_buttons, |
313 | .nbuttons = ARRAY_SIZE(dns323_buttons), | 352 | .nbuttons = ARRAY_SIZE(dns323ab_buttons), |
353 | }; | ||
354 | |||
355 | static struct gpio_keys_button dns323c_buttons[] = { | ||
356 | { | ||
357 | .code = KEY_POWER, | ||
358 | .gpio = DNS323C_GPIO_KEY_POWER, | ||
359 | .desc = "Power Button", | ||
360 | .active_low = 1, | ||
361 | }, | ||
362 | }; | ||
363 | |||
364 | static struct gpio_keys_platform_data dns323c_button_data = { | ||
365 | .buttons = dns323c_buttons, | ||
366 | .nbuttons = ARRAY_SIZE(dns323c_buttons), | ||
314 | }; | 367 | }; |
315 | 368 | ||
316 | static struct platform_device dns323_button_device = { | 369 | static struct platform_device dns323_button_device = { |
@@ -318,7 +371,7 @@ static struct platform_device dns323_button_device = { | |||
318 | .id = -1, | 371 | .id = -1, |
319 | .num_resources = 0, | 372 | .num_resources = 0, |
320 | .dev = { | 373 | .dev = { |
321 | .platform_data = &dns323_button_data, | 374 | .platform_data = &dns323ab_button_data, |
322 | }, | 375 | }, |
323 | }; | 376 | }; |
324 | 377 | ||
@@ -332,7 +385,7 @@ static struct mv_sata_platform_data dns323_sata_data = { | |||
332 | /**************************************************************************** | 385 | /**************************************************************************** |
333 | * General Setup | 386 | * General Setup |
334 | */ | 387 | */ |
335 | static struct orion5x_mpp_mode dns323_mv88f5181_mpp_modes[] __initdata = { | 388 | static struct orion5x_mpp_mode dns323a_mpp_modes[] __initdata = { |
336 | { 0, MPP_PCIE_RST_OUTn }, | 389 | { 0, MPP_PCIE_RST_OUTn }, |
337 | { 1, MPP_GPIO }, /* right amber LED (sata ch0) */ | 390 | { 1, MPP_GPIO }, /* right amber LED (sata ch0) */ |
338 | { 2, MPP_GPIO }, /* left amber LED (sata ch1) */ | 391 | { 2, MPP_GPIO }, /* left amber LED (sata ch1) */ |
@@ -356,7 +409,7 @@ static struct orion5x_mpp_mode dns323_mv88f5181_mpp_modes[] __initdata = { | |||
356 | { -1 }, | 409 | { -1 }, |
357 | }; | 410 | }; |
358 | 411 | ||
359 | static struct orion5x_mpp_mode dns323_mv88f5182_mpp_modes[] __initdata = { | 412 | static struct orion5x_mpp_mode dns323b_mpp_modes[] __initdata = { |
360 | { 0, MPP_UNUSED }, | 413 | { 0, MPP_UNUSED }, |
361 | { 1, MPP_GPIO }, /* right amber LED (sata ch0) */ | 414 | { 1, MPP_GPIO }, /* right amber LED (sata ch0) */ |
362 | { 2, MPP_GPIO }, /* left amber LED (sata ch1) */ | 415 | { 2, MPP_GPIO }, /* left amber LED (sata ch1) */ |
@@ -380,15 +433,57 @@ static struct orion5x_mpp_mode dns323_mv88f5182_mpp_modes[] __initdata = { | |||
380 | { -1 }, | 433 | { -1 }, |
381 | }; | 434 | }; |
382 | 435 | ||
436 | static struct orion5x_mpp_mode dns323c_mpp_modes[] __initdata = { | ||
437 | { 0, MPP_GPIO }, /* ? input */ | ||
438 | { 1, MPP_GPIO }, /* input power switch (0 = pressed) */ | ||
439 | { 2, MPP_GPIO }, /* output power off */ | ||
440 | { 3, MPP_UNUSED }, /* ? output */ | ||
441 | { 4, MPP_UNUSED }, /* ? output */ | ||
442 | { 5, MPP_UNUSED }, /* ? output */ | ||
443 | { 6, MPP_UNUSED }, /* ? output */ | ||
444 | { 7, MPP_UNUSED }, /* ? output */ | ||
445 | { 8, MPP_GPIO }, /* i/o right amber LED */ | ||
446 | { 9, MPP_GPIO }, /* i/o left amber LED */ | ||
447 | { 10, MPP_GPIO }, /* input */ | ||
448 | { 11, MPP_UNUSED }, | ||
449 | { 12, MPP_SATA_LED }, | ||
450 | { 13, MPP_SATA_LED }, | ||
451 | { 14, MPP_SATA_LED }, | ||
452 | { 15, MPP_SATA_LED }, | ||
453 | { 16, MPP_UNUSED }, | ||
454 | { 17, MPP_GPIO }, /* power button LED */ | ||
455 | { 18, MPP_GPIO }, /* fan speed bit 0 */ | ||
456 | { 19, MPP_GPIO }, /* fan speed bit 1 */ | ||
457 | { -1 }, | ||
458 | }; | ||
459 | |||
460 | /* Rev C1 Fan speed notes: | ||
461 | * | ||
462 | * The fan is controlled by 2 GPIOs on this board. The settings | ||
463 | * of the bits is as follow: | ||
464 | * | ||
465 | * GPIO 18 GPIO 19 Fan | ||
466 | * | ||
467 | * 0 0 stopped | ||
468 | * 0 1 low speed | ||
469 | * 1 0 high speed | ||
470 | * 1 1 don't do that (*) | ||
471 | * | ||
472 | * (*) I think the two bits control two feed-in resistors into a fixed | ||
473 | * PWN circuit, setting both bits will basically go a 'bit' faster | ||
474 | * than high speed, but d-link doesn't do it and you may get out of | ||
475 | * HW spec so don't do it. | ||
476 | */ | ||
477 | |||
383 | /* | 478 | /* |
384 | * On the DNS-323 the following devices are attached via I2C: | 479 | * On the DNS-323 A1 and B1 the following devices are attached via I2C: |
385 | * | 480 | * |
386 | * i2c addr | chip | description | 481 | * i2c addr | chip | description |
387 | * 0x3e | GMT G760Af | fan speed PWM controller | 482 | * 0x3e | GMT G760Af | fan speed PWM controller |
388 | * 0x48 | GMT G751-2f | temp. sensor and therm. watchdog (LM75 compatible) | 483 | * 0x48 | GMT G751-2f | temp. sensor and therm. watchdog (LM75 compatible) |
389 | * 0x68 | ST M41T80 | RTC w/ alarm | 484 | * 0x68 | ST M41T80 | RTC w/ alarm |
390 | */ | 485 | */ |
391 | static struct i2c_board_info __initdata dns323_i2c_devices[] = { | 486 | static struct i2c_board_info __initdata dns323ab_i2c_devices[] = { |
392 | { | 487 | { |
393 | I2C_BOARD_INFO("g760a", 0x3e), | 488 | I2C_BOARD_INFO("g760a", 0x3e), |
394 | }, { | 489 | }, { |
@@ -398,36 +493,140 @@ static struct i2c_board_info __initdata dns323_i2c_devices[] = { | |||
398 | }, | 493 | }, |
399 | }; | 494 | }; |
400 | 495 | ||
496 | /* | ||
497 | * On the DNS-323 C1 the following devices are attached via I2C: | ||
498 | * | ||
499 | * i2c addr | chip | description | ||
500 | * 0x48 | GMT G751-2f | temp. sensor and therm. watchdog (LM75 compatible) | ||
501 | * 0x68 | ST M41T80 | RTC w/ alarm | ||
502 | */ | ||
503 | static struct i2c_board_info __initdata dns323c_i2c_devices[] = { | ||
504 | { | ||
505 | I2C_BOARD_INFO("lm75", 0x48), | ||
506 | }, { | ||
507 | I2C_BOARD_INFO("m41t80", 0x68), | ||
508 | }, | ||
509 | }; | ||
510 | |||
401 | /* DNS-323 rev. A specific power off method */ | 511 | /* DNS-323 rev. A specific power off method */ |
402 | static void dns323a_power_off(void) | 512 | static void dns323a_power_off(void) |
403 | { | 513 | { |
404 | pr_info("%s: triggering power-off...\n", __func__); | 514 | pr_info("DNS-323: Triggering power-off...\n"); |
405 | gpio_set_value(DNS323_GPIO_POWER_OFF, 1); | 515 | gpio_set_value(DNS323_GPIO_POWER_OFF, 1); |
406 | } | 516 | } |
407 | 517 | ||
408 | /* DNS-323 rev B specific power off method */ | 518 | /* DNS-323 rev B specific power off method */ |
409 | static void dns323b_power_off(void) | 519 | static void dns323b_power_off(void) |
410 | { | 520 | { |
411 | pr_info("%s: triggering power-off...\n", __func__); | 521 | pr_info("DNS-323: Triggering power-off...\n"); |
412 | /* Pin has to be changed to 1 and back to 0 to do actual power off. */ | 522 | /* Pin has to be changed to 1 and back to 0 to do actual power off. */ |
413 | gpio_set_value(DNS323_GPIO_POWER_OFF, 1); | 523 | gpio_set_value(DNS323_GPIO_POWER_OFF, 1); |
414 | mdelay(100); | 524 | mdelay(100); |
415 | gpio_set_value(DNS323_GPIO_POWER_OFF, 0); | 525 | gpio_set_value(DNS323_GPIO_POWER_OFF, 0); |
416 | } | 526 | } |
417 | 527 | ||
528 | /* DNS-323 rev. C specific power off method */ | ||
529 | static void dns323c_power_off(void) | ||
530 | { | ||
531 | pr_info("DNS-323: Triggering power-off...\n"); | ||
532 | gpio_set_value(DNS323C_GPIO_POWER_OFF, 1); | ||
533 | } | ||
534 | |||
535 | static int dns323c_phy_fixup(struct phy_device *phy) | ||
536 | { | ||
537 | phy->dev_flags |= MARVELL_PHY_M1118_DNS323_LEDS; | ||
538 | |||
539 | return 0; | ||
540 | } | ||
541 | |||
542 | static int __init dns323_identify_rev(void) | ||
543 | { | ||
544 | u32 dev, rev, i, reg; | ||
545 | |||
546 | pr_debug("DNS-323: Identifying board ... \n"); | ||
547 | |||
548 | /* Rev A1 has a 5181 */ | ||
549 | orion5x_pcie_id(&dev, &rev); | ||
550 | if (dev == MV88F5181_DEV_ID) { | ||
551 | pr_debug("DNS-323: 5181 found, board is A1\n"); | ||
552 | return DNS323_REV_A1; | ||
553 | } | ||
554 | pr_debug("DNS-323: 5182 found, board is B1 or C1, checking PHY...\n"); | ||
555 | |||
556 | /* Rev B1 and C1 both have 5182, let's poke at the eth PHY. This is | ||
557 | * a bit gross but we want to do that without links into the eth | ||
558 | * driver so let's poke at it directly. We default to rev B1 in | ||
559 | * case the accesses fail | ||
560 | */ | ||
561 | |||
562 | #define ETH_SMI_REG (ORION5X_ETH_VIRT_BASE + 0x2000 + 0x004) | ||
563 | #define SMI_BUSY 0x10000000 | ||
564 | #define SMI_READ_VALID 0x08000000 | ||
565 | #define SMI_OPCODE_READ 0x04000000 | ||
566 | #define SMI_OPCODE_WRITE 0x00000000 | ||
567 | |||
568 | for (i = 0; i < 1000; i++) { | ||
569 | reg = readl(ETH_SMI_REG); | ||
570 | if (!(reg & SMI_BUSY)) | ||
571 | break; | ||
572 | } | ||
573 | if (i >= 1000) { | ||
574 | pr_warning("DNS-323: Timeout accessing PHY, assuming rev B1\n"); | ||
575 | return DNS323_REV_B1; | ||
576 | } | ||
577 | writel((3 << 21) /* phy ID reg */ | | ||
578 | (8 << 16) /* phy addr */ | | ||
579 | SMI_OPCODE_READ, ETH_SMI_REG); | ||
580 | for (i = 0; i < 1000; i++) { | ||
581 | reg = readl(ETH_SMI_REG); | ||
582 | if (reg & SMI_READ_VALID) | ||
583 | break; | ||
584 | } | ||
585 | if (i >= 1000) { | ||
586 | pr_warning("DNS-323: Timeout reading PHY, assuming rev B1\n"); | ||
587 | return DNS323_REV_B1; | ||
588 | } | ||
589 | pr_debug("DNS-323: Ethernet PHY ID 0x%x\n", reg & 0xffff); | ||
590 | |||
591 | /* Note: the Marvell tools mask the ID with 0x3f0 before comparison | ||
592 | * but I don't see that making a difference here, at least with | ||
593 | * any known Marvell PHY ID | ||
594 | */ | ||
595 | switch(reg & 0xfff0) { | ||
596 | case 0x0cc0: /* MV88E1111 */ | ||
597 | return DNS323_REV_B1; | ||
598 | case 0x0e10: /* MV88E1118 */ | ||
599 | return DNS323_REV_C1; | ||
600 | default: | ||
601 | pr_warning("DNS-323: Unknown PHY ID 0x%04x, assuming rev B1\n", | ||
602 | reg & 0xffff); | ||
603 | } | ||
604 | return DNS323_REV_B1; | ||
605 | } | ||
606 | |||
418 | static void __init dns323_init(void) | 607 | static void __init dns323_init(void) |
419 | { | 608 | { |
420 | /* Setup basic Orion functions. Need to be called early. */ | 609 | /* Setup basic Orion functions. Need to be called early. */ |
421 | orion5x_init(); | 610 | orion5x_init(); |
422 | 611 | ||
612 | /* Identify revision */ | ||
613 | system_rev = dns323_identify_rev(); | ||
614 | pr_info("DNS-323: Identified HW revision %c1\n", 'A' + system_rev); | ||
615 | |||
423 | /* Just to be tricky, the 5182 has a completely different | 616 | /* Just to be tricky, the 5182 has a completely different |
424 | * set of MPP modes to the 5181. | 617 | * set of MPP modes to the 5181. |
425 | */ | 618 | */ |
426 | if (dns323_dev_id() == MV88F5182_DEV_ID) | 619 | switch(system_rev) { |
427 | orion5x_mpp_conf(dns323_mv88f5182_mpp_modes); | 620 | case DNS323_REV_A1: |
428 | else { | 621 | orion5x_mpp_conf(dns323a_mpp_modes); |
429 | orion5x_mpp_conf(dns323_mv88f5181_mpp_modes); | ||
430 | writel(0, MPP_DEV_CTRL); /* DEV_D[31:16] */ | 622 | writel(0, MPP_DEV_CTRL); /* DEV_D[31:16] */ |
623 | break; | ||
624 | case DNS323_REV_B1: | ||
625 | orion5x_mpp_conf(dns323b_mpp_modes); | ||
626 | break; | ||
627 | case DNS323_REV_C1: | ||
628 | orion5x_mpp_conf(dns323c_mpp_modes); | ||
629 | break; | ||
431 | } | 630 | } |
432 | 631 | ||
433 | /* setup flash mapping | 632 | /* setup flash mapping |
@@ -436,53 +635,96 @@ static void __init dns323_init(void) | |||
436 | orion5x_setup_dev_boot_win(DNS323_NOR_BOOT_BASE, DNS323_NOR_BOOT_SIZE); | 635 | orion5x_setup_dev_boot_win(DNS323_NOR_BOOT_BASE, DNS323_NOR_BOOT_SIZE); |
437 | platform_device_register(&dns323_nor_flash); | 636 | platform_device_register(&dns323_nor_flash); |
438 | 637 | ||
439 | /* The 5181 power LED is active low and requires | 638 | /* Sort out LEDs, Buttons and i2c devices */ |
440 | * DNS323_GPIO_LED_POWER1 to also be low. | 639 | switch(system_rev) { |
441 | */ | 640 | case DNS323_REV_A1: |
442 | if (dns323_dev_id() == MV88F5181_DEV_ID) { | 641 | /* The 5181 power LED is active low and requires |
443 | dns323_leds[0].active_low = 1; | 642 | * DNS323_GPIO_LED_POWER1 to also be low. |
444 | gpio_request(DNS323_GPIO_LED_POWER1, "Power Led Enable"); | 643 | */ |
445 | gpio_direction_output(DNS323_GPIO_LED_POWER1, 0); | 644 | dns323ab_leds[0].active_low = 1; |
645 | gpio_request(DNS323_GPIO_LED_POWER1, "Power Led Enable"); | ||
646 | gpio_direction_output(DNS323_GPIO_LED_POWER1, 0); | ||
647 | /* Fall through */ | ||
648 | case DNS323_REV_B1: | ||
649 | i2c_register_board_info(0, dns323ab_i2c_devices, | ||
650 | ARRAY_SIZE(dns323ab_i2c_devices)); | ||
651 | break; | ||
652 | case DNS323_REV_C1: | ||
653 | /* Hookup LEDs & Buttons */ | ||
654 | dns323_gpio_leds.dev.platform_data = &dns323c_led_data; | ||
655 | dns323_button_device.dev.platform_data = &dns323c_button_data; | ||
656 | |||
657 | /* Hookup i2c devices and fan driver */ | ||
658 | i2c_register_board_info(0, dns323c_i2c_devices, | ||
659 | ARRAY_SIZE(dns323c_i2c_devices)); | ||
660 | platform_device_register_simple("dns323c-fan", 0, NULL, 0); | ||
661 | |||
662 | /* Register fixup for the PHY LEDs */ | ||
663 | phy_register_fixup_for_uid(MARVELL_PHY_ID_88E1118, | ||
664 | MARVELL_PHY_ID_MASK, | ||
665 | dns323c_phy_fixup); | ||
446 | } | 666 | } |
447 | 667 | ||
448 | platform_device_register(&dns323_gpio_leds); | 668 | platform_device_register(&dns323_gpio_leds); |
449 | |||
450 | platform_device_register(&dns323_button_device); | 669 | platform_device_register(&dns323_button_device); |
451 | 670 | ||
452 | i2c_register_board_info(0, dns323_i2c_devices, | ||
453 | ARRAY_SIZE(dns323_i2c_devices)); | ||
454 | |||
455 | /* | 671 | /* |
456 | * Configure peripherals. | 672 | * Configure peripherals. |
457 | */ | 673 | */ |
458 | if (dns323_read_mac_addr() < 0) | 674 | if (dns323_read_mac_addr() < 0) |
459 | printk("DNS323: Failed to read MAC address\n"); | 675 | printk("DNS-323: Failed to read MAC address\n"); |
460 | |||
461 | orion5x_ehci0_init(); | 676 | orion5x_ehci0_init(); |
462 | orion5x_eth_init(&dns323_eth_data); | 677 | orion5x_eth_init(&dns323_eth_data); |
463 | orion5x_i2c_init(); | 678 | orion5x_i2c_init(); |
464 | orion5x_uart0_init(); | 679 | orion5x_uart0_init(); |
465 | 680 | ||
466 | /* The 5182 has its SATA controller on-chip, and needs its own little | 681 | /* Remaining GPIOs */ |
467 | * init routine. | 682 | switch(system_rev) { |
468 | */ | 683 | case DNS323_REV_A1: |
469 | if (dns323_dev_id() == MV88F5182_DEV_ID) | 684 | /* Poweroff GPIO */ |
685 | if (gpio_request(DNS323_GPIO_POWER_OFF, "POWEROFF") != 0 || | ||
686 | gpio_direction_output(DNS323_GPIO_POWER_OFF, 0) != 0) | ||
687 | pr_err("DNS-323: failed to setup power-off GPIO\n"); | ||
688 | pm_power_off = dns323a_power_off; | ||
689 | break; | ||
690 | case DNS323_REV_B1: | ||
691 | /* 5182 built-in SATA init */ | ||
470 | orion5x_sata_init(&dns323_sata_data); | 692 | orion5x_sata_init(&dns323_sata_data); |
471 | 693 | ||
472 | /* The 5182 has flag to indicate the system is up. Without this flag | 694 | /* The DNS323 rev B1 has flag to indicate the system is up. |
473 | * set, power LED will flash and cannot be controlled via leds-gpio. | 695 | * Without this flag set, power LED will flash and cannot be |
474 | */ | 696 | * controlled via leds-gpio. |
475 | if (dns323_dev_id() == MV88F5182_DEV_ID) | 697 | */ |
476 | gpio_set_value(DNS323_GPIO_SYSTEM_UP, 1); | 698 | if (gpio_request(DNS323_GPIO_SYSTEM_UP, "SYS_READY") == 0) |
477 | 699 | gpio_direction_output(DNS323_GPIO_SYSTEM_UP, 1); | |
478 | /* Register dns323 specific power-off method */ | 700 | |
479 | if (gpio_request(DNS323_GPIO_POWER_OFF, "POWEROFF") != 0 || | 701 | /* Poweroff GPIO */ |
480 | gpio_direction_output(DNS323_GPIO_POWER_OFF, 0) != 0) | 702 | if (gpio_request(DNS323_GPIO_POWER_OFF, "POWEROFF") != 0 || |
481 | pr_err("DNS323: failed to setup power-off GPIO\n"); | 703 | gpio_direction_output(DNS323_GPIO_POWER_OFF, 0) != 0) |
482 | if (dns323_dev_id() == MV88F5182_DEV_ID) | 704 | pr_err("DNS-323: failed to setup power-off GPIO\n"); |
483 | pm_power_off = dns323b_power_off; | 705 | pm_power_off = dns323b_power_off; |
484 | else | 706 | break; |
485 | pm_power_off = dns323a_power_off; | 707 | case DNS323_REV_C1: |
708 | /* 5182 built-in SATA init */ | ||
709 | orion5x_sata_init(&dns323_sata_data); | ||
710 | |||
711 | /* Poweroff GPIO */ | ||
712 | if (gpio_request(DNS323C_GPIO_POWER_OFF, "POWEROFF") != 0 || | ||
713 | gpio_direction_output(DNS323C_GPIO_POWER_OFF, 0) != 0) | ||
714 | pr_err("DNS-323: failed to setup power-off GPIO\n"); | ||
715 | pm_power_off = dns323c_power_off; | ||
716 | |||
717 | /* Now, -this- should theorically be done by the sata_mv driver | ||
718 | * once I figure out what's going on there. Maybe the behaviour | ||
719 | * of the LEDs should be somewhat passed via the platform_data. | ||
720 | * for now, just whack the register and make the LEDs happy | ||
721 | * | ||
722 | * Note: AFAIK, rev B1 needs the same treatement but I'll let | ||
723 | * somebody else test it. | ||
724 | */ | ||
725 | writel(0x5, ORION5X_SATA_VIRT_BASE | 0x2c); | ||
726 | break; | ||
727 | } | ||
486 | } | 728 | } |
487 | 729 | ||
488 | /* Warning: D-Link uses a wrong mach-type (=526) in their bootloader */ | 730 | /* Warning: D-Link uses a wrong mach-type (=526) in their bootloader */ |
diff --git a/arch/arm/mach-orion5x/include/mach/system.h b/arch/arm/mach-orion5x/include/mach/system.h index 60e734c10458..a1d6e46ab035 100644 --- a/arch/arm/mach-orion5x/include/mach/system.h +++ b/arch/arm/mach-orion5x/include/mach/system.h | |||
@@ -25,6 +25,8 @@ static inline void arch_reset(char mode, const char *cmd) | |||
25 | */ | 25 | */ |
26 | orion5x_setbits(RSTOUTn_MASK, (1 << 2)); | 26 | orion5x_setbits(RSTOUTn_MASK, (1 << 2)); |
27 | orion5x_setbits(CPU_SOFT_RESET, 1); | 27 | orion5x_setbits(CPU_SOFT_RESET, 1); |
28 | mdelay(200); | ||
29 | orion5x_clrbits(CPU_SOFT_RESET, 1); | ||
28 | } | 30 | } |
29 | 31 | ||
30 | 32 | ||