diff options
author | Philipp Zabel <philipp.zabel@gmail.com> | 2011-04-28 16:21:04 -0400 |
---|---|---|
committer | Eric Miao <eric.y.miao@gmail.com> | 2011-07-11 02:43:30 -0400 |
commit | 5db15f86830070e0905940c5d3d92d12c0874424 (patch) | |
tree | eb5dc3b31d271242f8ffdada7212dca75dac7c20 /arch/arm/mach-pxa/magician.c | |
parent | 250ccd4f343b8ecb50f94d27ef5dc131db337024 (diff) |
ARM: pxa/magician: use gpio arrays for backlight and global gpios
Use gpio_request_array() / gpio_free_array() in backlight init and exit
functions and global gpio initialization.
Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
Signed-off-by: Eric Miao <eric.y.miao@gmail.com>
Diffstat (limited to 'arch/arm/mach-pxa/magician.c')
-rw-r--r-- | arch/arm/mach-pxa/magician.c | 57 |
1 files changed, 23 insertions, 34 deletions
diff --git a/arch/arm/mach-pxa/magician.c b/arch/arm/mach-pxa/magician.c index e1920572948a..0e42798942f7 100644 --- a/arch/arm/mach-pxa/magician.c +++ b/arch/arm/mach-pxa/magician.c | |||
@@ -344,22 +344,14 @@ static struct pxafb_mach_info samsung_info = { | |||
344 | * Backlight | 344 | * Backlight |
345 | */ | 345 | */ |
346 | 346 | ||
347 | static struct gpio magician_bl_gpios[] = { | ||
348 | { EGPIO_MAGICIAN_BL_POWER, GPIOF_DIR_OUT, "Backlight power" }, | ||
349 | { EGPIO_MAGICIAN_BL_POWER2, GPIOF_DIR_OUT, "Backlight power 2" }, | ||
350 | }; | ||
351 | |||
347 | static int magician_backlight_init(struct device *dev) | 352 | static int magician_backlight_init(struct device *dev) |
348 | { | 353 | { |
349 | int ret; | 354 | return gpio_request_array(ARRAY_AND_SIZE(magician_bl_gpios)); |
350 | |||
351 | ret = gpio_request(EGPIO_MAGICIAN_BL_POWER, "BL_POWER"); | ||
352 | if (ret) | ||
353 | goto err; | ||
354 | ret = gpio_request(EGPIO_MAGICIAN_BL_POWER2, "BL_POWER2"); | ||
355 | if (ret) | ||
356 | goto err2; | ||
357 | return 0; | ||
358 | |||
359 | err2: | ||
360 | gpio_free(EGPIO_MAGICIAN_BL_POWER); | ||
361 | err: | ||
362 | return ret; | ||
363 | } | 355 | } |
364 | 356 | ||
365 | static int magician_backlight_notify(struct device *dev, int brightness) | 357 | static int magician_backlight_notify(struct device *dev, int brightness) |
@@ -376,8 +368,7 @@ static int magician_backlight_notify(struct device *dev, int brightness) | |||
376 | 368 | ||
377 | static void magician_backlight_exit(struct device *dev) | 369 | static void magician_backlight_exit(struct device *dev) |
378 | { | 370 | { |
379 | gpio_free(EGPIO_MAGICIAN_BL_POWER); | 371 | gpio_free_array(ARRAY_AND_SIZE(magician_bl_gpios)); |
380 | gpio_free(EGPIO_MAGICIAN_BL_POWER2); | ||
381 | } | 372 | } |
382 | 373 | ||
383 | static struct platform_pwm_backlight_data backlight_data = { | 374 | static struct platform_pwm_backlight_data backlight_data = { |
@@ -712,16 +703,25 @@ static struct platform_device *devices[] __initdata = { | |||
712 | &leds_gpio, | 703 | &leds_gpio, |
713 | }; | 704 | }; |
714 | 705 | ||
706 | static struct gpio magician_global_gpios[] = { | ||
707 | { GPIO13_MAGICIAN_CPLD_IRQ, GPIOF_IN, "CPLD_IRQ" }, | ||
708 | { GPIO107_MAGICIAN_DS1WM_IRQ, GPIOF_IN, "DS1WM_IRQ" }, | ||
709 | { GPIO104_MAGICIAN_LCD_POWER_1, GPIOF_OUT_INIT_LOW, "LCD power 1" }, | ||
710 | { GPIO105_MAGICIAN_LCD_POWER_2, GPIOF_OUT_INIT_LOW, "LCD power 2" }, | ||
711 | { GPIO106_MAGICIAN_LCD_POWER_3, GPIOF_OUT_INIT_LOW, "LCD power 3" }, | ||
712 | { GPIO83_MAGICIAN_nIR_EN, GPIOF_OUT_INIT_HIGH, "nIR_EN" }, | ||
713 | }; | ||
714 | |||
715 | static void __init magician_init(void) | 715 | static void __init magician_init(void) |
716 | { | 716 | { |
717 | void __iomem *cpld; | 717 | void __iomem *cpld; |
718 | int lcd_select; | 718 | int lcd_select; |
719 | int err; | 719 | int err; |
720 | 720 | ||
721 | gpio_request(GPIO13_MAGICIAN_CPLD_IRQ, "CPLD_IRQ"); | ||
722 | gpio_request(GPIO107_MAGICIAN_DS1WM_IRQ, "DS1WM_IRQ"); | ||
723 | |||
724 | pxa2xx_mfp_config(ARRAY_AND_SIZE(magician_pin_config)); | 721 | pxa2xx_mfp_config(ARRAY_AND_SIZE(magician_pin_config)); |
722 | err = gpio_request_array(ARRAY_AND_SIZE(magician_global_gpios)); | ||
723 | if (err) | ||
724 | pr_err("magician: Failed to request GPIOs: %d\n", err); | ||
725 | 725 | ||
726 | pxa_set_ffuart_info(NULL); | 726 | pxa_set_ffuart_info(NULL); |
727 | pxa_set_btuart_info(NULL); | 727 | pxa_set_btuart_info(NULL); |
@@ -729,11 +729,7 @@ static void __init magician_init(void) | |||
729 | 729 | ||
730 | platform_add_devices(ARRAY_AND_SIZE(devices)); | 730 | platform_add_devices(ARRAY_AND_SIZE(devices)); |
731 | 731 | ||
732 | err = gpio_request(GPIO83_MAGICIAN_nIR_EN, "nIR_EN"); | 732 | pxa_set_ficp_info(&magician_ficp_info); |
733 | if (!err) { | ||
734 | gpio_direction_output(GPIO83_MAGICIAN_nIR_EN, 1); | ||
735 | pxa_set_ficp_info(&magician_ficp_info); | ||
736 | } | ||
737 | pxa27x_set_i2c_power_info(NULL); | 733 | pxa27x_set_i2c_power_info(NULL); |
738 | pxa_set_i2c_info(&i2c_info); | 734 | pxa_set_i2c_info(&i2c_info); |
739 | pxa_set_mci_info(&magician_mci_info); | 735 | pxa_set_mci_info(&magician_mci_info); |
@@ -747,16 +743,9 @@ static void __init magician_init(void) | |||
747 | system_rev = board_id & 0x7; | 743 | system_rev = board_id & 0x7; |
748 | lcd_select = board_id & 0x8; | 744 | lcd_select = board_id & 0x8; |
749 | pr_info("LCD type: %s\n", lcd_select ? "Samsung" : "Toppoly"); | 745 | pr_info("LCD type: %s\n", lcd_select ? "Samsung" : "Toppoly"); |
750 | if (lcd_select && (system_rev < 3)) { | 746 | if (lcd_select && (system_rev < 3)) |
751 | gpio_request(GPIO75_MAGICIAN_SAMSUNG_POWER, "SAMSUNG_POWER"); | 747 | gpio_request_one(GPIO75_MAGICIAN_SAMSUNG_POWER, |
752 | gpio_direction_output(GPIO75_MAGICIAN_SAMSUNG_POWER, 0); | 748 | GPIOF_OUT_INIT_LOW, "SAMSUNG_POWER"); |
753 | } | ||
754 | gpio_request(GPIO104_MAGICIAN_LCD_POWER_1, "LCD_POWER_1"); | ||
755 | gpio_request(GPIO105_MAGICIAN_LCD_POWER_2, "LCD_POWER_2"); | ||
756 | gpio_request(GPIO106_MAGICIAN_LCD_POWER_3, "LCD_POWER_3"); | ||
757 | gpio_direction_output(GPIO104_MAGICIAN_LCD_POWER_1, 0); | ||
758 | gpio_direction_output(GPIO105_MAGICIAN_LCD_POWER_2, 0); | ||
759 | gpio_direction_output(GPIO106_MAGICIAN_LCD_POWER_3, 0); | ||
760 | pxa_set_fb_info(NULL, lcd_select ? &samsung_info : &toppoly_info); | 749 | pxa_set_fb_info(NULL, lcd_select ? &samsung_info : &toppoly_info); |
761 | } else | 750 | } else |
762 | pr_err("LCD detection: CPLD mapping failed\n"); | 751 | pr_err("LCD detection: CPLD mapping failed\n"); |