spi: Add support for SPL_OF_PLATDATA to mxs_spi.c driver
[platform/kernel/u-boot.git] / drivers / spi / mxs_spi.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Freescale i.MX28 SPI driver
4  *
5  * Copyright (C) 2019 DENX Software Engineering
6  * Lukasz Majewski, DENX Software Engineering, lukma@denx.de
7  *
8  * Copyright (C) 2011 Marek Vasut <marek.vasut@gmail.com>
9  * on behalf of DENX Software Engineering GmbH
10  *
11  * NOTE: This driver only supports the SPI-controller chipselects,
12  *       GPIO driven chipselects are not supported.
13  */
14
15 #include <common.h>
16 #include <malloc.h>
17 #include <memalign.h>
18 #include <spi.h>
19 #include <linux/errno.h>
20 #include <asm/io.h>
21 #include <asm/arch/clock.h>
22 #include <asm/arch/imx-regs.h>
23 #include <asm/arch/sys_proto.h>
24 #include <asm/mach-imx/dma.h>
25
26 #define MXS_SPI_MAX_TIMEOUT     1000000
27 #define MXS_SPI_PORT_OFFSET     0x2000
28 #define MXS_SSP_CHIPSELECT_MASK         0x00300000
29 #define MXS_SSP_CHIPSELECT_SHIFT        20
30
31 #define MXSSSP_SMALL_TRANSFER   512
32
33 static void mxs_spi_start_xfer(struct mxs_ssp_regs *ssp_regs)
34 {
35         writel(SSP_CTRL0_LOCK_CS, &ssp_regs->hw_ssp_ctrl0_set);
36         writel(SSP_CTRL0_IGNORE_CRC, &ssp_regs->hw_ssp_ctrl0_clr);
37 }
38
39 static void mxs_spi_end_xfer(struct mxs_ssp_regs *ssp_regs)
40 {
41         writel(SSP_CTRL0_LOCK_CS, &ssp_regs->hw_ssp_ctrl0_clr);
42         writel(SSP_CTRL0_IGNORE_CRC, &ssp_regs->hw_ssp_ctrl0_set);
43 }
44
45 #if !CONFIG_IS_ENABLED(DM_SPI)
46 struct mxs_spi_slave {
47         struct spi_slave        slave;
48         uint32_t                max_khz;
49         uint32_t                mode;
50         struct mxs_ssp_regs     *regs;
51 };
52
53 static inline struct mxs_spi_slave *to_mxs_slave(struct spi_slave *slave)
54 {
55         return container_of(slave, struct mxs_spi_slave, slave);
56 }
57 #else
58 #include <dm.h>
59 #include <errno.h>
60 #include <dt-structs.h>
61
62 #ifdef CONFIG_MX28
63 #define dtd_fsl_imx_spi dtd_fsl_imx28_spi
64 #else /* CONFIG_MX23 */
65 #define dtd_fsl_imx_spi dtd_fsl_imx23_spi
66 #endif
67
68 struct mxs_spi_platdata {
69 #if CONFIG_IS_ENABLED(OF_PLATDATA)
70         struct dtd_fsl_imx_spi dtplat;
71 #endif
72         s32 frequency;          /* Default clock frequency, -1 for none */
73         fdt_addr_t base;        /* SPI IP block base address */
74         int num_cs;             /* Number of CSes supported */
75         int dma_id;             /* ID of the DMA channel */
76         int clk_id;             /* ID of the SSP clock */
77 };
78
79 struct mxs_spi_priv {
80         struct mxs_ssp_regs *regs;
81         unsigned int dma_channel;
82         unsigned int max_freq;
83         unsigned int clk_id;
84         unsigned int mode;
85 };
86 #endif
87
88 #if !CONFIG_IS_ENABLED(DM_SPI)
89 static int mxs_spi_xfer_pio(struct mxs_spi_slave *slave,
90                         char *data, int length, int write, unsigned long flags)
91 {
92         struct mxs_ssp_regs *ssp_regs = slave->regs;
93 #else
94 static int mxs_spi_xfer_pio(struct mxs_spi_priv *priv,
95                             char *data, int length, int write,
96                             unsigned long flags)
97 {
98         struct mxs_ssp_regs *ssp_regs = priv->regs;
99 #endif
100
101         if (flags & SPI_XFER_BEGIN)
102                 mxs_spi_start_xfer(ssp_regs);
103
104         while (length--) {
105                 /* We transfer 1 byte */
106 #if defined(CONFIG_MX23)
107                 writel(SSP_CTRL0_XFER_COUNT_MASK, &ssp_regs->hw_ssp_ctrl0_clr);
108                 writel(1, &ssp_regs->hw_ssp_ctrl0_set);
109 #elif defined(CONFIG_MX28)
110                 writel(1, &ssp_regs->hw_ssp_xfer_size);
111 #endif
112
113                 if ((flags & SPI_XFER_END) && !length)
114                         mxs_spi_end_xfer(ssp_regs);
115
116                 if (write)
117                         writel(SSP_CTRL0_READ, &ssp_regs->hw_ssp_ctrl0_clr);
118                 else
119                         writel(SSP_CTRL0_READ, &ssp_regs->hw_ssp_ctrl0_set);
120
121                 writel(SSP_CTRL0_RUN, &ssp_regs->hw_ssp_ctrl0_set);
122
123                 if (mxs_wait_mask_set(&ssp_regs->hw_ssp_ctrl0_reg,
124                         SSP_CTRL0_RUN, MXS_SPI_MAX_TIMEOUT)) {
125                         printf("MXS SPI: Timeout waiting for start\n");
126                         return -ETIMEDOUT;
127                 }
128
129                 if (write)
130                         writel(*data++, &ssp_regs->hw_ssp_data);
131
132                 writel(SSP_CTRL0_DATA_XFER, &ssp_regs->hw_ssp_ctrl0_set);
133
134                 if (!write) {
135                         if (mxs_wait_mask_clr(&ssp_regs->hw_ssp_status_reg,
136                                 SSP_STATUS_FIFO_EMPTY, MXS_SPI_MAX_TIMEOUT)) {
137                                 printf("MXS SPI: Timeout waiting for data\n");
138                                 return -ETIMEDOUT;
139                         }
140
141                         *data = readl(&ssp_regs->hw_ssp_data);
142                         data++;
143                 }
144
145                 if (mxs_wait_mask_clr(&ssp_regs->hw_ssp_ctrl0_reg,
146                         SSP_CTRL0_RUN, MXS_SPI_MAX_TIMEOUT)) {
147                         printf("MXS SPI: Timeout waiting for finish\n");
148                         return -ETIMEDOUT;
149                 }
150         }
151
152         return 0;
153 }
154
155 #if !CONFIG_IS_ENABLED(DM_SPI)
156 static int mxs_spi_xfer_dma(struct mxs_spi_slave *slave,
157                         char *data, int length, int write, unsigned long flags)
158 {
159         struct mxs_ssp_regs *ssp_regs = slave->regs;
160 #else
161 static int mxs_spi_xfer_dma(struct mxs_spi_priv *priv,
162                             char *data, int length, int write,
163                             unsigned long flags)
164 {       struct mxs_ssp_regs *ssp_regs = priv->regs;
165 #endif
166         const int xfer_max_sz = 0xff00;
167         const int desc_count = DIV_ROUND_UP(length, xfer_max_sz) + 1;
168         struct mxs_dma_desc *dp;
169         uint32_t ctrl0;
170         uint32_t cache_data_count;
171         const uint32_t dstart = (uint32_t)data;
172         int dmach;
173         int tl;
174         int ret = 0;
175
176 #if defined(CONFIG_MX23)
177         const int mxs_spi_pio_words = 1;
178 #elif defined(CONFIG_MX28)
179         const int mxs_spi_pio_words = 4;
180 #endif
181
182         ALLOC_CACHE_ALIGN_BUFFER(struct mxs_dma_desc, desc, desc_count);
183
184         memset(desc, 0, sizeof(struct mxs_dma_desc) * desc_count);
185
186         ctrl0 = readl(&ssp_regs->hw_ssp_ctrl0);
187         ctrl0 |= SSP_CTRL0_DATA_XFER;
188
189         if (flags & SPI_XFER_BEGIN)
190                 ctrl0 |= SSP_CTRL0_LOCK_CS;
191         if (!write)
192                 ctrl0 |= SSP_CTRL0_READ;
193
194         if (length % ARCH_DMA_MINALIGN)
195                 cache_data_count = roundup(length, ARCH_DMA_MINALIGN);
196         else
197                 cache_data_count = length;
198
199         /* Flush data to DRAM so DMA can pick them up */
200         if (write)
201                 flush_dcache_range(dstart, dstart + cache_data_count);
202
203         /* Invalidate the area, so no writeback into the RAM races with DMA */
204         invalidate_dcache_range(dstart, dstart + cache_data_count);
205
206 #if !CONFIG_IS_ENABLED(DM_SPI)
207         dmach = MXS_DMA_CHANNEL_AHB_APBH_SSP0 + slave->slave.bus;
208 #else
209         dmach = priv->dma_channel;
210 #endif
211
212         dp = desc;
213         while (length) {
214                 dp->address = (dma_addr_t)dp;
215                 dp->cmd.address = (dma_addr_t)data;
216
217                 /*
218                  * This is correct, even though it does indeed look insane.
219                  * I hereby have to, wholeheartedly, thank Freescale Inc.,
220                  * for always inventing insane hardware and keeping me busy
221                  * and employed ;-)
222                  */
223                 if (write)
224                         dp->cmd.data = MXS_DMA_DESC_COMMAND_DMA_READ;
225                 else
226                         dp->cmd.data = MXS_DMA_DESC_COMMAND_DMA_WRITE;
227
228                 /*
229                  * The DMA controller can transfer large chunks (64kB) at
230                  * time by setting the transfer length to 0. Setting tl to
231                  * 0x10000 will overflow below and make .data contain 0.
232                  * Otherwise, 0xff00 is the transfer maximum.
233                  */
234                 if (length >= 0x10000)
235                         tl = 0x10000;
236                 else
237                         tl = min(length, xfer_max_sz);
238
239                 dp->cmd.data |=
240                         ((tl & 0xffff) << MXS_DMA_DESC_BYTES_OFFSET) |
241                         (mxs_spi_pio_words << MXS_DMA_DESC_PIO_WORDS_OFFSET) |
242                         MXS_DMA_DESC_HALT_ON_TERMINATE |
243                         MXS_DMA_DESC_TERMINATE_FLUSH;
244
245                 data += tl;
246                 length -= tl;
247
248                 if (!length) {
249                         dp->cmd.data |= MXS_DMA_DESC_IRQ | MXS_DMA_DESC_DEC_SEM;
250
251                         if (flags & SPI_XFER_END) {
252                                 ctrl0 &= ~SSP_CTRL0_LOCK_CS;
253                                 ctrl0 |= SSP_CTRL0_IGNORE_CRC;
254                         }
255                 }
256
257                 /*
258                  * Write CTRL0, CMD0, CMD1 and XFER_SIZE registers in
259                  * case of MX28, write only CTRL0 in case of MX23 due
260                  * to the difference in register layout. It is utterly
261                  * essential that the XFER_SIZE register is written on
262                  * a per-descriptor basis with the same size as is the
263                  * descriptor!
264                  */
265                 dp->cmd.pio_words[0] = ctrl0;
266 #ifdef CONFIG_MX28
267                 dp->cmd.pio_words[1] = 0;
268                 dp->cmd.pio_words[2] = 0;
269                 dp->cmd.pio_words[3] = tl;
270 #endif
271
272                 mxs_dma_desc_append(dmach, dp);
273
274                 dp++;
275         }
276
277         if (mxs_dma_go(dmach))
278                 ret = -EINVAL;
279
280         /* The data arrived into DRAM, invalidate cache over them */
281         if (!write)
282                 invalidate_dcache_range(dstart, dstart + cache_data_count);
283
284         return ret;
285 }
286
287 #if !CONFIG_IS_ENABLED(DM_SPI)
288 int spi_xfer(struct spi_slave *slave, unsigned int bitlen,
289                 const void *dout, void *din, unsigned long flags)
290 {
291         struct mxs_spi_slave *mxs_slave = to_mxs_slave(slave);
292         struct mxs_ssp_regs *ssp_regs = mxs_slave->regs;
293 #else
294 int mxs_spi_xfer(struct udevice *dev, unsigned int bitlen,
295                  const void *dout, void *din, unsigned long flags)
296 {
297         struct udevice *bus = dev_get_parent(dev);
298         struct mxs_spi_priv *priv = dev_get_priv(bus);
299         struct mxs_ssp_regs *ssp_regs = priv->regs;
300 #endif
301         int len = bitlen / 8;
302         char dummy;
303         int write = 0;
304         char *data = NULL;
305         int dma = 1;
306
307         if (bitlen == 0) {
308                 if (flags & SPI_XFER_END) {
309                         din = (void *)&dummy;
310                         len = 1;
311                 } else
312                         return 0;
313         }
314
315         /* Half-duplex only */
316         if (din && dout)
317                 return -EINVAL;
318         /* No data */
319         if (!din && !dout)
320                 return 0;
321
322         if (dout) {
323                 data = (char *)dout;
324                 write = 1;
325         } else if (din) {
326                 data = (char *)din;
327                 write = 0;
328         }
329
330         /*
331          * Check for alignment, if the buffer is aligned, do DMA transfer,
332          * PIO otherwise. This is a temporary workaround until proper bounce
333          * buffer is in place.
334          */
335         if (dma) {
336                 if (((uint32_t)data) & (ARCH_DMA_MINALIGN - 1))
337                         dma = 0;
338                 if (((uint32_t)len) & (ARCH_DMA_MINALIGN - 1))
339                         dma = 0;
340         }
341
342         if (!dma || (len < MXSSSP_SMALL_TRANSFER)) {
343                 writel(SSP_CTRL1_DMA_ENABLE, &ssp_regs->hw_ssp_ctrl1_clr);
344 #if !CONFIG_IS_ENABLED(DM_SPI)
345                 return mxs_spi_xfer_pio(mxs_slave, data, len, write, flags);
346 #else
347                 return mxs_spi_xfer_pio(priv, data, len, write, flags);
348 #endif
349         } else {
350                 writel(SSP_CTRL1_DMA_ENABLE, &ssp_regs->hw_ssp_ctrl1_set);
351 #if !CONFIG_IS_ENABLED(DM_SPI)
352                 return mxs_spi_xfer_dma(mxs_slave, data, len, write, flags);
353 #else
354                 return mxs_spi_xfer_dma(priv, data, len, write, flags);
355 #endif
356         }
357 }
358
359 #if !CONFIG_IS_ENABLED(DM_SPI)
360 int spi_cs_is_valid(unsigned int bus, unsigned int cs)
361 {
362         /* MXS SPI: 4 ports and 3 chip selects maximum */
363         if (!mxs_ssp_bus_id_valid(bus) || cs > 2)
364                 return 0;
365         else
366                 return 1;
367 }
368
369 struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
370                                   unsigned int max_hz, unsigned int mode)
371 {
372         struct mxs_spi_slave *mxs_slave;
373
374         if (!spi_cs_is_valid(bus, cs)) {
375                 printf("mxs_spi: invalid bus %d / chip select %d\n", bus, cs);
376                 return NULL;
377         }
378
379         mxs_slave = spi_alloc_slave(struct mxs_spi_slave, bus, cs);
380         if (!mxs_slave)
381                 return NULL;
382
383         if (mxs_dma_init_channel(MXS_DMA_CHANNEL_AHB_APBH_SSP0 + bus))
384                 goto err_init;
385
386         mxs_slave->max_khz = max_hz / 1000;
387         mxs_slave->mode = mode;
388         mxs_slave->regs = mxs_ssp_regs_by_bus(bus);
389
390         return &mxs_slave->slave;
391
392 err_init:
393         free(mxs_slave);
394         return NULL;
395 }
396
397 void spi_free_slave(struct spi_slave *slave)
398 {
399         struct mxs_spi_slave *mxs_slave = to_mxs_slave(slave);
400
401         free(mxs_slave);
402 }
403
404 int spi_claim_bus(struct spi_slave *slave)
405 {
406         struct mxs_spi_slave *mxs_slave = to_mxs_slave(slave);
407         struct mxs_ssp_regs *ssp_regs = mxs_slave->regs;
408         u32 reg = 0;
409
410         mxs_reset_block(&ssp_regs->hw_ssp_ctrl0_reg);
411
412         writel((slave->cs << MXS_SSP_CHIPSELECT_SHIFT) |
413                SSP_CTRL0_BUS_WIDTH_ONE_BIT,
414                &ssp_regs->hw_ssp_ctrl0);
415
416         reg = SSP_CTRL1_SSP_MODE_SPI | SSP_CTRL1_WORD_LENGTH_EIGHT_BITS;
417         reg |= (mxs_slave->mode & SPI_CPOL) ? SSP_CTRL1_POLARITY : 0;
418         reg |= (mxs_slave->mode & SPI_CPHA) ? SSP_CTRL1_PHASE : 0;
419         writel(reg, &ssp_regs->hw_ssp_ctrl1);
420
421         writel(0, &ssp_regs->hw_ssp_cmd0);
422
423         mxs_set_ssp_busclock(slave->bus, mxs_slave->max_khz);
424
425         return 0;
426 }
427
428 void spi_release_bus(struct spi_slave *slave)
429 {
430 }
431
432 #else /* CONFIG_DM_SPI */
433 /* Base numbers of i.MX2[38] clk for ssp0 IP block */
434 #define MXS_SSP_IMX23_CLKID_SSP0 33
435 #define MXS_SSP_IMX28_CLKID_SSP0 46
436
437 static int mxs_spi_probe(struct udevice *bus)
438 {
439         struct mxs_spi_platdata *plat = dev_get_platdata(bus);
440         struct mxs_spi_priv *priv = dev_get_priv(bus);
441         int ret;
442
443         debug("%s: probe\n", __func__);
444
445 #if CONFIG_IS_ENABLED(OF_PLATDATA)
446         struct dtd_fsl_imx_spi *dtplat = &plat->dtplat;
447         struct phandle_1_arg *p1a = &dtplat->clocks[0];
448
449         priv->regs = (struct mxs_ssp_regs *)dtplat->reg[0];
450         priv->dma_channel = dtplat->dmas[1];
451         priv->clk_id = p1a->arg[0];
452         priv->max_freq = dtplat->spi_max_frequency;
453         plat->num_cs = dtplat->num_cs;
454
455         debug("OF_PLATDATA: regs: 0x%x max freq: %d clkid: %d\n",
456               (unsigned int)priv->regs, priv->max_freq, priv->clk_id);
457 #else
458         priv->regs = (struct mxs_ssp_regs *)plat->base;
459         priv->max_freq = plat->frequency;
460
461         priv->dma_channel = plat->dma_id;
462         priv->clk_id = plat->clk_id;
463 #endif
464
465         mxs_reset_block(&priv->regs->hw_ssp_ctrl0_reg);
466
467         ret = mxs_dma_init_channel(priv->dma_channel);
468         if (ret) {
469                 printf("%s: DMA init channel error %d\n", __func__, ret);
470                 return ret;
471         }
472
473         return 0;
474 }
475
476 static int mxs_spi_claim_bus(struct udevice *dev)
477 {
478         struct udevice *bus = dev_get_parent(dev);
479         struct mxs_spi_priv *priv = dev_get_priv(bus);
480         struct mxs_ssp_regs *ssp_regs = priv->regs;
481         int cs = spi_chip_select(dev);
482
483         /*
484          * i.MX28 supports up to 3 CS (SSn0, SSn1, SSn2)
485          * To set them it uses following tuple (WAIT_FOR_IRQ,WAIT_FOR_CMD),
486          * where:
487          *
488          * WAIT_FOR_IRQ is bit 21 of HW_SSP_CTRL0
489          * WAIT_FOR_CMD is bit 20 (#defined as MXS_SSP_CHIPSELECT_SHIFT here) of
490          *                        HW_SSP_CTRL0
491          * SSn0 b00
492          * SSn1 b01
493          * SSn2 b10 (which require setting WAIT_FOR_IRQ)
494          *
495          * However, for now i.MX28 SPI driver will support up till 2 CSes
496          * (SSn0, and SSn1).
497          */
498
499         /* Ungate SSP clock and set active CS */
500         clrsetbits_le32(&ssp_regs->hw_ssp_ctrl0,
501                         BIT(MXS_SSP_CHIPSELECT_SHIFT) |
502                         SSP_CTRL0_CLKGATE, (cs << MXS_SSP_CHIPSELECT_SHIFT));
503
504         return 0;
505 }
506
507 static int mxs_spi_release_bus(struct udevice *dev)
508 {
509         struct udevice *bus = dev_get_parent(dev);
510         struct mxs_spi_priv *priv = dev_get_priv(bus);
511         struct mxs_ssp_regs *ssp_regs = priv->regs;
512
513         /* Gate SSP clock */
514         setbits_le32(&ssp_regs->hw_ssp_ctrl0, SSP_CTRL0_CLKGATE);
515
516         return 0;
517 }
518
519 static int mxs_spi_set_speed(struct udevice *bus, uint speed)
520 {
521         struct mxs_spi_priv *priv = dev_get_priv(bus);
522 #ifdef CONFIG_MX28
523         int clkid = priv->clk_id - MXS_SSP_IMX28_CLKID_SSP0;
524 #else /* CONFIG_MX23 */
525         int clkid = priv->clk_id - MXS_SSP_IMX23_CLKID_SSP0;
526 #endif
527         if (speed > priv->max_freq)
528                 speed = priv->max_freq;
529
530         debug("%s speed: %u [Hz] clkid: %d\n", __func__, speed, clkid);
531         mxs_set_ssp_busclock(clkid, speed / 1000);
532
533         return 0;
534 }
535
536 static int mxs_spi_set_mode(struct udevice *bus, uint mode)
537 {
538         struct mxs_spi_priv *priv = dev_get_priv(bus);
539         struct mxs_ssp_regs *ssp_regs = priv->regs;
540         u32 reg;
541
542         priv->mode = mode;
543         debug("%s: mode 0x%x\n", __func__, mode);
544
545         reg = SSP_CTRL1_SSP_MODE_SPI | SSP_CTRL1_WORD_LENGTH_EIGHT_BITS;
546         reg |= (priv->mode & SPI_CPOL) ? SSP_CTRL1_POLARITY : 0;
547         reg |= (priv->mode & SPI_CPHA) ? SSP_CTRL1_PHASE : 0;
548         writel(reg, &ssp_regs->hw_ssp_ctrl1);
549
550         /* Single bit SPI support */
551         writel(SSP_CTRL0_BUS_WIDTH_ONE_BIT, &ssp_regs->hw_ssp_ctrl0);
552
553         return 0;
554 }
555
556 static const struct dm_spi_ops mxs_spi_ops = {
557         .claim_bus      = mxs_spi_claim_bus,
558         .release_bus    = mxs_spi_release_bus,
559         .xfer           = mxs_spi_xfer,
560         .set_speed      = mxs_spi_set_speed,
561         .set_mode       = mxs_spi_set_mode,
562         /*
563          * cs_info is not needed, since we require all chip selects to be
564          * in the device tree explicitly
565          */
566 };
567
568 #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
569 static int mxs_ofdata_to_platdata(struct udevice *bus)
570 {
571         struct mxs_spi_platdata *plat = bus->platdata;
572         u32 prop[2];
573         int ret;
574
575         plat->base = dev_read_addr(bus);
576         plat->frequency =
577                 dev_read_u32_default(bus, "spi-max-frequency", 40000000);
578         plat->num_cs = dev_read_u32_default(bus, "num-cs", 2);
579
580         ret = dev_read_u32_array(bus, "dmas", prop, ARRAY_SIZE(prop));
581         if (ret) {
582                 printf("%s: Reading 'dmas' property failed!\n", __func__);
583                 return ret;
584         }
585         plat->dma_id = prop[1];
586
587         ret = dev_read_u32_array(bus, "clocks", prop, ARRAY_SIZE(prop));
588         if (ret) {
589                 printf("%s: Reading 'clocks' property failed!\n", __func__);
590                 return ret;
591         }
592         plat->clk_id = prop[1];
593
594         debug("%s: base=0x%x, max-frequency=%d num-cs=%d dma_id=%d clk_id=%d\n",
595               __func__, (uint)plat->base, plat->frequency, plat->num_cs,
596               plat->dma_id, plat->clk_id);
597
598         return 0;
599 }
600
601 static const struct udevice_id mxs_spi_ids[] = {
602         { .compatible = "fsl,imx23-spi" },
603         { .compatible = "fsl,imx28-spi" },
604         { }
605 };
606 #endif
607
608 U_BOOT_DRIVER(mxs_spi) = {
609 #ifdef CONFIG_MX28
610         .name = "fsl_imx28_spi",
611 #else /* CONFIG_MX23 */
612         .name = "fsl_imx23_spi",
613 #endif
614         .id     = UCLASS_SPI,
615 #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
616         .of_match = mxs_spi_ids,
617         .ofdata_to_platdata = mxs_ofdata_to_platdata,
618 #endif
619         .platdata_auto_alloc_size = sizeof(struct mxs_spi_platdata),
620         .ops    = &mxs_spi_ops,
621         .priv_auto_alloc_size = sizeof(struct mxs_spi_priv),
622         .probe  = mxs_spi_probe,
623 };
624 #endif