Blackfin: bf537-stamp: add example ADAU1361 resources
[safe/jmp/linux-2.6] / arch / blackfin / mach-bf537 / boards / stamp.c
index 80b3b57..8a138f0 100644 (file)
 #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
+#include <linux/regulator/consumer.h>
+#include <linux/regulator/userspace-consumer.h>
 
 /*
  * Name the Board for the /proc/cpuinfo
@@ -528,8 +536,8 @@ static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
 };
 #endif
 
-#if defined(CONFIG_SND_BF5XX_SOC_AD1938) \
-       || defined(CONFIG_SND_BF5XX_SOC_AD1938_MODULE)
+#if defined(CONFIG_SND_BF5XX_SOC_AD193X) \
+       || defined(CONFIG_SND_BF5XX_SOC_AD193X_MODULE)
 static struct bfin5xx_spi_chip ad1938_spi_chip_info = {
        .enable_dma = 0,
        .bits_per_word = 8,
@@ -648,6 +656,13 @@ static struct ad714x_platform_data ad7142_i2c_platform_data = {
 };
 #endif
 
+#if defined(CONFIG_AD2S90) || defined(CONFIG_AD2S90_MODULE)
+static struct bfin5xx_spi_chip ad2s90_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
 
@@ -825,6 +840,29 @@ static inline void adf702x_mac_init(void)
 static inline void adf702x_mac_init(void) {}
 #endif
 
+#if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
+#include <linux/spi/ads7846.h>
+static struct bfin5xx_spi_chip ad7873_spi_chip_info = {
+       .bits_per_word  = 8,
+};
+
+static int ads7873_get_pendown_state(void)
+{
+       return gpio_get_value(GPIO_PF6);
+}
+
+static struct ads7846_platform_data __initdata ad7873_pdata = {
+       .model          = 7873,         /* AD7873 */
+       .x_max          = 0xfff,
+       .y_max          = 0xfff,
+       .x_plate_ohms   = 620,
+       .debounce_max   = 1,
+       .debounce_rep   = 0,
+       .debounce_tol   = (~0),
+       .get_pendown_state = ads7873_get_pendown_state,
+};
+#endif
+
 #if defined(CONFIG_MTD_DATAFLASH) \
        || defined(CONFIG_MTD_DATAFLASH_MODULE)
 
@@ -915,9 +953,9 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
        },
 #endif
 
-#if defined(CONFIG_SND_BF5XX_SOC_AD1938) || defined(CONFIG_SND_BF5XX_SOC_AD1938_MODULE)
+#if defined(CONFIG_SND_BF5XX_SOC_AD193X) || defined(CONFIG_SND_BF5XX_SOC_AD193X_MODULE)
        {
-               .modalias = "ad1938",
+               .modalias = "ad193x",
                .max_speed_hz = 3125000,     /* max spi clock (SCK) speed in HZ */
                .bus_num = 0,
                .chip_select = 5,
@@ -939,6 +977,16 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
        },
 #endif
 
+#if defined(CONFIG_AD2S90) || defined(CONFIG_AD2S90_MODULE)
+       {
+               .modalias = "ad2s90",
+               .bus_num = 0,
+               .chip_select = 3,            /* change it for your board */
+               .platform_data = NULL,
+               .controller_data = &ad2s90_spi_chip_info,
+       },
+#endif
+
 #if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
        {
                .modalias = "mmc_spi",
@@ -1026,7 +1074,18 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = {
                .mode = SPI_MODE_0,
        },
 #endif
-
+#if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
+       {
+               .modalias = "ads7846",
+               .max_speed_hz = 2000000,     /* max spi clock (SCK) speed in HZ */
+               .bus_num = 0,
+               .irq = IRQ_PF6,
+               .chip_select = GPIO_PF10 + MAX_CTRL_CS, /* GPIO controlled SSEL */
+               .controller_data = &ad7873_spi_chip_info,
+               .platform_data = &ad7873_pdata,
+               .mode = SPI_MODE_0,
+       },
+#endif
 };
 
 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
@@ -1600,6 +1659,59 @@ static struct adp8870_backlight_platform_data adp8870_pdata = {
 };
 #endif
 
+#if defined(CONFIG_REGULATOR_AD5398) || defined(CONFIG_REGULATOR_AD5398_MODULE)
+static struct regulator_consumer_supply ad5398_consumer = {
+       .supply = "current",
+};
+
+static struct regulator_init_data ad5398_regulator_data = {
+       .constraints = {
+               .name = "current range",
+               .max_uA = 120000,
+               .valid_ops_mask = REGULATOR_CHANGE_CURRENT | REGULATOR_CHANGE_STATUS,
+       },
+       .num_consumer_supplies = 1,
+       .consumer_supplies     = &ad5398_consumer,
+};
+
+static struct ad5398_platform_data ad5398_i2c_platform_data = {
+       .current_bits = 10,
+       .current_offset = 4,
+       .regulator_data = &ad5398_regulator_data,
+};
+
+#if defined(CONFIG_REGULATOR_VIRTUAL_CONSUMER) || \
+       defined(CONFIG_REGULATOR_VIRTUAL_CONSUMER_MODULE)
+static struct platform_device ad5398_virt_consumer_device = {
+       .name = "reg-virt-consumer",
+       .id = 0,
+       .dev = {
+               .platform_data = "current", /* Passed to driver */
+       },
+};
+#endif
+#if defined(CONFIG_REGULATOR_USERSPACE_CONSUMER) || \
+       defined(CONFIG_REGULATOR_USERSPACE_CONSUMER_MODULE)
+static struct regulator_bulk_data ad5398_bulk_data = {
+       .supply = "current",
+};
+
+static struct regulator_userspace_consumer_data ad5398_userspace_comsumer_data = {
+       .name = "ad5398",
+       .num_supplies = 1,
+       .supplies = &ad5398_bulk_data,
+};
+
+static struct platform_device ad5398_userspace_consumer_device = {
+       .name = "reg-userspace-consumer",
+       .id = 0,
+       .dev = {
+               .platform_data = &ad5398_userspace_comsumer_data,
+       },
+};
+#endif
+#endif
+
 static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
 #if defined(CONFIG_INPUT_AD714X_I2C) || defined(CONFIG_INPUT_AD714X_I2C_MODULE)
        {
@@ -1608,6 +1720,26 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
                .platform_data = (void *)&ad7142_i2c_platform_data,
        },
 #endif
+
+#if defined(CONFIG_AD7150) || defined(CONFIG_AD7150_MODULE)
+       {
+               I2C_BOARD_INFO("ad7150", 0x48),
+               .irq = IRQ_PG5, /* fixme: use real interrupt number */
+       },
+#endif
+
+#if defined(CONFIG_AD7152) || defined(CONFIG_AD7152_MODULE)
+       {
+               I2C_BOARD_INFO("ad7152", 0x48),
+       },
+#endif
+
+#if defined(CONFIG_AD774X) || defined(CONFIG_AD774X_MODULE)
+       {
+               I2C_BOARD_INFO("ad774x", 0x48),
+       },
+#endif
+
 #if defined(CONFIG_BFIN_TWI_LCD) || defined(CONFIG_BFIN_TWI_LCD_MODULE)
        {
                I2C_BOARD_INFO("pcf8574_lcd", 0x22),
@@ -1679,6 +1811,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),
@@ -1689,6 +1826,12 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
                I2C_BOARD_INFO("ssm2602", 0x1b),
        },
 #endif
+#if defined(CONFIG_REGULATOR_AD5398) || defined(CONFIG_REGULATOR_AD5398_MODULE)
+       {
+               I2C_BOARD_INFO("ad5398", 0xC),
+               .platform_data = (void *)&ad5398_i2c_platform_data,
+       },
+#endif
 };
 
 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
@@ -1873,6 +2016,93 @@ 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,
+               },
+               .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,
+               },
+               .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,
@@ -1993,6 +2223,25 @@ static struct platform_device *stamp_devices[] __initdata = {
 #if defined(CONFIG_SND_BF5XX_AC97) || defined(CONFIG_SND_BF5XX_AC97_MODULE)
        &bfin_ac97,
 #endif
+#if defined(CONFIG_REGULATOR_AD5398) || defined(CONFIG_REGULATOR_AD5398_MODULE)
+#if defined(CONFIG_REGULATOR_VIRTUAL_CONSUMER) || \
+       defined(CONFIG_REGULATOR_VIRTUAL_CONSUMER_MODULE)
+       &ad5398_virt_consumer_device,
+#endif
+#if defined(CONFIG_REGULATOR_USERSPACE_CONSUMER) || \
+       defined(CONFIG_REGULATOR_USERSPACE_CONSUMER_MODULE)
+       &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)