Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ericvh...
[sfrench/cifs-2.6.git] / arch / arm / mach-kirkwood / netspace_v2-setup.c
index 3ae158d72681f13a2a6f9e0246c08e3a3f618d3a..d26bf324738bde48e5be8b5c5cf13978a9f03730 100644 (file)
@@ -39,6 +39,7 @@
 #include <asm/mach/arch.h>
 #include <asm/mach/time.h>
 #include <mach/kirkwood.h>
+#include <mach/leds-ns2.h>
 #include <plat/time.h>
 #include "common.h"
 #include "mpp.h"
@@ -126,6 +127,18 @@ static void __init netspace_v2_sata_power_init(void)
        }
        if (err)
                pr_err("netspace_v2: failed to setup SATA0 power\n");
+
+       if (machine_is_netspace_max_v2()) {
+               err = gpio_request(NETSPACE_V2_GPIO_SATA1_POWER, "SATA1 power");
+               if (err == 0) {
+                       err = gpio_direction_output(
+                                       NETSPACE_V2_GPIO_SATA1_POWER, 1);
+                       if (err)
+                               gpio_free(NETSPACE_V2_GPIO_SATA1_POWER);
+               }
+               if (err)
+                       pr_err("netspace_v2: failed to setup SATA1 power\n");
+       }
 }
 
 /*****************************************************************************
@@ -160,36 +173,12 @@ static struct platform_device netspace_v2_gpio_buttons = {
  * GPIO LEDs
  ****************************************************************************/
 
-/*
- * The blue front LED is wired to a CPLD and can blink in relation with the
- * SATA activity.
- *
- * The following array detail the different LED registers and the combination
- * of their possible values:
- *
- *  cmd_led   |  slow_led  | /SATA active | LED state
- *            |            |              |
- *     1      |     0      |      x       |  off
- *     -      |     1      |      x       |  on
- *     0      |     0      |      1       |  on
- *     0      |     0      |      0       |  blink (rate 300ms)
- */
-
 #define NETSPACE_V2_GPIO_RED_LED       12
-#define NETSPACE_V2_GPIO_BLUE_LED_SLOW 29
-#define NETSPACE_V2_GPIO_BLUE_LED_CMD  30
-
 
 static struct gpio_led netspace_v2_gpio_led_pins[] = {
        {
-               .name                   = "ns_v2:blue:sata",
-               .default_trigger        = "default-on",
-               .gpio                   = NETSPACE_V2_GPIO_BLUE_LED_CMD,
-               .active_low             = 1,
-       },
-       {
-               .name                   = "ns_v2:red:fail",
-               .gpio                   = NETSPACE_V2_GPIO_RED_LED,
+               .name   = "ns_v2:red:fail",
+               .gpio   = NETSPACE_V2_GPIO_RED_LED,
        },
 };
 
@@ -206,22 +195,33 @@ static struct platform_device netspace_v2_gpio_leds = {
        },
 };
 
-static void __init netspace_v2_gpio_leds_init(void)
-{
-       int err;
+/*****************************************************************************
+ * Dual-GPIO CPLD LEDs
+ ****************************************************************************/
 
-       /* Configure register slow_led to allow SATA activity LED blinking */
-       err = gpio_request(NETSPACE_V2_GPIO_BLUE_LED_SLOW, "blue LED slow");
-       if (err == 0) {
-               err = gpio_direction_output(NETSPACE_V2_GPIO_BLUE_LED_SLOW, 0);
-               if (err)
-                       gpio_free(NETSPACE_V2_GPIO_BLUE_LED_SLOW);
-       }
-       if (err)
-               pr_err("netspace_v2: failed to configure blue LED slow GPIO\n");
+#define NETSPACE_V2_GPIO_BLUE_LED_SLOW 29
+#define NETSPACE_V2_GPIO_BLUE_LED_CMD  30
 
-       platform_device_register(&netspace_v2_gpio_leds);
-}
+static struct ns2_led netspace_v2_led_pins[] = {
+       {
+               .name   = "ns_v2:blue:sata",
+               .cmd    = NETSPACE_V2_GPIO_BLUE_LED_CMD,
+               .slow   = NETSPACE_V2_GPIO_BLUE_LED_SLOW,
+       },
+};
+
+static struct ns2_led_platform_data netspace_v2_leds_data = {
+       .num_leds       = ARRAY_SIZE(netspace_v2_led_pins),
+       .leds           = netspace_v2_led_pins,
+};
+
+static struct platform_device netspace_v2_leds = {
+       .name           = "leds-ns2",
+       .id             = -1,
+       .dev            = {
+               .platform_data  = &netspace_v2_leds_data,
+       },
+};
 
 /*****************************************************************************
  * Timer
@@ -249,17 +249,21 @@ static unsigned int netspace_v2_mpp_config[] __initdata = {
        MPP4_NF_IO6,
        MPP5_NF_IO7,
        MPP6_SYSRST_OUTn,
-       MPP8_TW_SDA,
-       MPP9_TW_SCK,
+       MPP7_GPO,               /* Fan speed (bit 1) */
+       MPP8_TW0_SDA,
+       MPP9_TW0_SCK,
        MPP10_UART0_TXD,
        MPP11_UART0_RXD,
        MPP12_GPO,              /* Red led */
        MPP14_GPIO,             /* USB fuse */
        MPP16_GPIO,             /* SATA 0 power */
+       MPP17_GPIO,             /* SATA 1 power */
        MPP18_NF_IO0,
        MPP19_NF_IO1,
        MPP20_SATA1_ACTn,
        MPP21_SATA0_ACTn,
+       MPP22_GPIO,             /* Fan speed (bit 0) */
+       MPP23_GPIO,             /* Fan power */
        MPP24_GPIO,             /* USB mode select */
        MPP25_GPIO,             /* Fan rotation fail */
        MPP26_GPIO,             /* USB device vbus */
@@ -268,6 +272,7 @@ static unsigned int netspace_v2_mpp_config[] __initdata = {
        MPP30_GPIO,             /* Blue led (command register) */
        MPP31_GPIO,             /* Board power off */
        MPP32_GPIO,             /* Power button (0 = Released, 1 = Pushed) */
+       MPP33_GPO,              /* Fan speed (bit 2) */
        0
 };
 
@@ -299,7 +304,8 @@ static void __init netspace_v2_init(void)
        i2c_register_board_info(0, netspace_v2_i2c_info,
                                ARRAY_SIZE(netspace_v2_i2c_info));
 
-       netspace_v2_gpio_leds_init();
+       platform_device_register(&netspace_v2_leds);
+       platform_device_register(&netspace_v2_gpio_leds);
        platform_device_register(&netspace_v2_gpio_buttons);
 
        if (gpio_request(NETSPACE_V2_GPIO_POWER_OFF, "power-off") == 0 &&
@@ -332,3 +338,15 @@ MACHINE_START(INETSPACE_V2, "LaCie Internet Space v2")
        .timer          = &netspace_v2_timer,
 MACHINE_END
 #endif
+
+#ifdef CONFIG_MACH_NETSPACE_MAX_V2
+MACHINE_START(NETSPACE_MAX_V2, "LaCie Network Space Max v2")
+       .phys_io        = KIRKWOOD_REGS_PHYS_BASE,
+       .io_pg_offst    = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc,
+       .boot_params    = 0x00000100,
+       .init_machine   = netspace_v2_init,
+       .map_io         = kirkwood_map_io,
+       .init_irq       = kirkwood_init_irq,
+       .timer          = &netspace_v2_timer,
+MACHINE_END
+#endif