Lines Matching refs:pdata

27 	const struct matrix_keypad_platform_data *pdata;  member
47 static void __activate_col(const struct matrix_keypad_platform_data *pdata, in __activate_col() argument
50 bool level_on = !pdata->active_low; in __activate_col()
53 gpio_direction_output(pdata->col_gpios[col], level_on); in __activate_col()
55 gpio_set_value_cansleep(pdata->col_gpios[col], !level_on); in __activate_col()
56 if (!pdata->drive_inactive_cols) in __activate_col()
57 gpio_direction_input(pdata->col_gpios[col]); in __activate_col()
61 static void activate_col(const struct matrix_keypad_platform_data *pdata, in activate_col() argument
64 __activate_col(pdata, col, on); in activate_col()
66 if (on && pdata->col_scan_delay_us) in activate_col()
67 udelay(pdata->col_scan_delay_us); in activate_col()
70 static void activate_all_cols(const struct matrix_keypad_platform_data *pdata, in activate_all_cols() argument
75 for (col = 0; col < pdata->num_col_gpios; col++) in activate_all_cols()
76 __activate_col(pdata, col, on); in activate_all_cols()
79 static bool row_asserted(const struct matrix_keypad_platform_data *pdata, in row_asserted() argument
82 return gpio_get_value_cansleep(pdata->row_gpios[row]) ? in row_asserted()
83 !pdata->active_low : pdata->active_low; in row_asserted()
88 const struct matrix_keypad_platform_data *pdata = keypad->pdata; in enable_row_irqs() local
91 if (pdata->clustered_irq > 0) in enable_row_irqs()
92 enable_irq(pdata->clustered_irq); in enable_row_irqs()
94 for (i = 0; i < pdata->num_row_gpios; i++) in enable_row_irqs()
95 enable_irq(gpio_to_irq(pdata->row_gpios[i])); in enable_row_irqs()
101 const struct matrix_keypad_platform_data *pdata = keypad->pdata; in disable_row_irqs() local
104 if (pdata->clustered_irq > 0) in disable_row_irqs()
105 disable_irq_nosync(pdata->clustered_irq); in disable_row_irqs()
107 for (i = 0; i < pdata->num_row_gpios; i++) in disable_row_irqs()
108 disable_irq_nosync(gpio_to_irq(pdata->row_gpios[i])); in disable_row_irqs()
121 const struct matrix_keypad_platform_data *pdata = keypad->pdata; in matrix_keypad_scan() local
126 activate_all_cols(pdata, false); in matrix_keypad_scan()
131 for (col = 0; col < pdata->num_col_gpios; col++) { in matrix_keypad_scan()
133 activate_col(pdata, col, true); in matrix_keypad_scan()
135 for (row = 0; row < pdata->num_row_gpios; row++) in matrix_keypad_scan()
137 row_asserted(pdata, row) ? (1 << row) : 0; in matrix_keypad_scan()
139 activate_col(pdata, col, false); in matrix_keypad_scan()
142 for (col = 0; col < pdata->num_col_gpios; col++) { in matrix_keypad_scan()
149 for (row = 0; row < pdata->num_row_gpios; row++) { in matrix_keypad_scan()
164 activate_all_cols(pdata, true); in matrix_keypad_scan()
191 msecs_to_jiffies(keypad->pdata->debounce_ms)); in matrix_keypad_interrupt()
233 const struct matrix_keypad_platform_data *pdata = keypad->pdata; in matrix_keypad_enable_wakeup() local
237 if (pdata->clustered_irq > 0) { in matrix_keypad_enable_wakeup()
238 if (enable_irq_wake(pdata->clustered_irq) == 0) in matrix_keypad_enable_wakeup()
242 for (i = 0; i < pdata->num_row_gpios; i++) { in matrix_keypad_enable_wakeup()
244 gpio = pdata->row_gpios[i]; in matrix_keypad_enable_wakeup()
255 const struct matrix_keypad_platform_data *pdata = keypad->pdata; in matrix_keypad_disable_wakeup() local
259 if (pdata->clustered_irq > 0) { in matrix_keypad_disable_wakeup()
261 disable_irq_wake(pdata->clustered_irq); in matrix_keypad_disable_wakeup()
265 for (i = 0; i < pdata->num_row_gpios; i++) { in matrix_keypad_disable_wakeup()
267 gpio = pdata->row_gpios[i]; in matrix_keypad_disable_wakeup()
307 const struct matrix_keypad_platform_data *pdata = keypad->pdata; in matrix_keypad_init_gpio() local
311 for (i = 0; i < pdata->num_col_gpios; i++) { in matrix_keypad_init_gpio()
312 err = gpio_request(pdata->col_gpios[i], "matrix_kbd_col"); in matrix_keypad_init_gpio()
316 pdata->col_gpios[i], i); in matrix_keypad_init_gpio()
320 gpio_direction_output(pdata->col_gpios[i], !pdata->active_low); in matrix_keypad_init_gpio()
323 for (i = 0; i < pdata->num_row_gpios; i++) { in matrix_keypad_init_gpio()
324 err = gpio_request(pdata->row_gpios[i], "matrix_kbd_row"); in matrix_keypad_init_gpio()
328 pdata->row_gpios[i], i); in matrix_keypad_init_gpio()
332 gpio_direction_input(pdata->row_gpios[i]); in matrix_keypad_init_gpio()
335 if (pdata->clustered_irq > 0) { in matrix_keypad_init_gpio()
336 err = request_any_context_irq(pdata->clustered_irq, in matrix_keypad_init_gpio()
338 pdata->clustered_irq_flags, in matrix_keypad_init_gpio()
346 for (i = 0; i < pdata->num_row_gpios; i++) { in matrix_keypad_init_gpio()
348 gpio_to_irq(pdata->row_gpios[i]), in matrix_keypad_init_gpio()
356 pdata->row_gpios[i]); in matrix_keypad_init_gpio()
368 free_irq(gpio_to_irq(pdata->row_gpios[i]), keypad); in matrix_keypad_init_gpio()
369 i = pdata->num_row_gpios; in matrix_keypad_init_gpio()
372 gpio_free(pdata->row_gpios[i]); in matrix_keypad_init_gpio()
373 i = pdata->num_col_gpios; in matrix_keypad_init_gpio()
376 gpio_free(pdata->col_gpios[i]); in matrix_keypad_init_gpio()
383 const struct matrix_keypad_platform_data *pdata = keypad->pdata; in matrix_keypad_free_gpio() local
386 if (pdata->clustered_irq > 0) { in matrix_keypad_free_gpio()
387 free_irq(pdata->clustered_irq, keypad); in matrix_keypad_free_gpio()
389 for (i = 0; i < pdata->num_row_gpios; i++) in matrix_keypad_free_gpio()
390 free_irq(gpio_to_irq(pdata->row_gpios[i]), keypad); in matrix_keypad_free_gpio()
393 for (i = 0; i < pdata->num_row_gpios; i++) in matrix_keypad_free_gpio()
394 gpio_free(pdata->row_gpios[i]); in matrix_keypad_free_gpio()
396 for (i = 0; i < pdata->num_col_gpios; i++) in matrix_keypad_free_gpio()
397 gpio_free(pdata->col_gpios[i]); in matrix_keypad_free_gpio()
404 struct matrix_keypad_platform_data *pdata; in matrix_keypad_parse_dt() local
414 pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); in matrix_keypad_parse_dt()
415 if (!pdata) { in matrix_keypad_parse_dt()
420 pdata->num_row_gpios = nrow = gpiod_count(dev, "row"); in matrix_keypad_parse_dt()
421 pdata->num_col_gpios = ncol = gpiod_count(dev, "col"); in matrix_keypad_parse_dt()
428 pdata->no_autorepeat = true; in matrix_keypad_parse_dt()
430 pdata->wakeup = of_property_read_bool(np, "wakeup-source") || in matrix_keypad_parse_dt()
434 pdata->active_low = true; in matrix_keypad_parse_dt()
436 pdata->drive_inactive_cols = in matrix_keypad_parse_dt()
439 of_property_read_u32(np, "debounce-delay-ms", &pdata->debounce_ms); in matrix_keypad_parse_dt()
441 &pdata->col_scan_delay_us); in matrix_keypad_parse_dt()
444 pdata->num_row_gpios + pdata->num_col_gpios, in matrix_keypad_parse_dt()
466 pdata->row_gpios = gpios; in matrix_keypad_parse_dt()
467 pdata->col_gpios = &gpios[pdata->num_row_gpios]; in matrix_keypad_parse_dt()
469 return pdata; in matrix_keypad_parse_dt()
483 const struct matrix_keypad_platform_data *pdata; in matrix_keypad_probe() local
488 pdata = dev_get_platdata(&pdev->dev); in matrix_keypad_probe()
489 if (!pdata) { in matrix_keypad_probe()
490 pdata = matrix_keypad_parse_dt(&pdev->dev); in matrix_keypad_probe()
491 if (IS_ERR(pdata)) in matrix_keypad_probe()
492 return PTR_ERR(pdata); in matrix_keypad_probe()
493 } else if (!pdata->keymap_data) { in matrix_keypad_probe()
506 keypad->pdata = pdata; in matrix_keypad_probe()
507 keypad->row_shift = get_count_order(pdata->num_col_gpios); in matrix_keypad_probe()
518 err = matrix_keypad_build_keymap(pdata->keymap_data, NULL, in matrix_keypad_probe()
519 pdata->num_row_gpios, in matrix_keypad_probe()
520 pdata->num_col_gpios, in matrix_keypad_probe()
527 if (!pdata->no_autorepeat) in matrix_keypad_probe()
540 device_init_wakeup(&pdev->dev, pdata->wakeup); in matrix_keypad_probe()