2 * ADS7846 based touchscreen and sensor driver
4 * Copyright (c) 2005 David Brownell
5 * Copyright (c) 2006 Nokia Corporation
6 * Various changes: Imre Deak <imre.deak@nokia.com>
10 * Copyright (C) 2004-2005 Richard Purdie
11 * - omap_ts.[hc], ads7846.h, ts_osk.c
12 * Copyright (C) 2002 MontaVista Software
13 * Copyright (C) 2004 Texas Instruments
14 * Copyright (C) 2005 Dirk Behme
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License version 2 as
18 * published by the Free Software Foundation.
20 #include <linux/hwmon.h>
21 #include <linux/init.h>
22 #include <linux/err.h>
23 #include <linux/delay.h>
24 #include <linux/input.h>
25 #include <linux/interrupt.h>
26 #include <linux/slab.h>
27 #include <linux/spi/spi.h>
28 #include <linux/spi/ads7846.h>
32 #include <asm/mach-types.h>
33 #ifdef CONFIG_ARCH_OMAP
34 #include <asm/arch/gpio.h>
40 * This code has been heavily tested on a Nokia 770, and lightly
41 * tested on other ads7846 devices (OSK/Mistral, Lubbock).
42 * Support for ads7843 and ads7845 has only been stubbed in.
44 * IRQ handling needs a workaround because of a shortcoming in handling
45 * edge triggered IRQs on some platforms like the OMAP1/2. These
46 * platforms don't handle the ARM lazy IRQ disabling properly, thus we
47 * have to maintain our own SW IRQ disabled status. This should be
48 * removed as soon as the affected platform's IRQ handling is fixed.
50 * app note sbaa036 talks in more detail about accurate sampling...
51 * that ought to help in situations like LCDs inducing noise (which
52 * can also be helped by using synch signals) and more generally.
53 * This driver tries to utilize the measures described in the app
54 * note. The strength of filtering can be set in the board-* specific
58 #define TS_POLL_PERIOD msecs_to_jiffies(10)
60 /* this driver doesn't aim at the peak continuous sample rate */
61 #define SAMPLE_BITS (8 /*cmd*/ + 16 /*sample*/ + 2 /* before, after */)
64 /* For portability, we can't read 12 bit values using SPI (which
65 * would make the controller deliver them as native byteorder u16
66 * with msbs zeroed). Instead, we read them as two 8-bit values,
67 * which need byteswapping then range adjustment.
75 struct input_dev *input;
78 struct spi_device *spi;
79 struct class_device *hwmon;
84 u8 read_x, read_y, read_z1, read_z2, pwrdown;
85 u16 dummy; /* for the pwrdown read */
88 struct spi_transfer xfer[10];
89 struct spi_message msg[5];
98 struct timer_list timer; /* P: lock */
99 unsigned pendown:1; /* P: lock */
100 unsigned pending:1; /* P: lock */
101 // FIXME remove "irq_disabled"
102 unsigned irq_disabled:1; /* P: lock */
106 /* leave chip selected when we're done, for quicker re-select? */
108 #define CS_CHANGE(xfer) ((xfer).cs_change = 1)
110 #define CS_CHANGE(xfer) ((xfer).cs_change = 0)
113 /*--------------------------------------------------------------------------*/
115 /* The ADS7846 has touchscreen and other sensors.
116 * Earlier ads784x chips are somewhat compatible.
118 #define ADS_START (1 << 7)
119 #define ADS_A2A1A0_d_y (1 << 4) /* differential */
120 #define ADS_A2A1A0_d_z1 (3 << 4) /* differential */
121 #define ADS_A2A1A0_d_z2 (4 << 4) /* differential */
122 #define ADS_A2A1A0_d_x (5 << 4) /* differential */
123 #define ADS_A2A1A0_temp0 (0 << 4) /* non-differential */
124 #define ADS_A2A1A0_vbatt (2 << 4) /* non-differential */
125 #define ADS_A2A1A0_vaux (6 << 4) /* non-differential */
126 #define ADS_A2A1A0_temp1 (7 << 4) /* non-differential */
127 #define ADS_8_BIT (1 << 3)
128 #define ADS_12_BIT (0 << 3)
129 #define ADS_SER (1 << 2) /* non-differential */
130 #define ADS_DFR (0 << 2) /* differential */
131 #define ADS_PD10_PDOWN (0 << 0) /* lowpower mode + penirq */
132 #define ADS_PD10_ADC_ON (1 << 0) /* ADC on */
133 #define ADS_PD10_REF_ON (2 << 0) /* vREF on + penirq */
134 #define ADS_PD10_ALL_ON (3 << 0) /* ADC + vREF on */
136 #define MAX_12BIT ((1<<12)-1)
138 /* leave ADC powered up (disables penirq) between differential samples */
139 #define READ_12BIT_DFR(x) (ADS_START | ADS_A2A1A0_d_ ## x \
140 | ADS_12_BIT | ADS_DFR)
142 #define READ_Y (READ_12BIT_DFR(y) | ADS_PD10_ADC_ON)
143 #define READ_Z1 (READ_12BIT_DFR(z1) | ADS_PD10_ADC_ON)
144 #define READ_Z2 (READ_12BIT_DFR(z2) | ADS_PD10_ADC_ON)
146 #define READ_X (READ_12BIT_DFR(x) | ADS_PD10_ADC_ON)
147 #define PWRDOWN (READ_12BIT_DFR(y) | ADS_PD10_PDOWN) /* LAST */
149 /* single-ended samples need to first power up reference voltage;
150 * we leave both ADC and VREF powered
152 #define READ_12BIT_SER(x) (ADS_START | ADS_A2A1A0_ ## x \
153 | ADS_12_BIT | ADS_SER)
155 #define REF_ON (READ_12BIT_DFR(x) | ADS_PD10_ALL_ON)
156 #define REF_OFF (READ_12BIT_DFR(y) | ADS_PD10_PDOWN)
158 /*--------------------------------------------------------------------------*/
161 * Non-touchscreen sensors only use single-ended conversions.
162 * The range is GND..vREF. The ads7843 and ads7835 must use external vREF;
163 * ads7846 lets that pin be unconnected, to use internal vREF.
165 * FIXME make external vREF_mV be a module option, and use that as needed...
167 static const unsigned vREF_mV = 2500;
175 struct spi_message msg;
176 struct spi_transfer xfer[6];
179 static void ads7846_enable(struct ads7846 *ts);
180 static void ads7846_disable(struct ads7846 *ts);
182 static int ads7846_read12_ser(struct device *dev, unsigned command)
184 struct spi_device *spi = to_spi_device(dev);
185 struct ads7846 *ts = dev_get_drvdata(dev);
186 struct ser_req *req = kzalloc(sizeof *req, SLAB_KERNEL);
194 spi_message_init(&req->msg);
196 /* FIXME boards with ads7846 might use external vref instead ... */
197 use_internal = (ts->model == 7846);
199 /* maybe turn on internal vREF, and let it settle */
201 req->ref_on = REF_ON;
202 req->xfer[0].tx_buf = &req->ref_on;
203 req->xfer[0].len = 1;
204 spi_message_add_tail(&req->xfer[0], &req->msg);
206 req->xfer[1].rx_buf = &req->scratch;
207 req->xfer[1].len = 2;
209 /* for 1uF, settle for 800 usec; no cap, 100 usec. */
210 req->xfer[1].delay_usecs = ts->vref_delay_usecs;
211 spi_message_add_tail(&req->xfer[1], &req->msg);
215 req->command = (u8) command;
216 req->xfer[2].tx_buf = &req->command;
217 req->xfer[2].len = 1;
218 spi_message_add_tail(&req->xfer[2], &req->msg);
220 req->xfer[3].rx_buf = &req->sample;
221 req->xfer[3].len = 2;
222 spi_message_add_tail(&req->xfer[3], &req->msg);
224 /* REVISIT: take a few more samples, and compare ... */
226 /* maybe off internal vREF */
228 req->ref_off = REF_OFF;
229 req->xfer[4].tx_buf = &req->ref_off;
230 req->xfer[4].len = 1;
231 spi_message_add_tail(&req->xfer[4], &req->msg);
233 req->xfer[5].rx_buf = &req->scratch;
234 req->xfer[5].len = 2;
235 CS_CHANGE(req->xfer[5]);
236 spi_message_add_tail(&req->xfer[5], &req->msg);
239 disable_irq(spi->irq);
240 status = spi_sync(spi, &req->msg);
241 enable_irq(spi->irq);
244 status = req->msg.status;
246 /* on-wire is a must-ignore bit, a BE12 value, then padding */
247 sample = be16_to_cpu(req->sample);
248 sample = sample >> 3;
252 return status ? status : sample;
255 #define SHOW(name,var,adjust) static ssize_t \
256 name ## _show(struct device *dev, struct device_attribute *attr, char *buf) \
258 struct ads7846 *ts = dev_get_drvdata(dev); \
259 ssize_t v = ads7846_read12_ser(dev, \
260 READ_12BIT_SER(var) | ADS_PD10_ALL_ON); \
263 return sprintf(buf, "%u\n", adjust(ts, v)); \
265 static DEVICE_ATTR(name, S_IRUGO, name ## _show, NULL);
268 /* Sysfs conventions report temperatures in millidegrees Celcius.
269 * We could use the low-accuracy two-sample scheme, but can't do the high
270 * accuracy scheme without calibration data. For now we won't try either;
271 * userspace sees raw sensor values, and must scale appropriately.
273 static inline unsigned null_adjust(struct ads7846 *ts, ssize_t v)
278 SHOW(temp0, temp0, null_adjust) // temp1_input
279 SHOW(temp1, temp1, null_adjust) // temp2_input
282 /* sysfs conventions report voltages in millivolts. We can convert voltages
283 * if we know vREF. userspace may need to scale vAUX to match the board's
284 * external resistors; we assume that vBATT only uses the internal ones.
286 static inline unsigned vaux_adjust(struct ads7846 *ts, ssize_t v)
290 /* external resistors may scale vAUX into 0..vREF */
292 retval = retval >> 12;
296 static inline unsigned vbatt_adjust(struct ads7846 *ts, ssize_t v)
298 unsigned retval = vaux_adjust(ts, v);
300 /* ads7846 has a resistor ladder to scale this signal down */
301 if (ts->model == 7846)
306 SHOW(in0_input, vaux, vaux_adjust)
307 SHOW(in1_input, vbatt, vbatt_adjust)
310 static int is_pen_down(struct device *dev)
312 struct ads7846 *ts = dev_get_drvdata(dev);
317 static ssize_t ads7846_pen_down_show(struct device *dev,
318 struct device_attribute *attr, char *buf)
320 return sprintf(buf, "%u\n", is_pen_down(dev));
323 static DEVICE_ATTR(pen_down, S_IRUGO, ads7846_pen_down_show, NULL);
325 static ssize_t ads7846_disable_show(struct device *dev,
326 struct device_attribute *attr, char *buf)
328 struct ads7846 *ts = dev_get_drvdata(dev);
330 return sprintf(buf, "%u\n", ts->disabled);
333 static ssize_t ads7846_disable_store(struct device *dev,
334 struct device_attribute *attr,
335 const char *buf, size_t count)
337 struct ads7846 *ts = dev_get_drvdata(dev);
341 i = simple_strtoul(buf, &endp, 10);
342 spin_lock_irq(&ts->lock);
349 spin_unlock_irq(&ts->lock);
354 static DEVICE_ATTR(disable, 0664, ads7846_disable_show, ads7846_disable_store);
356 /*--------------------------------------------------------------------------*/
359 * PENIRQ only kicks the timer. The timer only reissues the SPI transfer,
360 * to retrieve touchscreen status.
362 * The SPI transfer completion callback does the real work. It reports
363 * touchscreen events and reactivates the timer (or IRQ) as appropriate.
366 static void ads7846_rx(void *ads)
368 struct ads7846 *ts = ads;
369 struct input_dev *input_dev = ts->input;
375 /* adjust: on-wire is a must-ignore bit, a BE12 value, then padding;
376 * built from two 8 bit values written msb-first.
378 x = (be16_to_cpu(ts->tc.x) >> 3) & 0x0fff;
379 y = (be16_to_cpu(ts->tc.y) >> 3) & 0x0fff;
380 z1 = (be16_to_cpu(ts->tc.z1) >> 3) & 0x0fff;
381 z2 = (be16_to_cpu(ts->tc.z2) >> 3) & 0x0fff;
383 /* range filtering */
387 if (x && z1 && ts->spi->dev.power.power_state.event == PM_EVENT_ON) {
388 /* compute touch pressure resistance using equation #2 */
392 Rt *= ts->x_plate_ohms;
394 Rt = (Rt + 2047) >> 12;
398 /* NOTE: "pendown" is inferred from pressure; we don't rely on
399 * being able to check nPENIRQ status, or "friendly" trigger modes
400 * (both-edges is much better than just-falling or low-level).
402 * REVISIT: some boards may require reading nPENIRQ; it's
403 * needed on 7843. and 7845 reads pressure differently...
405 * REVISIT: the touchscreen might not be connected; this code
406 * won't notice that, even if nPENIRQ never fires ...
408 if (!ts->pendown && Rt != 0) {
409 input_report_key(input_dev, BTN_TOUCH, 1);
411 } else if (ts->pendown && Rt == 0) {
412 input_report_key(input_dev, BTN_TOUCH, 0);
417 input_report_abs(input_dev, ABS_X, x);
418 input_report_abs(input_dev, ABS_Y, y);
419 input_report_abs(input_dev, ABS_PRESSURE, Rt);
423 input_sync(input_dev);
426 if (Rt || ts->pendown)
427 pr_debug("%s: %d/%d/%d%s\n", ts->spi->dev.bus_id,
428 x, y, Rt, Rt ? "" : " UP");
431 /* don't retrigger while we're suspended */
432 spin_lock_irqsave(&ts->lock, flags);
434 ts->pendown = (Rt != 0);
437 if (ts->spi->dev.power.power_state.event == PM_EVENT_ON) {
439 mod_timer(&ts->timer, jiffies + TS_POLL_PERIOD);
440 else if (ts->irq_disabled) {
441 ts->irq_disabled = 0;
442 enable_irq(ts->spi->irq);
446 spin_unlock_irqrestore(&ts->lock, flags);
449 static void ads7846_debounce(void *ads)
451 struct ads7846 *ts = ads;
452 struct spi_message *m;
453 struct spi_transfer *t;
457 m = &ts->msg[ts->msg_idx];
458 t = list_entry(m->transfers.prev, struct spi_transfer, transfer_list);
459 val = (*(u16 *)t->rx_buf) >> 3;
461 if (!ts->read_cnt || (abs(ts->last_read - val) > ts->debounce_tol
462 && ts->read_cnt < ts->debounce_max)) {
463 /* Repeat it, if this was the first read or the read wasn't
469 /* Go for the next read */
474 status = spi_async(ts->spi, m);
476 dev_err(&ts->spi->dev, "spi_async --> %d\n",
480 static void ads7846_timer(unsigned long handle)
482 struct ads7846 *ts = (void *)handle;
486 status = spi_async(ts->spi, &ts->msg[0]);
488 dev_err(&ts->spi->dev, "spi_async --> %d\n", status);
491 static irqreturn_t ads7846_irq(int irq, void *handle, struct pt_regs *regs)
493 struct ads7846 *ts = handle;
496 spin_lock_irqsave(&ts->lock, flags);
497 if (likely(!ts->irq_disabled && !ts->disabled)) {
498 if (!ts->irq_disabled) {
499 /* REVISIT irq logic for many ARM chips has cloned a
500 * bug wherein disabling an irq in its handler won't
501 * work;(it's disabled lazily, and too late to work.
502 * until all their irq logic is fixed, we must shadow
505 ts->irq_disabled = 1;
507 disable_irq(ts->spi->irq);
511 mod_timer(&ts->timer, jiffies);
514 spin_unlock_irqrestore(&ts->lock, flags);
519 /*--------------------------------------------------------------------------*/
521 /* Must be called with ts->lock held */
522 static void ads7846_disable(struct ads7846 *ts)
527 /* are we waiting for IRQ, or polling? */
529 if (!ts->irq_disabled) {
530 ts->irq_disabled = 1;
531 disable_irq(ts->spi->irq);
534 /* polling; force a final SPI completion;
535 * that will clean things up neatly
538 mod_timer(&ts->timer, jiffies);
540 while (ts->pendown || ts->pending) {
541 spin_unlock_irq(&ts->lock);
543 spin_lock_irq(&ts->lock);
547 /* we know the chip's in lowpower mode since we always
548 * leave it that way after every request
554 /* Must be called with ts->lock held */
555 static void ads7846_enable(struct ads7846 *ts)
561 ts->irq_disabled = 0;
562 enable_irq(ts->spi->irq);
565 static int ads7846_suspend(struct spi_device *spi, pm_message_t message)
567 struct ads7846 *ts = dev_get_drvdata(&spi->dev);
569 spin_lock_irq(&ts->lock);
571 spi->dev.power.power_state = message;
574 spin_unlock_irq(&ts->lock);
580 static int ads7846_resume(struct spi_device *spi)
582 struct ads7846 *ts = dev_get_drvdata(&spi->dev);
584 spin_lock_irq(&ts->lock);
586 spi->dev.power.power_state = PMSG_ON;
589 spin_unlock_irq(&ts->lock);
594 static int __devinit ads7846_probe(struct spi_device *spi)
597 struct input_dev *input_dev;
598 struct class_device *hwmon = ERR_PTR(-ENOMEM);
599 struct ads7846_platform_data *pdata = spi->dev.platform_data;
600 struct spi_message *m;
601 struct spi_transfer *x;
605 dev_dbg(&spi->dev, "no IRQ?\n");
610 dev_dbg(&spi->dev, "no platform data?\n");
614 /* don't exceed max specified sample rate */
615 if (spi->max_speed_hz > (125000 * SAMPLE_BITS)) {
616 dev_dbg(&spi->dev, "f(sample) %d KHz?\n",
617 (spi->max_speed_hz/SAMPLE_BITS)/1000);
621 /* We'd set the wordsize to 12 bits ... except that some controllers
622 * will then treat the 8 bit command words as 12 bits (and drop the
623 * four MSBs of the 12 bit result). Result: inputs must be shifted
624 * to discard the four garbage LSBs. (Also, not all controllers can
625 * support 12 bit words.)
628 ts = kzalloc(sizeof(struct ads7846), GFP_KERNEL);
629 input_dev = input_allocate_device();
630 hwmon = hwmon_device_register(&spi->dev);
631 if (!ts || !input_dev || IS_ERR(hwmon)) {
636 dev_set_drvdata(&spi->dev, ts);
637 spi->dev.power.power_state = PMSG_ON;
640 ts->input = input_dev;
643 init_timer(&ts->timer);
644 ts->timer.data = (unsigned long) ts;
645 ts->timer.function = ads7846_timer;
647 spin_lock_init(&ts->lock);
649 ts->model = pdata->model ? : 7846;
650 ts->vref_delay_usecs = pdata->vref_delay_usecs ? : 100;
651 ts->x_plate_ohms = pdata->x_plate_ohms ? : 400;
652 ts->debounce_max = pdata->debounce_max ? : 1;
653 ts->debounce_tol = pdata->debounce_tol ? : 10;
655 snprintf(ts->phys, sizeof(ts->phys), "%s/input0", spi->dev.bus_id);
657 input_dev->name = "ADS784x Touchscreen";
658 input_dev->phys = ts->phys;
659 input_dev->cdev.dev = &spi->dev;
661 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
662 input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
663 input_set_abs_params(input_dev, ABS_X,
665 pdata->x_max ? : MAX_12BIT,
667 input_set_abs_params(input_dev, ABS_Y,
669 pdata->y_max ? : MAX_12BIT,
671 input_set_abs_params(input_dev, ABS_PRESSURE,
672 pdata->pressure_min, pdata->pressure_max, 0, 0);
674 /* set up the transfers to read touchscreen state; this assumes we
675 * use formula #2 for pressure, not #3.
682 /* y- still on; turn on only y+ (and ADC) */
684 x->tx_buf = &ts->read_y;
686 spi_message_add_tail(x, m);
689 x->rx_buf = &ts->tc.y;
691 spi_message_add_tail(x, m);
693 m->complete = ads7846_debounce;
699 /* turn y- off, x+ on, then leave in lowpower */
702 x->tx_buf = &ts->read_x;
704 spi_message_add_tail(x, m);
707 x->rx_buf = &ts->tc.x;
709 spi_message_add_tail(x, m);
711 m->complete = ads7846_debounce;
714 /* turn y+ off, x- on; we'll use formula #2 */
715 if (ts->model == 7846) {
720 ts->read_z1 = READ_Z1;
721 x->tx_buf = &ts->read_z1;
723 spi_message_add_tail(x, m);
726 x->rx_buf = &ts->tc.z1;
728 spi_message_add_tail(x, m);
730 m->complete = ads7846_debounce;
737 ts->read_z2 = READ_Z2;
738 x->tx_buf = &ts->read_z2;
740 spi_message_add_tail(x, m);
743 x->rx_buf = &ts->tc.z2;
745 spi_message_add_tail(x, m);
747 m->complete = ads7846_debounce;
756 ts->pwrdown = PWRDOWN;
757 x->tx_buf = &ts->pwrdown;
759 spi_message_add_tail(x, m);
762 x->rx_buf = &ts->dummy;
765 spi_message_add_tail(x, m);
767 m->complete = ads7846_rx;
770 if (request_irq(spi->irq, ads7846_irq,
771 SA_SAMPLE_RANDOM | SA_TRIGGER_FALLING,
772 spi->dev.bus_id, ts)) {
773 dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq);
778 dev_info(&spi->dev, "touchscreen + hwmon, irq %d\n", spi->irq);
780 /* take a first sample, leaving nPENIRQ active and vREF off; avoid
781 * the touchscreen, in case it's not connected.
783 (void) ads7846_read12_ser(&spi->dev,
784 READ_12BIT_SER(vaux) | ADS_PD10_ALL_ON);
786 /* ads7843/7845 don't have temperature sensors, and
787 * use the other ADC lines a bit differently too
789 if (ts->model == 7846) {
790 device_create_file(&spi->dev, &dev_attr_temp0);
791 device_create_file(&spi->dev, &dev_attr_temp1);
793 /* in1 == vBAT (7846), or a non-scaled ADC input */
794 if (ts->model != 7845)
795 device_create_file(&spi->dev, &dev_attr_in1_input);
796 /* in0 == a non-scaled ADC input */
797 device_create_file(&spi->dev, &dev_attr_in0_input);
799 /* non-hwmon device attributes */
800 device_create_file(&spi->dev, &dev_attr_pen_down);
801 device_create_file(&spi->dev, &dev_attr_disable);
803 err = input_register_device(input_dev);
805 goto err_remove_attr;
810 device_remove_file(&spi->dev, &dev_attr_disable);
811 device_remove_file(&spi->dev, &dev_attr_pen_down);
812 if (ts->model == 7846) {
813 device_remove_file(&spi->dev, &dev_attr_temp1);
814 device_remove_file(&spi->dev, &dev_attr_temp0);
816 if (ts->model != 7845)
817 device_remove_file(&spi->dev, &dev_attr_in1_input);
818 device_remove_file(&spi->dev, &dev_attr_in0_input);
820 free_irq(spi->irq, ts);
823 hwmon_device_unregister(hwmon);
824 input_free_device(input_dev);
829 static int __devexit ads7846_remove(struct spi_device *spi)
831 struct ads7846 *ts = dev_get_drvdata(&spi->dev);
833 hwmon_device_unregister(ts->hwmon);
834 input_unregister_device(ts->input);
836 ads7846_suspend(spi, PMSG_SUSPEND);
838 device_remove_file(&spi->dev, &dev_attr_disable);
839 device_remove_file(&spi->dev, &dev_attr_pen_down);
840 if (ts->model == 7846) {
841 device_remove_file(&spi->dev, &dev_attr_temp1);
842 device_remove_file(&spi->dev, &dev_attr_temp0);
844 if (ts->model != 7845)
845 device_remove_file(&spi->dev, &dev_attr_in1_input);
846 device_remove_file(&spi->dev, &dev_attr_in0_input);
848 free_irq(ts->spi->irq, ts);
849 if (ts->irq_disabled)
850 enable_irq(ts->spi->irq);
854 dev_dbg(&spi->dev, "unregistered touchscreen\n");
858 static struct spi_driver ads7846_driver = {
861 .bus = &spi_bus_type,
862 .owner = THIS_MODULE,
864 .probe = ads7846_probe,
865 .remove = __devexit_p(ads7846_remove),
866 .suspend = ads7846_suspend,
867 .resume = ads7846_resume,
870 static int __init ads7846_init(void)
872 /* grr, board-specific init should stay out of drivers!! */
874 #ifdef CONFIG_ARCH_OMAP
875 if (machine_is_omap_osk()) {
876 /* GPIO4 = PENIRQ; GPIO6 = BUSY */
877 omap_request_gpio(4);
878 omap_set_gpio_direction(4, 1);
879 omap_request_gpio(6);
880 omap_set_gpio_direction(6, 1);
882 // also TI 1510 Innovator, bitbanging through FPGA
884 // also Palm Tungsten T2
888 // also Dell Axim X50
889 // also HP iPaq H191x/H192x/H415x/H435x
890 // also Intel Lubbock (additional to UCB1400; as temperature sensor)
891 // also Sharp Zaurus C7xx, C8xx (corgi/sheperd/husky)
893 // Atmel at91sam9261-EK uses ads7843
895 // also various AMD Au1x00 devel boards
897 return spi_register_driver(&ads7846_driver);
899 device_initcall(ads7846_init);
901 static void __exit ads7846_exit(void)
903 spi_unregister_driver(&ads7846_driver);
905 #ifdef CONFIG_ARCH_OMAP
906 if (machine_is_omap_osk()) {
913 module_exit(ads7846_exit);
915 MODULE_DESCRIPTION("ADS7846 TouchScreen Driver");
916 MODULE_LICENSE("GPL");