Skip to content

Commit fd0fc21

Browse files
Rakesh Iyerdtor
authored andcommitted
Input: tegra-kbc - report wakeup key for some platforms
Tegra kbc cannot detect exact keypress causing wakeup in interrupt mode. Allow wakeup keypress to be reported for certain platforms. Signed-off-by: Rakesh Iyer <riyer@nvidia.com> Acked-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
1 parent a445c7f commit fd0fc21

2 files changed

Lines changed: 25 additions & 3 deletions

File tree

‎arch/arm/mach-tegra/include/mach/kbc.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ struct tegra_kbc_platform_data {
5353
struct tegra_kbc_pin_cfg pin_cfg[KBC_MAX_GPIO];
5454
const struct matrix_keymap_data *keymap_data;
5555

56+
u32 wakeup_key;
5657
bool wakeup;
5758
bool use_fn_map;
5859
bool use_ghost_filter;

‎drivers/input/keyboard/tegra-kbc.c‎

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
/* KBC Interrupt Register */
5454
#define KBC_INT_0 0x4
5555
#define KBC_INT_FIFO_CNT_INT_STATUS (1 << 2)
56+
#define KBC_INT_KEYPRESS_INT_STATUS (1 << 0)
5657

5758
#define KBC_ROW_CFG0_0 0x8
5859
#define KBC_COL_CFG0_0 0x18
@@ -75,10 +76,12 @@ struct tegra_kbc {
7576
unsigned int cp_to_wkup_dly;
7677
bool use_fn_map;
7778
bool use_ghost_filter;
79+
bool keypress_caused_wake;
7880
const struct tegra_kbc_platform_data *pdata;
7981
unsigned short keycode[KBC_MAX_KEY * 2];
8082
unsigned short current_keys[KBC_MAX_KPENT];
8183
unsigned int num_pressed_keys;
84+
u32 wakeup_key;
8285
struct timer_list timer;
8386
struct clk *clk;
8487
};
@@ -411,6 +414,9 @@ static irqreturn_t tegra_kbc_isr(int irq, void *args)
411414
*/
412415
tegra_kbc_set_fifo_interrupt(kbc, false);
413416
mod_timer(&kbc->timer, jiffies + kbc->cp_dly_jiffies);
417+
} else if (val & KBC_INT_KEYPRESS_INT_STATUS) {
418+
/* We can be here only through system resume path */
419+
kbc->keypress_caused_wake = true;
414420
}
415421

416422
spin_unlock_irqrestore(&kbc->lock, flags);
@@ -733,9 +739,10 @@ static int __devinit tegra_kbc_probe(struct platform_device *pdev)
733739
keymap_data = pdata->keymap_data ?: &tegra_kbc_default_keymap_data;
734740
matrix_keypad_build_keymap(keymap_data, KBC_ROW_SHIFT,
735741
input_dev->keycode, input_dev->keybit);
742+
kbc->wakeup_key = pdata->wakeup_key;
736743

737-
err = request_irq(kbc->irq, tegra_kbc_isr, IRQF_TRIGGER_HIGH,
738-
pdev->name, kbc);
744+
err = request_irq(kbc->irq, tegra_kbc_isr,
745+
IRQF_NO_SUSPEND | IRQF_TRIGGER_HIGH, pdev->name, kbc);
739746
if (err) {
740747
dev_err(&pdev->dev, "failed to request keyboard IRQ\n");
741748
goto err_put_clk;
@@ -823,6 +830,8 @@ static int tegra_kbc_suspend(struct device *dev)
823830
tegra_kbc_setup_wakekeys(kbc, true);
824831
msleep(30);
825832

833+
kbc->keypress_caused_wake = false;
834+
enable_irq(kbc->irq);
826835
enable_irq_wake(kbc->irq);
827836
} else {
828837
if (kbc->idev->users)
@@ -849,7 +858,19 @@ static int tegra_kbc_resume(struct device *dev)
849858

850859
tegra_kbc_set_fifo_interrupt(kbc, true);
851860

852-
enable_irq(kbc->irq);
861+
if (kbc->keypress_caused_wake && kbc->wakeup_key) {
862+
/*
863+
* We can't report events directly from the ISR
864+
* because timekeeping is stopped when processing
865+
* wakeup request and we get a nasty warning when
866+
* we try to call do_gettimeofday() in evdev
867+
* handler.
868+
*/
869+
input_report_key(kbc->idev, kbc->wakeup_key, 1);
870+
input_sync(kbc->idev);
871+
input_report_key(kbc->idev, kbc->wakeup_key, 0);
872+
input_sync(kbc->idev);
873+
}
853874
} else {
854875
if (kbc->idev->users)
855876
err = tegra_kbc_start(kbc);

0 commit comments

Comments
 (0)