summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mach-ux500/Kconfig6
-rw-r--r--arch/arm/mach-ux500/board-mop500-pins.c49
-rw-r--r--arch/arm/mach-ux500/board-mop500.c75
3 files changed, 101 insertions, 29 deletions
diff --git a/arch/arm/mach-ux500/Kconfig b/arch/arm/mach-ux500/Kconfig
index 32104365ec6..4569441dd32 100644
--- a/arch/arm/mach-ux500/Kconfig
+++ b/arch/arm/mach-ux500/Kconfig
@@ -100,6 +100,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 c4afb8c0977..5c6b1c5f880 100644
--- a/arch/arm/mach-ux500/board-mop500-pins.c
+++ b/arch/arm/mach-ux500/board-mop500-pins.c
@@ -18,7 +18,7 @@
#include "pins-db8500.h"
#include "pins.h"
-
+#include "board-mop500.h"
#include "board-pins-sleep-force.h"
enum custom_pin_cfg_t {
@@ -152,9 +152,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 */
@@ -168,9 +165,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,
};
@@ -412,7 +406,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),
@@ -429,6 +435,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
@@ -639,7 +653,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,
@@ -767,7 +783,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,
@@ -989,7 +1007,10 @@ 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_runtime_pins_old,
+ ARRAY_SIZE(mop500_runtime_pins_old));
switch (pinsfor) {
case PINS_FOR_U9500:
@@ -1014,7 +1035,10 @@ 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));
+
+ ux500_pins_add(mop500_runtime_pins_old,
+ ARRAY_SIZE(mop500_runtime_pins_old));
nmk_config_pins(u8500_pins, ARRAY_SIZE(u8500_pins));
@@ -1030,7 +1054,10 @@ 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_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 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;