From 9f6c66e59d2ee3224b45d1489e94f3b0d274204e Mon Sep 17 00:00:00 2001 From: Naga RADHESH Y Date: Tue, 14 Feb 2012 07:47:03 +0100 Subject: mach-ux500:Configure Proximity GPIO based on UIB Move proximity platform data from board-mop500 to board-mop500-uib and configure the GPIO pin depending on UIB ST-Ericsson ID: 374970 ST-Ericsson Linux next: NA ST-Ericsson FOSS-OUT ID: Trivial Change-Id:Ie61cc1f24ec1c80cb2659eacd7bff6f10e9ccbea Signed-off-by: Naga Radhesh --- arch/arm/mach-ux500/board-mop500-pins.c | 2 + arch/arm/mach-ux500/board-mop500-uib.c | 102 +++++++++++++++++++++++++++++++- arch/arm/mach-ux500/board-mop500.c | 87 --------------------------- 3 files changed, 102 insertions(+), 89 deletions(-) diff --git a/arch/arm/mach-ux500/board-mop500-pins.c b/arch/arm/mach-ux500/board-mop500-pins.c index 02b804d91ee..96f7b084c73 100644 --- a/arch/arm/mach-ux500/board-mop500-pins.c +++ b/arch/arm/mach-ux500/board-mop500-pins.c @@ -410,6 +410,8 @@ static UX500_PINS(mop500_pins_sensors1p, PIN_SLPM_GPIO | PIN_SLPM_INPUT_NOPULL, GPIO145_GPIO | PIN_INPUT_PULLDOWN | PIN_SLPM_GPIO | PIN_SLPM_INPUT_NOPULL, + GPIO139_GPIO | PIN_INPUT_PULLUP | + PIN_SLPM_GPIO | PIN_SLPM_INPUT_NOPULL, ); static UX500_PINS(mop500_pins_sensors1p_old, diff --git a/arch/arm/mach-ux500/board-mop500-uib.c b/arch/arm/mach-ux500/board-mop500-uib.c index 8679b15643c..6dc77d42d86 100644 --- a/arch/arm/mach-ux500/board-mop500-uib.c +++ b/arch/arm/mach-ux500/board-mop500-uib.c @@ -11,9 +11,14 @@ #include #include #include -#include #include +#include +#include +#include +#include +#include +#include "pins.h" #include "board-mop500.h" enum mop500_uib { @@ -129,6 +134,97 @@ int uib_is_u8500uibr3(void) return (type_of_uib == U8500UIB_R3); } + +#ifdef CONFIG_UX500_GPIO_KEYS +static struct gpio_keys_button mop500_gpio_keys[] = { + { + .desc = "SFH7741 Proximity Sensor", + .type = EV_SW, + .code = SW_FRONT_PROXIMITY, + .active_low = 0, + .can_disable = 1, + }, + { + .desc = "HED54XXU11 Hall Effect Sensor", + .type = EV_SW, + .code = SW_LID, /* FIXME arbitrary usage */ + .active_low = 0, + .can_disable = 1, + } +}; + +static struct regulator *gpio_keys_regulator; +static int mop500_gpio_keys_activate(struct device *dev); +static void mop500_gpio_keys_deactivate(struct device *dev); + +static struct gpio_keys_platform_data mop500_gpio_keys_data = { + .buttons = mop500_gpio_keys, + .nbuttons = ARRAY_SIZE(mop500_gpio_keys), + .enable = mop500_gpio_keys_activate, + .disable = mop500_gpio_keys_deactivate, +}; + +static struct platform_device mop500_gpio_keys_device = { + .name = "gpio-keys", + .id = 0, + .dev = { + .platform_data = &mop500_gpio_keys_data, + }, +}; + +static int mop500_gpio_keys_activate(struct device *dev) +{ + gpio_keys_regulator = regulator_get(&mop500_gpio_keys_device.dev, + "vcc"); + if (IS_ERR(gpio_keys_regulator)) { + dev_err(&mop500_gpio_keys_device.dev, "no regulator\n"); + return PTR_ERR(gpio_keys_regulator); + } + regulator_enable(gpio_keys_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_gpio_keys_deactivate(struct device *dev) +{ + if (!IS_ERR(gpio_keys_regulator)) { + regulator_disable(gpio_keys_regulator); + regulator_put(gpio_keys_regulator); + } +} + +static __init void mop500_gpio_keys_init(void) +{ + struct ux500_pins *gpio_keys_pins = ux500_pins_get("gpio-keys.0"); + + if (gpio_keys_pins == NULL) { + pr_err("gpio_keys: Fail to get pins\n"); + return; + } + + ux500_pins_enable(gpio_keys_pins); + if (type_of_uib == U8500UIB_R3) + mop500_gpio_keys[0].gpio = PIN_NUM(gpio_keys_pins->cfg[2]); + else + mop500_gpio_keys[0].gpio = PIN_NUM(gpio_keys_pins->cfg[0]); + mop500_gpio_keys[1].gpio = PIN_NUM(gpio_keys_pins->cfg[1]); +} +#else +static inline void mop500_gpio_keys_init(void) { } +#endif + +/* add any platform devices here - TODO */ +static struct platform_device *mop500_uib_platform_devs[] __initdata = { +#ifdef CONFIG_UX500_GPIO_KEYS + &mop500_gpio_keys_device, +#endif +}; + /* * Detect the UIB attached based on the presence or absence of i2c devices. */ @@ -177,7 +273,9 @@ static int __init mop500_uib_init(void) uib = &mop500_uibs[STUIB]; } __mop500_uib_init(uib, "detected"); - + mop500_gpio_keys_init(); + platform_add_devices(mop500_uib_platform_devs, + ARRAY_SIZE(mop500_uib_platform_devs)); return 0; } diff --git a/arch/arm/mach-ux500/board-mop500.c b/arch/arm/mach-ux500/board-mop500.c index 8df987925da..1200db26f75 100644 --- a/arch/arm/mach-ux500/board-mop500.c +++ b/arch/arm/mach-ux500/board-mop500.c @@ -653,43 +653,6 @@ 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", - .type = EV_SW, - .code = SW_FRONT_PROXIMITY, - .active_low = 0, - .can_disable = 1, - }, - { - .desc = "HED54XXU11 Hall Effect Sensor", - .type = EV_SW, - .code = SW_LID, /* FIXME arbitrary usage */ - .active_low = 0, - .can_disable = 1, - } -}; - -static struct regulator *gpio_keys_regulator; -static int mop500_gpio_keys_activate(struct device *dev); -static void mop500_gpio_keys_deactivate(struct device *dev); - -static struct gpio_keys_platform_data mop500_gpio_keys_data = { - .buttons = mop500_gpio_keys, - .nbuttons = ARRAY_SIZE(mop500_gpio_keys), - .enable = mop500_gpio_keys_activate, - .disable = mop500_gpio_keys_deactivate, -}; - -static struct platform_device mop500_gpio_keys_device = { - .name = "gpio-keys", - .id = 0, - .dev = { - .platform_data = &mop500_gpio_keys_data, - }, -}; - #ifdef CONFIG_REGULATOR_FIXED_VOLTAGE static struct platform_device snowball_gpio_wlan_vbat_regulator_device = { .name = "reg-fixed-voltage", @@ -708,51 +671,6 @@ static struct platform_device snowball_gpio_en_3v3_regulator_device = { }; #endif -static int mop500_gpio_keys_activate(struct device *dev) -{ - gpio_keys_regulator = regulator_get(&mop500_gpio_keys_device.dev, - "vcc"); - if (IS_ERR(gpio_keys_regulator)) { - dev_err(&mop500_gpio_keys_device.dev, "no regulator\n"); - return PTR_ERR(gpio_keys_regulator); - } - regulator_enable(gpio_keys_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_gpio_keys_deactivate(struct device *dev) -{ - if (!IS_ERR(gpio_keys_regulator)) { - regulator_disable(gpio_keys_regulator); - regulator_put(gpio_keys_regulator); - } -} - -static __init void mop500_gpio_keys_init(void) -{ - struct ux500_pins *gpio_keys_pins = ux500_pins_get("gpio-keys.0"); - - if (gpio_keys_pins == NULL) { - pr_err("gpio_keys: Fail to get pins\n"); - return; - } - - ux500_pins_enable(gpio_keys_pins); - - mop500_gpio_keys[0].gpio = PIN_NUM(gpio_keys_pins->cfg[0]); - mop500_gpio_keys[1].gpio = PIN_NUM(gpio_keys_pins->cfg[1]); - -} -#else -static inline void mop500_gpio_keys_init(void) { } -#endif - #ifdef CONFIG_LEDS_PWM static struct led_pwm pwm_leds_data[] = { [0] = { @@ -957,9 +875,6 @@ 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 @@ -1222,7 +1137,6 @@ static void __init mop500_init_machine(void) ARRAY_SIZE(u8500_hsi_devices)); #endif - mop500_gpio_keys_init(); platform_add_devices(mop500_platform_devs, ARRAY_SIZE(mop500_platform_devs)); @@ -1309,7 +1223,6 @@ static void __init hrefv60_init_machine(void) ARRAY_SIZE(u8500_hsi_devices)); #endif - mop500_gpio_keys_init(); platform_add_devices(mop500_platform_devs, ARRAY_SIZE(mop500_platform_devs)); -- cgit v1.2.3