Lines Matching +full:num +full:- +full:rows
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) ST-Ericsson SA 2010
5 * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson
60 * struct stmpe_keypad_variant - model-specific attributes
62 * auto-increments on multiple read
63 * @set_pullup: whether the pins need to have their pull-ups set
67 * @max_rows: maximum number of rows supported
69 * @row_gpios: bitmask of gpios which can be used for rows
89 .col_gpios = 0x000ff, /* GPIO 0 - 7 */
90 .row_gpios = 0x0ff00, /* GPIO 8 - 15 */
99 .col_gpios = 0x0000ff, /* GPIO 0 - 7*/
100 .row_gpios = 0x1f7f00, /* GPIO 8-14, 16-20 */
109 .col_gpios = 0x0000ff, /* GPIO 0 - 7*/
110 .row_gpios = 0x1fef00, /* GPIO 8-14, 16-20 */
115 * struct stmpe_keypad - STMPE keypad state container
124 * @rows: bitmask for the rows
135 unsigned int rows; member
142 const struct stmpe_keypad_variant *variant = keypad->variant; in stmpe_keypad_read_data()
143 struct stmpe *stmpe = keypad->stmpe; in stmpe_keypad_read_data()
147 if (variant->auto_increment) in stmpe_keypad_read_data()
149 variant->num_data, data); in stmpe_keypad_read_data()
151 for (i = 0; i < variant->num_data; i++) { in stmpe_keypad_read_data()
165 struct input_dev *input = keypad->input; in stmpe_keypad_irq()
166 const struct stmpe_keypad_variant *variant = keypad->variant; in stmpe_keypad_irq()
175 for (i = 0; i < variant->num_normal_data; i++) { in stmpe_keypad_irq()
187 input_report_key(input, keypad->keymap[code], !up); in stmpe_keypad_irq()
196 const struct stmpe_keypad_variant *variant = keypad->variant; in stmpe_keypad_altfunc_init()
197 unsigned int col_gpios = variant->col_gpios; in stmpe_keypad_altfunc_init()
198 unsigned int row_gpios = variant->row_gpios; in stmpe_keypad_altfunc_init()
199 struct stmpe *stmpe = keypad->stmpe; in stmpe_keypad_altfunc_init()
200 u8 pureg = stmpe->regs[STMPE_IDX_GPPUR_LSB]; in stmpe_keypad_altfunc_init()
210 * {cols,rows}_gpios are bitmasks of which pins on the chip can be used in stmpe_keypad_altfunc_init()
213 * keypad->{cols,rows} are a bitmask of which pins (of the ones useable in stmpe_keypad_altfunc_init()
217 for (i = 0; i < variant->max_cols; i++) { in stmpe_keypad_altfunc_init()
218 int num = __ffs(col_gpios); in stmpe_keypad_altfunc_init() local
220 if (keypad->cols & (1 << i)) { in stmpe_keypad_altfunc_init()
221 pins |= 1 << num; in stmpe_keypad_altfunc_init()
222 pu_pins |= 1 << num; in stmpe_keypad_altfunc_init()
225 col_gpios &= ~(1 << num); in stmpe_keypad_altfunc_init()
228 for (i = 0; i < variant->max_rows; i++) { in stmpe_keypad_altfunc_init()
229 int num = __ffs(row_gpios); in stmpe_keypad_altfunc_init() local
231 if (keypad->rows & (1 << i)) in stmpe_keypad_altfunc_init()
232 pins |= 1 << num; in stmpe_keypad_altfunc_init()
234 row_gpios &= ~(1 << num); in stmpe_keypad_altfunc_init()
242 * On STMPE24xx, set pin bias to pull-up on all keypad input in stmpe_keypad_altfunc_init()
244 * and placed at GPIO0-7 so only the LSB of the pull up register in stmpe_keypad_altfunc_init()
247 if (variant->set_pullup) { in stmpe_keypad_altfunc_init()
266 const struct stmpe_keypad_variant *variant = keypad->variant; in stmpe_keypad_chip_init()
267 struct stmpe *stmpe = keypad->stmpe; in stmpe_keypad_chip_init()
270 if (keypad->debounce_ms > STMPE_KEYPAD_MAX_DEBOUNCE) in stmpe_keypad_chip_init()
271 return -EINVAL; in stmpe_keypad_chip_init()
273 if (keypad->scan_count > STMPE_KEYPAD_MAX_SCAN_COUNT) in stmpe_keypad_chip_init()
274 return -EINVAL; in stmpe_keypad_chip_init()
284 ret = stmpe_reg_write(stmpe, STMPE_KPC_COL, keypad->cols); in stmpe_keypad_chip_init()
288 ret = stmpe_reg_write(stmpe, STMPE_KPC_ROW_LSB, keypad->rows); in stmpe_keypad_chip_init()
292 if (variant->max_rows > 8) { in stmpe_keypad_chip_init()
295 keypad->rows >> 8); in stmpe_keypad_chip_init()
302 keypad->scan_count << 4); in stmpe_keypad_chip_init()
310 (keypad->debounce_ms << 1)); in stmpe_keypad_chip_init()
322 if (keypad->keymap[code] != KEY_RESERVED) { in stmpe_keypad_fill_used_pins()
323 keypad->rows |= 1 << row; in stmpe_keypad_fill_used_pins()
324 keypad->cols |= 1 << col; in stmpe_keypad_fill_used_pins()
332 struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent); in stmpe_keypad_probe()
333 struct device_node *np = pdev->dev.of_node; in stmpe_keypad_probe()
336 u32 rows; in stmpe_keypad_probe() local
345 keypad = devm_kzalloc(&pdev->dev, sizeof(struct stmpe_keypad), in stmpe_keypad_probe()
348 return -ENOMEM; in stmpe_keypad_probe()
350 keypad->stmpe = stmpe; in stmpe_keypad_probe()
351 keypad->variant = &stmpe_keypad_variants[stmpe->partnum]; in stmpe_keypad_probe()
353 of_property_read_u32(np, "debounce-interval", &keypad->debounce_ms); in stmpe_keypad_probe()
354 of_property_read_u32(np, "st,scan-count", &keypad->scan_count); in stmpe_keypad_probe()
355 keypad->no_autorepeat = of_property_read_bool(np, "st,no-autorepeat"); in stmpe_keypad_probe()
357 input = devm_input_allocate_device(&pdev->dev); in stmpe_keypad_probe()
359 return -ENOMEM; in stmpe_keypad_probe()
361 input->name = "STMPE keypad"; in stmpe_keypad_probe()
362 input->id.bustype = BUS_I2C; in stmpe_keypad_probe()
363 input->dev.parent = &pdev->dev; in stmpe_keypad_probe()
365 error = matrix_keypad_parse_properties(&pdev->dev, &rows, &cols); in stmpe_keypad_probe()
369 error = matrix_keypad_build_keymap(NULL, NULL, rows, cols, in stmpe_keypad_probe()
370 keypad->keymap, input); in stmpe_keypad_probe()
375 if (!keypad->no_autorepeat) in stmpe_keypad_probe()
376 __set_bit(EV_REP, input->evbit); in stmpe_keypad_probe()
378 stmpe_keypad_fill_used_pins(keypad, rows, cols); in stmpe_keypad_probe()
380 keypad->input = input; in stmpe_keypad_probe()
386 error = devm_request_threaded_irq(&pdev->dev, irq, in stmpe_keypad_probe()
388 IRQF_ONESHOT, "stmpe-keypad", keypad); in stmpe_keypad_probe()
390 dev_err(&pdev->dev, "unable to get irq: %d\n", error); in stmpe_keypad_probe()
396 dev_err(&pdev->dev, in stmpe_keypad_probe()
410 stmpe_disable(keypad->stmpe, STMPE_BLOCK_KEYPAD); in stmpe_keypad_remove()
416 .driver.name = "stmpe-keypad",