]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
ARM: tegra: loki: Enable Hall Effect Sensor
authorAnkita Garg <ankitag@nvidia.com>
Tue, 10 Sep 2013 00:33:14 +0000 (17:33 -0700)
committerAjay Nandakumar <anandakumarm@nvidia.com>
Tue, 1 Oct 2013 09:52:59 +0000 (15:22 +0530)
Bug 1346464

Change-Id: I5516049a3bccb5a10feab9dcc62b1bc1d7fbb593
Signed-off-by: Ankita Garg <ankitag@nvidia.com>
Reviewed-on: http://git-master/r/272233
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
Tested-by: Laxman Dewangan <ldewangan@nvidia.com>
(cherry picked from commit dc01e43f1ee1f45aa82723fdda078f2b1065ef8c)
Signed-off-by: Ajay Nandakumar <anandakumarm@nvidia.com>
arch/arm/mach-tegra/board-loki-kbc.c
arch/arm/mach-tegra/board-loki-pinmux-t12x.h
arch/arm/mach-tegra/board-loki.h

index 17fbccd84365c34fd61d7597a562016905ae1e5c..bfe2ae4be636ecfad6126f8186c6ff58c23f7699 100644 (file)
 
 #define PMC_WAKE_STATUS         0x14
 #define TEGRA_WAKE_PWR_INT      (1UL << 18)
+#define PMC_WAKE2_STATUS        0x168
 
 static int loki_wakeup_key(void);
 
 static struct gpio_keys_button loki_int_keys[] = {
        [0] = GPIO_IKEY(KEY_POWER, 0, 1, 10),
+       [1] = {
+               .code = SW_LID,
+               .gpio = TEGRA_GPIO_HALL,
+               .irq = -1,
+               .type = EV_SW,
+               .desc = "Hall Effect Sensor",
+               .active_low = 1,
+               .wakeup = 1,
+               .debounce_interval = 0,
+       },
 };
 
 static struct gpio_keys_platform_data loki_int_keys_pdata = {
@@ -83,12 +94,20 @@ static struct platform_device loki_int_keys_device = {
 
 static int loki_wakeup_key(void)
 {
+       int wakeup_key;
        u32 status;
-       status = __raw_readl(IO_ADDRESS(TEGRA_PMC_BASE) + PMC_WAKE_STATUS);
-
-       pr_info("%s: Power key pressed\n", __func__);
-
-       return (status & TEGRA_WAKE_PWR_INT) ? KEY_POWER : KEY_RESERVED;
+       status = readl(IO_ADDRESS(TEGRA_PMC_BASE) + PMC_WAKE_STATUS)
+               | (u64)readl(IO_ADDRESS(TEGRA_PMC_BASE)
+               + PMC_WAKE2_STATUS) << 32;
+
+       if (status & TEGRA_WAKE_PWR_INT)
+               wakeup_key = KEY_POWER;
+       else if (status & (1UL << TEGRA_WAKE_GPIO_PS0))
+               wakeup_key = SW_LID;
+       else
+               wakeup_key = -1;
+
+       return wakeup_key;
 }
 
 int __init loki_kbc_init(void)
index d7539a066383b438c72cc572bbf31bbb178d2fd7..ed16d9951575a86a56b81b887cd0d55957a50076 100644 (file)
@@ -319,7 +319,6 @@ static struct gpio_init_pin_info init_gpio_mode_loki_common[] = {
        GPIO_INIT_PIN_MODE(TEGRA_GPIO_PR5, false, 1),
        GPIO_INIT_PIN_MODE(TEGRA_GPIO_PR6, true, 0),
        GPIO_INIT_PIN_MODE(TEGRA_GPIO_PR7, true, 0),
-       GPIO_INIT_PIN_MODE(TEGRA_GPIO_PS0, true, 0),
        GPIO_INIT_PIN_MODE(TEGRA_GPIO_PEE1, false, 0),
        GPIO_INIT_PIN_MODE(TEGRA_GPIO_PU0, true, 0),
        GPIO_INIT_PIN_MODE(TEGRA_GPIO_PU1, false, 0),
index eaa17a7c77e9855e37a50378c68dd1b71fcd538e..4dcd1360d351c29486133b79e949328d6b5b728b 100644 (file)
@@ -75,6 +75,9 @@ int loki_soctherm_init(void);
 #define MDM_RST                        TEGRA_GPIO_PS3
 #define MDM_COLDBOOT           TEGRA_GPIO_PO5
 
+/* Hall Effect Sensor GPIO */
+#define TEGRA_GPIO_HALL                TEGRA_GPIO_PS0
+
 /* Baseband IDs */
 enum tegra_bb_type {
        TEGRA_BB_BRUCE = 1,