Lines Matching +full:short +full:- +full:key +full:- +full:debounce
1 // SPDX-License-Identifier: GPL-2.0-only
3 * STMicroelectronics Key Scanning driver
44 unsigned short *keycode = keypad->input_dev->keycode; in keyscan_isr()
48 state = readl(keypad->base + KEYSCAN_MATRIX_STATE_OFF) & 0xffff; in keyscan_isr()
49 change = keypad->last_state ^ state; in keyscan_isr()
50 keypad->last_state = state; in keyscan_isr()
53 input_report_key(keypad->input_dev, in keyscan_isr()
56 input_sync(keypad->input_dev); in keyscan_isr()
65 error = clk_enable(keypad->clk); in keyscan_start()
69 writel(keypad->debounce_us * (clk_get_rate(keypad->clk) / 1000000), in keyscan_start()
70 keypad->base + KEYSCAN_DEBOUNCE_TIME_OFF); in keyscan_start()
72 writel(((keypad->n_cols - 1) << KEYSCAN_MATRIX_DIM_X_SHIFT) | in keyscan_start()
73 ((keypad->n_rows - 1) << KEYSCAN_MATRIX_DIM_Y_SHIFT), in keyscan_start()
74 keypad->base + KEYSCAN_MATRIX_DIM_OFF); in keyscan_start()
76 writel(KEYSCAN_CONFIG_ENABLE, keypad->base + KEYSCAN_CONFIG_OFF); in keyscan_start()
83 writel(0, keypad->base + KEYSCAN_CONFIG_OFF); in keyscan_stop()
85 clk_disable(keypad->clk); in keyscan_stop()
104 struct device *dev = keypad_data->input_dev->dev.parent; in keypad_matrix_key_parse_dt()
105 struct device_node *np = dev->of_node; in keypad_matrix_key_parse_dt()
108 error = matrix_keypad_parse_properties(dev, &keypad_data->n_rows, in keypad_matrix_key_parse_dt()
109 &keypad_data->n_cols); in keypad_matrix_key_parse_dt()
115 of_property_read_u32(np, "st,debounce-us", &keypad_data->debounce_us); in keypad_matrix_key_parse_dt()
117 dev_dbg(dev, "n_rows=%d n_col=%d debounce=%d\n", in keypad_matrix_key_parse_dt()
118 keypad_data->n_rows, keypad_data->n_cols, in keypad_matrix_key_parse_dt()
119 keypad_data->debounce_us); in keypad_matrix_key_parse_dt()
130 if (!pdev->dev.of_node) { in keyscan_probe()
131 dev_err(&pdev->dev, "no DT data present\n"); in keyscan_probe()
132 return -EINVAL; in keyscan_probe()
135 keypad_data = devm_kzalloc(&pdev->dev, sizeof(*keypad_data), in keyscan_probe()
138 return -ENOMEM; in keyscan_probe()
140 input_dev = devm_input_allocate_device(&pdev->dev); in keyscan_probe()
142 dev_err(&pdev->dev, "failed to allocate the input device\n"); in keyscan_probe()
143 return -ENOMEM; in keyscan_probe()
146 input_dev->name = pdev->name; in keyscan_probe()
147 input_dev->phys = "keyscan-keys/input0"; in keyscan_probe()
148 input_dev->dev.parent = &pdev->dev; in keyscan_probe()
149 input_dev->open = keyscan_open; in keyscan_probe()
150 input_dev->close = keyscan_close; in keyscan_probe()
152 input_dev->id.bustype = BUS_HOST; in keyscan_probe()
154 keypad_data->input_dev = input_dev; in keyscan_probe()
161 keypad_data->n_rows, in keyscan_probe()
162 keypad_data->n_cols, in keyscan_probe()
165 dev_err(&pdev->dev, "failed to build keymap\n"); in keyscan_probe()
171 keypad_data->base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); in keyscan_probe()
172 if (IS_ERR(keypad_data->base)) in keyscan_probe()
173 return PTR_ERR(keypad_data->base); in keyscan_probe()
175 keypad_data->clk = devm_clk_get(&pdev->dev, NULL); in keyscan_probe()
176 if (IS_ERR(keypad_data->clk)) { in keyscan_probe()
177 dev_err(&pdev->dev, "cannot get clock\n"); in keyscan_probe()
178 return PTR_ERR(keypad_data->clk); in keyscan_probe()
181 error = clk_enable(keypad_data->clk); in keyscan_probe()
183 dev_err(&pdev->dev, "failed to enable clock\n"); in keyscan_probe()
189 keypad_data->irq = platform_get_irq(pdev, 0); in keyscan_probe()
190 if (keypad_data->irq < 0) in keyscan_probe()
191 return -EINVAL; in keyscan_probe()
193 error = devm_request_irq(&pdev->dev, keypad_data->irq, keyscan_isr, 0, in keyscan_probe()
194 pdev->name, keypad_data); in keyscan_probe()
196 dev_err(&pdev->dev, "failed to request IRQ\n"); in keyscan_probe()
202 dev_err(&pdev->dev, "failed to register input device\n"); in keyscan_probe()
208 device_set_wakeup_capable(&pdev->dev, 1); in keyscan_probe()
217 struct input_dev *input = keypad->input_dev; in keyscan_suspend()
219 mutex_lock(&input->mutex); in keyscan_suspend()
222 enable_irq_wake(keypad->irq); in keyscan_suspend()
226 mutex_unlock(&input->mutex); in keyscan_suspend()
234 struct input_dev *input = keypad->input_dev; in keyscan_resume()
237 mutex_lock(&input->mutex); in keyscan_resume()
240 disable_irq_wake(keypad->irq); in keyscan_resume()
244 mutex_unlock(&input->mutex); in keyscan_resume()
252 { .compatible = "st,sti-keyscan" },
260 .name = "st-keyscan",