#include "board-loki.h"
#include "devices.h"
#include "iomap.h"
-#ifdef CONFIG_ARCH_TEGRA_11x_SOC
-#include "wakeups-t11x.h"
-#else
#include "wakeups-t12x.h"
-#endif
#define GPIO_KEY(_id, _gpio, _iswake) \
#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),
+ [0] = GPIO_KEY(KEY_POWER, PQ0, 1),
+ [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,
+ },
+ [2] = {
+ .code = KEY_WAKEUP,
+ .gpio = TEGRA_GPIO_PS6,
+ .irq = -1,
+ .type = EV_KEY,
+ .desc = "Gamepad",
+ .active_low = 1,
+ .wakeup = 1,
+ .debounce_interval = 0,
+ },
};
static struct gpio_keys_platform_data loki_int_keys_pdata = {
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_GPIO_PQ0)
+ wakeup_key = KEY_POWER;
+ else if (status & (1UL << TEGRA_WAKE_GPIO_PS0))
+ wakeup_key = SW_LID;
+ else if (status & (1UL << TEGRA_WAKE_GPIO_PS6))
+ wakeup_key = KEY_WAKEUP;
+ else
+ wakeup_key = -1;
+
+ return wakeup_key;
}
int __init loki_kbc_init(void)
pr_info("Boardid:SKU = 0x%04x:0x%04x\n",
board_info.board_id, board_info.sku);
- loki_int_keys[0].gpio = TEGRA_GPIO_PQ0;
- loki_int_keys[0].active_low = 1;
-
ret = platform_device_register(&loki_int_keys_device);
return ret;
}