Lines Matching full:ts
256 struct ad7877 *ts = spi_get_drvdata(spi); in ad7877_read_adc() local
270 AD7877_POL(ts->stopacq_polarity) | in ad7877_read_adc()
272 AD7877_ACQ(ts->acquisition_time) | AD7877_FCD(0); in ad7877_read_adc()
284 req->xfer[1].delay.value = ts->vref_delay_usecs; in ad7877_read_adc()
290 req->xfer[2].delay.value = ts->vref_delay_usecs; in ad7877_read_adc()
298 req->xfer[4].tx_buf = &ts->cmd_crtl2; /*REF OFF*/ in ad7877_read_adc()
302 req->xfer[5].tx_buf = &ts->cmd_crtl1; /*DEFAULT*/ in ad7877_read_adc()
319 static int ad7877_process_data(struct ad7877 *ts) in ad7877_process_data() argument
321 struct input_dev *input_dev = ts->input; in ad7877_process_data()
325 x = ts->conversion_data[AD7877_SEQ_XPOS] & MAX_12BIT; in ad7877_process_data()
326 y = ts->conversion_data[AD7877_SEQ_YPOS] & MAX_12BIT; in ad7877_process_data()
327 z1 = ts->conversion_data[AD7877_SEQ_Z1] & MAX_12BIT; in ad7877_process_data()
328 z2 = ts->conversion_data[AD7877_SEQ_Z2] & MAX_12BIT; in ad7877_process_data()
342 Rt = (z2 - z1) * x * ts->x_plate_ohms; in ad7877_process_data()
350 if (Rt > ts->pressure_max) in ad7877_process_data()
353 if (!timer_pending(&ts->timer)) in ad7877_process_data()
367 static inline void ad7877_ts_event_release(struct ad7877 *ts) in ad7877_ts_event_release() argument
369 struct input_dev *input_dev = ts->input; in ad7877_ts_event_release()
378 struct ad7877 *ts = from_timer(ts, t, timer); in ad7877_timer() local
381 spin_lock_irqsave(&ts->lock, flags); in ad7877_timer()
382 ad7877_ts_event_release(ts); in ad7877_timer()
383 spin_unlock_irqrestore(&ts->lock, flags); in ad7877_timer()
388 struct ad7877 *ts = handle; in ad7877_irq() local
392 error = spi_sync(ts->spi, &ts->msg); in ad7877_irq()
394 dev_err(&ts->spi->dev, "spi_sync --> %d\n", error); in ad7877_irq()
398 spin_lock_irqsave(&ts->lock, flags); in ad7877_irq()
399 error = ad7877_process_data(ts); in ad7877_irq()
401 mod_timer(&ts->timer, jiffies + TS_PEN_UP_TIMEOUT); in ad7877_irq()
402 spin_unlock_irqrestore(&ts->lock, flags); in ad7877_irq()
410 struct ad7877 *ts = data; in ad7877_disable() local
412 mutex_lock(&ts->mutex); in ad7877_disable()
414 if (!ts->disabled) { in ad7877_disable()
415 ts->disabled = true; in ad7877_disable()
416 disable_irq(ts->spi->irq); in ad7877_disable()
418 if (del_timer_sync(&ts->timer)) in ad7877_disable()
419 ad7877_ts_event_release(ts); in ad7877_disable()
427 mutex_unlock(&ts->mutex); in ad7877_disable()
430 static void ad7877_enable(struct ad7877 *ts) in ad7877_enable() argument
432 mutex_lock(&ts->mutex); in ad7877_enable()
434 if (ts->disabled) { in ad7877_enable()
435 ts->disabled = false; in ad7877_enable()
436 enable_irq(ts->spi->irq); in ad7877_enable()
439 mutex_unlock(&ts->mutex); in ad7877_enable()
445 struct ad7877 *ts = dev_get_drvdata(dev); \
446 ssize_t v = ad7877_read_adc(ts->spi, \
465 struct ad7877 *ts = dev_get_drvdata(dev); in SHOW() local
467 return sprintf(buf, "%u\n", ts->disabled); in SHOW()
474 struct ad7877 *ts = dev_get_drvdata(dev); in ad7877_disable_store() local
483 ad7877_disable(ts); in ad7877_disable_store()
485 ad7877_enable(ts); in ad7877_disable_store()
495 struct ad7877 *ts = dev_get_drvdata(dev); in ad7877_dac_show() local
497 return sprintf(buf, "%u\n", ts->dac); in ad7877_dac_show()
504 struct ad7877 *ts = dev_get_drvdata(dev); in ad7877_dac_store() local
512 mutex_lock(&ts->mutex); in ad7877_dac_store()
513 ts->dac = val & 0xFF; in ad7877_dac_store()
514 ad7877_write(ts->spi, AD7877_REG_DAC, (ts->dac << 4) | AD7877_DAC_CONF); in ad7877_dac_store()
515 mutex_unlock(&ts->mutex); in ad7877_dac_store()
525 struct ad7877 *ts = dev_get_drvdata(dev); in ad7877_gpio3_show() local
527 return sprintf(buf, "%u\n", ts->gpio3); in ad7877_gpio3_show()
534 struct ad7877 *ts = dev_get_drvdata(dev); in ad7877_gpio3_store() local
542 mutex_lock(&ts->mutex); in ad7877_gpio3_store()
543 ts->gpio3 = !!val; in ad7877_gpio3_store()
544 ad7877_write(ts->spi, AD7877_REG_EXTWRITE, AD7877_EXTW_GPIO_DATA | in ad7877_gpio3_store()
545 (ts->gpio4 << 4) | (ts->gpio3 << 5)); in ad7877_gpio3_store()
546 mutex_unlock(&ts->mutex); in ad7877_gpio3_store()
556 struct ad7877 *ts = dev_get_drvdata(dev); in ad7877_gpio4_show() local
558 return sprintf(buf, "%u\n", ts->gpio4); in ad7877_gpio4_show()
565 struct ad7877 *ts = dev_get_drvdata(dev); in ad7877_gpio4_store() local
573 mutex_lock(&ts->mutex); in ad7877_gpio4_store()
574 ts->gpio4 = !!val; in ad7877_gpio4_store()
575 ad7877_write(ts->spi, AD7877_REG_EXTWRITE, AD7877_EXTW_GPIO_DATA | in ad7877_gpio4_store()
576 (ts->gpio4 << 4) | (ts->gpio3 << 5)); in ad7877_gpio4_store()
577 mutex_unlock(&ts->mutex); in ad7877_gpio4_store()
620 static void ad7877_setup_ts_def_msg(struct spi_device *spi, struct ad7877 *ts) in ad7877_setup_ts_def_msg() argument
625 ts->cmd_crtl2 = AD7877_WRITEADD(AD7877_REG_CTRL2) | in ad7877_setup_ts_def_msg()
626 AD7877_POL(ts->stopacq_polarity) | in ad7877_setup_ts_def_msg()
627 AD7877_AVG(ts->averaging) | AD7877_PM(1) | in ad7877_setup_ts_def_msg()
628 AD7877_TMR(ts->pen_down_acc_interval) | in ad7877_setup_ts_def_msg()
629 AD7877_ACQ(ts->acquisition_time) | in ad7877_setup_ts_def_msg()
630 AD7877_FCD(ts->first_conversion_delay); in ad7877_setup_ts_def_msg()
632 ad7877_write(spi, AD7877_REG_CTRL2, ts->cmd_crtl2); in ad7877_setup_ts_def_msg()
634 ts->cmd_crtl1 = AD7877_WRITEADD(AD7877_REG_CTRL1) | in ad7877_setup_ts_def_msg()
638 ad7877_write(spi, AD7877_REG_CTRL1, ts->cmd_crtl1); in ad7877_setup_ts_def_msg()
640 ts->cmd_dummy = 0; in ad7877_setup_ts_def_msg()
642 m = &ts->msg; in ad7877_setup_ts_def_msg()
646 m->context = ts; in ad7877_setup_ts_def_msg()
648 ts->xfer[0].tx_buf = &ts->cmd_crtl1; in ad7877_setup_ts_def_msg()
649 ts->xfer[0].len = 2; in ad7877_setup_ts_def_msg()
650 ts->xfer[0].cs_change = 1; in ad7877_setup_ts_def_msg()
652 spi_message_add_tail(&ts->xfer[0], m); in ad7877_setup_ts_def_msg()
654 ts->xfer[1].tx_buf = &ts->cmd_dummy; /* Send ZERO */ in ad7877_setup_ts_def_msg()
655 ts->xfer[1].len = 2; in ad7877_setup_ts_def_msg()
656 ts->xfer[1].cs_change = 1; in ad7877_setup_ts_def_msg()
658 spi_message_add_tail(&ts->xfer[1], m); in ad7877_setup_ts_def_msg()
661 ts->xfer[i + 2].rx_buf = &ts->conversion_data[AD7877_SEQ_YPOS + i]; in ad7877_setup_ts_def_msg()
662 ts->xfer[i + 2].len = 2; in ad7877_setup_ts_def_msg()
664 ts->xfer[i + 2].cs_change = 1; in ad7877_setup_ts_def_msg()
665 spi_message_add_tail(&ts->xfer[i + 2], m); in ad7877_setup_ts_def_msg()
671 struct ad7877 *ts; in ad7877_probe() local
700 ts = devm_kzalloc(&spi->dev, sizeof(struct ad7877), GFP_KERNEL); in ad7877_probe()
701 if (!ts) in ad7877_probe()
708 err = devm_add_action_or_reset(&spi->dev, ad7877_disable, ts); in ad7877_probe()
712 spi_set_drvdata(spi, ts); in ad7877_probe()
713 ts->spi = spi; in ad7877_probe()
714 ts->input = input_dev; in ad7877_probe()
716 timer_setup(&ts->timer, ad7877_timer, 0); in ad7877_probe()
717 mutex_init(&ts->mutex); in ad7877_probe()
718 spin_lock_init(&ts->lock); in ad7877_probe()
720 ts->model = pdata->model ? : 7877; in ad7877_probe()
721 ts->vref_delay_usecs = pdata->vref_delay_usecs ? : 100; in ad7877_probe()
722 ts->x_plate_ohms = pdata->x_plate_ohms ? : 400; in ad7877_probe()
723 ts->pressure_max = pdata->pressure_max ? : ~0; in ad7877_probe()
725 ts->stopacq_polarity = pdata->stopacq_polarity; in ad7877_probe()
726 ts->first_conversion_delay = pdata->first_conversion_delay; in ad7877_probe()
727 ts->acquisition_time = pdata->acquisition_time; in ad7877_probe()
728 ts->averaging = pdata->averaging; in ad7877_probe()
729 ts->pen_down_acc_interval = pdata->pen_down_acc_interval; in ad7877_probe()
731 snprintf(ts->phys, sizeof(ts->phys), "%s/input0", dev_name(&spi->dev)); in ad7877_probe()
734 input_dev->phys = ts->phys; in ad7877_probe()
768 ad7877_setup_ts_def_msg(spi, ts); in ad7877_probe()
774 spi->dev.driver->name, ts); in ad7877_probe()
793 struct ad7877 *ts = dev_get_drvdata(dev); in ad7877_suspend() local
795 ad7877_disable(ts); in ad7877_suspend()
802 struct ad7877 *ts = dev_get_drvdata(dev); in ad7877_resume() local
804 ad7877_enable(ts); in ad7877_resume()