From f32792d045e1bbd86c0af0a28a46ae87af1ae100 Mon Sep 17 00:00:00 2001 From: Sonic Zhang Date: Tue, 9 Feb 2010 02:47:09 +0000 Subject: [PATCH] Blackfin: bf537-stamp: add example AD5398 power regulator resources Signed-off-by: Sonic Zhang Signed-off-by: Mike Frysinger --- arch/blackfin/mach-bf537/boards/stamp.c | 74 +++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/arch/blackfin/mach-bf537/boards/stamp.c b/arch/blackfin/mach-bf537/boards/stamp.c index 7a1d645bbfbb..845629260290 100644 --- a/arch/blackfin/mach-bf537/boards/stamp.c +++ b/arch/blackfin/mach-bf537/boards/stamp.c @@ -35,6 +35,11 @@ #include #include #include +#ifdef CONFIG_REGULATOR_AD5398 +#include +#endif +#include +#include /* * Name the Board for the /proc/cpuinfo @@ -1634,6 +1639,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) { @@ -1743,6 +1801,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) @@ -2047,6 +2111,16 @@ 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 }; static int __init stamp_init(void)