Blackfin: bf537-stamp: add example AD7416 IIO resources
[safe/jmp/linux-2.6] / arch / blackfin / mach-bf537 / boards / stamp.c
index 4a09ce9..4aec6c0 100644 (file)
@@ -35,6 +35,9 @@
 #include <asm/reboot.h>
 #include <asm/portmux.h>
 #include <asm/dpmc.h>
+#ifdef CONFIG_REGULATOR_ADP_SWITCH
+#include <linux/regulator/adp_switch.h>
+#endif
 #ifdef CONFIG_REGULATOR_AD5398
 #include <linux/regulator/ad5398.h>
 #endif
@@ -525,8 +528,8 @@ static struct bfin5xx_spi_chip spi_adc_chip_info = {
 };
 #endif
 
-#if defined(CONFIG_SND_BF5XX_SOC_AD1836) \
-       || defined(CONFIG_SND_BF5XX_SOC_AD1836_MODULE)
+#if defined(CONFIG_SND_BF5XX_SOC_AD183X) \
+       || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
 static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
        .enable_dma = 0,
        .bits_per_word = 16,
@@ -660,6 +663,18 @@ static struct bfin5xx_spi_chip ad2s90_spi_chip_info = {
 };
 #endif
 
+#if defined(CONFIG_AD2S120X) || defined(CONFIG_AD2S120X_MODULE)
+unsigned short ad2s120x_platform_data[] = {
+       /* used as SAMPLE and RDVEL */
+       GPIO_PF5, GPIO_PF6, 0
+};
+
+static struct bfin5xx_spi_chip ad2s120x_spi_chip_info = {
+       .enable_dma = 0,
+       .bits_per_word = 16,
+};
+#endif
+
 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
 #define MMC_SPI_CARD_DETECT_INT IRQ_PF5
 
@@ -938,13 +953,14 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
        },
 #endif
 
-#if defined(CONFIG_SND_BF5XX_SOC_AD1836) \
-       || defined(CONFIG_SND_BF5XX_SOC_AD1836_MODULE)
+#if defined(CONFIG_SND_BF5XX_SOC_AD183X) \
+       || defined(CONFIG_SND_BF5XX_SOC_AD183X_MODULE)
        {
-               .modalias = "ad1836",
+               .modalias = "ad183x",
                .max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
                .bus_num = 0,
                .chip_select = 4,/* CONFIG_SND_BLACKFIN_SPI_PFBIT */
+               .platform_data = "ad1836", /* only includes chip name for the moment */
                .controller_data = &ad1836_spi_chip_info,
                .mode = SPI_MODE_3,
        },
@@ -984,6 +1000,16 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
        },
 #endif
 
+#if defined(CONFIG_AD2S120X) || defined(CONFIG_AD2S120X_MODULE)
+       {
+               .modalias = "ad2s120x",
+               .bus_num = 0,
+               .chip_select = 4,            /* CS, change it for your board */
+               .platform_data = ad2s120x_platform_data,
+               .controller_data = &ad2s120x_spi_chip_info,
+       },
+#endif
+
 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
        {
                .modalias = "mmc_spi",
@@ -1656,6 +1682,48 @@ static struct adp8870_backlight_platform_data adp8870_pdata = {
 };
 #endif
 
+#if defined(CONFIG_BACKLIGHT_ADP8860) || defined(CONFIG_BACKLIGHT_ADP8860_MODULE)
+#include <linux/i2c/adp8860.h>
+static struct led_info adp8860_leds[] = {
+       {
+               .name = "adp8860-led7",
+               .default_trigger = "none",
+               .flags = ADP8860_LED_D7 | ADP8860_LED_OFFT_600ms,
+       },
+};
+
+static struct adp8860_backlight_platform_data adp8860_pdata = {
+       .bl_led_assign = ADP8860_BL_D1 | ADP8860_BL_D2 | ADP8860_BL_D3 |
+                        ADP8860_BL_D4 | ADP8860_BL_D5 | ADP8860_BL_D6, /* 1 = Backlight 0 = Individual LED */
+
+       .bl_fade_in = ADP8860_FADE_T_1200ms,            /* Backlight Fade-In Timer */
+       .bl_fade_out = ADP8860_FADE_T_1200ms,           /* Backlight Fade-Out Timer */
+       .bl_fade_law = ADP8860_FADE_LAW_CUBIC1,         /* fade-on/fade-off transfer characteristic */
+
+       .en_ambl_sens = 1,                              /* 1 = enable ambient light sensor */
+       .abml_filt = ADP8860_BL_AMBL_FILT_320ms,        /* Light sensor filter time */
+
+       .l1_daylight_max = ADP8860_BL_CUR_mA(20),       /* use BL_CUR_mA(I) 0 <= I <= 30 mA */
+       .l1_daylight_dim = ADP8860_BL_CUR_mA(0),        /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */
+       .l2_office_max = ADP8860_BL_CUR_mA(6),          /* use BL_CUR_mA(I) 0 <= I <= 30 mA */
+       .l2_office_dim = ADP8860_BL_CUR_mA(0),          /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */
+       .l3_dark_max = ADP8860_BL_CUR_mA(2),            /* use BL_CUR_mA(I) 0 <= I <= 30 mA */
+       .l3_dark_dim = ADP8860_BL_CUR_mA(0),            /* typ = 0, use BL_CUR_mA(I) 0 <= I <= 30 mA */
+
+       .l2_trip = ADP8860_L2_COMP_CURR_uA(710),        /* use L2_COMP_CURR_uA(I) 0 <= I <= 1106 uA */
+       .l2_hyst = ADP8860_L2_COMP_CURR_uA(73),         /* use L2_COMP_CURR_uA(I) 0 <= I <= 1106 uA */
+       .l3_trip = ADP8860_L3_COMP_CURR_uA(43),         /* use L3_COMP_CURR_uA(I) 0 <= I <= 138 uA */
+       .l3_hyst = ADP8860_L3_COMP_CURR_uA(11),         /* use L3_COMP_CURR_uA(I) 0 <= I <= 138 uA */
+
+       .leds = adp8860_leds,
+       .num_leds = ARRAY_SIZE(adp8860_leds),
+       .led_fade_law = ADP8860_FADE_LAW_SQUARE,        /* fade-on/fade-off transfer characteristic */
+       .led_fade_in = ADP8860_FADE_T_600ms,
+       .led_fade_out = ADP8860_FADE_T_600ms,
+       .led_on_time = ADP8860_LED_ONT_200ms,
+};
+#endif
+
 #if defined(CONFIG_REGULATOR_AD5398) || defined(CONFIG_REGULATOR_AD5398_MODULE)
 static struct regulator_consumer_supply ad5398_consumer = {
        .supply = "current",
@@ -1737,6 +1805,32 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
        },
 #endif
 
+#if defined(CONFIG_AD7414) || defined(CONFIG_AD7414_MODULE)
+       {
+               I2C_BOARD_INFO("ad7414", 0x9),
+               .irq = IRQ_PG5,
+               /*
+                * platform_data pointer is borrwoed by the driver to
+                * store custimer defined IRQ ALART level mode.
+                * only IRQF_TRIGGER_HIGH and IRQF_TRIGGER_LOW are valid.
+                */
+               .platform_data = (void *)IRQF_TRIGGER_LOW,
+       },
+#endif
+
+#if defined(CONFIG_AD7416) || defined(CONFIG_AD7416_MODULE)
+       {
+               I2C_BOARD_INFO("ad7417", 0xb),
+               .irq = IRQ_PG5,
+               /*
+                * platform_data pointer is borrwoed by the driver to
+                * store custimer defined IRQ ALART level mode.
+                * only IRQF_TRIGGER_HIGH and IRQF_TRIGGER_LOW are valid.
+                */
+               .platform_data = (void *)IRQF_TRIGGER_LOW,
+       },
+#endif
+
 #if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE)
        {
                I2C_BOARD_INFO("pcf8574_lcd", 0x22),
@@ -1808,6 +1902,11 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
                I2C_BOARD_INFO("adau1761", 0x38),
        },
 #endif
+#if defined(CONFIG_SND_SOC_ADAU1361) || defined(CONFIG_SND_SOC_ADAU1361_MODULE)
+       {
+               I2C_BOARD_INFO("adau1361", 0x38),
+       },
+#endif
 #if defined(CONFIG_AD525X_DPOT) || defined(CONFIG_AD525X_DPOT_MODULE)
        {
                I2C_BOARD_INFO("ad5258", 0x18),
@@ -1824,6 +1923,12 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
                .platform_data = (void *)&ad5398_i2c_platform_data,
        },
 #endif
+#if defined(CONFIG_BACKLIGHT_ADP8860) || defined(CONFIG_BACKLIGHT_ADP8860_MODULE)
+       {
+               I2C_BOARD_INFO("adp8860", 0x2A),
+               .platform_data = (void *)&adp8860_pdata,
+       },
+#endif
 };
 
 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
@@ -2008,6 +2113,97 @@ static struct platform_device bfin_ac97 = {
 };
 #endif
 
+#if defined(CONFIG_REGULATOR_ADP_SWITCH) || defined(CONFIG_REGULATOR_ADP_SWITCH_MODULE)
+#define REGULATOR_ADP122        "adp122"
+#define REGULATOR_ADP150        "adp150"
+
+static struct regulator_consumer_supply adp122_consumers = {
+               .supply = REGULATOR_ADP122,
+};
+
+static struct regulator_consumer_supply adp150_consumers = {
+               .supply = REGULATOR_ADP150,
+};
+
+static struct regulator_init_data adp_switch_regulator_data[] = {
+       {
+               .constraints = {
+                       .name = REGULATOR_ADP122,
+                       .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+                       .min_uA = 0,
+                       .max_uA = 300000,
+               },
+               .num_consumer_supplies = 1,     /* only 1 */
+               .consumer_supplies     = &adp122_consumers,
+               .driver_data           = (void *)GPIO_PF2, /* gpio port only */
+       },
+       {
+               .constraints = {
+                       .name = REGULATOR_ADP150,
+                       .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+                       .min_uA = 0,
+                       .max_uA = 150000,
+               },
+               .num_consumer_supplies = 1,     /* only 1 */
+               .consumer_supplies     = &adp150_consumers,
+               .driver_data           = (void *)GPIO_PF3, /* gpio port only */
+       },
+};
+
+static struct adp_switch_platform_data adp_switch_pdata = {
+       .regulator_num = ARRAY_SIZE(adp_switch_regulator_data),
+       .regulator_data = adp_switch_regulator_data,
+};
+
+static struct platform_device adp_switch_device = {
+       .name = "adp_switch",
+       .id = 0,
+       .dev = {
+               .platform_data = &adp_switch_pdata,
+       },
+};
+
+#if defined(CONFIG_REGULATOR_USERSPACE_CONSUMER) || \
+       defined(CONFIG_REGULATOR_USERSPACE_CONSUMER_MODULE)
+static struct regulator_bulk_data adp122_bulk_data = {
+       .supply = REGULATOR_ADP122,
+};
+
+static struct regulator_userspace_consumer_data adp122_userspace_comsumer_data = {
+       .name = REGULATOR_ADP122,
+       .num_supplies = 1,
+       .supplies = &adp122_bulk_data,
+};
+
+static struct platform_device adp122_userspace_consumer_device = {
+       .name = "reg-userspace-consumer",
+       .id = 0,
+       .dev = {
+               .platform_data = &adp122_userspace_comsumer_data,
+       },
+};
+
+static struct regulator_bulk_data adp150_bulk_data = {
+       .supply = REGULATOR_ADP150,
+};
+
+static struct regulator_userspace_consumer_data adp150_userspace_comsumer_data = {
+       .name = REGULATOR_ADP150,
+       .num_supplies = 1,
+       .supplies = &adp150_bulk_data,
+};
+
+static struct platform_device adp150_userspace_consumer_device = {
+       .name = "reg-userspace-consumer",
+       .id = 1,
+       .dev = {
+               .platform_data = &adp150_userspace_comsumer_data,
+       },
+};
+#endif
+#endif
+
+
 static struct platform_device *stamp_devices[] __initdata = {
 
        &bfin_dpmc,
@@ -2138,6 +2334,15 @@ static struct platform_device *stamp_devices[] __initdata = {
        &ad5398_userspace_consumer_device,
 #endif
 #endif
+
+#if defined(CONFIG_REGULATOR_ADP_SWITCH) || defined(CONFIG_REGULATOR_ADP_SWITCH_MODULE)
+       &adp_switch_device,
+#if defined(CONFIG_REGULATOR_USERSPACE_CONSUMER) || \
+       defined(CONFIG_REGULATOR_USERSPACE_CONSUMER_MODULE)
+       &adp122_userspace_consumer_device,
+       &adp150_userspace_consumer_device,
+#endif
+#endif
 };
 
 static int __init stamp_init(void)