From 28fadd1a74188da5b3f98a7568298c74e916037d Mon Sep 17 00:00:00 2001 From: Jonas Aaberg Date: Tue, 14 Feb 2012 07:47:00 +0100 Subject: 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 --- arch/arm/configs/u8500_defconfig | 1 + arch/arm/mach-ux500/Kconfig | 6 +++++ arch/arm/mach-ux500/board-mop500-pins.c | 42 ++++++++++++++++++++++++--------- arch/arm/mach-ux500/board-mop500.c | 42 +++++++++++++++++++++++++++++++-- 4 files changed, 78 insertions(+), 13 deletions(-) diff --git a/arch/arm/configs/u8500_defconfig b/arch/arm/configs/u8500_defconfig index cfda7a86307..16fc7d572a4 100755 --- a/arch/arm/configs/u8500_defconfig +++ b/arch/arm/configs/u8500_defconfig @@ -30,6 +30,7 @@ CONFIG_DISPLAY_GENERIC_DSI_PRIMARY_VSYNC=y CONFIG_DISPLAY_SONY_ACX424AKP_DSI_PRIMARY=y CONFIG_DISPLAY_AV8100_TERTIARY=y CONFIG_DISPLAY_AV8100_TRIPPLE_BUFFER=y +CONFIG_UX500_GPIO_KEYS=y CONFIG_UX500_SUSPEND=y CONFIG_UX500_SUSPEND_STANDBY=y CONFIG_UX500_SUSPEND_MEM=y diff --git a/arch/arm/mach-ux500/Kconfig b/arch/arm/mach-ux500/Kconfig index 92a85c202e6..626154fc2e3 100644 --- a/arch/arm/mach-ux500/Kconfig +++ b/arch/arm/mach-ux500/Kconfig @@ -80,6 +80,12 @@ config UX500_DEBUG_UART Choose the UART on which kernel low-level debug messages should be output. +config UX500_GPIO_KEYS + bool "Use gpio-keys for proximity and hal sensors" + depends on KEYBOARD_GPIO + help + Add proximity and hal sensors as a gpio keyboard. + config SENSORS1P_MOP tristate "HAL and Proximity sensors support" depends on REGULATOR && (GPIO_STMPE2401 || GPIO_TC35892) diff --git a/arch/arm/mach-ux500/board-mop500-pins.c b/arch/arm/mach-ux500/board-mop500-pins.c index da171115533..02b804d91ee 100644 --- a/arch/arm/mach-ux500/board-mop500-pins.c +++ b/arch/arm/mach-ux500/board-mop500-pins.c @@ -17,7 +17,7 @@ #include "pins-db8500.h" #include "pins.h" - +#include "board-mop500.h" #include "board-pins-sleep-force.h" enum custom_pin_cfg_t { @@ -160,9 +160,6 @@ static pin_cfg_t hrefv60_pins[] = { /* DiPro Sensor Interface */ GPIO139_GPIO | PIN_INPUT_PULLUP, /* DIPRO_INT */ - /* HAL SWITCH INTERFACE */ - GPIO145_GPIO | PIN_INPUT_PULLDOWN,/* HAL_SW */ - /* Audio Amplifier Interface */ GPIO149_GPIO | PIN_OUTPUT_HIGH, /* VAUDIO_HF_EN, enable MAX8968 */ @@ -176,9 +173,6 @@ static pin_cfg_t hrefv60_pins[] = { GPIO82_GPIO | PIN_INPUT_PULLUP, /* ACC_INT1 */ GPIO83_GPIO | PIN_INPUT_PULLUP, /* ACC_INT2 */ - /* Proximity Sensor */ - GPIO217_GPIO | PIN_INPUT_PULLUP, - /* SD card detect */ GPIO95_GPIO | PIN_INPUT_PULLUP, }; @@ -411,7 +405,19 @@ static UX500_PINS(mop500_pins_spi2, GPIO217_SPI2_CLK | PIN_OUTPUT_LOW, ); -static struct ux500_pin_lookup mop500_pins[] = { +static UX500_PINS(mop500_pins_sensors1p, + GPIO217_GPIO| PIN_INPUT_PULLUP | + PIN_SLPM_GPIO | PIN_SLPM_INPUT_NOPULL, + GPIO145_GPIO | PIN_INPUT_PULLDOWN | + PIN_SLPM_GPIO | PIN_SLPM_INPUT_NOPULL, +); + +static UX500_PINS(mop500_pins_sensors1p_old, + PIN_CFG_INPUT(GPIO_PROX_SENSOR, GPIO, NOPULL), + PIN_CFG_INPUT(GPIO_HAL_SENSOR, GPIO, NOPULL), +); + +static struct ux500_pin_lookup mop500_runtime_pins[] = { PIN_LOOKUP("mcde-dpi", &mop500_pins_mcde_dpi), PIN_LOOKUP("mcde-tvout", &mop500_pins_mcde_tvout), PIN_LOOKUP("av8100-hdmi", &mop500_pins_mcde_hdmi), @@ -427,6 +433,14 @@ static struct ux500_pin_lookup mop500_pins[] = { PIN_LOOKUP("spi2", &mop500_pins_spi2), }; +static struct ux500_pin_lookup mop500_runtime_pins_v60[] = { + PIN_LOOKUP("gpio-keys.0", &mop500_pins_sensors1p), +}; + +static struct ux500_pin_lookup mop500_runtime_pins_old[] = { + PIN_LOOKUP("gpio-keys.0", &mop500_pins_sensors1p_old), +}; + static struct ux500_pin_lookup mop500_ske_pins[] = { PIN_LOOKUP("ske", &mop500_pins_ske), }; @@ -641,7 +655,9 @@ static pin_cfg_t mop500_pins_common_power_save_bank4[] = { GPIO143_GPIO | PIN_SLPM_OUTPUT_LOW | PIN_SLPM_WAKEUP_ENABLE | PIN_SLPM_PDIS_DISABLED, GPIO144_GPIO | PIN_SLPM_OUTPUT_HIGH | PIN_SLPM_WAKEUP_ENABLE | PIN_SLPM_PDIS_DISABLED, + /* 145 - HAL sensor (on v60 and later) */ GPIO145_GPIO | PIN_SLPM_DIR_INPUT | PIN_SLPM_WAKEUP_ENABLE | PIN_SLPM_PDIS_DISABLED, + GPIO146_GPIO | PIN_SLPM_OUTPUT_LOW | PIN_SLPM_WAKEUP_ENABLE | PIN_SLPM_PDIS_DISABLED, GPIO147_GPIO | PIN_SLPM_DIR_INPUT | PIN_SLPM_WAKEUP_ENABLE | PIN_SLPM_PDIS_DISABLED, @@ -769,7 +785,9 @@ static pin_cfg_t mop500_pins_common_power_save_bank6_href60[] = { GPIO215_GPIO | PIN_SLPM_OUTPUT_LOW | PIN_SLPM_WAKEUP_ENABLE | PIN_SLPM_PDIS_DISABLED, GPIO216_GPIO | PIN_SLPM_DIR_INPUT | PIN_SLPM_WAKEUP_ENABLE | PIN_SLPM_PDIS_DISABLED, + /* 217 - Proximity */ GPIO217_GPIO | PIN_SLPM_WAKEUP_ENABLE | PIN_SLPM_PDIS_DISABLED, + GPIO218_GPIO | PIN_SLPM_DIR_INPUT | PIN_SLPM_WAKEUP_ENABLE | PIN_SLPM_PDIS_DISABLED, GPIO219_GPIO | PIN_SLPM_OUTPUT_LOW | PIN_SLPM_WAKEUP_ENABLE | PIN_SLPM_PDIS_DISABLED, @@ -932,8 +950,9 @@ void __init mop500_pins_init(void) nmk_config_pins(mop500_pins_common, ARRAY_SIZE(mop500_pins_common)); - ux500_pins_add(mop500_pins, ARRAY_SIZE(mop500_pins)); + ux500_pins_add(mop500_runtime_pins, ARRAY_SIZE(mop500_runtime_pins)); ux500_pins_add(mop500_ske_pins, ARRAY_SIZE(mop500_ske_pins)); + ux500_pins_add(mop500_runtime_pins_old, ARRAY_SIZE(mop500_runtime_pins_old)); switch (pinsfor) { case PINS_FOR_U9500: @@ -958,7 +977,7 @@ void __init snowball_pins_init(void) nmk_config_pins(mop500_pins_common, ARRAY_SIZE(mop500_pins_common)); - ux500_pins_add(mop500_pins, ARRAY_SIZE(mop500_pins)); + ux500_pins_add(mop500_runtime_pins, ARRAY_SIZE(mop500_runtime_pins)); nmk_config_pins(u8500_pins, ARRAY_SIZE(u8500_pins)); @@ -974,8 +993,9 @@ void __init hrefv60_pins_init(void) nmk_config_pins(mop500_pins_common, ARRAY_SIZE(mop500_pins_common)); - ux500_pins_add(mop500_pins, ARRAY_SIZE(mop500_pins)); + ux500_pins_add(mop500_runtime_pins, ARRAY_SIZE(mop500_runtime_pins)); ux500_pins_add(mop500_ske_pins, ARRAY_SIZE(mop500_ske_pins)); + ux500_pins_add(mop500_runtime_pins_v60, ARRAY_SIZE(mop500_runtime_pins_v60)); nmk_config_pins(hrefv60_pins, ARRAY_SIZE(hrefv60_pins)); 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)); -- cgit v1.2.3