ads7846.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. /*
  2. * ADS7846 based touchscreen and sensor driver
  3. *
  4. * Copyright (c) 2005 David Brownell
  5. *
  6. * Using code from:
  7. * - corgi_ts.c
  8. * Copyright (C) 2004-2005 Richard Purdie
  9. * - omap_ts.[hc], ads7846.h, ts_osk.c
  10. * Copyright (C) 2002 MontaVista Software
  11. * Copyright (C) 2004 Texas Instruments
  12. * Copyright (C) 2005 Dirk Behme
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License version 2 as
  16. * published by the Free Software Foundation.
  17. */
  18. #include <linux/device.h>
  19. #include <linux/init.h>
  20. #include <linux/delay.h>
  21. #include <linux/input.h>
  22. #include <linux/interrupt.h>
  23. #include <linux/slab.h>
  24. #include <linux/spi/spi.h>
  25. #include <linux/spi/ads7846.h>
  26. #include <asm/irq.h>
  27. #ifdef CONFIG_ARM
  28. #include <asm/mach-types.h>
  29. #ifdef CONFIG_ARCH_OMAP
  30. #include <asm/arch/gpio.h>
  31. #endif
  32. #endif
  33. /*
  34. * This code has been lightly tested on an ads7846.
  35. * Support for ads7843 and ads7845 has only been stubbed in.
  36. *
  37. * Not yet done: investigate the values reported. Are x/y/pressure
  38. * event values sane enough for X11? How accurate are the temperature
  39. * and voltage readings? (System-specific calibration should support
  40. * accuracy of 0.3 degrees C; otherwise it's 2.0 degrees.)
  41. *
  42. * app note sbaa036 talks in more detail about accurate sampling...
  43. * that ought to help in situations like LCDs inducing noise (which
  44. * can also be helped by using synch signals) and more generally.
  45. */
  46. #define TS_POLL_PERIOD msecs_to_jiffies(10)
  47. /* this driver doesn't aim at the peak continuous sample rate */
  48. #define SAMPLE_BITS (8 /*cmd*/ + 16 /*sample*/ + 2 /* before, after */)
  49. struct ts_event {
  50. /* For portability, we can't read 12 bit values using SPI (which
  51. * would make the controller deliver them as native byteorder u16
  52. * with msbs zeroed). Instead, we read them as two 8-bit values,
  53. * which need byteswapping then range adjustment.
  54. */
  55. __be16 x;
  56. __be16 y;
  57. __be16 z1, z2;
  58. };
  59. struct ads7846 {
  60. struct input_dev *input;
  61. char phys[32];
  62. struct spi_device *spi;
  63. u16 model;
  64. u16 vref_delay_usecs;
  65. u16 x_plate_ohms;
  66. u8 read_x, read_y, read_z1, read_z2;
  67. struct ts_event tc;
  68. struct spi_transfer xfer[8];
  69. struct spi_message msg;
  70. spinlock_t lock;
  71. struct timer_list timer; /* P: lock */
  72. unsigned pendown:1; /* P: lock */
  73. unsigned pending:1; /* P: lock */
  74. // FIXME remove "irq_disabled"
  75. unsigned irq_disabled:1; /* P: lock */
  76. };
  77. /* leave chip selected when we're done, for quicker re-select? */
  78. #if 0
  79. #define CS_CHANGE(xfer) ((xfer).cs_change = 1)
  80. #else
  81. #define CS_CHANGE(xfer) ((xfer).cs_change = 0)
  82. #endif
  83. /*--------------------------------------------------------------------------*/
  84. /* The ADS7846 has touchscreen and other sensors.
  85. * Earlier ads784x chips are somewhat compatible.
  86. */
  87. #define ADS_START (1 << 7)
  88. #define ADS_A2A1A0_d_y (1 << 4) /* differential */
  89. #define ADS_A2A1A0_d_z1 (3 << 4) /* differential */
  90. #define ADS_A2A1A0_d_z2 (4 << 4) /* differential */
  91. #define ADS_A2A1A0_d_x (5 << 4) /* differential */
  92. #define ADS_A2A1A0_temp0 (0 << 4) /* non-differential */
  93. #define ADS_A2A1A0_vbatt (2 << 4) /* non-differential */
  94. #define ADS_A2A1A0_vaux (6 << 4) /* non-differential */
  95. #define ADS_A2A1A0_temp1 (7 << 4) /* non-differential */
  96. #define ADS_8_BIT (1 << 3)
  97. #define ADS_12_BIT (0 << 3)
  98. #define ADS_SER (1 << 2) /* non-differential */
  99. #define ADS_DFR (0 << 2) /* differential */
  100. #define ADS_PD10_PDOWN (0 << 0) /* lowpower mode + penirq */
  101. #define ADS_PD10_ADC_ON (1 << 0) /* ADC on */
  102. #define ADS_PD10_REF_ON (2 << 0) /* vREF on + penirq */
  103. #define ADS_PD10_ALL_ON (3 << 0) /* ADC + vREF on */
  104. #define MAX_12BIT ((1<<12)-1)
  105. /* leave ADC powered up (disables penirq) between differential samples */
  106. #define READ_12BIT_DFR(x) (ADS_START | ADS_A2A1A0_d_ ## x \
  107. | ADS_12_BIT | ADS_DFR)
  108. #define READ_Y (READ_12BIT_DFR(y) | ADS_PD10_ADC_ON)
  109. #define READ_Z1 (READ_12BIT_DFR(z1) | ADS_PD10_ADC_ON)
  110. #define READ_Z2 (READ_12BIT_DFR(z2) | ADS_PD10_ADC_ON)
  111. #define READ_X (READ_12BIT_DFR(x) | ADS_PD10_PDOWN) /* LAST */
  112. /* single-ended samples need to first power up reference voltage;
  113. * we leave both ADC and VREF powered
  114. */
  115. #define READ_12BIT_SER(x) (ADS_START | ADS_A2A1A0_ ## x \
  116. | ADS_12_BIT | ADS_SER)
  117. #define REF_ON (READ_12BIT_DFR(x) | ADS_PD10_ALL_ON)
  118. #define REF_OFF (READ_12BIT_DFR(y) | ADS_PD10_PDOWN)
  119. /*--------------------------------------------------------------------------*/
  120. /*
  121. * Non-touchscreen sensors only use single-ended conversions.
  122. */
  123. struct ser_req {
  124. u8 ref_on;
  125. u8 command;
  126. u8 ref_off;
  127. u16 scratch;
  128. __be16 sample;
  129. struct spi_message msg;
  130. struct spi_transfer xfer[6];
  131. };
  132. static int ads7846_read12_ser(struct device *dev, unsigned command)
  133. {
  134. struct spi_device *spi = to_spi_device(dev);
  135. struct ads7846 *ts = dev_get_drvdata(dev);
  136. struct ser_req *req = kzalloc(sizeof *req, SLAB_KERNEL);
  137. int status;
  138. int sample;
  139. int i;
  140. if (!req)
  141. return -ENOMEM;
  142. INIT_LIST_HEAD(&req->msg.transfers);
  143. /* activate reference, so it has time to settle; */
  144. req->ref_on = REF_ON;
  145. req->xfer[0].tx_buf = &req->ref_on;
  146. req->xfer[0].len = 1;
  147. req->xfer[1].rx_buf = &req->scratch;
  148. req->xfer[1].len = 2;
  149. /*
  150. * for external VREF, 0 usec (and assume it's always on);
  151. * for 1uF, use 800 usec;
  152. * no cap, 100 usec.
  153. */
  154. req->xfer[1].delay_usecs = ts->vref_delay_usecs;
  155. /* take sample */
  156. req->command = (u8) command;
  157. req->xfer[2].tx_buf = &req->command;
  158. req->xfer[2].len = 1;
  159. req->xfer[3].rx_buf = &req->sample;
  160. req->xfer[3].len = 2;
  161. /* REVISIT: take a few more samples, and compare ... */
  162. /* turn off reference */
  163. req->ref_off = REF_OFF;
  164. req->xfer[4].tx_buf = &req->ref_off;
  165. req->xfer[4].len = 1;
  166. req->xfer[5].rx_buf = &req->scratch;
  167. req->xfer[5].len = 2;
  168. CS_CHANGE(req->xfer[5]);
  169. /* group all the transfers together, so we can't interfere with
  170. * reading touchscreen state; disable penirq while sampling
  171. */
  172. for (i = 0; i < 6; i++)
  173. spi_message_add_tail(&req->xfer[i], &req->msg);
  174. disable_irq(spi->irq);
  175. status = spi_sync(spi, &req->msg);
  176. enable_irq(spi->irq);
  177. if (req->msg.status)
  178. status = req->msg.status;
  179. sample = be16_to_cpu(req->sample);
  180. sample = sample >> 4;
  181. kfree(req);
  182. return status ? status : sample;
  183. }
  184. #define SHOW(name) static ssize_t \
  185. name ## _show(struct device *dev, struct device_attribute *attr, char *buf) \
  186. { \
  187. ssize_t v = ads7846_read12_ser(dev, \
  188. READ_12BIT_SER(name) | ADS_PD10_ALL_ON); \
  189. if (v < 0) \
  190. return v; \
  191. return sprintf(buf, "%u\n", (unsigned) v); \
  192. } \
  193. static DEVICE_ATTR(name, S_IRUGO, name ## _show, NULL);
  194. SHOW(temp0)
  195. SHOW(temp1)
  196. SHOW(vaux)
  197. SHOW(vbatt)
  198. /*--------------------------------------------------------------------------*/
  199. /*
  200. * PENIRQ only kicks the timer. The timer only reissues the SPI transfer,
  201. * to retrieve touchscreen status.
  202. *
  203. * The SPI transfer completion callback does the real work. It reports
  204. * touchscreen events and reactivates the timer (or IRQ) as appropriate.
  205. */
  206. static void ads7846_rx(void *ads)
  207. {
  208. struct ads7846 *ts = ads;
  209. struct input_dev *input_dev = ts->input;
  210. unsigned Rt;
  211. unsigned sync = 0;
  212. u16 x, y, z1, z2;
  213. unsigned long flags;
  214. /* adjust: 12 bit samples (left aligned), built from
  215. * two 8 bit values writen msb-first.
  216. */
  217. x = be16_to_cpu(ts->tc.x) >> 4;
  218. y = be16_to_cpu(ts->tc.y) >> 4;
  219. z1 = be16_to_cpu(ts->tc.z1) >> 4;
  220. z2 = be16_to_cpu(ts->tc.z2) >> 4;
  221. /* range filtering */
  222. if (x == MAX_12BIT)
  223. x = 0;
  224. if (x && z1 && ts->spi->dev.power.power_state.event == PM_EVENT_ON) {
  225. /* compute touch pressure resistance using equation #2 */
  226. Rt = z2;
  227. Rt -= z1;
  228. Rt *= x;
  229. Rt *= ts->x_plate_ohms;
  230. Rt /= z1;
  231. Rt = (Rt + 2047) >> 12;
  232. } else
  233. Rt = 0;
  234. /* NOTE: "pendown" is inferred from pressure; we don't rely on
  235. * being able to check nPENIRQ status, or "friendly" trigger modes
  236. * (both-edges is much better than just-falling or low-level).
  237. *
  238. * REVISIT: some boards may require reading nPENIRQ; it's
  239. * needed on 7843. and 7845 reads pressure differently...
  240. *
  241. * REVISIT: the touchscreen might not be connected; this code
  242. * won't notice that, even if nPENIRQ never fires ...
  243. */
  244. if (!ts->pendown && Rt != 0) {
  245. input_report_key(input_dev, BTN_TOUCH, 1);
  246. sync = 1;
  247. } else if (ts->pendown && Rt == 0) {
  248. input_report_key(input_dev, BTN_TOUCH, 0);
  249. sync = 1;
  250. }
  251. if (Rt) {
  252. input_report_abs(input_dev, ABS_X, x);
  253. input_report_abs(input_dev, ABS_Y, y);
  254. input_report_abs(input_dev, ABS_PRESSURE, Rt);
  255. sync = 1;
  256. }
  257. if (sync)
  258. input_sync(input_dev);
  259. #ifdef VERBOSE
  260. if (Rt || ts->pendown)
  261. pr_debug("%s: %d/%d/%d%s\n", ts->spi->dev.bus_id,
  262. x, y, Rt, Rt ? "" : " UP");
  263. #endif
  264. /* don't retrigger while we're suspended */
  265. spin_lock_irqsave(&ts->lock, flags);
  266. ts->pendown = (Rt != 0);
  267. ts->pending = 0;
  268. if (ts->spi->dev.power.power_state.event == PM_EVENT_ON) {
  269. if (ts->pendown)
  270. mod_timer(&ts->timer, jiffies + TS_POLL_PERIOD);
  271. else if (ts->irq_disabled) {
  272. ts->irq_disabled = 0;
  273. enable_irq(ts->spi->irq);
  274. }
  275. }
  276. spin_unlock_irqrestore(&ts->lock, flags);
  277. }
  278. static void ads7846_timer(unsigned long handle)
  279. {
  280. struct ads7846 *ts = (void *)handle;
  281. int status = 0;
  282. unsigned long flags;
  283. spin_lock_irqsave(&ts->lock, flags);
  284. if (!ts->pending) {
  285. ts->pending = 1;
  286. if (!ts->irq_disabled) {
  287. ts->irq_disabled = 1;
  288. disable_irq(ts->spi->irq);
  289. }
  290. status = spi_async(ts->spi, &ts->msg);
  291. if (status)
  292. dev_err(&ts->spi->dev, "spi_async --> %d\n",
  293. status);
  294. }
  295. spin_unlock_irqrestore(&ts->lock, flags);
  296. }
  297. static irqreturn_t ads7846_irq(int irq, void *handle, struct pt_regs *regs)
  298. {
  299. ads7846_timer((unsigned long) handle);
  300. return IRQ_HANDLED;
  301. }
  302. /*--------------------------------------------------------------------------*/
  303. static int
  304. ads7846_suspend(struct spi_device *spi, pm_message_t message)
  305. {
  306. struct ads7846 *ts = dev_get_drvdata(&spi->dev);
  307. unsigned long flags;
  308. spin_lock_irqsave(&ts->lock, flags);
  309. spi->dev.power.power_state = message;
  310. /* are we waiting for IRQ, or polling? */
  311. if (!ts->pendown) {
  312. if (!ts->irq_disabled) {
  313. ts->irq_disabled = 1;
  314. disable_irq(ts->spi->irq);
  315. }
  316. } else {
  317. /* polling; force a final SPI completion;
  318. * that will clean things up neatly
  319. */
  320. if (!ts->pending)
  321. mod_timer(&ts->timer, jiffies);
  322. while (ts->pendown || ts->pending) {
  323. spin_unlock_irqrestore(&ts->lock, flags);
  324. udelay(10);
  325. spin_lock_irqsave(&ts->lock, flags);
  326. }
  327. }
  328. /* we know the chip's in lowpower mode since we always
  329. * leave it that way after every request
  330. */
  331. spin_unlock_irqrestore(&ts->lock, flags);
  332. return 0;
  333. }
  334. static int ads7846_resume(struct spi_device *spi)
  335. {
  336. struct ads7846 *ts = dev_get_drvdata(&spi->dev);
  337. ts->irq_disabled = 0;
  338. enable_irq(ts->spi->irq);
  339. spi->dev.power.power_state = PMSG_ON;
  340. return 0;
  341. }
  342. static int __devinit ads7846_probe(struct spi_device *spi)
  343. {
  344. struct ads7846 *ts;
  345. struct input_dev *input_dev;
  346. struct ads7846_platform_data *pdata = spi->dev.platform_data;
  347. struct spi_transfer *x;
  348. int err;
  349. if (!spi->irq) {
  350. dev_dbg(&spi->dev, "no IRQ?\n");
  351. return -ENODEV;
  352. }
  353. if (!pdata) {
  354. dev_dbg(&spi->dev, "no platform data?\n");
  355. return -ENODEV;
  356. }
  357. /* don't exceed max specified sample rate */
  358. if (spi->max_speed_hz > (125000 * SAMPLE_BITS)) {
  359. dev_dbg(&spi->dev, "f(sample) %d KHz?\n",
  360. (spi->max_speed_hz/SAMPLE_BITS)/1000);
  361. return -EINVAL;
  362. }
  363. /* We'd set the wordsize to 12 bits ... except that some controllers
  364. * will then treat the 8 bit command words as 12 bits (and drop the
  365. * four MSBs of the 12 bit result). Result: inputs must be shifted
  366. * to discard the four garbage LSBs.
  367. */
  368. ts = kzalloc(sizeof(struct ads7846), GFP_KERNEL);
  369. input_dev = input_allocate_device();
  370. if (!ts || !input_dev) {
  371. err = -ENOMEM;
  372. goto err_free_mem;
  373. }
  374. dev_set_drvdata(&spi->dev, ts);
  375. spi->dev.power.power_state = PMSG_ON;
  376. ts->spi = spi;
  377. ts->input = input_dev;
  378. init_timer(&ts->timer);
  379. ts->timer.data = (unsigned long) ts;
  380. ts->timer.function = ads7846_timer;
  381. ts->model = pdata->model ? : 7846;
  382. ts->vref_delay_usecs = pdata->vref_delay_usecs ? : 100;
  383. ts->x_plate_ohms = pdata->x_plate_ohms ? : 400;
  384. snprintf(ts->phys, sizeof(ts->phys), "%s/input0", spi->dev.bus_id);
  385. input_dev->name = "ADS784x Touchscreen";
  386. input_dev->phys = ts->phys;
  387. input_dev->cdev.dev = &spi->dev;
  388. input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
  389. input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
  390. input_set_abs_params(input_dev, ABS_X,
  391. pdata->x_min ? : 0,
  392. pdata->x_max ? : MAX_12BIT,
  393. 0, 0);
  394. input_set_abs_params(input_dev, ABS_Y,
  395. pdata->y_min ? : 0,
  396. pdata->y_max ? : MAX_12BIT,
  397. 0, 0);
  398. input_set_abs_params(input_dev, ABS_PRESSURE,
  399. pdata->pressure_min, pdata->pressure_max, 0, 0);
  400. /* set up the transfers to read touchscreen state; this assumes we
  401. * use formula #2 for pressure, not #3.
  402. */
  403. INIT_LIST_HEAD(&ts->msg.transfers);
  404. x = ts->xfer;
  405. /* y- still on; turn on only y+ (and ADC) */
  406. ts->read_y = READ_Y;
  407. x->tx_buf = &ts->read_y;
  408. x->len = 1;
  409. spi_message_add_tail(x, &ts->msg);
  410. x++;
  411. x->rx_buf = &ts->tc.y;
  412. x->len = 2;
  413. spi_message_add_tail(x, &ts->msg);
  414. /* turn y+ off, x- on; we'll use formula #2 */
  415. if (ts->model == 7846) {
  416. x++;
  417. ts->read_z1 = READ_Z1;
  418. x->tx_buf = &ts->read_z1;
  419. x->len = 1;
  420. spi_message_add_tail(x, &ts->msg);
  421. x++;
  422. x->rx_buf = &ts->tc.z1;
  423. x->len = 2;
  424. spi_message_add_tail(x, &ts->msg);
  425. x++;
  426. ts->read_z2 = READ_Z2;
  427. x->tx_buf = &ts->read_z2;
  428. x->len = 1;
  429. spi_message_add_tail(x, &ts->msg);
  430. x++;
  431. x->rx_buf = &ts->tc.z2;
  432. x->len = 2;
  433. spi_message_add_tail(x, &ts->msg);
  434. }
  435. /* turn y- off, x+ on, then leave in lowpower */
  436. x++;
  437. ts->read_x = READ_X;
  438. x->tx_buf = &ts->read_x;
  439. x->len = 1;
  440. spi_message_add_tail(x, &ts->msg);
  441. x++;
  442. x->rx_buf = &ts->tc.x;
  443. x->len = 2;
  444. CS_CHANGE(*x);
  445. spi_message_add_tail(x, &ts->msg);
  446. ts->msg.complete = ads7846_rx;
  447. ts->msg.context = ts;
  448. if (request_irq(spi->irq, ads7846_irq,
  449. SA_SAMPLE_RANDOM | SA_TRIGGER_FALLING,
  450. spi->dev.bus_id, ts)) {
  451. dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq);
  452. err = -EBUSY;
  453. goto err_free_mem;
  454. }
  455. dev_info(&spi->dev, "touchscreen, irq %d\n", spi->irq);
  456. /* take a first sample, leaving nPENIRQ active; avoid
  457. * the touchscreen, in case it's not connected.
  458. */
  459. (void) ads7846_read12_ser(&spi->dev,
  460. READ_12BIT_SER(vaux) | ADS_PD10_ALL_ON);
  461. /* ads7843/7845 don't have temperature sensors, and
  462. * use the other sensors a bit differently too
  463. */
  464. if (ts->model == 7846) {
  465. device_create_file(&spi->dev, &dev_attr_temp0);
  466. device_create_file(&spi->dev, &dev_attr_temp1);
  467. }
  468. if (ts->model != 7845)
  469. device_create_file(&spi->dev, &dev_attr_vbatt);
  470. device_create_file(&spi->dev, &dev_attr_vaux);
  471. err = input_register_device(input_dev);
  472. if (err)
  473. goto err_free_irq;
  474. return 0;
  475. err_free_irq:
  476. free_irq(spi->irq, ts);
  477. err_free_mem:
  478. input_free_device(input_dev);
  479. kfree(ts);
  480. return err;
  481. }
  482. static int __devexit ads7846_remove(struct spi_device *spi)
  483. {
  484. struct ads7846 *ts = dev_get_drvdata(&spi->dev);
  485. ads7846_suspend(spi, PMSG_SUSPEND);
  486. free_irq(ts->spi->irq, ts);
  487. if (ts->irq_disabled)
  488. enable_irq(ts->spi->irq);
  489. if (ts->model == 7846) {
  490. device_remove_file(&spi->dev, &dev_attr_temp0);
  491. device_remove_file(&spi->dev, &dev_attr_temp1);
  492. }
  493. if (ts->model != 7845)
  494. device_remove_file(&spi->dev, &dev_attr_vbatt);
  495. device_remove_file(&spi->dev, &dev_attr_vaux);
  496. input_unregister_device(ts->input);
  497. kfree(ts);
  498. dev_dbg(&spi->dev, "unregistered touchscreen\n");
  499. return 0;
  500. }
  501. static struct spi_driver ads7846_driver = {
  502. .driver = {
  503. .name = "ads7846",
  504. .bus = &spi_bus_type,
  505. .owner = THIS_MODULE,
  506. },
  507. .probe = ads7846_probe,
  508. .remove = __devexit_p(ads7846_remove),
  509. .suspend = ads7846_suspend,
  510. .resume = ads7846_resume,
  511. };
  512. static int __init ads7846_init(void)
  513. {
  514. /* grr, board-specific init should stay out of drivers!! */
  515. #ifdef CONFIG_ARCH_OMAP
  516. if (machine_is_omap_osk()) {
  517. /* GPIO4 = PENIRQ; GPIO6 = BUSY */
  518. omap_request_gpio(4);
  519. omap_set_gpio_direction(4, 1);
  520. omap_request_gpio(6);
  521. omap_set_gpio_direction(6, 1);
  522. }
  523. // also TI 1510 Innovator, bitbanging through FPGA
  524. // also Nokia 770
  525. // also Palm Tungsten T2
  526. #endif
  527. // PXA:
  528. // also Dell Axim X50
  529. // also HP iPaq H191x/H192x/H415x/H435x
  530. // also Intel Lubbock (additional to UCB1400; as temperature sensor)
  531. // also Sharp Zaurus C7xx, C8xx (corgi/sheperd/husky)
  532. // Atmel at91sam9261-EK uses ads7843
  533. // also various AMD Au1x00 devel boards
  534. return spi_register_driver(&ads7846_driver);
  535. }
  536. module_init(ads7846_init);
  537. static void __exit ads7846_exit(void)
  538. {
  539. spi_unregister_driver(&ads7846_driver);
  540. #ifdef CONFIG_ARCH_OMAP
  541. if (machine_is_omap_osk()) {
  542. omap_free_gpio(4);
  543. omap_free_gpio(6);
  544. }
  545. #endif
  546. }
  547. module_exit(ads7846_exit);
  548. MODULE_DESCRIPTION("ADS7846 TouchScreen Driver");
  549. MODULE_LICENSE("GPL");