[ARM] pxa: factor pxamci gpio handling
[linux-2.6.git] / arch / arm / mach-pxa / poodle.c
index 74f4ce6..333b1dc 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/delay.h>
 #include <linux/mtd/physmap.h>
 #include <linux/gpio.h>
+#include <linux/i2c.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/ads7846.h>
 #include <linux/mtd/sharpsl.h>
@@ -214,13 +215,8 @@ static struct ads7846_platform_data poodle_ads7846_info = {
        .gpio_pendown           = POODLE_GPIO_TP_INT,
 };
 
-static void ads7846_cs(u32 command)
-{
-       gpio_set_value(POODLE_GPIO_TP_CS, !(command == PXA2XX_CS_ASSERT));
-}
-
 static struct pxa2xx_spi_chip poodle_ads7846_chip = {
-       .cs_control             = ads7846_cs,
+       .gpio_cs                = POODLE_GPIO_TP_CS,
 };
 
 static struct spi_board_info poodle_spi_devices[] = {
@@ -236,14 +232,6 @@ static struct spi_board_info poodle_spi_devices[] = {
 
 static void __init poodle_init_spi(void)
 {
-       int err;
-
-       err = gpio_request(POODLE_GPIO_TP_CS, "ADS7846_CS");
-       if (err)
-               return;
-
-       gpio_direction_output(POODLE_GPIO_TP_CS, 1);
-
        pxa2xx_set_spi_info(1, &poodle_spi_info);
        spi_register_board_info(ARRAY_AND_SIZE(poodle_spi_devices));
 }
@@ -257,20 +245,10 @@ static inline void poodle_init_spi(void) {}
  * The card detect interrupt isn't debounced so we delay it by 250ms
  * to give the card a chance to fully insert/eject.
  */
-static struct pxamci_platform_data poodle_mci_platform_data;
-
 static int poodle_mci_init(struct device *dev, irq_handler_t poodle_detect_int, void *data)
 {
        int err;
 
-       err = gpio_request(POODLE_GPIO_nSD_DETECT, "nSD_DETECT");
-       if (err)
-               goto err_out;
-
-       err = gpio_request(POODLE_GPIO_nSD_WP, "nSD_WP");
-       if (err)
-               goto err_free_1;
-
        err = gpio_request(POODLE_GPIO_SD_PWR, "SD_PWR");
        if (err)
                goto err_free_2;
@@ -279,34 +257,14 @@ static int poodle_mci_init(struct device *dev, irq_handler_t poodle_detect_int,
        if (err)
                goto err_free_3;
 
-       gpio_direction_input(POODLE_GPIO_nSD_DETECT);
-       gpio_direction_input(POODLE_GPIO_nSD_WP);
-
        gpio_direction_output(POODLE_GPIO_SD_PWR, 0);
        gpio_direction_output(POODLE_GPIO_SD_PWR1, 0);
 
-       poodle_mci_platform_data.detect_delay = msecs_to_jiffies(250);
-
-       err = request_irq(POODLE_IRQ_GPIO_nSD_DETECT, poodle_detect_int,
-                         IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
-                         "MMC card detect", data);
-       if (err) {
-               pr_err("%s: MMC/SD: can't request MMC card detect IRQ\n",
-                               __func__);
-               goto err_free_4;
-       }
-
        return 0;
 
-err_free_4:
-       gpio_free(POODLE_GPIO_SD_PWR1);
 err_free_3:
        gpio_free(POODLE_GPIO_SD_PWR);
 err_free_2:
-       gpio_free(POODLE_GPIO_nSD_WP);
-err_free_1:
-       gpio_free(POODLE_GPIO_nSD_DETECT);
-err_out:
        return err;
 }
 
@@ -324,28 +282,20 @@ static void poodle_mci_setpower(struct device *dev, unsigned int vdd)
        }
 }
 
-static int poodle_mci_get_ro(struct device *dev)
-{
-       return !!gpio_get_value(POODLE_GPIO_nSD_WP);
-       return GPLR(POODLE_GPIO_nSD_WP) & GPIO_bit(POODLE_GPIO_nSD_WP);
-}
-
-
 static void poodle_mci_exit(struct device *dev, void *data)
 {
-       free_irq(POODLE_IRQ_GPIO_nSD_DETECT, data);
        gpio_free(POODLE_GPIO_SD_PWR1);
        gpio_free(POODLE_GPIO_SD_PWR);
-       gpio_free(POODLE_GPIO_nSD_WP);
-       gpio_free(POODLE_GPIO_nSD_DETECT);
 }
 
 static struct pxamci_platform_data poodle_mci_platform_data = {
-       .ocr_mask       = MMC_VDD_32_33|MMC_VDD_33_34,
-       .init           = poodle_mci_init,
-       .get_ro         = poodle_mci_get_ro,
-       .setpower       = poodle_mci_setpower,
-       .exit           = poodle_mci_exit,
+       .ocr_mask               = MMC_VDD_32_33|MMC_VDD_33_34,
+       .init                   = poodle_mci_init,
+       .setpower               = poodle_mci_setpower,
+       .exit                   = poodle_mci_exit,
+       .gpio_card_detect       = POODLE_IRQ_GPIO_nSD_DETECT,
+       .gpio_card_ro           = POODLE_GPIO_nSD_WP,
+       .gpio_power             = -1,
 };
 
 
@@ -499,6 +449,10 @@ static struct platform_device *devices[] __initdata = {
        &sharpsl_rom_device,
 };
 
+static struct i2c_board_info __initdata poodle_i2c_devices[] = {
+       { I2C_BOARD_INFO("wm8731", 0x1b) },
+};
+
 static void poodle_poweroff(void)
 {
        arm_machine_restart('h', NULL);
@@ -529,9 +483,11 @@ static void __init poodle_init(void)
        set_pxa_fb_parent(&poodle_locomo_device.dev);
        set_pxa_fb_info(&poodle_fb_info);
        pxa_set_udc_info(&udc_info);
+       poodle_mci_platform_data.detect_delay = msecs_to_jiffies(250);
        pxa_set_mci_info(&poodle_mci_platform_data);
        pxa_set_ficp_info(&poodle_ficp_platform_data);
        pxa_set_i2c_info(NULL);
+       i2c_register_board_info(0, ARRAY_AND_SIZE(poodle_i2c_devices));
        poodle_init_spi();
 }