Lines Matching refs:kp
125 static int twl4030_kpread(struct twl4030_keypad *kp, in twl4030_kpread() argument
131 dev_warn(kp->dbg_dev, in twl4030_kpread()
138 static int twl4030_kpwrite_u8(struct twl4030_keypad *kp, u8 data, u32 reg) in twl4030_kpwrite_u8() argument
143 dev_warn(kp->dbg_dev, in twl4030_kpwrite_u8()
150 static inline u16 twl4030_col_xlate(struct twl4030_keypad *kp, u8 col) in twl4030_col_xlate() argument
159 return 1 << kp->n_cols; in twl4030_col_xlate()
161 return col & ((1 << kp->n_cols) - 1); in twl4030_col_xlate()
164 static int twl4030_read_kp_matrix_state(struct twl4030_keypad *kp, u16 *state) in twl4030_read_kp_matrix_state() argument
168 int ret = twl4030_kpread(kp, new_state, in twl4030_read_kp_matrix_state()
169 KEYP_FULL_CODE_7_0, kp->n_rows); in twl4030_read_kp_matrix_state()
171 for (row = 0; row < kp->n_rows; row++) in twl4030_read_kp_matrix_state()
172 state[row] = twl4030_col_xlate(kp, new_state[row]); in twl4030_read_kp_matrix_state()
177 static bool twl4030_is_in_ghost_state(struct twl4030_keypad *kp, u16 *key_state) in twl4030_is_in_ghost_state() argument
182 for (i = 0; i < kp->n_rows; i++) { in twl4030_is_in_ghost_state()
194 static void twl4030_kp_scan(struct twl4030_keypad *kp, bool release_all) in twl4030_kp_scan() argument
196 struct input_dev *input = kp->input; in twl4030_kp_scan()
204 int ret = twl4030_read_kp_matrix_state(kp, new_state); in twl4030_kp_scan()
209 if (twl4030_is_in_ghost_state(kp, new_state)) in twl4030_kp_scan()
214 for (row = 0; row < kp->n_rows; row++) { in twl4030_kp_scan()
215 int changed = new_state[row] ^ kp->kp_state[row]; in twl4030_kp_scan()
221 for (col = 0; col < kp->n_cols + 1; col++) { in twl4030_kp_scan()
227 dev_dbg(kp->dbg_dev, "key [%d:%d] %s\n", row, col, in twl4030_kp_scan()
233 input_report_key(input, kp->keymap[code], in twl4030_kp_scan()
236 kp->kp_state[row] = new_state[row]; in twl4030_kp_scan()
246 struct twl4030_keypad *kp = _kp; in do_kp_irq() local
251 ret = twl4030_kpread(kp, ®, KEYP_ISR1, 1); in do_kp_irq()
258 twl4030_kp_scan(kp, false); in do_kp_irq()
260 twl4030_kp_scan(kp, true); in do_kp_irq()
265 static int twl4030_kp_program(struct twl4030_keypad *kp) in twl4030_kp_program() argument
273 if (twl4030_kpwrite_u8(kp, reg, KEYP_CTRL) < 0) in twl4030_kp_program()
283 if (twl4030_kpwrite_u8(kp, reg, KEYP_EDR) < 0) in twl4030_kp_program()
288 if (twl4030_kpwrite_u8(kp, reg, KEYP_LK_PTV) < 0) in twl4030_kp_program()
293 if (twl4030_kpwrite_u8(kp, i, KEYP_DEB) < 0) in twl4030_kp_program()
298 if (twl4030_kpwrite_u8(kp, (i & 0xFF), KEYP_TIMEOUT_L) < 0) in twl4030_kp_program()
301 if (twl4030_kpwrite_u8(kp, (i >> 8), KEYP_TIMEOUT_H) < 0) in twl4030_kp_program()
309 if (twl4030_kpwrite_u8(kp, reg, KEYP_SIH_CTRL) < 0) in twl4030_kp_program()
313 if (twl4030_read_kp_matrix_state(kp, kp->kp_state) < 0) in twl4030_kp_program()
327 struct twl4030_keypad *kp; in twl4030_kp_probe() local
332 kp = devm_kzalloc(&pdev->dev, sizeof(*kp), GFP_KERNEL); in twl4030_kp_probe()
333 if (!kp) in twl4030_kp_probe()
341 kp->dbg_dev = &pdev->dev; in twl4030_kp_probe()
342 kp->input = input; in twl4030_kp_probe()
359 kp->n_rows = pdata->rows; in twl4030_kp_probe()
360 kp->n_cols = pdata->cols; in twl4030_kp_probe()
361 kp->autorepeat = pdata->rep; in twl4030_kp_probe()
364 error = matrix_keypad_parse_properties(&pdev->dev, &kp->n_rows, in twl4030_kp_probe()
365 &kp->n_cols); in twl4030_kp_probe()
369 kp->autorepeat = true; in twl4030_kp_probe()
372 if (kp->n_rows > TWL4030_MAX_ROWS || kp->n_cols > TWL4030_MAX_COLS) { in twl4030_kp_probe()
378 kp->irq = platform_get_irq(pdev, 0); in twl4030_kp_probe()
379 if (kp->irq < 0) in twl4030_kp_probe()
380 return kp->irq; in twl4030_kp_probe()
385 kp->keymap, input); in twl4030_kp_probe()
387 dev_err(kp->dbg_dev, "Failed to build keymap\n"); in twl4030_kp_probe()
393 if (kp->autorepeat) in twl4030_kp_probe()
398 dev_err(kp->dbg_dev, in twl4030_kp_probe()
403 error = twl4030_kp_program(kp); in twl4030_kp_probe()
413 error = devm_request_threaded_irq(&pdev->dev, kp->irq, NULL, do_kp_irq, in twl4030_kp_probe()
414 0, pdev->name, kp); in twl4030_kp_probe()
416 dev_info(kp->dbg_dev, "request_irq failed for irq no=%d: %d\n", in twl4030_kp_probe()
417 kp->irq, error); in twl4030_kp_probe()
423 if (twl4030_kpwrite_u8(kp, reg, KEYP_IMR1)) { in twl4030_kp_probe()
425 (void) twl4030_kpwrite_u8(kp, 0xff, KEYP_IMR1); in twl4030_kp_probe()