diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2013-09-10 05:19:55 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2013-09-27 08:15:07 -0400 |
commit | 8040dd09c2ca7e70daf84f040beb3ced9602fce5 (patch) | |
tree | c57e492d4d402a07c7585207a063545f50abc77d /arch/arm/mach-ixp4xx | |
parent | 272b98c6455f00884f0350f775c5342358ebb73f (diff) |
ARM: ixp4xx: convert remaining users to use gpiolib
A few call sites inside mach-ixp4xx were still using the custom
ixp4xx GPIO API with gpio_line_* accessors, convert all these
to use the standard gpiolib functions instead. Also attempt to
request and label all GPIOs before use. Move the GPIO requests
to per-machine device_initcalls() so we are not dependent on the
GPIO chip to be available at machine_init time.
Cc: Imre Kaloz <kaloz@openwrt.org>
Cc: Alexandre Courbot <acourbot@nvidia.com>
Acked-by: Krzysztof Halasa <khc@pm.waw.pl>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'arch/arm/mach-ixp4xx')
-rw-r--r-- | arch/arm/mach-ixp4xx/dsmg600-setup.c | 65 | ||||
-rw-r--r-- | arch/arm/mach-ixp4xx/ixdp425-setup.c | 8 | ||||
-rw-r--r-- | arch/arm/mach-ixp4xx/nas100d-setup.c | 49 | ||||
-rw-r--r-- | arch/arm/mach-ixp4xx/nslu2-setup.c | 17 |
4 files changed, 85 insertions, 54 deletions
diff --git a/arch/arm/mach-ixp4xx/dsmg600-setup.c b/arch/arm/mach-ixp4xx/dsmg600-setup.c index 63de1b3fd06b..736dc692d540 100644 --- a/arch/arm/mach-ixp4xx/dsmg600-setup.c +++ b/arch/arm/mach-ixp4xx/dsmg600-setup.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/reboot.h> | 26 | #include <linux/reboot.h> |
27 | #include <linux/i2c.h> | 27 | #include <linux/i2c.h> |
28 | #include <linux/i2c-gpio.h> | 28 | #include <linux/i2c-gpio.h> |
29 | #include <linux/gpio.h> | ||
29 | 30 | ||
30 | #include <mach/hardware.h> | 31 | #include <mach/hardware.h> |
31 | 32 | ||
@@ -161,11 +162,8 @@ static struct platform_device *dsmg600_devices[] __initdata = { | |||
161 | 162 | ||
162 | static void dsmg600_power_off(void) | 163 | static void dsmg600_power_off(void) |
163 | { | 164 | { |
164 | /* enable the pwr cntl gpio */ | 165 | /* enable the pwr cntl and drive it high */ |
165 | gpio_line_config(DSMG600_PO_GPIO, IXP4XX_GPIO_OUT); | 166 | gpio_direction_output(DSMG600_PO_GPIO, 1); |
166 | |||
167 | /* poweroff */ | ||
168 | gpio_line_set(DSMG600_PO_GPIO, IXP4XX_GPIO_HIGH); | ||
169 | } | 167 | } |
170 | 168 | ||
171 | /* This is used to make sure the power-button pusher is serious. The button | 169 | /* This is used to make sure the power-button pusher is serious. The button |
@@ -202,7 +200,7 @@ static void dsmg600_power_handler(unsigned long data) | |||
202 | ctrl_alt_del(); | 200 | ctrl_alt_del(); |
203 | 201 | ||
204 | /* Change the state of the power LED to "blink" */ | 202 | /* Change the state of the power LED to "blink" */ |
205 | gpio_line_set(DSMG600_LED_PWR_GPIO, IXP4XX_GPIO_LOW); | 203 | gpio_set_value(DSMG600_LED_PWR_GPIO, 0); |
206 | } else { | 204 | } else { |
207 | power_button_countdown = PBUTTON_HOLDDOWN_COUNT; | 205 | power_button_countdown = PBUTTON_HOLDDOWN_COUNT; |
208 | } | 206 | } |
@@ -228,6 +226,40 @@ static void __init dsmg600_timer_init(void) | |||
228 | ixp4xx_timer_init(); | 226 | ixp4xx_timer_init(); |
229 | } | 227 | } |
230 | 228 | ||
229 | static int __init dsmg600_gpio_init(void) | ||
230 | { | ||
231 | if (!machine_is_dsmg600()) | ||
232 | return 0; | ||
233 | |||
234 | gpio_request(DSMG600_RB_GPIO, "reset button"); | ||
235 | if (request_irq(gpio_to_irq(DSMG600_RB_GPIO), &dsmg600_reset_handler, | ||
236 | IRQF_DISABLED | IRQF_TRIGGER_LOW, | ||
237 | "DSM-G600 reset button", NULL) < 0) { | ||
238 | |||
239 | printk(KERN_DEBUG "Reset Button IRQ %d not available\n", | ||
240 | gpio_to_irq(DSMG600_RB_GPIO)); | ||
241 | } | ||
242 | |||
243 | /* | ||
244 | * The power button on the D-Link DSM-G600 is on GPIO 15, but | ||
245 | * it cannot handle interrupts on that GPIO line. So we'll | ||
246 | * have to poll it with a kernel timer. | ||
247 | */ | ||
248 | |||
249 | /* Make sure that the power button GPIO is set up as an input */ | ||
250 | gpio_request(DSMG600_PB_GPIO, "power button"); | ||
251 | gpio_direction_input(DSMG600_PB_GPIO); | ||
252 | /* Request poweroff GPIO line */ | ||
253 | gpio_request(DSMG600_PO_GPIO, "power off button"); | ||
254 | |||
255 | /* Set the initial value for the power button IRQ handler */ | ||
256 | power_button_countdown = PBUTTON_HOLDDOWN_COUNT; | ||
257 | |||
258 | mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500)); | ||
259 | return 0; | ||
260 | } | ||
261 | device_initcall(dsmg600_gpio_init); | ||
262 | |||
231 | static void __init dsmg600_init(void) | 263 | static void __init dsmg600_init(void) |
232 | { | 264 | { |
233 | ixp4xx_sys_init(); | 265 | ixp4xx_sys_init(); |
@@ -251,27 +283,6 @@ static void __init dsmg600_init(void) | |||
251 | platform_add_devices(dsmg600_devices, ARRAY_SIZE(dsmg600_devices)); | 283 | platform_add_devices(dsmg600_devices, ARRAY_SIZE(dsmg600_devices)); |
252 | 284 | ||
253 | pm_power_off = dsmg600_power_off; | 285 | pm_power_off = dsmg600_power_off; |
254 | |||
255 | if (request_irq(gpio_to_irq(DSMG600_RB_GPIO), &dsmg600_reset_handler, | ||
256 | IRQF_DISABLED | IRQF_TRIGGER_LOW, | ||
257 | "DSM-G600 reset button", NULL) < 0) { | ||
258 | |||
259 | printk(KERN_DEBUG "Reset Button IRQ %d not available\n", | ||
260 | gpio_to_irq(DSMG600_RB_GPIO)); | ||
261 | } | ||
262 | |||
263 | /* The power button on the D-Link DSM-G600 is on GPIO 15, but | ||
264 | * it cannot handle interrupts on that GPIO line. So we'll | ||
265 | * have to poll it with a kernel timer. | ||
266 | */ | ||
267 | |||
268 | /* Make sure that the power button GPIO is set up as an input */ | ||
269 | gpio_line_config(DSMG600_PB_GPIO, IXP4XX_GPIO_IN); | ||
270 | |||
271 | /* Set the initial value for the power button IRQ handler */ | ||
272 | power_button_countdown = PBUTTON_HOLDDOWN_COUNT; | ||
273 | |||
274 | mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500)); | ||
275 | } | 286 | } |
276 | 287 | ||
277 | MACHINE_START(DSMG600, "D-Link DSM-G600 RevA") | 288 | MACHINE_START(DSMG600, "D-Link DSM-G600 RevA") |
diff --git a/arch/arm/mach-ixp4xx/ixdp425-setup.c b/arch/arm/mach-ixp4xx/ixdp425-setup.c index 22d688b7d513..e7b8befa8729 100644 --- a/arch/arm/mach-ixp4xx/ixdp425-setup.c +++ b/arch/arm/mach-ixp4xx/ixdp425-setup.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/mtd/nand.h> | 20 | #include <linux/mtd/nand.h> |
21 | #include <linux/mtd/partitions.h> | 21 | #include <linux/mtd/partitions.h> |
22 | #include <linux/delay.h> | 22 | #include <linux/delay.h> |
23 | #include <linux/gpio.h> | ||
23 | #include <asm/types.h> | 24 | #include <asm/types.h> |
24 | #include <asm/setup.h> | 25 | #include <asm/setup.h> |
25 | #include <asm/memory.h> | 26 | #include <asm/memory.h> |
@@ -80,10 +81,10 @@ ixdp425_flash_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) | |||
80 | 81 | ||
81 | if (ctrl & NAND_CTRL_CHANGE) { | 82 | if (ctrl & NAND_CTRL_CHANGE) { |
82 | if (ctrl & NAND_NCE) { | 83 | if (ctrl & NAND_NCE) { |
83 | gpio_line_set(IXDP425_NAND_NCE_PIN, IXP4XX_GPIO_LOW); | 84 | gpio_set_value(IXDP425_NAND_NCE_PIN, 0); |
84 | udelay(5); | 85 | udelay(5); |
85 | } else | 86 | } else |
86 | gpio_line_set(IXDP425_NAND_NCE_PIN, IXP4XX_GPIO_HIGH); | 87 | gpio_set_value(IXDP425_NAND_NCE_PIN, 1); |
87 | 88 | ||
88 | offset = (ctrl & NAND_CLE) ? IXDP425_NAND_CMD_BYTE : 0; | 89 | offset = (ctrl & NAND_CLE) ? IXDP425_NAND_CMD_BYTE : 0; |
89 | offset |= (ctrl & NAND_ALE) ? IXDP425_NAND_ADDR_BYTE : 0; | 90 | offset |= (ctrl & NAND_ALE) ? IXDP425_NAND_ADDR_BYTE : 0; |
@@ -227,7 +228,8 @@ static void __init ixdp425_init(void) | |||
227 | ixdp425_flash_nand_resource.start = IXP4XX_EXP_BUS_BASE(3), | 228 | ixdp425_flash_nand_resource.start = IXP4XX_EXP_BUS_BASE(3), |
228 | ixdp425_flash_nand_resource.end = IXP4XX_EXP_BUS_BASE(3) + 0x10 - 1; | 229 | ixdp425_flash_nand_resource.end = IXP4XX_EXP_BUS_BASE(3) + 0x10 - 1; |
229 | 230 | ||
230 | gpio_line_config(IXDP425_NAND_NCE_PIN, IXP4XX_GPIO_OUT); | 231 | gpio_request(IXDP425_NAND_NCE_PIN, "NAND NCE pin"); |
232 | gpio_direction_output(IXDP425_NAND_NCE_PIN, 0); | ||
231 | 233 | ||
232 | /* Configure expansion bus for NAND Flash */ | 234 | /* Configure expansion bus for NAND Flash */ |
233 | *IXP4XX_EXP_CS3 = IXP4XX_EXP_BUS_CS_EN | | 235 | *IXP4XX_EXP_CS3 = IXP4XX_EXP_BUS_CS_EN | |
diff --git a/arch/arm/mach-ixp4xx/nas100d-setup.c b/arch/arm/mach-ixp4xx/nas100d-setup.c index ed667ce9f576..507cb5233537 100644 --- a/arch/arm/mach-ixp4xx/nas100d-setup.c +++ b/arch/arm/mach-ixp4xx/nas100d-setup.c | |||
@@ -184,11 +184,8 @@ static void nas100d_power_off(void) | |||
184 | { | 184 | { |
185 | /* This causes the box to drop the power and go dead. */ | 185 | /* This causes the box to drop the power and go dead. */ |
186 | 186 | ||
187 | /* enable the pwr cntl gpio */ | 187 | /* enable the pwr cntl gpio and assert power off */ |
188 | gpio_line_config(NAS100D_PO_GPIO, IXP4XX_GPIO_OUT); | 188 | gpio_direction_output(NAS100D_PO_GPIO, 1); |
189 | |||
190 | /* do the deed */ | ||
191 | gpio_line_set(NAS100D_PO_GPIO, IXP4XX_GPIO_HIGH); | ||
192 | } | 189 | } |
193 | 190 | ||
194 | /* This is used to make sure the power-button pusher is serious. The button | 191 | /* This is used to make sure the power-button pusher is serious. The button |
@@ -225,7 +222,7 @@ static void nas100d_power_handler(unsigned long data) | |||
225 | ctrl_alt_del(); | 222 | ctrl_alt_del(); |
226 | 223 | ||
227 | /* Change the state of the power LED to "blink" */ | 224 | /* Change the state of the power LED to "blink" */ |
228 | gpio_line_set(NAS100D_LED_PWR_GPIO, IXP4XX_GPIO_LOW); | 225 | gpio_set_value(NAS100D_LED_PWR_GPIO, 0); |
229 | } else { | 226 | } else { |
230 | power_button_countdown = PBUTTON_HOLDDOWN_COUNT; | 227 | power_button_countdown = PBUTTON_HOLDDOWN_COUNT; |
231 | } | 228 | } |
@@ -242,6 +239,33 @@ static irqreturn_t nas100d_reset_handler(int irq, void *dev_id) | |||
242 | return IRQ_HANDLED; | 239 | return IRQ_HANDLED; |
243 | } | 240 | } |
244 | 241 | ||
242 | static int __init nas100d_gpio_init(void) | ||
243 | { | ||
244 | if (!machine_is_nas100d()) | ||
245 | return 0; | ||
246 | |||
247 | /* | ||
248 | * The power button on the Iomega NAS100d is on GPIO 14, but | ||
249 | * it cannot handle interrupts on that GPIO line. So we'll | ||
250 | * have to poll it with a kernel timer. | ||
251 | */ | ||
252 | |||
253 | /* Request the power off GPIO */ | ||
254 | gpio_request(NAS100D_PO_GPIO, "power off"); | ||
255 | |||
256 | /* Make sure that the power button GPIO is set up as an input */ | ||
257 | gpio_request(NAS100D_PB_GPIO, "power button"); | ||
258 | gpio_direction_input(NAS100D_PB_GPIO); | ||
259 | |||
260 | /* Set the initial value for the power button IRQ handler */ | ||
261 | power_button_countdown = PBUTTON_HOLDDOWN_COUNT; | ||
262 | |||
263 | mod_timer(&nas100d_power_timer, jiffies + msecs_to_jiffies(500)); | ||
264 | |||
265 | return 0; | ||
266 | } | ||
267 | device_initcall(nas100d_gpio_init); | ||
268 | |||
245 | static void __init nas100d_init(void) | 269 | static void __init nas100d_init(void) |
246 | { | 270 | { |
247 | uint8_t __iomem *f; | 271 | uint8_t __iomem *f; |
@@ -278,19 +302,6 @@ static void __init nas100d_init(void) | |||
278 | gpio_to_irq(NAS100D_RB_GPIO)); | 302 | gpio_to_irq(NAS100D_RB_GPIO)); |
279 | } | 303 | } |
280 | 304 | ||
281 | /* The power button on the Iomega NAS100d is on GPIO 14, but | ||
282 | * it cannot handle interrupts on that GPIO line. So we'll | ||
283 | * have to poll it with a kernel timer. | ||
284 | */ | ||
285 | |||
286 | /* Make sure that the power button GPIO is set up as an input */ | ||
287 | gpio_line_config(NAS100D_PB_GPIO, IXP4XX_GPIO_IN); | ||
288 | |||
289 | /* Set the initial value for the power button IRQ handler */ | ||
290 | power_button_countdown = PBUTTON_HOLDDOWN_COUNT; | ||
291 | |||
292 | mod_timer(&nas100d_power_timer, jiffies + msecs_to_jiffies(500)); | ||
293 | |||
294 | /* | 305 | /* |
295 | * Map in a portion of the flash and read the MAC address. | 306 | * Map in a portion of the flash and read the MAC address. |
296 | * Since it is stored in BE in the flash itself, we need to | 307 | * Since it is stored in BE in the flash itself, we need to |
diff --git a/arch/arm/mach-ixp4xx/nslu2-setup.c b/arch/arm/mach-ixp4xx/nslu2-setup.c index 7e55236c26ea..ba5f1cda2a9d 100644 --- a/arch/arm/mach-ixp4xx/nslu2-setup.c +++ b/arch/arm/mach-ixp4xx/nslu2-setup.c | |||
@@ -197,11 +197,8 @@ static void nslu2_power_off(void) | |||
197 | { | 197 | { |
198 | /* This causes the box to drop the power and go dead. */ | 198 | /* This causes the box to drop the power and go dead. */ |
199 | 199 | ||
200 | /* enable the pwr cntl gpio */ | 200 | /* enable the pwr cntl gpio and assert power off */ |
201 | gpio_line_config(NSLU2_PO_GPIO, IXP4XX_GPIO_OUT); | 201 | gpio_direction_output(NSLU2_PO_GPIO, 1); |
202 | |||
203 | /* do the deed */ | ||
204 | gpio_line_set(NSLU2_PO_GPIO, IXP4XX_GPIO_HIGH); | ||
205 | } | 202 | } |
206 | 203 | ||
207 | static irqreturn_t nslu2_power_handler(int irq, void *dev_id) | 204 | static irqreturn_t nslu2_power_handler(int irq, void *dev_id) |
@@ -223,6 +220,16 @@ static irqreturn_t nslu2_reset_handler(int irq, void *dev_id) | |||
223 | return IRQ_HANDLED; | 220 | return IRQ_HANDLED; |
224 | } | 221 | } |
225 | 222 | ||
223 | static int __init nslu2_gpio_init(void) | ||
224 | { | ||
225 | if (!machine_is_nslu2()) | ||
226 | return 0; | ||
227 | |||
228 | /* Request the power off GPIO */ | ||
229 | return gpio_request(NSLU2_PO_GPIO, "power off"); | ||
230 | } | ||
231 | device_initcall(nslu2_gpio_init); | ||
232 | |||
226 | static void __init nslu2_timer_init(void) | 233 | static void __init nslu2_timer_init(void) |
227 | { | 234 | { |
228 | /* The xtal on this machine is non-standard. */ | 235 | /* The xtal on this machine is non-standard. */ |