diff options
author | Philippe Langlais <philippe.langlais@stericsson.com> | 2012-01-20 14:39:30 +0100 |
---|---|---|
committer | Philippe Langlais <philippe.langlais@stericsson.com> | 2012-05-22 11:02:28 +0200 |
commit | e99a0f9cc185e5907a50e742aa8bcbe1ff4884ae (patch) | |
tree | ee429629f1a19ec582b2d4280fd911e6c3e83cff /arch/arm/mach-ux500/board-mop500.c | |
parent | 89a1e6c32b9eeb57a6b442a5dff5085b26e7fa8c (diff) |
ARM: ux500: sensors: Update with gpio handling
Update the gpio-keyboard use of hal and proximity sensors to
use the ux500 pin framework.
ST-Ericsson Linux next: -
ST-Ericsson ID: -
ST-Ericsson FOSS-OUT ID: Trivial
Change-Id: I409d9734c3995d6cfdfff8c7196624a4f89b3e2d
Signed-off-by: Jonas Aaberg <jonas.aberg@stericsson.com>
Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/32694
Diffstat (limited to 'arch/arm/mach-ux500/board-mop500.c')
-rw-r--r-- | arch/arm/mach-ux500/board-mop500.c | 75 |
1 files changed, 57 insertions, 18 deletions
diff --git a/arch/arm/mach-ux500/board-mop500.c b/arch/arm/mach-ux500/board-mop500.c index 3db1b2c1a92..4883910b61f 100644 --- a/arch/arm/mach-ux500/board-mop500.c +++ b/arch/arm/mach-ux500/board-mop500.c @@ -674,6 +674,7 @@ static void __init mop500_i2c_init(struct device *parent) db8500_add_i2c3(parent, &u8500_i2c3_data); } +#ifdef CONFIG_UX500_GPIO_KEYS static struct gpio_keys_button mop500_gpio_keys[] = { { .desc = "SFH7741 Proximity Sensor", @@ -692,6 +693,7 @@ static struct gpio_keys_button mop500_gpio_keys[] = { }; static struct regulator *sensors1p_regulator; +struct ux500_pins *sensors1p_pins; static int mop500_sensors1p_activate(struct device *dev); static void mop500_sensors1p_deactivate(struct device *dev); @@ -710,6 +712,56 @@ static struct platform_device mop500_gpio_keys_device = { }, }; +static int mop500_sensors1p_activate(struct device *dev) +{ + if (sensors1p_pins == NULL) + return -EINVAL; + + ux500_pins_enable(sensors1p_pins); + + sensors1p_regulator = regulator_get(&mop500_gpio_keys_device.dev, + "vcc"); + if (IS_ERR(sensors1p_regulator)) { + dev_err(&mop500_gpio_keys_device.dev, "no regulator\n"); + return PTR_ERR(sensors1p_regulator); + } + regulator_enable(sensors1p_regulator); + + /* + * Please be aware that the start-up time of the SFH7741 is + * 120 ms and during that time the output is undefined. + */ + + return 0; +} + +static void mop500_sensors1p_deactivate(struct device *dev) +{ + if (!IS_ERR(sensors1p_regulator)) { + regulator_disable(sensors1p_regulator); + regulator_put(sensors1p_regulator); + } + + if (sensors1p_pins != NULL) + ux500_pins_disable(sensors1p_pins); +} + +static __init void mop500_sensors1p_init(void) +{ + sensors1p_pins = ux500_pins_get("gpio-keys.0"); + + if (sensors1p_pins == NULL) { + pr_err("sensors1p: Fail to get keys\n"); + return; + } + + mop500_gpio_keys[0].gpio = PIN_NUM(sensors1p_pins->cfg[0]); + mop500_gpio_keys[1].gpio = PIN_NUM(sensors1p_pins->cfg[1]); +} +#else +static inline void mop500_sensors1p_init(void) { } +#endif + #ifdef CONFIG_REGULATOR_FIXED_VOLTAGE static struct platform_device snowball_gpio_wlan_vbat_regulator_device = { .name = "reg-fixed-voltage", @@ -728,24 +780,6 @@ static struct platform_device snowball_gpio_en_3v3_regulator_device = { }; #endif -static int mop500_sensors1p_activate(struct device *dev) -{ - sensors1p_regulator = regulator_get(&mop500_gpio_keys_device.dev, - "vcc"); - if (IS_ERR(sensors1p_regulator)) { - dev_err(&mop500_gpio_keys_device.dev, "no regulator\n"); - return PTR_ERR(sensors1p_regulator); - } - regulator_enable(sensors1p_regulator); - return 0; -} - -static void mop500_sensors1p_deactivate(struct device *dev) -{ - regulator_disable(sensors1p_regulator); - regulator_put(sensors1p_regulator); -} - #ifdef CONFIG_LEDS_PWM static struct led_pwm pwm_leds_data[] = { [0] = { @@ -977,7 +1011,9 @@ static struct platform_device *mop500_platform_devs[] __initdata = { #ifdef CONFIG_STE_TRACE_MODEM &u8500_trace_modem, #endif +#ifdef CONFIG_UX500_GPIO_KEYS &mop500_gpio_keys_device, +#endif #ifdef CONFIG_LEDS_PWM &ux500_leds_device, #endif @@ -1268,6 +1304,7 @@ static void __init mop500_init_machine(void) sizeof(mop500_ske_keypad_data)); #endif + mop500_sensors1p_init(); platform_device_register(&ab8500_device); i2c_register_board_info(0, mop500_i2c0_devices, @@ -1353,6 +1390,8 @@ static void __init hrefv60_init_machine(void) ARRAY_SIZE(u8500_hsi_devices)); #endif + mop500_sensors1p_init(); + for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++) mop500_platform_devs[i]->dev.parent = parent; |