Merge branch 'master' of git://git.lpclinux.com/linux-2.6.34-lpc32xx
authorKevin Wells <wellsk40@gmail.com>
Thu, 7 Apr 2011 18:24:17 +0000 (11:24 -0700)
committerKevin Wells <wellsk40@gmail.com>
Thu, 7 Apr 2011 18:24:17 +0000 (11:24 -0700)
arch/arm/mach-lpc32xx/ea3250.c

index ff80325..41849d8 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/spi/spi.h>
 #include <linux/spi/eeprom.h>
 #include <linux/leds.h>
+#include <linux/leds-pca9532.h>
 #include <linux/gpio.h>
 #include <linux/input.h>
 #include <linux/amba/bus.h>
@@ -58,6 +59,7 @@
 #define        LCD_RS_GPIO     LPC32XX_GPIO(LPC32XX_GPO_P3_GRP, 5)
 #define        BKL_POW_GPIO    LPC32XX_GPIO(LPC32XX_GPO_P3_GRP, 14)
 #define        SSEL0_GPIO5     LPC32XX_GPIO(LPC32XX_GPIO_P3_GRP, 5)
+#define        MMC_POWER_GPIO  LPC32XX_GPIO(LPC32XX_GPO_P3_GRP, 1)
 
 /*
  * LCD controller functions
@@ -92,6 +94,52 @@ static struct platform_device lpc32xx_gpio_led_device = {
        .dev.platform_data      = &led_data,
 };
 
+static struct pca9532_platform_data ea3250_leds = {
+       .leds = {
+       {       .type = PCA9532_TYPE_NONE }, /* Key 1 */
+       {       .type = PCA9532_TYPE_NONE }, /* Key 2 */
+       {       .type = PCA9532_TYPE_NONE }, /* Key 3 */
+       {       .type = PCA9532_TYPE_NONE }, /* Key 4 */
+       {       .type = PCA9532_TYPE_NONE }, /* MMC CD */
+       {       .type = PCA9532_TYPE_NONE }, /* MMC WP */
+       {       .type = PCA9532_TYPE_NONE }, /* not used */
+       {       .type = PCA9532_TYPE_NONE }, /* not used */
+       {       .name = "eabb:red:led1",
+               .state = PCA9532_OFF,
+               .type = PCA9532_TYPE_LED,
+       },
+       {       .name = "eabb:red:led2",
+               .state = PCA9532_OFF,
+               .type = PCA9532_TYPE_LED,
+       },
+       {       .name = "eabb:red:led3",
+               .state = PCA9532_OFF,
+               .type = PCA9532_TYPE_LED,
+       },
+       {       .name = "eabb:red:led4",
+               .state = PCA9532_OFF,
+               .type = PCA9532_TYPE_LED,
+       },
+       {       .name = "eabb:red:led5",
+               .state = PCA9532_OFF,
+               .type = PCA9532_TYPE_LED,
+       },
+       {       .name = "eabb:red:led6",
+               .state = PCA9532_OFF,
+               .type = PCA9532_TYPE_LED,
+       },
+       {       .name = "eabb:red:led7",
+               .state = PCA9532_OFF,
+               .type = PCA9532_TYPE_LED,
+       },
+       {       .name = "eabb:red:led8",
+               .state = PCA9532_OFF,
+               .type = PCA9532_TYPE_LED,
+       }, },
+       .psc = { 0, 0 },
+       .pwm = { 0, 0 },
+};
+
 /*
  * AMBA SSP (SPI)
  */
@@ -581,12 +629,89 @@ void __init ea3250_spi_lcdc_drv_init(void)
         spi_register_driver(&ea3250_spi_lcdc_driver);
 }
 
+#if defined (CONFIG_MMC_ARMMMCI)
+
+/*
+ * Returns !0 when card is removed, 0 when present
+ */
+unsigned int mmc_card_detect(struct device *dev)
+{
+       /*
+        * This function may be adapted to retrieve the actual 'card detect'
+        * status over the I2C bus, from PCA9532 pin 8 (LED4). For now, simply
+        * indicate that a card is always present.
+       */
+       return 0;
+}
+
+/*
+ * Enable or disable SD slot power
+ */
+void mmc_power_enable(int enable)
+{
+       if (enable != 0)
+       {
+               /* active low */
+               gpio_set_value(MMC_POWER_GPIO,0);
+       }
+       else
+       {
+               gpio_set_value(MMC_POWER_GPIO,0);
+       }
+}
+
+/*
+ * Board specific MMC driver data
+ */
+struct mmci_platform_data lpc32xx_plat_data = {
+       .ocr_mask       = MMC_VDD_30_31|MMC_VDD_31_32|MMC_VDD_32_33|MMC_VDD_33_34,
+       .translate_vdd  = NULL,
+       .capabilities   = MMC_CAP_4_BIT_DATA,
+       /*
+        * Indicate no direct GPIO, so MMC driver will assume card is NOT
+        * write-protected
+        */
+        .gpio_wp        = -ENOSYS,
+       /*
+        * Indicate no direct GPIO, so MMC driver will call 'status' callback
+        * function
+        */
+        .gpio_cd        = -ENOSYS,
+       /*
+        * Callback function, used by MMC driver in case 'gpio_cd'
+        * equals -ENOSYS
+        */
+       .status         = mmc_card_detect,
+};
+
+/*
+ * SD card controller resources
+ */
+struct amba_device lpc32xx_mmc_device = {
+       .dev                            = {
+               .coherent_dma_mask      = ~0,
+               .init_name              = "dev:mmc0",
+               .platform_data          = &lpc32xx_plat_data,
+       },
+       .res                            = {
+               .start                  = LPC32XX_SD_BASE,
+               .end                    = (LPC32XX_SD_BASE + SZ_4K - 1),
+               .flags                  = IORESOURCE_MEM,
+       },
+       .dma_mask                       = ~0,
+       .irq                            = {IRQ_LPC32XX_SD0, IRQ_LPC32XX_SD1},
+};
+#endif
+
 /* AMBA based devices list */
 static struct amba_device *amba_devs[] __initdata = {
        &lpc32xx_ssp0_device,
 #if defined (CONFIG_FB_ARMCLCD)
        &lpc32xx_clcd_device,
 #endif
+#if defined (CONFIG_MMC_ARMMMCI)
+       &lpc32xx_mmc_device,
+#endif
 };
 
 /*
@@ -739,12 +864,12 @@ static struct platform_device lpc32xx_net_device = {
 /*
  * I2C devices support
  */
-#if defined (CONFIG_SENSORS_PCA9532) || defined (CONFIG_AT24)
+#if defined (CONFIG_LEDS_PCA9532) || defined (CONFIG_AT24)
        static struct i2c_board_info __initdata ea3250_i2c_board_info [] = {
-#if defined (CONFIG_SENSORS_PCA9532)
+#if defined (CONFIG_LEDS_PCA9532)
                {
                        I2C_BOARD_INFO("pca9532", I2C_PCA9532_ADDR),
-
+                       .platform_data = &ea3250_leds,
                },
 #endif
 #if defined (CONFIG_AT24)
@@ -786,6 +911,11 @@ void __init ea3250_board_init(void)
        /* Intiliase GPIO */
        lpc32xx_gpio_init();
 
+#if defined (CONFIG_MMC_ARMMMCI)
+       /* Enable SD slot power */
+       mmc_power_enable(1);
+#endif
+
        /* Set SPI CS GPIO to output */
        gpio_request(SPI0_CS_GPIO, "spi0 cs");
        gpio_direction_output(SPI0_CS_GPIO, 1);
@@ -862,7 +992,7 @@ void __init ea3250_board_init(void)
                        LPC32XX_CLKPWR_TESTCLK_TESTCLK2_EN,
                        LPC32XX_CLKPWR_TEST_CLK_SEL);
 
-#if defined (CONFIG_SENSORS_PCA9532) || defined (CONFIG_AT24)
+#if defined (CONFIG_LEDS_PCA9532) || defined (CONFIG_AT24)
        i2c_register_board_info(0, ea3250_i2c_board_info,
                        ARRAY_SIZE(ea3250_i2c_board_info));
 #endif