spi-mpc512x-psc.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  1. /*
  2. * MPC512x PSC in SPI mode driver.
  3. *
  4. * Copyright (C) 2007,2008 Freescale Semiconductor Inc.
  5. * Original port from 52xx driver:
  6. * Hongjun Chen <hong-jun.chen@freescale.com>
  7. *
  8. * Fork of mpc52xx_psc_spi.c:
  9. * Copyright (C) 2006 TOPTICA Photonics AG., Dragos Carp
  10. *
  11. * This program is free software; you can redistribute it and/or modify it
  12. * under the terms of the GNU General Public License as published by the
  13. * Free Software Foundation; either version 2 of the License, or (at your
  14. * option) any later version.
  15. */
  16. #include <linux/module.h>
  17. #include <linux/kernel.h>
  18. #include <linux/errno.h>
  19. #include <linux/interrupt.h>
  20. #include <linux/of_address.h>
  21. #include <linux/of_irq.h>
  22. #include <linux/of_platform.h>
  23. #include <linux/completion.h>
  24. #include <linux/io.h>
  25. #include <linux/delay.h>
  26. #include <linux/clk.h>
  27. #include <linux/spi/spi.h>
  28. #include <linux/fsl_devices.h>
  29. #include <linux/gpio.h>
  30. #include <asm/mpc52xx_psc.h>
  31. enum {
  32. TYPE_MPC5121,
  33. TYPE_MPC5125,
  34. };
  35. /*
  36. * This macro abstracts the differences in the PSC register layout between
  37. * MPC5121 (which uses a struct mpc52xx_psc) and MPC5125 (using mpc5125_psc).
  38. */
  39. #define psc_addr(mps, regname) ({ \
  40. void *__ret = NULL; \
  41. switch (mps->type) { \
  42. case TYPE_MPC5121: { \
  43. struct mpc52xx_psc __iomem *psc = mps->psc; \
  44. __ret = &psc->regname; \
  45. }; \
  46. break; \
  47. case TYPE_MPC5125: { \
  48. struct mpc5125_psc __iomem *psc = mps->psc; \
  49. __ret = &psc->regname; \
  50. }; \
  51. break; \
  52. } \
  53. __ret; })
  54. struct mpc512x_psc_spi {
  55. void (*cs_control)(struct spi_device *spi, bool on);
  56. /* driver internal data */
  57. int type;
  58. void __iomem *psc;
  59. struct mpc512x_psc_fifo __iomem *fifo;
  60. unsigned int irq;
  61. u8 bits_per_word;
  62. struct clk *clk_mclk;
  63. struct clk *clk_ipg;
  64. u32 mclk_rate;
  65. struct completion txisrdone;
  66. };
  67. /* controller state */
  68. struct mpc512x_psc_spi_cs {
  69. int bits_per_word;
  70. int speed_hz;
  71. };
  72. /* set clock freq, clock ramp, bits per work
  73. * if t is NULL then reset the values to the default values
  74. */
  75. static int mpc512x_psc_spi_transfer_setup(struct spi_device *spi,
  76. struct spi_transfer *t)
  77. {
  78. struct mpc512x_psc_spi_cs *cs = spi->controller_state;
  79. cs->speed_hz = (t && t->speed_hz)
  80. ? t->speed_hz : spi->max_speed_hz;
  81. cs->bits_per_word = (t && t->bits_per_word)
  82. ? t->bits_per_word : spi->bits_per_word;
  83. cs->bits_per_word = ((cs->bits_per_word + 7) / 8) * 8;
  84. return 0;
  85. }
  86. static void mpc512x_psc_spi_activate_cs(struct spi_device *spi)
  87. {
  88. struct mpc512x_psc_spi_cs *cs = spi->controller_state;
  89. struct mpc512x_psc_spi *mps = spi_master_get_devdata(spi->master);
  90. u32 sicr;
  91. u32 ccr;
  92. int speed;
  93. u16 bclkdiv;
  94. sicr = in_be32(psc_addr(mps, sicr));
  95. /* Set clock phase and polarity */
  96. if (spi->mode & SPI_CPHA)
  97. sicr |= 0x00001000;
  98. else
  99. sicr &= ~0x00001000;
  100. if (spi->mode & SPI_CPOL)
  101. sicr |= 0x00002000;
  102. else
  103. sicr &= ~0x00002000;
  104. if (spi->mode & SPI_LSB_FIRST)
  105. sicr |= 0x10000000;
  106. else
  107. sicr &= ~0x10000000;
  108. out_be32(psc_addr(mps, sicr), sicr);
  109. ccr = in_be32(psc_addr(mps, ccr));
  110. ccr &= 0xFF000000;
  111. speed = cs->speed_hz;
  112. if (!speed)
  113. speed = 1000000; /* default 1MHz */
  114. bclkdiv = (mps->mclk_rate / speed) - 1;
  115. ccr |= (((bclkdiv & 0xff) << 16) | (((bclkdiv >> 8) & 0xff) << 8));
  116. out_be32(psc_addr(mps, ccr), ccr);
  117. mps->bits_per_word = cs->bits_per_word;
  118. if (mps->cs_control && gpio_is_valid(spi->cs_gpio))
  119. mps->cs_control(spi, (spi->mode & SPI_CS_HIGH) ? 1 : 0);
  120. }
  121. static void mpc512x_psc_spi_deactivate_cs(struct spi_device *spi)
  122. {
  123. struct mpc512x_psc_spi *mps = spi_master_get_devdata(spi->master);
  124. if (mps->cs_control && gpio_is_valid(spi->cs_gpio))
  125. mps->cs_control(spi, (spi->mode & SPI_CS_HIGH) ? 0 : 1);
  126. }
  127. /* extract and scale size field in txsz or rxsz */
  128. #define MPC512x_PSC_FIFO_SZ(sz) ((sz & 0x7ff) << 2);
  129. #define EOFBYTE 1
  130. static int mpc512x_psc_spi_transfer_rxtx(struct spi_device *spi,
  131. struct spi_transfer *t)
  132. {
  133. struct mpc512x_psc_spi *mps = spi_master_get_devdata(spi->master);
  134. struct mpc512x_psc_fifo __iomem *fifo = mps->fifo;
  135. size_t tx_len = t->len;
  136. size_t rx_len = t->len;
  137. u8 *tx_buf = (u8 *)t->tx_buf;
  138. u8 *rx_buf = (u8 *)t->rx_buf;
  139. if (!tx_buf && !rx_buf && t->len)
  140. return -EINVAL;
  141. while (rx_len || tx_len) {
  142. size_t txcount;
  143. u8 data;
  144. size_t fifosz;
  145. size_t rxcount;
  146. int rxtries;
  147. /*
  148. * send the TX bytes in as large a chunk as possible
  149. * but neither exceed the TX nor the RX FIFOs
  150. */
  151. fifosz = MPC512x_PSC_FIFO_SZ(in_be32(&fifo->txsz));
  152. txcount = min(fifosz, tx_len);
  153. fifosz = MPC512x_PSC_FIFO_SZ(in_be32(&fifo->rxsz));
  154. fifosz -= in_be32(&fifo->rxcnt) + 1;
  155. txcount = min(fifosz, txcount);
  156. if (txcount) {
  157. /* fill the TX FIFO */
  158. while (txcount-- > 0) {
  159. data = tx_buf ? *tx_buf++ : 0;
  160. if (tx_len == EOFBYTE && t->cs_change)
  161. setbits32(&fifo->txcmd,
  162. MPC512x_PSC_FIFO_EOF);
  163. out_8(&fifo->txdata_8, data);
  164. tx_len--;
  165. }
  166. /* have the ISR trigger when the TX FIFO is empty */
  167. reinit_completion(&mps->txisrdone);
  168. out_be32(&fifo->txisr, MPC512x_PSC_FIFO_EMPTY);
  169. out_be32(&fifo->tximr, MPC512x_PSC_FIFO_EMPTY);
  170. wait_for_completion(&mps->txisrdone);
  171. }
  172. /*
  173. * consume as much RX data as the FIFO holds, while we
  174. * iterate over the transfer's TX data length
  175. *
  176. * only insist in draining all the remaining RX bytes
  177. * when the TX bytes were exhausted (that's at the very
  178. * end of this transfer, not when still iterating over
  179. * the transfer's chunks)
  180. */
  181. rxtries = 50;
  182. do {
  183. /*
  184. * grab whatever was in the FIFO when we started
  185. * looking, don't bother fetching what was added to
  186. * the FIFO while we read from it -- we'll return
  187. * here eventually and prefer sending out remaining
  188. * TX data
  189. */
  190. fifosz = in_be32(&fifo->rxcnt);
  191. rxcount = min(fifosz, rx_len);
  192. while (rxcount-- > 0) {
  193. data = in_8(&fifo->rxdata_8);
  194. if (rx_buf)
  195. *rx_buf++ = data;
  196. rx_len--;
  197. }
  198. /*
  199. * come back later if there still is TX data to send,
  200. * bail out of the RX drain loop if all of the TX data
  201. * was sent and all of the RX data was received (i.e.
  202. * when the transmission has completed)
  203. */
  204. if (tx_len)
  205. break;
  206. if (!rx_len)
  207. break;
  208. /*
  209. * TX data transmission has completed while RX data
  210. * is still pending -- that's a transient situation
  211. * which depends on wire speed and specific
  212. * hardware implementation details (buffering) yet
  213. * should resolve very quickly
  214. *
  215. * just yield for a moment to not hog the CPU for
  216. * too long when running SPI at low speed
  217. *
  218. * the timeout range is rather arbitrary and tries
  219. * to balance throughput against system load; the
  220. * chosen values result in a minimal timeout of 50
  221. * times 10us and thus work at speeds as low as
  222. * some 20kbps, while the maximum timeout at the
  223. * transfer's end could be 5ms _if_ nothing else
  224. * ticks in the system _and_ RX data still wasn't
  225. * received, which only occurs in situations that
  226. * are exceptional; removing the unpredictability
  227. * of the timeout either decreases throughput
  228. * (longer timeouts), or puts more load on the
  229. * system (fixed short timeouts) or requires the
  230. * use of a timeout API instead of a counter and an
  231. * unknown inner delay
  232. */
  233. usleep_range(10, 100);
  234. } while (--rxtries > 0);
  235. if (!tx_len && rx_len && !rxtries) {
  236. /*
  237. * not enough RX bytes even after several retries
  238. * and the resulting rather long timeout?
  239. */
  240. rxcount = in_be32(&fifo->rxcnt);
  241. dev_warn(&spi->dev,
  242. "short xfer, missing %zd RX bytes, FIFO level %zd\n",
  243. rx_len, rxcount);
  244. }
  245. /*
  246. * drain and drop RX data which "should not be there" in
  247. * the first place, for undisturbed transmission this turns
  248. * into a NOP (except for the FIFO level fetch)
  249. */
  250. if (!tx_len && !rx_len) {
  251. while (in_be32(&fifo->rxcnt))
  252. in_8(&fifo->rxdata_8);
  253. }
  254. }
  255. return 0;
  256. }
  257. static int mpc512x_psc_spi_msg_xfer(struct spi_master *master,
  258. struct spi_message *m)
  259. {
  260. struct spi_device *spi;
  261. unsigned cs_change;
  262. int status;
  263. struct spi_transfer *t;
  264. spi = m->spi;
  265. cs_change = 1;
  266. status = 0;
  267. list_for_each_entry(t, &m->transfers, transfer_list) {
  268. if (t->bits_per_word || t->speed_hz) {
  269. status = mpc512x_psc_spi_transfer_setup(spi, t);
  270. if (status < 0)
  271. break;
  272. }
  273. if (cs_change)
  274. mpc512x_psc_spi_activate_cs(spi);
  275. cs_change = t->cs_change;
  276. status = mpc512x_psc_spi_transfer_rxtx(spi, t);
  277. if (status)
  278. break;
  279. m->actual_length += t->len;
  280. if (t->delay_usecs)
  281. udelay(t->delay_usecs);
  282. if (cs_change)
  283. mpc512x_psc_spi_deactivate_cs(spi);
  284. }
  285. m->status = status;
  286. if (m->complete)
  287. m->complete(m->context);
  288. if (status || !cs_change)
  289. mpc512x_psc_spi_deactivate_cs(spi);
  290. mpc512x_psc_spi_transfer_setup(spi, NULL);
  291. spi_finalize_current_message(master);
  292. return status;
  293. }
  294. static int mpc512x_psc_spi_prep_xfer_hw(struct spi_master *master)
  295. {
  296. struct mpc512x_psc_spi *mps = spi_master_get_devdata(master);
  297. dev_dbg(&master->dev, "%s()\n", __func__);
  298. /* Zero MR2 */
  299. in_8(psc_addr(mps, mr2));
  300. out_8(psc_addr(mps, mr2), 0x0);
  301. /* enable transmitter/receiver */
  302. out_8(psc_addr(mps, command), MPC52xx_PSC_TX_ENABLE | MPC52xx_PSC_RX_ENABLE);
  303. return 0;
  304. }
  305. static int mpc512x_psc_spi_unprep_xfer_hw(struct spi_master *master)
  306. {
  307. struct mpc512x_psc_spi *mps = spi_master_get_devdata(master);
  308. struct mpc512x_psc_fifo __iomem *fifo = mps->fifo;
  309. dev_dbg(&master->dev, "%s()\n", __func__);
  310. /* disable transmitter/receiver and fifo interrupt */
  311. out_8(psc_addr(mps, command), MPC52xx_PSC_TX_DISABLE | MPC52xx_PSC_RX_DISABLE);
  312. out_be32(&fifo->tximr, 0);
  313. return 0;
  314. }
  315. static int mpc512x_psc_spi_setup(struct spi_device *spi)
  316. {
  317. struct mpc512x_psc_spi_cs *cs = spi->controller_state;
  318. int ret;
  319. if (spi->bits_per_word % 8)
  320. return -EINVAL;
  321. if (!cs) {
  322. cs = kzalloc(sizeof *cs, GFP_KERNEL);
  323. if (!cs)
  324. return -ENOMEM;
  325. if (gpio_is_valid(spi->cs_gpio)) {
  326. ret = gpio_request(spi->cs_gpio, dev_name(&spi->dev));
  327. if (ret) {
  328. dev_err(&spi->dev, "can't get CS gpio: %d\n",
  329. ret);
  330. kfree(cs);
  331. return ret;
  332. }
  333. gpio_direction_output(spi->cs_gpio,
  334. spi->mode & SPI_CS_HIGH ? 0 : 1);
  335. }
  336. spi->controller_state = cs;
  337. }
  338. cs->bits_per_word = spi->bits_per_word;
  339. cs->speed_hz = spi->max_speed_hz;
  340. return 0;
  341. }
  342. static void mpc512x_psc_spi_cleanup(struct spi_device *spi)
  343. {
  344. if (gpio_is_valid(spi->cs_gpio))
  345. gpio_free(spi->cs_gpio);
  346. kfree(spi->controller_state);
  347. }
  348. static int mpc512x_psc_spi_port_config(struct spi_master *master,
  349. struct mpc512x_psc_spi *mps)
  350. {
  351. struct mpc512x_psc_fifo __iomem *fifo = mps->fifo;
  352. u32 sicr;
  353. u32 ccr;
  354. int speed;
  355. u16 bclkdiv;
  356. /* Reset the PSC into a known state */
  357. out_8(psc_addr(mps, command), MPC52xx_PSC_RST_RX);
  358. out_8(psc_addr(mps, command), MPC52xx_PSC_RST_TX);
  359. out_8(psc_addr(mps, command), MPC52xx_PSC_TX_DISABLE | MPC52xx_PSC_RX_DISABLE);
  360. /* Disable psc interrupts all useful interrupts are in fifo */
  361. out_be16(psc_addr(mps, isr_imr.imr), 0);
  362. /* Disable fifo interrupts, will be enabled later */
  363. out_be32(&fifo->tximr, 0);
  364. out_be32(&fifo->rximr, 0);
  365. /* Setup fifo slice address and size */
  366. /*out_be32(&fifo->txsz, 0x0fe00004);*/
  367. /*out_be32(&fifo->rxsz, 0x0ff00004);*/
  368. sicr = 0x01000000 | /* SIM = 0001 -- 8 bit */
  369. 0x00800000 | /* GenClk = 1 -- internal clk */
  370. 0x00008000 | /* SPI = 1 */
  371. 0x00004000 | /* MSTR = 1 -- SPI master */
  372. 0x00000800; /* UseEOF = 1 -- SS low until EOF */
  373. out_be32(psc_addr(mps, sicr), sicr);
  374. ccr = in_be32(psc_addr(mps, ccr));
  375. ccr &= 0xFF000000;
  376. speed = 1000000; /* default 1MHz */
  377. bclkdiv = (mps->mclk_rate / speed) - 1;
  378. ccr |= (((bclkdiv & 0xff) << 16) | (((bclkdiv >> 8) & 0xff) << 8));
  379. out_be32(psc_addr(mps, ccr), ccr);
  380. /* Set 2ms DTL delay */
  381. out_8(psc_addr(mps, ctur), 0x00);
  382. out_8(psc_addr(mps, ctlr), 0x82);
  383. /* we don't use the alarms */
  384. out_be32(&fifo->rxalarm, 0xfff);
  385. out_be32(&fifo->txalarm, 0);
  386. /* Enable FIFO slices for Rx/Tx */
  387. out_be32(&fifo->rxcmd,
  388. MPC512x_PSC_FIFO_ENABLE_SLICE | MPC512x_PSC_FIFO_ENABLE_DMA);
  389. out_be32(&fifo->txcmd,
  390. MPC512x_PSC_FIFO_ENABLE_SLICE | MPC512x_PSC_FIFO_ENABLE_DMA);
  391. mps->bits_per_word = 8;
  392. return 0;
  393. }
  394. static irqreturn_t mpc512x_psc_spi_isr(int irq, void *dev_id)
  395. {
  396. struct mpc512x_psc_spi *mps = (struct mpc512x_psc_spi *)dev_id;
  397. struct mpc512x_psc_fifo __iomem *fifo = mps->fifo;
  398. /* clear interrupt and wake up the rx/tx routine */
  399. if (in_be32(&fifo->txisr) &
  400. in_be32(&fifo->tximr) & MPC512x_PSC_FIFO_EMPTY) {
  401. out_be32(&fifo->txisr, MPC512x_PSC_FIFO_EMPTY);
  402. out_be32(&fifo->tximr, 0);
  403. complete(&mps->txisrdone);
  404. return IRQ_HANDLED;
  405. }
  406. return IRQ_NONE;
  407. }
  408. static void mpc512x_spi_cs_control(struct spi_device *spi, bool onoff)
  409. {
  410. gpio_set_value(spi->cs_gpio, onoff);
  411. }
  412. static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr,
  413. u32 size, unsigned int irq)
  414. {
  415. struct fsl_spi_platform_data *pdata = dev_get_platdata(dev);
  416. struct mpc512x_psc_spi *mps;
  417. struct spi_master *master;
  418. int ret;
  419. void *tempp;
  420. struct clk *clk;
  421. master = spi_alloc_master(dev, sizeof *mps);
  422. if (master == NULL)
  423. return -ENOMEM;
  424. dev_set_drvdata(dev, master);
  425. mps = spi_master_get_devdata(master);
  426. mps->type = (int)of_device_get_match_data(dev);
  427. mps->irq = irq;
  428. if (pdata == NULL) {
  429. mps->cs_control = mpc512x_spi_cs_control;
  430. } else {
  431. mps->cs_control = pdata->cs_control;
  432. master->bus_num = pdata->bus_num;
  433. master->num_chipselect = pdata->max_chipselect;
  434. }
  435. master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LSB_FIRST;
  436. master->setup = mpc512x_psc_spi_setup;
  437. master->prepare_transfer_hardware = mpc512x_psc_spi_prep_xfer_hw;
  438. master->transfer_one_message = mpc512x_psc_spi_msg_xfer;
  439. master->unprepare_transfer_hardware = mpc512x_psc_spi_unprep_xfer_hw;
  440. master->cleanup = mpc512x_psc_spi_cleanup;
  441. master->dev.of_node = dev->of_node;
  442. tempp = devm_ioremap(dev, regaddr, size);
  443. if (!tempp) {
  444. dev_err(dev, "could not ioremap I/O port range\n");
  445. ret = -EFAULT;
  446. goto free_master;
  447. }
  448. mps->psc = tempp;
  449. mps->fifo =
  450. (struct mpc512x_psc_fifo *)(tempp + sizeof(struct mpc52xx_psc));
  451. ret = devm_request_irq(dev, mps->irq, mpc512x_psc_spi_isr, IRQF_SHARED,
  452. "mpc512x-psc-spi", mps);
  453. if (ret)
  454. goto free_master;
  455. init_completion(&mps->txisrdone);
  456. clk = devm_clk_get(dev, "mclk");
  457. if (IS_ERR(clk)) {
  458. ret = PTR_ERR(clk);
  459. goto free_master;
  460. }
  461. ret = clk_prepare_enable(clk);
  462. if (ret)
  463. goto free_master;
  464. mps->clk_mclk = clk;
  465. mps->mclk_rate = clk_get_rate(clk);
  466. clk = devm_clk_get(dev, "ipg");
  467. if (IS_ERR(clk)) {
  468. ret = PTR_ERR(clk);
  469. goto free_mclk_clock;
  470. }
  471. ret = clk_prepare_enable(clk);
  472. if (ret)
  473. goto free_mclk_clock;
  474. mps->clk_ipg = clk;
  475. ret = mpc512x_psc_spi_port_config(master, mps);
  476. if (ret < 0)
  477. goto free_ipg_clock;
  478. ret = devm_spi_register_master(dev, master);
  479. if (ret < 0)
  480. goto free_ipg_clock;
  481. return ret;
  482. free_ipg_clock:
  483. clk_disable_unprepare(mps->clk_ipg);
  484. free_mclk_clock:
  485. clk_disable_unprepare(mps->clk_mclk);
  486. free_master:
  487. spi_master_put(master);
  488. return ret;
  489. }
  490. static int mpc512x_psc_spi_do_remove(struct device *dev)
  491. {
  492. struct spi_master *master = dev_get_drvdata(dev);
  493. struct mpc512x_psc_spi *mps = spi_master_get_devdata(master);
  494. clk_disable_unprepare(mps->clk_mclk);
  495. clk_disable_unprepare(mps->clk_ipg);
  496. return 0;
  497. }
  498. static int mpc512x_psc_spi_of_probe(struct platform_device *op)
  499. {
  500. const u32 *regaddr_p;
  501. u64 regaddr64, size64;
  502. regaddr_p = of_get_address(op->dev.of_node, 0, &size64, NULL);
  503. if (!regaddr_p) {
  504. dev_err(&op->dev, "Invalid PSC address\n");
  505. return -EINVAL;
  506. }
  507. regaddr64 = of_translate_address(op->dev.of_node, regaddr_p);
  508. return mpc512x_psc_spi_do_probe(&op->dev, (u32) regaddr64, (u32) size64,
  509. irq_of_parse_and_map(op->dev.of_node, 0));
  510. }
  511. static int mpc512x_psc_spi_of_remove(struct platform_device *op)
  512. {
  513. return mpc512x_psc_spi_do_remove(&op->dev);
  514. }
  515. static const struct of_device_id mpc512x_psc_spi_of_match[] = {
  516. { .compatible = "fsl,mpc5121-psc-spi", .data = (void *)TYPE_MPC5121 },
  517. { .compatible = "fsl,mpc5125-psc-spi", .data = (void *)TYPE_MPC5125 },
  518. {},
  519. };
  520. MODULE_DEVICE_TABLE(of, mpc512x_psc_spi_of_match);
  521. static struct platform_driver mpc512x_psc_spi_of_driver = {
  522. .probe = mpc512x_psc_spi_of_probe,
  523. .remove = mpc512x_psc_spi_of_remove,
  524. .driver = {
  525. .name = "mpc512x-psc-spi",
  526. .of_match_table = mpc512x_psc_spi_of_match,
  527. },
  528. };
  529. module_platform_driver(mpc512x_psc_spi_of_driver);
  530. MODULE_AUTHOR("John Rigby");
  531. MODULE_DESCRIPTION("MPC512x PSC SPI Driver");
  532. MODULE_LICENSE("GPL");