Lines Matching +full:input +full:- +full:wakeup

1 // SPDX-License-Identifier: GPL-2.0+
10 #include <linux/input.h>
39 int wakeup; member
41 struct input_dev *input; member
48 struct input_dev *input = pdata->input; in imx_imx_snvs_check_for_events() local
51 regmap_read(pdata->snvs, SNVS_HPSR_REG, &state); in imx_imx_snvs_check_for_events()
55 if (state ^ pdata->keystate) { in imx_imx_snvs_check_for_events()
56 pdata->keystate = state; in imx_imx_snvs_check_for_events()
57 input_event(input, EV_KEY, pdata->keycode, state); in imx_imx_snvs_check_for_events()
58 input_sync(input); in imx_imx_snvs_check_for_events()
59 pm_relax(pdata->input->dev.parent); in imx_imx_snvs_check_for_events()
64 mod_timer(&pdata->check_timer, in imx_imx_snvs_check_for_events()
73 struct input_dev *input = pdata->input; in imx_snvs_pwrkey_interrupt() local
76 pm_wakeup_event(input->dev.parent, 0); in imx_snvs_pwrkey_interrupt()
78 regmap_read(pdata->snvs, SNVS_LPSR_REG, &lp_status); in imx_snvs_pwrkey_interrupt()
80 if (pdata->minor_rev == 0) { in imx_snvs_pwrkey_interrupt()
83 * interrupt on button release. To mimic power-key in imx_snvs_pwrkey_interrupt()
86 input_report_key(input, pdata->keycode, 1); in imx_snvs_pwrkey_interrupt()
87 input_sync(input); in imx_snvs_pwrkey_interrupt()
88 input_report_key(input, pdata->keycode, 0); in imx_snvs_pwrkey_interrupt()
89 input_sync(input); in imx_snvs_pwrkey_interrupt()
90 pm_relax(input->dev.parent); in imx_snvs_pwrkey_interrupt()
92 mod_timer(&pdata->check_timer, in imx_snvs_pwrkey_interrupt()
98 regmap_write(pdata->snvs, SNVS_LPSR_REG, SNVS_LPSR_SPO); in imx_snvs_pwrkey_interrupt()
107 del_timer_sync(&pd->check_timer); in imx_snvs_pwrkey_act()
113 struct input_dev *input; in imx_snvs_pwrkey_probe() local
120 np = pdev->dev.of_node; in imx_snvs_pwrkey_probe()
122 return -ENODEV; in imx_snvs_pwrkey_probe()
124 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); in imx_snvs_pwrkey_probe()
126 return -ENOMEM; in imx_snvs_pwrkey_probe()
128 pdata->snvs = syscon_regmap_lookup_by_phandle(np, "regmap"); in imx_snvs_pwrkey_probe()
129 if (IS_ERR(pdata->snvs)) { in imx_snvs_pwrkey_probe()
130 dev_err(&pdev->dev, "Can't get snvs syscon\n"); in imx_snvs_pwrkey_probe()
131 return PTR_ERR(pdata->snvs); in imx_snvs_pwrkey_probe()
134 if (of_property_read_u32(np, "linux,keycode", &pdata->keycode)) { in imx_snvs_pwrkey_probe()
135 pdata->keycode = KEY_POWER; in imx_snvs_pwrkey_probe()
136 dev_warn(&pdev->dev, "KEY_POWER without setting in dts\n"); in imx_snvs_pwrkey_probe()
139 clk = devm_clk_get_optional_enabled(&pdev->dev, NULL); in imx_snvs_pwrkey_probe()
141 dev_err(&pdev->dev, "Failed to get snvs clock (%pe)\n", clk); in imx_snvs_pwrkey_probe()
145 pdata->wakeup = of_property_read_bool(np, "wakeup-source"); in imx_snvs_pwrkey_probe()
147 pdata->irq = platform_get_irq(pdev, 0); in imx_snvs_pwrkey_probe()
148 if (pdata->irq < 0) in imx_snvs_pwrkey_probe()
149 return -EINVAL; in imx_snvs_pwrkey_probe()
151 regmap_read(pdata->snvs, SNVS_HPVIDR1_REG, &vid); in imx_snvs_pwrkey_probe()
152 pdata->minor_rev = vid & 0xff; in imx_snvs_pwrkey_probe()
154 regmap_update_bits(pdata->snvs, SNVS_LPCR_REG, SNVS_LPCR_DEP_EN, SNVS_LPCR_DEP_EN); in imx_snvs_pwrkey_probe()
157 regmap_write(pdata->snvs, SNVS_LPSR_REG, SNVS_LPSR_SPO); in imx_snvs_pwrkey_probe()
159 timer_setup(&pdata->check_timer, imx_imx_snvs_check_for_events, 0); in imx_snvs_pwrkey_probe()
161 input = devm_input_allocate_device(&pdev->dev); in imx_snvs_pwrkey_probe()
162 if (!input) { in imx_snvs_pwrkey_probe()
163 dev_err(&pdev->dev, "failed to allocate the input device\n"); in imx_snvs_pwrkey_probe()
164 return -ENOMEM; in imx_snvs_pwrkey_probe()
167 input->name = pdev->name; in imx_snvs_pwrkey_probe()
168 input->phys = "snvs-pwrkey/input0"; in imx_snvs_pwrkey_probe()
169 input->id.bustype = BUS_HOST; in imx_snvs_pwrkey_probe()
171 input_set_capability(input, EV_KEY, pdata->keycode); in imx_snvs_pwrkey_probe()
173 /* input customer action to cancel release timer */ in imx_snvs_pwrkey_probe()
174 error = devm_add_action(&pdev->dev, imx_snvs_pwrkey_act, pdata); in imx_snvs_pwrkey_probe()
176 dev_err(&pdev->dev, "failed to register remove action\n"); in imx_snvs_pwrkey_probe()
180 pdata->input = input; in imx_snvs_pwrkey_probe()
183 error = devm_request_irq(&pdev->dev, pdata->irq, in imx_snvs_pwrkey_probe()
185 0, pdev->name, pdev); in imx_snvs_pwrkey_probe()
187 dev_err(&pdev->dev, "interrupt not available.\n"); in imx_snvs_pwrkey_probe()
191 error = input_register_device(input); in imx_snvs_pwrkey_probe()
193 dev_err(&pdev->dev, "failed to register input device\n"); in imx_snvs_pwrkey_probe()
197 device_init_wakeup(&pdev->dev, pdata->wakeup); in imx_snvs_pwrkey_probe()
198 error = dev_pm_set_wake_irq(&pdev->dev, pdata->irq); in imx_snvs_pwrkey_probe()
200 dev_err(&pdev->dev, "irq wake enable failed.\n"); in imx_snvs_pwrkey_probe()
206 { .compatible = "fsl,sec-v4.0-pwrkey" },