Lines Matching +full:0 +full:- +full:1023

1 // SPDX-License-Identifier: GPL-2.0-or-later
18 #define TSI_PEN_DOWN_STATUS 0x40
30 da9052_reg_update(tsi->da9052, DA9052_TSI_CONT_A_REG, 1 << 0, on); in da9052_ts_adc_toggle()
31 tsi->adc_on = on; in da9052_ts_adc_toggle()
38 if (!tsi->stopped) { in da9052_ts_pendwn_irq()
40 da9052_disable_irq_nosync(tsi->da9052, DA9052_IRQ_PENDOWN); in da9052_ts_pendwn_irq()
41 da9052_enable_irq(tsi->da9052, DA9052_IRQ_TSIREADY); in da9052_ts_pendwn_irq()
45 schedule_delayed_work(&tsi->ts_pen_work, HZ / 50); in da9052_ts_pendwn_irq()
53 struct input_dev *input = tsi->dev; in da9052_ts_read()
58 ret = da9052_reg_read(tsi->da9052, DA9052_TSI_X_MSB_REG); in da9052_ts_read()
59 if (ret < 0) in da9052_ts_read()
64 ret = da9052_reg_read(tsi->da9052, DA9052_TSI_Y_MSB_REG); in da9052_ts_read()
65 if (ret < 0) in da9052_ts_read()
70 ret = da9052_reg_read(tsi->da9052, DA9052_TSI_Z_MSB_REG); in da9052_ts_read()
71 if (ret < 0) in da9052_ts_read()
76 ret = da9052_reg_read(tsi->da9052, DA9052_TSI_LSB_REG); in da9052_ts_read()
77 if (ret < 0) in da9052_ts_read()
82 x = ((x << 2) & 0x3fc) | (v & 0x3); in da9052_ts_read()
83 y = ((y << 2) & 0x3fc) | ((v & 0xc) >> 2); in da9052_ts_read()
84 z = ((z << 2) & 0x3fc) | ((v & 0x30) >> 4); in da9052_ts_read()
106 if (!tsi->stopped) { in da9052_ts_pen_work()
107 int ret = da9052_reg_read(tsi->da9052, DA9052_TSI_LSB_REG); in da9052_ts_pen_work()
108 if (ret < 0 || (ret & TSI_PEN_DOWN_STATUS)) { in da9052_ts_pen_work()
110 schedule_delayed_work(&tsi->ts_pen_work, HZ / 50); in da9052_ts_pen_work()
112 struct input_dev *input = tsi->dev; in da9052_ts_pen_work()
118 input_report_key(input, BTN_TOUCH, 0); in da9052_ts_pen_work()
119 input_report_abs(input, ABS_PRESSURE, 0); in da9052_ts_pen_work()
126 ret = da9052_reg_update(tsi->da9052, in da9052_ts_pen_work()
127 DA9052_EVENT_B_REG, 0xC0, 0xC0); in da9052_ts_pen_work()
128 if (ret < 0) in da9052_ts_pen_work()
132 da9052_disable_irq(tsi->da9052, DA9052_IRQ_TSIREADY); in da9052_ts_pen_work()
133 da9052_enable_irq(tsi->da9052, DA9052_IRQ_PENDOWN); in da9052_ts_pen_work()
142 error = da9052_reg_update(da9052, DA9052_GPIO_2_3_REG, 0x30, 0); in da9052_ts_configure_gpio()
143 if (error < 0) in da9052_ts_configure_gpio()
146 error = da9052_reg_update(da9052, DA9052_GPIO_4_5_REG, 0x33, 0); in da9052_ts_configure_gpio()
147 if (error < 0) in da9052_ts_configure_gpio()
150 error = da9052_reg_update(da9052, DA9052_GPIO_6_7_REG, 0x33, 0); in da9052_ts_configure_gpio()
151 if (error < 0) in da9052_ts_configure_gpio()
154 return 0; in da9052_ts_configure_gpio()
161 error = da9052_ts_configure_gpio(tsi->da9052); in da9052_configure_tsi()
166 error = da9052_reg_update(tsi->da9052, DA9052_ADC_CONT_REG, in da9052_configure_tsi()
168 if (error < 0) in da9052_configure_tsi()
171 /* TSI_DELAY: 3 slots, TSI_SKIP: 0 slots, TSI_MODE: XYZP */ in da9052_configure_tsi()
172 error = da9052_reg_update(tsi->da9052, DA9052_TSI_CONT_A_REG, 0xFC, 0xC0); in da9052_configure_tsi()
173 if (error < 0) in da9052_configure_tsi()
177 error = da9052_reg_write(tsi->da9052, DA9052_LDO9_REG, 0x59); in da9052_configure_tsi()
178 if (error < 0) in da9052_configure_tsi()
181 return 0; in da9052_configure_tsi()
188 tsi->stopped = false; in da9052_ts_input_open()
192 da9052_enable_irq(tsi->da9052, DA9052_IRQ_PENDOWN); in da9052_ts_input_open()
195 return da9052_reg_update(tsi->da9052, DA9052_TSI_CONT_A_REG, in da9052_ts_input_open()
203 tsi->stopped = true; in da9052_ts_input_close()
205 da9052_disable_irq(tsi->da9052, DA9052_IRQ_PENDOWN); in da9052_ts_input_close()
206 cancel_delayed_work_sync(&tsi->ts_pen_work); in da9052_ts_input_close()
208 if (tsi->adc_on) { in da9052_ts_input_close()
209 da9052_disable_irq(tsi->da9052, DA9052_IRQ_TSIREADY); in da9052_ts_input_close()
217 da9052_enable_irq(tsi->da9052, DA9052_IRQ_PENDOWN); in da9052_ts_input_close()
221 da9052_reg_update(tsi->da9052, DA9052_TSI_CONT_A_REG, 1 << 1, 0); in da9052_ts_input_close()
231 da9052 = dev_get_drvdata(pdev->dev.parent); in da9052_ts_probe()
233 return -EINVAL; in da9052_ts_probe()
238 error = -ENOMEM; in da9052_ts_probe()
242 tsi->da9052 = da9052; in da9052_ts_probe()
243 tsi->dev = input_dev; in da9052_ts_probe()
244 tsi->stopped = true; in da9052_ts_probe()
245 INIT_DELAYED_WORK(&tsi->ts_pen_work, da9052_ts_pen_work); in da9052_ts_probe()
247 input_dev->id.version = 0x0101; in da9052_ts_probe()
248 input_dev->id.vendor = 0x15B6; in da9052_ts_probe()
249 input_dev->id.product = 0x9052; in da9052_ts_probe()
250 input_dev->name = "Dialog DA9052 TouchScreen Driver"; in da9052_ts_probe()
251 input_dev->dev.parent = &pdev->dev; in da9052_ts_probe()
252 input_dev->open = da9052_ts_input_open; in da9052_ts_probe()
253 input_dev->close = da9052_ts_input_close; in da9052_ts_probe()
255 __set_bit(EV_ABS, input_dev->evbit); in da9052_ts_probe()
256 __set_bit(EV_KEY, input_dev->evbit); in da9052_ts_probe()
257 __set_bit(BTN_TOUCH, input_dev->keybit); in da9052_ts_probe()
259 input_set_abs_params(input_dev, ABS_X, 0, 1023, 0, 0); in da9052_ts_probe()
260 input_set_abs_params(input_dev, ABS_Y, 0, 1023, 0, 0); in da9052_ts_probe()
261 input_set_abs_params(input_dev, ABS_PRESSURE, 0, 1023, 0, 0); in da9052_ts_probe()
266 da9052_reg_update(tsi->da9052, DA9052_TSI_CONT_A_REG, 1 << 1, 0); in da9052_ts_probe()
271 error = da9052_request_irq(tsi->da9052, DA9052_IRQ_PENDOWN, in da9052_ts_probe()
272 "pendown-irq", da9052_ts_pendwn_irq, tsi); in da9052_ts_probe()
274 dev_err(tsi->da9052->dev, in da9052_ts_probe()
279 error = da9052_request_irq(tsi->da9052, DA9052_IRQ_TSIREADY, in da9052_ts_probe()
280 "tsiready-irq", da9052_ts_datardy_irq, tsi); in da9052_ts_probe()
282 dev_err(tsi->da9052->dev, in da9052_ts_probe()
288 da9052_disable_irq(tsi->da9052, DA9052_IRQ_PENDOWN); in da9052_ts_probe()
289 da9052_disable_irq(tsi->da9052, DA9052_IRQ_TSIREADY); in da9052_ts_probe()
295 error = input_register_device(tsi->dev); in da9052_ts_probe()
301 return 0; in da9052_ts_probe()
304 da9052_free_irq(tsi->da9052, DA9052_IRQ_TSIREADY, tsi); in da9052_ts_probe()
306 da9052_free_irq(tsi->da9052, DA9052_IRQ_PENDOWN, tsi); in da9052_ts_probe()
318 da9052_reg_write(tsi->da9052, DA9052_LDO9_REG, 0x19); in da9052_ts_remove()
320 da9052_free_irq(tsi->da9052, DA9052_IRQ_TSIREADY, tsi); in da9052_ts_remove()
321 da9052_free_irq(tsi->da9052, DA9052_IRQ_PENDOWN, tsi); in da9052_ts_remove()
323 input_unregister_device(tsi->dev); in da9052_ts_remove()
326 return 0; in da9052_ts_remove()
333 .name = "da9052-tsi",
342 MODULE_ALIAS("platform:da9052-tsi");