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

1 // SPDX-License-Identifier: GPL-2.0
16 #define MTK_KPD_NAME "mt6779-keypad"
51 const unsigned short *keycode = keypad->input_dev->keycode; in mt6779_keypad_irq_handler()
57 unsigned int row_shift = get_count_order(keypad->n_cols); in mt6779_keypad_irq_handler()
60 regmap_bulk_read(keypad->regmap, MTK_KPD_MEM, in mt6779_keypad_irq_handler()
63 bitmap_xor(change, new_state, keypad->keymap_state, MTK_KPD_NUM_BITS); in mt6779_keypad_irq_handler()
74 keypad->calc_row_col(key, &row, &col); in mt6779_keypad_irq_handler()
79 dev_dbg(&keypad->input_dev->dev, "%s", in mt6779_keypad_irq_handler()
82 input_event(keypad->input_dev, EV_MSC, MSC_SCAN, scancode); in mt6779_keypad_irq_handler()
83 input_report_key(keypad->input_dev, keycode[scancode], pressed); in mt6779_keypad_irq_handler()
84 input_sync(keypad->input_dev); in mt6779_keypad_irq_handler()
86 dev_dbg(&keypad->input_dev->dev, in mt6779_keypad_irq_handler()
90 bitmap_copy(keypad->keymap_state, new_state, MTK_KPD_NUM_BITS); in mt6779_keypad_irq_handler()
116 u32 debounce; in mt6779_keypad_pdrv_probe() local
121 keypad = devm_kzalloc(&pdev->dev, sizeof(*keypad), GFP_KERNEL); in mt6779_keypad_pdrv_probe()
123 return -ENOMEM; in mt6779_keypad_pdrv_probe()
129 keypad->regmap = devm_regmap_init_mmio(&pdev->dev, base, in mt6779_keypad_pdrv_probe()
131 if (IS_ERR(keypad->regmap)) { in mt6779_keypad_pdrv_probe()
132 dev_err(&pdev->dev, in mt6779_keypad_pdrv_probe()
133 "regmap init failed:%pe\n", keypad->regmap); in mt6779_keypad_pdrv_probe()
134 return PTR_ERR(keypad->regmap); in mt6779_keypad_pdrv_probe()
137 bitmap_fill(keypad->keymap_state, MTK_KPD_NUM_BITS); in mt6779_keypad_pdrv_probe()
139 keypad->input_dev = devm_input_allocate_device(&pdev->dev); in mt6779_keypad_pdrv_probe()
140 if (!keypad->input_dev) { in mt6779_keypad_pdrv_probe()
141 dev_err(&pdev->dev, "Failed to allocate input dev\n"); in mt6779_keypad_pdrv_probe()
142 return -ENOMEM; in mt6779_keypad_pdrv_probe()
145 keypad->input_dev->name = MTK_KPD_NAME; in mt6779_keypad_pdrv_probe()
146 keypad->input_dev->id.bustype = BUS_HOST; in mt6779_keypad_pdrv_probe()
148 error = matrix_keypad_parse_properties(&pdev->dev, &keypad->n_rows, in mt6779_keypad_pdrv_probe()
149 &keypad->n_cols); in mt6779_keypad_pdrv_probe()
151 dev_err(&pdev->dev, "Failed to parse keypad params\n"); in mt6779_keypad_pdrv_probe()
155 if (device_property_read_u32(&pdev->dev, "debounce-delay-ms", in mt6779_keypad_pdrv_probe()
156 &debounce)) in mt6779_keypad_pdrv_probe()
157 debounce = 16; in mt6779_keypad_pdrv_probe()
159 if (debounce > MTK_KPD_DEBOUNCE_MAX_MS) { in mt6779_keypad_pdrv_probe()
160 dev_err(&pdev->dev, in mt6779_keypad_pdrv_probe()
161 "Debounce time exceeds the maximum allowed time %dms\n", in mt6779_keypad_pdrv_probe()
163 return -EINVAL; in mt6779_keypad_pdrv_probe()
166 if (device_property_read_u32(&pdev->dev, "mediatek,keys-per-group", in mt6779_keypad_pdrv_probe()
172 keypad->calc_row_col = mt6779_keypad_calc_row_col_single; in mt6779_keypad_pdrv_probe()
175 keypad->calc_row_col = mt6779_keypad_calc_row_col_double; in mt6779_keypad_pdrv_probe()
178 dev_err(&pdev->dev, in mt6779_keypad_pdrv_probe()
179 "Invalid keys-per-group: %d\n", keys_per_group); in mt6779_keypad_pdrv_probe()
180 return -EINVAL; in mt6779_keypad_pdrv_probe()
183 wakeup = device_property_read_bool(&pdev->dev, "wakeup-source"); in mt6779_keypad_pdrv_probe()
185 dev_dbg(&pdev->dev, "n_row=%d n_col=%d debounce=%d\n", in mt6779_keypad_pdrv_probe()
186 keypad->n_rows, keypad->n_cols, debounce); in mt6779_keypad_pdrv_probe()
189 keypad->n_rows, keypad->n_cols, in mt6779_keypad_pdrv_probe()
190 NULL, keypad->input_dev); in mt6779_keypad_pdrv_probe()
192 dev_err(&pdev->dev, "Failed to build keymap\n"); in mt6779_keypad_pdrv_probe()
196 input_set_capability(keypad->input_dev, EV_MSC, MSC_SCAN); in mt6779_keypad_pdrv_probe()
198 regmap_write(keypad->regmap, MTK_KPD_DEBOUNCE, in mt6779_keypad_pdrv_probe()
199 (debounce * (1 << 5)) & MTK_KPD_DEBOUNCE_MASK); in mt6779_keypad_pdrv_probe()
202 regmap_update_bits(keypad->regmap, MTK_KPD_SEL, in mt6779_keypad_pdrv_probe()
206 regmap_update_bits(keypad->regmap, MTK_KPD_SEL, MTK_KPD_SEL_ROW, in mt6779_keypad_pdrv_probe()
207 MTK_KPD_SEL_ROWMASK(keypad->n_rows)); in mt6779_keypad_pdrv_probe()
208 regmap_update_bits(keypad->regmap, MTK_KPD_SEL, MTK_KPD_SEL_COL, in mt6779_keypad_pdrv_probe()
209 MTK_KPD_SEL_COLMASK(keypad->n_cols)); in mt6779_keypad_pdrv_probe()
211 keypad->clk = devm_clk_get_enabled(&pdev->dev, "kpd"); in mt6779_keypad_pdrv_probe()
212 if (IS_ERR(keypad->clk)) in mt6779_keypad_pdrv_probe()
213 return PTR_ERR(keypad->clk); in mt6779_keypad_pdrv_probe()
219 error = devm_request_threaded_irq(&pdev->dev, irq, in mt6779_keypad_pdrv_probe()
223 dev_err(&pdev->dev, "Failed to request IRQ#%d: %d\n", in mt6779_keypad_pdrv_probe()
228 error = input_register_device(keypad->input_dev); in mt6779_keypad_pdrv_probe()
230 dev_err(&pdev->dev, "Failed to register device\n"); in mt6779_keypad_pdrv_probe()
234 error = device_init_wakeup(&pdev->dev, wakeup); in mt6779_keypad_pdrv_probe()
236 dev_warn(&pdev->dev, "device_init_wakeup() failed: %d\n", in mt6779_keypad_pdrv_probe()
243 { .compatible = "mediatek,mt6779-keypad" },
244 { .compatible = "mediatek,mt6873-keypad" },