diff options
author | Philipp Zabel <philipp.zabel@gmail.com> | 2011-04-28 16:19:32 -0400 |
---|---|---|
committer | Eric Miao <eric.y.miao@gmail.com> | 2011-07-11 02:43:31 -0400 |
commit | 4c738b2568340f5a99618d75293d7ee6a9267b1b (patch) | |
tree | e2e7c6accf587040f361f4f6d81423b237762522 /arch/arm/mach-pxa | |
parent | 6d49e6cfb2a199256ec851b1855dd86de83c5092 (diff) |
ARM: pxa/mioa701: use gpio arrays for global and gsm gpios
gpio_request_array() / gpio_free_array() are functional replacements for
mio_gpio_request() / mio_gpio_free(), which are now obsolete.
Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Eric Miao <eric.y.miao@gmail.com>
Diffstat (limited to 'arch/arm/mach-pxa')
-rw-r--r-- | arch/arm/mach-pxa/mioa701.c | 70 |
1 files changed, 15 insertions, 55 deletions
diff --git a/arch/arm/mach-pxa/mioa701.c b/arch/arm/mach-pxa/mioa701.c index e3470137c934..aa67637ae41d 100644 --- a/arch/arm/mach-pxa/mioa701.c +++ b/arch/arm/mach-pxa/mioa701.c | |||
@@ -177,50 +177,6 @@ static unsigned long mioa701_pin_config[] = { | |||
177 | MFP_CFG_OUT(GPIO116, AF0, DRIVE_HIGH), | 177 | MFP_CFG_OUT(GPIO116, AF0, DRIVE_HIGH), |
178 | }; | 178 | }; |
179 | 179 | ||
180 | #define MIO_GPIO_IN(num, _desc) \ | ||
181 | { .gpio = (num), .dir = 0, .desc = (_desc) } | ||
182 | #define MIO_GPIO_OUT(num, _init, _desc) \ | ||
183 | { .gpio = (num), .dir = 1, .init = (_init), .desc = (_desc) } | ||
184 | struct gpio_ress { | ||
185 | unsigned gpio : 8; | ||
186 | unsigned dir : 1; | ||
187 | unsigned init : 1; | ||
188 | char *desc; | ||
189 | }; | ||
190 | |||
191 | static int mio_gpio_request(struct gpio_ress *gpios, int size) | ||
192 | { | ||
193 | int i, rc = 0; | ||
194 | int gpio; | ||
195 | int dir; | ||
196 | |||
197 | for (i = 0; (!rc) && (i < size); i++) { | ||
198 | gpio = gpios[i].gpio; | ||
199 | dir = gpios[i].dir; | ||
200 | rc = gpio_request(gpio, gpios[i].desc); | ||
201 | if (rc) { | ||
202 | printk(KERN_ERR "Error requesting GPIO %d(%s) : %d\n", | ||
203 | gpio, gpios[i].desc, rc); | ||
204 | continue; | ||
205 | } | ||
206 | if (dir) | ||
207 | gpio_direction_output(gpio, gpios[i].init); | ||
208 | else | ||
209 | gpio_direction_input(gpio); | ||
210 | } | ||
211 | while ((rc) && (--i >= 0)) | ||
212 | gpio_free(gpios[i].gpio); | ||
213 | return rc; | ||
214 | } | ||
215 | |||
216 | static void mio_gpio_free(struct gpio_ress *gpios, int size) | ||
217 | { | ||
218 | int i; | ||
219 | |||
220 | for (i = 0; i < size; i++) | ||
221 | gpio_free(gpios[i].gpio); | ||
222 | } | ||
223 | |||
224 | /* LCD Screen and Backlight */ | 180 | /* LCD Screen and Backlight */ |
225 | static struct platform_pwm_backlight_data mioa701_backlight_data = { | 181 | static struct platform_pwm_backlight_data mioa701_backlight_data = { |
226 | .pwm_id = 0, | 182 | .pwm_id = 0, |
@@ -346,16 +302,16 @@ irqreturn_t gsm_on_irq(int irq, void *p) | |||
346 | return IRQ_HANDLED; | 302 | return IRQ_HANDLED; |
347 | } | 303 | } |
348 | 304 | ||
349 | struct gpio_ress gsm_gpios[] = { | 305 | static struct gpio gsm_gpios[] = { |
350 | MIO_GPIO_IN(GPIO25_GSM_MOD_ON_STATE, "GSM state"), | 306 | { GPIO25_GSM_MOD_ON_STATE, GPIOF_IN, "GSM state" }, |
351 | MIO_GPIO_IN(GPIO113_GSM_EVENT, "GSM event"), | 307 | { GPIO113_GSM_EVENT, GPIOF_IN, "GSM event" }, |
352 | }; | 308 | }; |
353 | 309 | ||
354 | static int __init gsm_init(void) | 310 | static int __init gsm_init(void) |
355 | { | 311 | { |
356 | int rc; | 312 | int rc; |
357 | 313 | ||
358 | rc = mio_gpio_request(ARRAY_AND_SIZE(gsm_gpios)); | 314 | rc = gpio_request_array(ARRAY_AND_SIZE(gsm_gpios)); |
359 | if (rc) | 315 | if (rc) |
360 | goto err_gpio; | 316 | goto err_gpio; |
361 | rc = request_irq(gpio_to_irq(GPIO25_GSM_MOD_ON_STATE), gsm_on_irq, | 317 | rc = request_irq(gpio_to_irq(GPIO25_GSM_MOD_ON_STATE), gsm_on_irq, |
@@ -369,7 +325,7 @@ static int __init gsm_init(void) | |||
369 | 325 | ||
370 | err_irq: | 326 | err_irq: |
371 | printk(KERN_ERR "Mioa701: Can't request GSM_ON irq\n"); | 327 | printk(KERN_ERR "Mioa701: Can't request GSM_ON irq\n"); |
372 | mio_gpio_free(ARRAY_AND_SIZE(gsm_gpios)); | 328 | gpio_free_array(ARRAY_AND_SIZE(gsm_gpios)); |
373 | err_gpio: | 329 | err_gpio: |
374 | printk(KERN_ERR "Mioa701: gsm not available\n"); | 330 | printk(KERN_ERR "Mioa701: gsm not available\n"); |
375 | return rc; | 331 | return rc; |
@@ -378,7 +334,7 @@ err_gpio: | |||
378 | static void gsm_exit(void) | 334 | static void gsm_exit(void) |
379 | { | 335 | { |
380 | free_irq(gpio_to_irq(GPIO25_GSM_MOD_ON_STATE), NULL); | 336 | free_irq(gpio_to_irq(GPIO25_GSM_MOD_ON_STATE), NULL); |
381 | mio_gpio_free(ARRAY_AND_SIZE(gsm_gpios)); | 337 | gpio_free_array(ARRAY_AND_SIZE(gsm_gpios)); |
382 | } | 338 | } |
383 | 339 | ||
384 | /* | 340 | /* |
@@ -749,14 +705,16 @@ static void mioa701_restart(char c, const char *cmd) | |||
749 | arm_machine_restart('s', cmd); | 705 | arm_machine_restart('s', cmd); |
750 | } | 706 | } |
751 | 707 | ||
752 | static struct gpio_ress global_gpios[] = { | 708 | static struct gpio global_gpios[] = { |
753 | MIO_GPIO_OUT(GPIO9_CHARGE_EN, 1, "Charger enable"), | 709 | { GPIO9_CHARGE_EN, GPIOF_OUT_INIT_HIGH, "Charger enable" }, |
754 | MIO_GPIO_OUT(GPIO18_POWEROFF, 0, "Power Off"), | 710 | { GPIO18_POWEROFF, GPIOF_OUT_INIT_LOW, "Power Off" }, |
755 | MIO_GPIO_OUT(GPIO87_LCD_POWER, 0, "LCD Power"), | 711 | { GPIO87_LCD_POWER, GPIOF_OUT_INIT_LOW, "LCD Power" }, |
756 | }; | 712 | }; |
757 | 713 | ||
758 | static void __init mioa701_machine_init(void) | 714 | static void __init mioa701_machine_init(void) |
759 | { | 715 | { |
716 | int rc; | ||
717 | |||
760 | PSLR = 0xff100000; /* SYSDEL=125ms, PWRDEL=125ms, PSLR_SL_ROD=1 */ | 718 | PSLR = 0xff100000; /* SYSDEL=125ms, PWRDEL=125ms, PSLR_SL_ROD=1 */ |
761 | PCFR = PCFR_DC_EN | PCFR_GPR_EN | PCFR_OPDE; | 719 | PCFR = PCFR_DC_EN | PCFR_GPR_EN | PCFR_OPDE; |
762 | RTTR = 32768 - 1; /* Reset crazy WinCE value */ | 720 | RTTR = 32768 - 1; /* Reset crazy WinCE value */ |
@@ -766,7 +724,9 @@ static void __init mioa701_machine_init(void) | |||
766 | pxa_set_ffuart_info(NULL); | 724 | pxa_set_ffuart_info(NULL); |
767 | pxa_set_btuart_info(NULL); | 725 | pxa_set_btuart_info(NULL); |
768 | pxa_set_stuart_info(NULL); | 726 | pxa_set_stuart_info(NULL); |
769 | mio_gpio_request(ARRAY_AND_SIZE(global_gpios)); | 727 | rc = gpio_request_array(ARRAY_AND_SIZE(global_gpios)); |
728 | if (rc) | ||
729 | pr_err("MioA701: Failed to request GPIOs: %d", rc); | ||
770 | bootstrap_init(); | 730 | bootstrap_init(); |
771 | pxa_set_fb_info(NULL, &mioa701_pxafb_info); | 731 | pxa_set_fb_info(NULL, &mioa701_pxafb_info); |
772 | pxa_set_mci_info(&mioa701_mci_info); | 732 | pxa_set_mci_info(&mioa701_mci_info); |