Lines Matching +full:rx +full:- +full:input +full:- +full:m
1 // SPDX-License-Identifier: GPL-2.0-only
10 * - corgi_ts.c
11 * Copyright (C) 2004-2005 Richard Purdie
12 * - omap_ts.[hc], ads7846.h, ts_osk.c
22 #include <linux/input.h>
23 #include <linux/input/touchscreen.h>
39 * Support for ads7843 tested on Atmel at91sam926x-EK.
53 * note. The strength of filtering can be set in the board-* specific
76 * driver is used with DMA-based SPI controllers (like atmel_spi) on
77 * systems where main memory is not DMA-coherent (most non-x86 boards).
85 struct ads7846_buf *rx; member
95 struct input_dev *input; member
152 /* leave chip selected when we're done, for quicker re-select? */
159 /*--------------------------------------------------------------------------*/
169 #define ADS_A2A1A0_temp0 (0 << 4) /* non-differential */
170 #define ADS_A2A1A0_vbatt (2 << 4) /* non-differential */
171 #define ADS_A2A1A0_vaux (6 << 4) /* non-differential */
172 #define ADS_A2A1A0_temp1 (7 << 4) /* non-differential */
175 #define ADS_SER (1 << 2) /* non-differential */
182 #define MAX_12BIT ((1<<12)-1)
195 /* single-ended samples need to first power up reference voltage;
206 * Measure: X; Vref: X+, X-; IN: Y+
207 * Measure: Y; Vref: Y+, Y-; IN: X+
208 * Measure: Z1; Vref: Y+, X-; IN: X+
209 * Measure: Z2; Vref: Y+, X-; IN: Y-
221 if (ts->get_pendown_state) in get_pendown_state()
222 return ts->get_pendown_state(); in get_pendown_state()
224 return gpiod_get_value(ts->gpio_pendown); in get_pendown_state()
229 struct input_dev *input = ts->input; in ads7846_report_pen_up() local
231 input_report_key(input, BTN_TOUCH, 0); in ads7846_report_pen_up()
232 input_report_abs(input, ABS_PRESSURE, 0); in ads7846_report_pen_up()
233 input_sync(input); in ads7846_report_pen_up()
235 ts->pendown = false; in ads7846_report_pen_up()
236 dev_vdbg(&ts->spi->dev, "UP\n"); in ads7846_report_pen_up()
239 /* Must be called with ts->lock held */
242 if (!ts->disabled && !ts->suspended) { in ads7846_stop()
244 ts->stopped = true; in ads7846_stop()
246 wake_up(&ts->wait); in ads7846_stop()
247 disable_irq(ts->spi->irq); in ads7846_stop()
251 /* Must be called with ts->lock held */
254 if (!ts->disabled && !ts->suspended) { in ads7846_restart()
256 if (ts->pendown && !get_pendown_state(ts)) in ads7846_restart()
260 ts->stopped = false; in ads7846_restart()
262 enable_irq(ts->spi->irq); in ads7846_restart()
266 /* Must be called with ts->lock held */
270 regulator_disable(ts->reg); in __ads7846_disable()
278 /* Must be called with ts->lock held */
283 error = regulator_enable(ts->reg); in __ads7846_enable()
285 dev_err(&ts->spi->dev, "Failed to enable supply: %d\n", error); in __ads7846_enable()
292 mutex_lock(&ts->lock); in ads7846_disable()
294 if (!ts->disabled) { in ads7846_disable()
296 if (!ts->suspended) in ads7846_disable()
299 ts->disabled = true; in ads7846_disable()
302 mutex_unlock(&ts->lock); in ads7846_disable()
307 mutex_lock(&ts->lock); in ads7846_enable()
309 if (ts->disabled) { in ads7846_enable()
311 ts->disabled = false; in ads7846_enable()
313 if (!ts->suspended) in ads7846_enable()
317 mutex_unlock(&ts->lock); in ads7846_enable()
320 /*--------------------------------------------------------------------------*/
323 * Non-touchscreen sensors only use single-ended conversions.
362 return -ENOMEM; in ads7846_read12_ser()
364 spi_message_init(&req->msg); in ads7846_read12_ser()
367 if (ts->use_internal) { in ads7846_read12_ser()
368 req->ref_on = REF_ON; in ads7846_read12_ser()
369 req->xfer[0].tx_buf = &req->ref_on; in ads7846_read12_ser()
370 req->xfer[0].len = 1; in ads7846_read12_ser()
371 spi_message_add_tail(&req->xfer[0], &req->msg); in ads7846_read12_ser()
373 req->xfer[1].rx_buf = &req->scratch; in ads7846_read12_ser()
374 req->xfer[1].len = 2; in ads7846_read12_ser()
377 req->xfer[1].delay.value = ts->vref_delay_usecs; in ads7846_read12_ser()
378 req->xfer[1].delay.unit = SPI_DELAY_UNIT_USECS; in ads7846_read12_ser()
379 spi_message_add_tail(&req->xfer[1], &req->msg); in ads7846_read12_ser()
389 req->command = (u8) command; in ads7846_read12_ser()
390 req->xfer[2].tx_buf = &req->command; in ads7846_read12_ser()
391 req->xfer[2].len = 1; in ads7846_read12_ser()
392 spi_message_add_tail(&req->xfer[2], &req->msg); in ads7846_read12_ser()
394 req->xfer[3].rx_buf = &req->sample; in ads7846_read12_ser()
395 req->xfer[3].len = 2; in ads7846_read12_ser()
396 spi_message_add_tail(&req->xfer[3], &req->msg); in ads7846_read12_ser()
401 req->ref_off = PWRDOWN; in ads7846_read12_ser()
402 req->xfer[4].tx_buf = &req->ref_off; in ads7846_read12_ser()
403 req->xfer[4].len = 1; in ads7846_read12_ser()
404 spi_message_add_tail(&req->xfer[4], &req->msg); in ads7846_read12_ser()
406 req->xfer[5].rx_buf = &req->scratch; in ads7846_read12_ser()
407 req->xfer[5].len = 2; in ads7846_read12_ser()
408 spi_message_add_tail(&req->xfer[5], &req->msg); in ads7846_read12_ser()
411 req->scratch = 0; in ads7846_read12_ser()
412 req->xfer[6].tx_buf = &req->scratch; in ads7846_read12_ser()
413 req->xfer[6].len = 1; in ads7846_read12_ser()
414 spi_message_add_tail(&req->xfer[6], &req->msg); in ads7846_read12_ser()
416 req->xfer[7].rx_buf = &req->scratch; in ads7846_read12_ser()
417 req->xfer[7].len = 2; in ads7846_read12_ser()
418 CS_CHANGE(req->xfer[7]); in ads7846_read12_ser()
419 spi_message_add_tail(&req->xfer[7], &req->msg); in ads7846_read12_ser()
421 mutex_lock(&ts->lock); in ads7846_read12_ser()
423 status = spi_sync(spi, &req->msg); in ads7846_read12_ser()
425 mutex_unlock(&ts->lock); in ads7846_read12_ser()
428 /* on-wire is a must-ignore bit, a BE12 value, then padding */ in ads7846_read12_ser()
429 status = be16_to_cpu(req->sample); in ads7846_read12_ser()
447 return -ENOMEM; in ads7845_read12_ser()
449 spi_message_init(&req->msg); in ads7845_read12_ser()
451 req->command[0] = (u8) command; in ads7845_read12_ser()
452 req->xfer[0].tx_buf = req->command; in ads7845_read12_ser()
453 req->xfer[0].rx_buf = req->sample; in ads7845_read12_ser()
454 req->xfer[0].len = 3; in ads7845_read12_ser()
455 spi_message_add_tail(&req->xfer[0], &req->msg); in ads7845_read12_ser()
457 mutex_lock(&ts->lock); in ads7845_read12_ser()
459 status = spi_sync(spi, &req->msg); in ads7845_read12_ser()
461 mutex_unlock(&ts->lock); in ads7845_read12_ser()
465 status = get_unaligned_be16(&req->sample[1]); in ads7845_read12_ser()
480 ssize_t v = ads7846_read12_ser(&ts->spi->dev, \
490 * ADS7846 could use the low-accuracy two-sample scheme, but can't do the high
512 retval *= ts->vref_mv; in SHOW()
523 if (ts->model == 7846) in vbatt_adjust()
538 if (ts->model == 7843 && index < 2) /* in0, in1 */ in SHOW()
540 if (ts->model == 7845 && index != 2) /* in0 */ in SHOW()
543 return attr->mode; in SHOW()
565 switch (ts->model) { in ads784x_hwmon_register()
567 if (!ts->vref_mv) { in ads784x_hwmon_register()
568 dev_dbg(&spi->dev, "assuming 2.5V internal vREF\n"); in ads784x_hwmon_register()
569 ts->vref_mv = 2500; in ads784x_hwmon_register()
570 ts->use_internal = true; in ads784x_hwmon_register()
575 if (!ts->vref_mv) { in ads784x_hwmon_register()
576 dev_warn(&spi->dev, in ads784x_hwmon_register()
578 ts->model); in ads784x_hwmon_register()
584 hwmon = devm_hwmon_device_register_with_groups(&spi->dev, in ads784x_hwmon_register()
585 spi->modalias, ts, in ads784x_hwmon_register()
604 return sprintf(buf, "%u\n", ts->pendown); in ads7846_pen_down_show()
614 return sprintf(buf, "%u\n", ts->disabled); in ads7846_disable_show()
646 /*--------------------------------------------------------------------------*/
652 if (!ts->read_cnt || (abs(ts->last_read - *val) > ts->debounce_tol)) { in ads7846_debounce_filter()
654 ts->read_rep = 0; in ads7846_debounce_filter()
659 if (ts->read_cnt < ts->debounce_max) { in ads7846_debounce_filter()
660 ts->last_read = *val; in ads7846_debounce_filter()
661 ts->read_cnt++; in ads7846_debounce_filter()
670 ts->read_cnt = 0; in ads7846_debounce_filter()
674 if (++ts->read_rep > ts->debounce_rep) { in ads7846_debounce_filter()
679 ts->read_cnt = 0; in ads7846_debounce_filter()
680 ts->read_rep = 0; in ads7846_debounce_filter()
684 ts->read_cnt++; in ads7846_debounce_filter()
699 value = be16_to_cpup(&buf->data); in ads7846_get_value()
708 struct ads7846_packet *packet = ts->packet; in ads7846_set_cmd_val()
712 packet->y = val; in ads7846_set_cmd_val()
715 packet->x = val; in ads7846_set_cmd_val()
718 packet->z1 = val; in ads7846_set_cmd_val()
721 packet->z2 = val; in ads7846_set_cmd_val()
769 struct ads7846_packet *packet = ts->packet; in ads7846_filter()
774 packet->ignore = false; in ads7846_filter()
775 for (cmd_idx = packet->last_cmd_idx; cmd_idx < packet->cmds - 1; cmd_idx++) { in ads7846_filter()
776 struct ads7846_buf_layout *l = &packet->l[cmd_idx]; in ads7846_filter()
778 packet->last_cmd_idx = cmd_idx; in ads7846_filter()
780 for (b = l->skip; b < l->count; b++) { in ads7846_filter()
781 val = ads7846_get_value(&packet->rx[l->offset + b]); in ads7846_filter()
783 action = ts->filter(ts->filter_data, cmd_idx, &val); in ads7846_filter()
785 if (b == l->count - 1) in ads7846_filter()
786 return -EAGAIN; in ads7846_filter()
791 packet->ignore = true; in ads7846_filter()
802 if (ts->wait_for_sync) { in ads7846_wait_for_hsync()
803 ts->wait_for_sync(); in ads7846_wait_for_hsync()
807 if (!ts->gpio_hsync) in ads7846_wait_for_hsync()
814 while (!gpiod_get_value(ts->gpio_hsync)) in ads7846_wait_for_hsync()
817 /* Then we wait for it do de-assert */ in ads7846_wait_for_hsync()
818 while (gpiod_get_value(ts->gpio_hsync)) in ads7846_wait_for_hsync()
824 struct ads7846_packet *packet = ts->packet; in ads7846_read_state()
825 struct spi_message *m; in ads7846_read_state() local
829 packet->last_cmd_idx = 0; in ads7846_read_state()
834 m = &ts->msg[msg_idx]; in ads7846_read_state()
835 error = spi_sync(ts->spi, m); in ads7846_read_state()
837 dev_err_ratelimited(&ts->spi->dev, "spi_sync --> %d\n", error); in ads7846_read_state()
838 packet->ignore = true; in ads7846_read_state()
852 struct ads7846_packet *packet = ts->packet; in ads7846_report_state()
856 x = packet->x; in ads7846_report_state()
857 y = packet->y; in ads7846_report_state()
858 if (ts->model == 7845) { in ads7846_report_state()
862 z1 = packet->z1; in ads7846_report_state()
863 z2 = packet->z2; in ads7846_report_state()
870 if (ts->model == 7843 || ts->model == 7845) { in ads7846_report_state()
871 Rt = ts->pressure_max / 2; in ads7846_report_state()
875 Rt -= z1; in ads7846_report_state()
876 Rt *= ts->x_plate_ohms; in ads7846_report_state()
890 if (packet->ignore || Rt > ts->pressure_max) { in ads7846_report_state()
891 dev_vdbg(&ts->spi->dev, "ignored %d pressure %d\n", in ads7846_report_state()
892 packet->ignore, Rt); in ads7846_report_state()
900 if (ts->penirq_recheck_delay_usecs) { in ads7846_report_state()
901 udelay(ts->penirq_recheck_delay_usecs); in ads7846_report_state()
916 struct input_dev *input = ts->input; in ads7846_report_state() local
918 if (!ts->pendown) { in ads7846_report_state()
919 input_report_key(input, BTN_TOUCH, 1); in ads7846_report_state()
920 ts->pendown = true; in ads7846_report_state()
921 dev_vdbg(&ts->spi->dev, "DOWN\n"); in ads7846_report_state()
924 touchscreen_report_pos(input, &ts->core_prop, x, y, false); in ads7846_report_state()
925 input_report_abs(input, ABS_PRESSURE, ts->pressure_max - Rt); in ads7846_report_state()
927 input_sync(input); in ads7846_report_state()
928 dev_vdbg(&ts->spi->dev, "%4d/%4d/%4d\n", x, y, Rt); in ads7846_report_state()
947 while (!ts->stopped && get_pendown_state(ts)) { in ads7846_irq()
952 if (!ts->stopped) in ads7846_irq()
955 wait_event_timeout(ts->wait, ts->stopped, in ads7846_irq()
959 if (ts->pendown && !ts->stopped) in ads7846_irq()
969 mutex_lock(&ts->lock); in ads7846_suspend()
971 if (!ts->suspended) { in ads7846_suspend()
973 if (!ts->disabled) in ads7846_suspend()
976 if (device_may_wakeup(&ts->spi->dev)) in ads7846_suspend()
977 enable_irq_wake(ts->spi->irq); in ads7846_suspend()
979 ts->suspended = true; in ads7846_suspend()
982 mutex_unlock(&ts->lock); in ads7846_suspend()
991 mutex_lock(&ts->lock); in ads7846_resume()
993 if (ts->suspended) { in ads7846_resume()
995 ts->suspended = false; in ads7846_resume()
997 if (device_may_wakeup(&ts->spi->dev)) in ads7846_resume()
998 disable_irq_wake(ts->spi->irq); in ads7846_resume()
1000 if (!ts->disabled) in ads7846_resume()
1004 mutex_unlock(&ts->lock); in ads7846_resume()
1016 * REVISIT when the irq can be triggered active-low, or if for some in ads7846_setup_pendown()
1021 if (pdata->get_pendown_state) { in ads7846_setup_pendown()
1022 ts->get_pendown_state = pdata->get_pendown_state; in ads7846_setup_pendown()
1024 ts->gpio_pendown = gpiod_get(&spi->dev, "pendown", GPIOD_IN); in ads7846_setup_pendown()
1025 if (IS_ERR(ts->gpio_pendown)) { in ads7846_setup_pendown()
1026 dev_err(&spi->dev, "failed to request pendown GPIO\n"); in ads7846_setup_pendown()
1027 return PTR_ERR(ts->gpio_pendown); in ads7846_setup_pendown()
1029 if (pdata->gpio_pendown_debounce) in ads7846_setup_pendown()
1030 gpiod_set_debounce(ts->gpio_pendown, in ads7846_setup_pendown()
1031 pdata->gpio_pendown_debounce); in ads7846_setup_pendown()
1044 struct spi_message *m = &ts->msg[0]; in ads7846_setup_spi_msg() local
1045 struct spi_transfer *x = ts->xfer; in ads7846_setup_spi_msg()
1046 struct ads7846_packet *packet = ts->packet; in ads7846_setup_spi_msg()
1047 int vref = pdata->keep_vref_on; in ads7846_setup_spi_msg()
1054 time = NSEC_PER_SEC / ts->spi->max_speed_hz; in ads7846_setup_spi_msg()
1056 count = pdata->settle_delay_usecs * NSEC_PER_USEC / time; in ads7846_setup_spi_msg()
1057 packet->count_skip = DIV_ROUND_UP(count, 24); in ads7846_setup_spi_msg()
1059 if (ts->debounce_max && ts->debounce_rep) in ads7846_setup_spi_msg()
1060 /* ads7846_debounce_filter() is making ts->debounce_rep + 2 in ads7846_setup_spi_msg()
1062 packet->count = ts->debounce_rep + 2; in ads7846_setup_spi_msg()
1064 packet->count = 1; in ads7846_setup_spi_msg()
1066 if (ts->model == 7846) in ads7846_setup_spi_msg()
1067 packet->cmds = 5; /* x, y, z1, z2, pwdown */ in ads7846_setup_spi_msg()
1069 packet->cmds = 3; /* x, y, pwdown */ in ads7846_setup_spi_msg()
1071 for (cmd_idx = 0; cmd_idx < packet->cmds; cmd_idx++) { in ads7846_setup_spi_msg()
1072 struct ads7846_buf_layout *l = &packet->l[cmd_idx]; in ads7846_setup_spi_msg()
1075 if (cmd_idx == packet->cmds - 1) in ads7846_setup_spi_msg()
1079 max_count = packet->count + packet->count_skip; in ads7846_setup_spi_msg()
1081 max_count = packet->count; in ads7846_setup_spi_msg()
1083 l->offset = offset; in ads7846_setup_spi_msg()
1085 l->count = max_count; in ads7846_setup_spi_msg()
1086 l->skip = packet->count_skip; in ads7846_setup_spi_msg()
1087 size += sizeof(*packet->tx) * max_count; in ads7846_setup_spi_msg()
1090 packet->tx = devm_kzalloc(&ts->spi->dev, size, GFP_KERNEL); in ads7846_setup_spi_msg()
1091 if (!packet->tx) in ads7846_setup_spi_msg()
1092 return -ENOMEM; in ads7846_setup_spi_msg()
1094 packet->rx = devm_kzalloc(&ts->spi->dev, size, GFP_KERNEL); in ads7846_setup_spi_msg()
1095 if (!packet->rx) in ads7846_setup_spi_msg()
1096 return -ENOMEM; in ads7846_setup_spi_msg()
1098 if (ts->model == 7873) { in ads7846_setup_spi_msg()
1104 ts->model = 7846; in ads7846_setup_spi_msg()
1108 ts->msg_count = 1; in ads7846_setup_spi_msg()
1109 spi_message_init(m); in ads7846_setup_spi_msg()
1110 m->context = ts; in ads7846_setup_spi_msg()
1112 for (cmd_idx = 0; cmd_idx < packet->cmds; cmd_idx++) { in ads7846_setup_spi_msg()
1113 struct ads7846_buf_layout *l = &packet->l[cmd_idx]; in ads7846_setup_spi_msg()
1116 if (cmd_idx == packet->cmds - 1) in ads7846_setup_spi_msg()
1121 for (b = 0; b < l->count; b++) in ads7846_setup_spi_msg()
1122 packet->tx[l->offset + b].cmd = cmd; in ads7846_setup_spi_msg()
1125 x->tx_buf = packet->tx; in ads7846_setup_spi_msg()
1126 x->rx_buf = packet->rx; in ads7846_setup_spi_msg()
1127 x->len = size; in ads7846_setup_spi_msg()
1128 spi_message_add_tail(x, m); in ads7846_setup_spi_msg()
1160 return ERR_PTR(-ENOMEM); in ads7846_get_props()
1162 pdata->model = (uintptr_t)device_get_match_data(dev); in ads7846_get_props()
1164 device_property_read_u16(dev, "ti,vref-delay-usecs", in ads7846_get_props()
1165 &pdata->vref_delay_usecs); in ads7846_get_props()
1166 device_property_read_u16(dev, "ti,vref-mv", &pdata->vref_mv); in ads7846_get_props()
1167 pdata->keep_vref_on = device_property_read_bool(dev, "ti,keep-vref-on"); in ads7846_get_props()
1169 pdata->swap_xy = device_property_read_bool(dev, "ti,swap-xy"); in ads7846_get_props()
1171 device_property_read_u16(dev, "ti,settle-delay-usec", in ads7846_get_props()
1172 &pdata->settle_delay_usecs); in ads7846_get_props()
1173 device_property_read_u16(dev, "ti,penirq-recheck-delay-usecs", in ads7846_get_props()
1174 &pdata->penirq_recheck_delay_usecs); in ads7846_get_props()
1176 device_property_read_u16(dev, "ti,x-plate-ohms", &pdata->x_plate_ohms); in ads7846_get_props()
1177 device_property_read_u16(dev, "ti,y-plate-ohms", &pdata->y_plate_ohms); in ads7846_get_props()
1179 device_property_read_u16(dev, "ti,x-min", &pdata->x_min); in ads7846_get_props()
1180 device_property_read_u16(dev, "ti,y-min", &pdata->y_min); in ads7846_get_props()
1181 device_property_read_u16(dev, "ti,x-max", &pdata->x_max); in ads7846_get_props()
1182 device_property_read_u16(dev, "ti,y-max", &pdata->y_max); in ads7846_get_props()
1185 * touchscreen-max-pressure gets parsed during in ads7846_get_props()
1188 device_property_read_u16(dev, "ti,pressure-min", &pdata->pressure_min); in ads7846_get_props()
1189 if (!device_property_read_u32(dev, "touchscreen-min-pressure", &value)) in ads7846_get_props()
1190 pdata->pressure_min = (u16) value; in ads7846_get_props()
1191 device_property_read_u16(dev, "ti,pressure-max", &pdata->pressure_max); in ads7846_get_props()
1193 device_property_read_u16(dev, "ti,debounce-max", &pdata->debounce_max); in ads7846_get_props()
1194 if (!device_property_read_u32(dev, "touchscreen-average-samples", &value)) in ads7846_get_props()
1195 pdata->debounce_max = (u16) value; in ads7846_get_props()
1196 device_property_read_u16(dev, "ti,debounce-tol", &pdata->debounce_tol); in ads7846_get_props()
1197 device_property_read_u16(dev, "ti,debounce-rep", &pdata->debounce_rep); in ads7846_get_props()
1199 device_property_read_u32(dev, "ti,pendown-gpio-debounce", in ads7846_get_props()
1200 &pdata->gpio_pendown_debounce); in ads7846_get_props()
1202 pdata->wakeup = device_property_read_bool(dev, "wakeup-source") || in ads7846_get_props()
1217 struct device *dev = &spi->dev; in ads7846_probe()
1223 if (!spi->irq) { in ads7846_probe()
1225 return -EINVAL; in ads7846_probe()
1229 if (spi->max_speed_hz > (125000 * SAMPLE_BITS)) { in ads7846_probe()
1231 (spi->max_speed_hz/SAMPLE_BITS)/1000); in ads7846_probe()
1232 return -EINVAL; in ads7846_probe()
1236 * We'd set TX word size 8 bits and RX word size to 13 bits ... except in ads7846_probe()
1238 * may not. So we stick to very-portable 8 bit words, both RX and TX. in ads7846_probe()
1240 spi->bits_per_word = 8; in ads7846_probe()
1241 spi->mode &= ~SPI_MODE_X_MASK; in ads7846_probe()
1242 spi->mode |= SPI_MODE_0; in ads7846_probe()
1249 return -ENOMEM; in ads7846_probe()
1253 return -ENOMEM; in ads7846_probe()
1257 return -ENOMEM; in ads7846_probe()
1261 ts->packet = packet; in ads7846_probe()
1262 ts->spi = spi; in ads7846_probe()
1263 ts->input = input_dev; in ads7846_probe()
1265 mutex_init(&ts->lock); in ads7846_probe()
1266 init_waitqueue_head(&ts->wait); in ads7846_probe()
1275 ts->model = pdata->model ? : 7846; in ads7846_probe()
1276 ts->vref_delay_usecs = pdata->vref_delay_usecs ? : 100; in ads7846_probe()
1277 ts->x_plate_ohms = pdata->x_plate_ohms ? : 400; in ads7846_probe()
1278 ts->vref_mv = pdata->vref_mv; in ads7846_probe()
1280 if (pdata->debounce_max) { in ads7846_probe()
1281 ts->debounce_max = pdata->debounce_max; in ads7846_probe()
1282 if (ts->debounce_max < 2) in ads7846_probe()
1283 ts->debounce_max = 2; in ads7846_probe()
1284 ts->debounce_tol = pdata->debounce_tol; in ads7846_probe()
1285 ts->debounce_rep = pdata->debounce_rep; in ads7846_probe()
1286 ts->filter = ads7846_debounce_filter; in ads7846_probe()
1287 ts->filter_data = ts; in ads7846_probe()
1289 ts->filter = ads7846_no_filter; in ads7846_probe()
1296 if (pdata->penirq_recheck_delay_usecs) in ads7846_probe()
1297 ts->penirq_recheck_delay_usecs = in ads7846_probe()
1298 pdata->penirq_recheck_delay_usecs; in ads7846_probe()
1300 ts->wait_for_sync = pdata->wait_for_sync; in ads7846_probe()
1302 ts->gpio_hsync = devm_gpiod_get_optional(dev, "ti,hsync", GPIOD_IN); in ads7846_probe()
1303 if (IS_ERR(ts->gpio_hsync)) in ads7846_probe()
1304 return PTR_ERR(ts->gpio_hsync); in ads7846_probe()
1306 snprintf(ts->phys, sizeof(ts->phys), "%s/input0", dev_name(dev)); in ads7846_probe()
1307 snprintf(ts->name, sizeof(ts->name), "ADS%d Touchscreen", ts->model); in ads7846_probe()
1309 input_dev->name = ts->name; in ads7846_probe()
1310 input_dev->phys = ts->phys; in ads7846_probe()
1312 input_dev->id.bustype = BUS_SPI; in ads7846_probe()
1313 input_dev->id.product = pdata->model; in ads7846_probe()
1317 pdata->x_min ? : 0, in ads7846_probe()
1318 pdata->x_max ? : MAX_12BIT, in ads7846_probe()
1321 pdata->y_min ? : 0, in ads7846_probe()
1322 pdata->y_max ? : MAX_12BIT, in ads7846_probe()
1324 if (ts->model != 7845) in ads7846_probe()
1326 pdata->pressure_min, pdata->pressure_max, 0, 0); in ads7846_probe()
1333 touchscreen_parse_properties(ts->input, false, &ts->core_prop); in ads7846_probe()
1334 ts->pressure_max = input_abs_get_max(input_dev, ABS_PRESSURE) ? : ~0; in ads7846_probe()
1337 * Check if legacy ti,swap-xy binding is used instead of in ads7846_probe()
1338 * touchscreen-swapped-x-y in ads7846_probe()
1340 if (!ts->core_prop.swap_x_y && pdata->swap_xy) { in ads7846_probe()
1341 swap(input_dev->absinfo[ABS_X], input_dev->absinfo[ABS_Y]); in ads7846_probe()
1342 ts->core_prop.swap_x_y = true; in ads7846_probe()
1347 ts->reg = devm_regulator_get(dev, "vcc"); in ads7846_probe()
1348 if (IS_ERR(ts->reg)) { in ads7846_probe()
1349 err = PTR_ERR(ts->reg); in ads7846_probe()
1354 err = regulator_enable(ts->reg); in ads7846_probe()
1360 err = devm_add_action_or_reset(dev, ads7846_regulator_disable, ts->reg); in ads7846_probe()
1364 irq_flags = pdata->irq_flags ? : IRQF_TRIGGER_FALLING; in ads7846_probe()
1367 err = devm_request_threaded_irq(dev, spi->irq, in ads7846_probe()
1369 irq_flags, dev->driver->name, ts); in ads7846_probe()
1370 if (err && err != -EPROBE_DEFER && !pdata->irq_flags) { in ads7846_probe()
1372 "trying pin change workaround on irq %d\n", spi->irq); in ads7846_probe()
1374 err = devm_request_threaded_irq(dev, spi->irq, in ads7846_probe()
1376 irq_flags, dev->driver->name, in ads7846_probe()
1381 dev_dbg(dev, "irq %d busy?\n", spi->irq); in ads7846_probe()
1389 dev_info(dev, "touchscreen, irq %d\n", spi->irq); in ads7846_probe()
1395 if (ts->model == 7845) in ads7846_probe()
1404 device_init_wakeup(dev, pdata->wakeup); in ads7846_probe()