• Home
  • Raw
  • Download

Lines Matching refs:ts

139 static int ad7879_read(struct ad7879 *ts, u8 reg)  in ad7879_read()  argument
141 return ts->bops->read(ts->dev, reg); in ad7879_read()
144 static int ad7879_multi_read(struct ad7879 *ts, u8 first_reg, u8 count, u16 *buf) in ad7879_multi_read() argument
146 return ts->bops->multi_read(ts->dev, first_reg, count, buf); in ad7879_multi_read()
149 static int ad7879_write(struct ad7879 *ts, u8 reg, u16 val) in ad7879_write() argument
151 return ts->bops->write(ts->dev, reg, val); in ad7879_write()
154 static int ad7879_report(struct ad7879 *ts) in ad7879_report() argument
156 struct input_dev *input_dev = ts->input; in ad7879_report()
160 x = ts->conversion_data[AD7879_SEQ_XPOS] & MAX_12BIT; in ad7879_report()
161 y = ts->conversion_data[AD7879_SEQ_YPOS] & MAX_12BIT; in ad7879_report()
162 z1 = ts->conversion_data[AD7879_SEQ_Z1] & MAX_12BIT; in ad7879_report()
163 z2 = ts->conversion_data[AD7879_SEQ_Z2] & MAX_12BIT; in ad7879_report()
165 if (ts->swap_xy) in ad7879_report()
182 Rt = (z2 - z1) * x * ts->x_plate_ohms; in ad7879_report()
190 if (Rt > ts->pressure_max) in ad7879_report()
199 if (timer_pending(&ts->timer)) { in ad7879_report()
202 input_report_abs(input_dev, ABS_X, ts->x); in ad7879_report()
203 input_report_abs(input_dev, ABS_Y, ts->y); in ad7879_report()
204 input_report_abs(input_dev, ABS_PRESSURE, ts->Rt); in ad7879_report()
208 ts->x = x; in ad7879_report()
209 ts->y = y; in ad7879_report()
210 ts->Rt = Rt; in ad7879_report()
218 static void ad7879_ts_event_release(struct ad7879 *ts) in ad7879_ts_event_release() argument
220 struct input_dev *input_dev = ts->input; in ad7879_ts_event_release()
229 struct ad7879 *ts = (void *)handle; in ad7879_timer() local
231 ad7879_ts_event_release(ts); in ad7879_timer()
236 struct ad7879 *ts = handle; in ad7879_irq() local
238 ad7879_multi_read(ts, AD7879_REG_XPLUS, AD7879_NR_SENSE, ts->conversion_data); in ad7879_irq()
240 if (!ad7879_report(ts)) in ad7879_irq()
241 mod_timer(&ts->timer, jiffies + TS_PEN_UP_TIMEOUT); in ad7879_irq()
246 static void __ad7879_enable(struct ad7879 *ts) in __ad7879_enable() argument
248 ad7879_write(ts, AD7879_REG_CTRL2, ts->cmd_crtl2); in __ad7879_enable()
249 ad7879_write(ts, AD7879_REG_CTRL3, ts->cmd_crtl3); in __ad7879_enable()
250 ad7879_write(ts, AD7879_REG_CTRL1, ts->cmd_crtl1); in __ad7879_enable()
252 enable_irq(ts->irq); in __ad7879_enable()
255 static void __ad7879_disable(struct ad7879 *ts) in __ad7879_disable() argument
257 u16 reg = (ts->cmd_crtl2 & ~AD7879_PM(-1)) | in __ad7879_disable()
259 disable_irq(ts->irq); in __ad7879_disable()
261 if (del_timer_sync(&ts->timer)) in __ad7879_disable()
262 ad7879_ts_event_release(ts); in __ad7879_disable()
264 ad7879_write(ts, AD7879_REG_CTRL2, reg); in __ad7879_disable()
270 struct ad7879 *ts = input_get_drvdata(input); in ad7879_open() local
273 if (!ts->disabled && !ts->suspended) in ad7879_open()
274 __ad7879_enable(ts); in ad7879_open()
281 struct ad7879 *ts = input_get_drvdata(input); in ad7879_close() local
284 if (!ts->disabled && !ts->suspended) in ad7879_close()
285 __ad7879_disable(ts); in ad7879_close()
291 struct ad7879 *ts = dev_get_drvdata(dev); in ad7879_suspend() local
293 mutex_lock(&ts->input->mutex); in ad7879_suspend()
295 if (!ts->suspended && !ts->disabled && ts->input->users) in ad7879_suspend()
296 __ad7879_disable(ts); in ad7879_suspend()
298 ts->suspended = true; in ad7879_suspend()
300 mutex_unlock(&ts->input->mutex); in ad7879_suspend()
307 struct ad7879 *ts = dev_get_drvdata(dev); in ad7879_resume() local
309 mutex_lock(&ts->input->mutex); in ad7879_resume()
311 if (ts->suspended && !ts->disabled && ts->input->users) in ad7879_resume()
312 __ad7879_enable(ts); in ad7879_resume()
314 ts->suspended = false; in ad7879_resume()
316 mutex_unlock(&ts->input->mutex); in ad7879_resume()
325 static void ad7879_toggle(struct ad7879 *ts, bool disable) in ad7879_toggle() argument
327 mutex_lock(&ts->input->mutex); in ad7879_toggle()
329 if (!ts->suspended && ts->input->users != 0) { in ad7879_toggle()
332 if (ts->disabled) in ad7879_toggle()
333 __ad7879_enable(ts); in ad7879_toggle()
335 if (!ts->disabled) in ad7879_toggle()
336 __ad7879_disable(ts); in ad7879_toggle()
340 ts->disabled = disable; in ad7879_toggle()
342 mutex_unlock(&ts->input->mutex); in ad7879_toggle()
348 struct ad7879 *ts = dev_get_drvdata(dev); in ad7879_disable_show() local
350 return sprintf(buf, "%u\n", ts->disabled); in ad7879_disable_show()
357 struct ad7879 *ts = dev_get_drvdata(dev); in ad7879_disable_store() local
365 ad7879_toggle(ts, val); in ad7879_disable_store()
385 struct ad7879 *ts = container_of(chip, struct ad7879, gc); in ad7879_gpio_direction_input() local
388 mutex_lock(&ts->mutex); in ad7879_gpio_direction_input()
389 ts->cmd_crtl2 |= AD7879_GPIO_EN | AD7879_GPIODIR | AD7879_GPIOPOL; in ad7879_gpio_direction_input()
390 err = ad7879_write(ts, AD7879_REG_CTRL2, ts->cmd_crtl2); in ad7879_gpio_direction_input()
391 mutex_unlock(&ts->mutex); in ad7879_gpio_direction_input()
399 struct ad7879 *ts = container_of(chip, struct ad7879, gc); in ad7879_gpio_direction_output() local
402 mutex_lock(&ts->mutex); in ad7879_gpio_direction_output()
403 ts->cmd_crtl2 &= ~AD7879_GPIODIR; in ad7879_gpio_direction_output()
404 ts->cmd_crtl2 |= AD7879_GPIO_EN | AD7879_GPIOPOL; in ad7879_gpio_direction_output()
406 ts->cmd_crtl2 |= AD7879_GPIO_DATA; in ad7879_gpio_direction_output()
408 ts->cmd_crtl2 &= ~AD7879_GPIO_DATA; in ad7879_gpio_direction_output()
410 err = ad7879_write(ts, AD7879_REG_CTRL2, ts->cmd_crtl2); in ad7879_gpio_direction_output()
411 mutex_unlock(&ts->mutex); in ad7879_gpio_direction_output()
418 struct ad7879 *ts = container_of(chip, struct ad7879, gc); in ad7879_gpio_get_value() local
421 mutex_lock(&ts->mutex); in ad7879_gpio_get_value()
422 val = ad7879_read(ts, AD7879_REG_CTRL2); in ad7879_gpio_get_value()
423 mutex_unlock(&ts->mutex); in ad7879_gpio_get_value()
431 struct ad7879 *ts = container_of(chip, struct ad7879, gc); in ad7879_gpio_set_value() local
433 mutex_lock(&ts->mutex); in ad7879_gpio_set_value()
435 ts->cmd_crtl2 |= AD7879_GPIO_DATA; in ad7879_gpio_set_value()
437 ts->cmd_crtl2 &= ~AD7879_GPIO_DATA; in ad7879_gpio_set_value()
439 ad7879_write(ts, AD7879_REG_CTRL2, ts->cmd_crtl2); in ad7879_gpio_set_value()
440 mutex_unlock(&ts->mutex); in ad7879_gpio_set_value()
443 static int ad7879_gpio_add(struct ad7879 *ts, in ad7879_gpio_add() argument
448 mutex_init(&ts->mutex); in ad7879_gpio_add()
451 ts->gc.direction_input = ad7879_gpio_direction_input; in ad7879_gpio_add()
452 ts->gc.direction_output = ad7879_gpio_direction_output; in ad7879_gpio_add()
453 ts->gc.get = ad7879_gpio_get_value; in ad7879_gpio_add()
454 ts->gc.set = ad7879_gpio_set_value; in ad7879_gpio_add()
455 ts->gc.can_sleep = 1; in ad7879_gpio_add()
456 ts->gc.base = pdata->gpio_base; in ad7879_gpio_add()
457 ts->gc.ngpio = 1; in ad7879_gpio_add()
458 ts->gc.label = "AD7879-GPIO"; in ad7879_gpio_add()
459 ts->gc.owner = THIS_MODULE; in ad7879_gpio_add()
460 ts->gc.dev = ts->dev; in ad7879_gpio_add()
462 ret = gpiochip_add(&ts->gc); in ad7879_gpio_add()
464 dev_err(ts->dev, "failed to register gpio %d\n", in ad7879_gpio_add()
465 ts->gc.base); in ad7879_gpio_add()
471 static void ad7879_gpio_remove(struct ad7879 *ts) in ad7879_gpio_remove() argument
473 const struct ad7879_platform_data *pdata = ts->dev->platform_data; in ad7879_gpio_remove()
477 ret = gpiochip_remove(&ts->gc); in ad7879_gpio_remove()
479 dev_err(ts->dev, "failed to remove gpio %d\n", in ad7879_gpio_remove()
480 ts->gc.base); in ad7879_gpio_remove()
484 static inline int ad7879_gpio_add(struct ad7879 *ts, in ad7879_gpio_add() argument
490 static inline void ad7879_gpio_remove(struct ad7879 *ts) in ad7879_gpio_remove() argument
499 struct ad7879 *ts; in ad7879_probe() local
516 ts = kzalloc(sizeof(*ts), GFP_KERNEL); in ad7879_probe()
518 if (!ts || !input_dev) { in ad7879_probe()
523 ts->bops = bops; in ad7879_probe()
524 ts->dev = dev; in ad7879_probe()
525 ts->input = input_dev; in ad7879_probe()
526 ts->irq = irq; in ad7879_probe()
527 ts->swap_xy = pdata->swap_xy; in ad7879_probe()
529 setup_timer(&ts->timer, ad7879_timer, (unsigned long) ts); in ad7879_probe()
531 ts->x_plate_ohms = pdata->x_plate_ohms ? : 400; in ad7879_probe()
532 ts->pressure_max = pdata->pressure_max ? : ~0; in ad7879_probe()
534 ts->first_conversion_delay = pdata->first_conversion_delay; in ad7879_probe()
535 ts->acquisition_time = pdata->acquisition_time; in ad7879_probe()
536 ts->averaging = pdata->averaging; in ad7879_probe()
537 ts->pen_down_acc_interval = pdata->pen_down_acc_interval; in ad7879_probe()
538 ts->median = pdata->median; in ad7879_probe()
540 snprintf(ts->phys, sizeof(ts->phys), "%s/input0", dev_name(dev)); in ad7879_probe()
543 input_dev->phys = ts->phys; in ad7879_probe()
550 input_set_drvdata(input_dev, ts); in ad7879_probe()
571 err = ad7879_write(ts, AD7879_REG_CTRL2, AD7879_RESET); in ad7879_probe()
577 revid = ad7879_read(ts, AD7879_REG_REVID); in ad7879_probe()
587 ts->cmd_crtl3 = AD7879_YPLUS_BIT | in ad7879_probe()
595 ts->cmd_crtl2 = AD7879_PM(AD7879_PM_DYN) | AD7879_DFR | in ad7879_probe()
596 AD7879_AVG(ts->averaging) | in ad7879_probe()
597 AD7879_MFS(ts->median) | in ad7879_probe()
598 AD7879_FCD(ts->first_conversion_delay); in ad7879_probe()
600 ts->cmd_crtl1 = AD7879_MODE_INT | AD7879_MODE_SEQ1 | in ad7879_probe()
601 AD7879_ACQ(ts->acquisition_time) | in ad7879_probe()
602 AD7879_TMR(ts->pen_down_acc_interval); in ad7879_probe()
604 err = request_threaded_irq(ts->irq, NULL, ad7879_irq, in ad7879_probe()
606 dev_name(dev), ts); in ad7879_probe()
608 dev_err(dev, "irq %d busy?\n", ts->irq); in ad7879_probe()
612 __ad7879_disable(ts); in ad7879_probe()
618 err = ad7879_gpio_add(ts, pdata); in ad7879_probe()
626 return ts; in ad7879_probe()
629 ad7879_gpio_remove(ts); in ad7879_probe()
633 free_irq(ts->irq, ts); in ad7879_probe()
636 kfree(ts); in ad7879_probe()
642 void ad7879_remove(struct ad7879 *ts) in ad7879_remove() argument
644 ad7879_gpio_remove(ts); in ad7879_remove()
645 sysfs_remove_group(&ts->dev->kobj, &ad7879_attr_group); in ad7879_remove()
646 free_irq(ts->irq, ts); in ad7879_remove()
647 input_unregister_device(ts->input); in ad7879_remove()
648 kfree(ts); in ad7879_remove()