davinci_spi.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186
  1. /*
  2. * Copyright (C) 2009 Texas Instruments.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. */
  18. #include <linux/interrupt.h>
  19. #include <linux/io.h>
  20. #include <linux/gpio.h>
  21. #include <linux/module.h>
  22. #include <linux/delay.h>
  23. #include <linux/platform_device.h>
  24. #include <linux/err.h>
  25. #include <linux/clk.h>
  26. #include <linux/dma-mapping.h>
  27. #include <linux/spi/spi.h>
  28. #include <linux/spi/spi_bitbang.h>
  29. #include <linux/slab.h>
  30. #include <mach/spi.h>
  31. #include <mach/edma.h>
  32. #define SPI_NO_RESOURCE ((resource_size_t)-1)
  33. #define SPI_MAX_CHIPSELECT 2
  34. #define CS_DEFAULT 0xFF
  35. #define SPI_BUFSIZ (SMP_CACHE_BYTES + 1)
  36. #define DAVINCI_DMA_DATA_TYPE_S8 0x01
  37. #define DAVINCI_DMA_DATA_TYPE_S16 0x02
  38. #define DAVINCI_DMA_DATA_TYPE_S32 0x04
  39. #define SPIFMT_PHASE_MASK BIT(16)
  40. #define SPIFMT_POLARITY_MASK BIT(17)
  41. #define SPIFMT_DISTIMER_MASK BIT(18)
  42. #define SPIFMT_SHIFTDIR_MASK BIT(20)
  43. #define SPIFMT_WAITENA_MASK BIT(21)
  44. #define SPIFMT_PARITYENA_MASK BIT(22)
  45. #define SPIFMT_ODD_PARITY_MASK BIT(23)
  46. #define SPIFMT_WDELAY_MASK 0x3f000000u
  47. #define SPIFMT_WDELAY_SHIFT 24
  48. #define SPIFMT_PRESCALE_SHIFT 8
  49. /* SPIPC0 */
  50. #define SPIPC0_DIFUN_MASK BIT(11) /* MISO */
  51. #define SPIPC0_DOFUN_MASK BIT(10) /* MOSI */
  52. #define SPIPC0_CLKFUN_MASK BIT(9) /* CLK */
  53. #define SPIPC0_SPIENA_MASK BIT(8) /* nREADY */
  54. #define SPIINT_MASKALL 0x0101035F
  55. #define SPI_INTLVL_1 0x000001FFu
  56. #define SPI_INTLVL_0 0x00000000u
  57. /* SPIDAT1 (upper 16 bit defines) */
  58. #define SPIDAT1_CSHOLD_MASK BIT(12)
  59. /* SPIGCR1 */
  60. #define SPIGCR1_CLKMOD_MASK BIT(1)
  61. #define SPIGCR1_MASTER_MASK BIT(0)
  62. #define SPIGCR1_LOOPBACK_MASK BIT(16)
  63. #define SPIGCR1_SPIENA_MASK BIT(24)
  64. /* SPIBUF */
  65. #define SPIBUF_TXFULL_MASK BIT(29)
  66. #define SPIBUF_RXEMPTY_MASK BIT(31)
  67. /* Error Masks */
  68. #define SPIFLG_DLEN_ERR_MASK BIT(0)
  69. #define SPIFLG_TIMEOUT_MASK BIT(1)
  70. #define SPIFLG_PARERR_MASK BIT(2)
  71. #define SPIFLG_DESYNC_MASK BIT(3)
  72. #define SPIFLG_BITERR_MASK BIT(4)
  73. #define SPIFLG_OVRRUN_MASK BIT(6)
  74. #define SPIFLG_RX_INTR_MASK BIT(8)
  75. #define SPIFLG_TX_INTR_MASK BIT(9)
  76. #define SPIFLG_BUF_INIT_ACTIVE_MASK BIT(24)
  77. #define SPIINT_BITERR_INTR BIT(4)
  78. #define SPIINT_OVRRUN_INTR BIT(6)
  79. #define SPIINT_RX_INTR BIT(8)
  80. #define SPIINT_TX_INTR BIT(9)
  81. #define SPIINT_DMA_REQ_EN BIT(16)
  82. #define SPI_T2CDELAY_SHIFT 16
  83. #define SPI_C2TDELAY_SHIFT 24
  84. /* SPI Controller registers */
  85. #define SPIGCR0 0x00
  86. #define SPIGCR1 0x04
  87. #define SPIINT 0x08
  88. #define SPILVL 0x0c
  89. #define SPIFLG 0x10
  90. #define SPIPC0 0x14
  91. #define SPIDAT1 0x3c
  92. #define SPIBUF 0x40
  93. #define SPIDELAY 0x48
  94. #define SPIDEF 0x4c
  95. #define SPIFMT0 0x50
  96. struct davinci_spi_slave {
  97. u32 cmd_to_write;
  98. u32 clk_ctrl_to_write;
  99. u32 bytes_per_word;
  100. u8 active_cs;
  101. };
  102. /* We have 2 DMA channels per CS, one for RX and one for TX */
  103. struct davinci_spi_dma {
  104. int dma_tx_channel;
  105. int dma_rx_channel;
  106. int dma_tx_sync_dev;
  107. int dma_rx_sync_dev;
  108. enum dma_event_q eventq;
  109. struct completion dma_tx_completion;
  110. struct completion dma_rx_completion;
  111. };
  112. /* SPI Controller driver's private data. */
  113. struct davinci_spi {
  114. struct spi_bitbang bitbang;
  115. struct clk *clk;
  116. u8 version;
  117. resource_size_t pbase;
  118. void __iomem *base;
  119. size_t region_size;
  120. u32 irq;
  121. struct completion done;
  122. const void *tx;
  123. void *rx;
  124. u8 *tmp_buf;
  125. int count;
  126. struct davinci_spi_dma *dma_channels;
  127. struct davinci_spi_platform_data *pdata;
  128. void (*get_rx)(u32 rx_data, struct davinci_spi *);
  129. u32 (*get_tx)(struct davinci_spi *);
  130. struct davinci_spi_slave slave[SPI_MAX_CHIPSELECT];
  131. };
  132. static struct davinci_spi_config davinci_spi_default_cfg;
  133. static unsigned use_dma;
  134. static void davinci_spi_rx_buf_u8(u32 data, struct davinci_spi *davinci_spi)
  135. {
  136. u8 *rx = davinci_spi->rx;
  137. *rx++ = (u8)data;
  138. davinci_spi->rx = rx;
  139. }
  140. static void davinci_spi_rx_buf_u16(u32 data, struct davinci_spi *davinci_spi)
  141. {
  142. u16 *rx = davinci_spi->rx;
  143. *rx++ = (u16)data;
  144. davinci_spi->rx = rx;
  145. }
  146. static u32 davinci_spi_tx_buf_u8(struct davinci_spi *davinci_spi)
  147. {
  148. u32 data;
  149. const u8 *tx = davinci_spi->tx;
  150. data = *tx++;
  151. davinci_spi->tx = tx;
  152. return data;
  153. }
  154. static u32 davinci_spi_tx_buf_u16(struct davinci_spi *davinci_spi)
  155. {
  156. u32 data;
  157. const u16 *tx = davinci_spi->tx;
  158. data = *tx++;
  159. davinci_spi->tx = tx;
  160. return data;
  161. }
  162. static inline void set_io_bits(void __iomem *addr, u32 bits)
  163. {
  164. u32 v = ioread32(addr);
  165. v |= bits;
  166. iowrite32(v, addr);
  167. }
  168. static inline void clear_io_bits(void __iomem *addr, u32 bits)
  169. {
  170. u32 v = ioread32(addr);
  171. v &= ~bits;
  172. iowrite32(v, addr);
  173. }
  174. static void davinci_spi_set_dma_req(const struct spi_device *spi, int enable)
  175. {
  176. struct davinci_spi *davinci_spi = spi_master_get_devdata(spi->master);
  177. if (enable)
  178. set_io_bits(davinci_spi->base + SPIINT, SPIINT_DMA_REQ_EN);
  179. else
  180. clear_io_bits(davinci_spi->base + SPIINT, SPIINT_DMA_REQ_EN);
  181. }
  182. /*
  183. * Interface to control the chip select signal
  184. */
  185. static void davinci_spi_chipselect(struct spi_device *spi, int value)
  186. {
  187. struct davinci_spi *davinci_spi;
  188. struct davinci_spi_platform_data *pdata;
  189. u8 chip_sel = spi->chip_select;
  190. u16 spidat1_cfg = CS_DEFAULT;
  191. bool gpio_chipsel = false;
  192. davinci_spi = spi_master_get_devdata(spi->master);
  193. pdata = davinci_spi->pdata;
  194. if (pdata->chip_sel && chip_sel < pdata->num_chipselect &&
  195. pdata->chip_sel[chip_sel] != SPI_INTERN_CS)
  196. gpio_chipsel = true;
  197. /*
  198. * Board specific chip select logic decides the polarity and cs
  199. * line for the controller
  200. */
  201. if (gpio_chipsel) {
  202. if (value == BITBANG_CS_ACTIVE)
  203. gpio_set_value(pdata->chip_sel[chip_sel], 0);
  204. else
  205. gpio_set_value(pdata->chip_sel[chip_sel], 1);
  206. } else {
  207. if (value == BITBANG_CS_ACTIVE) {
  208. spidat1_cfg |= SPIDAT1_CSHOLD_MASK;
  209. spidat1_cfg &= ~(0x1 << chip_sel);
  210. }
  211. iowrite16(spidat1_cfg, davinci_spi->base + SPIDAT1 + 2);
  212. }
  213. }
  214. /**
  215. * davinci_spi_get_prescale - Calculates the correct prescale value
  216. * @maxspeed_hz: the maximum rate the SPI clock can run at
  217. *
  218. * This function calculates the prescale value that generates a clock rate
  219. * less than or equal to the specified maximum.
  220. *
  221. * Returns: calculated prescale - 1 for easy programming into SPI registers
  222. * or negative error number if valid prescalar cannot be updated.
  223. */
  224. static inline int davinci_spi_get_prescale(struct davinci_spi *davinci_spi,
  225. u32 max_speed_hz)
  226. {
  227. int ret;
  228. ret = DIV_ROUND_UP(clk_get_rate(davinci_spi->clk), max_speed_hz);
  229. if (ret < 3 || ret > 256)
  230. return -EINVAL;
  231. return ret - 1;
  232. }
  233. /**
  234. * davinci_spi_setup_transfer - This functions will determine transfer method
  235. * @spi: spi device on which data transfer to be done
  236. * @t: spi transfer in which transfer info is filled
  237. *
  238. * This function determines data transfer method (8/16/32 bit transfer).
  239. * It will also set the SPI Clock Control register according to
  240. * SPI slave device freq.
  241. */
  242. static int davinci_spi_setup_transfer(struct spi_device *spi,
  243. struct spi_transfer *t)
  244. {
  245. struct davinci_spi *davinci_spi;
  246. struct davinci_spi_config *spicfg;
  247. u8 bits_per_word = 0;
  248. u32 hz = 0, spifmt = 0, prescale = 0;
  249. davinci_spi = spi_master_get_devdata(spi->master);
  250. spicfg = (struct davinci_spi_config *)spi->controller_data;
  251. if (!spicfg)
  252. spicfg = &davinci_spi_default_cfg;
  253. if (t) {
  254. bits_per_word = t->bits_per_word;
  255. hz = t->speed_hz;
  256. }
  257. /* if bits_per_word is not set then set it default */
  258. if (!bits_per_word)
  259. bits_per_word = spi->bits_per_word;
  260. /*
  261. * Assign function pointer to appropriate transfer method
  262. * 8bit, 16bit or 32bit transfer
  263. */
  264. if (bits_per_word <= 8 && bits_per_word >= 2) {
  265. davinci_spi->get_rx = davinci_spi_rx_buf_u8;
  266. davinci_spi->get_tx = davinci_spi_tx_buf_u8;
  267. davinci_spi->slave[spi->chip_select].bytes_per_word = 1;
  268. } else if (bits_per_word <= 16 && bits_per_word >= 2) {
  269. davinci_spi->get_rx = davinci_spi_rx_buf_u16;
  270. davinci_spi->get_tx = davinci_spi_tx_buf_u16;
  271. davinci_spi->slave[spi->chip_select].bytes_per_word = 2;
  272. } else
  273. return -EINVAL;
  274. if (!hz)
  275. hz = spi->max_speed_hz;
  276. /* Set up SPIFMTn register, unique to this chipselect. */
  277. prescale = davinci_spi_get_prescale(davinci_spi, hz);
  278. if (prescale < 0)
  279. return prescale;
  280. spifmt = (prescale << SPIFMT_PRESCALE_SHIFT) | (bits_per_word & 0x1f);
  281. if (spi->mode & SPI_LSB_FIRST)
  282. spifmt |= SPIFMT_SHIFTDIR_MASK;
  283. if (spi->mode & SPI_CPOL)
  284. spifmt |= SPIFMT_POLARITY_MASK;
  285. if (!(spi->mode & SPI_CPHA))
  286. spifmt |= SPIFMT_PHASE_MASK;
  287. /*
  288. * Version 1 hardware supports two basic SPI modes:
  289. * - Standard SPI mode uses 4 pins, with chipselect
  290. * - 3 pin SPI is a 4 pin variant without CS (SPI_NO_CS)
  291. * (distinct from SPI_3WIRE, with just one data wire;
  292. * or similar variants without MOSI or without MISO)
  293. *
  294. * Version 2 hardware supports an optional handshaking signal,
  295. * so it can support two more modes:
  296. * - 5 pin SPI variant is standard SPI plus SPI_READY
  297. * - 4 pin with enable is (SPI_READY | SPI_NO_CS)
  298. */
  299. if (davinci_spi->version == SPI_VERSION_2) {
  300. spifmt |= ((spicfg->wdelay << SPIFMT_WDELAY_SHIFT)
  301. & SPIFMT_WDELAY_MASK);
  302. if (spicfg->odd_parity)
  303. spifmt |= SPIFMT_ODD_PARITY_MASK;
  304. if (spicfg->parity_enable)
  305. spifmt |= SPIFMT_PARITYENA_MASK;
  306. if (spicfg->timer_disable)
  307. spifmt |= SPIFMT_DISTIMER_MASK;
  308. if (spi->mode & SPI_READY)
  309. spifmt |= SPIFMT_WAITENA_MASK;
  310. }
  311. iowrite32(spifmt, davinci_spi->base + SPIFMT0);
  312. return 0;
  313. }
  314. static void davinci_spi_dma_rx_callback(unsigned lch, u16 ch_status, void *data)
  315. {
  316. struct spi_device *spi = (struct spi_device *)data;
  317. struct davinci_spi *davinci_spi;
  318. struct davinci_spi_dma *davinci_spi_dma;
  319. davinci_spi = spi_master_get_devdata(spi->master);
  320. davinci_spi_dma = &(davinci_spi->dma_channels[spi->chip_select]);
  321. if (ch_status == DMA_COMPLETE)
  322. edma_stop(davinci_spi_dma->dma_rx_channel);
  323. else
  324. edma_clean_channel(davinci_spi_dma->dma_rx_channel);
  325. complete(&davinci_spi_dma->dma_rx_completion);
  326. /* We must disable the DMA RX request */
  327. davinci_spi_set_dma_req(spi, 0);
  328. }
  329. static void davinci_spi_dma_tx_callback(unsigned lch, u16 ch_status, void *data)
  330. {
  331. struct spi_device *spi = (struct spi_device *)data;
  332. struct davinci_spi *davinci_spi;
  333. struct davinci_spi_dma *davinci_spi_dma;
  334. davinci_spi = spi_master_get_devdata(spi->master);
  335. davinci_spi_dma = &(davinci_spi->dma_channels[spi->chip_select]);
  336. if (ch_status == DMA_COMPLETE)
  337. edma_stop(davinci_spi_dma->dma_tx_channel);
  338. else
  339. edma_clean_channel(davinci_spi_dma->dma_tx_channel);
  340. complete(&davinci_spi_dma->dma_tx_completion);
  341. /* We must disable the DMA TX request */
  342. davinci_spi_set_dma_req(spi, 0);
  343. }
  344. static int davinci_spi_request_dma(struct spi_device *spi)
  345. {
  346. struct davinci_spi *davinci_spi;
  347. struct davinci_spi_dma *davinci_spi_dma;
  348. struct device *sdev;
  349. int r;
  350. davinci_spi = spi_master_get_devdata(spi->master);
  351. davinci_spi_dma = &davinci_spi->dma_channels[spi->chip_select];
  352. sdev = davinci_spi->bitbang.master->dev.parent;
  353. r = edma_alloc_channel(davinci_spi_dma->dma_rx_sync_dev,
  354. davinci_spi_dma_rx_callback, spi,
  355. davinci_spi_dma->eventq);
  356. if (r < 0) {
  357. dev_dbg(sdev, "Unable to request DMA channel for SPI RX\n");
  358. return -EAGAIN;
  359. }
  360. davinci_spi_dma->dma_rx_channel = r;
  361. r = edma_alloc_channel(davinci_spi_dma->dma_tx_sync_dev,
  362. davinci_spi_dma_tx_callback, spi,
  363. davinci_spi_dma->eventq);
  364. if (r < 0) {
  365. edma_free_channel(davinci_spi_dma->dma_rx_channel);
  366. davinci_spi_dma->dma_rx_channel = -1;
  367. dev_dbg(sdev, "Unable to request DMA channel for SPI TX\n");
  368. return -EAGAIN;
  369. }
  370. davinci_spi_dma->dma_tx_channel = r;
  371. return 0;
  372. }
  373. /**
  374. * davinci_spi_setup - This functions will set default transfer method
  375. * @spi: spi device on which data transfer to be done
  376. *
  377. * This functions sets the default transfer method.
  378. */
  379. static int davinci_spi_setup(struct spi_device *spi)
  380. {
  381. int retval;
  382. struct davinci_spi *davinci_spi;
  383. struct davinci_spi_dma *davinci_spi_dma;
  384. davinci_spi = spi_master_get_devdata(spi->master);
  385. /* if bits per word length is zero then set it default 8 */
  386. if (!spi->bits_per_word)
  387. spi->bits_per_word = 8;
  388. davinci_spi->slave[spi->chip_select].cmd_to_write = 0;
  389. if (use_dma && davinci_spi->dma_channels) {
  390. davinci_spi_dma = &davinci_spi->dma_channels[spi->chip_select];
  391. if ((davinci_spi_dma->dma_rx_channel == -1)
  392. || (davinci_spi_dma->dma_tx_channel == -1)) {
  393. retval = davinci_spi_request_dma(spi);
  394. if (retval < 0)
  395. return retval;
  396. }
  397. }
  398. retval = davinci_spi_setup_transfer(spi, NULL);
  399. return retval;
  400. }
  401. static void davinci_spi_cleanup(struct spi_device *spi)
  402. {
  403. struct davinci_spi *davinci_spi = spi_master_get_devdata(spi->master);
  404. struct davinci_spi_dma *davinci_spi_dma;
  405. davinci_spi_dma = &davinci_spi->dma_channels[spi->chip_select];
  406. if (use_dma && davinci_spi->dma_channels) {
  407. davinci_spi_dma = &davinci_spi->dma_channels[spi->chip_select];
  408. if ((davinci_spi_dma->dma_rx_channel != -1)
  409. && (davinci_spi_dma->dma_tx_channel != -1)) {
  410. edma_free_channel(davinci_spi_dma->dma_tx_channel);
  411. edma_free_channel(davinci_spi_dma->dma_rx_channel);
  412. }
  413. }
  414. }
  415. static int davinci_spi_bufs_prep(struct spi_device *spi,
  416. struct davinci_spi *davinci_spi)
  417. {
  418. struct davinci_spi_platform_data *pdata;
  419. int op_mode = 0;
  420. /*
  421. * REVISIT unless devices disagree about SPI_LOOP or
  422. * SPI_READY (SPI_NO_CS only allows one device!), this
  423. * should not need to be done before each message...
  424. * optimize for both flags staying cleared.
  425. */
  426. op_mode = SPIPC0_DIFUN_MASK
  427. | SPIPC0_DOFUN_MASK
  428. | SPIPC0_CLKFUN_MASK;
  429. if (!(spi->mode & SPI_NO_CS)) {
  430. pdata = davinci_spi->pdata;
  431. if (!pdata->chip_sel ||
  432. pdata->chip_sel[spi->chip_select] == SPI_INTERN_CS)
  433. op_mode |= 1 << spi->chip_select;
  434. }
  435. if (spi->mode & SPI_READY)
  436. op_mode |= SPIPC0_SPIENA_MASK;
  437. iowrite32(op_mode, davinci_spi->base + SPIPC0);
  438. if (spi->mode & SPI_LOOP)
  439. set_io_bits(davinci_spi->base + SPIGCR1,
  440. SPIGCR1_LOOPBACK_MASK);
  441. else
  442. clear_io_bits(davinci_spi->base + SPIGCR1,
  443. SPIGCR1_LOOPBACK_MASK);
  444. return 0;
  445. }
  446. static int davinci_spi_check_error(struct davinci_spi *davinci_spi,
  447. int int_status)
  448. {
  449. struct device *sdev = davinci_spi->bitbang.master->dev.parent;
  450. if (int_status & SPIFLG_TIMEOUT_MASK) {
  451. dev_dbg(sdev, "SPI Time-out Error\n");
  452. return -ETIMEDOUT;
  453. }
  454. if (int_status & SPIFLG_DESYNC_MASK) {
  455. dev_dbg(sdev, "SPI Desynchronization Error\n");
  456. return -EIO;
  457. }
  458. if (int_status & SPIFLG_BITERR_MASK) {
  459. dev_dbg(sdev, "SPI Bit error\n");
  460. return -EIO;
  461. }
  462. if (davinci_spi->version == SPI_VERSION_2) {
  463. if (int_status & SPIFLG_DLEN_ERR_MASK) {
  464. dev_dbg(sdev, "SPI Data Length Error\n");
  465. return -EIO;
  466. }
  467. if (int_status & SPIFLG_PARERR_MASK) {
  468. dev_dbg(sdev, "SPI Parity Error\n");
  469. return -EIO;
  470. }
  471. if (int_status & SPIFLG_OVRRUN_MASK) {
  472. dev_dbg(sdev, "SPI Data Overrun error\n");
  473. return -EIO;
  474. }
  475. if (int_status & SPIFLG_TX_INTR_MASK) {
  476. dev_dbg(sdev, "SPI TX intr bit set\n");
  477. return -EIO;
  478. }
  479. if (int_status & SPIFLG_BUF_INIT_ACTIVE_MASK) {
  480. dev_dbg(sdev, "SPI Buffer Init Active\n");
  481. return -EBUSY;
  482. }
  483. }
  484. return 0;
  485. }
  486. /**
  487. * davinci_spi_bufs - functions which will handle transfer data
  488. * @spi: spi device on which data transfer to be done
  489. * @t: spi transfer in which transfer info is filled
  490. *
  491. * This function will put data to be transferred into data register
  492. * of SPI controller and then wait until the completion will be marked
  493. * by the IRQ Handler.
  494. */
  495. static int davinci_spi_bufs_pio(struct spi_device *spi, struct spi_transfer *t)
  496. {
  497. struct davinci_spi *davinci_spi;
  498. int int_status, count, ret;
  499. u8 conv;
  500. u32 tx_data, data1_reg_val;
  501. u32 buf_val, flg_val;
  502. struct davinci_spi_platform_data *pdata;
  503. struct davinci_spi_config *spicfg;
  504. davinci_spi = spi_master_get_devdata(spi->master);
  505. pdata = davinci_spi->pdata;
  506. spicfg = (struct davinci_spi_config *)spi->controller_data;
  507. if (!spicfg)
  508. spicfg = &davinci_spi_default_cfg;
  509. davinci_spi->tx = t->tx_buf;
  510. davinci_spi->rx = t->rx_buf;
  511. /* convert len to words based on bits_per_word */
  512. conv = davinci_spi->slave[spi->chip_select].bytes_per_word;
  513. davinci_spi->count = t->len / conv;
  514. data1_reg_val = ioread32(davinci_spi->base + SPIDAT1);
  515. INIT_COMPLETION(davinci_spi->done);
  516. ret = davinci_spi_bufs_prep(spi, davinci_spi);
  517. if (ret)
  518. return ret;
  519. /* Enable SPI */
  520. set_io_bits(davinci_spi->base + SPIGCR1, SPIGCR1_SPIENA_MASK);
  521. iowrite32((spicfg->c2tdelay << SPI_C2TDELAY_SHIFT) |
  522. (spicfg->t2cdelay << SPI_T2CDELAY_SHIFT),
  523. davinci_spi->base + SPIDELAY);
  524. count = davinci_spi->count;
  525. /* Determine the command to execute READ or WRITE */
  526. if (t->tx_buf) {
  527. clear_io_bits(davinci_spi->base + SPIINT, SPIINT_MASKALL);
  528. while (1) {
  529. tx_data = davinci_spi->get_tx(davinci_spi);
  530. data1_reg_val &= ~(0xFFFF);
  531. data1_reg_val |= (0xFFFF & tx_data);
  532. buf_val = ioread32(davinci_spi->base + SPIBUF);
  533. if ((buf_val & SPIBUF_TXFULL_MASK) == 0) {
  534. iowrite32(data1_reg_val,
  535. davinci_spi->base + SPIDAT1);
  536. count--;
  537. }
  538. while (ioread32(davinci_spi->base + SPIBUF)
  539. & SPIBUF_RXEMPTY_MASK)
  540. cpu_relax();
  541. /* getting the returned byte */
  542. if (t->rx_buf) {
  543. buf_val = ioread32(davinci_spi->base + SPIBUF);
  544. davinci_spi->get_rx(buf_val, davinci_spi);
  545. }
  546. if (count <= 0)
  547. break;
  548. }
  549. } else {
  550. if (pdata->poll_mode) {
  551. while (1) {
  552. /* keeps the serial clock going */
  553. if ((ioread32(davinci_spi->base + SPIBUF)
  554. & SPIBUF_TXFULL_MASK) == 0)
  555. iowrite32(data1_reg_val,
  556. davinci_spi->base + SPIDAT1);
  557. while (ioread32(davinci_spi->base + SPIBUF) &
  558. SPIBUF_RXEMPTY_MASK)
  559. cpu_relax();
  560. flg_val = ioread32(davinci_spi->base + SPIFLG);
  561. buf_val = ioread32(davinci_spi->base + SPIBUF);
  562. davinci_spi->get_rx(buf_val, davinci_spi);
  563. count--;
  564. if (count <= 0)
  565. break;
  566. }
  567. } else { /* Receive in Interrupt mode */
  568. int i;
  569. for (i = 0; i < davinci_spi->count; i++) {
  570. set_io_bits(davinci_spi->base + SPIINT,
  571. SPIINT_BITERR_INTR
  572. | SPIINT_OVRRUN_INTR
  573. | SPIINT_RX_INTR);
  574. iowrite32(data1_reg_val,
  575. davinci_spi->base + SPIDAT1);
  576. while (ioread32(davinci_spi->base + SPIINT) &
  577. SPIINT_RX_INTR)
  578. cpu_relax();
  579. }
  580. iowrite32((data1_reg_val & 0x0ffcffff),
  581. davinci_spi->base + SPIDAT1);
  582. }
  583. }
  584. /*
  585. * Check for bit error, desync error,parity error,timeout error and
  586. * receive overflow errors
  587. */
  588. int_status = ioread32(davinci_spi->base + SPIFLG);
  589. ret = davinci_spi_check_error(davinci_spi, int_status);
  590. if (ret != 0)
  591. return ret;
  592. /* SPI Framework maintains the count only in bytes so convert back */
  593. davinci_spi->count *= conv;
  594. return t->len;
  595. }
  596. #define DAVINCI_DMA_DATA_TYPE_S8 0x01
  597. #define DAVINCI_DMA_DATA_TYPE_S16 0x02
  598. #define DAVINCI_DMA_DATA_TYPE_S32 0x04
  599. static int davinci_spi_bufs_dma(struct spi_device *spi, struct spi_transfer *t)
  600. {
  601. struct davinci_spi *davinci_spi;
  602. int int_status = 0;
  603. int count, temp_count;
  604. u8 conv = 1;
  605. u32 data1_reg_val;
  606. struct davinci_spi_dma *davinci_spi_dma;
  607. int word_len, data_type, ret;
  608. unsigned long tx_reg, rx_reg;
  609. struct davinci_spi_config *spicfg;
  610. struct device *sdev;
  611. davinci_spi = spi_master_get_devdata(spi->master);
  612. sdev = davinci_spi->bitbang.master->dev.parent;
  613. spicfg = (struct davinci_spi_config *)spi->controller_data;
  614. if (!spicfg)
  615. spicfg = &davinci_spi_default_cfg;
  616. davinci_spi_dma = &davinci_spi->dma_channels[spi->chip_select];
  617. tx_reg = (unsigned long)davinci_spi->pbase + SPIDAT1;
  618. rx_reg = (unsigned long)davinci_spi->pbase + SPIBUF;
  619. davinci_spi->tx = t->tx_buf;
  620. davinci_spi->rx = t->rx_buf;
  621. /* convert len to words based on bits_per_word */
  622. conv = davinci_spi->slave[spi->chip_select].bytes_per_word;
  623. davinci_spi->count = t->len / conv;
  624. data1_reg_val = ioread32(davinci_spi->base + SPIDAT1);
  625. INIT_COMPLETION(davinci_spi->done);
  626. init_completion(&davinci_spi_dma->dma_rx_completion);
  627. init_completion(&davinci_spi_dma->dma_tx_completion);
  628. word_len = conv * 8;
  629. if (word_len <= 8)
  630. data_type = DAVINCI_DMA_DATA_TYPE_S8;
  631. else if (word_len <= 16)
  632. data_type = DAVINCI_DMA_DATA_TYPE_S16;
  633. else if (word_len <= 32)
  634. data_type = DAVINCI_DMA_DATA_TYPE_S32;
  635. else
  636. return -EINVAL;
  637. ret = davinci_spi_bufs_prep(spi, davinci_spi);
  638. if (ret)
  639. return ret;
  640. /* Put delay val if required */
  641. iowrite32((spicfg->c2tdelay << SPI_C2TDELAY_SHIFT) |
  642. (spicfg->t2cdelay << SPI_T2CDELAY_SHIFT),
  643. davinci_spi->base + SPIDELAY);
  644. count = davinci_spi->count; /* the number of elements */
  645. /* disable all interrupts for dma transfers */
  646. clear_io_bits(davinci_spi->base + SPIINT, SPIINT_MASKALL);
  647. /* Disable SPI to write configuration bits in SPIDAT */
  648. clear_io_bits(davinci_spi->base + SPIGCR1, SPIGCR1_SPIENA_MASK);
  649. /* Enable SPI */
  650. set_io_bits(davinci_spi->base + SPIGCR1, SPIGCR1_SPIENA_MASK);
  651. if (t->tx_buf) {
  652. t->tx_dma = dma_map_single(&spi->dev, (void *)t->tx_buf, count,
  653. DMA_TO_DEVICE);
  654. if (dma_mapping_error(&spi->dev, t->tx_dma)) {
  655. dev_dbg(sdev, "Unable to DMA map a %d bytes"
  656. " TX buffer\n", count);
  657. return -ENOMEM;
  658. }
  659. temp_count = count;
  660. } else {
  661. /* We need TX clocking for RX transaction */
  662. t->tx_dma = dma_map_single(&spi->dev,
  663. (void *)davinci_spi->tmp_buf, count + 1,
  664. DMA_TO_DEVICE);
  665. if (dma_mapping_error(&spi->dev, t->tx_dma)) {
  666. dev_dbg(sdev, "Unable to DMA map a %d bytes"
  667. " TX tmp buffer\n", count);
  668. return -ENOMEM;
  669. }
  670. temp_count = count + 1;
  671. }
  672. edma_set_transfer_params(davinci_spi_dma->dma_tx_channel,
  673. data_type, temp_count, 1, 0, ASYNC);
  674. edma_set_dest(davinci_spi_dma->dma_tx_channel, tx_reg, INCR, W8BIT);
  675. edma_set_src(davinci_spi_dma->dma_tx_channel, t->tx_dma, INCR, W8BIT);
  676. edma_set_src_index(davinci_spi_dma->dma_tx_channel, data_type, 0);
  677. edma_set_dest_index(davinci_spi_dma->dma_tx_channel, 0, 0);
  678. if (t->rx_buf) {
  679. /* initiate transaction */
  680. iowrite32(data1_reg_val, davinci_spi->base + SPIDAT1);
  681. t->rx_dma = dma_map_single(&spi->dev, (void *)t->rx_buf, count,
  682. DMA_FROM_DEVICE);
  683. if (dma_mapping_error(&spi->dev, t->rx_dma)) {
  684. dev_dbg(sdev, "Couldn't DMA map a %d bytes RX buffer\n",
  685. count);
  686. if (t->tx_buf != NULL)
  687. dma_unmap_single(NULL, t->tx_dma,
  688. count, DMA_TO_DEVICE);
  689. return -ENOMEM;
  690. }
  691. edma_set_transfer_params(davinci_spi_dma->dma_rx_channel,
  692. data_type, count, 1, 0, ASYNC);
  693. edma_set_src(davinci_spi_dma->dma_rx_channel,
  694. rx_reg, INCR, W8BIT);
  695. edma_set_dest(davinci_spi_dma->dma_rx_channel,
  696. t->rx_dma, INCR, W8BIT);
  697. edma_set_src_index(davinci_spi_dma->dma_rx_channel, 0, 0);
  698. edma_set_dest_index(davinci_spi_dma->dma_rx_channel,
  699. data_type, 0);
  700. }
  701. if ((t->tx_buf) || (t->rx_buf))
  702. edma_start(davinci_spi_dma->dma_tx_channel);
  703. if (t->rx_buf)
  704. edma_start(davinci_spi_dma->dma_rx_channel);
  705. if ((t->rx_buf) || (t->tx_buf))
  706. davinci_spi_set_dma_req(spi, 1);
  707. if (t->tx_buf)
  708. wait_for_completion_interruptible(
  709. &davinci_spi_dma->dma_tx_completion);
  710. if (t->rx_buf)
  711. wait_for_completion_interruptible(
  712. &davinci_spi_dma->dma_rx_completion);
  713. dma_unmap_single(NULL, t->tx_dma, temp_count, DMA_TO_DEVICE);
  714. if (t->rx_buf)
  715. dma_unmap_single(NULL, t->rx_dma, count, DMA_FROM_DEVICE);
  716. /*
  717. * Check for bit error, desync error,parity error,timeout error and
  718. * receive overflow errors
  719. */
  720. int_status = ioread32(davinci_spi->base + SPIFLG);
  721. ret = davinci_spi_check_error(davinci_spi, int_status);
  722. if (ret != 0)
  723. return ret;
  724. /* SPI Framework maintains the count only in bytes so convert back */
  725. davinci_spi->count *= conv;
  726. return t->len;
  727. }
  728. /**
  729. * davinci_spi_irq - IRQ handler for DaVinci SPI
  730. * @irq: IRQ number for this SPI Master
  731. * @context_data: structure for SPI Master controller davinci_spi
  732. */
  733. static irqreturn_t davinci_spi_irq(s32 irq, void *context_data)
  734. {
  735. struct davinci_spi *davinci_spi = context_data;
  736. u32 int_status, rx_data = 0;
  737. irqreturn_t ret = IRQ_NONE;
  738. int_status = ioread32(davinci_spi->base + SPIFLG);
  739. while ((int_status & SPIFLG_RX_INTR_MASK)) {
  740. if (likely(int_status & SPIFLG_RX_INTR_MASK)) {
  741. ret = IRQ_HANDLED;
  742. rx_data = ioread32(davinci_spi->base + SPIBUF);
  743. davinci_spi->get_rx(rx_data, davinci_spi);
  744. /* Disable Receive Interrupt */
  745. iowrite32(~(SPIINT_RX_INTR | SPIINT_TX_INTR),
  746. davinci_spi->base + SPIINT);
  747. } else
  748. (void)davinci_spi_check_error(davinci_spi, int_status);
  749. int_status = ioread32(davinci_spi->base + SPIFLG);
  750. }
  751. return ret;
  752. }
  753. /**
  754. * davinci_spi_probe - probe function for SPI Master Controller
  755. * @pdev: platform_device structure which contains plateform specific data
  756. */
  757. static int davinci_spi_probe(struct platform_device *pdev)
  758. {
  759. struct spi_master *master;
  760. struct davinci_spi *davinci_spi;
  761. struct davinci_spi_platform_data *pdata;
  762. struct resource *r, *mem;
  763. resource_size_t dma_rx_chan = SPI_NO_RESOURCE;
  764. resource_size_t dma_tx_chan = SPI_NO_RESOURCE;
  765. resource_size_t dma_eventq = SPI_NO_RESOURCE;
  766. int i = 0, ret = 0;
  767. pdata = pdev->dev.platform_data;
  768. if (pdata == NULL) {
  769. ret = -ENODEV;
  770. goto err;
  771. }
  772. master = spi_alloc_master(&pdev->dev, sizeof(struct davinci_spi));
  773. if (master == NULL) {
  774. ret = -ENOMEM;
  775. goto err;
  776. }
  777. dev_set_drvdata(&pdev->dev, master);
  778. davinci_spi = spi_master_get_devdata(master);
  779. if (davinci_spi == NULL) {
  780. ret = -ENOENT;
  781. goto free_master;
  782. }
  783. r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  784. if (r == NULL) {
  785. ret = -ENOENT;
  786. goto free_master;
  787. }
  788. davinci_spi->pbase = r->start;
  789. davinci_spi->region_size = resource_size(r);
  790. davinci_spi->pdata = pdata;
  791. mem = request_mem_region(r->start, davinci_spi->region_size,
  792. pdev->name);
  793. if (mem == NULL) {
  794. ret = -EBUSY;
  795. goto free_master;
  796. }
  797. davinci_spi->base = ioremap(r->start, davinci_spi->region_size);
  798. if (davinci_spi->base == NULL) {
  799. ret = -ENOMEM;
  800. goto release_region;
  801. }
  802. davinci_spi->irq = platform_get_irq(pdev, 0);
  803. if (davinci_spi->irq <= 0) {
  804. ret = -EINVAL;
  805. goto unmap_io;
  806. }
  807. ret = request_irq(davinci_spi->irq, davinci_spi_irq, IRQF_DISABLED,
  808. dev_name(&pdev->dev), davinci_spi);
  809. if (ret)
  810. goto unmap_io;
  811. /* Allocate tmp_buf for tx_buf */
  812. davinci_spi->tmp_buf = kzalloc(SPI_BUFSIZ, GFP_KERNEL);
  813. if (davinci_spi->tmp_buf == NULL) {
  814. ret = -ENOMEM;
  815. goto irq_free;
  816. }
  817. davinci_spi->bitbang.master = spi_master_get(master);
  818. if (davinci_spi->bitbang.master == NULL) {
  819. ret = -ENODEV;
  820. goto free_tmp_buf;
  821. }
  822. davinci_spi->clk = clk_get(&pdev->dev, NULL);
  823. if (IS_ERR(davinci_spi->clk)) {
  824. ret = -ENODEV;
  825. goto put_master;
  826. }
  827. clk_enable(davinci_spi->clk);
  828. master->bus_num = pdev->id;
  829. master->num_chipselect = pdata->num_chipselect;
  830. master->setup = davinci_spi_setup;
  831. master->cleanup = davinci_spi_cleanup;
  832. davinci_spi->bitbang.chipselect = davinci_spi_chipselect;
  833. davinci_spi->bitbang.setup_transfer = davinci_spi_setup_transfer;
  834. davinci_spi->version = pdata->version;
  835. use_dma = pdata->use_dma;
  836. davinci_spi->bitbang.flags = SPI_NO_CS | SPI_LSB_FIRST | SPI_LOOP;
  837. if (davinci_spi->version == SPI_VERSION_2)
  838. davinci_spi->bitbang.flags |= SPI_READY;
  839. if (use_dma) {
  840. r = platform_get_resource(pdev, IORESOURCE_DMA, 0);
  841. if (r)
  842. dma_rx_chan = r->start;
  843. r = platform_get_resource(pdev, IORESOURCE_DMA, 1);
  844. if (r)
  845. dma_tx_chan = r->start;
  846. r = platform_get_resource(pdev, IORESOURCE_DMA, 2);
  847. if (r)
  848. dma_eventq = r->start;
  849. }
  850. if (!use_dma ||
  851. dma_rx_chan == SPI_NO_RESOURCE ||
  852. dma_tx_chan == SPI_NO_RESOURCE ||
  853. dma_eventq == SPI_NO_RESOURCE) {
  854. davinci_spi->bitbang.txrx_bufs = davinci_spi_bufs_pio;
  855. use_dma = 0;
  856. } else {
  857. davinci_spi->bitbang.txrx_bufs = davinci_spi_bufs_dma;
  858. davinci_spi->dma_channels = kzalloc(master->num_chipselect
  859. * sizeof(struct davinci_spi_dma), GFP_KERNEL);
  860. if (davinci_spi->dma_channels == NULL) {
  861. ret = -ENOMEM;
  862. goto free_clk;
  863. }
  864. for (i = 0; i < master->num_chipselect; i++) {
  865. davinci_spi->dma_channels[i].dma_rx_channel = -1;
  866. davinci_spi->dma_channels[i].dma_rx_sync_dev =
  867. dma_rx_chan;
  868. davinci_spi->dma_channels[i].dma_tx_channel = -1;
  869. davinci_spi->dma_channels[i].dma_tx_sync_dev =
  870. dma_tx_chan;
  871. davinci_spi->dma_channels[i].eventq = dma_eventq;
  872. }
  873. dev_info(&pdev->dev, "DaVinci SPI driver in EDMA mode\n"
  874. "Using RX channel = %d , TX channel = %d and "
  875. "event queue = %d", dma_rx_chan, dma_tx_chan,
  876. dma_eventq);
  877. }
  878. davinci_spi->get_rx = davinci_spi_rx_buf_u8;
  879. davinci_spi->get_tx = davinci_spi_tx_buf_u8;
  880. init_completion(&davinci_spi->done);
  881. /* Reset In/OUT SPI module */
  882. iowrite32(0, davinci_spi->base + SPIGCR0);
  883. udelay(100);
  884. iowrite32(1, davinci_spi->base + SPIGCR0);
  885. /* initialize chip selects */
  886. if (pdata->chip_sel) {
  887. for (i = 0; i < pdata->num_chipselect; i++) {
  888. if (pdata->chip_sel[i] != SPI_INTERN_CS)
  889. gpio_direction_output(pdata->chip_sel[i], 1);
  890. }
  891. }
  892. /* Clock internal */
  893. if (davinci_spi->pdata->clk_internal)
  894. set_io_bits(davinci_spi->base + SPIGCR1,
  895. SPIGCR1_CLKMOD_MASK);
  896. else
  897. clear_io_bits(davinci_spi->base + SPIGCR1,
  898. SPIGCR1_CLKMOD_MASK);
  899. iowrite32(CS_DEFAULT, davinci_spi->base + SPIDEF);
  900. /* master mode default */
  901. set_io_bits(davinci_spi->base + SPIGCR1, SPIGCR1_MASTER_MASK);
  902. if (davinci_spi->pdata->intr_level)
  903. iowrite32(SPI_INTLVL_1, davinci_spi->base + SPILVL);
  904. else
  905. iowrite32(SPI_INTLVL_0, davinci_spi->base + SPILVL);
  906. ret = spi_bitbang_start(&davinci_spi->bitbang);
  907. if (ret)
  908. goto free_clk;
  909. dev_info(&pdev->dev, "Controller at 0x%p\n", davinci_spi->base);
  910. if (!pdata->poll_mode)
  911. dev_info(&pdev->dev, "Operating in interrupt mode"
  912. " using IRQ %d\n", davinci_spi->irq);
  913. return ret;
  914. free_clk:
  915. clk_disable(davinci_spi->clk);
  916. clk_put(davinci_spi->clk);
  917. put_master:
  918. spi_master_put(master);
  919. free_tmp_buf:
  920. kfree(davinci_spi->tmp_buf);
  921. irq_free:
  922. free_irq(davinci_spi->irq, davinci_spi);
  923. unmap_io:
  924. iounmap(davinci_spi->base);
  925. release_region:
  926. release_mem_region(davinci_spi->pbase, davinci_spi->region_size);
  927. free_master:
  928. kfree(master);
  929. err:
  930. return ret;
  931. }
  932. /**
  933. * davinci_spi_remove - remove function for SPI Master Controller
  934. * @pdev: platform_device structure which contains plateform specific data
  935. *
  936. * This function will do the reverse action of davinci_spi_probe function
  937. * It will free the IRQ and SPI controller's memory region.
  938. * It will also call spi_bitbang_stop to destroy the work queue which was
  939. * created by spi_bitbang_start.
  940. */
  941. static int __exit davinci_spi_remove(struct platform_device *pdev)
  942. {
  943. struct davinci_spi *davinci_spi;
  944. struct spi_master *master;
  945. master = dev_get_drvdata(&pdev->dev);
  946. davinci_spi = spi_master_get_devdata(master);
  947. spi_bitbang_stop(&davinci_spi->bitbang);
  948. clk_disable(davinci_spi->clk);
  949. clk_put(davinci_spi->clk);
  950. spi_master_put(master);
  951. kfree(davinci_spi->tmp_buf);
  952. free_irq(davinci_spi->irq, davinci_spi);
  953. iounmap(davinci_spi->base);
  954. release_mem_region(davinci_spi->pbase, davinci_spi->region_size);
  955. return 0;
  956. }
  957. static struct platform_driver davinci_spi_driver = {
  958. .driver.name = "spi_davinci",
  959. .remove = __exit_p(davinci_spi_remove),
  960. };
  961. static int __init davinci_spi_init(void)
  962. {
  963. return platform_driver_probe(&davinci_spi_driver, davinci_spi_probe);
  964. }
  965. module_init(davinci_spi_init);
  966. static void __exit davinci_spi_exit(void)
  967. {
  968. platform_driver_unregister(&davinci_spi_driver);
  969. }
  970. module_exit(davinci_spi_exit);
  971. MODULE_DESCRIPTION("TI DaVinci SPI Master Controller Driver");
  972. MODULE_LICENSE("GPL");