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()
175 static void tsc2007_stop(struct tsc2007 *ts) in tsc2007_stop() argument
177 ts->stopped = true; in tsc2007_stop()
179 wake_up(&ts->wait); in tsc2007_stop()
181 disable_irq(ts->irq); in tsc2007_stop()
186 struct tsc2007 *ts = input_get_drvdata(input_dev); in tsc2007_open() local
189 ts->stopped = false; in tsc2007_open()
192 enable_irq(ts->irq); in tsc2007_open()
195 err = tsc2007_xfer(ts, PWRDOWN); in tsc2007_open()
197 tsc2007_stop(ts); in tsc2007_open()
206 struct tsc2007 *ts = input_get_drvdata(input_dev); in tsc2007_close() local
208 tsc2007_stop(ts); in tsc2007_close()
214 struct tsc2007 *ts = i2c_get_clientdata(client); in tsc2007_get_pendown_state_gpio() local
216 return gpiod_get_value_cansleep(ts->gpiod); in tsc2007_get_pendown_state_gpio()
219 static int tsc2007_probe_properties(struct device *dev, struct tsc2007 *ts) in tsc2007_probe_properties() argument
225 ts->max_rt = val32; in tsc2007_probe_properties()
227 ts->max_rt = MAX_12BIT; in tsc2007_probe_properties()
230 ts->fuzzx = val32; in tsc2007_probe_properties()
233 ts->fuzzy = val32; in tsc2007_probe_properties()
236 ts->fuzzz = val32; in tsc2007_probe_properties()
239 ts->poll_period = msecs_to_jiffies(val64); in tsc2007_probe_properties()
241 ts->poll_period = msecs_to_jiffies(1); in tsc2007_probe_properties()
244 ts->x_plate_ohms = val32; in tsc2007_probe_properties()
250 ts->gpiod = devm_gpiod_get_optional(dev, NULL, GPIOD_IN); in tsc2007_probe_properties()
251 if (IS_ERR(ts->gpiod)) in tsc2007_probe_properties()
252 return PTR_ERR(ts->gpiod); in tsc2007_probe_properties()
254 if (ts->gpiod) in tsc2007_probe_properties()
255 ts->get_pendown_state = tsc2007_get_pendown_state_gpio; in tsc2007_probe_properties()
262 static int tsc2007_probe_pdev(struct device *dev, struct tsc2007 *ts, in tsc2007_probe_pdev() argument
266 ts->model = pdata->model; in tsc2007_probe_pdev()
267 ts->x_plate_ohms = pdata->x_plate_ohms; in tsc2007_probe_pdev()
268 ts->max_rt = pdata->max_rt ? : MAX_12BIT; in tsc2007_probe_pdev()
269 ts->poll_period = msecs_to_jiffies(pdata->poll_period ? : 1); in tsc2007_probe_pdev()
270 ts->get_pendown_state = pdata->get_pendown_state; in tsc2007_probe_pdev()
271 ts->clear_penirq = pdata->clear_penirq; in tsc2007_probe_pdev()
272 ts->fuzzx = pdata->fuzzx; in tsc2007_probe_pdev()
273 ts->fuzzy = pdata->fuzzy; in tsc2007_probe_pdev()
274 ts->fuzzz = pdata->fuzzz; in tsc2007_probe_pdev()
297 struct tsc2007 *ts; in tsc2007_probe() local
305 ts = devm_kzalloc(&client->dev, sizeof(struct tsc2007), GFP_KERNEL); in tsc2007_probe()
306 if (!ts) in tsc2007_probe()
310 err = tsc2007_probe_pdev(&client->dev, ts, pdata, id); in tsc2007_probe()
312 err = tsc2007_probe_properties(&client->dev, ts); in tsc2007_probe()
320 i2c_set_clientdata(client, ts); in tsc2007_probe()
322 ts->client = client; in tsc2007_probe()
323 ts->irq = client->irq; in tsc2007_probe()
324 ts->input = input_dev; in tsc2007_probe()
326 init_waitqueue_head(&ts->wait); in tsc2007_probe()
327 mutex_init(&ts->mlock); in tsc2007_probe()
329 snprintf(ts->phys, sizeof(ts->phys), in tsc2007_probe()
333 input_dev->phys = ts->phys; in tsc2007_probe()
339 input_set_drvdata(input_dev, ts); in tsc2007_probe()
343 input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, ts->fuzzx, 0); in tsc2007_probe()
344 input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, ts->fuzzy, 0); in tsc2007_probe()
346 ts->fuzzz, 0); in tsc2007_probe()
365 err = devm_request_threaded_irq(&client->dev, ts->irq, in tsc2007_probe()
368 client->dev.driver->name, ts); in tsc2007_probe()
371 ts->irq, err); in tsc2007_probe()
375 tsc2007_stop(ts); in tsc2007_probe()
378 err = tsc2007_xfer(ts, PWRDOWN); in tsc2007_probe()
392 err = tsc2007_iio_configure(ts); in tsc2007_probe()