Lines Matching refs:ts
89 bool tsc2007_is_pen_down(struct tsc2007 *ts) in tsc2007_is_pen_down() argument
105 if (!ts->get_pendown_state) in tsc2007_is_pen_down()
108 return ts->get_pendown_state(&ts->client->dev); in tsc2007_is_pen_down()
113 struct tsc2007 *ts = handle; in tsc2007_soft_irq() local
114 struct input_dev *input = ts->input; in tsc2007_soft_irq()
118 while (!ts->stopped && tsc2007_is_pen_down(ts)) { in tsc2007_soft_irq()
122 mutex_lock(&ts->mlock); in tsc2007_soft_irq()
123 tsc2007_read_values(ts, &tc); in tsc2007_soft_irq()
124 mutex_unlock(&ts->mlock); in tsc2007_soft_irq()
126 rt = tsc2007_calculate_resistance(ts, &tc); in tsc2007_soft_irq()
128 if (!rt && !ts->get_pendown_state) { in tsc2007_soft_irq()
137 if (rt <= ts->max_rt) { in tsc2007_soft_irq()
138 dev_dbg(&ts->client->dev, in tsc2007_soft_irq()
142 rt = ts->max_rt - rt; in tsc2007_soft_irq()
157 dev_dbg(&ts->client->dev, "ignored pressure %d\n", rt); in tsc2007_soft_irq()
160 wait_event_timeout(ts->wait, ts->stopped, ts->poll_period); in tsc2007_soft_irq()
163 dev_dbg(&ts->client->dev, "UP\n"); in tsc2007_soft_irq()
169 if (ts->clear_penirq) in tsc2007_soft_irq()
170 ts->clear_penirq(); in tsc2007_soft_irq()
177 struct tsc2007 *ts = handle; in tsc2007_hard_irq() local
179 if (tsc2007_is_pen_down(ts)) in tsc2007_hard_irq()
182 if (ts->clear_penirq) in tsc2007_hard_irq()
183 ts->clear_penirq(); in tsc2007_hard_irq()
188 static void tsc2007_stop(struct tsc2007 *ts) in tsc2007_stop() argument
190 ts->stopped = true; in tsc2007_stop()
192 wake_up(&ts->wait); in tsc2007_stop()
194 disable_irq(ts->irq); in tsc2007_stop()
199 struct tsc2007 *ts = input_get_drvdata(input_dev); in tsc2007_open() local
202 ts->stopped = false; in tsc2007_open()
205 enable_irq(ts->irq); in tsc2007_open()
208 err = tsc2007_xfer(ts, PWRDOWN); in tsc2007_open()
210 tsc2007_stop(ts); in tsc2007_open()
219 struct tsc2007 *ts = input_get_drvdata(input_dev); in tsc2007_close() local
221 tsc2007_stop(ts); in tsc2007_close()
227 struct tsc2007 *ts = i2c_get_clientdata(client); in tsc2007_get_pendown_state_gpio() local
229 return gpiod_get_value(ts->gpiod); in tsc2007_get_pendown_state_gpio()
232 static int tsc2007_probe_properties(struct device *dev, struct tsc2007 *ts) in tsc2007_probe_properties() argument
238 ts->max_rt = val32; in tsc2007_probe_properties()
240 ts->max_rt = MAX_12BIT; in tsc2007_probe_properties()
243 ts->fuzzx = val32; in tsc2007_probe_properties()
246 ts->fuzzy = val32; in tsc2007_probe_properties()
249 ts->fuzzz = val32; in tsc2007_probe_properties()
252 ts->poll_period = msecs_to_jiffies(val64); in tsc2007_probe_properties()
254 ts->poll_period = msecs_to_jiffies(1); in tsc2007_probe_properties()
257 ts->x_plate_ohms = val32; in tsc2007_probe_properties()
263 ts->gpiod = devm_gpiod_get_optional(dev, NULL, GPIOD_IN); in tsc2007_probe_properties()
264 if (IS_ERR(ts->gpiod)) in tsc2007_probe_properties()
265 return PTR_ERR(ts->gpiod); in tsc2007_probe_properties()
267 if (ts->gpiod) in tsc2007_probe_properties()
268 ts->get_pendown_state = tsc2007_get_pendown_state_gpio; in tsc2007_probe_properties()
275 static int tsc2007_probe_pdev(struct device *dev, struct tsc2007 *ts, in tsc2007_probe_pdev() argument
279 ts->model = pdata->model; in tsc2007_probe_pdev()
280 ts->x_plate_ohms = pdata->x_plate_ohms; in tsc2007_probe_pdev()
281 ts->max_rt = pdata->max_rt ? : MAX_12BIT; in tsc2007_probe_pdev()
282 ts->poll_period = msecs_to_jiffies(pdata->poll_period ? : 1); in tsc2007_probe_pdev()
283 ts->get_pendown_state = pdata->get_pendown_state; in tsc2007_probe_pdev()
284 ts->clear_penirq = pdata->clear_penirq; in tsc2007_probe_pdev()
285 ts->fuzzx = pdata->fuzzx; in tsc2007_probe_pdev()
286 ts->fuzzy = pdata->fuzzy; in tsc2007_probe_pdev()
287 ts->fuzzz = pdata->fuzzz; in tsc2007_probe_pdev()
310 struct tsc2007 *ts; in tsc2007_probe() local
318 ts = devm_kzalloc(&client->dev, sizeof(struct tsc2007), GFP_KERNEL); in tsc2007_probe()
319 if (!ts) in tsc2007_probe()
323 err = tsc2007_probe_pdev(&client->dev, ts, pdata, id); in tsc2007_probe()
325 err = tsc2007_probe_properties(&client->dev, ts); in tsc2007_probe()
333 i2c_set_clientdata(client, ts); in tsc2007_probe()
335 ts->client = client; in tsc2007_probe()
336 ts->irq = client->irq; in tsc2007_probe()
337 ts->input = input_dev; in tsc2007_probe()
339 init_waitqueue_head(&ts->wait); in tsc2007_probe()
340 mutex_init(&ts->mlock); in tsc2007_probe()
342 snprintf(ts->phys, sizeof(ts->phys), in tsc2007_probe()
346 input_dev->phys = ts->phys; in tsc2007_probe()
352 input_set_drvdata(input_dev, ts); in tsc2007_probe()
356 input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, ts->fuzzx, 0); in tsc2007_probe()
357 input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, ts->fuzzy, 0); in tsc2007_probe()
359 ts->fuzzz, 0); in tsc2007_probe()
378 err = devm_request_threaded_irq(&client->dev, ts->irq, in tsc2007_probe()
381 client->dev.driver->name, ts); in tsc2007_probe()
384 ts->irq, err); in tsc2007_probe()
388 tsc2007_stop(ts); in tsc2007_probe()
391 err = tsc2007_xfer(ts, PWRDOWN); in tsc2007_probe()
405 err = tsc2007_iio_configure(ts); in tsc2007_probe()