blob: 3d0f659ecb2c10ba3d3138d61450fa7cecacfa13 [file] [log] [blame]
Michael Walled3967f32019-12-18 00:09:58 +01001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * NXP FlexSPI(FSPI) controller driver.
4 *
5 * Copyright (c) 2019 Michael Walle <michael@walle.cc>
6 * Copyright (c) 2019 NXP
7 *
8 * This driver was originally ported from the linux kernel v5.4-rc3, which had
9 * the following notes:
10 *
11 * FlexSPI is a flexsible SPI host controller which supports two SPI
12 * channels and up to 4 external devices. Each channel supports
13 * Single/Dual/Quad/Octal mode data transfer (1/2/4/8 bidirectional
14 * data lines).
15 *
16 * FlexSPI controller is driven by the LUT(Look-up Table) registers
17 * LUT registers are a look-up-table for sequences of instructions.
18 * A valid sequence consists of four LUT registers.
19 * Maximum 32 LUT sequences can be programmed simultaneously.
20 *
21 * LUTs are being created at run-time based on the commands passed
22 * from the spi-mem framework, thus using single LUT index.
23 *
24 * Software triggered Flash read/write access by IP Bus.
25 *
26 * Memory mapped read access by AHB Bus.
27 *
28 * Based on SPI MEM interface and spi-fsl-qspi.c driver.
29 *
30 * Author:
31 * Yogesh Narayan Gaur <yogeshnarayan.gaur@nxp.com>
32 * Boris Brezillon <bbrezillon@kernel.org>
33 * Frieder Schrempf <frieder.schrempf@kontron.de>
34 */
35
Sean Andersonacccaca2020-10-04 21:39:49 -040036#include <clk.h>
37#include <dm.h>
38#include <dm/device_compat.h>
Michael Walled3967f32019-12-18 00:09:58 +010039#include <malloc.h>
40#include <spi.h>
41#include <spi-mem.h>
Sean Andersonacccaca2020-10-04 21:39:49 -040042#include <asm/io.h>
Kuldeep Singh19e38b22021-08-03 14:32:58 +053043#ifdef CONFIG_FSL_LAYERSCAPE
44#include <asm/arch/clock.h>
45#include <asm/arch/soc.h>
46#include <asm/arch/speed.h>
47#endif
Simon Glass4dcacfc2020-05-10 11:40:13 -060048#include <linux/bitops.h>
Michael Walled3967f32019-12-18 00:09:58 +010049#include <linux/kernel.h>
50#include <linux/sizes.h>
51#include <linux/iopoll.h>
52#include <linux/bug.h>
Simon Glassfb6f4822020-02-03 07:36:17 -070053#include <linux/err.h>
Michael Walled3967f32019-12-18 00:09:58 +010054
Michael Walled3967f32019-12-18 00:09:58 +010055/* Registers used by the driver */
56#define FSPI_MCR0 0x00
57#define FSPI_MCR0_AHB_TIMEOUT(x) ((x) << 24)
58#define FSPI_MCR0_IP_TIMEOUT(x) ((x) << 16)
59#define FSPI_MCR0_LEARN_EN BIT(15)
60#define FSPI_MCR0_SCRFRUN_EN BIT(14)
61#define FSPI_MCR0_OCTCOMB_EN BIT(13)
62#define FSPI_MCR0_DOZE_EN BIT(12)
63#define FSPI_MCR0_HSEN BIT(11)
64#define FSPI_MCR0_SERCLKDIV BIT(8)
65#define FSPI_MCR0_ATDF_EN BIT(7)
66#define FSPI_MCR0_ARDF_EN BIT(6)
67#define FSPI_MCR0_RXCLKSRC(x) ((x) << 4)
68#define FSPI_MCR0_END_CFG(x) ((x) << 2)
69#define FSPI_MCR0_MDIS BIT(1)
70#define FSPI_MCR0_SWRST BIT(0)
71
72#define FSPI_MCR1 0x04
73#define FSPI_MCR1_SEQ_TIMEOUT(x) ((x) << 16)
74#define FSPI_MCR1_AHB_TIMEOUT(x) (x)
75
76#define FSPI_MCR2 0x08
77#define FSPI_MCR2_IDLE_WAIT(x) ((x) << 24)
78#define FSPI_MCR2_SAMEDEVICEEN BIT(15)
79#define FSPI_MCR2_CLRLRPHS BIT(14)
80#define FSPI_MCR2_ABRDATSZ BIT(8)
81#define FSPI_MCR2_ABRLEARN BIT(7)
82#define FSPI_MCR2_ABR_READ BIT(6)
83#define FSPI_MCR2_ABRWRITE BIT(5)
84#define FSPI_MCR2_ABRDUMMY BIT(4)
85#define FSPI_MCR2_ABR_MODE BIT(3)
86#define FSPI_MCR2_ABRCADDR BIT(2)
87#define FSPI_MCR2_ABRRADDR BIT(1)
88#define FSPI_MCR2_ABR_CMD BIT(0)
89
90#define FSPI_AHBCR 0x0c
91#define FSPI_AHBCR_RDADDROPT BIT(6)
92#define FSPI_AHBCR_PREF_EN BIT(5)
93#define FSPI_AHBCR_BUFF_EN BIT(4)
94#define FSPI_AHBCR_CACH_EN BIT(3)
95#define FSPI_AHBCR_CLRTXBUF BIT(2)
96#define FSPI_AHBCR_CLRRXBUF BIT(1)
97#define FSPI_AHBCR_PAR_EN BIT(0)
98
99#define FSPI_INTEN 0x10
100#define FSPI_INTEN_SCLKSBWR BIT(9)
101#define FSPI_INTEN_SCLKSBRD BIT(8)
102#define FSPI_INTEN_DATALRNFL BIT(7)
103#define FSPI_INTEN_IPTXWE BIT(6)
104#define FSPI_INTEN_IPRXWA BIT(5)
105#define FSPI_INTEN_AHBCMDERR BIT(4)
106#define FSPI_INTEN_IPCMDERR BIT(3)
107#define FSPI_INTEN_AHBCMDGE BIT(2)
108#define FSPI_INTEN_IPCMDGE BIT(1)
109#define FSPI_INTEN_IPCMDDONE BIT(0)
110
111#define FSPI_INTR 0x14
112#define FSPI_INTR_SCLKSBWR BIT(9)
113#define FSPI_INTR_SCLKSBRD BIT(8)
114#define FSPI_INTR_DATALRNFL BIT(7)
115#define FSPI_INTR_IPTXWE BIT(6)
116#define FSPI_INTR_IPRXWA BIT(5)
117#define FSPI_INTR_AHBCMDERR BIT(4)
118#define FSPI_INTR_IPCMDERR BIT(3)
119#define FSPI_INTR_AHBCMDGE BIT(2)
120#define FSPI_INTR_IPCMDGE BIT(1)
121#define FSPI_INTR_IPCMDDONE BIT(0)
122
123#define FSPI_LUTKEY 0x18
124#define FSPI_LUTKEY_VALUE 0x5AF05AF0
125
126#define FSPI_LCKCR 0x1C
127
128#define FSPI_LCKER_LOCK 0x1
129#define FSPI_LCKER_UNLOCK 0x2
130
131#define FSPI_BUFXCR_INVALID_MSTRID 0xE
132#define FSPI_AHBRX_BUF0CR0 0x20
133#define FSPI_AHBRX_BUF1CR0 0x24
134#define FSPI_AHBRX_BUF2CR0 0x28
135#define FSPI_AHBRX_BUF3CR0 0x2C
136#define FSPI_AHBRX_BUF4CR0 0x30
137#define FSPI_AHBRX_BUF5CR0 0x34
138#define FSPI_AHBRX_BUF6CR0 0x38
139#define FSPI_AHBRX_BUF7CR0 0x3C
140#define FSPI_AHBRXBUF0CR7_PREF BIT(31)
141
142#define FSPI_AHBRX_BUF0CR1 0x40
143#define FSPI_AHBRX_BUF1CR1 0x44
144#define FSPI_AHBRX_BUF2CR1 0x48
145#define FSPI_AHBRX_BUF3CR1 0x4C
146#define FSPI_AHBRX_BUF4CR1 0x50
147#define FSPI_AHBRX_BUF5CR1 0x54
148#define FSPI_AHBRX_BUF6CR1 0x58
149#define FSPI_AHBRX_BUF7CR1 0x5C
150
151#define FSPI_FLSHA1CR0 0x60
152#define FSPI_FLSHA2CR0 0x64
153#define FSPI_FLSHB1CR0 0x68
154#define FSPI_FLSHB2CR0 0x6C
155#define FSPI_FLSHXCR0_SZ_KB 10
156#define FSPI_FLSHXCR0_SZ(x) ((x) >> FSPI_FLSHXCR0_SZ_KB)
157
158#define FSPI_FLSHA1CR1 0x70
159#define FSPI_FLSHA2CR1 0x74
160#define FSPI_FLSHB1CR1 0x78
161#define FSPI_FLSHB2CR1 0x7C
162#define FSPI_FLSHXCR1_CSINTR(x) ((x) << 16)
163#define FSPI_FLSHXCR1_CAS(x) ((x) << 11)
164#define FSPI_FLSHXCR1_WA BIT(10)
165#define FSPI_FLSHXCR1_TCSH(x) ((x) << 5)
166#define FSPI_FLSHXCR1_TCSS(x) (x)
167
168#define FSPI_FLSHA1CR2 0x80
169#define FSPI_FLSHA2CR2 0x84
170#define FSPI_FLSHB1CR2 0x88
171#define FSPI_FLSHB2CR2 0x8C
172#define FSPI_FLSHXCR2_CLRINSP BIT(24)
173#define FSPI_FLSHXCR2_AWRWAIT BIT(16)
174#define FSPI_FLSHXCR2_AWRSEQN_SHIFT 13
175#define FSPI_FLSHXCR2_AWRSEQI_SHIFT 8
176#define FSPI_FLSHXCR2_ARDSEQN_SHIFT 5
177#define FSPI_FLSHXCR2_ARDSEQI_SHIFT 0
178
179#define FSPI_IPCR0 0xA0
180
181#define FSPI_IPCR1 0xA4
182#define FSPI_IPCR1_IPAREN BIT(31)
183#define FSPI_IPCR1_SEQNUM_SHIFT 24
184#define FSPI_IPCR1_SEQID_SHIFT 16
185#define FSPI_IPCR1_IDATSZ(x) (x)
186
187#define FSPI_IPCMD 0xB0
188#define FSPI_IPCMD_TRG BIT(0)
189
190#define FSPI_DLPR 0xB4
191
192#define FSPI_IPRXFCR 0xB8
193#define FSPI_IPRXFCR_CLR BIT(0)
194#define FSPI_IPRXFCR_DMA_EN BIT(1)
195#define FSPI_IPRXFCR_WMRK(x) ((x) << 2)
196
197#define FSPI_IPTXFCR 0xBC
198#define FSPI_IPTXFCR_CLR BIT(0)
199#define FSPI_IPTXFCR_DMA_EN BIT(1)
200#define FSPI_IPTXFCR_WMRK(x) ((x) << 2)
201
202#define FSPI_DLLACR 0xC0
203#define FSPI_DLLACR_OVRDEN BIT(8)
204
205#define FSPI_DLLBCR 0xC4
206#define FSPI_DLLBCR_OVRDEN BIT(8)
207
208#define FSPI_STS0 0xE0
209#define FSPI_STS0_DLPHB(x) ((x) << 8)
210#define FSPI_STS0_DLPHA(x) ((x) << 4)
211#define FSPI_STS0_CMD_SRC(x) ((x) << 2)
212#define FSPI_STS0_ARB_IDLE BIT(1)
213#define FSPI_STS0_SEQ_IDLE BIT(0)
214
215#define FSPI_STS1 0xE4
216#define FSPI_STS1_IP_ERRCD(x) ((x) << 24)
217#define FSPI_STS1_IP_ERRID(x) ((x) << 16)
218#define FSPI_STS1_AHB_ERRCD(x) ((x) << 8)
219#define FSPI_STS1_AHB_ERRID(x) (x)
220
221#define FSPI_AHBSPNST 0xEC
222#define FSPI_AHBSPNST_DATLFT(x) ((x) << 16)
223#define FSPI_AHBSPNST_BUFID(x) ((x) << 1)
224#define FSPI_AHBSPNST_ACTIVE BIT(0)
225
226#define FSPI_IPRXFSTS 0xF0
227#define FSPI_IPRXFSTS_RDCNTR(x) ((x) << 16)
228#define FSPI_IPRXFSTS_FILL(x) (x)
229
230#define FSPI_IPTXFSTS 0xF4
231#define FSPI_IPTXFSTS_WRCNTR(x) ((x) << 16)
232#define FSPI_IPTXFSTS_FILL(x) (x)
233
234#define FSPI_RFDR 0x100
235#define FSPI_TFDR 0x180
236
237#define FSPI_LUT_BASE 0x200
Michael Walled3967f32019-12-18 00:09:58 +0100238
239/* register map end */
240
241/* Instruction set for the LUT register. */
242#define LUT_STOP 0x00
243#define LUT_CMD 0x01
244#define LUT_ADDR 0x02
245#define LUT_CADDR_SDR 0x03
246#define LUT_MODE 0x04
247#define LUT_MODE2 0x05
248#define LUT_MODE4 0x06
249#define LUT_MODE8 0x07
250#define LUT_NXP_WRITE 0x08
251#define LUT_NXP_READ 0x09
252#define LUT_LEARN_SDR 0x0A
253#define LUT_DATSZ_SDR 0x0B
254#define LUT_DUMMY 0x0C
255#define LUT_DUMMY_RWDS_SDR 0x0D
256#define LUT_JMP_ON_CS 0x1F
257#define LUT_CMD_DDR 0x21
258#define LUT_ADDR_DDR 0x22
259#define LUT_CADDR_DDR 0x23
260#define LUT_MODE_DDR 0x24
261#define LUT_MODE2_DDR 0x25
262#define LUT_MODE4_DDR 0x26
263#define LUT_MODE8_DDR 0x27
264#define LUT_WRITE_DDR 0x28
265#define LUT_READ_DDR 0x29
266#define LUT_LEARN_DDR 0x2A
267#define LUT_DATSZ_DDR 0x2B
268#define LUT_DUMMY_DDR 0x2C
269#define LUT_DUMMY_RWDS_DDR 0x2D
270
271/*
272 * Calculate number of required PAD bits for LUT register.
273 *
274 * The pad stands for the number of IO lines [0:7].
275 * For example, the octal read needs eight IO lines,
276 * so you should use LUT_PAD(8). This macro
277 * returns 3 i.e. use eight (2^3) IP lines for read.
278 */
279#define LUT_PAD(x) (fls(x) - 1)
280
281/*
282 * Macro for constructing the LUT entries with the following
283 * register layout:
284 *
285 * ---------------------------------------------------
286 * | INSTR1 | PAD1 | OPRND1 | INSTR0 | PAD0 | OPRND0 |
287 * ---------------------------------------------------
288 */
289#define PAD_SHIFT 8
290#define INSTR_SHIFT 10
291#define OPRND_SHIFT 16
292
293/* Macros for constructing the LUT register. */
294#define LUT_DEF(idx, ins, pad, opr) \
295 ((((ins) << INSTR_SHIFT) | ((pad) << PAD_SHIFT) | \
296 (opr)) << (((idx) % 2) * OPRND_SHIFT))
297
298#define POLL_TOUT 5000
299#define NXP_FSPI_MAX_CHIPSELECT 4
300
Kuldeep Singh66a813e2021-08-03 14:32:57 +0530301/* Access flash memory using IP bus only */
302#define FSPI_QUIRK_USE_IP_ONLY BIT(0)
303
Michael Walled3967f32019-12-18 00:09:58 +0100304struct nxp_fspi_devtype_data {
305 unsigned int rxfifo;
306 unsigned int txfifo;
307 unsigned int ahb_buf_size;
308 unsigned int quirks;
Jonathan Currier1e50ca82025-05-07 03:36:20 -0500309 unsigned int lut_num;
Michael Walled3967f32019-12-18 00:09:58 +0100310 bool little_endian;
311};
312
Kuldeep Singh19e38b22021-08-03 14:32:58 +0530313static struct nxp_fspi_devtype_data lx2160a_data = {
Michael Walled3967f32019-12-18 00:09:58 +0100314 .rxfifo = SZ_512, /* (64 * 64 bits) */
315 .txfifo = SZ_1K, /* (128 * 64 bits) */
316 .ahb_buf_size = SZ_2K, /* (256 * 64 bits) */
317 .quirks = 0,
Jonathan Currier1e50ca82025-05-07 03:36:20 -0500318 .lut_num = 32,
Michael Walled3967f32019-12-18 00:09:58 +0100319 .little_endian = true, /* little-endian */
320};
321
Kuldeep Singh19e38b22021-08-03 14:32:58 +0530322static struct nxp_fspi_devtype_data imx8mm_data = {
Adam Fordcf559bf2021-01-18 15:32:50 -0600323 .rxfifo = SZ_512, /* (64 * 64 bits) */
324 .txfifo = SZ_1K, /* (128 * 64 bits) */
325 .ahb_buf_size = SZ_2K, /* (256 * 64 bits) */
326 .quirks = 0,
Jonathan Currier1e50ca82025-05-07 03:36:20 -0500327 .lut_num = 32,
Adam Fordcf559bf2021-01-18 15:32:50 -0600328 .little_endian = true, /* little-endian */
329};
330
Michael Walled3967f32019-12-18 00:09:58 +0100331struct nxp_fspi {
332 struct udevice *dev;
333 void __iomem *iobase;
334 void __iomem *ahb_addr;
335 u32 memmap_phy;
336 u32 memmap_phy_size;
337 struct clk clk, clk_en;
Kuldeep Singh19e38b22021-08-03 14:32:58 +0530338 struct nxp_fspi_devtype_data *devtype_data;
Michael Walled3967f32019-12-18 00:09:58 +0100339};
340
Kuldeep Singh66a813e2021-08-03 14:32:57 +0530341static inline int needs_ip_only(struct nxp_fspi *f)
342{
343 return f->devtype_data->quirks & FSPI_QUIRK_USE_IP_ONLY;
344}
345
Michael Walled3967f32019-12-18 00:09:58 +0100346/*
347 * R/W functions for big- or little-endian registers:
348 * The FSPI controller's endianness is independent of
349 * the CPU core's endianness. So far, although the CPU
350 * core is little-endian the FSPI controller can use
351 * big-endian or little-endian.
352 */
353static void fspi_writel(struct nxp_fspi *f, u32 val, void __iomem *addr)
354{
355 if (f->devtype_data->little_endian)
356 out_le32(addr, val);
357 else
358 out_be32(addr, val);
359}
360
361static u32 fspi_readl(struct nxp_fspi *f, void __iomem *addr)
362{
363 if (f->devtype_data->little_endian)
364 return in_le32(addr);
365 else
366 return in_be32(addr);
367}
368
369static int nxp_fspi_check_buswidth(struct nxp_fspi *f, u8 width)
370{
371 switch (width) {
372 case 1:
373 case 2:
374 case 4:
375 case 8:
376 return 0;
377 }
378
379 return -ENOTSUPP;
380}
381
382static bool nxp_fspi_supports_op(struct spi_slave *slave,
383 const struct spi_mem_op *op)
384{
385 struct nxp_fspi *f;
386 struct udevice *bus;
387 int ret;
388
389 bus = slave->dev->parent;
390 f = dev_get_priv(bus);
391
392 ret = nxp_fspi_check_buswidth(f, op->cmd.buswidth);
393
394 if (op->addr.nbytes)
395 ret |= nxp_fspi_check_buswidth(f, op->addr.buswidth);
396
397 if (op->dummy.nbytes)
398 ret |= nxp_fspi_check_buswidth(f, op->dummy.buswidth);
399
400 if (op->data.nbytes)
401 ret |= nxp_fspi_check_buswidth(f, op->data.buswidth);
402
403 if (ret)
404 return false;
405
406 /*
407 * The number of address bytes should be equal to or less than 4 bytes.
408 */
409 if (op->addr.nbytes > 4)
410 return false;
411
412 /*
413 * If requested address value is greater than controller assigned
414 * memory mapped space, return error as it didn't fit in the range
415 * of assigned address space.
416 */
417 if (op->addr.val >= f->memmap_phy_size)
418 return false;
419
420 /* Max 64 dummy clock cycles supported */
421 if (op->dummy.buswidth &&
422 (op->dummy.nbytes * 8 / op->dummy.buswidth > 64))
423 return false;
424
425 /* Max data length, check controller limits and alignment */
426 if (op->data.dir == SPI_MEM_DATA_IN &&
427 (op->data.nbytes > f->devtype_data->ahb_buf_size ||
428 (op->data.nbytes > f->devtype_data->rxfifo - 4 &&
429 !IS_ALIGNED(op->data.nbytes, 8))))
430 return false;
431
432 if (op->data.dir == SPI_MEM_DATA_OUT &&
433 op->data.nbytes > f->devtype_data->txfifo)
434 return false;
435
Michael Walled9d57332021-07-26 21:35:28 +0200436 return spi_mem_default_supports_op(slave, op);
Michael Walled3967f32019-12-18 00:09:58 +0100437}
438
Kuldeep Singhcab56512020-04-27 12:38:51 +0530439/* Instead of busy looping invoke readl_poll_sleep_timeout functionality. */
Michael Walled3967f32019-12-18 00:09:58 +0100440static int fspi_readl_poll_tout(struct nxp_fspi *f, void __iomem *base,
441 u32 mask, u32 delay_us,
442 u32 timeout_us, bool c)
443{
444 u32 reg;
445
446 if (!f->devtype_data->little_endian)
447 mask = (u32)cpu_to_be32(mask);
448
449 if (c)
Kuldeep Singhcab56512020-04-27 12:38:51 +0530450 return readl_poll_sleep_timeout(base, reg, (reg & mask),
451 delay_us, timeout_us);
Michael Walled3967f32019-12-18 00:09:58 +0100452 else
Kuldeep Singhcab56512020-04-27 12:38:51 +0530453 return readl_poll_sleep_timeout(base, reg, !(reg & mask),
454 delay_us, timeout_us);
Michael Walled3967f32019-12-18 00:09:58 +0100455}
456
457/*
458 * If the slave device content being changed by Write/Erase, need to
459 * invalidate the AHB buffer. This can be achieved by doing the reset
460 * of controller after setting MCR0[SWRESET] bit.
461 */
462static inline void nxp_fspi_invalid(struct nxp_fspi *f)
463{
464 u32 reg;
465 int ret;
466
467 reg = fspi_readl(f, f->iobase + FSPI_MCR0);
468 fspi_writel(f, reg | FSPI_MCR0_SWRST, f->iobase + FSPI_MCR0);
469
470 /* w1c register, wait unit clear */
471 ret = fspi_readl_poll_tout(f, f->iobase + FSPI_MCR0,
472 FSPI_MCR0_SWRST, 0, POLL_TOUT, false);
473 WARN_ON(ret);
474}
475
476static void nxp_fspi_prepare_lut(struct nxp_fspi *f,
477 const struct spi_mem_op *op)
478{
479 void __iomem *base = f->iobase;
480 u32 lutval[4] = {};
481 int lutidx = 1, i;
Jonathan Currier1e50ca82025-05-07 03:36:20 -0500482 u32 lut_offset = (f->devtype_data->lut_num - 1) * 4 * 4;
483 u32 target_lut_reg;
Michael Walled3967f32019-12-18 00:09:58 +0100484
485 /* cmd */
486 lutval[0] |= LUT_DEF(0, LUT_CMD, LUT_PAD(op->cmd.buswidth),
487 op->cmd.opcode);
488
489 /* addr bytes */
490 if (op->addr.nbytes) {
491 lutval[lutidx / 2] |= LUT_DEF(lutidx, LUT_ADDR,
492 LUT_PAD(op->addr.buswidth),
493 op->addr.nbytes * 8);
494 lutidx++;
495 }
496
497 /* dummy bytes, if needed */
498 if (op->dummy.nbytes) {
499 lutval[lutidx / 2] |= LUT_DEF(lutidx, LUT_DUMMY,
500 /*
501 * Due to FlexSPI controller limitation number of PAD for dummy
502 * buswidth needs to be programmed as equal to data buswidth.
503 */
504 LUT_PAD(op->data.buswidth),
505 op->dummy.nbytes * 8 /
506 op->dummy.buswidth);
507 lutidx++;
508 }
509
510 /* read/write data bytes */
511 if (op->data.nbytes) {
512 lutval[lutidx / 2] |= LUT_DEF(lutidx,
513 op->data.dir == SPI_MEM_DATA_IN ?
514 LUT_NXP_READ : LUT_NXP_WRITE,
515 LUT_PAD(op->data.buswidth),
516 0);
517 lutidx++;
518 }
519
520 /* stop condition. */
521 lutval[lutidx / 2] |= LUT_DEF(lutidx, LUT_STOP, 0, 0);
522
523 /* unlock LUT */
524 fspi_writel(f, FSPI_LUTKEY_VALUE, f->iobase + FSPI_LUTKEY);
525 fspi_writel(f, FSPI_LCKER_UNLOCK, f->iobase + FSPI_LCKCR);
526
527 /* fill LUT */
Jonathan Currier1e50ca82025-05-07 03:36:20 -0500528 for (i = 0; i < ARRAY_SIZE(lutval); i++) {
529 target_lut_reg = FSPI_LUT_BASE + lut_offset + i * 4;
530 fspi_writel(f, lutval[i], base + target_lut_reg);
531 }
Michael Walled3967f32019-12-18 00:09:58 +0100532
Kuldeep Singh19e38b22021-08-03 14:32:58 +0530533 dev_dbg(f->dev, "CMD[%x] lutval[0:%x \t 1:%x \t 2:%x \t 3:%x], size: 0x%08x\n",
534 op->cmd.opcode, lutval[0], lutval[1], lutval[2], lutval[3], op->data.nbytes);
Michael Walled3967f32019-12-18 00:09:58 +0100535
536 /* lock LUT */
537 fspi_writel(f, FSPI_LUTKEY_VALUE, f->iobase + FSPI_LUTKEY);
538 fspi_writel(f, FSPI_LCKER_LOCK, f->iobase + FSPI_LCKCR);
539}
540
Alper Nebi Yasak5de2f332020-10-05 09:57:29 +0300541#if CONFIG_IS_ENABLED(CLK)
Michael Walled3967f32019-12-18 00:09:58 +0100542static int nxp_fspi_clk_prep_enable(struct nxp_fspi *f)
543{
544 int ret;
545
546 ret = clk_enable(&f->clk_en);
547 if (ret)
548 return ret;
549
550 ret = clk_enable(&f->clk);
551 if (ret) {
552 clk_disable(&f->clk_en);
553 return ret;
554 }
555
556 return 0;
557}
558
559static void nxp_fspi_clk_disable_unprep(struct nxp_fspi *f)
560{
561 clk_disable(&f->clk);
562 clk_disable(&f->clk_en);
563}
564#endif
565
566/*
567 * In FlexSPI controller, flash access is based on value of FSPI_FLSHXXCR0
568 * register and start base address of the slave device.
569 *
570 * (Higher address)
571 * -------- <-- FLSHB2CR0
572 * | B2 |
573 * | |
574 * B2 start address --> -------- <-- FLSHB1CR0
575 * | B1 |
576 * | |
577 * B1 start address --> -------- <-- FLSHA2CR0
578 * | A2 |
579 * | |
580 * A2 start address --> -------- <-- FLSHA1CR0
581 * | A1 |
582 * | |
583 * A1 start address --> -------- (Lower address)
584 *
585 *
586 * Start base address defines the starting address range for given CS and
587 * FSPI_FLSHXXCR0 defines the size of the slave device connected at given CS.
588 *
589 * But, different targets are having different combinations of number of CS,
590 * some targets only have single CS or two CS covering controller's full
591 * memory mapped space area.
592 * Thus, implementation is being done as independent of the size and number
593 * of the connected slave device.
594 * Assign controller memory mapped space size as the size to the connected
595 * slave device.
596 * Mark FLSHxxCR0 as zero initially and then assign value only to the selected
597 * chip-select Flash configuration register.
598 *
599 * For e.g. to access CS2 (B1), FLSHB1CR0 register would be equal to the
600 * memory mapped size of the controller.
601 * Value for rest of the CS FLSHxxCR0 register would be zero.
602 *
603 */
604static void nxp_fspi_select_mem(struct nxp_fspi *f, int chip_select)
605{
606 u64 size_kb;
607
608 /* Reset FLSHxxCR0 registers */
609 fspi_writel(f, 0, f->iobase + FSPI_FLSHA1CR0);
610 fspi_writel(f, 0, f->iobase + FSPI_FLSHA2CR0);
611 fspi_writel(f, 0, f->iobase + FSPI_FLSHB1CR0);
612 fspi_writel(f, 0, f->iobase + FSPI_FLSHB2CR0);
613
614 /* Assign controller memory mapped space as size, KBytes, of flash. */
615 size_kb = FSPI_FLSHXCR0_SZ(f->memmap_phy_size);
616
617 fspi_writel(f, size_kb, f->iobase + FSPI_FLSHA1CR0 +
618 4 * chip_select);
619
620 dev_dbg(f->dev, "Slave device [CS:%x] selected\n", chip_select);
621}
622
623static void nxp_fspi_read_ahb(struct nxp_fspi *f, const struct spi_mem_op *op)
624{
625 u32 len = op->data.nbytes;
626
627 /* Read out the data directly from the AHB buffer. */
628 memcpy_fromio(op->data.buf.in, (f->ahb_addr + op->addr.val), len);
629}
630
631static void nxp_fspi_fill_txfifo(struct nxp_fspi *f,
632 const struct spi_mem_op *op)
633{
634 void __iomem *base = f->iobase;
635 int i, ret;
636 u8 *buf = (u8 *)op->data.buf.out;
637
638 /* clear the TX FIFO. */
639 fspi_writel(f, FSPI_IPTXFCR_CLR, base + FSPI_IPTXFCR);
640
641 /*
642 * Default value of water mark level is 8 bytes, hence in single
643 * write request controller can write max 8 bytes of data.
644 */
645
646 for (i = 0; i < ALIGN_DOWN(op->data.nbytes, 8); i += 8) {
647 /* Wait for TXFIFO empty */
648 ret = fspi_readl_poll_tout(f, f->iobase + FSPI_INTR,
649 FSPI_INTR_IPTXWE, 0,
650 POLL_TOUT, true);
651 WARN_ON(ret);
652
653 fspi_writel(f, *(u32 *)(buf + i), base + FSPI_TFDR);
654 fspi_writel(f, *(u32 *)(buf + i + 4), base + FSPI_TFDR + 4);
655 fspi_writel(f, FSPI_INTR_IPTXWE, base + FSPI_INTR);
656 }
657
658 if (i < op->data.nbytes) {
659 u32 data = 0;
660 int j;
661 /* Wait for TXFIFO empty */
662 ret = fspi_readl_poll_tout(f, f->iobase + FSPI_INTR,
663 FSPI_INTR_IPTXWE, 0,
664 POLL_TOUT, true);
665 WARN_ON(ret);
666
667 for (j = 0; j < ALIGN(op->data.nbytes - i, 4); j += 4) {
668 memcpy(&data, buf + i + j, 4);
669 fspi_writel(f, data, base + FSPI_TFDR + j);
670 }
671 fspi_writel(f, FSPI_INTR_IPTXWE, base + FSPI_INTR);
672 }
673}
674
675static void nxp_fspi_read_rxfifo(struct nxp_fspi *f,
676 const struct spi_mem_op *op)
677{
678 void __iomem *base = f->iobase;
679 int i, ret;
680 int len = op->data.nbytes;
681 u8 *buf = (u8 *)op->data.buf.in;
682
683 /*
684 * Default value of water mark level is 8 bytes, hence in single
685 * read request controller can read max 8 bytes of data.
686 */
687 for (i = 0; i < ALIGN_DOWN(len, 8); i += 8) {
688 /* Wait for RXFIFO available */
689 ret = fspi_readl_poll_tout(f, f->iobase + FSPI_INTR,
690 FSPI_INTR_IPRXWA, 0,
691 POLL_TOUT, true);
692 WARN_ON(ret);
693
694 *(u32 *)(buf + i) = fspi_readl(f, base + FSPI_RFDR);
695 *(u32 *)(buf + i + 4) = fspi_readl(f, base + FSPI_RFDR + 4);
696 /* move the FIFO pointer */
697 fspi_writel(f, FSPI_INTR_IPRXWA, base + FSPI_INTR);
698 }
699
700 if (i < len) {
701 u32 tmp;
702 int size, j;
703
704 buf = op->data.buf.in + i;
705 /* Wait for RXFIFO available */
706 ret = fspi_readl_poll_tout(f, f->iobase + FSPI_INTR,
707 FSPI_INTR_IPRXWA, 0,
708 POLL_TOUT, true);
709 WARN_ON(ret);
710
711 len = op->data.nbytes - i;
712 for (j = 0; j < op->data.nbytes - i; j += 4) {
713 tmp = fspi_readl(f, base + FSPI_RFDR + j);
714 size = min(len, 4);
715 memcpy(buf + j, &tmp, size);
716 len -= size;
717 }
718 }
719
720 /* invalid the RXFIFO */
721 fspi_writel(f, FSPI_IPRXFCR_CLR, base + FSPI_IPRXFCR);
722 /* move the FIFO pointer */
723 fspi_writel(f, FSPI_INTR_IPRXWA, base + FSPI_INTR);
724}
725
726static int nxp_fspi_do_op(struct nxp_fspi *f, const struct spi_mem_op *op)
727{
728 void __iomem *base = f->iobase;
729 int seqnum = 0;
730 int err = 0;
Jonathan Currier1e50ca82025-05-07 03:36:20 -0500731 u32 reg, seqid_lut;
Michael Walled3967f32019-12-18 00:09:58 +0100732
733 reg = fspi_readl(f, base + FSPI_IPRXFCR);
734 /* invalid RXFIFO first */
735 reg &= ~FSPI_IPRXFCR_DMA_EN;
736 reg = reg | FSPI_IPRXFCR_CLR;
737 fspi_writel(f, reg, base + FSPI_IPRXFCR);
738
739 fspi_writel(f, op->addr.val, base + FSPI_IPCR0);
740 /*
741 * Always start the sequence at the same index since we update
742 * the LUT at each exec_op() call. And also specify the DATA
743 * length, since it's has not been specified in the LUT.
744 */
Jonathan Currier1e50ca82025-05-07 03:36:20 -0500745 seqid_lut = f->devtype_data->lut_num - 1;
Michael Walled3967f32019-12-18 00:09:58 +0100746 fspi_writel(f, op->data.nbytes |
Jonathan Currier1e50ca82025-05-07 03:36:20 -0500747 (seqid_lut << FSPI_IPCR1_SEQID_SHIFT) |
Michael Walled3967f32019-12-18 00:09:58 +0100748 (seqnum << FSPI_IPCR1_SEQNUM_SHIFT),
749 base + FSPI_IPCR1);
750
751 /* Trigger the LUT now. */
752 fspi_writel(f, FSPI_IPCMD_TRG, base + FSPI_IPCMD);
753
754 /* Wait for the completion. */
755 err = fspi_readl_poll_tout(f, f->iobase + FSPI_STS0,
756 FSPI_STS0_ARB_IDLE, 1, 1000 * 1000, true);
757
758 /* Invoke IP data read, if request is of data read. */
759 if (!err && op->data.nbytes && op->data.dir == SPI_MEM_DATA_IN)
760 nxp_fspi_read_rxfifo(f, op);
761
762 return err;
763}
764
765static int nxp_fspi_exec_op(struct spi_slave *slave,
766 const struct spi_mem_op *op)
767{
768 struct nxp_fspi *f;
769 struct udevice *bus;
770 int err = 0;
771
772 bus = slave->dev->parent;
773 f = dev_get_priv(bus);
774
775 /* Wait for controller being ready. */
776 err = fspi_readl_poll_tout(f, f->iobase + FSPI_STS0,
777 FSPI_STS0_ARB_IDLE, 1, POLL_TOUT, true);
778 WARN_ON(err);
779
780 nxp_fspi_prepare_lut(f, op);
781 /*
Kuldeep Singh66a813e2021-08-03 14:32:57 +0530782 * If we have large chunks of data, we read them through the AHB bus by
783 * accessing the mapped memory. In all other cases we use IP commands
784 * to access the flash. Read via AHB bus may be corrupted due to
785 * existence of an errata and therefore discard AHB read in such cases.
Michael Walled3967f32019-12-18 00:09:58 +0100786 */
787 if (op->data.nbytes > (f->devtype_data->rxfifo - 4) &&
Kuldeep Singh66a813e2021-08-03 14:32:57 +0530788 op->data.dir == SPI_MEM_DATA_IN &&
789 !needs_ip_only(f)) {
Michael Walled3967f32019-12-18 00:09:58 +0100790 nxp_fspi_read_ahb(f, op);
791 } else {
792 if (op->data.nbytes && op->data.dir == SPI_MEM_DATA_OUT)
793 nxp_fspi_fill_txfifo(f, op);
794
795 err = nxp_fspi_do_op(f, op);
796 }
797
798 /* Invalidate the data in the AHB buffer. */
799 nxp_fspi_invalid(f);
800
801 return err;
802}
803
804static int nxp_fspi_adjust_op_size(struct spi_slave *slave,
805 struct spi_mem_op *op)
806{
807 struct nxp_fspi *f;
808 struct udevice *bus;
809
810 bus = slave->dev->parent;
811 f = dev_get_priv(bus);
812
813 if (op->data.dir == SPI_MEM_DATA_OUT) {
814 if (op->data.nbytes > f->devtype_data->txfifo)
815 op->data.nbytes = f->devtype_data->txfifo;
816 } else {
817 if (op->data.nbytes > f->devtype_data->ahb_buf_size)
818 op->data.nbytes = f->devtype_data->ahb_buf_size;
819 else if (op->data.nbytes > (f->devtype_data->rxfifo - 4))
820 op->data.nbytes = ALIGN_DOWN(op->data.nbytes, 8);
821 }
822
Kuldeep Singh66a813e2021-08-03 14:32:57 +0530823 /* Limit data bytes to RX FIFO in case of IP read only */
824 if (needs_ip_only(f) &&
825 op->data.dir == SPI_MEM_DATA_IN &&
826 op->data.nbytes > f->devtype_data->rxfifo)
827 op->data.nbytes = f->devtype_data->rxfifo;
828
Michael Walled3967f32019-12-18 00:09:58 +0100829 return 0;
830}
831
Kuldeep Singh19e38b22021-08-03 14:32:58 +0530832#ifdef CONFIG_FSL_LAYERSCAPE
833static void erratum_err050568(struct nxp_fspi *f)
834{
835 struct sys_info sysinfo;
836 u32 svr = 0, freq = 0;
837
838 /* Check for LS1028A variants */
839 svr = SVR_SOC_VER(get_svr());
840 if (svr != SVR_LS1017A ||
841 svr != SVR_LS1018A ||
842 svr != SVR_LS1027A ||
843 svr != SVR_LS1028A) {
844 dev_dbg(f->dev, "Errata applicable only for LS1028A variants\n");
845 return;
846 }
847
848 /* Read PLL frequency */
849 get_sys_info(&sysinfo);
850 freq = sysinfo.freq_systembus / 1000000; /* Convert to MHz */
851 dev_dbg(f->dev, "svr: %08x, Frequency: %dMhz\n", svr, freq);
852
853 /* Use IP bus only if PLL is 300MHz */
854 if (freq == 300)
855 f->devtype_data->quirks |= FSPI_QUIRK_USE_IP_ONLY;
856}
857#endif
858
Michael Walled3967f32019-12-18 00:09:58 +0100859static int nxp_fspi_default_setup(struct nxp_fspi *f)
860{
861 void __iomem *base = f->iobase;
862 int ret, i;
Jonathan Currier1e50ca82025-05-07 03:36:20 -0500863 u32 reg, seqid_lut;
Michael Walled3967f32019-12-18 00:09:58 +0100864
Alper Nebi Yasak5de2f332020-10-05 09:57:29 +0300865#if CONFIG_IS_ENABLED(CLK)
Michael Walled3967f32019-12-18 00:09:58 +0100866 /* the default frequency, we will change it later if necessary. */
867 ret = clk_set_rate(&f->clk, 20000000);
Adam Fordc9ad0482021-01-18 15:32:49 -0600868 if (ret < 0)
Michael Walled3967f32019-12-18 00:09:58 +0100869 return ret;
870
871 ret = nxp_fspi_clk_prep_enable(f);
872 if (ret)
873 return ret;
874#endif
875
Kuldeep Singh19e38b22021-08-03 14:32:58 +0530876#ifdef CONFIG_FSL_LAYERSCAPE
877 /*
878 * ERR050568: Flash access by FlexSPI AHB command may not work with
879 * platform frequency equal to 300 MHz on LS1028A.
880 * LS1028A reuses LX2160A compatible entry. Make errata applicable for
881 * Layerscape LS1028A platform family.
882 */
883 if (device_is_compatible(f->dev, "nxp,lx2160a-fspi"))
884 erratum_err050568(f);
885#endif
886
Michael Walled3967f32019-12-18 00:09:58 +0100887 /* Reset the module */
888 /* w1c register, wait unit clear */
889 ret = fspi_readl_poll_tout(f, f->iobase + FSPI_MCR0,
890 FSPI_MCR0_SWRST, 0, POLL_TOUT, false);
891 WARN_ON(ret);
892
893 /* Disable the module */
894 fspi_writel(f, FSPI_MCR0_MDIS, base + FSPI_MCR0);
895
896 /* Reset the DLL register to default value */
897 fspi_writel(f, FSPI_DLLACR_OVRDEN, base + FSPI_DLLACR);
898 fspi_writel(f, FSPI_DLLBCR_OVRDEN, base + FSPI_DLLBCR);
899
900 /* enable module */
901 fspi_writel(f, FSPI_MCR0_AHB_TIMEOUT(0xFF) | FSPI_MCR0_IP_TIMEOUT(0xFF),
902 base + FSPI_MCR0);
903
904 /*
905 * Disable same device enable bit and configure all slave devices
906 * independently.
907 */
908 reg = fspi_readl(f, f->iobase + FSPI_MCR2);
909 reg = reg & ~(FSPI_MCR2_SAMEDEVICEEN);
910 fspi_writel(f, reg, base + FSPI_MCR2);
911
912 /* AHB configuration for access buffer 0~7. */
913 for (i = 0; i < 7; i++)
914 fspi_writel(f, 0, base + FSPI_AHBRX_BUF0CR0 + 4 * i);
915
916 /*
917 * Set ADATSZ with the maximum AHB buffer size to improve the read
918 * performance.
919 */
920 fspi_writel(f, (f->devtype_data->ahb_buf_size / 8 |
921 FSPI_AHBRXBUF0CR7_PREF), base + FSPI_AHBRX_BUF7CR0);
922
923 /* prefetch and no start address alignment limitation */
924 fspi_writel(f, FSPI_AHBCR_PREF_EN | FSPI_AHBCR_RDADDROPT,
925 base + FSPI_AHBCR);
926
Han Xud2744882023-09-13 16:15:35 -0500927 /* Reset the flashx control1 registers */
928 reg = FSPI_FLSHXCR1_TCSH(0x3) | FSPI_FLSHXCR1_TCSS(0x3);
929 fspi_writel(f, reg, base + FSPI_FLSHA1CR1);
930 fspi_writel(f, reg, base + FSPI_FLSHA2CR1);
931 fspi_writel(f, reg, base + FSPI_FLSHB1CR1);
932 fspi_writel(f, reg, base + FSPI_FLSHB2CR1);
933
Jonathan Currier1e50ca82025-05-07 03:36:20 -0500934 /*
935 * The driver only uses one single LUT entry, that is updated on
936 * each call of exec_op(). Index 0 is preset at boot with a basic
937 * read operation, so let's use the last entry.
938 */
939 seqid_lut = f->devtype_data->lut_num - 1;
Michael Walled3967f32019-12-18 00:09:58 +0100940 /* AHB Read - Set lut sequence ID for all CS. */
Jonathan Currier1e50ca82025-05-07 03:36:20 -0500941 fspi_writel(f, seqid_lut, base + FSPI_FLSHA1CR2);
942 fspi_writel(f, seqid_lut, base + FSPI_FLSHA2CR2);
943 fspi_writel(f, seqid_lut, base + FSPI_FLSHB1CR2);
944 fspi_writel(f, seqid_lut, base + FSPI_FLSHB2CR2);
Michael Walled3967f32019-12-18 00:09:58 +0100945
946 return 0;
947}
948
949static int nxp_fspi_probe(struct udevice *bus)
950{
951 struct nxp_fspi *f = dev_get_priv(bus);
952
953 f->devtype_data =
954 (struct nxp_fspi_devtype_data *)dev_get_driver_data(bus);
955 nxp_fspi_default_setup(f);
956
957 return 0;
958}
959
960static int nxp_fspi_claim_bus(struct udevice *dev)
961{
962 struct nxp_fspi *f;
963 struct udevice *bus;
Simon Glassb75b15b2020-12-03 16:55:23 -0700964 struct dm_spi_slave_plat *slave_plat = dev_get_parent_plat(dev);
Michael Walled3967f32019-12-18 00:09:58 +0100965
966 bus = dev->parent;
967 f = dev_get_priv(bus);
968
Venkatesh Yadav Abbarapu91b9e372024-09-26 10:25:05 +0530969 nxp_fspi_select_mem(f, slave_plat->cs[0]);
Michael Walled3967f32019-12-18 00:09:58 +0100970
971 return 0;
972}
973
974static int nxp_fspi_set_speed(struct udevice *bus, uint speed)
975{
Alper Nebi Yasak5de2f332020-10-05 09:57:29 +0300976#if CONFIG_IS_ENABLED(CLK)
Michael Walled3967f32019-12-18 00:09:58 +0100977 struct nxp_fspi *f = dev_get_priv(bus);
978 int ret;
979
980 nxp_fspi_clk_disable_unprep(f);
981
982 ret = clk_set_rate(&f->clk, speed);
Adam Fordc9ad0482021-01-18 15:32:49 -0600983 if (ret < 0)
Michael Walled3967f32019-12-18 00:09:58 +0100984 return ret;
985
986 ret = nxp_fspi_clk_prep_enable(f);
987 if (ret)
988 return ret;
989#endif
990 return 0;
991}
992
993static int nxp_fspi_set_mode(struct udevice *bus, uint mode)
994{
995 /* Nothing to do */
996 return 0;
997}
998
Simon Glassaad29ae2020-12-03 16:55:21 -0700999static int nxp_fspi_of_to_plat(struct udevice *bus)
Michael Walled3967f32019-12-18 00:09:58 +01001000{
1001 struct nxp_fspi *f = dev_get_priv(bus);
Alper Nebi Yasak5de2f332020-10-05 09:57:29 +03001002#if CONFIG_IS_ENABLED(CLK)
Michael Walled3967f32019-12-18 00:09:58 +01001003 int ret;
1004#endif
1005
1006 fdt_addr_t iobase;
1007 fdt_addr_t iobase_size;
1008 fdt_addr_t ahb_addr;
1009 fdt_addr_t ahb_size;
1010
1011 f->dev = bus;
1012
1013 iobase = devfdt_get_addr_size_name(bus, "fspi_base", &iobase_size);
1014 if (iobase == FDT_ADDR_T_NONE) {
1015 dev_err(bus, "fspi_base regs missing\n");
1016 return -ENODEV;
1017 }
1018 f->iobase = map_physmem(iobase, iobase_size, MAP_NOCACHE);
1019
1020 ahb_addr = devfdt_get_addr_size_name(bus, "fspi_mmap", &ahb_size);
1021 if (ahb_addr == FDT_ADDR_T_NONE) {
1022 dev_err(bus, "fspi_mmap regs missing\n");
1023 return -ENODEV;
1024 }
1025 f->ahb_addr = map_physmem(ahb_addr, ahb_size, MAP_NOCACHE);
1026 f->memmap_phy_size = ahb_size;
1027
Alper Nebi Yasak5de2f332020-10-05 09:57:29 +03001028#if CONFIG_IS_ENABLED(CLK)
Michael Walled3967f32019-12-18 00:09:58 +01001029 ret = clk_get_by_name(bus, "fspi_en", &f->clk_en);
1030 if (ret) {
1031 dev_err(bus, "failed to get fspi_en clock\n");
1032 return ret;
1033 }
1034
1035 ret = clk_get_by_name(bus, "fspi", &f->clk);
1036 if (ret) {
1037 dev_err(bus, "failed to get fspi clock\n");
1038 return ret;
1039 }
1040#endif
1041
1042 dev_dbg(bus, "iobase=<0x%llx>, ahb_addr=<0x%llx>\n", iobase, ahb_addr);
1043
1044 return 0;
1045}
1046
1047static const struct spi_controller_mem_ops nxp_fspi_mem_ops = {
1048 .adjust_op_size = nxp_fspi_adjust_op_size,
1049 .supports_op = nxp_fspi_supports_op,
1050 .exec_op = nxp_fspi_exec_op,
1051};
1052
1053static const struct dm_spi_ops nxp_fspi_ops = {
1054 .claim_bus = nxp_fspi_claim_bus,
1055 .set_speed = nxp_fspi_set_speed,
1056 .set_mode = nxp_fspi_set_mode,
1057 .mem_ops = &nxp_fspi_mem_ops,
1058};
1059
1060static const struct udevice_id nxp_fspi_ids[] = {
1061 { .compatible = "nxp,lx2160a-fspi", .data = (ulong)&lx2160a_data, },
Adam Fordcf559bf2021-01-18 15:32:50 -06001062 { .compatible = "nxp,imx8mm-fspi", .data = (ulong)&imx8mm_data, },
Marek Vasut2e4b63b2022-03-09 04:18:57 +01001063 { .compatible = "nxp,imx8mp-fspi", .data = (ulong)&imx8mm_data, },
Michael Walled3967f32019-12-18 00:09:58 +01001064 { }
1065};
1066
1067U_BOOT_DRIVER(nxp_fspi) = {
1068 .name = "nxp_fspi",
1069 .id = UCLASS_SPI,
1070 .of_match = nxp_fspi_ids,
1071 .ops = &nxp_fspi_ops,
Simon Glassaad29ae2020-12-03 16:55:21 -07001072 .of_to_plat = nxp_fspi_of_to_plat,
Simon Glass8a2b47f2020-12-03 16:55:17 -07001073 .priv_auto = sizeof(struct nxp_fspi),
Michael Walled3967f32019-12-18 00:09:58 +01001074 .probe = nxp_fspi_probe,
1075};