spi-microchip-core.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. // SPDX-License-Identifier: (GPL-2.0)
  2. /*
  3. * Microchip CoreSPI SPI controller driver
  4. *
  5. * Copyright (c) 2018-2022 Microchip Technology Inc. and its subsidiaries
  6. *
  7. * Author: Daire McNamara <[email protected]>
  8. * Author: Conor Dooley <[email protected]>
  9. *
  10. */
  11. #include <linux/clk.h>
  12. #include <linux/delay.h>
  13. #include <linux/err.h>
  14. #include <linux/init.h>
  15. #include <linux/interrupt.h>
  16. #include <linux/io.h>
  17. #include <linux/module.h>
  18. #include <linux/of.h>
  19. #include <linux/platform_device.h>
  20. #include <linux/spi/spi.h>
  21. #define MAX_LEN (0xffff)
  22. #define MAX_CS (8)
  23. #define DEFAULT_FRAMESIZE (8)
  24. #define FIFO_DEPTH (32)
  25. #define CLK_GEN_MODE1_MAX (255)
  26. #define CLK_GEN_MODE0_MAX (15)
  27. #define CLK_GEN_MIN (0)
  28. #define MODE_X_MASK_SHIFT (24)
  29. #define CONTROL_ENABLE BIT(0)
  30. #define CONTROL_MASTER BIT(1)
  31. #define CONTROL_RX_DATA_INT BIT(4)
  32. #define CONTROL_TX_DATA_INT BIT(5)
  33. #define CONTROL_RX_OVER_INT BIT(6)
  34. #define CONTROL_TX_UNDER_INT BIT(7)
  35. #define CONTROL_SPO BIT(24)
  36. #define CONTROL_SPH BIT(25)
  37. #define CONTROL_SPS BIT(26)
  38. #define CONTROL_FRAMEURUN BIT(27)
  39. #define CONTROL_CLKMODE BIT(28)
  40. #define CONTROL_BIGFIFO BIT(29)
  41. #define CONTROL_OENOFF BIT(30)
  42. #define CONTROL_RESET BIT(31)
  43. #define CONTROL_MODE_MASK GENMASK(3, 2)
  44. #define MOTOROLA_MODE (0)
  45. #define CONTROL_FRAMECNT_MASK GENMASK(23, 8)
  46. #define CONTROL_FRAMECNT_SHIFT (8)
  47. #define STATUS_ACTIVE BIT(14)
  48. #define STATUS_SSEL BIT(13)
  49. #define STATUS_FRAMESTART BIT(12)
  50. #define STATUS_TXFIFO_EMPTY_NEXT_READ BIT(11)
  51. #define STATUS_TXFIFO_EMPTY BIT(10)
  52. #define STATUS_TXFIFO_FULL_NEXT_WRITE BIT(9)
  53. #define STATUS_TXFIFO_FULL BIT(8)
  54. #define STATUS_RXFIFO_EMPTY_NEXT_READ BIT(7)
  55. #define STATUS_RXFIFO_EMPTY BIT(6)
  56. #define STATUS_RXFIFO_FULL_NEXT_WRITE BIT(5)
  57. #define STATUS_RXFIFO_FULL BIT(4)
  58. #define STATUS_TX_UNDERRUN BIT(3)
  59. #define STATUS_RX_OVERFLOW BIT(2)
  60. #define STATUS_RXDAT_RXED BIT(1)
  61. #define STATUS_TXDAT_SENT BIT(0)
  62. #define INT_TXDONE BIT(0)
  63. #define INT_RXRDY BIT(1)
  64. #define INT_RX_CHANNEL_OVERFLOW BIT(2)
  65. #define INT_TX_CHANNEL_UNDERRUN BIT(3)
  66. #define INT_ENABLE_MASK (CONTROL_RX_DATA_INT | CONTROL_TX_DATA_INT | \
  67. CONTROL_RX_OVER_INT | CONTROL_TX_UNDER_INT)
  68. #define REG_CONTROL (0x00)
  69. #define REG_FRAME_SIZE (0x04)
  70. #define REG_STATUS (0x08)
  71. #define REG_INT_CLEAR (0x0c)
  72. #define REG_RX_DATA (0x10)
  73. #define REG_TX_DATA (0x14)
  74. #define REG_CLK_GEN (0x18)
  75. #define REG_SLAVE_SELECT (0x1c)
  76. #define SSEL_MASK GENMASK(7, 0)
  77. #define SSEL_DIRECT BIT(8)
  78. #define SSELOUT_SHIFT 9
  79. #define SSELOUT BIT(SSELOUT_SHIFT)
  80. #define REG_MIS (0x20)
  81. #define REG_RIS (0x24)
  82. #define REG_CONTROL2 (0x28)
  83. #define REG_COMMAND (0x2c)
  84. #define REG_PKTSIZE (0x30)
  85. #define REG_CMD_SIZE (0x34)
  86. #define REG_HWSTATUS (0x38)
  87. #define REG_STAT8 (0x3c)
  88. #define REG_CTRL2 (0x48)
  89. #define REG_FRAMESUP (0x50)
  90. struct mchp_corespi {
  91. void __iomem *regs;
  92. struct clk *clk;
  93. const u8 *tx_buf;
  94. u8 *rx_buf;
  95. u32 clk_gen; /* divider for spi output clock generated by the controller */
  96. u32 clk_mode;
  97. int irq;
  98. int tx_len;
  99. int rx_len;
  100. int pending;
  101. };
  102. static inline u32 mchp_corespi_read(struct mchp_corespi *spi, unsigned int reg)
  103. {
  104. return readl(spi->regs + reg);
  105. }
  106. static inline void mchp_corespi_write(struct mchp_corespi *spi, unsigned int reg, u32 val)
  107. {
  108. writel(val, spi->regs + reg);
  109. }
  110. static inline void mchp_corespi_enable(struct mchp_corespi *spi)
  111. {
  112. u32 control = mchp_corespi_read(spi, REG_CONTROL);
  113. control |= CONTROL_ENABLE;
  114. mchp_corespi_write(spi, REG_CONTROL, control);
  115. }
  116. static inline void mchp_corespi_disable(struct mchp_corespi *spi)
  117. {
  118. u32 control = mchp_corespi_read(spi, REG_CONTROL);
  119. control &= ~CONTROL_ENABLE;
  120. mchp_corespi_write(spi, REG_CONTROL, control);
  121. }
  122. static inline void mchp_corespi_read_fifo(struct mchp_corespi *spi)
  123. {
  124. u8 data;
  125. int fifo_max, i = 0;
  126. fifo_max = min(spi->rx_len, FIFO_DEPTH);
  127. while ((i < fifo_max) && !(mchp_corespi_read(spi, REG_STATUS) & STATUS_RXFIFO_EMPTY)) {
  128. data = mchp_corespi_read(spi, REG_RX_DATA);
  129. if (spi->rx_buf)
  130. *spi->rx_buf++ = data;
  131. i++;
  132. }
  133. spi->rx_len -= i;
  134. spi->pending -= i;
  135. }
  136. static void mchp_corespi_enable_ints(struct mchp_corespi *spi)
  137. {
  138. u32 control, mask = INT_ENABLE_MASK;
  139. mchp_corespi_disable(spi);
  140. control = mchp_corespi_read(spi, REG_CONTROL);
  141. control |= mask;
  142. mchp_corespi_write(spi, REG_CONTROL, control);
  143. control |= CONTROL_ENABLE;
  144. mchp_corespi_write(spi, REG_CONTROL, control);
  145. }
  146. static void mchp_corespi_disable_ints(struct mchp_corespi *spi)
  147. {
  148. u32 control, mask = INT_ENABLE_MASK;
  149. mchp_corespi_disable(spi);
  150. control = mchp_corespi_read(spi, REG_CONTROL);
  151. control &= ~mask;
  152. mchp_corespi_write(spi, REG_CONTROL, control);
  153. control |= CONTROL_ENABLE;
  154. mchp_corespi_write(spi, REG_CONTROL, control);
  155. }
  156. static inline void mchp_corespi_set_xfer_size(struct mchp_corespi *spi, int len)
  157. {
  158. u32 control;
  159. u16 lenpart;
  160. /*
  161. * Disable the SPI controller. Writes to transfer length have
  162. * no effect when the controller is enabled.
  163. */
  164. mchp_corespi_disable(spi);
  165. /*
  166. * The lower 16 bits of the frame count are stored in the control reg
  167. * for legacy reasons, but the upper 16 written to a different register:
  168. * FRAMESUP. While both the upper and lower bits can be *READ* from the
  169. * FRAMESUP register, writing to the lower 16 bits is a NOP
  170. */
  171. lenpart = len & 0xffff;
  172. control = mchp_corespi_read(spi, REG_CONTROL);
  173. control &= ~CONTROL_FRAMECNT_MASK;
  174. control |= lenpart << CONTROL_FRAMECNT_SHIFT;
  175. mchp_corespi_write(spi, REG_CONTROL, control);
  176. lenpart = len & 0xffff0000;
  177. mchp_corespi_write(spi, REG_FRAMESUP, lenpart);
  178. control |= CONTROL_ENABLE;
  179. mchp_corespi_write(spi, REG_CONTROL, control);
  180. }
  181. static inline void mchp_corespi_write_fifo(struct mchp_corespi *spi)
  182. {
  183. u8 byte;
  184. int fifo_max, i = 0;
  185. fifo_max = min(spi->tx_len, FIFO_DEPTH);
  186. mchp_corespi_set_xfer_size(spi, fifo_max);
  187. while ((i < fifo_max) && !(mchp_corespi_read(spi, REG_STATUS) & STATUS_TXFIFO_FULL)) {
  188. byte = spi->tx_buf ? *spi->tx_buf++ : 0xaa;
  189. mchp_corespi_write(spi, REG_TX_DATA, byte);
  190. i++;
  191. }
  192. spi->tx_len -= i;
  193. spi->pending += i;
  194. }
  195. static inline void mchp_corespi_set_framesize(struct mchp_corespi *spi, int bt)
  196. {
  197. u32 control;
  198. /*
  199. * Disable the SPI controller. Writes to the frame size have
  200. * no effect when the controller is enabled.
  201. */
  202. mchp_corespi_disable(spi);
  203. mchp_corespi_write(spi, REG_FRAME_SIZE, bt);
  204. control = mchp_corespi_read(spi, REG_CONTROL);
  205. control |= CONTROL_ENABLE;
  206. mchp_corespi_write(spi, REG_CONTROL, control);
  207. }
  208. static void mchp_corespi_set_cs(struct spi_device *spi, bool disable)
  209. {
  210. u32 reg;
  211. struct mchp_corespi *corespi = spi_master_get_devdata(spi->master);
  212. reg = mchp_corespi_read(corespi, REG_SLAVE_SELECT);
  213. reg &= ~BIT(spi->chip_select);
  214. reg |= !disable << spi->chip_select;
  215. mchp_corespi_write(corespi, REG_SLAVE_SELECT, reg);
  216. }
  217. static int mchp_corespi_setup(struct spi_device *spi)
  218. {
  219. struct mchp_corespi *corespi = spi_master_get_devdata(spi->master);
  220. u32 reg;
  221. /*
  222. * Active high slaves need to be specifically set to their inactive
  223. * states during probe by adding them to the "control group" & thus
  224. * driving their select line low.
  225. */
  226. if (spi->mode & SPI_CS_HIGH) {
  227. reg = mchp_corespi_read(corespi, REG_SLAVE_SELECT);
  228. reg |= BIT(spi->chip_select);
  229. mchp_corespi_write(corespi, REG_SLAVE_SELECT, reg);
  230. }
  231. return 0;
  232. }
  233. static void mchp_corespi_init(struct spi_master *master, struct mchp_corespi *spi)
  234. {
  235. unsigned long clk_hz;
  236. u32 control = mchp_corespi_read(spi, REG_CONTROL);
  237. control |= CONTROL_MASTER;
  238. control &= ~CONTROL_MODE_MASK;
  239. control |= MOTOROLA_MODE;
  240. mchp_corespi_set_framesize(spi, DEFAULT_FRAMESIZE);
  241. /* max. possible spi clock rate is the apb clock rate */
  242. clk_hz = clk_get_rate(spi->clk);
  243. master->max_speed_hz = clk_hz;
  244. /*
  245. * The controller must be configured so that it doesn't remove Chip
  246. * Select until the entire message has been transferred, even if at
  247. * some points TX FIFO becomes empty.
  248. *
  249. * BIGFIFO mode is also enabled, which sets the fifo depth to 32 frames
  250. * for the 8 bit transfers that this driver uses.
  251. */
  252. control = mchp_corespi_read(spi, REG_CONTROL);
  253. control |= CONTROL_SPS | CONTROL_BIGFIFO;
  254. mchp_corespi_write(spi, REG_CONTROL, control);
  255. mchp_corespi_enable_ints(spi);
  256. /*
  257. * It is required to enable direct mode, otherwise control over the chip
  258. * select is relinquished to the hardware. SSELOUT is enabled too so we
  259. * can deal with active high slaves.
  260. */
  261. mchp_corespi_write(spi, REG_SLAVE_SELECT, SSELOUT | SSEL_DIRECT);
  262. control = mchp_corespi_read(spi, REG_CONTROL);
  263. control &= ~CONTROL_RESET;
  264. control |= CONTROL_ENABLE;
  265. mchp_corespi_write(spi, REG_CONTROL, control);
  266. }
  267. static inline void mchp_corespi_set_clk_gen(struct mchp_corespi *spi)
  268. {
  269. u32 control;
  270. mchp_corespi_disable(spi);
  271. control = mchp_corespi_read(spi, REG_CONTROL);
  272. if (spi->clk_mode)
  273. control |= CONTROL_CLKMODE;
  274. else
  275. control &= ~CONTROL_CLKMODE;
  276. mchp_corespi_write(spi, REG_CLK_GEN, spi->clk_gen);
  277. mchp_corespi_write(spi, REG_CONTROL, control);
  278. mchp_corespi_write(spi, REG_CONTROL, control | CONTROL_ENABLE);
  279. }
  280. static inline void mchp_corespi_set_mode(struct mchp_corespi *spi, unsigned int mode)
  281. {
  282. u32 control, mode_val;
  283. switch (mode & SPI_MODE_X_MASK) {
  284. case SPI_MODE_0:
  285. mode_val = 0;
  286. break;
  287. case SPI_MODE_1:
  288. mode_val = CONTROL_SPH;
  289. break;
  290. case SPI_MODE_2:
  291. mode_val = CONTROL_SPO;
  292. break;
  293. case SPI_MODE_3:
  294. mode_val = CONTROL_SPH | CONTROL_SPO;
  295. break;
  296. }
  297. /*
  298. * Disable the SPI controller. Writes to the frame size have
  299. * no effect when the controller is enabled.
  300. */
  301. mchp_corespi_disable(spi);
  302. control = mchp_corespi_read(spi, REG_CONTROL);
  303. control &= ~(SPI_MODE_X_MASK << MODE_X_MASK_SHIFT);
  304. control |= mode_val;
  305. mchp_corespi_write(spi, REG_CONTROL, control);
  306. control |= CONTROL_ENABLE;
  307. mchp_corespi_write(spi, REG_CONTROL, control);
  308. }
  309. static irqreturn_t mchp_corespi_interrupt(int irq, void *dev_id)
  310. {
  311. struct spi_master *master = dev_id;
  312. struct mchp_corespi *spi = spi_master_get_devdata(master);
  313. u32 intfield = mchp_corespi_read(spi, REG_MIS) & 0xf;
  314. bool finalise = false;
  315. /* Interrupt line may be shared and not for us at all */
  316. if (intfield == 0)
  317. return IRQ_NONE;
  318. if (intfield & INT_TXDONE) {
  319. mchp_corespi_write(spi, REG_INT_CLEAR, INT_TXDONE);
  320. if (spi->rx_len)
  321. mchp_corespi_read_fifo(spi);
  322. if (spi->tx_len)
  323. mchp_corespi_write_fifo(spi);
  324. if (!spi->rx_len)
  325. finalise = true;
  326. }
  327. if (intfield & INT_RXRDY)
  328. mchp_corespi_write(spi, REG_INT_CLEAR, INT_RXRDY);
  329. if (intfield & INT_RX_CHANNEL_OVERFLOW) {
  330. mchp_corespi_write(spi, REG_INT_CLEAR, INT_RX_CHANNEL_OVERFLOW);
  331. finalise = true;
  332. dev_err(&master->dev,
  333. "%s: RX OVERFLOW: rxlen: %d, txlen: %d\n", __func__,
  334. spi->rx_len, spi->tx_len);
  335. }
  336. if (intfield & INT_TX_CHANNEL_UNDERRUN) {
  337. mchp_corespi_write(spi, REG_INT_CLEAR, INT_TX_CHANNEL_UNDERRUN);
  338. finalise = true;
  339. dev_err(&master->dev,
  340. "%s: TX UNDERFLOW: rxlen: %d, txlen: %d\n", __func__,
  341. spi->rx_len, spi->tx_len);
  342. }
  343. if (finalise)
  344. spi_finalize_current_transfer(master);
  345. return IRQ_HANDLED;
  346. }
  347. static int mchp_corespi_calculate_clkgen(struct mchp_corespi *spi,
  348. unsigned long target_hz)
  349. {
  350. unsigned long clk_hz, spi_hz, clk_gen;
  351. clk_hz = clk_get_rate(spi->clk);
  352. if (!clk_hz)
  353. return -EINVAL;
  354. spi_hz = min(target_hz, clk_hz);
  355. /*
  356. * There are two possible clock modes for the controller generated
  357. * clock's division ratio:
  358. * CLK_MODE = 0: 1 / (2^(CLK_GEN + 1)) where CLK_GEN = 0 to 15.
  359. * CLK_MODE = 1: 1 / (2 * CLK_GEN + 1) where CLK_GEN = 0 to 255.
  360. * First try mode 1, fall back to 0 and if we have tried both modes and
  361. * we /still/ can't get a good setting, we then throw the toys out of
  362. * the pram and give up
  363. * clk_gen is the register name for the clock divider on MPFS.
  364. */
  365. clk_gen = DIV_ROUND_UP(clk_hz, 2 * spi_hz) - 1;
  366. if (clk_gen > CLK_GEN_MODE1_MAX || clk_gen <= CLK_GEN_MIN) {
  367. clk_gen = DIV_ROUND_UP(clk_hz, spi_hz);
  368. clk_gen = fls(clk_gen) - 1;
  369. if (clk_gen > CLK_GEN_MODE0_MAX)
  370. return -EINVAL;
  371. spi->clk_mode = 0;
  372. } else {
  373. spi->clk_mode = 1;
  374. }
  375. spi->clk_gen = clk_gen;
  376. return 0;
  377. }
  378. static int mchp_corespi_transfer_one(struct spi_master *master,
  379. struct spi_device *spi_dev,
  380. struct spi_transfer *xfer)
  381. {
  382. struct mchp_corespi *spi = spi_master_get_devdata(master);
  383. int ret;
  384. ret = mchp_corespi_calculate_clkgen(spi, (unsigned long)xfer->speed_hz);
  385. if (ret) {
  386. dev_err(&master->dev, "failed to set clk_gen for target %u Hz\n", xfer->speed_hz);
  387. return ret;
  388. }
  389. mchp_corespi_set_clk_gen(spi);
  390. spi->tx_buf = xfer->tx_buf;
  391. spi->rx_buf = xfer->rx_buf;
  392. spi->tx_len = xfer->len;
  393. spi->rx_len = xfer->len;
  394. spi->pending = 0;
  395. mchp_corespi_set_xfer_size(spi, (spi->tx_len > FIFO_DEPTH)
  396. ? FIFO_DEPTH : spi->tx_len);
  397. if (spi->tx_len)
  398. mchp_corespi_write_fifo(spi);
  399. return 1;
  400. }
  401. static int mchp_corespi_prepare_message(struct spi_master *master,
  402. struct spi_message *msg)
  403. {
  404. struct spi_device *spi_dev = msg->spi;
  405. struct mchp_corespi *spi = spi_master_get_devdata(master);
  406. mchp_corespi_set_framesize(spi, DEFAULT_FRAMESIZE);
  407. mchp_corespi_set_mode(spi, spi_dev->mode);
  408. return 0;
  409. }
  410. static int mchp_corespi_probe(struct platform_device *pdev)
  411. {
  412. struct spi_master *master;
  413. struct mchp_corespi *spi;
  414. struct resource *res;
  415. u32 num_cs;
  416. int ret = 0;
  417. master = devm_spi_alloc_master(&pdev->dev, sizeof(*spi));
  418. if (!master)
  419. return dev_err_probe(&pdev->dev, -ENOMEM,
  420. "unable to allocate master for SPI controller\n");
  421. platform_set_drvdata(pdev, master);
  422. if (of_property_read_u32(pdev->dev.of_node, "num-cs", &num_cs))
  423. num_cs = MAX_CS;
  424. master->num_chipselect = num_cs;
  425. master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
  426. master->setup = mchp_corespi_setup;
  427. master->bits_per_word_mask = SPI_BPW_MASK(8);
  428. master->transfer_one = mchp_corespi_transfer_one;
  429. master->prepare_message = mchp_corespi_prepare_message;
  430. master->set_cs = mchp_corespi_set_cs;
  431. master->dev.of_node = pdev->dev.of_node;
  432. spi = spi_master_get_devdata(master);
  433. spi->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
  434. if (IS_ERR(spi->regs))
  435. return PTR_ERR(spi->regs);
  436. spi->irq = platform_get_irq(pdev, 0);
  437. if (spi->irq <= 0)
  438. return dev_err_probe(&pdev->dev, -ENXIO,
  439. "invalid IRQ %d for SPI controller\n",
  440. spi->irq);
  441. ret = devm_request_irq(&pdev->dev, spi->irq, mchp_corespi_interrupt,
  442. IRQF_SHARED, dev_name(&pdev->dev), master);
  443. if (ret)
  444. return dev_err_probe(&pdev->dev, ret,
  445. "could not request irq\n");
  446. spi->clk = devm_clk_get(&pdev->dev, NULL);
  447. if (IS_ERR(spi->clk))
  448. return dev_err_probe(&pdev->dev, PTR_ERR(spi->clk),
  449. "could not get clk\n");
  450. ret = clk_prepare_enable(spi->clk);
  451. if (ret)
  452. return dev_err_probe(&pdev->dev, ret,
  453. "failed to enable clock\n");
  454. mchp_corespi_init(master, spi);
  455. ret = devm_spi_register_master(&pdev->dev, master);
  456. if (ret) {
  457. mchp_corespi_disable(spi);
  458. clk_disable_unprepare(spi->clk);
  459. return dev_err_probe(&pdev->dev, ret,
  460. "unable to register master for SPI controller\n");
  461. }
  462. dev_info(&pdev->dev, "Registered SPI controller %d\n", master->bus_num);
  463. return 0;
  464. }
  465. static int mchp_corespi_remove(struct platform_device *pdev)
  466. {
  467. struct spi_master *master = platform_get_drvdata(pdev);
  468. struct mchp_corespi *spi = spi_master_get_devdata(master);
  469. mchp_corespi_disable_ints(spi);
  470. clk_disable_unprepare(spi->clk);
  471. mchp_corespi_disable(spi);
  472. return 0;
  473. }
  474. #define MICROCHIP_SPI_PM_OPS (NULL)
  475. /*
  476. * Platform driver data structure
  477. */
  478. #if defined(CONFIG_OF)
  479. static const struct of_device_id mchp_corespi_dt_ids[] = {
  480. { .compatible = "microchip,mpfs-spi" },
  481. { /* sentinel */ }
  482. };
  483. MODULE_DEVICE_TABLE(of, mchp_corespi_dt_ids);
  484. #endif
  485. static struct platform_driver mchp_corespi_driver = {
  486. .probe = mchp_corespi_probe,
  487. .driver = {
  488. .name = "microchip-corespi",
  489. .pm = MICROCHIP_SPI_PM_OPS,
  490. .of_match_table = of_match_ptr(mchp_corespi_dt_ids),
  491. },
  492. .remove = mchp_corespi_remove,
  493. };
  494. module_platform_driver(mchp_corespi_driver);
  495. MODULE_DESCRIPTION("Microchip coreSPI SPI controller driver");
  496. MODULE_AUTHOR("Daire McNamara <[email protected]>");
  497. MODULE_AUTHOR("Conor Dooley <[email protected]>");
  498. MODULE_LICENSE("GPL");