ads7846.c 16 KB

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