Lines Matching +full:input +full:- +full:debounce
1 // SPDX-License-Identifier: GPL-2.0-or-later
21 #include <linux/input.h>
25 #include <linux/input/matrix_keypad.h>
57 struct input_dev *input; member
62 u32 deb_clks; /* Debounce clocks (based on 32KHz clock) */
73 struct input_dev *input = kscandat->input; in lpc32xx_mod_states() local
77 key = readl(LPC32XX_KS_DATA(kscandat->kscan_base, col)); in lpc32xx_mod_states()
78 changed = key ^ kscandat->lastkeystates[col]; in lpc32xx_mod_states()
79 kscandat->lastkeystates[col] = key; in lpc32xx_mod_states()
85 kscandat->row_shift); in lpc32xx_mod_states()
86 keycode = kscandat->keymap[scancode]; in lpc32xx_mod_states()
87 input_event(input, EV_MSC, MSC_SCAN, scancode); in lpc32xx_mod_states()
88 input_report_key(input, keycode, key & (1 << row)); in lpc32xx_mod_states()
98 for (i = 0; i < kscandat->matrix_sz; i++) in lpc32xx_kscan_irq()
101 writel(1, LPC32XX_KS_IRQ(kscandat->kscan_base)); in lpc32xx_kscan_irq()
103 input_sync(kscandat->input); in lpc32xx_kscan_irq()
113 error = clk_prepare_enable(kscandat->clk); in lpc32xx_kscan_open()
117 writel(1, LPC32XX_KS_IRQ(kscandat->kscan_base)); in lpc32xx_kscan_open()
126 writel(1, LPC32XX_KS_IRQ(kscandat->kscan_base)); in lpc32xx_kscan_close()
127 clk_disable_unprepare(kscandat->clk); in lpc32xx_kscan_close()
133 struct device_node *np = dev->of_node; in lpc32xx_parse_dt()
142 return -EINVAL; in lpc32xx_parse_dt()
145 kscandat->matrix_sz = rows; in lpc32xx_parse_dt()
146 kscandat->row_shift = get_count_order(columns); in lpc32xx_parse_dt()
148 of_property_read_u32(np, "nxp,debounce-delay-ms", &kscandat->deb_clks); in lpc32xx_parse_dt()
149 of_property_read_u32(np, "nxp,scan-delay-ms", &kscandat->scan_delay); in lpc32xx_parse_dt()
150 if (!kscandat->deb_clks || !kscandat->scan_delay) { in lpc32xx_parse_dt()
151 dev_err(dev, "debounce or scan delay not specified\n"); in lpc32xx_parse_dt()
152 return -EINVAL; in lpc32xx_parse_dt()
161 struct input_dev *input; in lpc32xx_kscan_probe() local
168 return -EINVAL; in lpc32xx_kscan_probe()
170 kscandat = devm_kzalloc(&pdev->dev, sizeof(*kscandat), in lpc32xx_kscan_probe()
173 return -ENOMEM; in lpc32xx_kscan_probe()
175 error = lpc32xx_parse_dt(&pdev->dev, kscandat); in lpc32xx_kscan_probe()
177 dev_err(&pdev->dev, "failed to parse device tree\n"); in lpc32xx_kscan_probe()
181 keymap_size = sizeof(kscandat->keymap[0]) * in lpc32xx_kscan_probe()
182 (kscandat->matrix_sz << kscandat->row_shift); in lpc32xx_kscan_probe()
183 kscandat->keymap = devm_kzalloc(&pdev->dev, keymap_size, GFP_KERNEL); in lpc32xx_kscan_probe()
184 if (!kscandat->keymap) in lpc32xx_kscan_probe()
185 return -ENOMEM; in lpc32xx_kscan_probe()
187 kscandat->input = input = devm_input_allocate_device(&pdev->dev); in lpc32xx_kscan_probe()
188 if (!input) { in lpc32xx_kscan_probe()
189 dev_err(&pdev->dev, "failed to allocate input device\n"); in lpc32xx_kscan_probe()
190 return -ENOMEM; in lpc32xx_kscan_probe()
193 /* Setup key input */ in lpc32xx_kscan_probe()
194 input->name = pdev->name; in lpc32xx_kscan_probe()
195 input->phys = "lpc32xx/input0"; in lpc32xx_kscan_probe()
196 input->id.vendor = 0x0001; in lpc32xx_kscan_probe()
197 input->id.product = 0x0001; in lpc32xx_kscan_probe()
198 input->id.version = 0x0100; in lpc32xx_kscan_probe()
199 input->open = lpc32xx_kscan_open; in lpc32xx_kscan_probe()
200 input->close = lpc32xx_kscan_close; in lpc32xx_kscan_probe()
201 input->dev.parent = &pdev->dev; in lpc32xx_kscan_probe()
203 input_set_capability(input, EV_MSC, MSC_SCAN); in lpc32xx_kscan_probe()
206 kscandat->matrix_sz, in lpc32xx_kscan_probe()
207 kscandat->matrix_sz, in lpc32xx_kscan_probe()
208 kscandat->keymap, kscandat->input); in lpc32xx_kscan_probe()
210 dev_err(&pdev->dev, "failed to build keymap\n"); in lpc32xx_kscan_probe()
214 input_set_drvdata(kscandat->input, kscandat); in lpc32xx_kscan_probe()
216 kscandat->kscan_base = devm_platform_ioremap_resource(pdev, 0); in lpc32xx_kscan_probe()
217 if (IS_ERR(kscandat->kscan_base)) in lpc32xx_kscan_probe()
218 return PTR_ERR(kscandat->kscan_base); in lpc32xx_kscan_probe()
221 kscandat->clk = devm_clk_get(&pdev->dev, NULL); in lpc32xx_kscan_probe()
222 if (IS_ERR(kscandat->clk)) { in lpc32xx_kscan_probe()
223 dev_err(&pdev->dev, "failed to get clock\n"); in lpc32xx_kscan_probe()
224 return PTR_ERR(kscandat->clk); in lpc32xx_kscan_probe()
228 error = clk_prepare_enable(kscandat->clk); in lpc32xx_kscan_probe()
232 writel(kscandat->deb_clks, LPC32XX_KS_DEB(kscandat->kscan_base)); in lpc32xx_kscan_probe()
233 writel(kscandat->scan_delay, LPC32XX_KS_SCAN_CTL(kscandat->kscan_base)); in lpc32xx_kscan_probe()
235 LPC32XX_KS_FAST_TST(kscandat->kscan_base)); in lpc32xx_kscan_probe()
236 writel(kscandat->matrix_sz, in lpc32xx_kscan_probe()
237 LPC32XX_KS_MATRIX_DIM(kscandat->kscan_base)); in lpc32xx_kscan_probe()
238 writel(1, LPC32XX_KS_IRQ(kscandat->kscan_base)); in lpc32xx_kscan_probe()
239 clk_disable_unprepare(kscandat->clk); in lpc32xx_kscan_probe()
241 error = devm_request_irq(&pdev->dev, irq, lpc32xx_kscan_irq, 0, in lpc32xx_kscan_probe()
242 pdev->name, kscandat); in lpc32xx_kscan_probe()
244 dev_err(&pdev->dev, "failed to request irq\n"); in lpc32xx_kscan_probe()
248 error = input_register_device(kscandat->input); in lpc32xx_kscan_probe()
250 dev_err(&pdev->dev, "failed to register input device\n"); in lpc32xx_kscan_probe()
263 struct input_dev *input = kscandat->input; in lpc32xx_kscan_suspend() local
265 mutex_lock(&input->mutex); in lpc32xx_kscan_suspend()
267 if (input_device_enabled(input)) { in lpc32xx_kscan_suspend()
269 writel(1, LPC32XX_KS_IRQ(kscandat->kscan_base)); in lpc32xx_kscan_suspend()
270 clk_disable_unprepare(kscandat->clk); in lpc32xx_kscan_suspend()
273 mutex_unlock(&input->mutex); in lpc32xx_kscan_suspend()
281 struct input_dev *input = kscandat->input; in lpc32xx_kscan_resume() local
284 mutex_lock(&input->mutex); in lpc32xx_kscan_resume()
286 if (input_device_enabled(input)) { in lpc32xx_kscan_resume()
288 retval = clk_prepare_enable(kscandat->clk); in lpc32xx_kscan_resume()
290 writel(1, LPC32XX_KS_IRQ(kscandat->kscan_base)); in lpc32xx_kscan_resume()
293 mutex_unlock(&input->mutex); in lpc32xx_kscan_resume()
301 { .compatible = "nxp,lpc3220-key" },