diff options
-rw-r--r-- | arch/arm/configs/kirkwood_defconfig | 1 | ||||
-rw-r--r-- | arch/arm/mach-kirkwood/Kconfig | 12 | ||||
-rw-r--r-- | arch/arm/mach-kirkwood/Makefile | 12 | ||||
-rw-r--r-- | arch/arm/mach-kirkwood/d2net_v2-setup.c | 231 | ||||
-rw-r--r-- | arch/arm/mach-kirkwood/dockstar-setup.c | 112 | ||||
-rw-r--r-- | arch/arm/mach-kirkwood/include/mach/leds-netxbig.h | 55 | ||||
-rw-r--r-- | arch/arm/mach-kirkwood/lacie_v2-common.c | 127 | ||||
-rw-r--r-- | arch/arm/mach-kirkwood/lacie_v2-common.h | 18 | ||||
-rw-r--r-- | arch/arm/mach-kirkwood/netspace_v2-setup.c | 122 | ||||
-rw-r--r-- | arch/arm/mach-kirkwood/netxbig_v2-setup.c | 269 | ||||
-rw-r--r-- | arch/arm/mach-kirkwood/openrd-setup.c | 101 | ||||
-rw-r--r-- | drivers/leds/Kconfig | 11 | ||||
-rw-r--r-- | drivers/leds/Makefile | 1 | ||||
-rw-r--r-- | drivers/leds/leds-netxbig.c | 449 | ||||
-rw-r--r-- | drivers/leds/leds-ns2.c | 9 |
15 files changed, 1277 insertions, 253 deletions
diff --git a/arch/arm/configs/kirkwood_defconfig b/arch/arm/configs/kirkwood_defconfig index ccc9c9959b82..2f7042813765 100644 --- a/arch/arm/configs/kirkwood_defconfig +++ b/arch/arm/configs/kirkwood_defconfig | |||
@@ -15,6 +15,7 @@ CONFIG_MACH_MV88F6281GTW_GE=y | |||
15 | CONFIG_MACH_SHEEVAPLUG=y | 15 | CONFIG_MACH_SHEEVAPLUG=y |
16 | CONFIG_MACH_ESATA_SHEEVAPLUG=y | 16 | CONFIG_MACH_ESATA_SHEEVAPLUG=y |
17 | CONFIG_MACH_GURUPLUG=y | 17 | CONFIG_MACH_GURUPLUG=y |
18 | CONFIG_MACH_DOCKSTAR=y | ||
18 | CONFIG_MACH_TS219=y | 19 | CONFIG_MACH_TS219=y |
19 | CONFIG_MACH_TS41X=y | 20 | CONFIG_MACH_TS41X=y |
20 | CONFIG_MACH_OPENRD_BASE=y | 21 | CONFIG_MACH_OPENRD_BASE=y |
diff --git a/arch/arm/mach-kirkwood/Kconfig b/arch/arm/mach-kirkwood/Kconfig index cc25501b57fa..34106335c728 100644 --- a/arch/arm/mach-kirkwood/Kconfig +++ b/arch/arm/mach-kirkwood/Kconfig | |||
@@ -58,6 +58,12 @@ config MACH_TS41X | |||
58 | QNAP TS-410, TS-410U, TS-419P and TS-419U Turbo NAS | 58 | QNAP TS-410, TS-410U, TS-419P and TS-419U Turbo NAS |
59 | devices. | 59 | devices. |
60 | 60 | ||
61 | config MACH_DOCKSTAR | ||
62 | bool "Seagate FreeAgent DockStar" | ||
63 | help | ||
64 | Say 'Y' here if you want your kernel to support the | ||
65 | Seagate FreeAgent DockStar. | ||
66 | |||
61 | config MACH_OPENRD | 67 | config MACH_OPENRD |
62 | bool | 68 | bool |
63 | 69 | ||
@@ -100,6 +106,12 @@ config MACH_NETSPACE_MAX_V2 | |||
100 | Say 'Y' here if you want your kernel to support the | 106 | Say 'Y' here if you want your kernel to support the |
101 | LaCie Network Space Max v2 NAS. | 107 | LaCie Network Space Max v2 NAS. |
102 | 108 | ||
109 | config MACH_D2NET_V2 | ||
110 | bool "LaCie d2 Network v2 NAS Board" | ||
111 | help | ||
112 | Say 'Y' here if you want your kernel to support the | ||
113 | LaCie d2 Network v2 NAS. | ||
114 | |||
103 | config MACH_NET2BIG_V2 | 115 | config MACH_NET2BIG_V2 |
104 | bool "LaCie 2Big Network v2 NAS Board" | 116 | bool "LaCie 2Big Network v2 NAS Board" |
105 | help | 117 | help |
diff --git a/arch/arm/mach-kirkwood/Makefile b/arch/arm/mach-kirkwood/Makefile index 295d7baa6ae1..5dcaa81a2ec3 100644 --- a/arch/arm/mach-kirkwood/Makefile +++ b/arch/arm/mach-kirkwood/Makefile | |||
@@ -7,14 +7,16 @@ obj-$(CONFIG_MACH_MV88F6281GTW_GE) += mv88f6281gtw_ge-setup.o | |||
7 | obj-$(CONFIG_MACH_SHEEVAPLUG) += sheevaplug-setup.o | 7 | obj-$(CONFIG_MACH_SHEEVAPLUG) += sheevaplug-setup.o |
8 | obj-$(CONFIG_MACH_ESATA_SHEEVAPLUG) += sheevaplug-setup.o | 8 | obj-$(CONFIG_MACH_ESATA_SHEEVAPLUG) += sheevaplug-setup.o |
9 | obj-$(CONFIG_MACH_GURUPLUG) += guruplug-setup.o | 9 | obj-$(CONFIG_MACH_GURUPLUG) += guruplug-setup.o |
10 | obj-$(CONFIG_MACH_DOCKSTAR) += dockstar-setup.o | ||
10 | obj-$(CONFIG_MACH_TS219) += ts219-setup.o tsx1x-common.o | 11 | obj-$(CONFIG_MACH_TS219) += ts219-setup.o tsx1x-common.o |
11 | obj-$(CONFIG_MACH_TS41X) += ts41x-setup.o tsx1x-common.o | 12 | obj-$(CONFIG_MACH_TS41X) += ts41x-setup.o tsx1x-common.o |
12 | obj-$(CONFIG_MACH_OPENRD) += openrd-setup.o | 13 | obj-$(CONFIG_MACH_OPENRD) += openrd-setup.o |
13 | obj-$(CONFIG_MACH_NETSPACE_V2) += netspace_v2-setup.o | 14 | obj-$(CONFIG_MACH_NETSPACE_V2) += netspace_v2-setup.o lacie_v2-common.o |
14 | obj-$(CONFIG_MACH_INETSPACE_V2) += netspace_v2-setup.o | 15 | obj-$(CONFIG_MACH_INETSPACE_V2) += netspace_v2-setup.o lacie_v2-common.o |
15 | obj-$(CONFIG_MACH_NETSPACE_MAX_V2) += netspace_v2-setup.o | 16 | obj-$(CONFIG_MACH_NETSPACE_MAX_V2) += netspace_v2-setup.o lacie_v2-common.o |
16 | obj-$(CONFIG_MACH_NET2BIG_V2) += netxbig_v2-setup.o | 17 | obj-$(CONFIG_MACH_D2NET_V2) += d2net_v2-setup.o lacie_v2-common.o |
17 | obj-$(CONFIG_MACH_NET5BIG_V2) += netxbig_v2-setup.o | 18 | obj-$(CONFIG_MACH_NET2BIG_V2) += netxbig_v2-setup.o lacie_v2-common.o |
19 | obj-$(CONFIG_MACH_NET5BIG_V2) += netxbig_v2-setup.o lacie_v2-common.o | ||
18 | obj-$(CONFIG_MACH_T5325) += t5325-setup.o | 20 | obj-$(CONFIG_MACH_T5325) += t5325-setup.o |
19 | 21 | ||
20 | obj-$(CONFIG_CPU_IDLE) += cpuidle.o | 22 | obj-$(CONFIG_CPU_IDLE) += cpuidle.o |
diff --git a/arch/arm/mach-kirkwood/d2net_v2-setup.c b/arch/arm/mach-kirkwood/d2net_v2-setup.c new file mode 100644 index 000000000000..cd62d0f82a73 --- /dev/null +++ b/arch/arm/mach-kirkwood/d2net_v2-setup.c | |||
@@ -0,0 +1,231 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-kirkwood/d2net_v2-setup.c | ||
3 | * | ||
4 | * LaCie d2 Network Space v2 Board Setup | ||
5 | * | ||
6 | * Copyright (C) 2010 Simon Guinot <sguinot@lacie.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
21 | */ | ||
22 | |||
23 | #include <linux/kernel.h> | ||
24 | #include <linux/init.h> | ||
25 | #include <linux/platform_device.h> | ||
26 | #include <linux/ata_platform.h> | ||
27 | #include <linux/mv643xx_eth.h> | ||
28 | #include <linux/input.h> | ||
29 | #include <linux/gpio.h> | ||
30 | #include <linux/gpio_keys.h> | ||
31 | #include <linux/leds.h> | ||
32 | #include <asm/mach-types.h> | ||
33 | #include <asm/mach/arch.h> | ||
34 | #include <mach/kirkwood.h> | ||
35 | #include <mach/leds-ns2.h> | ||
36 | #include "common.h" | ||
37 | #include "mpp.h" | ||
38 | #include "lacie_v2-common.h" | ||
39 | |||
40 | /***************************************************************************** | ||
41 | * Ethernet | ||
42 | ****************************************************************************/ | ||
43 | |||
44 | static struct mv643xx_eth_platform_data d2net_v2_ge00_data = { | ||
45 | .phy_addr = MV643XX_ETH_PHY_ADDR(8), | ||
46 | }; | ||
47 | |||
48 | /***************************************************************************** | ||
49 | * SATA | ||
50 | ****************************************************************************/ | ||
51 | |||
52 | static struct mv_sata_platform_data d2net_v2_sata_data = { | ||
53 | .n_ports = 2, | ||
54 | }; | ||
55 | |||
56 | /***************************************************************************** | ||
57 | * GPIO keys | ||
58 | ****************************************************************************/ | ||
59 | |||
60 | #define D2NET_V2_GPIO_PUSH_BUTTON 34 | ||
61 | #define D2NET_V2_GPIO_POWER_SWITCH_ON 13 | ||
62 | #define D2NET_V2_GPIO_POWER_SWITCH_OFF 15 | ||
63 | |||
64 | #define D2NET_V2_SWITCH_POWER_ON 0x1 | ||
65 | #define D2NET_V2_SWITCH_POWER_OFF 0x2 | ||
66 | |||
67 | static struct gpio_keys_button d2net_v2_buttons[] = { | ||
68 | [0] = { | ||
69 | .type = EV_SW, | ||
70 | .code = D2NET_V2_SWITCH_POWER_ON, | ||
71 | .gpio = D2NET_V2_GPIO_POWER_SWITCH_ON, | ||
72 | .desc = "Back power switch (on|auto)", | ||
73 | .active_low = 0, | ||
74 | }, | ||
75 | [1] = { | ||
76 | .type = EV_SW, | ||
77 | .code = D2NET_V2_SWITCH_POWER_OFF, | ||
78 | .gpio = D2NET_V2_GPIO_POWER_SWITCH_OFF, | ||
79 | .desc = "Back power switch (auto|off)", | ||
80 | .active_low = 0, | ||
81 | }, | ||
82 | [2] = { | ||
83 | .code = KEY_POWER, | ||
84 | .gpio = D2NET_V2_GPIO_PUSH_BUTTON, | ||
85 | .desc = "Front Push Button", | ||
86 | .active_low = 1, | ||
87 | }, | ||
88 | }; | ||
89 | |||
90 | static struct gpio_keys_platform_data d2net_v2_button_data = { | ||
91 | .buttons = d2net_v2_buttons, | ||
92 | .nbuttons = ARRAY_SIZE(d2net_v2_buttons), | ||
93 | }; | ||
94 | |||
95 | static struct platform_device d2net_v2_gpio_buttons = { | ||
96 | .name = "gpio-keys", | ||
97 | .id = -1, | ||
98 | .dev = { | ||
99 | .platform_data = &d2net_v2_button_data, | ||
100 | }, | ||
101 | }; | ||
102 | |||
103 | /***************************************************************************** | ||
104 | * GPIO LEDs | ||
105 | ****************************************************************************/ | ||
106 | |||
107 | #define D2NET_V2_GPIO_RED_LED 12 | ||
108 | |||
109 | static struct gpio_led d2net_v2_gpio_led_pins[] = { | ||
110 | { | ||
111 | .name = "d2net_v2:red:fail", | ||
112 | .gpio = D2NET_V2_GPIO_RED_LED, | ||
113 | }, | ||
114 | }; | ||
115 | |||
116 | static struct gpio_led_platform_data d2net_v2_gpio_leds_data = { | ||
117 | .num_leds = ARRAY_SIZE(d2net_v2_gpio_led_pins), | ||
118 | .leds = d2net_v2_gpio_led_pins, | ||
119 | }; | ||
120 | |||
121 | static struct platform_device d2net_v2_gpio_leds = { | ||
122 | .name = "leds-gpio", | ||
123 | .id = -1, | ||
124 | .dev = { | ||
125 | .platform_data = &d2net_v2_gpio_leds_data, | ||
126 | }, | ||
127 | }; | ||
128 | |||
129 | /***************************************************************************** | ||
130 | * Dual-GPIO CPLD LEDs | ||
131 | ****************************************************************************/ | ||
132 | |||
133 | #define D2NET_V2_GPIO_BLUE_LED_SLOW 29 | ||
134 | #define D2NET_V2_GPIO_BLUE_LED_CMD 30 | ||
135 | |||
136 | static struct ns2_led d2net_v2_led_pins[] = { | ||
137 | { | ||
138 | .name = "d2net_v2:blue:sata", | ||
139 | .cmd = D2NET_V2_GPIO_BLUE_LED_CMD, | ||
140 | .slow = D2NET_V2_GPIO_BLUE_LED_SLOW, | ||
141 | }, | ||
142 | }; | ||
143 | |||
144 | static struct ns2_led_platform_data d2net_v2_leds_data = { | ||
145 | .num_leds = ARRAY_SIZE(d2net_v2_led_pins), | ||
146 | .leds = d2net_v2_led_pins, | ||
147 | }; | ||
148 | |||
149 | static struct platform_device d2net_v2_leds = { | ||
150 | .name = "leds-ns2", | ||
151 | .id = -1, | ||
152 | .dev = { | ||
153 | .platform_data = &d2net_v2_leds_data, | ||
154 | }, | ||
155 | }; | ||
156 | |||
157 | /***************************************************************************** | ||
158 | * General Setup | ||
159 | ****************************************************************************/ | ||
160 | |||
161 | static unsigned int d2net_v2_mpp_config[] __initdata = { | ||
162 | MPP0_SPI_SCn, | ||
163 | MPP1_SPI_MOSI, | ||
164 | MPP2_SPI_SCK, | ||
165 | MPP3_SPI_MISO, | ||
166 | MPP6_SYSRST_OUTn, | ||
167 | MPP7_GPO, /* Request power-off */ | ||
168 | MPP8_TW0_SDA, | ||
169 | MPP9_TW0_SCK, | ||
170 | MPP10_UART0_TXD, | ||
171 | MPP11_UART0_RXD, | ||
172 | MPP12_GPO, /* Red led */ | ||
173 | MPP13_GPIO, /* Rear power switch (on|auto) */ | ||
174 | MPP14_GPIO, /* USB fuse */ | ||
175 | MPP15_GPIO, /* Rear power switch (auto|off) */ | ||
176 | MPP16_GPIO, /* SATA 0 power */ | ||
177 | MPP21_SATA0_ACTn, | ||
178 | MPP24_GPIO, /* USB mode select */ | ||
179 | MPP26_GPIO, /* USB device vbus */ | ||
180 | MPP28_GPIO, /* USB enable host vbus */ | ||
181 | MPP29_GPIO, /* Blue led (slow register) */ | ||
182 | MPP30_GPIO, /* Blue led (command register) */ | ||
183 | MPP34_GPIO, /* Power button (1 = Released, 0 = Pushed) */ | ||
184 | MPP35_GPIO, /* Inhibit power-off */ | ||
185 | 0 | ||
186 | }; | ||
187 | |||
188 | #define D2NET_V2_GPIO_POWER_OFF 7 | ||
189 | |||
190 | static void d2net_v2_power_off(void) | ||
191 | { | ||
192 | gpio_set_value(D2NET_V2_GPIO_POWER_OFF, 1); | ||
193 | } | ||
194 | |||
195 | static void __init d2net_v2_init(void) | ||
196 | { | ||
197 | /* | ||
198 | * Basic setup. Needs to be called early. | ||
199 | */ | ||
200 | kirkwood_init(); | ||
201 | kirkwood_mpp_conf(d2net_v2_mpp_config); | ||
202 | |||
203 | lacie_v2_hdd_power_init(1); | ||
204 | |||
205 | kirkwood_ehci_init(); | ||
206 | kirkwood_ge00_init(&d2net_v2_ge00_data); | ||
207 | kirkwood_sata_init(&d2net_v2_sata_data); | ||
208 | kirkwood_uart0_init(); | ||
209 | lacie_v2_register_flash(); | ||
210 | lacie_v2_register_i2c_devices(); | ||
211 | |||
212 | platform_device_register(&d2net_v2_leds); | ||
213 | platform_device_register(&d2net_v2_gpio_leds); | ||
214 | platform_device_register(&d2net_v2_gpio_buttons); | ||
215 | |||
216 | if (gpio_request(D2NET_V2_GPIO_POWER_OFF, "power-off") == 0 && | ||
217 | gpio_direction_output(D2NET_V2_GPIO_POWER_OFF, 0) == 0) | ||
218 | pm_power_off = d2net_v2_power_off; | ||
219 | else | ||
220 | pr_err("d2net_v2: failed to configure power-off GPIO\n"); | ||
221 | } | ||
222 | |||
223 | MACHINE_START(D2NET_V2, "LaCie d2 Network v2") | ||
224 | .phys_io = KIRKWOOD_REGS_PHYS_BASE, | ||
225 | .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc, | ||
226 | .boot_params = 0x00000100, | ||
227 | .init_machine = d2net_v2_init, | ||
228 | .map_io = kirkwood_map_io, | ||
229 | .init_irq = kirkwood_init_irq, | ||
230 | .timer = &lacie_v2_timer, | ||
231 | MACHINE_END | ||
diff --git a/arch/arm/mach-kirkwood/dockstar-setup.c b/arch/arm/mach-kirkwood/dockstar-setup.c new file mode 100644 index 000000000000..a90475d5059c --- /dev/null +++ b/arch/arm/mach-kirkwood/dockstar-setup.c | |||
@@ -0,0 +1,112 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-kirkwood/dockstar-setup.c | ||
3 | * | ||
4 | * Seagate FreeAgent DockStar Setup | ||
5 | * | ||
6 | * This file is licensed under the terms of the GNU General Public | ||
7 | * License version 2. This program is licensed "as is" without any | ||
8 | * warranty of any kind, whether express or implied. | ||
9 | */ | ||
10 | |||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/init.h> | ||
13 | #include <linux/platform_device.h> | ||
14 | #include <linux/ata_platform.h> | ||
15 | #include <linux/mtd/partitions.h> | ||
16 | #include <linux/mv643xx_eth.h> | ||
17 | #include <linux/gpio.h> | ||
18 | #include <linux/leds.h> | ||
19 | #include <asm/mach-types.h> | ||
20 | #include <asm/mach/arch.h> | ||
21 | #include <mach/kirkwood.h> | ||
22 | #include <plat/mvsdio.h> | ||
23 | #include "common.h" | ||
24 | #include "mpp.h" | ||
25 | |||
26 | static struct mtd_partition dockstar_nand_parts[] = { | ||
27 | { | ||
28 | .name = "u-boot", | ||
29 | .offset = 0, | ||
30 | .size = SZ_1M | ||
31 | }, { | ||
32 | .name = "uImage", | ||
33 | .offset = MTDPART_OFS_NXTBLK, | ||
34 | .size = SZ_4M | ||
35 | }, { | ||
36 | .name = "root", | ||
37 | .offset = MTDPART_OFS_NXTBLK, | ||
38 | .size = MTDPART_SIZ_FULL | ||
39 | }, | ||
40 | }; | ||
41 | |||
42 | static struct mv643xx_eth_platform_data dockstar_ge00_data = { | ||
43 | .phy_addr = MV643XX_ETH_PHY_ADDR(0), | ||
44 | }; | ||
45 | |||
46 | static struct gpio_led dockstar_led_pins[] = { | ||
47 | { | ||
48 | .name = "dockstar:green:health", | ||
49 | .default_trigger = "default-on", | ||
50 | .gpio = 46, | ||
51 | .active_low = 1, | ||
52 | }, | ||
53 | { | ||
54 | .name = "dockstar:orange:misc", | ||
55 | .default_trigger = "none", | ||
56 | .gpio = 47, | ||
57 | .active_low = 1, | ||
58 | }, | ||
59 | }; | ||
60 | |||
61 | static struct gpio_led_platform_data dockstar_led_data = { | ||
62 | .leds = dockstar_led_pins, | ||
63 | .num_leds = ARRAY_SIZE(dockstar_led_pins), | ||
64 | }; | ||
65 | |||
66 | static struct platform_device dockstar_leds = { | ||
67 | .name = "leds-gpio", | ||
68 | .id = -1, | ||
69 | .dev = { | ||
70 | .platform_data = &dockstar_led_data, | ||
71 | } | ||
72 | }; | ||
73 | |||
74 | static unsigned int dockstar_mpp_config[] __initdata = { | ||
75 | MPP29_GPIO, /* USB Power Enable */ | ||
76 | MPP46_GPIO, /* LED green */ | ||
77 | MPP47_GPIO, /* LED orange */ | ||
78 | 0 | ||
79 | }; | ||
80 | |||
81 | static void __init dockstar_init(void) | ||
82 | { | ||
83 | /* | ||
84 | * Basic setup. Needs to be called early. | ||
85 | */ | ||
86 | kirkwood_init(); | ||
87 | |||
88 | /* setup gpio pin select */ | ||
89 | kirkwood_mpp_conf(dockstar_mpp_config); | ||
90 | |||
91 | kirkwood_uart0_init(); | ||
92 | kirkwood_nand_init(ARRAY_AND_SIZE(dockstar_nand_parts), 25); | ||
93 | |||
94 | if (gpio_request(29, "USB Power Enable") != 0 || | ||
95 | gpio_direction_output(29, 1) != 0) | ||
96 | printk(KERN_ERR "can't set up GPIO 29 (USB Power Enable)\n"); | ||
97 | kirkwood_ehci_init(); | ||
98 | |||
99 | kirkwood_ge00_init(&dockstar_ge00_data); | ||
100 | |||
101 | platform_device_register(&dockstar_leds); | ||
102 | } | ||
103 | |||
104 | MACHINE_START(DOCKSTAR, "Seagate FreeAgent DockStar") | ||
105 | .phys_io = KIRKWOOD_REGS_PHYS_BASE, | ||
106 | .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc, | ||
107 | .boot_params = 0x00000100, | ||
108 | .init_machine = dockstar_init, | ||
109 | .map_io = kirkwood_map_io, | ||
110 | .init_irq = kirkwood_init_irq, | ||
111 | .timer = &kirkwood_timer, | ||
112 | MACHINE_END | ||
diff --git a/arch/arm/mach-kirkwood/include/mach/leds-netxbig.h b/arch/arm/mach-kirkwood/include/mach/leds-netxbig.h new file mode 100644 index 000000000000..24b536ebdf13 --- /dev/null +++ b/arch/arm/mach-kirkwood/include/mach/leds-netxbig.h | |||
@@ -0,0 +1,55 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-kirkwood/include/mach/leds-netxbig.h | ||
3 | * | ||
4 | * Platform data structure for netxbig LED driver | ||
5 | * | ||
6 | * This file is licensed under the terms of the GNU General Public | ||
7 | * License version 2. This program is licensed "as is" without any | ||
8 | * warranty of any kind, whether express or implied. | ||
9 | */ | ||
10 | |||
11 | #ifndef __MACH_LEDS_NETXBIG_H | ||
12 | #define __MACH_LEDS_NETXBIG_H | ||
13 | |||
14 | struct netxbig_gpio_ext { | ||
15 | unsigned *addr; | ||
16 | int num_addr; | ||
17 | unsigned *data; | ||
18 | int num_data; | ||
19 | unsigned enable; | ||
20 | }; | ||
21 | |||
22 | enum netxbig_led_mode { | ||
23 | NETXBIG_LED_OFF, | ||
24 | NETXBIG_LED_ON, | ||
25 | NETXBIG_LED_SATA, | ||
26 | NETXBIG_LED_TIMER1, | ||
27 | NETXBIG_LED_TIMER2, | ||
28 | NETXBIG_LED_MODE_NUM, | ||
29 | }; | ||
30 | |||
31 | #define NETXBIG_LED_INVALID_MODE NETXBIG_LED_MODE_NUM | ||
32 | |||
33 | struct netxbig_led_timer { | ||
34 | unsigned long delay_on; | ||
35 | unsigned long delay_off; | ||
36 | enum netxbig_led_mode mode; | ||
37 | }; | ||
38 | |||
39 | struct netxbig_led { | ||
40 | const char *name; | ||
41 | const char *default_trigger; | ||
42 | int mode_addr; | ||
43 | int *mode_val; | ||
44 | int bright_addr; | ||
45 | }; | ||
46 | |||
47 | struct netxbig_led_platform_data { | ||
48 | struct netxbig_gpio_ext *gpio_ext; | ||
49 | struct netxbig_led_timer *timer; | ||
50 | int num_timer; | ||
51 | struct netxbig_led *leds; | ||
52 | int num_leds; | ||
53 | }; | ||
54 | |||
55 | #endif /* __MACH_LEDS_NETXBIG_H */ | ||
diff --git a/arch/arm/mach-kirkwood/lacie_v2-common.c b/arch/arm/mach-kirkwood/lacie_v2-common.c new file mode 100644 index 000000000000..d3ea1b6c8a02 --- /dev/null +++ b/arch/arm/mach-kirkwood/lacie_v2-common.c | |||
@@ -0,0 +1,127 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-kirkwood/lacie_v2-common.c | ||
3 | * | ||
4 | * This file is licensed under the terms of the GNU General Public | ||
5 | * License version 2. This program is licensed "as is" without any | ||
6 | * warranty of any kind, whether express or implied. | ||
7 | */ | ||
8 | |||
9 | #include <linux/kernel.h> | ||
10 | #include <linux/init.h> | ||
11 | #include <linux/mtd/physmap.h> | ||
12 | #include <linux/spi/flash.h> | ||
13 | #include <linux/spi/spi.h> | ||
14 | #include <linux/i2c.h> | ||
15 | #include <linux/i2c/at24.h> | ||
16 | #include <linux/gpio.h> | ||
17 | #include <asm/mach/time.h> | ||
18 | #include <mach/kirkwood.h> | ||
19 | #include <mach/irqs.h> | ||
20 | #include <plat/time.h> | ||
21 | #include "common.h" | ||
22 | |||
23 | /***************************************************************************** | ||
24 | * 512KB SPI Flash on Boot Device (MACRONIX MX25L4005) | ||
25 | ****************************************************************************/ | ||
26 | |||
27 | static struct mtd_partition lacie_v2_flash_parts[] = { | ||
28 | { | ||
29 | .name = "u-boot", | ||
30 | .size = MTDPART_SIZ_FULL, | ||
31 | .offset = 0, | ||
32 | .mask_flags = MTD_WRITEABLE, /* force read-only */ | ||
33 | }, | ||
34 | }; | ||
35 | |||
36 | static const struct flash_platform_data lacie_v2_flash = { | ||
37 | .type = "mx25l4005a", | ||
38 | .name = "spi_flash", | ||
39 | .parts = lacie_v2_flash_parts, | ||
40 | .nr_parts = ARRAY_SIZE(lacie_v2_flash_parts), | ||
41 | }; | ||
42 | |||
43 | static struct spi_board_info __initdata lacie_v2_spi_slave_info[] = { | ||
44 | { | ||
45 | .modalias = "m25p80", | ||
46 | .platform_data = &lacie_v2_flash, | ||
47 | .irq = -1, | ||
48 | .max_speed_hz = 20000000, | ||
49 | .bus_num = 0, | ||
50 | .chip_select = 0, | ||
51 | }, | ||
52 | }; | ||
53 | |||
54 | void __init lacie_v2_register_flash(void) | ||
55 | { | ||
56 | spi_register_board_info(lacie_v2_spi_slave_info, | ||
57 | ARRAY_SIZE(lacie_v2_spi_slave_info)); | ||
58 | kirkwood_spi_init(); | ||
59 | } | ||
60 | |||
61 | /***************************************************************************** | ||
62 | * I2C devices | ||
63 | ****************************************************************************/ | ||
64 | |||
65 | static struct at24_platform_data at24c04 = { | ||
66 | .byte_len = SZ_4K / 8, | ||
67 | .page_size = 16, | ||
68 | }; | ||
69 | |||
70 | /* | ||
71 | * i2c addr | chip | description | ||
72 | * 0x50 | HT24LC04 | eeprom (512B) | ||
73 | */ | ||
74 | |||
75 | static struct i2c_board_info __initdata lacie_v2_i2c_info[] = { | ||
76 | { | ||
77 | I2C_BOARD_INFO("24c04", 0x50), | ||
78 | .platform_data = &at24c04, | ||
79 | } | ||
80 | }; | ||
81 | |||
82 | void __init lacie_v2_register_i2c_devices(void) | ||
83 | { | ||
84 | kirkwood_i2c_init(); | ||
85 | i2c_register_board_info(0, lacie_v2_i2c_info, | ||
86 | ARRAY_SIZE(lacie_v2_i2c_info)); | ||
87 | } | ||
88 | |||
89 | /***************************************************************************** | ||
90 | * Hard Disk power | ||
91 | ****************************************************************************/ | ||
92 | |||
93 | static int __initdata lacie_v2_gpio_hdd_power[] = { 16, 17, 41, 42, 43 }; | ||
94 | |||
95 | void __init lacie_v2_hdd_power_init(int hdd_num) | ||
96 | { | ||
97 | int i; | ||
98 | int err; | ||
99 | |||
100 | /* Power up all hard disks. */ | ||
101 | for (i = 0; i < hdd_num; i++) { | ||
102 | err = gpio_request(lacie_v2_gpio_hdd_power[i], NULL); | ||
103 | if (err == 0) { | ||
104 | err = gpio_direction_output( | ||
105 | lacie_v2_gpio_hdd_power[i], 1); | ||
106 | /* Free the HDD power GPIOs. This allow user-space to | ||
107 | * configure them via the gpiolib sysfs interface. */ | ||
108 | gpio_free(lacie_v2_gpio_hdd_power[i]); | ||
109 | } | ||
110 | if (err) | ||
111 | pr_err("Failed to power up HDD%d\n", i + 1); | ||
112 | } | ||
113 | } | ||
114 | |||
115 | /***************************************************************************** | ||
116 | * Timer | ||
117 | ****************************************************************************/ | ||
118 | |||
119 | static void lacie_v2_timer_init(void) | ||
120 | { | ||
121 | kirkwood_tclk = 166666667; | ||
122 | orion_time_init(IRQ_KIRKWOOD_BRIDGE, kirkwood_tclk); | ||
123 | } | ||
124 | |||
125 | struct sys_timer lacie_v2_timer = { | ||
126 | .init = lacie_v2_timer_init, | ||
127 | }; | ||
diff --git a/arch/arm/mach-kirkwood/lacie_v2-common.h b/arch/arm/mach-kirkwood/lacie_v2-common.h new file mode 100644 index 000000000000..af521315b87b --- /dev/null +++ b/arch/arm/mach-kirkwood/lacie_v2-common.h | |||
@@ -0,0 +1,18 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-kirkwood/lacie_v2-common.h | ||
3 | * | ||
4 | * This file is licensed under the terms of the GNU General Public | ||
5 | * License version 2. This program is licensed "as is" without any | ||
6 | * warranty of any kind, whether express or implied. | ||
7 | */ | ||
8 | |||
9 | #ifndef __ARCH_KIRKWOOD_LACIE_V2_COMMON_H | ||
10 | #define __ARCH_KIRKWOOD_LACIE_V2_COMMON_H | ||
11 | |||
12 | void lacie_v2_register_flash(void); | ||
13 | void lacie_v2_register_i2c_devices(void); | ||
14 | void lacie_v2_hdd_power_init(int hdd_num); | ||
15 | |||
16 | extern struct sys_timer lacie_v2_timer; | ||
17 | |||
18 | #endif | ||
diff --git a/arch/arm/mach-kirkwood/netspace_v2-setup.c b/arch/arm/mach-kirkwood/netspace_v2-setup.c index d26bf324738b..fed264d28f4a 100644 --- a/arch/arm/mach-kirkwood/netspace_v2-setup.c +++ b/arch/arm/mach-kirkwood/netspace_v2-setup.c | |||
@@ -24,56 +24,19 @@ | |||
24 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
25 | #include <linux/init.h> | 25 | #include <linux/init.h> |
26 | #include <linux/platform_device.h> | 26 | #include <linux/platform_device.h> |
27 | #include <linux/mtd/physmap.h> | ||
28 | #include <linux/spi/flash.h> | ||
29 | #include <linux/spi/spi.h> | ||
30 | #include <linux/ata_platform.h> | 27 | #include <linux/ata_platform.h> |
31 | #include <linux/mv643xx_eth.h> | 28 | #include <linux/mv643xx_eth.h> |
32 | #include <linux/i2c.h> | ||
33 | #include <linux/i2c/at24.h> | ||
34 | #include <linux/input.h> | 29 | #include <linux/input.h> |
35 | #include <linux/gpio.h> | 30 | #include <linux/gpio.h> |
36 | #include <linux/gpio_keys.h> | 31 | #include <linux/gpio_keys.h> |
37 | #include <linux/leds.h> | 32 | #include <linux/leds.h> |
38 | #include <asm/mach-types.h> | 33 | #include <asm/mach-types.h> |
39 | #include <asm/mach/arch.h> | 34 | #include <asm/mach/arch.h> |
40 | #include <asm/mach/time.h> | ||
41 | #include <mach/kirkwood.h> | 35 | #include <mach/kirkwood.h> |
42 | #include <mach/leds-ns2.h> | 36 | #include <mach/leds-ns2.h> |
43 | #include <plat/time.h> | ||
44 | #include "common.h" | 37 | #include "common.h" |
45 | #include "mpp.h" | 38 | #include "mpp.h" |
46 | 39 | #include "lacie_v2-common.h" | |
47 | /***************************************************************************** | ||
48 | * 512KB SPI Flash on Boot Device (MACRONIX MX25L4005) | ||
49 | ****************************************************************************/ | ||
50 | |||
51 | static struct mtd_partition netspace_v2_flash_parts[] = { | ||
52 | { | ||
53 | .name = "u-boot", | ||
54 | .size = MTDPART_SIZ_FULL, | ||
55 | .offset = 0, | ||
56 | .mask_flags = MTD_WRITEABLE, /* force read-only */ | ||
57 | }, | ||
58 | }; | ||
59 | |||
60 | static const struct flash_platform_data netspace_v2_flash = { | ||
61 | .type = "mx25l4005a", | ||
62 | .name = "spi_flash", | ||
63 | .parts = netspace_v2_flash_parts, | ||
64 | .nr_parts = ARRAY_SIZE(netspace_v2_flash_parts), | ||
65 | }; | ||
66 | |||
67 | static struct spi_board_info __initdata netspace_v2_spi_slave_info[] = { | ||
68 | { | ||
69 | .modalias = "m25p80", | ||
70 | .platform_data = &netspace_v2_flash, | ||
71 | .irq = -1, | ||
72 | .max_speed_hz = 20000000, | ||
73 | .bus_num = 0, | ||
74 | .chip_select = 0, | ||
75 | }, | ||
76 | }; | ||
77 | 40 | ||
78 | /***************************************************************************** | 41 | /***************************************************************************** |
79 | * Ethernet | 42 | * Ethernet |
@@ -84,27 +47,6 @@ static struct mv643xx_eth_platform_data netspace_v2_ge00_data = { | |||
84 | }; | 47 | }; |
85 | 48 | ||
86 | /***************************************************************************** | 49 | /***************************************************************************** |
87 | * I2C devices | ||
88 | ****************************************************************************/ | ||
89 | |||
90 | static struct at24_platform_data at24c04 = { | ||
91 | .byte_len = SZ_4K / 8, | ||
92 | .page_size = 16, | ||
93 | }; | ||
94 | |||
95 | /* | ||
96 | * i2c addr | chip | description | ||
97 | * 0x50 | HT24LC04 | eeprom (512B) | ||
98 | */ | ||
99 | |||
100 | static struct i2c_board_info __initdata netspace_v2_i2c_info[] = { | ||
101 | { | ||
102 | I2C_BOARD_INFO("24c04", 0x50), | ||
103 | .platform_data = &at24c04, | ||
104 | } | ||
105 | }; | ||
106 | |||
107 | /***************************************************************************** | ||
108 | * SATA | 50 | * SATA |
109 | ****************************************************************************/ | 51 | ****************************************************************************/ |
110 | 52 | ||
@@ -112,35 +54,6 @@ static struct mv_sata_platform_data netspace_v2_sata_data = { | |||
112 | .n_ports = 2, | 54 | .n_ports = 2, |
113 | }; | 55 | }; |
114 | 56 | ||
115 | #define NETSPACE_V2_GPIO_SATA0_POWER 16 | ||
116 | #define NETSPACE_V2_GPIO_SATA1_POWER 17 | ||
117 | |||
118 | static void __init netspace_v2_sata_power_init(void) | ||
119 | { | ||
120 | int err; | ||
121 | |||
122 | err = gpio_request(NETSPACE_V2_GPIO_SATA0_POWER, "SATA0 power"); | ||
123 | if (err == 0) { | ||
124 | err = gpio_direction_output(NETSPACE_V2_GPIO_SATA0_POWER, 1); | ||
125 | if (err) | ||
126 | gpio_free(NETSPACE_V2_GPIO_SATA0_POWER); | ||
127 | } | ||
128 | if (err) | ||
129 | pr_err("netspace_v2: failed to setup SATA0 power\n"); | ||
130 | |||
131 | if (machine_is_netspace_max_v2()) { | ||
132 | err = gpio_request(NETSPACE_V2_GPIO_SATA1_POWER, "SATA1 power"); | ||
133 | if (err == 0) { | ||
134 | err = gpio_direction_output( | ||
135 | NETSPACE_V2_GPIO_SATA1_POWER, 1); | ||
136 | if (err) | ||
137 | gpio_free(NETSPACE_V2_GPIO_SATA1_POWER); | ||
138 | } | ||
139 | if (err) | ||
140 | pr_err("netspace_v2: failed to setup SATA1 power\n"); | ||
141 | } | ||
142 | } | ||
143 | |||
144 | /***************************************************************************** | 57 | /***************************************************************************** |
145 | * GPIO keys | 58 | * GPIO keys |
146 | ****************************************************************************/ | 59 | ****************************************************************************/ |
@@ -224,20 +137,6 @@ static struct platform_device netspace_v2_leds = { | |||
224 | }; | 137 | }; |
225 | 138 | ||
226 | /***************************************************************************** | 139 | /***************************************************************************** |
227 | * Timer | ||
228 | ****************************************************************************/ | ||
229 | |||
230 | static void netspace_v2_timer_init(void) | ||
231 | { | ||
232 | kirkwood_tclk = 166666667; | ||
233 | orion_time_init(IRQ_KIRKWOOD_BRIDGE, kirkwood_tclk); | ||
234 | } | ||
235 | |||
236 | struct sys_timer netspace_v2_timer = { | ||
237 | .init = netspace_v2_timer_init, | ||
238 | }; | ||
239 | |||
240 | /***************************************************************************** | ||
241 | * General Setup | 140 | * General Setup |
242 | ****************************************************************************/ | 141 | ****************************************************************************/ |
243 | 142 | ||
@@ -291,18 +190,17 @@ static void __init netspace_v2_init(void) | |||
291 | kirkwood_init(); | 190 | kirkwood_init(); |
292 | kirkwood_mpp_conf(netspace_v2_mpp_config); | 191 | kirkwood_mpp_conf(netspace_v2_mpp_config); |
293 | 192 | ||
294 | netspace_v2_sata_power_init(); | 193 | if (machine_is_netspace_max_v2()) |
194 | lacie_v2_hdd_power_init(2); | ||
195 | else | ||
196 | lacie_v2_hdd_power_init(1); | ||
295 | 197 | ||
296 | kirkwood_ehci_init(); | 198 | kirkwood_ehci_init(); |
297 | kirkwood_ge00_init(&netspace_v2_ge00_data); | 199 | kirkwood_ge00_init(&netspace_v2_ge00_data); |
298 | kirkwood_sata_init(&netspace_v2_sata_data); | 200 | kirkwood_sata_init(&netspace_v2_sata_data); |
299 | kirkwood_uart0_init(); | 201 | kirkwood_uart0_init(); |
300 | spi_register_board_info(netspace_v2_spi_slave_info, | 202 | lacie_v2_register_flash(); |
301 | ARRAY_SIZE(netspace_v2_spi_slave_info)); | 203 | lacie_v2_register_i2c_devices(); |
302 | kirkwood_spi_init(); | ||
303 | kirkwood_i2c_init(); | ||
304 | i2c_register_board_info(0, netspace_v2_i2c_info, | ||
305 | ARRAY_SIZE(netspace_v2_i2c_info)); | ||
306 | 204 | ||
307 | platform_device_register(&netspace_v2_leds); | 205 | platform_device_register(&netspace_v2_leds); |
308 | platform_device_register(&netspace_v2_gpio_leds); | 206 | platform_device_register(&netspace_v2_gpio_leds); |
@@ -323,7 +221,7 @@ MACHINE_START(NETSPACE_V2, "LaCie Network Space v2") | |||
323 | .init_machine = netspace_v2_init, | 221 | .init_machine = netspace_v2_init, |
324 | .map_io = kirkwood_map_io, | 222 | .map_io = kirkwood_map_io, |
325 | .init_irq = kirkwood_init_irq, | 223 | .init_irq = kirkwood_init_irq, |
326 | .timer = &netspace_v2_timer, | 224 | .timer = &lacie_v2_timer, |
327 | MACHINE_END | 225 | MACHINE_END |
328 | #endif | 226 | #endif |
329 | 227 | ||
@@ -335,7 +233,7 @@ MACHINE_START(INETSPACE_V2, "LaCie Internet Space v2") | |||
335 | .init_machine = netspace_v2_init, | 233 | .init_machine = netspace_v2_init, |
336 | .map_io = kirkwood_map_io, | 234 | .map_io = kirkwood_map_io, |
337 | .init_irq = kirkwood_init_irq, | 235 | .init_irq = kirkwood_init_irq, |
338 | .timer = &netspace_v2_timer, | 236 | .timer = &lacie_v2_timer, |
339 | MACHINE_END | 237 | MACHINE_END |
340 | #endif | 238 | #endif |
341 | 239 | ||
@@ -347,6 +245,6 @@ MACHINE_START(NETSPACE_MAX_V2, "LaCie Network Space Max v2") | |||
347 | .init_machine = netspace_v2_init, | 245 | .init_machine = netspace_v2_init, |
348 | .map_io = kirkwood_map_io, | 246 | .map_io = kirkwood_map_io, |
349 | .init_irq = kirkwood_init_irq, | 247 | .init_irq = kirkwood_init_irq, |
350 | .timer = &netspace_v2_timer, | 248 | .timer = &lacie_v2_timer, |
351 | MACHINE_END | 249 | MACHINE_END |
352 | #endif | 250 | #endif |
diff --git a/arch/arm/mach-kirkwood/netxbig_v2-setup.c b/arch/arm/mach-kirkwood/netxbig_v2-setup.c index 2bd14c5079de..d970e1eee37d 100644 --- a/arch/arm/mach-kirkwood/netxbig_v2-setup.c +++ b/arch/arm/mach-kirkwood/netxbig_v2-setup.c | |||
@@ -23,55 +23,19 @@ | |||
23 | #include <linux/kernel.h> | 23 | #include <linux/kernel.h> |
24 | #include <linux/init.h> | 24 | #include <linux/init.h> |
25 | #include <linux/platform_device.h> | 25 | #include <linux/platform_device.h> |
26 | #include <linux/mtd/physmap.h> | ||
27 | #include <linux/spi/flash.h> | ||
28 | #include <linux/spi/spi.h> | ||
29 | #include <linux/ata_platform.h> | 26 | #include <linux/ata_platform.h> |
30 | #include <linux/mv643xx_eth.h> | 27 | #include <linux/mv643xx_eth.h> |
31 | #include <linux/i2c.h> | ||
32 | #include <linux/i2c/at24.h> | ||
33 | #include <linux/input.h> | 28 | #include <linux/input.h> |
34 | #include <linux/gpio.h> | 29 | #include <linux/gpio.h> |
35 | #include <linux/gpio_keys.h> | 30 | #include <linux/gpio_keys.h> |
36 | #include <linux/leds.h> | 31 | #include <linux/leds.h> |
37 | #include <asm/mach-types.h> | 32 | #include <asm/mach-types.h> |
38 | #include <asm/mach/arch.h> | 33 | #include <asm/mach/arch.h> |
39 | #include <asm/mach/time.h> | ||
40 | #include <mach/kirkwood.h> | 34 | #include <mach/kirkwood.h> |
41 | #include <plat/time.h> | 35 | #include <mach/leds-netxbig.h> |
42 | #include "common.h" | 36 | #include "common.h" |
43 | #include "mpp.h" | 37 | #include "mpp.h" |
44 | 38 | #include "lacie_v2-common.h" | |
45 | /***************************************************************************** | ||
46 | * 512KB SPI Flash on Boot Device (MACRONIX MX25L4005) | ||
47 | ****************************************************************************/ | ||
48 | |||
49 | static struct mtd_partition netxbig_v2_flash_parts[] = { | ||
50 | { | ||
51 | .name = "u-boot", | ||
52 | .size = MTDPART_SIZ_FULL, | ||
53 | .offset = 0, | ||
54 | .mask_flags = MTD_WRITEABLE, /* force read-only */ | ||
55 | }, | ||
56 | }; | ||
57 | |||
58 | static const struct flash_platform_data netxbig_v2_flash = { | ||
59 | .type = "mx25l4005a", | ||
60 | .name = "spi_flash", | ||
61 | .parts = netxbig_v2_flash_parts, | ||
62 | .nr_parts = ARRAY_SIZE(netxbig_v2_flash_parts), | ||
63 | }; | ||
64 | |||
65 | static struct spi_board_info __initdata netxbig_v2_spi_slave_info[] = { | ||
66 | { | ||
67 | .modalias = "m25p80", | ||
68 | .platform_data = &netxbig_v2_flash, | ||
69 | .irq = -1, | ||
70 | .max_speed_hz = 20000000, | ||
71 | .bus_num = 0, | ||
72 | .chip_select = 0, | ||
73 | }, | ||
74 | }; | ||
75 | 39 | ||
76 | /***************************************************************************** | 40 | /***************************************************************************** |
77 | * Ethernet | 41 | * Ethernet |
@@ -86,27 +50,6 @@ static struct mv643xx_eth_platform_data netxbig_v2_ge01_data = { | |||
86 | }; | 50 | }; |
87 | 51 | ||
88 | /***************************************************************************** | 52 | /***************************************************************************** |
89 | * I2C devices | ||
90 | ****************************************************************************/ | ||
91 | |||
92 | static struct at24_platform_data at24c04 = { | ||
93 | .byte_len = SZ_4K / 8, | ||
94 | .page_size = 16, | ||
95 | }; | ||
96 | |||
97 | /* | ||
98 | * i2c addr | chip | description | ||
99 | * 0x50 | HT24LC04 | eeprom (512B) | ||
100 | */ | ||
101 | |||
102 | static struct i2c_board_info __initdata netxbig_v2_i2c_info[] = { | ||
103 | { | ||
104 | I2C_BOARD_INFO("24c04", 0x50), | ||
105 | .platform_data = &at24c04, | ||
106 | } | ||
107 | }; | ||
108 | |||
109 | /***************************************************************************** | ||
110 | * SATA | 53 | * SATA |
111 | ****************************************************************************/ | 54 | ****************************************************************************/ |
112 | 55 | ||
@@ -114,34 +57,6 @@ static struct mv_sata_platform_data netxbig_v2_sata_data = { | |||
114 | .n_ports = 2, | 57 | .n_ports = 2, |
115 | }; | 58 | }; |
116 | 59 | ||
117 | static int __initdata netxbig_v2_gpio_hdd_power[] = { 16, 17, 41, 42, 43 }; | ||
118 | |||
119 | static void __init netxbig_v2_sata_power_init(void) | ||
120 | { | ||
121 | int i; | ||
122 | int err; | ||
123 | int hdd_nb; | ||
124 | |||
125 | if (machine_is_net2big_v2()) | ||
126 | hdd_nb = 2; | ||
127 | else | ||
128 | hdd_nb = 5; | ||
129 | |||
130 | /* Power up all hard disks. */ | ||
131 | for (i = 0; i < hdd_nb; i++) { | ||
132 | err = gpio_request(netxbig_v2_gpio_hdd_power[i], NULL); | ||
133 | if (err == 0) { | ||
134 | err = gpio_direction_output( | ||
135 | netxbig_v2_gpio_hdd_power[i], 1); | ||
136 | /* Free the HDD power GPIOs. This allow user-space to | ||
137 | * configure them via the gpiolib sysfs interface. */ | ||
138 | gpio_free(netxbig_v2_gpio_hdd_power[i]); | ||
139 | } | ||
140 | if (err) | ||
141 | pr_err("netxbig_v2: failed to power up HDD%d\n", i + 1); | ||
142 | } | ||
143 | } | ||
144 | |||
145 | /***************************************************************************** | 60 | /***************************************************************************** |
146 | * GPIO keys | 61 | * GPIO keys |
147 | ****************************************************************************/ | 62 | ****************************************************************************/ |
@@ -190,7 +105,7 @@ static struct platform_device netxbig_v2_gpio_buttons = { | |||
190 | }; | 105 | }; |
191 | 106 | ||
192 | /***************************************************************************** | 107 | /***************************************************************************** |
193 | * GPIO LEDs | 108 | * GPIO extension LEDs |
194 | ****************************************************************************/ | 109 | ****************************************************************************/ |
195 | 110 | ||
196 | /* | 111 | /* |
@@ -200,19 +115,32 @@ static struct platform_device netxbig_v2_gpio_buttons = { | |||
200 | * - address register : bit [0-2] -> GPIO [47-49] | 115 | * - address register : bit [0-2] -> GPIO [47-49] |
201 | * - data register : bit [0-2] -> GPIO [44-46] | 116 | * - data register : bit [0-2] -> GPIO [44-46] |
202 | * - enable register : GPIO 29 | 117 | * - enable register : GPIO 29 |
203 | * | 118 | */ |
119 | |||
120 | static int netxbig_v2_gpio_ext_addr[] = { 47, 48, 49 }; | ||
121 | static int netxbig_v2_gpio_ext_data[] = { 44, 45, 46 }; | ||
122 | |||
123 | static struct netxbig_gpio_ext netxbig_v2_gpio_ext = { | ||
124 | .addr = netxbig_v2_gpio_ext_addr, | ||
125 | .num_addr = ARRAY_SIZE(netxbig_v2_gpio_ext_addr), | ||
126 | .data = netxbig_v2_gpio_ext_data, | ||
127 | .num_data = ARRAY_SIZE(netxbig_v2_gpio_ext_data), | ||
128 | .enable = 29, | ||
129 | }; | ||
130 | |||
131 | /* | ||
204 | * Address register selection: | 132 | * Address register selection: |
205 | * | 133 | * |
206 | * addr | register | 134 | * addr | register |
207 | * ---------------------------- | 135 | * ---------------------------- |
208 | * 0 | front LED | 136 | * 0 | front LED |
209 | * 1 | front LED brightness | 137 | * 1 | front LED brightness |
210 | * 2 | HDD LED brightness | 138 | * 2 | SATA LED brightness |
211 | * 3 | HDD1 LED | 139 | * 3 | SATA0 LED |
212 | * 4 | HDD2 LED | 140 | * 4 | SATA1 LED |
213 | * 5 | HDD3 LED | 141 | * 5 | SATA2 LED |
214 | * 6 | HDD4 LED | 142 | * 6 | SATA3 LED |
215 | * 7 | HDD5 LED | 143 | * 7 | SATA4 LED |
216 | * | 144 | * |
217 | * Data register configuration: | 145 | * Data register configuration: |
218 | * | 146 | * |
@@ -233,30 +161,107 @@ static struct platform_device netxbig_v2_gpio_buttons = { | |||
233 | * 6 | blink blue on=1 sec and red on=1 sec | 161 | * 6 | blink blue on=1 sec and red on=1 sec |
234 | * 7 | blink blue on=0.5 sec and blue off=2.5 sec | 162 | * 7 | blink blue on=0.5 sec and blue off=2.5 sec |
235 | * | 163 | * |
236 | * data | HDD LED mode | 164 | * data | SATA LED mode |
237 | * ------------------------------------------------- | 165 | * ------------------------------------------------- |
238 | * 0 | fix blue on | 166 | * 0 | fix off |
239 | * 1 | SATA activity blink | 167 | * 1 | SATA activity blink |
240 | * 2 | fix red on | 168 | * 2 | fix red on |
241 | * 3 | blink blue on=1 sec and blue off=1 sec | 169 | * 3 | blink blue on=1 sec and blue off=1 sec |
242 | * 4 | blink red on=1 sec and red off=1 sec | 170 | * 4 | blink red on=1 sec and red off=1 sec |
243 | * 5 | blink blue on=2.5 sec and red on=0.5 sec | 171 | * 5 | blink blue on=2.5 sec and red on=0.5 sec |
244 | * 6 | blink blue on=1 sec and red on=1 sec | 172 | * 6 | blink blue on=1 sec and red on=1 sec |
245 | * 7 | blink blue on=0.5 sec and blue off=2.5 sec | 173 | * 7 | fix blue on |
246 | */ | 174 | */ |
247 | 175 | ||
248 | /***************************************************************************** | 176 | static int netxbig_v2_red_mled[NETXBIG_LED_MODE_NUM] = { |
249 | * Timer | 177 | [NETXBIG_LED_OFF] = 0, |
250 | ****************************************************************************/ | 178 | [NETXBIG_LED_ON] = 2, |
179 | [NETXBIG_LED_SATA] = NETXBIG_LED_INVALID_MODE, | ||
180 | [NETXBIG_LED_TIMER1] = 4, | ||
181 | [NETXBIG_LED_TIMER2] = NETXBIG_LED_INVALID_MODE, | ||
182 | }; | ||
251 | 183 | ||
252 | static void netxbig_v2_timer_init(void) | 184 | static int netxbig_v2_blue_pwr_mled[NETXBIG_LED_MODE_NUM] = { |
253 | { | 185 | [NETXBIG_LED_OFF] = 0, |
254 | kirkwood_tclk = 166666667; | 186 | [NETXBIG_LED_ON] = 1, |
255 | orion_time_init(IRQ_KIRKWOOD_BRIDGE, kirkwood_tclk); | 187 | [NETXBIG_LED_SATA] = NETXBIG_LED_INVALID_MODE, |
256 | } | 188 | [NETXBIG_LED_TIMER1] = 3, |
189 | [NETXBIG_LED_TIMER2] = 7, | ||
190 | }; | ||
191 | |||
192 | static int netxbig_v2_blue_sata_mled[NETXBIG_LED_MODE_NUM] = { | ||
193 | [NETXBIG_LED_OFF] = 0, | ||
194 | [NETXBIG_LED_ON] = 7, | ||
195 | [NETXBIG_LED_SATA] = 1, | ||
196 | [NETXBIG_LED_TIMER1] = 3, | ||
197 | [NETXBIG_LED_TIMER2] = NETXBIG_LED_INVALID_MODE, | ||
198 | }; | ||
199 | |||
200 | static struct netxbig_led_timer netxbig_v2_led_timer[] = { | ||
201 | [0] = { | ||
202 | .delay_on = 500, | ||
203 | .delay_off = 500, | ||
204 | .mode = NETXBIG_LED_TIMER1, | ||
205 | }, | ||
206 | [1] = { | ||
207 | .delay_on = 500, | ||
208 | .delay_off = 1000, | ||
209 | .mode = NETXBIG_LED_TIMER2, | ||
210 | }, | ||
211 | }; | ||
212 | |||
213 | #define NETXBIG_LED(_name, maddr, mval, baddr) \ | ||
214 | { .name = _name, \ | ||
215 | .mode_addr = maddr, \ | ||
216 | .mode_val = mval, \ | ||
217 | .bright_addr = baddr } | ||
218 | |||
219 | static struct netxbig_led net2big_v2_leds_ctrl[] = { | ||
220 | NETXBIG_LED("net2big-v2:blue:power", 0, netxbig_v2_blue_pwr_mled, 1), | ||
221 | NETXBIG_LED("net2big-v2:red:power", 0, netxbig_v2_red_mled, 1), | ||
222 | NETXBIG_LED("net2big-v2:blue:sata0", 3, netxbig_v2_blue_sata_mled, 2), | ||
223 | NETXBIG_LED("net2big-v2:red:sata0", 3, netxbig_v2_red_mled, 2), | ||
224 | NETXBIG_LED("net2big-v2:blue:sata1", 4, netxbig_v2_blue_sata_mled, 2), | ||
225 | NETXBIG_LED("net2big-v2:red:sata1", 4, netxbig_v2_red_mled, 2), | ||
226 | }; | ||
227 | |||
228 | static struct netxbig_led_platform_data net2big_v2_leds_data = { | ||
229 | .gpio_ext = &netxbig_v2_gpio_ext, | ||
230 | .timer = netxbig_v2_led_timer, | ||
231 | .num_timer = ARRAY_SIZE(netxbig_v2_led_timer), | ||
232 | .leds = net2big_v2_leds_ctrl, | ||
233 | .num_leds = ARRAY_SIZE(net2big_v2_leds_ctrl), | ||
234 | }; | ||
235 | |||
236 | static struct netxbig_led net5big_v2_leds_ctrl[] = { | ||
237 | NETXBIG_LED("net5big-v2:blue:power", 0, netxbig_v2_blue_pwr_mled, 1), | ||
238 | NETXBIG_LED("net5big-v2:red:power", 0, netxbig_v2_red_mled, 1), | ||
239 | NETXBIG_LED("net5big-v2:blue:sata0", 3, netxbig_v2_blue_sata_mled, 2), | ||
240 | NETXBIG_LED("net5big-v2:red:sata0", 3, netxbig_v2_red_mled, 2), | ||
241 | NETXBIG_LED("net5big-v2:blue:sata1", 4, netxbig_v2_blue_sata_mled, 2), | ||
242 | NETXBIG_LED("net5big-v2:red:sata1", 4, netxbig_v2_red_mled, 2), | ||
243 | NETXBIG_LED("net5big-v2:blue:sata2", 5, netxbig_v2_blue_sata_mled, 2), | ||
244 | NETXBIG_LED("net5big-v2:red:sata2", 5, netxbig_v2_red_mled, 2), | ||
245 | NETXBIG_LED("net5big-v2:blue:sata3", 6, netxbig_v2_blue_sata_mled, 2), | ||
246 | NETXBIG_LED("net5big-v2:red:sata3", 6, netxbig_v2_red_mled, 2), | ||
247 | NETXBIG_LED("net5big-v2:blue:sata4", 7, netxbig_v2_blue_sata_mled, 2), | ||
248 | NETXBIG_LED("net5big-v2:red:sata5", 7, netxbig_v2_red_mled, 2), | ||
249 | }; | ||
257 | 250 | ||
258 | struct sys_timer netxbig_v2_timer = { | 251 | static struct netxbig_led_platform_data net5big_v2_leds_data = { |
259 | .init = netxbig_v2_timer_init, | 252 | .gpio_ext = &netxbig_v2_gpio_ext, |
253 | .timer = netxbig_v2_led_timer, | ||
254 | .num_timer = ARRAY_SIZE(netxbig_v2_led_timer), | ||
255 | .leds = net5big_v2_leds_ctrl, | ||
256 | .num_leds = ARRAY_SIZE(net5big_v2_leds_ctrl), | ||
257 | }; | ||
258 | |||
259 | static struct platform_device netxbig_v2_leds = { | ||
260 | .name = "leds-netxbig", | ||
261 | .id = -1, | ||
262 | .dev = { | ||
263 | .platform_data = &net2big_v2_leds_data, | ||
264 | }, | ||
260 | }; | 265 | }; |
261 | 266 | ||
262 | /***************************************************************************** | 267 | /***************************************************************************** |
@@ -284,18 +289,18 @@ static unsigned int net2big_v2_mpp_config[] __initdata = { | |||
284 | MPP24_GPIO, /* USB mode select */ | 289 | MPP24_GPIO, /* USB mode select */ |
285 | MPP26_GPIO, /* USB device vbus */ | 290 | MPP26_GPIO, /* USB device vbus */ |
286 | MPP28_GPIO, /* USB enable host vbus */ | 291 | MPP28_GPIO, /* USB enable host vbus */ |
287 | MPP29_GPIO, /* CPLD extension ALE */ | 292 | MPP29_GPIO, /* GPIO extension ALE */ |
288 | MPP34_GPIO, /* Rear Push button */ | 293 | MPP34_GPIO, /* Rear Push button */ |
289 | MPP35_GPIO, /* Inhibit switch power-off */ | 294 | MPP35_GPIO, /* Inhibit switch power-off */ |
290 | MPP36_GPIO, /* SATA HDD1 presence */ | 295 | MPP36_GPIO, /* SATA HDD1 presence */ |
291 | MPP37_GPIO, /* SATA HDD2 presence */ | 296 | MPP37_GPIO, /* SATA HDD2 presence */ |
292 | MPP40_GPIO, /* eSATA presence */ | 297 | MPP40_GPIO, /* eSATA presence */ |
293 | MPP44_GPIO, /* CPLD extension (data 0) */ | 298 | MPP44_GPIO, /* GPIO extension (data 0) */ |
294 | MPP45_GPIO, /* CPLD extension (data 1) */ | 299 | MPP45_GPIO, /* GPIO extension (data 1) */ |
295 | MPP46_GPIO, /* CPLD extension (data 2) */ | 300 | MPP46_GPIO, /* GPIO extension (data 2) */ |
296 | MPP47_GPIO, /* CPLD extension (addr 0) */ | 301 | MPP47_GPIO, /* GPIO extension (addr 0) */ |
297 | MPP48_GPIO, /* CPLD extension (addr 1) */ | 302 | MPP48_GPIO, /* GPIO extension (addr 1) */ |
298 | MPP49_GPIO, /* CPLD extension (addr 2) */ | 303 | MPP49_GPIO, /* GPIO extension (addr 2) */ |
299 | 0 | 304 | 0 |
300 | }; | 305 | }; |
301 | 306 | ||
@@ -324,7 +329,7 @@ static unsigned int net5big_v2_mpp_config[] __initdata = { | |||
324 | MPP26_GE1_RXD2, | 329 | MPP26_GE1_RXD2, |
325 | MPP27_GE1_RXD3, | 330 | MPP27_GE1_RXD3, |
326 | MPP28_GPIO, /* USB enable host vbus */ | 331 | MPP28_GPIO, /* USB enable host vbus */ |
327 | MPP29_GPIO, /* CPLD extension ALE */ | 332 | MPP29_GPIO, /* GPIO extension ALE */ |
328 | MPP30_GE1_RXCTL, | 333 | MPP30_GE1_RXCTL, |
329 | MPP31_GE1_RXCLK, | 334 | MPP31_GE1_RXCLK, |
330 | MPP32_GE1_TCLKOUT, | 335 | MPP32_GE1_TCLKOUT, |
@@ -339,12 +344,12 @@ static unsigned int net5big_v2_mpp_config[] __initdata = { | |||
339 | MPP41_GPIO, /* SATA HDD3 power */ | 344 | MPP41_GPIO, /* SATA HDD3 power */ |
340 | MPP42_GPIO, /* SATA HDD4 power */ | 345 | MPP42_GPIO, /* SATA HDD4 power */ |
341 | MPP43_GPIO, /* SATA HDD5 power */ | 346 | MPP43_GPIO, /* SATA HDD5 power */ |
342 | MPP44_GPIO, /* CPLD extension (data 0) */ | 347 | MPP44_GPIO, /* GPIO extension (data 0) */ |
343 | MPP45_GPIO, /* CPLD extension (data 1) */ | 348 | MPP45_GPIO, /* GPIO extension (data 1) */ |
344 | MPP46_GPIO, /* CPLD extension (data 2) */ | 349 | MPP46_GPIO, /* GPIO extension (data 2) */ |
345 | MPP47_GPIO, /* CPLD extension (addr 0) */ | 350 | MPP47_GPIO, /* GPIO extension (addr 0) */ |
346 | MPP48_GPIO, /* CPLD extension (addr 1) */ | 351 | MPP48_GPIO, /* GPIO extension (addr 1) */ |
347 | MPP49_GPIO, /* CPLD extension (addr 2) */ | 352 | MPP49_GPIO, /* GPIO extension (addr 2) */ |
348 | 0 | 353 | 0 |
349 | }; | 354 | }; |
350 | 355 | ||
@@ -366,7 +371,10 @@ static void __init netxbig_v2_init(void) | |||
366 | else | 371 | else |
367 | kirkwood_mpp_conf(net5big_v2_mpp_config); | 372 | kirkwood_mpp_conf(net5big_v2_mpp_config); |
368 | 373 | ||
369 | netxbig_v2_sata_power_init(); | 374 | if (machine_is_net2big_v2()) |
375 | lacie_v2_hdd_power_init(2); | ||
376 | else | ||
377 | lacie_v2_hdd_power_init(5); | ||
370 | 378 | ||
371 | kirkwood_ehci_init(); | 379 | kirkwood_ehci_init(); |
372 | kirkwood_ge00_init(&netxbig_v2_ge00_data); | 380 | kirkwood_ge00_init(&netxbig_v2_ge00_data); |
@@ -374,13 +382,12 @@ static void __init netxbig_v2_init(void) | |||
374 | kirkwood_ge01_init(&netxbig_v2_ge01_data); | 382 | kirkwood_ge01_init(&netxbig_v2_ge01_data); |
375 | kirkwood_sata_init(&netxbig_v2_sata_data); | 383 | kirkwood_sata_init(&netxbig_v2_sata_data); |
376 | kirkwood_uart0_init(); | 384 | kirkwood_uart0_init(); |
377 | spi_register_board_info(netxbig_v2_spi_slave_info, | 385 | lacie_v2_register_flash(); |
378 | ARRAY_SIZE(netxbig_v2_spi_slave_info)); | 386 | lacie_v2_register_i2c_devices(); |
379 | kirkwood_spi_init(); | ||
380 | kirkwood_i2c_init(); | ||
381 | i2c_register_board_info(0, netxbig_v2_i2c_info, | ||
382 | ARRAY_SIZE(netxbig_v2_i2c_info)); | ||
383 | 387 | ||
388 | if (machine_is_net5big_v2()) | ||
389 | netxbig_v2_leds.dev.platform_data = &net5big_v2_leds_data; | ||
390 | platform_device_register(&netxbig_v2_leds); | ||
384 | platform_device_register(&netxbig_v2_gpio_buttons); | 391 | platform_device_register(&netxbig_v2_gpio_buttons); |
385 | 392 | ||
386 | if (gpio_request(NETXBIG_V2_GPIO_POWER_OFF, "power-off") == 0 && | 393 | if (gpio_request(NETXBIG_V2_GPIO_POWER_OFF, "power-off") == 0 && |
@@ -398,7 +405,7 @@ MACHINE_START(NET2BIG_V2, "LaCie 2Big Network v2") | |||
398 | .init_machine = netxbig_v2_init, | 405 | .init_machine = netxbig_v2_init, |
399 | .map_io = kirkwood_map_io, | 406 | .map_io = kirkwood_map_io, |
400 | .init_irq = kirkwood_init_irq, | 407 | .init_irq = kirkwood_init_irq, |
401 | .timer = &netxbig_v2_timer, | 408 | .timer = &lacie_v2_timer, |
402 | MACHINE_END | 409 | MACHINE_END |
403 | #endif | 410 | #endif |
404 | 411 | ||
@@ -410,6 +417,6 @@ MACHINE_START(NET5BIG_V2, "LaCie 5Big Network v2") | |||
410 | .init_machine = netxbig_v2_init, | 417 | .init_machine = netxbig_v2_init, |
411 | .map_io = kirkwood_map_io, | 418 | .map_io = kirkwood_map_io, |
412 | .init_irq = kirkwood_init_irq, | 419 | .init_irq = kirkwood_init_irq, |
413 | .timer = &netxbig_v2_timer, | 420 | .timer = &lacie_v2_timer, |
414 | MACHINE_END | 421 | MACHINE_END |
415 | #endif | 422 | #endif |
diff --git a/arch/arm/mach-kirkwood/openrd-setup.c b/arch/arm/mach-kirkwood/openrd-setup.c index fd06be618815..38017c8ac43f 100644 --- a/arch/arm/mach-kirkwood/openrd-setup.c +++ b/arch/arm/mach-kirkwood/openrd-setup.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/ata_platform.h> | 16 | #include <linux/ata_platform.h> |
17 | #include <linux/mv643xx_eth.h> | 17 | #include <linux/mv643xx_eth.h> |
18 | #include <linux/i2c.h> | 18 | #include <linux/i2c.h> |
19 | #include <linux/gpio.h> | ||
19 | #include <asm/mach-types.h> | 20 | #include <asm/mach-types.h> |
20 | #include <asm/mach/arch.h> | 21 | #include <asm/mach/arch.h> |
21 | #include <mach/kirkwood.h> | 22 | #include <mach/kirkwood.h> |
@@ -57,7 +58,22 @@ static struct mvsdio_platform_data openrd_mvsdio_data = { | |||
57 | }; | 58 | }; |
58 | 59 | ||
59 | static unsigned int openrd_mpp_config[] __initdata = { | 60 | static unsigned int openrd_mpp_config[] __initdata = { |
61 | MPP12_SD_CLK, | ||
62 | MPP13_SD_CMD, | ||
63 | MPP14_SD_D0, | ||
64 | MPP15_SD_D1, | ||
65 | MPP16_SD_D2, | ||
66 | MPP17_SD_D3, | ||
67 | MPP28_GPIO, | ||
60 | MPP29_GPIO, | 68 | MPP29_GPIO, |
69 | MPP34_GPIO, | ||
70 | 0 | ||
71 | }; | ||
72 | |||
73 | /* Configure MPP for UART1 */ | ||
74 | static unsigned int openrd_uart1_mpp_config[] __initdata = { | ||
75 | MPP13_UART1_TXD, | ||
76 | MPP14_UART1_RXD, | ||
61 | 0 | 77 | 0 |
62 | }; | 78 | }; |
63 | 79 | ||
@@ -67,6 +83,68 @@ static struct i2c_board_info i2c_board_info[] __initdata = { | |||
67 | }, | 83 | }, |
68 | }; | 84 | }; |
69 | 85 | ||
86 | static int __initdata uart1; | ||
87 | |||
88 | static int __init sd_uart_selection(char *str) | ||
89 | { | ||
90 | uart1 = -EINVAL; | ||
91 | |||
92 | /* Default is SD. Change if required, for UART */ | ||
93 | if (!str) | ||
94 | return 0; | ||
95 | |||
96 | if (!strncmp(str, "232", 3)) { | ||
97 | uart1 = 232; | ||
98 | } else if (!strncmp(str, "485", 3)) { | ||
99 | /* OpenRD-Base doesn't have RS485. Treat is as an | ||
100 | * unknown argument & just have default setting - | ||
101 | * which is SD */ | ||
102 | if (machine_is_openrd_base()) { | ||
103 | uart1 = -ENODEV; | ||
104 | return 1; | ||
105 | } | ||
106 | |||
107 | uart1 = 485; | ||
108 | } | ||
109 | return 1; | ||
110 | } | ||
111 | /* Parse boot_command_line string kw_openrd_init_uart1=232/485 */ | ||
112 | __setup("kw_openrd_init_uart1=", sd_uart_selection); | ||
113 | |||
114 | static int __init uart1_mpp_config(void) | ||
115 | { | ||
116 | kirkwood_mpp_conf(openrd_uart1_mpp_config); | ||
117 | |||
118 | if (gpio_request(34, "SD_UART1_SEL")) { | ||
119 | printk(KERN_ERR "GPIO request failed for SD/UART1 selection" | ||
120 | ", gpio: 34\n"); | ||
121 | return -EIO; | ||
122 | } | ||
123 | |||
124 | if (gpio_request(28, "RS232_RS485_SEL")) { | ||
125 | printk(KERN_ERR "GPIO request failed for RS232/RS485 selection" | ||
126 | ", gpio# 28\n"); | ||
127 | gpio_free(34); | ||
128 | return -EIO; | ||
129 | } | ||
130 | |||
131 | /* Select UART1 | ||
132 | * Pin # 34: 0 => UART1, 1 => SD */ | ||
133 | gpio_direction_output(34, 0); | ||
134 | |||
135 | /* Select RS232 OR RS485 | ||
136 | * Pin # 28: 0 => RS232, 1 => RS485 */ | ||
137 | if (uart1 == 232) | ||
138 | gpio_direction_output(28, 0); | ||
139 | else | ||
140 | gpio_direction_output(28, 1); | ||
141 | |||
142 | gpio_free(34); | ||
143 | gpio_free(28); | ||
144 | |||
145 | return 0; | ||
146 | } | ||
147 | |||
70 | static void __init openrd_init(void) | 148 | static void __init openrd_init(void) |
71 | { | 149 | { |
72 | /* | 150 | /* |
@@ -90,7 +168,6 @@ static void __init openrd_init(void) | |||
90 | kirkwood_ge01_init(&openrd_ge01_data); | 168 | kirkwood_ge01_init(&openrd_ge01_data); |
91 | 169 | ||
92 | kirkwood_sata_init(&openrd_sata_data); | 170 | kirkwood_sata_init(&openrd_sata_data); |
93 | kirkwood_sdio_init(&openrd_mvsdio_data); | ||
94 | 171 | ||
95 | kirkwood_i2c_init(); | 172 | kirkwood_i2c_init(); |
96 | 173 | ||
@@ -99,6 +176,28 @@ static void __init openrd_init(void) | |||
99 | ARRAY_SIZE(i2c_board_info)); | 176 | ARRAY_SIZE(i2c_board_info)); |
100 | kirkwood_audio_init(); | 177 | kirkwood_audio_init(); |
101 | } | 178 | } |
179 | |||
180 | if (uart1 <= 0) { | ||
181 | if (uart1 < 0) | ||
182 | printk(KERN_ERR "Invalid kernel parameter to select " | ||
183 | "UART1. Defaulting to SD. ERROR CODE: %d\n", | ||
184 | uart1); | ||
185 | |||
186 | /* Select SD | ||
187 | * Pin # 34: 0 => UART1, 1 => SD */ | ||
188 | if (gpio_request(34, "SD_UART1_SEL")) { | ||
189 | printk(KERN_ERR "GPIO request failed for SD/UART1 " | ||
190 | "selection, gpio: 34\n"); | ||
191 | } else { | ||
192 | |||
193 | gpio_direction_output(34, 1); | ||
194 | gpio_free(34); | ||
195 | kirkwood_sdio_init(&openrd_mvsdio_data); | ||
196 | } | ||
197 | } else { | ||
198 | if (!uart1_mpp_config()) | ||
199 | kirkwood_uart1_init(); | ||
200 | } | ||
102 | } | 201 | } |
103 | 202 | ||
104 | static int __init openrd_pci_init(void) | 203 | static int __init openrd_pci_init(void) |
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index e4112622e5a2..cc2a88d5192f 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig | |||
@@ -304,13 +304,22 @@ config LEDS_MC13783 | |||
304 | 304 | ||
305 | config LEDS_NS2 | 305 | config LEDS_NS2 |
306 | tristate "LED support for Network Space v2 GPIO LEDs" | 306 | tristate "LED support for Network Space v2 GPIO LEDs" |
307 | depends on MACH_NETSPACE_V2 || MACH_INETSPACE_V2 || MACH_NETSPACE_MAX_V2 | 307 | depends on MACH_NETSPACE_V2 || MACH_INETSPACE_V2 || MACH_NETSPACE_MAX_V2 || D2NET_V2 |
308 | default y | 308 | default y |
309 | help | 309 | help |
310 | This option enable support for the dual-GPIO LED found on the | 310 | This option enable support for the dual-GPIO LED found on the |
311 | Network Space v2 board (and parents). This include Internet Space v2, | 311 | Network Space v2 board (and parents). This include Internet Space v2, |
312 | Network Space (Max) v2 and d2 Network v2 boards. | 312 | Network Space (Max) v2 and d2 Network v2 boards. |
313 | 313 | ||
314 | config LEDS_NETXBIG | ||
315 | tristate "LED support for Big Network series LEDs" | ||
316 | depends on MACH_NET2BIG_V2 || MACH_NET5BIG_V2 | ||
317 | default y | ||
318 | help | ||
319 | This option enable support for LEDs found on the LaCie 2Big | ||
320 | and 5Big Network v2 boards. The LEDs are wired to a CPLD and are | ||
321 | controlled through a GPIO extension bus. | ||
322 | |||
314 | config LEDS_TRIGGERS | 323 | config LEDS_TRIGGERS |
315 | bool "LED Trigger support" | 324 | bool "LED Trigger support" |
316 | help | 325 | help |
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index 7d6b95831f8e..9c96db40ef6d 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile | |||
@@ -38,6 +38,7 @@ obj-$(CONFIG_LEDS_ADP5520) += leds-adp5520.o | |||
38 | obj-$(CONFIG_LEDS_DELL_NETBOOKS) += dell-led.o | 38 | obj-$(CONFIG_LEDS_DELL_NETBOOKS) += dell-led.o |
39 | obj-$(CONFIG_LEDS_MC13783) += leds-mc13783.o | 39 | obj-$(CONFIG_LEDS_MC13783) += leds-mc13783.o |
40 | obj-$(CONFIG_LEDS_NS2) += leds-ns2.o | 40 | obj-$(CONFIG_LEDS_NS2) += leds-ns2.o |
41 | obj-$(CONFIG_LEDS_NETXBIG) += leds-netxbig.o | ||
41 | 42 | ||
42 | # LED SPI Drivers | 43 | # LED SPI Drivers |
43 | obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o | 44 | obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o |
diff --git a/drivers/leds/leds-netxbig.c b/drivers/leds/leds-netxbig.c new file mode 100644 index 000000000000..f2e51c134399 --- /dev/null +++ b/drivers/leds/leds-netxbig.c | |||
@@ -0,0 +1,449 @@ | |||
1 | /* | ||
2 | * leds-netxbig.c - Driver for the 2Big and 5Big Network series LEDs | ||
3 | * | ||
4 | * Copyright (C) 2010 LaCie | ||
5 | * | ||
6 | * Author: Simon Guinot <sguinot@lacie.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
21 | */ | ||
22 | |||
23 | #include <linux/module.h> | ||
24 | #include <linux/init.h> | ||
25 | #include <linux/irq.h> | ||
26 | #include <linux/slab.h> | ||
27 | #include <linux/spinlock.h> | ||
28 | #include <linux/platform_device.h> | ||
29 | #include <linux/gpio.h> | ||
30 | #include <linux/leds.h> | ||
31 | #include <mach/leds-netxbig.h> | ||
32 | |||
33 | /* | ||
34 | * GPIO extension bus. | ||
35 | */ | ||
36 | |||
37 | static DEFINE_SPINLOCK(gpio_ext_lock); | ||
38 | |||
39 | static void gpio_ext_set_addr(struct netxbig_gpio_ext *gpio_ext, int addr) | ||
40 | { | ||
41 | int pin; | ||
42 | |||
43 | for (pin = 0; pin < gpio_ext->num_addr; pin++) | ||
44 | gpio_set_value(gpio_ext->addr[pin], (addr >> pin) & 1); | ||
45 | } | ||
46 | |||
47 | static void gpio_ext_set_data(struct netxbig_gpio_ext *gpio_ext, int data) | ||
48 | { | ||
49 | int pin; | ||
50 | |||
51 | for (pin = 0; pin < gpio_ext->num_data; pin++) | ||
52 | gpio_set_value(gpio_ext->data[pin], (data >> pin) & 1); | ||
53 | } | ||
54 | |||
55 | static void gpio_ext_enable_select(struct netxbig_gpio_ext *gpio_ext) | ||
56 | { | ||
57 | /* Enable select is done on the raising edge. */ | ||
58 | gpio_set_value(gpio_ext->enable, 0); | ||
59 | gpio_set_value(gpio_ext->enable, 1); | ||
60 | } | ||
61 | |||
62 | static void gpio_ext_set_value(struct netxbig_gpio_ext *gpio_ext, | ||
63 | int addr, int value) | ||
64 | { | ||
65 | unsigned long flags; | ||
66 | |||
67 | spin_lock_irqsave(&gpio_ext_lock, flags); | ||
68 | gpio_ext_set_addr(gpio_ext, addr); | ||
69 | gpio_ext_set_data(gpio_ext, value); | ||
70 | gpio_ext_enable_select(gpio_ext); | ||
71 | spin_unlock_irqrestore(&gpio_ext_lock, flags); | ||
72 | } | ||
73 | |||
74 | static int __devinit gpio_ext_init(struct netxbig_gpio_ext *gpio_ext) | ||
75 | { | ||
76 | int err; | ||
77 | int i; | ||
78 | |||
79 | if (unlikely(!gpio_ext)) | ||
80 | return -EINVAL; | ||
81 | |||
82 | /* Configure address GPIOs. */ | ||
83 | for (i = 0; i < gpio_ext->num_addr; i++) { | ||
84 | err = gpio_request(gpio_ext->addr[i], "GPIO extension addr"); | ||
85 | if (err) | ||
86 | goto err_free_addr; | ||
87 | err = gpio_direction_output(gpio_ext->addr[i], 0); | ||
88 | if (err) { | ||
89 | gpio_free(gpio_ext->addr[i]); | ||
90 | goto err_free_addr; | ||
91 | } | ||
92 | } | ||
93 | /* Configure data GPIOs. */ | ||
94 | for (i = 0; i < gpio_ext->num_data; i++) { | ||
95 | err = gpio_request(gpio_ext->data[i], "GPIO extension data"); | ||
96 | if (err) | ||
97 | goto err_free_data; | ||
98 | err = gpio_direction_output(gpio_ext->data[i], 0); | ||
99 | if (err) { | ||
100 | gpio_free(gpio_ext->data[i]); | ||
101 | goto err_free_data; | ||
102 | } | ||
103 | } | ||
104 | /* Configure "enable select" GPIO. */ | ||
105 | err = gpio_request(gpio_ext->enable, "GPIO extension enable"); | ||
106 | if (err) | ||
107 | goto err_free_data; | ||
108 | err = gpio_direction_output(gpio_ext->enable, 0); | ||
109 | if (err) { | ||
110 | gpio_free(gpio_ext->enable); | ||
111 | goto err_free_data; | ||
112 | } | ||
113 | |||
114 | return 0; | ||
115 | |||
116 | err_free_data: | ||
117 | for (i = i - 1; i >= 0; i--) | ||
118 | gpio_free(gpio_ext->data[i]); | ||
119 | i = gpio_ext->num_addr; | ||
120 | err_free_addr: | ||
121 | for (i = i - 1; i >= 0; i--) | ||
122 | gpio_free(gpio_ext->addr[i]); | ||
123 | |||
124 | return err; | ||
125 | } | ||
126 | |||
127 | static void __devexit gpio_ext_free(struct netxbig_gpio_ext *gpio_ext) | ||
128 | { | ||
129 | int i; | ||
130 | |||
131 | gpio_free(gpio_ext->enable); | ||
132 | for (i = gpio_ext->num_addr - 1; i >= 0; i--) | ||
133 | gpio_free(gpio_ext->addr[i]); | ||
134 | for (i = gpio_ext->num_data - 1; i >= 0; i--) | ||
135 | gpio_free(gpio_ext->data[i]); | ||
136 | } | ||
137 | |||
138 | /* | ||
139 | * Class LED driver. | ||
140 | */ | ||
141 | |||
142 | struct netxbig_led_data { | ||
143 | struct netxbig_gpio_ext *gpio_ext; | ||
144 | struct led_classdev cdev; | ||
145 | int mode_addr; | ||
146 | int *mode_val; | ||
147 | int bright_addr; | ||
148 | int bright_max; | ||
149 | struct netxbig_led_timer *timer; | ||
150 | int num_timer; | ||
151 | enum netxbig_led_mode mode; | ||
152 | int sata; | ||
153 | spinlock_t lock; | ||
154 | }; | ||
155 | |||
156 | static int netxbig_led_get_timer_mode(enum netxbig_led_mode *mode, | ||
157 | unsigned long delay_on, | ||
158 | unsigned long delay_off, | ||
159 | struct netxbig_led_timer *timer, | ||
160 | int num_timer) | ||
161 | { | ||
162 | int i; | ||
163 | |||
164 | for (i = 0; i < num_timer; i++) { | ||
165 | if (timer[i].delay_on == delay_on && | ||
166 | timer[i].delay_off == delay_off) { | ||
167 | *mode = timer[i].mode; | ||
168 | return 0; | ||
169 | } | ||
170 | } | ||
171 | return -EINVAL; | ||
172 | } | ||
173 | |||
174 | static int netxbig_led_blink_set(struct led_classdev *led_cdev, | ||
175 | unsigned long *delay_on, | ||
176 | unsigned long *delay_off) | ||
177 | { | ||
178 | struct netxbig_led_data *led_dat = | ||
179 | container_of(led_cdev, struct netxbig_led_data, cdev); | ||
180 | enum netxbig_led_mode mode; | ||
181 | int mode_val; | ||
182 | int ret; | ||
183 | |||
184 | /* Look for a LED mode with the requested timer frequency. */ | ||
185 | ret = netxbig_led_get_timer_mode(&mode, *delay_on, *delay_off, | ||
186 | led_dat->timer, led_dat->num_timer); | ||
187 | if (ret < 0) | ||
188 | return ret; | ||
189 | |||
190 | mode_val = led_dat->mode_val[mode]; | ||
191 | if (mode_val == NETXBIG_LED_INVALID_MODE) | ||
192 | return -EINVAL; | ||
193 | |||
194 | spin_lock_irq(&led_dat->lock); | ||
195 | |||
196 | gpio_ext_set_value(led_dat->gpio_ext, led_dat->mode_addr, mode_val); | ||
197 | led_dat->mode = mode; | ||
198 | |||
199 | spin_unlock_irq(&led_dat->lock); | ||
200 | |||
201 | return 0; | ||
202 | } | ||
203 | |||
204 | static void netxbig_led_set(struct led_classdev *led_cdev, | ||
205 | enum led_brightness value) | ||
206 | { | ||
207 | struct netxbig_led_data *led_dat = | ||
208 | container_of(led_cdev, struct netxbig_led_data, cdev); | ||
209 | enum netxbig_led_mode mode; | ||
210 | int mode_val, bright_val; | ||
211 | int set_brightness = 1; | ||
212 | unsigned long flags; | ||
213 | |||
214 | spin_lock_irqsave(&led_dat->lock, flags); | ||
215 | |||
216 | if (value == LED_OFF) { | ||
217 | mode = NETXBIG_LED_OFF; | ||
218 | set_brightness = 0; | ||
219 | } else { | ||
220 | if (led_dat->sata) | ||
221 | mode = NETXBIG_LED_SATA; | ||
222 | else if (led_dat->mode == NETXBIG_LED_OFF) | ||
223 | mode = NETXBIG_LED_ON; | ||
224 | else /* Keep 'timer' mode. */ | ||
225 | mode = led_dat->mode; | ||
226 | } | ||
227 | mode_val = led_dat->mode_val[mode]; | ||
228 | |||
229 | gpio_ext_set_value(led_dat->gpio_ext, led_dat->mode_addr, mode_val); | ||
230 | led_dat->mode = mode; | ||
231 | /* | ||
232 | * Note that the brightness register is shared between all the | ||
233 | * SATA LEDs. So, change the brightness setting for a single | ||
234 | * SATA LED will affect all the others. | ||
235 | */ | ||
236 | if (set_brightness) { | ||
237 | bright_val = DIV_ROUND_UP(value * led_dat->bright_max, | ||
238 | LED_FULL); | ||
239 | gpio_ext_set_value(led_dat->gpio_ext, | ||
240 | led_dat->bright_addr, bright_val); | ||
241 | } | ||
242 | |||
243 | spin_unlock_irqrestore(&led_dat->lock, flags); | ||
244 | } | ||
245 | |||
246 | static ssize_t netxbig_led_sata_store(struct device *dev, | ||
247 | struct device_attribute *attr, | ||
248 | const char *buff, size_t count) | ||
249 | { | ||
250 | struct led_classdev *led_cdev = dev_get_drvdata(dev); | ||
251 | struct netxbig_led_data *led_dat = | ||
252 | container_of(led_cdev, struct netxbig_led_data, cdev); | ||
253 | unsigned long enable; | ||
254 | enum netxbig_led_mode mode; | ||
255 | int mode_val; | ||
256 | int ret; | ||
257 | |||
258 | ret = strict_strtoul(buff, 10, &enable); | ||
259 | if (ret < 0) | ||
260 | return ret; | ||
261 | |||
262 | enable = !!enable; | ||
263 | |||
264 | spin_lock_irq(&led_dat->lock); | ||
265 | |||
266 | if (led_dat->sata == enable) { | ||
267 | ret = count; | ||
268 | goto exit_unlock; | ||
269 | } | ||
270 | |||
271 | if (led_dat->mode != NETXBIG_LED_ON && | ||
272 | led_dat->mode != NETXBIG_LED_SATA) | ||
273 | mode = led_dat->mode; /* Keep modes 'off' and 'timer'. */ | ||
274 | else if (enable) | ||
275 | mode = NETXBIG_LED_SATA; | ||
276 | else | ||
277 | mode = NETXBIG_LED_ON; | ||
278 | |||
279 | mode_val = led_dat->mode_val[mode]; | ||
280 | if (mode_val == NETXBIG_LED_INVALID_MODE) { | ||
281 | ret = -EINVAL; | ||
282 | goto exit_unlock; | ||
283 | } | ||
284 | |||
285 | gpio_ext_set_value(led_dat->gpio_ext, led_dat->mode_addr, mode_val); | ||
286 | led_dat->mode = mode; | ||
287 | led_dat->sata = enable; | ||
288 | |||
289 | ret = count; | ||
290 | |||
291 | exit_unlock: | ||
292 | spin_unlock_irq(&led_dat->lock); | ||
293 | |||
294 | return ret; | ||
295 | } | ||
296 | |||
297 | static ssize_t netxbig_led_sata_show(struct device *dev, | ||
298 | struct device_attribute *attr, char *buf) | ||
299 | { | ||
300 | struct led_classdev *led_cdev = dev_get_drvdata(dev); | ||
301 | struct netxbig_led_data *led_dat = | ||
302 | container_of(led_cdev, struct netxbig_led_data, cdev); | ||
303 | |||
304 | return sprintf(buf, "%d\n", led_dat->sata); | ||
305 | } | ||
306 | |||
307 | static DEVICE_ATTR(sata, 0644, netxbig_led_sata_show, netxbig_led_sata_store); | ||
308 | |||
309 | static void __devexit delete_netxbig_led(struct netxbig_led_data *led_dat) | ||
310 | { | ||
311 | if (led_dat->mode_val[NETXBIG_LED_SATA] != NETXBIG_LED_INVALID_MODE) | ||
312 | device_remove_file(led_dat->cdev.dev, &dev_attr_sata); | ||
313 | led_classdev_unregister(&led_dat->cdev); | ||
314 | } | ||
315 | |||
316 | static int __devinit | ||
317 | create_netxbig_led(struct platform_device *pdev, | ||
318 | struct netxbig_led_data *led_dat, | ||
319 | const struct netxbig_led *template) | ||
320 | { | ||
321 | struct netxbig_led_platform_data *pdata = pdev->dev.platform_data; | ||
322 | int ret; | ||
323 | |||
324 | spin_lock_init(&led_dat->lock); | ||
325 | led_dat->gpio_ext = pdata->gpio_ext; | ||
326 | led_dat->cdev.name = template->name; | ||
327 | led_dat->cdev.default_trigger = template->default_trigger; | ||
328 | led_dat->cdev.blink_set = netxbig_led_blink_set; | ||
329 | led_dat->cdev.brightness_set = netxbig_led_set; | ||
330 | /* | ||
331 | * Because the GPIO extension bus don't allow to read registers | ||
332 | * value, there is no way to probe the LED initial state. | ||
333 | * So, the initial sysfs LED value for the "brightness" and "sata" | ||
334 | * attributes are inconsistent. | ||
335 | * | ||
336 | * Note that the initial LED state can't be reconfigured. | ||
337 | * The reason is that the LED behaviour must stay uniform during | ||
338 | * the whole boot process (bootloader+linux). | ||
339 | */ | ||
340 | led_dat->sata = 0; | ||
341 | led_dat->cdev.brightness = LED_OFF; | ||
342 | led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME; | ||
343 | led_dat->mode_addr = template->mode_addr; | ||
344 | led_dat->mode_val = template->mode_val; | ||
345 | led_dat->bright_addr = template->bright_addr; | ||
346 | led_dat->bright_max = (1 << pdata->gpio_ext->num_data) - 1; | ||
347 | led_dat->timer = pdata->timer; | ||
348 | led_dat->num_timer = pdata->num_timer; | ||
349 | |||
350 | ret = led_classdev_register(&pdev->dev, &led_dat->cdev); | ||
351 | if (ret < 0) | ||
352 | return ret; | ||
353 | |||
354 | /* | ||
355 | * If available, expose the SATA activity blink capability through | ||
356 | * a "sata" sysfs attribute. | ||
357 | */ | ||
358 | if (led_dat->mode_val[NETXBIG_LED_SATA] != NETXBIG_LED_INVALID_MODE) { | ||
359 | ret = device_create_file(led_dat->cdev.dev, &dev_attr_sata); | ||
360 | if (ret) | ||
361 | led_classdev_unregister(&led_dat->cdev); | ||
362 | } | ||
363 | |||
364 | return ret; | ||
365 | } | ||
366 | |||
367 | static int __devinit netxbig_led_probe(struct platform_device *pdev) | ||
368 | { | ||
369 | struct netxbig_led_platform_data *pdata = pdev->dev.platform_data; | ||
370 | struct netxbig_led_data *leds_data; | ||
371 | int i; | ||
372 | int ret; | ||
373 | |||
374 | if (!pdata) | ||
375 | return -EINVAL; | ||
376 | |||
377 | leds_data = kzalloc(sizeof(struct netxbig_led_data) * pdata->num_leds, | ||
378 | GFP_KERNEL); | ||
379 | if (!leds_data) | ||
380 | return -ENOMEM; | ||
381 | |||
382 | ret = gpio_ext_init(pdata->gpio_ext); | ||
383 | if (ret < 0) | ||
384 | goto err_free_data; | ||
385 | |||
386 | for (i = 0; i < pdata->num_leds; i++) { | ||
387 | ret = create_netxbig_led(pdev, &leds_data[i], &pdata->leds[i]); | ||
388 | if (ret < 0) | ||
389 | goto err_free_leds; | ||
390 | } | ||
391 | |||
392 | platform_set_drvdata(pdev, leds_data); | ||
393 | |||
394 | return 0; | ||
395 | |||
396 | err_free_leds: | ||
397 | for (i = i - 1; i >= 0; i--) | ||
398 | delete_netxbig_led(&leds_data[i]); | ||
399 | |||
400 | gpio_ext_free(pdata->gpio_ext); | ||
401 | err_free_data: | ||
402 | kfree(leds_data); | ||
403 | |||
404 | return ret; | ||
405 | } | ||
406 | |||
407 | static int __devexit netxbig_led_remove(struct platform_device *pdev) | ||
408 | { | ||
409 | struct netxbig_led_platform_data *pdata = pdev->dev.platform_data; | ||
410 | struct netxbig_led_data *leds_data; | ||
411 | int i; | ||
412 | |||
413 | leds_data = platform_get_drvdata(pdev); | ||
414 | |||
415 | for (i = 0; i < pdata->num_leds; i++) | ||
416 | delete_netxbig_led(&leds_data[i]); | ||
417 | |||
418 | gpio_ext_free(pdata->gpio_ext); | ||
419 | kfree(leds_data); | ||
420 | |||
421 | return 0; | ||
422 | } | ||
423 | |||
424 | static struct platform_driver netxbig_led_driver = { | ||
425 | .probe = netxbig_led_probe, | ||
426 | .remove = __devexit_p(netxbig_led_remove), | ||
427 | .driver = { | ||
428 | .name = "leds-netxbig", | ||
429 | .owner = THIS_MODULE, | ||
430 | }, | ||
431 | }; | ||
432 | MODULE_ALIAS("platform:leds-netxbig"); | ||
433 | |||
434 | static int __init netxbig_led_init(void) | ||
435 | { | ||
436 | return platform_driver_register(&netxbig_led_driver); | ||
437 | } | ||
438 | |||
439 | static void __exit netxbig_led_exit(void) | ||
440 | { | ||
441 | platform_driver_unregister(&netxbig_led_driver); | ||
442 | } | ||
443 | |||
444 | module_init(netxbig_led_init); | ||
445 | module_exit(netxbig_led_exit); | ||
446 | |||
447 | MODULE_AUTHOR("Simon Guinot <sguinot@lacie.com>"); | ||
448 | MODULE_DESCRIPTION("LED driver for LaCie xBig Network boards"); | ||
449 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/leds/leds-ns2.c b/drivers/leds/leds-ns2.c index 350eb34f049c..f77d48d0b3e4 100644 --- a/drivers/leds/leds-ns2.c +++ b/drivers/leds/leds-ns2.c | |||
@@ -141,10 +141,12 @@ static ssize_t ns2_led_sata_store(struct device *dev, | |||
141 | struct device_attribute *attr, | 141 | struct device_attribute *attr, |
142 | const char *buff, size_t count) | 142 | const char *buff, size_t count) |
143 | { | 143 | { |
144 | struct led_classdev *led_cdev = dev_get_drvdata(dev); | ||
145 | struct ns2_led_data *led_dat = | ||
146 | container_of(led_cdev, struct ns2_led_data, cdev); | ||
144 | int ret; | 147 | int ret; |
145 | unsigned long enable; | 148 | unsigned long enable; |
146 | enum ns2_led_modes mode; | 149 | enum ns2_led_modes mode; |
147 | struct ns2_led_data *led_dat = dev_get_drvdata(dev); | ||
148 | 150 | ||
149 | ret = strict_strtoul(buff, 10, &enable); | 151 | ret = strict_strtoul(buff, 10, &enable); |
150 | if (ret < 0) | 152 | if (ret < 0) |
@@ -172,7 +174,9 @@ static ssize_t ns2_led_sata_store(struct device *dev, | |||
172 | static ssize_t ns2_led_sata_show(struct device *dev, | 174 | static ssize_t ns2_led_sata_show(struct device *dev, |
173 | struct device_attribute *attr, char *buf) | 175 | struct device_attribute *attr, char *buf) |
174 | { | 176 | { |
175 | struct ns2_led_data *led_dat = dev_get_drvdata(dev); | 177 | struct led_classdev *led_cdev = dev_get_drvdata(dev); |
178 | struct ns2_led_data *led_dat = | ||
179 | container_of(led_cdev, struct ns2_led_data, cdev); | ||
176 | 180 | ||
177 | return sprintf(buf, "%d\n", led_dat->sata); | 181 | return sprintf(buf, "%d\n", led_dat->sata); |
178 | } | 182 | } |
@@ -234,7 +238,6 @@ create_ns2_led(struct platform_device *pdev, struct ns2_led_data *led_dat, | |||
234 | if (ret < 0) | 238 | if (ret < 0) |
235 | goto err_free_slow; | 239 | goto err_free_slow; |
236 | 240 | ||
237 | dev_set_drvdata(led_dat->cdev.dev, led_dat); | ||
238 | ret = device_create_file(led_dat->cdev.dev, &dev_attr_sata); | 241 | ret = device_create_file(led_dat->cdev.dev, &dev_attr_sata); |
239 | if (ret < 0) | 242 | if (ret < 0) |
240 | goto err_free_cdev; | 243 | goto err_free_cdev; |