diff options
Diffstat (limited to 'arch/arm/mach-ux500/board-mop500.c')
-rw-r--r-- | arch/arm/mach-ux500/board-mop500.c | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/arch/arm/mach-ux500/board-mop500.c b/arch/arm/mach-ux500/board-mop500.c index ca1677e8b3e..09fe8fcf4be 100644 --- a/arch/arm/mach-ux500/board-mop500.c +++ b/arch/arm/mach-ux500/board-mop500.c @@ -654,6 +654,7 @@ static void __init mop500_i2c_init(void) db8500_add_i2c3(&u8500_i2c3_data); } +#ifdef CONFIG_UX500_GPIO_KEYS static struct gpio_keys_button mop500_gpio_keys[] = { { .desc = "SFH7741 Proximity Sensor", @@ -672,6 +673,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,11 @@ static struct platform_device snowball_gpio_en_3v3_regulator_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)) { @@ -717,15 +724,42 @@ static int mop500_sensors1p_activate(struct device *dev) 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) { - regulator_disable(sensors1p_regulator); - regulator_put(sensors1p_regulator); + 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_LEDS_PWM static struct led_pwm pwm_leds_data[] = { [0] = { @@ -957,7 +991,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 @@ -1223,6 +1259,7 @@ static void __init mop500_init_machine(void) ARRAY_SIZE(u8500_hsi_devices)); #endif + mop500_sensors1p_init(); platform_add_devices(mop500_platform_devs, ARRAY_SIZE(mop500_platform_devs)); @@ -1317,6 +1354,7 @@ static void __init hrefv60_init_machine(void) ARRAY_SIZE(u8500_hsi_devices)); #endif + mop500_sensors1p_init(); platform_add_devices(mop500_platform_devs, ARRAY_SIZE(mop500_platform_devs)); |