Lines Matching +full:debounce +full:- +full:delay +full:- +full:ms

1 // SPDX-License-Identifier: GPL-2.0-or-later
63 u32 deb_clks; /* Debounce clocks (based on 32KHz clock) */
64 u32 scan_delay; /* Scan delay (based on 32KHz clock) */
74 struct input_dev *input = kscandat->input; in lpc32xx_mod_states()
78 key = readl(LPC32XX_KS_DATA(kscandat->kscan_base, col)); in lpc32xx_mod_states()
79 changed = key ^ kscandat->lastkeystates[col]; in lpc32xx_mod_states()
80 kscandat->lastkeystates[col] = key; in lpc32xx_mod_states()
86 kscandat->row_shift); in lpc32xx_mod_states()
87 keycode = kscandat->keymap[scancode]; in lpc32xx_mod_states()
99 for (i = 0; i < kscandat->matrix_sz; i++) in lpc32xx_kscan_irq()
102 writel(1, LPC32XX_KS_IRQ(kscandat->kscan_base)); in lpc32xx_kscan_irq()
104 input_sync(kscandat->input); in lpc32xx_kscan_irq()
114 error = clk_prepare_enable(kscandat->clk); in lpc32xx_kscan_open()
118 writel(1, LPC32XX_KS_IRQ(kscandat->kscan_base)); in lpc32xx_kscan_open()
127 writel(1, LPC32XX_KS_IRQ(kscandat->kscan_base)); in lpc32xx_kscan_close()
128 clk_disable_unprepare(kscandat->clk); in lpc32xx_kscan_close()
134 struct device_node *np = dev->of_node; in lpc32xx_parse_dt()
143 return -EINVAL; in lpc32xx_parse_dt()
146 kscandat->matrix_sz = rows; in lpc32xx_parse_dt()
147 kscandat->row_shift = get_count_order(columns); in lpc32xx_parse_dt()
149 of_property_read_u32(np, "nxp,debounce-delay-ms", &kscandat->deb_clks); in lpc32xx_parse_dt()
150 of_property_read_u32(np, "nxp,scan-delay-ms", &kscandat->scan_delay); in lpc32xx_parse_dt()
151 if (!kscandat->deb_clks || !kscandat->scan_delay) { in lpc32xx_parse_dt()
152 dev_err(dev, "debounce or scan delay not specified\n"); in lpc32xx_parse_dt()
153 return -EINVAL; in lpc32xx_parse_dt()
169 return -EINVAL; in lpc32xx_kscan_probe()
171 kscandat = devm_kzalloc(&pdev->dev, sizeof(*kscandat), in lpc32xx_kscan_probe()
174 return -ENOMEM; in lpc32xx_kscan_probe()
176 error = lpc32xx_parse_dt(&pdev->dev, kscandat); in lpc32xx_kscan_probe()
178 dev_err(&pdev->dev, "failed to parse device tree\n"); in lpc32xx_kscan_probe()
182 keymap_size = sizeof(kscandat->keymap[0]) * in lpc32xx_kscan_probe()
183 (kscandat->matrix_sz << kscandat->row_shift); in lpc32xx_kscan_probe()
184 kscandat->keymap = devm_kzalloc(&pdev->dev, keymap_size, GFP_KERNEL); in lpc32xx_kscan_probe()
185 if (!kscandat->keymap) in lpc32xx_kscan_probe()
186 return -ENOMEM; in lpc32xx_kscan_probe()
188 kscandat->input = input = devm_input_allocate_device(&pdev->dev); in lpc32xx_kscan_probe()
190 dev_err(&pdev->dev, "failed to allocate input device\n"); in lpc32xx_kscan_probe()
191 return -ENOMEM; in lpc32xx_kscan_probe()
195 input->name = pdev->name; in lpc32xx_kscan_probe()
196 input->phys = "lpc32xx/input0"; in lpc32xx_kscan_probe()
197 input->id.vendor = 0x0001; in lpc32xx_kscan_probe()
198 input->id.product = 0x0001; in lpc32xx_kscan_probe()
199 input->id.version = 0x0100; in lpc32xx_kscan_probe()
200 input->open = lpc32xx_kscan_open; in lpc32xx_kscan_probe()
201 input->close = lpc32xx_kscan_close; in lpc32xx_kscan_probe()
202 input->dev.parent = &pdev->dev; in lpc32xx_kscan_probe()
207 kscandat->matrix_sz, in lpc32xx_kscan_probe()
208 kscandat->matrix_sz, in lpc32xx_kscan_probe()
209 kscandat->keymap, kscandat->input); in lpc32xx_kscan_probe()
211 dev_err(&pdev->dev, "failed to build keymap\n"); in lpc32xx_kscan_probe()
215 input_set_drvdata(kscandat->input, kscandat); in lpc32xx_kscan_probe()
217 kscandat->kscan_base = devm_platform_ioremap_resource(pdev, 0); in lpc32xx_kscan_probe()
218 if (IS_ERR(kscandat->kscan_base)) in lpc32xx_kscan_probe()
219 return PTR_ERR(kscandat->kscan_base); in lpc32xx_kscan_probe()
222 kscandat->clk = devm_clk_get(&pdev->dev, NULL); in lpc32xx_kscan_probe()
223 if (IS_ERR(kscandat->clk)) { in lpc32xx_kscan_probe()
224 dev_err(&pdev->dev, "failed to get clock\n"); in lpc32xx_kscan_probe()
225 return PTR_ERR(kscandat->clk); in lpc32xx_kscan_probe()
229 error = clk_prepare_enable(kscandat->clk); in lpc32xx_kscan_probe()
233 writel(kscandat->deb_clks, LPC32XX_KS_DEB(kscandat->kscan_base)); in lpc32xx_kscan_probe()
234 writel(kscandat->scan_delay, LPC32XX_KS_SCAN_CTL(kscandat->kscan_base)); in lpc32xx_kscan_probe()
236 LPC32XX_KS_FAST_TST(kscandat->kscan_base)); in lpc32xx_kscan_probe()
237 writel(kscandat->matrix_sz, in lpc32xx_kscan_probe()
238 LPC32XX_KS_MATRIX_DIM(kscandat->kscan_base)); in lpc32xx_kscan_probe()
239 writel(1, LPC32XX_KS_IRQ(kscandat->kscan_base)); in lpc32xx_kscan_probe()
240 clk_disable_unprepare(kscandat->clk); in lpc32xx_kscan_probe()
242 error = devm_request_irq(&pdev->dev, irq, lpc32xx_kscan_irq, 0, in lpc32xx_kscan_probe()
243 pdev->name, kscandat); in lpc32xx_kscan_probe()
245 dev_err(&pdev->dev, "failed to request irq\n"); in lpc32xx_kscan_probe()
249 error = input_register_device(kscandat->input); in lpc32xx_kscan_probe()
251 dev_err(&pdev->dev, "failed to register input device\n"); in lpc32xx_kscan_probe()
264 struct input_dev *input = kscandat->input; in lpc32xx_kscan_suspend()
266 mutex_lock(&input->mutex); in lpc32xx_kscan_suspend()
270 writel(1, LPC32XX_KS_IRQ(kscandat->kscan_base)); in lpc32xx_kscan_suspend()
271 clk_disable_unprepare(kscandat->clk); in lpc32xx_kscan_suspend()
274 mutex_unlock(&input->mutex); in lpc32xx_kscan_suspend()
282 struct input_dev *input = kscandat->input; in lpc32xx_kscan_resume()
285 mutex_lock(&input->mutex); in lpc32xx_kscan_resume()
289 retval = clk_prepare_enable(kscandat->clk); in lpc32xx_kscan_resume()
291 writel(1, LPC32XX_KS_IRQ(kscandat->kscan_base)); in lpc32xx_kscan_resume()
294 mutex_unlock(&input->mutex); in lpc32xx_kscan_resume()
302 { .compatible = "nxp,lpc3220-key" },