summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Aaberg <jonas.aberg@stericsson.com>2011-09-30 11:44:22 +0200
committerJonas ABERG <jonas.aberg@stericsson.com>2011-10-21 14:08:10 +0200
commita06873643ca8dc73ce01d40c56b2d4f6fb5bbbef (patch)
tree5c9058a1d10d82b3aa8d830734ae8e7a09ce3dcb
parent495151f0c85179c66a0be43f9ae5dc249e4695a9 (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
-rwxr-xr-xarch/arm/configs/u8500_defconfig1
-rw-r--r--arch/arm/mach-ux500/Kconfig6
-rw-r--r--arch/arm/mach-ux500/board-mop500-pins.c43
-rw-r--r--arch/arm/mach-ux500/board-mop500.c61
4 files changed, 83 insertions, 28 deletions
diff --git a/arch/arm/configs/u8500_defconfig b/arch/arm/configs/u8500_defconfig
index b7756eb92d3..2934c2889f1 100755
--- a/arch/arm/configs/u8500_defconfig
+++ b/arch/arm/configs/u8500_defconfig
@@ -36,6 +36,7 @@ CONFIG_DISPLAY_GENERIC_DSI_PRIMARY_VSYNC=y
CONFIG_DISPLAY_AV8100_TERTIARY=y
CONFIG_DISPLAY_AV8100_TRIPPLE_BUFFER=y
CONFIG_DBX500_PRCMU_QOS_POWER=y
+CONFIG_UX500_GPIO_KEYS=y
CONFIG_DBX500_PRCMU_DEBUG=y
CONFIG_CPU_IDLE=y
CONFIG_UX500_CPUIDLE=y
diff --git a/arch/arm/mach-ux500/Kconfig b/arch/arm/mach-ux500/Kconfig
index 697a4da87ef..0d7401af91a 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 bdf54459959..3598e8ff606 100644
--- a/arch/arm/mach-ux500/board-mop500-pins.c
+++ b/arch/arm/mach-ux500/board-mop500-pins.c
@@ -19,7 +19,7 @@
#include "pins-db8500.h"
#include "pins.h"
-
+#include "board-mop500.h"
#include "board-pins-sleep-force.h"
enum custom_pin_cfg_t {
@@ -153,9 +153,6 @@ static pin_cfg_t mop500_pins_hrefv60[] = {
/* 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 */
@@ -169,9 +166,6 @@ static pin_cfg_t mop500_pins_hrefv60[] = {
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,
};
@@ -413,7 +407,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),
@@ -430,6 +436,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),
+};
+
/*
* Sleep pin configuration for u8500 platform.
* If another HW is used the GPIO's must be configured
@@ -640,7 +654,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,
@@ -768,7 +784,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,
@@ -990,7 +1008,14 @@ 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));
+
+ if (machine_is_hrefv60())
+ ux500_pins_add(mop500_runtime_pins_v60,
+ ARRAY_SIZE(mop500_runtime_pins_v60));
+ else
+ ux500_pins_add(mop500_runtime_pins_old,
+ ARRAY_SIZE(mop500_runtime_pins_old));
if (machine_is_hrefv60())
nmk_config_pins(mop500_pins_hrefv60,
diff --git a/arch/arm/mach-ux500/board-mop500.c b/arch/arm/mach-ux500/board-mop500.c
index 71c3f0e9897..5d512186645 100644
--- a/arch/arm/mach-ux500/board-mop500.c
+++ b/arch/arm/mach-ux500/board-mop500.c
@@ -616,6 +616,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",
@@ -634,6 +635,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);
@@ -654,6 +656,11 @@ 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)) {
@@ -661,14 +668,41 @@ 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[] = {
@@ -897,7 +931,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
@@ -1150,21 +1186,6 @@ static void __init mop500_init_machine(void)
{
int i2c0_devs;
- /*
- * The HREFv60 board removed a GPIO expander and routed
- * all these GPIO pins to the internal GPIO controller
- * instead.
- */
- if (!machine_is_snowball()) {
- if (machine_is_hrefv60()) {
- mop500_gpio_keys[0].gpio = HREFV60_PROX_SENSE_GPIO;
- mop500_gpio_keys[1].gpio = HREFV60_HAL_SW_GPIO;
- } else {
- mop500_gpio_keys[0].gpio = GPIO_PROX_SENSOR;
- mop500_gpio_keys[1].gpio = GPIO_HAL_SENSOR;
- }
- }
-
accessory_detect_config();
u8500_init_devices();
@@ -1178,12 +1199,14 @@ static void __init mop500_init_machine(void)
ARRAY_SIZE(u8500_hsi_devices));
#endif
- if (machine_is_snowball())
+ if (machine_is_snowball()) {
platform_add_devices(snowball_platform_devs,
ARRAY_SIZE(snowball_platform_devs));
- else
+ } else {
+ mop500_sensors1p_init();
platform_add_devices(mop500_platform_devs,
ARRAY_SIZE(mop500_platform_devs));
+ }
mop500_i2c_init();
mop500_sdi_init();