]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - drivers/spi/spi-nxp-fspi.c
spi: spi-nxp-fspi: Add support for IP read only
[mirror_ubuntu-jammy-kernel.git] / drivers / spi / spi-nxp-fspi.c
CommitLineData
a5356aef
YNG
1// SPDX-License-Identifier: GPL-2.0+
2
3/*
4 * NXP FlexSPI(FSPI) controller driver.
5 *
55ab8487 6 * Copyright 2019-2020 NXP
7 * Copyright 2020 Puresoftware Ltd.
a5356aef
YNG
8 *
9 * FlexSPI is a flexsible SPI host controller which supports two SPI
10 * channels and up to 4 external devices. Each channel supports
11 * Single/Dual/Quad/Octal mode data transfer (1/2/4/8 bidirectional
12 * data lines).
13 *
14 * FlexSPI controller is driven by the LUT(Look-up Table) registers
15 * LUT registers are a look-up-table for sequences of instructions.
16 * A valid sequence consists of four LUT registers.
17 * Maximum 32 LUT sequences can be programmed simultaneously.
18 *
19 * LUTs are being created at run-time based on the commands passed
20 * from the spi-mem framework, thus using single LUT index.
21 *
22 * Software triggered Flash read/write access by IP Bus.
23 *
24 * Memory mapped read access by AHB Bus.
25 *
26 * Based on SPI MEM interface and spi-fsl-qspi.c driver.
27 *
28 * Author:
29 * Yogesh Narayan Gaur <yogeshnarayan.gaur@nxp.com>
ce6f0697 30 * Boris Brezillon <bbrezillon@kernel.org>
a5356aef
YNG
31 * Frieder Schrempf <frieder.schrempf@kontron.de>
32 */
33
55ab8487 34#include <linux/acpi.h>
a5356aef
YNG
35#include <linux/bitops.h>
36#include <linux/clk.h>
37#include <linux/completion.h>
38#include <linux/delay.h>
39#include <linux/err.h>
40#include <linux/errno.h>
41#include <linux/interrupt.h>
42#include <linux/io.h>
43#include <linux/iopoll.h>
44#include <linux/jiffies.h>
45#include <linux/kernel.h>
46#include <linux/module.h>
47#include <linux/mutex.h>
48#include <linux/of.h>
49#include <linux/of_device.h>
50#include <linux/platform_device.h>
51#include <linux/pm_qos.h>
52#include <linux/sizes.h>
53
54#include <linux/spi/spi.h>
55#include <linux/spi/spi-mem.h>
56
57/*
58 * The driver only uses one single LUT entry, that is updated on
59 * each call of exec_op(). Index 0 is preset at boot with a basic
60 * read operation, so let's use the last entry (31).
61 */
62#define SEQID_LUT 31
63
64/* Registers used by the driver */
65#define FSPI_MCR0 0x00
66#define FSPI_MCR0_AHB_TIMEOUT(x) ((x) << 24)
67#define FSPI_MCR0_IP_TIMEOUT(x) ((x) << 16)
68#define FSPI_MCR0_LEARN_EN BIT(15)
69#define FSPI_MCR0_SCRFRUN_EN BIT(14)
70#define FSPI_MCR0_OCTCOMB_EN BIT(13)
71#define FSPI_MCR0_DOZE_EN BIT(12)
72#define FSPI_MCR0_HSEN BIT(11)
73#define FSPI_MCR0_SERCLKDIV BIT(8)
74#define FSPI_MCR0_ATDF_EN BIT(7)
75#define FSPI_MCR0_ARDF_EN BIT(6)
76#define FSPI_MCR0_RXCLKSRC(x) ((x) << 4)
77#define FSPI_MCR0_END_CFG(x) ((x) << 2)
78#define FSPI_MCR0_MDIS BIT(1)
79#define FSPI_MCR0_SWRST BIT(0)
80
81#define FSPI_MCR1 0x04
82#define FSPI_MCR1_SEQ_TIMEOUT(x) ((x) << 16)
83#define FSPI_MCR1_AHB_TIMEOUT(x) (x)
84
85#define FSPI_MCR2 0x08
86#define FSPI_MCR2_IDLE_WAIT(x) ((x) << 24)
87#define FSPI_MCR2_SAMEDEVICEEN BIT(15)
88#define FSPI_MCR2_CLRLRPHS BIT(14)
89#define FSPI_MCR2_ABRDATSZ BIT(8)
90#define FSPI_MCR2_ABRLEARN BIT(7)
91#define FSPI_MCR2_ABR_READ BIT(6)
92#define FSPI_MCR2_ABRWRITE BIT(5)
93#define FSPI_MCR2_ABRDUMMY BIT(4)
94#define FSPI_MCR2_ABR_MODE BIT(3)
95#define FSPI_MCR2_ABRCADDR BIT(2)
96#define FSPI_MCR2_ABRRADDR BIT(1)
97#define FSPI_MCR2_ABR_CMD BIT(0)
98
99#define FSPI_AHBCR 0x0c
100#define FSPI_AHBCR_RDADDROPT BIT(6)
101#define FSPI_AHBCR_PREF_EN BIT(5)
102#define FSPI_AHBCR_BUFF_EN BIT(4)
103#define FSPI_AHBCR_CACH_EN BIT(3)
104#define FSPI_AHBCR_CLRTXBUF BIT(2)
105#define FSPI_AHBCR_CLRRXBUF BIT(1)
106#define FSPI_AHBCR_PAR_EN BIT(0)
107
108#define FSPI_INTEN 0x10
109#define FSPI_INTEN_SCLKSBWR BIT(9)
110#define FSPI_INTEN_SCLKSBRD BIT(8)
111#define FSPI_INTEN_DATALRNFL BIT(7)
112#define FSPI_INTEN_IPTXWE BIT(6)
113#define FSPI_INTEN_IPRXWA BIT(5)
114#define FSPI_INTEN_AHBCMDERR BIT(4)
115#define FSPI_INTEN_IPCMDERR BIT(3)
116#define FSPI_INTEN_AHBCMDGE BIT(2)
117#define FSPI_INTEN_IPCMDGE BIT(1)
118#define FSPI_INTEN_IPCMDDONE BIT(0)
119
120#define FSPI_INTR 0x14
121#define FSPI_INTR_SCLKSBWR BIT(9)
122#define FSPI_INTR_SCLKSBRD BIT(8)
123#define FSPI_INTR_DATALRNFL BIT(7)
124#define FSPI_INTR_IPTXWE BIT(6)
125#define FSPI_INTR_IPRXWA BIT(5)
126#define FSPI_INTR_AHBCMDERR BIT(4)
127#define FSPI_INTR_IPCMDERR BIT(3)
128#define FSPI_INTR_AHBCMDGE BIT(2)
129#define FSPI_INTR_IPCMDGE BIT(1)
130#define FSPI_INTR_IPCMDDONE BIT(0)
131
132#define FSPI_LUTKEY 0x18
133#define FSPI_LUTKEY_VALUE 0x5AF05AF0
134
135#define FSPI_LCKCR 0x1C
136
137#define FSPI_LCKER_LOCK 0x1
138#define FSPI_LCKER_UNLOCK 0x2
139
140#define FSPI_BUFXCR_INVALID_MSTRID 0xE
141#define FSPI_AHBRX_BUF0CR0 0x20
142#define FSPI_AHBRX_BUF1CR0 0x24
143#define FSPI_AHBRX_BUF2CR0 0x28
144#define FSPI_AHBRX_BUF3CR0 0x2C
145#define FSPI_AHBRX_BUF4CR0 0x30
146#define FSPI_AHBRX_BUF5CR0 0x34
147#define FSPI_AHBRX_BUF6CR0 0x38
148#define FSPI_AHBRX_BUF7CR0 0x3C
149#define FSPI_AHBRXBUF0CR7_PREF BIT(31)
150
151#define FSPI_AHBRX_BUF0CR1 0x40
152#define FSPI_AHBRX_BUF1CR1 0x44
153#define FSPI_AHBRX_BUF2CR1 0x48
154#define FSPI_AHBRX_BUF3CR1 0x4C
155#define FSPI_AHBRX_BUF4CR1 0x50
156#define FSPI_AHBRX_BUF5CR1 0x54
157#define FSPI_AHBRX_BUF6CR1 0x58
158#define FSPI_AHBRX_BUF7CR1 0x5C
159
160#define FSPI_FLSHA1CR0 0x60
161#define FSPI_FLSHA2CR0 0x64
162#define FSPI_FLSHB1CR0 0x68
163#define FSPI_FLSHB2CR0 0x6C
164#define FSPI_FLSHXCR0_SZ_KB 10
165#define FSPI_FLSHXCR0_SZ(x) ((x) >> FSPI_FLSHXCR0_SZ_KB)
166
167#define FSPI_FLSHA1CR1 0x70
168#define FSPI_FLSHA2CR1 0x74
169#define FSPI_FLSHB1CR1 0x78
170#define FSPI_FLSHB2CR1 0x7C
171#define FSPI_FLSHXCR1_CSINTR(x) ((x) << 16)
172#define FSPI_FLSHXCR1_CAS(x) ((x) << 11)
173#define FSPI_FLSHXCR1_WA BIT(10)
174#define FSPI_FLSHXCR1_TCSH(x) ((x) << 5)
175#define FSPI_FLSHXCR1_TCSS(x) (x)
176
177#define FSPI_FLSHA1CR2 0x80
178#define FSPI_FLSHA2CR2 0x84
179#define FSPI_FLSHB1CR2 0x88
180#define FSPI_FLSHB2CR2 0x8C
181#define FSPI_FLSHXCR2_CLRINSP BIT(24)
182#define FSPI_FLSHXCR2_AWRWAIT BIT(16)
183#define FSPI_FLSHXCR2_AWRSEQN_SHIFT 13
184#define FSPI_FLSHXCR2_AWRSEQI_SHIFT 8
185#define FSPI_FLSHXCR2_ARDSEQN_SHIFT 5
186#define FSPI_FLSHXCR2_ARDSEQI_SHIFT 0
187
188#define FSPI_IPCR0 0xA0
189
190#define FSPI_IPCR1 0xA4
191#define FSPI_IPCR1_IPAREN BIT(31)
192#define FSPI_IPCR1_SEQNUM_SHIFT 24
193#define FSPI_IPCR1_SEQID_SHIFT 16
194#define FSPI_IPCR1_IDATSZ(x) (x)
195
196#define FSPI_IPCMD 0xB0
197#define FSPI_IPCMD_TRG BIT(0)
198
199#define FSPI_DLPR 0xB4
200
201#define FSPI_IPRXFCR 0xB8
202#define FSPI_IPRXFCR_CLR BIT(0)
203#define FSPI_IPRXFCR_DMA_EN BIT(1)
204#define FSPI_IPRXFCR_WMRK(x) ((x) << 2)
205
206#define FSPI_IPTXFCR 0xBC
207#define FSPI_IPTXFCR_CLR BIT(0)
208#define FSPI_IPTXFCR_DMA_EN BIT(1)
209#define FSPI_IPTXFCR_WMRK(x) ((x) << 2)
210
211#define FSPI_DLLACR 0xC0
212#define FSPI_DLLACR_OVRDEN BIT(8)
213
214#define FSPI_DLLBCR 0xC4
215#define FSPI_DLLBCR_OVRDEN BIT(8)
216
217#define FSPI_STS0 0xE0
218#define FSPI_STS0_DLPHB(x) ((x) << 8)
219#define FSPI_STS0_DLPHA(x) ((x) << 4)
220#define FSPI_STS0_CMD_SRC(x) ((x) << 2)
221#define FSPI_STS0_ARB_IDLE BIT(1)
222#define FSPI_STS0_SEQ_IDLE BIT(0)
223
224#define FSPI_STS1 0xE4
225#define FSPI_STS1_IP_ERRCD(x) ((x) << 24)
226#define FSPI_STS1_IP_ERRID(x) ((x) << 16)
227#define FSPI_STS1_AHB_ERRCD(x) ((x) << 8)
228#define FSPI_STS1_AHB_ERRID(x) (x)
229
230#define FSPI_AHBSPNST 0xEC
231#define FSPI_AHBSPNST_DATLFT(x) ((x) << 16)
232#define FSPI_AHBSPNST_BUFID(x) ((x) << 1)
233#define FSPI_AHBSPNST_ACTIVE BIT(0)
234
235#define FSPI_IPRXFSTS 0xF0
236#define FSPI_IPRXFSTS_RDCNTR(x) ((x) << 16)
237#define FSPI_IPRXFSTS_FILL(x) (x)
238
239#define FSPI_IPTXFSTS 0xF4
240#define FSPI_IPTXFSTS_WRCNTR(x) ((x) << 16)
241#define FSPI_IPTXFSTS_FILL(x) (x)
242
243#define FSPI_RFDR 0x100
244#define FSPI_TFDR 0x180
245
246#define FSPI_LUT_BASE 0x200
247#define FSPI_LUT_OFFSET (SEQID_LUT * 4 * 4)
248#define FSPI_LUT_REG(idx) \
249 (FSPI_LUT_BASE + FSPI_LUT_OFFSET + (idx) * 4)
250
251/* register map end */
252
253/* Instruction set for the LUT register. */
254#define LUT_STOP 0x00
255#define LUT_CMD 0x01
256#define LUT_ADDR 0x02
257#define LUT_CADDR_SDR 0x03
258#define LUT_MODE 0x04
259#define LUT_MODE2 0x05
260#define LUT_MODE4 0x06
261#define LUT_MODE8 0x07
262#define LUT_NXP_WRITE 0x08
263#define LUT_NXP_READ 0x09
264#define LUT_LEARN_SDR 0x0A
265#define LUT_DATSZ_SDR 0x0B
266#define LUT_DUMMY 0x0C
267#define LUT_DUMMY_RWDS_SDR 0x0D
268#define LUT_JMP_ON_CS 0x1F
269#define LUT_CMD_DDR 0x21
270#define LUT_ADDR_DDR 0x22
271#define LUT_CADDR_DDR 0x23
272#define LUT_MODE_DDR 0x24
273#define LUT_MODE2_DDR 0x25
274#define LUT_MODE4_DDR 0x26
275#define LUT_MODE8_DDR 0x27
276#define LUT_WRITE_DDR 0x28
277#define LUT_READ_DDR 0x29
278#define LUT_LEARN_DDR 0x2A
279#define LUT_DATSZ_DDR 0x2B
280#define LUT_DUMMY_DDR 0x2C
281#define LUT_DUMMY_RWDS_DDR 0x2D
282
283/*
284 * Calculate number of required PAD bits for LUT register.
285 *
286 * The pad stands for the number of IO lines [0:7].
287 * For example, the octal read needs eight IO lines,
288 * so you should use LUT_PAD(8). This macro
289 * returns 3 i.e. use eight (2^3) IP lines for read.
290 */
291#define LUT_PAD(x) (fls(x) - 1)
292
293/*
294 * Macro for constructing the LUT entries with the following
295 * register layout:
296 *
297 * ---------------------------------------------------
298 * | INSTR1 | PAD1 | OPRND1 | INSTR0 | PAD0 | OPRND0 |
299 * ---------------------------------------------------
300 */
301#define PAD_SHIFT 8
302#define INSTR_SHIFT 10
303#define OPRND_SHIFT 16
304
305/* Macros for constructing the LUT register. */
306#define LUT_DEF(idx, ins, pad, opr) \
307 ((((ins) << INSTR_SHIFT) | ((pad) << PAD_SHIFT) | \
308 (opr)) << (((idx) % 2) * OPRND_SHIFT))
309
310#define POLL_TOUT 5000
311#define NXP_FSPI_MAX_CHIPSELECT 4
d166a735 312#define NXP_FSPI_MIN_IOMAP SZ_4M
a5356aef 313
31e92cbf
KS
314/* Access flash memory using IP bus only */
315#define FSPI_QUIRK_USE_IP_ONLY BIT(0)
316
a5356aef
YNG
317struct nxp_fspi_devtype_data {
318 unsigned int rxfifo;
319 unsigned int txfifo;
320 unsigned int ahb_buf_size;
321 unsigned int quirks;
322 bool little_endian;
323};
324
325static const struct nxp_fspi_devtype_data lx2160a_data = {
326 .rxfifo = SZ_512, /* (64 * 64 bits) */
327 .txfifo = SZ_1K, /* (128 * 64 bits) */
328 .ahb_buf_size = SZ_2K, /* (256 * 64 bits) */
329 .quirks = 0,
330 .little_endian = true, /* little-endian */
331};
332
941be8a7
HX
333static const struct nxp_fspi_devtype_data imx8mm_data = {
334 .rxfifo = SZ_512, /* (64 * 64 bits) */
335 .txfifo = SZ_1K, /* (128 * 64 bits) */
336 .ahb_buf_size = SZ_2K, /* (256 * 64 bits) */
337 .quirks = 0,
338 .little_endian = true, /* little-endian */
339};
340
341static const struct nxp_fspi_devtype_data imx8qxp_data = {
342 .rxfifo = SZ_512, /* (64 * 64 bits) */
343 .txfifo = SZ_1K, /* (128 * 64 bits) */
344 .ahb_buf_size = SZ_2K, /* (256 * 64 bits) */
345 .quirks = 0,
346 .little_endian = true, /* little-endian */
347};
348
a5356aef
YNG
349struct nxp_fspi {
350 void __iomem *iobase;
351 void __iomem *ahb_addr;
352 u32 memmap_phy;
353 u32 memmap_phy_size;
d166a735
HX
354 u32 memmap_start;
355 u32 memmap_len;
a5356aef
YNG
356 struct clk *clk, *clk_en;
357 struct device *dev;
358 struct completion c;
359 const struct nxp_fspi_devtype_data *devtype_data;
360 struct mutex lock;
361 struct pm_qos_request pm_qos_req;
362 int selected;
363};
364
31e92cbf
KS
365static inline int needs_ip_only(struct nxp_fspi *f)
366{
367 return f->devtype_data->quirks & FSPI_QUIRK_USE_IP_ONLY;
368}
369
a5356aef
YNG
370/*
371 * R/W functions for big- or little-endian registers:
372 * The FSPI controller's endianness is independent of
373 * the CPU core's endianness. So far, although the CPU
374 * core is little-endian the FSPI controller can use
375 * big-endian or little-endian.
376 */
377static void fspi_writel(struct nxp_fspi *f, u32 val, void __iomem *addr)
378{
379 if (f->devtype_data->little_endian)
380 iowrite32(val, addr);
381 else
382 iowrite32be(val, addr);
383}
384
385static u32 fspi_readl(struct nxp_fspi *f, void __iomem *addr)
386{
387 if (f->devtype_data->little_endian)
388 return ioread32(addr);
389 else
390 return ioread32be(addr);
391}
392
393static irqreturn_t nxp_fspi_irq_handler(int irq, void *dev_id)
394{
395 struct nxp_fspi *f = dev_id;
396 u32 reg;
397
398 /* clear interrupt */
399 reg = fspi_readl(f, f->iobase + FSPI_INTR);
400 fspi_writel(f, FSPI_INTR_IPCMDDONE, f->iobase + FSPI_INTR);
401
402 if (reg & FSPI_INTR_IPCMDDONE)
403 complete(&f->c);
404
405 return IRQ_HANDLED;
406}
407
408static int nxp_fspi_check_buswidth(struct nxp_fspi *f, u8 width)
409{
410 switch (width) {
411 case 1:
412 case 2:
413 case 4:
414 case 8:
415 return 0;
416 }
417
418 return -ENOTSUPP;
419}
420
421static bool nxp_fspi_supports_op(struct spi_mem *mem,
422 const struct spi_mem_op *op)
423{
424 struct nxp_fspi *f = spi_controller_get_devdata(mem->spi->master);
425 int ret;
426
427 ret = nxp_fspi_check_buswidth(f, op->cmd.buswidth);
428
429 if (op->addr.nbytes)
430 ret |= nxp_fspi_check_buswidth(f, op->addr.buswidth);
431
432 if (op->dummy.nbytes)
433 ret |= nxp_fspi_check_buswidth(f, op->dummy.buswidth);
434
435 if (op->data.nbytes)
436 ret |= nxp_fspi_check_buswidth(f, op->data.buswidth);
437
438 if (ret)
439 return false;
440
441 /*
442 * The number of address bytes should be equal to or less than 4 bytes.
443 */
444 if (op->addr.nbytes > 4)
445 return false;
446
447 /*
448 * If requested address value is greater than controller assigned
449 * memory mapped space, return error as it didn't fit in the range
450 * of assigned address space.
451 */
452 if (op->addr.val >= f->memmap_phy_size)
453 return false;
454
455 /* Max 64 dummy clock cycles supported */
456 if (op->dummy.buswidth &&
457 (op->dummy.nbytes * 8 / op->dummy.buswidth > 64))
458 return false;
459
460 /* Max data length, check controller limits and alignment */
461 if (op->data.dir == SPI_MEM_DATA_IN &&
462 (op->data.nbytes > f->devtype_data->ahb_buf_size ||
463 (op->data.nbytes > f->devtype_data->rxfifo - 4 &&
464 !IS_ALIGNED(op->data.nbytes, 8))))
465 return false;
466
467 if (op->data.dir == SPI_MEM_DATA_OUT &&
468 op->data.nbytes > f->devtype_data->txfifo)
469 return false;
470
007773e1 471 return spi_mem_default_supports_op(mem, op);
a5356aef
YNG
472}
473
474/* Instead of busy looping invoke readl_poll_timeout functionality. */
475static int fspi_readl_poll_tout(struct nxp_fspi *f, void __iomem *base,
476 u32 mask, u32 delay_us,
477 u32 timeout_us, bool c)
478{
479 u32 reg;
480
481 if (!f->devtype_data->little_endian)
482 mask = (u32)cpu_to_be32(mask);
483
484 if (c)
485 return readl_poll_timeout(base, reg, (reg & mask),
486 delay_us, timeout_us);
487 else
488 return readl_poll_timeout(base, reg, !(reg & mask),
489 delay_us, timeout_us);
490}
491
492/*
493 * If the slave device content being changed by Write/Erase, need to
494 * invalidate the AHB buffer. This can be achieved by doing the reset
495 * of controller after setting MCR0[SWRESET] bit.
496 */
497static inline void nxp_fspi_invalid(struct nxp_fspi *f)
498{
499 u32 reg;
500 int ret;
501
502 reg = fspi_readl(f, f->iobase + FSPI_MCR0);
503 fspi_writel(f, reg | FSPI_MCR0_SWRST, f->iobase + FSPI_MCR0);
504
505 /* w1c register, wait unit clear */
506 ret = fspi_readl_poll_tout(f, f->iobase + FSPI_MCR0,
507 FSPI_MCR0_SWRST, 0, POLL_TOUT, false);
508 WARN_ON(ret);
509}
510
511static void nxp_fspi_prepare_lut(struct nxp_fspi *f,
512 const struct spi_mem_op *op)
513{
514 void __iomem *base = f->iobase;
515 u32 lutval[4] = {};
516 int lutidx = 1, i;
517
518 /* cmd */
519 lutval[0] |= LUT_DEF(0, LUT_CMD, LUT_PAD(op->cmd.buswidth),
520 op->cmd.opcode);
521
522 /* addr bytes */
523 if (op->addr.nbytes) {
524 lutval[lutidx / 2] |= LUT_DEF(lutidx, LUT_ADDR,
525 LUT_PAD(op->addr.buswidth),
526 op->addr.nbytes * 8);
527 lutidx++;
528 }
529
530 /* dummy bytes, if needed */
531 if (op->dummy.nbytes) {
532 lutval[lutidx / 2] |= LUT_DEF(lutidx, LUT_DUMMY,
533 /*
534 * Due to FlexSPI controller limitation number of PAD for dummy
535 * buswidth needs to be programmed as equal to data buswidth.
536 */
537 LUT_PAD(op->data.buswidth),
538 op->dummy.nbytes * 8 /
539 op->dummy.buswidth);
540 lutidx++;
541 }
542
543 /* read/write data bytes */
544 if (op->data.nbytes) {
545 lutval[lutidx / 2] |= LUT_DEF(lutidx,
546 op->data.dir == SPI_MEM_DATA_IN ?
547 LUT_NXP_READ : LUT_NXP_WRITE,
548 LUT_PAD(op->data.buswidth),
549 0);
550 lutidx++;
551 }
552
553 /* stop condition. */
554 lutval[lutidx / 2] |= LUT_DEF(lutidx, LUT_STOP, 0, 0);
555
556 /* unlock LUT */
557 fspi_writel(f, FSPI_LUTKEY_VALUE, f->iobase + FSPI_LUTKEY);
558 fspi_writel(f, FSPI_LCKER_UNLOCK, f->iobase + FSPI_LCKCR);
559
560 /* fill LUT */
561 for (i = 0; i < ARRAY_SIZE(lutval); i++)
562 fspi_writel(f, lutval[i], base + FSPI_LUT_REG(i));
563
31e92cbf
KS
564 dev_dbg(f->dev, "CMD[%x] lutval[0:%x \t 1:%x \t 2:%x \t 3:%x], size: 0x%08x\n",
565 op->cmd.opcode, lutval[0], lutval[1], lutval[2], lutval[3], op->data.nbytes);
a5356aef
YNG
566
567 /* lock LUT */
568 fspi_writel(f, FSPI_LUTKEY_VALUE, f->iobase + FSPI_LUTKEY);
569 fspi_writel(f, FSPI_LCKER_LOCK, f->iobase + FSPI_LCKCR);
570}
571
572static int nxp_fspi_clk_prep_enable(struct nxp_fspi *f)
573{
574 int ret;
575
55ab8487 576 if (is_acpi_node(f->dev->fwnode))
577 return 0;
578
a5356aef
YNG
579 ret = clk_prepare_enable(f->clk_en);
580 if (ret)
581 return ret;
582
583 ret = clk_prepare_enable(f->clk);
584 if (ret) {
585 clk_disable_unprepare(f->clk_en);
586 return ret;
587 }
588
589 return 0;
590}
591
55ab8487 592static int nxp_fspi_clk_disable_unprep(struct nxp_fspi *f)
a5356aef 593{
55ab8487 594 if (is_acpi_node(f->dev->fwnode))
595 return 0;
596
a5356aef
YNG
597 clk_disable_unprepare(f->clk);
598 clk_disable_unprepare(f->clk_en);
55ab8487 599
600 return 0;
a5356aef
YNG
601}
602
603/*
604 * In FlexSPI controller, flash access is based on value of FSPI_FLSHXXCR0
605 * register and start base address of the slave device.
606 *
607 * (Higher address)
608 * -------- <-- FLSHB2CR0
609 * | B2 |
610 * | |
611 * B2 start address --> -------- <-- FLSHB1CR0
612 * | B1 |
613 * | |
614 * B1 start address --> -------- <-- FLSHA2CR0
615 * | A2 |
616 * | |
617 * A2 start address --> -------- <-- FLSHA1CR0
618 * | A1 |
619 * | |
620 * A1 start address --> -------- (Lower address)
621 *
622 *
623 * Start base address defines the starting address range for given CS and
624 * FSPI_FLSHXXCR0 defines the size of the slave device connected at given CS.
625 *
626 * But, different targets are having different combinations of number of CS,
627 * some targets only have single CS or two CS covering controller's full
628 * memory mapped space area.
629 * Thus, implementation is being done as independent of the size and number
630 * of the connected slave device.
631 * Assign controller memory mapped space size as the size to the connected
632 * slave device.
633 * Mark FLSHxxCR0 as zero initially and then assign value only to the selected
634 * chip-select Flash configuration register.
635 *
636 * For e.g. to access CS2 (B1), FLSHB1CR0 register would be equal to the
637 * memory mapped size of the controller.
638 * Value for rest of the CS FLSHxxCR0 register would be zero.
639 *
640 */
641static void nxp_fspi_select_mem(struct nxp_fspi *f, struct spi_device *spi)
642{
643 unsigned long rate = spi->max_speed_hz;
644 int ret;
645 uint64_t size_kb;
646
647 /*
648 * Return, if previously selected slave device is same as current
649 * requested slave device.
650 */
651 if (f->selected == spi->chip_select)
652 return;
653
654 /* Reset FLSHxxCR0 registers */
655 fspi_writel(f, 0, f->iobase + FSPI_FLSHA1CR0);
656 fspi_writel(f, 0, f->iobase + FSPI_FLSHA2CR0);
657 fspi_writel(f, 0, f->iobase + FSPI_FLSHB1CR0);
658 fspi_writel(f, 0, f->iobase + FSPI_FLSHB2CR0);
659
660 /* Assign controller memory mapped space as size, KBytes, of flash. */
661 size_kb = FSPI_FLSHXCR0_SZ(f->memmap_phy_size);
662
663 fspi_writel(f, size_kb, f->iobase + FSPI_FLSHA1CR0 +
664 4 * spi->chip_select);
665
666 dev_dbg(f->dev, "Slave device [CS:%x] selected\n", spi->chip_select);
667
668 nxp_fspi_clk_disable_unprep(f);
669
670 ret = clk_set_rate(f->clk, rate);
671 if (ret)
672 return;
673
674 ret = nxp_fspi_clk_prep_enable(f);
675 if (ret)
676 return;
677
678 f->selected = spi->chip_select;
679}
680
d166a735 681static int nxp_fspi_read_ahb(struct nxp_fspi *f, const struct spi_mem_op *op)
a5356aef 682{
d166a735 683 u32 start = op->addr.val;
a5356aef
YNG
684 u32 len = op->data.nbytes;
685
d166a735
HX
686 /* if necessary, ioremap before AHB read */
687 if ((!f->ahb_addr) || start < f->memmap_start ||
688 start + len > f->memmap_start + f->memmap_len) {
689 if (f->ahb_addr)
690 iounmap(f->ahb_addr);
691
692 f->memmap_start = start;
693 f->memmap_len = len > NXP_FSPI_MIN_IOMAP ?
694 len : NXP_FSPI_MIN_IOMAP;
695
696 f->ahb_addr = ioremap_wc(f->memmap_phy + f->memmap_start,
697 f->memmap_len);
698
699 if (!f->ahb_addr) {
700 dev_err(f->dev, "failed to alloc memory\n");
701 return -ENOMEM;
702 }
703 }
704
a5356aef 705 /* Read out the data directly from the AHB buffer. */
d166a735
HX
706 memcpy_fromio(op->data.buf.in,
707 f->ahb_addr + start - f->memmap_start, len);
708
709 return 0;
a5356aef
YNG
710}
711
712static void nxp_fspi_fill_txfifo(struct nxp_fspi *f,
713 const struct spi_mem_op *op)
714{
715 void __iomem *base = f->iobase;
716 int i, ret;
717 u8 *buf = (u8 *) op->data.buf.out;
718
719 /* clear the TX FIFO. */
720 fspi_writel(f, FSPI_IPTXFCR_CLR, base + FSPI_IPTXFCR);
721
722 /*
723 * Default value of water mark level is 8 bytes, hence in single
724 * write request controller can write max 8 bytes of data.
725 */
726
727 for (i = 0; i < ALIGN_DOWN(op->data.nbytes, 8); i += 8) {
728 /* Wait for TXFIFO empty */
729 ret = fspi_readl_poll_tout(f, f->iobase + FSPI_INTR,
730 FSPI_INTR_IPTXWE, 0,
731 POLL_TOUT, true);
732 WARN_ON(ret);
733
734 fspi_writel(f, *(u32 *) (buf + i), base + FSPI_TFDR);
735 fspi_writel(f, *(u32 *) (buf + i + 4), base + FSPI_TFDR + 4);
736 fspi_writel(f, FSPI_INTR_IPTXWE, base + FSPI_INTR);
737 }
738
739 if (i < op->data.nbytes) {
740 u32 data = 0;
741 int j;
742 /* Wait for TXFIFO empty */
743 ret = fspi_readl_poll_tout(f, f->iobase + FSPI_INTR,
744 FSPI_INTR_IPTXWE, 0,
745 POLL_TOUT, true);
746 WARN_ON(ret);
747
748 for (j = 0; j < ALIGN(op->data.nbytes - i, 4); j += 4) {
749 memcpy(&data, buf + i + j, 4);
750 fspi_writel(f, data, base + FSPI_TFDR + j);
751 }
752 fspi_writel(f, FSPI_INTR_IPTXWE, base + FSPI_INTR);
753 }
754}
755
756static void nxp_fspi_read_rxfifo(struct nxp_fspi *f,
757 const struct spi_mem_op *op)
758{
759 void __iomem *base = f->iobase;
760 int i, ret;
761 int len = op->data.nbytes;
762 u8 *buf = (u8 *) op->data.buf.in;
763
764 /*
765 * Default value of water mark level is 8 bytes, hence in single
766 * read request controller can read max 8 bytes of data.
767 */
768 for (i = 0; i < ALIGN_DOWN(len, 8); i += 8) {
769 /* Wait for RXFIFO available */
770 ret = fspi_readl_poll_tout(f, f->iobase + FSPI_INTR,
771 FSPI_INTR_IPRXWA, 0,
772 POLL_TOUT, true);
773 WARN_ON(ret);
774
775 *(u32 *)(buf + i) = fspi_readl(f, base + FSPI_RFDR);
776 *(u32 *)(buf + i + 4) = fspi_readl(f, base + FSPI_RFDR + 4);
777 /* move the FIFO pointer */
778 fspi_writel(f, FSPI_INTR_IPRXWA, base + FSPI_INTR);
779 }
780
781 if (i < len) {
782 u32 tmp;
783 int size, j;
784
785 buf = op->data.buf.in + i;
786 /* Wait for RXFIFO available */
787 ret = fspi_readl_poll_tout(f, f->iobase + FSPI_INTR,
788 FSPI_INTR_IPRXWA, 0,
789 POLL_TOUT, true);
790 WARN_ON(ret);
791
792 len = op->data.nbytes - i;
793 for (j = 0; j < op->data.nbytes - i; j += 4) {
794 tmp = fspi_readl(f, base + FSPI_RFDR + j);
795 size = min(len, 4);
796 memcpy(buf + j, &tmp, size);
797 len -= size;
798 }
799 }
800
801 /* invalid the RXFIFO */
802 fspi_writel(f, FSPI_IPRXFCR_CLR, base + FSPI_IPRXFCR);
803 /* move the FIFO pointer */
804 fspi_writel(f, FSPI_INTR_IPRXWA, base + FSPI_INTR);
805}
806
807static int nxp_fspi_do_op(struct nxp_fspi *f, const struct spi_mem_op *op)
808{
809 void __iomem *base = f->iobase;
810 int seqnum = 0;
811 int err = 0;
812 u32 reg;
813
814 reg = fspi_readl(f, base + FSPI_IPRXFCR);
815 /* invalid RXFIFO first */
816 reg &= ~FSPI_IPRXFCR_DMA_EN;
817 reg = reg | FSPI_IPRXFCR_CLR;
818 fspi_writel(f, reg, base + FSPI_IPRXFCR);
819
820 init_completion(&f->c);
821
822 fspi_writel(f, op->addr.val, base + FSPI_IPCR0);
823 /*
824 * Always start the sequence at the same index since we update
825 * the LUT at each exec_op() call. And also specify the DATA
826 * length, since it's has not been specified in the LUT.
827 */
828 fspi_writel(f, op->data.nbytes |
829 (SEQID_LUT << FSPI_IPCR1_SEQID_SHIFT) |
830 (seqnum << FSPI_IPCR1_SEQNUM_SHIFT),
831 base + FSPI_IPCR1);
832
833 /* Trigger the LUT now. */
834 fspi_writel(f, FSPI_IPCMD_TRG, base + FSPI_IPCMD);
835
836 /* Wait for the interrupt. */
837 if (!wait_for_completion_timeout(&f->c, msecs_to_jiffies(1000)))
838 err = -ETIMEDOUT;
839
840 /* Invoke IP data read, if request is of data read. */
841 if (!err && op->data.nbytes && op->data.dir == SPI_MEM_DATA_IN)
842 nxp_fspi_read_rxfifo(f, op);
843
844 return err;
845}
846
847static int nxp_fspi_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)
848{
849 struct nxp_fspi *f = spi_controller_get_devdata(mem->spi->master);
850 int err = 0;
851
852 mutex_lock(&f->lock);
853
854 /* Wait for controller being ready. */
855 err = fspi_readl_poll_tout(f, f->iobase + FSPI_STS0,
856 FSPI_STS0_ARB_IDLE, 1, POLL_TOUT, true);
857 WARN_ON(err);
858
859 nxp_fspi_select_mem(f, mem->spi);
860
861 nxp_fspi_prepare_lut(f, op);
862 /*
31e92cbf
KS
863 * If we have large chunks of data, we read them through the AHB bus by
864 * accessing the mapped memory. In all other cases we use IP commands
865 * to access the flash. Read via AHB bus may be corrupted due to
866 * existence of an errata and therefore discard AHB read in such cases.
a5356aef
YNG
867 */
868 if (op->data.nbytes > (f->devtype_data->rxfifo - 4) &&
31e92cbf
KS
869 op->data.dir == SPI_MEM_DATA_IN &&
870 !needs_ip_only(f)) {
d166a735 871 err = nxp_fspi_read_ahb(f, op);
a5356aef
YNG
872 } else {
873 if (op->data.nbytes && op->data.dir == SPI_MEM_DATA_OUT)
874 nxp_fspi_fill_txfifo(f, op);
875
876 err = nxp_fspi_do_op(f, op);
877 }
878
879 /* Invalidate the data in the AHB buffer. */
880 nxp_fspi_invalid(f);
881
882 mutex_unlock(&f->lock);
883
884 return err;
885}
886
887static int nxp_fspi_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op)
888{
889 struct nxp_fspi *f = spi_controller_get_devdata(mem->spi->master);
890
891 if (op->data.dir == SPI_MEM_DATA_OUT) {
892 if (op->data.nbytes > f->devtype_data->txfifo)
893 op->data.nbytes = f->devtype_data->txfifo;
894 } else {
895 if (op->data.nbytes > f->devtype_data->ahb_buf_size)
896 op->data.nbytes = f->devtype_data->ahb_buf_size;
897 else if (op->data.nbytes > (f->devtype_data->rxfifo - 4))
898 op->data.nbytes = ALIGN_DOWN(op->data.nbytes, 8);
899 }
900
31e92cbf
KS
901 /* Limit data bytes to RX FIFO in case of IP read only */
902 if (op->data.dir == SPI_MEM_DATA_IN &&
903 needs_ip_only(f) &&
904 op->data.nbytes > f->devtype_data->rxfifo)
905 op->data.nbytes = f->devtype_data->rxfifo;
906
a5356aef
YNG
907 return 0;
908}
909
910static int nxp_fspi_default_setup(struct nxp_fspi *f)
911{
912 void __iomem *base = f->iobase;
913 int ret, i;
914 u32 reg;
915
916 /* disable and unprepare clock to avoid glitch pass to controller */
917 nxp_fspi_clk_disable_unprep(f);
918
919 /* the default frequency, we will change it later if necessary. */
920 ret = clk_set_rate(f->clk, 20000000);
921 if (ret)
922 return ret;
923
924 ret = nxp_fspi_clk_prep_enable(f);
925 if (ret)
926 return ret;
927
928 /* Reset the module */
929 /* w1c register, wait unit clear */
930 ret = fspi_readl_poll_tout(f, f->iobase + FSPI_MCR0,
931 FSPI_MCR0_SWRST, 0, POLL_TOUT, false);
932 WARN_ON(ret);
933
934 /* Disable the module */
935 fspi_writel(f, FSPI_MCR0_MDIS, base + FSPI_MCR0);
936
937 /* Reset the DLL register to default value */
938 fspi_writel(f, FSPI_DLLACR_OVRDEN, base + FSPI_DLLACR);
939 fspi_writel(f, FSPI_DLLBCR_OVRDEN, base + FSPI_DLLBCR);
940
941 /* enable module */
b7461fa5
HX
942 fspi_writel(f, FSPI_MCR0_AHB_TIMEOUT(0xFF) |
943 FSPI_MCR0_IP_TIMEOUT(0xFF) | (u32) FSPI_MCR0_OCTCOMB_EN,
944 base + FSPI_MCR0);
a5356aef
YNG
945
946 /*
947 * Disable same device enable bit and configure all slave devices
948 * independently.
949 */
950 reg = fspi_readl(f, f->iobase + FSPI_MCR2);
951 reg = reg & ~(FSPI_MCR2_SAMEDEVICEEN);
952 fspi_writel(f, reg, base + FSPI_MCR2);
953
954 /* AHB configuration for access buffer 0~7. */
955 for (i = 0; i < 7; i++)
956 fspi_writel(f, 0, base + FSPI_AHBRX_BUF0CR0 + 4 * i);
957
958 /*
959 * Set ADATSZ with the maximum AHB buffer size to improve the read
960 * performance.
961 */
962 fspi_writel(f, (f->devtype_data->ahb_buf_size / 8 |
963 FSPI_AHBRXBUF0CR7_PREF), base + FSPI_AHBRX_BUF7CR0);
964
965 /* prefetch and no start address alignment limitation */
966 fspi_writel(f, FSPI_AHBCR_PREF_EN | FSPI_AHBCR_RDADDROPT,
967 base + FSPI_AHBCR);
968
969 /* AHB Read - Set lut sequence ID for all CS. */
970 fspi_writel(f, SEQID_LUT, base + FSPI_FLSHA1CR2);
971 fspi_writel(f, SEQID_LUT, base + FSPI_FLSHA2CR2);
972 fspi_writel(f, SEQID_LUT, base + FSPI_FLSHB1CR2);
973 fspi_writel(f, SEQID_LUT, base + FSPI_FLSHB2CR2);
974
975 f->selected = -1;
976
977 /* enable the interrupt */
978 fspi_writel(f, FSPI_INTEN_IPCMDDONE, base + FSPI_INTEN);
979
980 return 0;
981}
982
983static const char *nxp_fspi_get_name(struct spi_mem *mem)
984{
985 struct nxp_fspi *f = spi_controller_get_devdata(mem->spi->master);
986 struct device *dev = &mem->spi->dev;
987 const char *name;
988
989 // Set custom name derived from the platform_device of the controller.
990 if (of_get_available_child_count(f->dev->of_node) == 1)
991 return dev_name(f->dev);
992
993 name = devm_kasprintf(dev, GFP_KERNEL,
994 "%s-%d", dev_name(f->dev),
995 mem->spi->chip_select);
996
997 if (!name) {
998 dev_err(dev, "failed to get memory for custom flash name\n");
999 return ERR_PTR(-ENOMEM);
1000 }
1001
1002 return name;
1003}
1004
1005static const struct spi_controller_mem_ops nxp_fspi_mem_ops = {
1006 .adjust_op_size = nxp_fspi_adjust_op_size,
1007 .supports_op = nxp_fspi_supports_op,
1008 .exec_op = nxp_fspi_exec_op,
1009 .get_name = nxp_fspi_get_name,
1010};
1011
1012static int nxp_fspi_probe(struct platform_device *pdev)
1013{
1014 struct spi_controller *ctlr;
1015 struct device *dev = &pdev->dev;
1016 struct device_node *np = dev->of_node;
1017 struct resource *res;
1018 struct nxp_fspi *f;
1019 int ret;
71d80563 1020 u32 reg;
a5356aef
YNG
1021
1022 ctlr = spi_alloc_master(&pdev->dev, sizeof(*f));
1023 if (!ctlr)
1024 return -ENOMEM;
1025
b3281794
YNG
1026 ctlr->mode_bits = SPI_RX_DUAL | SPI_RX_QUAD | SPI_RX_OCTAL |
1027 SPI_TX_DUAL | SPI_TX_QUAD | SPI_TX_OCTAL;
a5356aef
YNG
1028
1029 f = spi_controller_get_devdata(ctlr);
1030 f->dev = dev;
55ab8487 1031 f->devtype_data = device_get_match_data(dev);
a5356aef
YNG
1032 if (!f->devtype_data) {
1033 ret = -ENODEV;
1034 goto err_put_ctrl;
1035 }
1036
1037 platform_set_drvdata(pdev, f);
1038
1039 /* find the resources - configuration register address space */
55ab8487 1040 if (is_acpi_node(f->dev->fwnode))
1041 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1042 else
1043 res = platform_get_resource_byname(pdev,
1044 IORESOURCE_MEM, "fspi_base");
1045
a5356aef
YNG
1046 f->iobase = devm_ioremap_resource(dev, res);
1047 if (IS_ERR(f->iobase)) {
1048 ret = PTR_ERR(f->iobase);
1049 goto err_put_ctrl;
1050 }
1051
71d80563
RW
1052 /* Clear potential interrupts */
1053 reg = fspi_readl(f, f->iobase + FSPI_INTR);
1054 if (reg)
1055 fspi_writel(f, reg, f->iobase + FSPI_INTR);
1056
1057
a5356aef 1058 /* find the resources - controller memory mapped space */
55ab8487 1059 if (is_acpi_node(f->dev->fwnode))
1060 res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
1061 else
1062 res = platform_get_resource_byname(pdev,
1063 IORESOURCE_MEM, "fspi_mmap");
1064
1a421eba
DC
1065 if (!res) {
1066 ret = -ENODEV;
a5356aef
YNG
1067 goto err_put_ctrl;
1068 }
1069
1070 /* assign memory mapped starting address and mapped size. */
1071 f->memmap_phy = res->start;
1072 f->memmap_phy_size = resource_size(res);
1073
1074 /* find the clocks */
55ab8487 1075 if (dev_of_node(&pdev->dev)) {
1076 f->clk_en = devm_clk_get(dev, "fspi_en");
1077 if (IS_ERR(f->clk_en)) {
1078 ret = PTR_ERR(f->clk_en);
1079 goto err_put_ctrl;
1080 }
a5356aef 1081
55ab8487 1082 f->clk = devm_clk_get(dev, "fspi");
1083 if (IS_ERR(f->clk)) {
1084 ret = PTR_ERR(f->clk);
1085 goto err_put_ctrl;
1086 }
a5356aef 1087
55ab8487 1088 ret = nxp_fspi_clk_prep_enable(f);
1089 if (ret) {
1090 dev_err(dev, "can not enable the clock\n");
1091 goto err_put_ctrl;
1092 }
a5356aef
YNG
1093 }
1094
1095 /* find the irq */
1096 ret = platform_get_irq(pdev, 0);
6b8ac10e 1097 if (ret < 0)
a5356aef 1098 goto err_disable_clk;
a5356aef
YNG
1099
1100 ret = devm_request_irq(dev, ret,
1101 nxp_fspi_irq_handler, 0, pdev->name, f);
1102 if (ret) {
1103 dev_err(dev, "failed to request irq: %d\n", ret);
1104 goto err_disable_clk;
1105 }
1106
1107 mutex_init(&f->lock);
1108
1109 ctlr->bus_num = -1;
1110 ctlr->num_chipselect = NXP_FSPI_MAX_CHIPSELECT;
1111 ctlr->mem_ops = &nxp_fspi_mem_ops;
1112
1113 nxp_fspi_default_setup(f);
1114
1115 ctlr->dev.of_node = np;
1116
69c23dbf 1117 ret = devm_spi_register_controller(&pdev->dev, ctlr);
a5356aef
YNG
1118 if (ret)
1119 goto err_destroy_mutex;
1120
1121 return 0;
1122
1123err_destroy_mutex:
1124 mutex_destroy(&f->lock);
1125
1126err_disable_clk:
1127 nxp_fspi_clk_disable_unprep(f);
1128
1129err_put_ctrl:
1130 spi_controller_put(ctlr);
1131
1132 dev_err(dev, "NXP FSPI probe failed\n");
1133 return ret;
1134}
1135
1136static int nxp_fspi_remove(struct platform_device *pdev)
1137{
1138 struct nxp_fspi *f = platform_get_drvdata(pdev);
1139
1140 /* disable the hardware */
1141 fspi_writel(f, FSPI_MCR0_MDIS, f->iobase + FSPI_MCR0);
1142
1143 nxp_fspi_clk_disable_unprep(f);
1144
1145 mutex_destroy(&f->lock);
1146
d166a735
HX
1147 if (f->ahb_addr)
1148 iounmap(f->ahb_addr);
1149
a5356aef
YNG
1150 return 0;
1151}
1152
1153static int nxp_fspi_suspend(struct device *dev)
1154{
1155 return 0;
1156}
1157
1158static int nxp_fspi_resume(struct device *dev)
1159{
1160 struct nxp_fspi *f = dev_get_drvdata(dev);
1161
1162 nxp_fspi_default_setup(f);
1163
1164 return 0;
1165}
1166
1167static const struct of_device_id nxp_fspi_dt_ids[] = {
1168 { .compatible = "nxp,lx2160a-fspi", .data = (void *)&lx2160a_data, },
941be8a7
HX
1169 { .compatible = "nxp,imx8mm-fspi", .data = (void *)&imx8mm_data, },
1170 { .compatible = "nxp,imx8qxp-fspi", .data = (void *)&imx8qxp_data, },
a5356aef
YNG
1171 { /* sentinel */ }
1172};
1173MODULE_DEVICE_TABLE(of, nxp_fspi_dt_ids);
1174
55ab8487 1175#ifdef CONFIG_ACPI
1176static const struct acpi_device_id nxp_fspi_acpi_ids[] = {
1177 { "NXP0009", .driver_data = (kernel_ulong_t)&lx2160a_data, },
1178 {}
1179};
1180MODULE_DEVICE_TABLE(acpi, nxp_fspi_acpi_ids);
1181#endif
1182
a5356aef
YNG
1183static const struct dev_pm_ops nxp_fspi_pm_ops = {
1184 .suspend = nxp_fspi_suspend,
1185 .resume = nxp_fspi_resume,
1186};
1187
1188static struct platform_driver nxp_fspi_driver = {
1189 .driver = {
1190 .name = "nxp-fspi",
1191 .of_match_table = nxp_fspi_dt_ids,
55ab8487 1192 .acpi_match_table = ACPI_PTR(nxp_fspi_acpi_ids),
a5356aef
YNG
1193 .pm = &nxp_fspi_pm_ops,
1194 },
1195 .probe = nxp_fspi_probe,
1196 .remove = nxp_fspi_remove,
1197};
1198module_platform_driver(nxp_fspi_driver);
1199
1200MODULE_DESCRIPTION("NXP FSPI Controller Driver");
1201MODULE_AUTHOR("NXP Semiconductor");
1202MODULE_AUTHOR("Yogesh Narayan Gaur <yogeshnarayan.gaur@nxp.com>");
ce6f0697 1203MODULE_AUTHOR("Boris Brezillon <bbrezillon@kernel.org>");
a5356aef 1204MODULE_AUTHOR("Frieder Schrempf <frieder.schrempf@kontron.de>");
ce6f0697 1205MODULE_LICENSE("GPL v2");