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/device.h>
21 #include <linux/init.h>
22 #include <linux/delay.h>
23 #include <linux/input.h>
24 #include <linux/interrupt.h>
25 #include <linux/slab.h>
26 #include <linux/spi/spi.h>
27 #include <linux/spi/ads7846.h>
31 #include <asm/mach-types.h>
32 #ifdef CONFIG_ARCH_OMAP
33 #include <asm/arch/gpio.h>
39 * This code has been heavily tested on a Nokia 770, and lightly
40 * tested on other ads7846 devices (OSK/Mistral, Lubbock).
41 * Support for ads7843 and ads7845 has only been stubbed in.
43 * IRQ handling needs a workaround because of a shortcoming in handling
44 * edge triggered IRQs on some platforms like the OMAP1/2. These
45 * platforms don't handle the ARM lazy IRQ disabling properly, thus we
46 * have to maintain our own SW IRQ disabled status. This should be
47 * removed as soon as the affected platform's IRQ handling is fixed.
49 * app note sbaa036 talks in more detail about accurate sampling...
50 * that ought to help in situations like LCDs inducing noise (which
51 * can also be helped by using synch signals) and more generally.
52 * This driver tries to utilize the measures described in the app
53 * note. The strength of filtering can be set in the board-* specific
57 #define TS_POLL_PERIOD msecs_to_jiffies(10)
59 /* this driver doesn't aim at the peak continuous sample rate */
60 #define SAMPLE_BITS (8 /*cmd*/ + 16 /*sample*/ + 2 /* before, after */)
63 /* For portability, we can't read 12 bit values using SPI (which
64 * would make the controller deliver them as native byteorder u16
65 * with msbs zeroed). Instead, we read them as two 8-bit values,
66 * *** WHICH NEED BYTESWAPPING *** and range adjustment.
75 struct input_dev *input;
78 struct spi_device *spi;
79 struct attribute_group *attr_group;
85 u8 read_x, read_y, read_z1, read_z2, pwrdown;
86 u16 dummy; /* for the pwrdown read */
89 struct spi_transfer xfer[10];
90 struct spi_message msg[5];
91 struct spi_message *last_msg;
102 struct timer_list timer; /* P: lock */
103 unsigned pendown:1; /* P: lock */
104 unsigned pending:1; /* P: lock */
105 // FIXME remove "irq_disabled"
106 unsigned irq_disabled:1; /* P: lock */
109 int (*filter)(void *data, int data_idx, int *val);
111 void (*filter_cleanup)(void *data);
112 int (*get_pendown_state)(void);
115 /* leave chip selected when we're done, for quicker re-select? */
117 #define CS_CHANGE(xfer) ((xfer).cs_change = 1)
119 #define CS_CHANGE(xfer) ((xfer).cs_change = 0)
122 /*--------------------------------------------------------------------------*/
124 /* The ADS7846 has touchscreen and other sensors.
125 * Earlier ads784x chips are somewhat compatible.
127 #define ADS_START (1 << 7)
128 #define ADS_A2A1A0_d_y (1 << 4) /* differential */
129 #define ADS_A2A1A0_d_z1 (3 << 4) /* differential */
130 #define ADS_A2A1A0_d_z2 (4 << 4) /* differential */
131 #define ADS_A2A1A0_d_x (5 << 4) /* differential */
132 #define ADS_A2A1A0_temp0 (0 << 4) /* non-differential */
133 #define ADS_A2A1A0_vbatt (2 << 4) /* non-differential */
134 #define ADS_A2A1A0_vaux (6 << 4) /* non-differential */
135 #define ADS_A2A1A0_temp1 (7 << 4) /* non-differential */
136 #define ADS_8_BIT (1 << 3)
137 #define ADS_12_BIT (0 << 3)
138 #define ADS_SER (1 << 2) /* non-differential */
139 #define ADS_DFR (0 << 2) /* differential */
140 #define ADS_PD10_PDOWN (0 << 0) /* lowpower mode + penirq */
141 #define ADS_PD10_ADC_ON (1 << 0) /* ADC on */
142 #define ADS_PD10_REF_ON (2 << 0) /* vREF on + penirq */
143 #define ADS_PD10_ALL_ON (3 << 0) /* ADC + vREF on */
145 #define MAX_12BIT ((1<<12)-1)
147 /* leave ADC powered up (disables penirq) between differential samples */
148 #define READ_12BIT_DFR(x) (ADS_START | ADS_A2A1A0_d_ ## x \
149 | ADS_12_BIT | ADS_DFR)
151 #define READ_Y (READ_12BIT_DFR(y) | ADS_PD10_ADC_ON)
152 #define READ_Z1 (READ_12BIT_DFR(z1) | ADS_PD10_ADC_ON)
153 #define READ_Z2 (READ_12BIT_DFR(z2) | ADS_PD10_ADC_ON)
155 #define READ_X (READ_12BIT_DFR(x) | ADS_PD10_ADC_ON)
156 #define PWRDOWN (READ_12BIT_DFR(y) | ADS_PD10_PDOWN) /* LAST */
158 /* single-ended samples need to first power up reference voltage;
159 * we leave both ADC and VREF powered
161 #define READ_12BIT_SER(x) (ADS_START | ADS_A2A1A0_ ## x \
162 | ADS_12_BIT | ADS_SER)
164 #define REF_ON (READ_12BIT_DFR(x) | ADS_PD10_ALL_ON)
165 #define REF_OFF (READ_12BIT_DFR(y) | ADS_PD10_PDOWN)
167 /*--------------------------------------------------------------------------*/
170 * Non-touchscreen sensors only use single-ended conversions.
179 struct spi_message msg;
180 struct spi_transfer xfer[6];
183 static void ads7846_enable(struct ads7846 *ts);
184 static void ads7846_disable(struct ads7846 *ts);
186 static int device_suspended(struct device *dev)
188 struct ads7846 *ts = dev_get_drvdata(dev);
189 return dev->power.power_state.event != PM_EVENT_ON || ts->disabled;
192 static int ads7846_read12_ser(struct device *dev, unsigned command)
194 struct spi_device *spi = to_spi_device(dev);
195 struct ads7846 *ts = dev_get_drvdata(dev);
196 struct ser_req *req = kzalloc(sizeof *req, GFP_KERNEL);
204 spi_message_init(&req->msg);
206 /* activate reference, so it has time to settle; */
207 req->ref_on = REF_ON;
208 req->xfer[0].tx_buf = &req->ref_on;
209 req->xfer[0].len = 1;
210 req->xfer[1].rx_buf = &req->scratch;
211 req->xfer[1].len = 2;
214 * for external VREF, 0 usec (and assume it's always on);
215 * for 1uF, use 800 usec;
218 req->xfer[1].delay_usecs = ts->vref_delay_usecs;
221 req->command = (u8) command;
222 req->xfer[2].tx_buf = &req->command;
223 req->xfer[2].len = 1;
224 req->xfer[3].rx_buf = &req->sample;
225 req->xfer[3].len = 2;
227 /* REVISIT: take a few more samples, and compare ... */
229 /* turn off reference */
230 req->ref_off = REF_OFF;
231 req->xfer[4].tx_buf = &req->ref_off;
232 req->xfer[4].len = 1;
233 req->xfer[5].rx_buf = &req->scratch;
234 req->xfer[5].len = 2;
236 CS_CHANGE(req->xfer[5]);
238 /* group all the transfers together, so we can't interfere with
239 * reading touchscreen state; disable penirq while sampling
241 for (i = 0; i < 6; i++)
242 spi_message_add_tail(&req->xfer[i], &req->msg);
244 ts->irq_disabled = 1;
245 disable_irq(spi->irq);
246 status = spi_sync(spi, &req->msg);
247 ts->irq_disabled = 0;
248 enable_irq(spi->irq);
251 status = req->msg.status;
253 /* on-wire is a must-ignore bit, a BE12 value, then padding */
254 sample = be16_to_cpu(req->sample);
255 sample = sample >> 3;
259 return status ? status : sample;
262 #define SHOW(name) static ssize_t \
263 name ## _show(struct device *dev, struct device_attribute *attr, char *buf) \
265 ssize_t v = ads7846_read12_ser(dev, \
266 READ_12BIT_SER(name) | ADS_PD10_ALL_ON); \
269 return sprintf(buf, "%u\n", (unsigned) v); \
271 static DEVICE_ATTR(name, S_IRUGO, name ## _show, NULL);
278 static int is_pen_down(struct device *dev)
280 struct ads7846 *ts = dev_get_drvdata(dev);
285 static ssize_t ads7846_pen_down_show(struct device *dev,
286 struct device_attribute *attr, char *buf)
288 return sprintf(buf, "%u\n", is_pen_down(dev));
291 static DEVICE_ATTR(pen_down, S_IRUGO, ads7846_pen_down_show, NULL);
293 static ssize_t ads7846_disable_show(struct device *dev,
294 struct device_attribute *attr, char *buf)
296 struct ads7846 *ts = dev_get_drvdata(dev);
298 return sprintf(buf, "%u\n", ts->disabled);
301 static ssize_t ads7846_disable_store(struct device *dev,
302 struct device_attribute *attr,
303 const char *buf, size_t count)
305 struct ads7846 *ts = dev_get_drvdata(dev);
309 i = simple_strtoul(buf, &endp, 10);
310 spin_lock_irq(&ts->lock);
317 spin_unlock_irq(&ts->lock);
322 static DEVICE_ATTR(disable, 0664, ads7846_disable_show, ads7846_disable_store);
324 static struct attribute *ads7846_attributes[] = {
325 &dev_attr_temp0.attr,
326 &dev_attr_temp1.attr,
327 &dev_attr_vbatt.attr,
329 &dev_attr_pen_down.attr,
330 &dev_attr_disable.attr,
334 static struct attribute_group ads7846_attr_group = {
335 .attrs = ads7846_attributes,
339 * ads7843/7845 don't have temperature sensors, and
340 * use the other sensors a bit differently too
343 static struct attribute *ads7843_attributes[] = {
344 &dev_attr_vbatt.attr,
346 &dev_attr_pen_down.attr,
347 &dev_attr_disable.attr,
351 static struct attribute_group ads7843_attr_group = {
352 .attrs = ads7843_attributes,
355 static struct attribute *ads7845_attributes[] = {
357 &dev_attr_pen_down.attr,
358 &dev_attr_disable.attr,
362 static struct attribute_group ads7845_attr_group = {
363 .attrs = ads7845_attributes,
366 /*--------------------------------------------------------------------------*/
369 * PENIRQ only kicks the timer. The timer only reissues the SPI transfer,
370 * to retrieve touchscreen status.
372 * The SPI transfer completion callback does the real work. It reports
373 * touchscreen events and reactivates the timer (or IRQ) as appropriate.
376 static void ads7846_rx(void *ads)
378 struct ads7846 *ts = ads;
379 struct input_dev *input_dev = ts->input;
385 /* ads7846_rx_val() did in-place conversion (including byteswap) from
386 * on-the-wire format as part of debouncing to get stable readings.
393 /* range filtering */
397 if (likely(x && z1 && !device_suspended(&ts->spi->dev))) {
398 /* compute touch pressure resistance using equation #2 */
402 Rt *= ts->x_plate_ohms;
404 Rt = (Rt + 2047) >> 12;
408 /* Sample found inconsistent by debouncing or pressure is beyond
409 * the maximum. Don't report it to user space, repeat at least
410 * once more the measurement */
411 if (ts->tc.ignore || Rt > ts->pressure_max) {
412 mod_timer(&ts->timer, jiffies + TS_POLL_PERIOD);
416 /* NOTE: "pendown" is inferred from pressure; we don't rely on
417 * being able to check nPENIRQ status, or "friendly" trigger modes
418 * (both-edges is much better than just-falling or low-level).
420 * REVISIT: some boards may require reading nPENIRQ; it's
421 * needed on 7843. and 7845 reads pressure differently...
423 * REVISIT: the touchscreen might not be connected; this code
424 * won't notice that, even if nPENIRQ never fires ...
426 if (!ts->pendown && Rt != 0) {
427 input_report_key(input_dev, BTN_TOUCH, 1);
429 } else if (ts->pendown && Rt == 0) {
430 input_report_key(input_dev, BTN_TOUCH, 0);
435 input_report_abs(input_dev, ABS_X, x);
436 input_report_abs(input_dev, ABS_Y, y);
441 input_report_abs(input_dev, ABS_PRESSURE, Rt);
442 input_sync(input_dev);
446 if (Rt || ts->pendown)
447 pr_debug("%s: %d/%d/%d%s\n", ts->spi->dev.bus_id,
448 x, y, Rt, Rt ? "" : " UP");
451 spin_lock_irqsave(&ts->lock, flags);
453 ts->pendown = (Rt != 0);
454 mod_timer(&ts->timer, jiffies + TS_POLL_PERIOD);
456 spin_unlock_irqrestore(&ts->lock, flags);
459 static int ads7846_debounce(void *ads, int data_idx, int *val)
461 struct ads7846 *ts = ads;
463 if (!ts->read_cnt || (abs(ts->last_read - *val) > ts->debounce_tol)) {
464 /* Start over collecting consistent readings. */
466 /* Repeat it, if this was the first read or the read
467 * wasn't consistent enough. */
468 if (ts->read_cnt < ts->debounce_max) {
469 ts->last_read = *val;
471 return ADS7846_FILTER_REPEAT;
473 /* Maximum number of debouncing reached and still
474 * not enough number of consistent readings. Abort
475 * the whole sample, repeat it in the next sampling
479 return ADS7846_FILTER_IGNORE;
482 if (++ts->read_rep > ts->debounce_rep) {
483 /* Got a good reading for this coordinate,
484 * go for the next one. */
487 return ADS7846_FILTER_OK;
489 /* Read more values that are consistent. */
491 return ADS7846_FILTER_REPEAT;
496 static int ads7846_no_filter(void *ads, int data_idx, int *val)
498 return ADS7846_FILTER_OK;
501 static void ads7846_rx_val(void *ads)
503 struct ads7846 *ts = ads;
504 struct spi_message *m;
505 struct spi_transfer *t;
511 m = &ts->msg[ts->msg_idx];
512 t = list_entry(m->transfers.prev, struct spi_transfer, transfer_list);
515 /* adjust: on-wire is a must-ignore bit, a BE12 value, then padding;
516 * built from two 8 bit values written msb-first.
518 val = be16_to_cpu(*rx_val) >> 3;
520 action = ts->filter(ts->filter_data, ts->msg_idx, &val);
522 case ADS7846_FILTER_REPEAT:
524 case ADS7846_FILTER_IGNORE:
526 /* Last message will contain ads7846_rx() as the
527 * completion function.
531 case ADS7846_FILTER_OK:
534 m = &ts->msg[++ts->msg_idx];
539 status = spi_async(ts->spi, m);
541 dev_err(&ts->spi->dev, "spi_async --> %d\n",
545 static void ads7846_timer(unsigned long handle)
547 struct ads7846 *ts = (void *)handle;
550 spin_lock_irq(&ts->lock);
552 if (unlikely(ts->msg_idx && !ts->pendown)) {
553 /* measurement cycle ended */
554 if (!device_suspended(&ts->spi->dev)) {
555 ts->irq_disabled = 0;
556 enable_irq(ts->spi->irq);
561 /* pen is still down, continue with the measurement */
563 status = spi_async(ts->spi, &ts->msg[0]);
565 dev_err(&ts->spi->dev, "spi_async --> %d\n", status);
568 spin_unlock_irq(&ts->lock);
571 static irqreturn_t ads7846_irq(int irq, void *handle)
573 struct ads7846 *ts = handle;
576 spin_lock_irqsave(&ts->lock, flags);
577 if (likely(ts->get_pendown_state())) {
578 if (!ts->irq_disabled) {
579 /* The ARM do_simple_IRQ() dispatcher doesn't act
580 * like the other dispatchers: it will report IRQs
581 * even after they've been disabled. We work around
582 * that here. (The "generic irq" framework may help...)
584 ts->irq_disabled = 1;
585 disable_irq(ts->spi->irq);
587 mod_timer(&ts->timer, jiffies);
590 spin_unlock_irqrestore(&ts->lock, flags);
595 /*--------------------------------------------------------------------------*/
597 /* Must be called with ts->lock held */
598 static void ads7846_disable(struct ads7846 *ts)
605 /* are we waiting for IRQ, or polling? */
607 ts->irq_disabled = 1;
608 disable_irq(ts->spi->irq);
610 /* the timer will run at least once more, and
611 * leave everything in a clean state, IRQ disabled
613 while (ts->pending) {
614 spin_unlock_irq(&ts->lock);
616 spin_lock_irq(&ts->lock);
620 /* we know the chip's in lowpower mode since we always
621 * leave it that way after every request
626 /* Must be called with ts->lock held */
627 static void ads7846_enable(struct ads7846 *ts)
633 ts->irq_disabled = 0;
634 enable_irq(ts->spi->irq);
637 static int ads7846_suspend(struct spi_device *spi, pm_message_t message)
639 struct ads7846 *ts = dev_get_drvdata(&spi->dev);
641 spin_lock_irq(&ts->lock);
643 spi->dev.power.power_state = message;
646 spin_unlock_irq(&ts->lock);
652 static int ads7846_resume(struct spi_device *spi)
654 struct ads7846 *ts = dev_get_drvdata(&spi->dev);
656 spin_lock_irq(&ts->lock);
658 spi->dev.power.power_state = PMSG_ON;
661 spin_unlock_irq(&ts->lock);
666 static int __devinit ads7846_probe(struct spi_device *spi)
669 struct input_dev *input_dev;
670 struct ads7846_platform_data *pdata = spi->dev.platform_data;
671 struct spi_message *m;
672 struct spi_transfer *x;
676 dev_dbg(&spi->dev, "no IRQ?\n");
681 dev_dbg(&spi->dev, "no platform data?\n");
685 /* don't exceed max specified sample rate */
686 if (spi->max_speed_hz > (125000 * SAMPLE_BITS)) {
687 dev_dbg(&spi->dev, "f(sample) %d KHz?\n",
688 (spi->max_speed_hz/SAMPLE_BITS)/1000);
692 /* REVISIT when the irq can be triggered active-low, or if for some
693 * reason the touchscreen isn't hooked up, we don't need to access
696 if (pdata->get_pendown_state == NULL) {
697 dev_dbg(&spi->dev, "no get_pendown_state function?\n");
701 /* We'd set TX wordsize 8 bits and RX wordsize to 13 bits ... except
702 * that even if the hardware can do that, the SPI controller driver
703 * may not. So we stick to very-portable 8 bit words, both RX and TX.
705 spi->bits_per_word = 8;
707 ts = kzalloc(sizeof(struct ads7846), GFP_KERNEL);
708 input_dev = input_allocate_device();
709 if (!ts || !input_dev) {
714 dev_set_drvdata(&spi->dev, ts);
715 spi->dev.power.power_state = PMSG_ON;
718 ts->input = input_dev;
720 init_timer(&ts->timer);
721 ts->timer.data = (unsigned long) ts;
722 ts->timer.function = ads7846_timer;
724 spin_lock_init(&ts->lock);
726 ts->model = pdata->model ? : 7846;
727 ts->vref_delay_usecs = pdata->vref_delay_usecs ? : 100;
728 ts->x_plate_ohms = pdata->x_plate_ohms ? : 400;
729 ts->pressure_max = pdata->pressure_max ? : ~0;
731 if (pdata->filter != NULL) {
732 if (pdata->filter_init != NULL) {
733 err = pdata->filter_init(pdata, &ts->filter_data);
737 ts->filter = pdata->filter;
738 ts->filter_cleanup = pdata->filter_cleanup;
739 } else if (pdata->debounce_max) {
740 ts->debounce_max = pdata->debounce_max;
741 if (ts->debounce_max < 2)
742 ts->debounce_max = 2;
743 ts->debounce_tol = pdata->debounce_tol;
744 ts->debounce_rep = pdata->debounce_rep;
745 ts->filter = ads7846_debounce;
746 ts->filter_data = ts;
748 ts->filter = ads7846_no_filter;
749 ts->get_pendown_state = pdata->get_pendown_state;
751 snprintf(ts->phys, sizeof(ts->phys), "%s/input0", spi->dev.bus_id);
753 input_dev->name = "ADS784x Touchscreen";
754 input_dev->phys = ts->phys;
755 input_dev->cdev.dev = &spi->dev;
757 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
758 input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
759 input_set_abs_params(input_dev, ABS_X,
761 pdata->x_max ? : MAX_12BIT,
763 input_set_abs_params(input_dev, ABS_Y,
765 pdata->y_max ? : MAX_12BIT,
767 input_set_abs_params(input_dev, ABS_PRESSURE,
768 pdata->pressure_min, pdata->pressure_max, 0, 0);
770 /* set up the transfers to read touchscreen state; this assumes we
771 * use formula #2 for pressure, not #3.
778 /* y- still on; turn on only y+ (and ADC) */
780 x->tx_buf = &ts->read_y;
782 spi_message_add_tail(x, m);
785 x->rx_buf = &ts->tc.y;
787 spi_message_add_tail(x, m);
789 m->complete = ads7846_rx_val;
795 /* turn y- off, x+ on, then leave in lowpower */
798 x->tx_buf = &ts->read_x;
800 spi_message_add_tail(x, m);
803 x->rx_buf = &ts->tc.x;
805 spi_message_add_tail(x, m);
807 m->complete = ads7846_rx_val;
810 /* turn y+ off, x- on; we'll use formula #2 */
811 if (ts->model == 7846) {
816 ts->read_z1 = READ_Z1;
817 x->tx_buf = &ts->read_z1;
819 spi_message_add_tail(x, m);
822 x->rx_buf = &ts->tc.z1;
824 spi_message_add_tail(x, m);
826 m->complete = ads7846_rx_val;
833 ts->read_z2 = READ_Z2;
834 x->tx_buf = &ts->read_z2;
836 spi_message_add_tail(x, m);
839 x->rx_buf = &ts->tc.z2;
841 spi_message_add_tail(x, m);
843 m->complete = ads7846_rx_val;
852 ts->pwrdown = PWRDOWN;
853 x->tx_buf = &ts->pwrdown;
855 spi_message_add_tail(x, m);
858 x->rx_buf = &ts->dummy;
861 spi_message_add_tail(x, m);
863 m->complete = ads7846_rx;
868 if (request_irq(spi->irq, ads7846_irq, IRQF_TRIGGER_FALLING,
869 spi->dev.driver->name, ts)) {
870 dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq);
872 goto err_cleanup_filter;
875 dev_info(&spi->dev, "touchscreen, irq %d\n", spi->irq);
877 /* take a first sample, leaving nPENIRQ active; avoid
878 * the touchscreen, in case it's not connected.
880 (void) ads7846_read12_ser(&spi->dev,
881 READ_12BIT_SER(vaux) | ADS_PD10_ALL_ON);
885 ts->attr_group = &ads7846_attr_group;
888 ts->attr_group = &ads7845_attr_group;
891 ts->attr_group = &ads7843_attr_group;
894 err = sysfs_create_group(&spi->dev.kobj, ts->attr_group);
898 err = input_register_device(input_dev);
900 goto err_remove_attr_group;
904 err_remove_attr_group:
905 sysfs_remove_group(&spi->dev.kobj, ts->attr_group);
907 free_irq(spi->irq, ts);
909 if (ts->filter_cleanup)
910 ts->filter_cleanup(ts->filter_data);
912 input_free_device(input_dev);
917 static int __devexit ads7846_remove(struct spi_device *spi)
919 struct ads7846 *ts = dev_get_drvdata(&spi->dev);
921 input_unregister_device(ts->input);
923 ads7846_suspend(spi, PMSG_SUSPEND);
925 sysfs_remove_group(&spi->dev.kobj, ts->attr_group);
927 free_irq(ts->spi->irq, ts);
928 /* suspend left the IRQ disabled */
929 enable_irq(ts->spi->irq);
931 if (ts->filter_cleanup)
932 ts->filter_cleanup(ts->filter_data);
936 dev_dbg(&spi->dev, "unregistered touchscreen\n");
940 static struct spi_driver ads7846_driver = {
943 .bus = &spi_bus_type,
944 .owner = THIS_MODULE,
946 .probe = ads7846_probe,
947 .remove = __devexit_p(ads7846_remove),
948 .suspend = ads7846_suspend,
949 .resume = ads7846_resume,
952 static int __init ads7846_init(void)
954 /* grr, board-specific init should stay out of drivers!! */
956 #ifdef CONFIG_ARCH_OMAP
957 if (machine_is_omap_osk()) {
958 /* GPIO4 = PENIRQ; GPIO6 = BUSY */
959 omap_request_gpio(4);
960 omap_set_gpio_direction(4, 1);
961 omap_request_gpio(6);
962 omap_set_gpio_direction(6, 1);
964 // also TI 1510 Innovator, bitbanging through FPGA
966 // also Palm Tungsten T2
970 // also Dell Axim X50
971 // also HP iPaq H191x/H192x/H415x/H435x
972 // also Intel Lubbock (additional to UCB1400; as temperature sensor)
973 // also Sharp Zaurus C7xx, C8xx (corgi/sheperd/husky)
975 // Atmel at91sam9261-EK uses ads7843
977 // also various AMD Au1x00 devel boards
979 return spi_register_driver(&ads7846_driver);
981 module_init(ads7846_init);
983 static void __exit ads7846_exit(void)
985 spi_unregister_driver(&ads7846_driver);
987 #ifdef CONFIG_ARCH_OMAP
988 if (machine_is_omap_osk()) {
995 module_exit(ads7846_exit);
997 MODULE_DESCRIPTION("ADS7846 TouchScreen Driver");
998 MODULE_LICENSE("GPL");