1 // SPDX-License-Identifier: GPL-2.0-only
3 // Driver for Cadence QSPI Controller
5 // Copyright Altera Corporation (C) 2012-2014. All rights reserved.
6 // Copyright Intel Corporation (C) 2019-2020. All rights reserved.
7 // Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com
10 #include <linux/completion.h>
11 #include <linux/delay.h>
12 #include <linux/dma-mapping.h>
13 #include <linux/dmaengine.h>
14 #include <linux/err.h>
15 #include <linux/errno.h>
16 #include <linux/firmware/xlnx-zynqmp.h>
17 #include <linux/interrupt.h>
19 #include <linux/iopoll.h>
20 #include <linux/jiffies.h>
21 #include <linux/kernel.h>
22 #include <linux/log2.h>
23 #include <linux/module.h>
25 #include <linux/platform_device.h>
26 #include <linux/pm_runtime.h>
27 #include <linux/reset.h>
28 #include <linux/sched.h>
29 #include <linux/spi/spi.h>
30 #include <linux/spi/spi-mem.h>
31 #include <linux/timer.h>
33 #define CQSPI_NAME "cadence-qspi"
34 #define CQSPI_MAX_CHIPSELECT 16
37 #define CQSPI_NEEDS_WR_DELAY BIT(0)
38 #define CQSPI_DISABLE_DAC_MODE BIT(1)
39 #define CQSPI_SUPPORT_EXTERNAL_DMA BIT(2)
40 #define CQSPI_NO_SUPPORT_WR_COMPLETION BIT(3)
41 #define CQSPI_SLOW_SRAM BIT(4)
42 #define CQSPI_NEEDS_APB_AHB_HAZARD_WAR BIT(5)
45 #define CQSPI_SUPPORTS_OCTAL BIT(0)
47 #define CQSPI_OP_WIDTH(part) ((part).nbytes ? ilog2((part).buswidth) : 0)
57 struct cqspi_flash_pdata {
58 struct cqspi_st *cqspi;
69 struct platform_device *pdev;
70 struct spi_controller *host;
72 struct clk *clks[CLK_QSPI_NUM];
76 void __iomem *ahb_base;
77 resource_size_t ahb_size;
78 struct completion transfer_complete;
80 struct dma_chan *rx_chan;
81 struct completion rx_dma_complete;
82 dma_addr_t mmap_phys_base;
85 unsigned long master_ref_clk_hz;
94 bool use_direct_mode_wr;
95 struct cqspi_flash_pdata f_pdata[CQSPI_MAX_CHIPSELECT];
102 bool is_jh7110; /* Flag for StarFive JH7110 SoC */
105 struct cqspi_driver_platdata {
108 int (*indirect_read_dma)(struct cqspi_flash_pdata *f_pdata,
109 u_char *rxbuf, loff_t from_addr, size_t n_rx);
110 u32 (*get_dma_status)(struct cqspi_st *cqspi);
111 int (*jh7110_clk_init)(struct platform_device *pdev,
112 struct cqspi_st *cqspi);
115 /* Operation timeout value */
116 #define CQSPI_TIMEOUT_MS 500
117 #define CQSPI_READ_TIMEOUT_MS 10
119 #define CQSPI_DUMMY_CLKS_PER_BYTE 8
120 #define CQSPI_DUMMY_BYTES_MAX 4
121 #define CQSPI_DUMMY_CLKS_MAX 31
123 #define CQSPI_STIG_DATA_LEN_MAX 8
126 #define CQSPI_REG_CONFIG 0x00
127 #define CQSPI_REG_CONFIG_ENABLE_MASK BIT(0)
128 #define CQSPI_REG_CONFIG_ENB_DIR_ACC_CTRL BIT(7)
129 #define CQSPI_REG_CONFIG_DECODE_MASK BIT(9)
130 #define CQSPI_REG_CONFIG_CHIPSELECT_LSB 10
131 #define CQSPI_REG_CONFIG_DMA_MASK BIT(15)
132 #define CQSPI_REG_CONFIG_BAUD_LSB 19
133 #define CQSPI_REG_CONFIG_DTR_PROTO BIT(24)
134 #define CQSPI_REG_CONFIG_DUAL_OPCODE BIT(30)
135 #define CQSPI_REG_CONFIG_IDLE_LSB 31
136 #define CQSPI_REG_CONFIG_CHIPSELECT_MASK 0xF
137 #define CQSPI_REG_CONFIG_BAUD_MASK 0xF
139 #define CQSPI_REG_RD_INSTR 0x04
140 #define CQSPI_REG_RD_INSTR_OPCODE_LSB 0
141 #define CQSPI_REG_RD_INSTR_TYPE_INSTR_LSB 8
142 #define CQSPI_REG_RD_INSTR_TYPE_ADDR_LSB 12
143 #define CQSPI_REG_RD_INSTR_TYPE_DATA_LSB 16
144 #define CQSPI_REG_RD_INSTR_MODE_EN_LSB 20
145 #define CQSPI_REG_RD_INSTR_DUMMY_LSB 24
146 #define CQSPI_REG_RD_INSTR_TYPE_INSTR_MASK 0x3
147 #define CQSPI_REG_RD_INSTR_TYPE_ADDR_MASK 0x3
148 #define CQSPI_REG_RD_INSTR_TYPE_DATA_MASK 0x3
149 #define CQSPI_REG_RD_INSTR_DUMMY_MASK 0x1F
151 #define CQSPI_REG_WR_INSTR 0x08
152 #define CQSPI_REG_WR_INSTR_OPCODE_LSB 0
153 #define CQSPI_REG_WR_INSTR_TYPE_ADDR_LSB 12
154 #define CQSPI_REG_WR_INSTR_TYPE_DATA_LSB 16
156 #define CQSPI_REG_DELAY 0x0C
157 #define CQSPI_REG_DELAY_TSLCH_LSB 0
158 #define CQSPI_REG_DELAY_TCHSH_LSB 8
159 #define CQSPI_REG_DELAY_TSD2D_LSB 16
160 #define CQSPI_REG_DELAY_TSHSL_LSB 24
161 #define CQSPI_REG_DELAY_TSLCH_MASK 0xFF
162 #define CQSPI_REG_DELAY_TCHSH_MASK 0xFF
163 #define CQSPI_REG_DELAY_TSD2D_MASK 0xFF
164 #define CQSPI_REG_DELAY_TSHSL_MASK 0xFF
166 #define CQSPI_REG_READCAPTURE 0x10
167 #define CQSPI_REG_READCAPTURE_BYPASS_LSB 0
168 #define CQSPI_REG_READCAPTURE_DELAY_LSB 1
169 #define CQSPI_REG_READCAPTURE_DELAY_MASK 0xF
171 #define CQSPI_REG_SIZE 0x14
172 #define CQSPI_REG_SIZE_ADDRESS_LSB 0
173 #define CQSPI_REG_SIZE_PAGE_LSB 4
174 #define CQSPI_REG_SIZE_BLOCK_LSB 16
175 #define CQSPI_REG_SIZE_ADDRESS_MASK 0xF
176 #define CQSPI_REG_SIZE_PAGE_MASK 0xFFF
177 #define CQSPI_REG_SIZE_BLOCK_MASK 0x3F
179 #define CQSPI_REG_SRAMPARTITION 0x18
180 #define CQSPI_REG_INDIRECTTRIGGER 0x1C
182 #define CQSPI_REG_DMA 0x20
183 #define CQSPI_REG_DMA_SINGLE_LSB 0
184 #define CQSPI_REG_DMA_BURST_LSB 8
185 #define CQSPI_REG_DMA_SINGLE_MASK 0xFF
186 #define CQSPI_REG_DMA_BURST_MASK 0xFF
188 #define CQSPI_REG_REMAP 0x24
189 #define CQSPI_REG_MODE_BIT 0x28
191 #define CQSPI_REG_SDRAMLEVEL 0x2C
192 #define CQSPI_REG_SDRAMLEVEL_RD_LSB 0
193 #define CQSPI_REG_SDRAMLEVEL_WR_LSB 16
194 #define CQSPI_REG_SDRAMLEVEL_RD_MASK 0xFFFF
195 #define CQSPI_REG_SDRAMLEVEL_WR_MASK 0xFFFF
197 #define CQSPI_REG_WR_COMPLETION_CTRL 0x38
198 #define CQSPI_REG_WR_DISABLE_AUTO_POLL BIT(14)
200 #define CQSPI_REG_IRQSTATUS 0x40
201 #define CQSPI_REG_IRQMASK 0x44
203 #define CQSPI_REG_INDIRECTRD 0x60
204 #define CQSPI_REG_INDIRECTRD_START_MASK BIT(0)
205 #define CQSPI_REG_INDIRECTRD_CANCEL_MASK BIT(1)
206 #define CQSPI_REG_INDIRECTRD_DONE_MASK BIT(5)
208 #define CQSPI_REG_INDIRECTRDWATERMARK 0x64
209 #define CQSPI_REG_INDIRECTRDSTARTADDR 0x68
210 #define CQSPI_REG_INDIRECTRDBYTES 0x6C
212 #define CQSPI_REG_CMDCTRL 0x90
213 #define CQSPI_REG_CMDCTRL_EXECUTE_MASK BIT(0)
214 #define CQSPI_REG_CMDCTRL_INPROGRESS_MASK BIT(1)
215 #define CQSPI_REG_CMDCTRL_DUMMY_LSB 7
216 #define CQSPI_REG_CMDCTRL_WR_BYTES_LSB 12
217 #define CQSPI_REG_CMDCTRL_WR_EN_LSB 15
218 #define CQSPI_REG_CMDCTRL_ADD_BYTES_LSB 16
219 #define CQSPI_REG_CMDCTRL_ADDR_EN_LSB 19
220 #define CQSPI_REG_CMDCTRL_RD_BYTES_LSB 20
221 #define CQSPI_REG_CMDCTRL_RD_EN_LSB 23
222 #define CQSPI_REG_CMDCTRL_OPCODE_LSB 24
223 #define CQSPI_REG_CMDCTRL_WR_BYTES_MASK 0x7
224 #define CQSPI_REG_CMDCTRL_ADD_BYTES_MASK 0x3
225 #define CQSPI_REG_CMDCTRL_RD_BYTES_MASK 0x7
226 #define CQSPI_REG_CMDCTRL_DUMMY_MASK 0x1F
228 #define CQSPI_REG_INDIRECTWR 0x70
229 #define CQSPI_REG_INDIRECTWR_START_MASK BIT(0)
230 #define CQSPI_REG_INDIRECTWR_CANCEL_MASK BIT(1)
231 #define CQSPI_REG_INDIRECTWR_DONE_MASK BIT(5)
233 #define CQSPI_REG_INDIRECTWRWATERMARK 0x74
234 #define CQSPI_REG_INDIRECTWRSTARTADDR 0x78
235 #define CQSPI_REG_INDIRECTWRBYTES 0x7C
237 #define CQSPI_REG_INDTRIG_ADDRRANGE 0x80
239 #define CQSPI_REG_CMDADDRESS 0x94
240 #define CQSPI_REG_CMDREADDATALOWER 0xA0
241 #define CQSPI_REG_CMDREADDATAUPPER 0xA4
242 #define CQSPI_REG_CMDWRITEDATALOWER 0xA8
243 #define CQSPI_REG_CMDWRITEDATAUPPER 0xAC
245 #define CQSPI_REG_POLLING_STATUS 0xB0
246 #define CQSPI_REG_POLLING_STATUS_DUMMY_LSB 16
248 #define CQSPI_REG_OP_EXT_LOWER 0xE0
249 #define CQSPI_REG_OP_EXT_READ_LSB 24
250 #define CQSPI_REG_OP_EXT_WRITE_LSB 16
251 #define CQSPI_REG_OP_EXT_STIG_LSB 0
253 #define CQSPI_REG_VERSAL_DMA_SRC_ADDR 0x1000
255 #define CQSPI_REG_VERSAL_DMA_DST_ADDR 0x1800
256 #define CQSPI_REG_VERSAL_DMA_DST_SIZE 0x1804
258 #define CQSPI_REG_VERSAL_DMA_DST_CTRL 0x180C
260 #define CQSPI_REG_VERSAL_DMA_DST_I_STS 0x1814
261 #define CQSPI_REG_VERSAL_DMA_DST_I_EN 0x1818
262 #define CQSPI_REG_VERSAL_DMA_DST_I_DIS 0x181C
263 #define CQSPI_REG_VERSAL_DMA_DST_DONE_MASK BIT(1)
265 #define CQSPI_REG_VERSAL_DMA_DST_ADDR_MSB 0x1828
267 #define CQSPI_REG_VERSAL_DMA_DST_CTRL_VAL 0xF43FFA00
268 #define CQSPI_REG_VERSAL_ADDRRANGE_WIDTH_VAL 0x6
270 /* Interrupt status bits */
271 #define CQSPI_REG_IRQ_MODE_ERR BIT(0)
272 #define CQSPI_REG_IRQ_UNDERFLOW BIT(1)
273 #define CQSPI_REG_IRQ_IND_COMP BIT(2)
274 #define CQSPI_REG_IRQ_IND_RD_REJECT BIT(3)
275 #define CQSPI_REG_IRQ_WR_PROTECTED_ERR BIT(4)
276 #define CQSPI_REG_IRQ_ILLEGAL_AHB_ERR BIT(5)
277 #define CQSPI_REG_IRQ_WATERMARK BIT(6)
278 #define CQSPI_REG_IRQ_IND_SRAM_FULL BIT(12)
280 #define CQSPI_IRQ_MASK_RD (CQSPI_REG_IRQ_WATERMARK | \
281 CQSPI_REG_IRQ_IND_SRAM_FULL | \
282 CQSPI_REG_IRQ_IND_COMP)
284 #define CQSPI_IRQ_MASK_WR (CQSPI_REG_IRQ_IND_COMP | \
285 CQSPI_REG_IRQ_WATERMARK | \
286 CQSPI_REG_IRQ_UNDERFLOW)
288 #define CQSPI_IRQ_STATUS_MASK 0x1FFFF
289 #define CQSPI_DMA_UNALIGN 0x3
291 #define CQSPI_REG_VERSAL_DMA_VAL 0x602
293 static int cqspi_wait_for_bit(void __iomem *reg, const u32 mask, bool clr)
297 return readl_relaxed_poll_timeout(reg, val,
298 (((clr ? ~val : val) & mask) == mask),
299 10, CQSPI_TIMEOUT_MS * 1000);
302 static bool cqspi_is_idle(struct cqspi_st *cqspi)
304 u32 reg = readl(cqspi->iobase + CQSPI_REG_CONFIG);
306 return reg & (1UL << CQSPI_REG_CONFIG_IDLE_LSB);
309 static u32 cqspi_get_rd_sram_level(struct cqspi_st *cqspi)
311 u32 reg = readl(cqspi->iobase + CQSPI_REG_SDRAMLEVEL);
313 reg >>= CQSPI_REG_SDRAMLEVEL_RD_LSB;
314 return reg & CQSPI_REG_SDRAMLEVEL_RD_MASK;
317 static u32 cqspi_get_versal_dma_status(struct cqspi_st *cqspi)
321 dma_status = readl(cqspi->iobase +
322 CQSPI_REG_VERSAL_DMA_DST_I_STS);
323 writel(dma_status, cqspi->iobase +
324 CQSPI_REG_VERSAL_DMA_DST_I_STS);
326 return dma_status & CQSPI_REG_VERSAL_DMA_DST_DONE_MASK;
329 static irqreturn_t cqspi_irq_handler(int this_irq, void *dev)
331 struct cqspi_st *cqspi = dev;
332 unsigned int irq_status;
333 struct device *device = &cqspi->pdev->dev;
334 const struct cqspi_driver_platdata *ddata;
336 ddata = of_device_get_match_data(device);
338 /* Read interrupt status */
339 irq_status = readl(cqspi->iobase + CQSPI_REG_IRQSTATUS);
341 /* Clear interrupt */
342 writel(irq_status, cqspi->iobase + CQSPI_REG_IRQSTATUS);
344 if (cqspi->use_dma_read && ddata && ddata->get_dma_status) {
345 if (ddata->get_dma_status(cqspi)) {
346 complete(&cqspi->transfer_complete);
351 else if (!cqspi->slow_sram)
352 irq_status &= CQSPI_IRQ_MASK_RD | CQSPI_IRQ_MASK_WR;
354 irq_status &= CQSPI_REG_IRQ_WATERMARK | CQSPI_IRQ_MASK_WR;
357 complete(&cqspi->transfer_complete);
362 static unsigned int cqspi_calc_rdreg(const struct spi_mem_op *op)
366 rdreg |= CQSPI_OP_WIDTH(op->cmd) << CQSPI_REG_RD_INSTR_TYPE_INSTR_LSB;
367 rdreg |= CQSPI_OP_WIDTH(op->addr) << CQSPI_REG_RD_INSTR_TYPE_ADDR_LSB;
368 rdreg |= CQSPI_OP_WIDTH(op->data) << CQSPI_REG_RD_INSTR_TYPE_DATA_LSB;
373 static unsigned int cqspi_calc_dummy(const struct spi_mem_op *op)
375 unsigned int dummy_clk;
377 if (!op->dummy.nbytes)
380 dummy_clk = op->dummy.nbytes * (8 / op->dummy.buswidth);
387 static int cqspi_wait_idle(struct cqspi_st *cqspi)
389 const unsigned int poll_idle_retry = 3;
390 unsigned int count = 0;
391 unsigned long timeout;
393 timeout = jiffies + msecs_to_jiffies(CQSPI_TIMEOUT_MS);
396 * Read few times in succession to ensure the controller
397 * is indeed idle, that is, the bit does not transition
400 if (cqspi_is_idle(cqspi))
405 if (count >= poll_idle_retry)
408 if (time_after(jiffies, timeout)) {
409 /* Timeout, in busy mode. */
410 dev_err(&cqspi->pdev->dev,
411 "QSPI is still busy after %dms timeout.\n",
420 static int cqspi_exec_flash_cmd(struct cqspi_st *cqspi, unsigned int reg)
422 void __iomem *reg_base = cqspi->iobase;
425 /* Write the CMDCTRL without start execution. */
426 writel(reg, reg_base + CQSPI_REG_CMDCTRL);
428 reg |= CQSPI_REG_CMDCTRL_EXECUTE_MASK;
429 writel(reg, reg_base + CQSPI_REG_CMDCTRL);
431 /* Polling for completion. */
432 ret = cqspi_wait_for_bit(reg_base + CQSPI_REG_CMDCTRL,
433 CQSPI_REG_CMDCTRL_INPROGRESS_MASK, 1);
435 dev_err(&cqspi->pdev->dev,
436 "Flash command execution timed out.\n");
440 /* Polling QSPI idle status. */
441 return cqspi_wait_idle(cqspi);
444 static int cqspi_setup_opcode_ext(struct cqspi_flash_pdata *f_pdata,
445 const struct spi_mem_op *op,
448 struct cqspi_st *cqspi = f_pdata->cqspi;
449 void __iomem *reg_base = cqspi->iobase;
453 if (op->cmd.nbytes != 2)
456 /* Opcode extension is the LSB. */
457 ext = op->cmd.opcode & 0xff;
459 reg = readl(reg_base + CQSPI_REG_OP_EXT_LOWER);
460 reg &= ~(0xff << shift);
462 writel(reg, reg_base + CQSPI_REG_OP_EXT_LOWER);
467 static int cqspi_enable_dtr(struct cqspi_flash_pdata *f_pdata,
468 const struct spi_mem_op *op, unsigned int shift)
470 struct cqspi_st *cqspi = f_pdata->cqspi;
471 void __iomem *reg_base = cqspi->iobase;
475 reg = readl(reg_base + CQSPI_REG_CONFIG);
478 * We enable dual byte opcode here. The callers have to set up the
479 * extension opcode based on which type of operation it is.
482 reg |= CQSPI_REG_CONFIG_DTR_PROTO;
483 reg |= CQSPI_REG_CONFIG_DUAL_OPCODE;
485 /* Set up command opcode extension. */
486 ret = cqspi_setup_opcode_ext(f_pdata, op, shift);
490 reg &= ~CQSPI_REG_CONFIG_DTR_PROTO;
491 reg &= ~CQSPI_REG_CONFIG_DUAL_OPCODE;
494 writel(reg, reg_base + CQSPI_REG_CONFIG);
496 return cqspi_wait_idle(cqspi);
499 static int cqspi_command_read(struct cqspi_flash_pdata *f_pdata,
500 const struct spi_mem_op *op)
502 struct cqspi_st *cqspi = f_pdata->cqspi;
503 void __iomem *reg_base = cqspi->iobase;
504 u8 *rxbuf = op->data.buf.in;
506 size_t n_rx = op->data.nbytes;
509 unsigned int dummy_clk;
513 status = cqspi_enable_dtr(f_pdata, op, CQSPI_REG_OP_EXT_STIG_LSB);
517 if (!n_rx || n_rx > CQSPI_STIG_DATA_LEN_MAX || !rxbuf) {
518 dev_err(&cqspi->pdev->dev,
519 "Invalid input argument, len %zu rxbuf 0x%p\n",
525 opcode = op->cmd.opcode >> 8;
527 opcode = op->cmd.opcode;
529 reg = opcode << CQSPI_REG_CMDCTRL_OPCODE_LSB;
531 rdreg = cqspi_calc_rdreg(op);
532 writel(rdreg, reg_base + CQSPI_REG_RD_INSTR);
534 dummy_clk = cqspi_calc_dummy(op);
535 if (dummy_clk > CQSPI_DUMMY_CLKS_MAX)
539 reg |= (dummy_clk & CQSPI_REG_CMDCTRL_DUMMY_MASK)
540 << CQSPI_REG_CMDCTRL_DUMMY_LSB;
542 reg |= (0x1 << CQSPI_REG_CMDCTRL_RD_EN_LSB);
544 /* 0 means 1 byte. */
545 reg |= (((n_rx - 1) & CQSPI_REG_CMDCTRL_RD_BYTES_MASK)
546 << CQSPI_REG_CMDCTRL_RD_BYTES_LSB);
548 /* setup ADDR BIT field */
549 if (op->addr.nbytes) {
550 reg |= (0x1 << CQSPI_REG_CMDCTRL_ADDR_EN_LSB);
551 reg |= ((op->addr.nbytes - 1) &
552 CQSPI_REG_CMDCTRL_ADD_BYTES_MASK)
553 << CQSPI_REG_CMDCTRL_ADD_BYTES_LSB;
555 writel(op->addr.val, reg_base + CQSPI_REG_CMDADDRESS);
558 status = cqspi_exec_flash_cmd(cqspi, reg);
562 reg = readl(reg_base + CQSPI_REG_CMDREADDATALOWER);
564 /* Put the read value into rx_buf */
565 read_len = (n_rx > 4) ? 4 : n_rx;
566 memcpy(rxbuf, ®, read_len);
570 reg = readl(reg_base + CQSPI_REG_CMDREADDATAUPPER);
572 read_len = n_rx - read_len;
573 memcpy(rxbuf, ®, read_len);
576 /* Reset CMD_CTRL Reg once command read completes */
577 writel(0, reg_base + CQSPI_REG_CMDCTRL);
582 static int cqspi_command_write(struct cqspi_flash_pdata *f_pdata,
583 const struct spi_mem_op *op)
585 struct cqspi_st *cqspi = f_pdata->cqspi;
586 void __iomem *reg_base = cqspi->iobase;
588 const u8 *txbuf = op->data.buf.out;
589 size_t n_tx = op->data.nbytes;
595 ret = cqspi_enable_dtr(f_pdata, op, CQSPI_REG_OP_EXT_STIG_LSB);
599 if (n_tx > CQSPI_STIG_DATA_LEN_MAX || (n_tx && !txbuf)) {
600 dev_err(&cqspi->pdev->dev,
601 "Invalid input argument, cmdlen %zu txbuf 0x%p\n",
606 reg = cqspi_calc_rdreg(op);
607 writel(reg, reg_base + CQSPI_REG_RD_INSTR);
610 opcode = op->cmd.opcode >> 8;
612 opcode = op->cmd.opcode;
614 reg = opcode << CQSPI_REG_CMDCTRL_OPCODE_LSB;
616 if (op->addr.nbytes) {
617 reg |= (0x1 << CQSPI_REG_CMDCTRL_ADDR_EN_LSB);
618 reg |= ((op->addr.nbytes - 1) &
619 CQSPI_REG_CMDCTRL_ADD_BYTES_MASK)
620 << CQSPI_REG_CMDCTRL_ADD_BYTES_LSB;
622 writel(op->addr.val, reg_base + CQSPI_REG_CMDADDRESS);
626 reg |= (0x1 << CQSPI_REG_CMDCTRL_WR_EN_LSB);
627 reg |= ((n_tx - 1) & CQSPI_REG_CMDCTRL_WR_BYTES_MASK)
628 << CQSPI_REG_CMDCTRL_WR_BYTES_LSB;
630 write_len = (n_tx > 4) ? 4 : n_tx;
631 memcpy(&data, txbuf, write_len);
633 writel(data, reg_base + CQSPI_REG_CMDWRITEDATALOWER);
637 write_len = n_tx - 4;
638 memcpy(&data, txbuf, write_len);
639 writel(data, reg_base + CQSPI_REG_CMDWRITEDATAUPPER);
643 ret = cqspi_exec_flash_cmd(cqspi, reg);
645 /* Reset CMD_CTRL Reg once command write completes */
646 writel(0, reg_base + CQSPI_REG_CMDCTRL);
651 static int cqspi_read_setup(struct cqspi_flash_pdata *f_pdata,
652 const struct spi_mem_op *op)
654 struct cqspi_st *cqspi = f_pdata->cqspi;
655 void __iomem *reg_base = cqspi->iobase;
656 unsigned int dummy_clk = 0;
661 ret = cqspi_enable_dtr(f_pdata, op, CQSPI_REG_OP_EXT_READ_LSB);
666 opcode = op->cmd.opcode >> 8;
668 opcode = op->cmd.opcode;
670 reg = opcode << CQSPI_REG_RD_INSTR_OPCODE_LSB;
671 reg |= cqspi_calc_rdreg(op);
673 /* Setup dummy clock cycles */
674 dummy_clk = cqspi_calc_dummy(op);
676 if (dummy_clk > CQSPI_DUMMY_CLKS_MAX)
680 reg |= (dummy_clk & CQSPI_REG_RD_INSTR_DUMMY_MASK)
681 << CQSPI_REG_RD_INSTR_DUMMY_LSB;
683 writel(reg, reg_base + CQSPI_REG_RD_INSTR);
685 /* Set address width */
686 reg = readl(reg_base + CQSPI_REG_SIZE);
687 reg &= ~CQSPI_REG_SIZE_ADDRESS_MASK;
688 reg |= (op->addr.nbytes - 1);
689 writel(reg, reg_base + CQSPI_REG_SIZE);
693 static int cqspi_indirect_read_execute(struct cqspi_flash_pdata *f_pdata,
694 u8 *rxbuf, loff_t from_addr,
697 struct cqspi_st *cqspi = f_pdata->cqspi;
698 struct device *dev = &cqspi->pdev->dev;
699 void __iomem *reg_base = cqspi->iobase;
700 void __iomem *ahb_base = cqspi->ahb_base;
701 unsigned int remaining = n_rx;
702 unsigned int mod_bytes = n_rx % 4;
703 unsigned int bytes_to_read = 0;
704 u8 *rxbuf_end = rxbuf + n_rx;
707 writel(from_addr, reg_base + CQSPI_REG_INDIRECTRDSTARTADDR);
708 writel(remaining, reg_base + CQSPI_REG_INDIRECTRDBYTES);
710 /* Clear all interrupts. */
711 writel(CQSPI_IRQ_STATUS_MASK, reg_base + CQSPI_REG_IRQSTATUS);
714 * On SoCFPGA platform reading the SRAM is slow due to
715 * hardware limitation and causing read interrupt storm to CPU,
716 * so enabling only watermark interrupt to disable all read
717 * interrupts later as we want to run "bytes to read" loop with
718 * all the read interrupts disabled for max performance.
721 if (!cqspi->slow_sram)
722 writel(CQSPI_IRQ_MASK_RD, reg_base + CQSPI_REG_IRQMASK);
724 writel(CQSPI_REG_IRQ_WATERMARK, reg_base + CQSPI_REG_IRQMASK);
726 reinit_completion(&cqspi->transfer_complete);
727 writel(CQSPI_REG_INDIRECTRD_START_MASK,
728 reg_base + CQSPI_REG_INDIRECTRD);
730 while (remaining > 0) {
731 if (!wait_for_completion_timeout(&cqspi->transfer_complete,
732 msecs_to_jiffies(CQSPI_READ_TIMEOUT_MS)))
736 * Disable all read interrupts until
737 * we are out of "bytes to read"
739 if (cqspi->slow_sram)
740 writel(0x0, reg_base + CQSPI_REG_IRQMASK);
742 bytes_to_read = cqspi_get_rd_sram_level(cqspi);
744 if (ret && bytes_to_read == 0) {
745 dev_err(dev, "Indirect read timeout, no bytes\n");
749 while (bytes_to_read != 0) {
750 unsigned int word_remain = round_down(remaining, 4);
752 bytes_to_read *= cqspi->fifo_width;
753 bytes_to_read = bytes_to_read > remaining ?
754 remaining : bytes_to_read;
755 bytes_to_read = round_down(bytes_to_read, 4);
756 /* Read 4 byte word chunks then single bytes */
758 ioread32_rep(ahb_base, rxbuf,
759 (bytes_to_read / 4));
760 } else if (!word_remain && mod_bytes) {
761 unsigned int temp = ioread32(ahb_base);
763 bytes_to_read = mod_bytes;
764 memcpy(rxbuf, &temp, min((unsigned int)
768 rxbuf += bytes_to_read;
769 remaining -= bytes_to_read;
770 bytes_to_read = cqspi_get_rd_sram_level(cqspi);
774 reinit_completion(&cqspi->transfer_complete);
775 if (cqspi->slow_sram)
776 writel(CQSPI_REG_IRQ_WATERMARK, reg_base + CQSPI_REG_IRQMASK);
780 /* Check indirect done status */
781 ret = cqspi_wait_for_bit(reg_base + CQSPI_REG_INDIRECTRD,
782 CQSPI_REG_INDIRECTRD_DONE_MASK, 0);
784 dev_err(dev, "Indirect read completion error (%i)\n", ret);
788 /* Disable interrupt */
789 writel(0, reg_base + CQSPI_REG_IRQMASK);
791 /* Clear indirect completion status */
792 writel(CQSPI_REG_INDIRECTRD_DONE_MASK, reg_base + CQSPI_REG_INDIRECTRD);
797 /* Disable interrupt */
798 writel(0, reg_base + CQSPI_REG_IRQMASK);
800 /* Cancel the indirect read */
801 writel(CQSPI_REG_INDIRECTRD_CANCEL_MASK,
802 reg_base + CQSPI_REG_INDIRECTRD);
806 static void cqspi_controller_enable(struct cqspi_st *cqspi, bool enable)
808 void __iomem *reg_base = cqspi->iobase;
811 reg = readl(reg_base + CQSPI_REG_CONFIG);
814 reg |= CQSPI_REG_CONFIG_ENABLE_MASK;
816 reg &= ~CQSPI_REG_CONFIG_ENABLE_MASK;
818 writel(reg, reg_base + CQSPI_REG_CONFIG);
821 static int cqspi_versal_indirect_read_dma(struct cqspi_flash_pdata *f_pdata,
822 u_char *rxbuf, loff_t from_addr,
825 struct cqspi_st *cqspi = f_pdata->cqspi;
826 struct device *dev = &cqspi->pdev->dev;
827 void __iomem *reg_base = cqspi->iobase;
828 u32 reg, bytes_to_dma;
829 loff_t addr = from_addr;
835 bytes_rem = n_rx % 4;
836 bytes_to_dma = (n_rx - bytes_rem);
841 ret = zynqmp_pm_ospi_mux_select(cqspi->pd_dev_id, PM_OSPI_MUX_SEL_DMA);
845 cqspi_controller_enable(cqspi, 0);
847 reg = readl(cqspi->iobase + CQSPI_REG_CONFIG);
848 reg |= CQSPI_REG_CONFIG_DMA_MASK;
849 writel(reg, cqspi->iobase + CQSPI_REG_CONFIG);
851 cqspi_controller_enable(cqspi, 1);
853 dma_addr = dma_map_single(dev, rxbuf, bytes_to_dma, DMA_FROM_DEVICE);
854 if (dma_mapping_error(dev, dma_addr)) {
855 dev_err(dev, "dma mapping failed\n");
859 writel(from_addr, reg_base + CQSPI_REG_INDIRECTRDSTARTADDR);
860 writel(bytes_to_dma, reg_base + CQSPI_REG_INDIRECTRDBYTES);
861 writel(CQSPI_REG_VERSAL_ADDRRANGE_WIDTH_VAL,
862 reg_base + CQSPI_REG_INDTRIG_ADDRRANGE);
864 /* Clear all interrupts. */
865 writel(CQSPI_IRQ_STATUS_MASK, reg_base + CQSPI_REG_IRQSTATUS);
867 /* Enable DMA done interrupt */
868 writel(CQSPI_REG_VERSAL_DMA_DST_DONE_MASK,
869 reg_base + CQSPI_REG_VERSAL_DMA_DST_I_EN);
871 /* Default DMA periph configuration */
872 writel(CQSPI_REG_VERSAL_DMA_VAL, reg_base + CQSPI_REG_DMA);
874 /* Configure DMA Dst address */
875 writel(lower_32_bits(dma_addr),
876 reg_base + CQSPI_REG_VERSAL_DMA_DST_ADDR);
877 writel(upper_32_bits(dma_addr),
878 reg_base + CQSPI_REG_VERSAL_DMA_DST_ADDR_MSB);
880 /* Configure DMA Src address */
881 writel(cqspi->trigger_address, reg_base +
882 CQSPI_REG_VERSAL_DMA_SRC_ADDR);
884 /* Set DMA destination size */
885 writel(bytes_to_dma, reg_base + CQSPI_REG_VERSAL_DMA_DST_SIZE);
887 /* Set DMA destination control */
888 writel(CQSPI_REG_VERSAL_DMA_DST_CTRL_VAL,
889 reg_base + CQSPI_REG_VERSAL_DMA_DST_CTRL);
891 writel(CQSPI_REG_INDIRECTRD_START_MASK,
892 reg_base + CQSPI_REG_INDIRECTRD);
894 reinit_completion(&cqspi->transfer_complete);
896 if (!wait_for_completion_timeout(&cqspi->transfer_complete,
897 msecs_to_jiffies(max_t(size_t, bytes_to_dma, 500)))) {
902 /* Disable DMA interrupt */
903 writel(0x0, cqspi->iobase + CQSPI_REG_VERSAL_DMA_DST_I_DIS);
905 /* Clear indirect completion status */
906 writel(CQSPI_REG_INDIRECTRD_DONE_MASK,
907 cqspi->iobase + CQSPI_REG_INDIRECTRD);
908 dma_unmap_single(dev, dma_addr, bytes_to_dma, DMA_FROM_DEVICE);
910 cqspi_controller_enable(cqspi, 0);
912 reg = readl(cqspi->iobase + CQSPI_REG_CONFIG);
913 reg &= ~CQSPI_REG_CONFIG_DMA_MASK;
914 writel(reg, cqspi->iobase + CQSPI_REG_CONFIG);
916 cqspi_controller_enable(cqspi, 1);
918 ret = zynqmp_pm_ospi_mux_select(cqspi->pd_dev_id,
919 PM_OSPI_MUX_SEL_LINEAR);
925 addr += bytes_to_dma;
927 ret = cqspi_indirect_read_execute(f_pdata, buf, addr,
936 /* Disable DMA interrupt */
937 writel(0x0, reg_base + CQSPI_REG_VERSAL_DMA_DST_I_DIS);
939 /* Cancel the indirect read */
940 writel(CQSPI_REG_INDIRECTWR_CANCEL_MASK,
941 reg_base + CQSPI_REG_INDIRECTRD);
943 dma_unmap_single(dev, dma_addr, bytes_to_dma, DMA_FROM_DEVICE);
945 reg = readl(cqspi->iobase + CQSPI_REG_CONFIG);
946 reg &= ~CQSPI_REG_CONFIG_DMA_MASK;
947 writel(reg, cqspi->iobase + CQSPI_REG_CONFIG);
949 zynqmp_pm_ospi_mux_select(cqspi->pd_dev_id, PM_OSPI_MUX_SEL_LINEAR);
954 static int cqspi_write_setup(struct cqspi_flash_pdata *f_pdata,
955 const struct spi_mem_op *op)
959 struct cqspi_st *cqspi = f_pdata->cqspi;
960 void __iomem *reg_base = cqspi->iobase;
963 ret = cqspi_enable_dtr(f_pdata, op, CQSPI_REG_OP_EXT_WRITE_LSB);
968 opcode = op->cmd.opcode >> 8;
970 opcode = op->cmd.opcode;
973 reg = opcode << CQSPI_REG_WR_INSTR_OPCODE_LSB;
974 reg |= CQSPI_OP_WIDTH(op->data) << CQSPI_REG_WR_INSTR_TYPE_DATA_LSB;
975 reg |= CQSPI_OP_WIDTH(op->addr) << CQSPI_REG_WR_INSTR_TYPE_ADDR_LSB;
976 writel(reg, reg_base + CQSPI_REG_WR_INSTR);
977 reg = cqspi_calc_rdreg(op);
978 writel(reg, reg_base + CQSPI_REG_RD_INSTR);
981 * SPI NAND flashes require the address of the status register to be
982 * passed in the Read SR command. Also, some SPI NOR flashes like the
983 * cypress Semper flash expect a 4-byte dummy address in the Read SR
984 * command in DTR mode.
986 * But this controller does not support address phase in the Read SR
987 * command when doing auto-HW polling. So, disable write completion
988 * polling on the controller's side. spinand and spi-nor will take
989 * care of polling the status register.
991 if (cqspi->wr_completion) {
992 reg = readl(reg_base + CQSPI_REG_WR_COMPLETION_CTRL);
993 reg |= CQSPI_REG_WR_DISABLE_AUTO_POLL;
994 writel(reg, reg_base + CQSPI_REG_WR_COMPLETION_CTRL);
996 * DAC mode require auto polling as flash needs to be polled
997 * for write completion in case of bubble in SPI transaction
998 * due to slow CPU/DMA master.
1000 cqspi->use_direct_mode_wr = false;
1003 reg = readl(reg_base + CQSPI_REG_SIZE);
1004 reg &= ~CQSPI_REG_SIZE_ADDRESS_MASK;
1005 reg |= (op->addr.nbytes - 1);
1006 writel(reg, reg_base + CQSPI_REG_SIZE);
1010 static int cqspi_indirect_write_execute(struct cqspi_flash_pdata *f_pdata,
1011 loff_t to_addr, const u8 *txbuf,
1014 struct cqspi_st *cqspi = f_pdata->cqspi;
1015 struct device *dev = &cqspi->pdev->dev;
1016 void __iomem *reg_base = cqspi->iobase;
1017 unsigned int remaining = n_tx;
1018 unsigned int write_bytes;
1021 writel(to_addr, reg_base + CQSPI_REG_INDIRECTWRSTARTADDR);
1022 writel(remaining, reg_base + CQSPI_REG_INDIRECTWRBYTES);
1024 /* Clear all interrupts. */
1025 writel(CQSPI_IRQ_STATUS_MASK, reg_base + CQSPI_REG_IRQSTATUS);
1027 writel(CQSPI_IRQ_MASK_WR, reg_base + CQSPI_REG_IRQMASK);
1029 reinit_completion(&cqspi->transfer_complete);
1030 writel(CQSPI_REG_INDIRECTWR_START_MASK,
1031 reg_base + CQSPI_REG_INDIRECTWR);
1033 * As per 66AK2G02 TRM SPRUHY8F section 11.15.5.3 Indirect Access
1034 * Controller programming sequence, couple of cycles of
1035 * QSPI_REF_CLK delay is required for the above bit to
1036 * be internally synchronized by the QSPI module. Provide 5
1039 if (cqspi->wr_delay)
1040 ndelay(cqspi->wr_delay);
1043 * If a hazard exists between the APB and AHB interfaces, perform a
1044 * dummy readback from the controller to ensure synchronization.
1046 if (cqspi->apb_ahb_hazard)
1047 readl(reg_base + CQSPI_REG_INDIRECTWR);
1049 while (remaining > 0) {
1050 size_t write_words, mod_bytes;
1052 write_bytes = remaining;
1053 write_words = write_bytes / 4;
1054 mod_bytes = write_bytes % 4;
1055 /* Write 4 bytes at a time then single bytes. */
1057 iowrite32_rep(cqspi->ahb_base, txbuf, write_words);
1058 txbuf += (write_words * 4);
1061 unsigned int temp = 0xFFFFFFFF;
1063 memcpy(&temp, txbuf, mod_bytes);
1064 iowrite32(temp, cqspi->ahb_base);
1068 if (!wait_for_completion_timeout(&cqspi->transfer_complete,
1069 msecs_to_jiffies(CQSPI_TIMEOUT_MS))) {
1070 dev_err(dev, "Indirect write timeout\n");
1075 remaining -= write_bytes;
1078 reinit_completion(&cqspi->transfer_complete);
1081 /* Check indirect done status */
1082 ret = cqspi_wait_for_bit(reg_base + CQSPI_REG_INDIRECTWR,
1083 CQSPI_REG_INDIRECTWR_DONE_MASK, 0);
1085 dev_err(dev, "Indirect write completion error (%i)\n", ret);
1089 /* Disable interrupt. */
1090 writel(0, reg_base + CQSPI_REG_IRQMASK);
1092 /* Clear indirect completion status */
1093 writel(CQSPI_REG_INDIRECTWR_DONE_MASK, reg_base + CQSPI_REG_INDIRECTWR);
1095 cqspi_wait_idle(cqspi);
1100 /* Disable interrupt. */
1101 writel(0, reg_base + CQSPI_REG_IRQMASK);
1103 /* Cancel the indirect write */
1104 writel(CQSPI_REG_INDIRECTWR_CANCEL_MASK,
1105 reg_base + CQSPI_REG_INDIRECTWR);
1109 static void cqspi_chipselect(struct cqspi_flash_pdata *f_pdata)
1111 struct cqspi_st *cqspi = f_pdata->cqspi;
1112 void __iomem *reg_base = cqspi->iobase;
1113 unsigned int chip_select = f_pdata->cs;
1116 reg = readl(reg_base + CQSPI_REG_CONFIG);
1117 if (cqspi->is_decoded_cs) {
1118 reg |= CQSPI_REG_CONFIG_DECODE_MASK;
1120 reg &= ~CQSPI_REG_CONFIG_DECODE_MASK;
1122 /* Convert CS if without decoder.
1128 chip_select = 0xF & ~(1 << chip_select);
1131 reg &= ~(CQSPI_REG_CONFIG_CHIPSELECT_MASK
1132 << CQSPI_REG_CONFIG_CHIPSELECT_LSB);
1133 reg |= (chip_select & CQSPI_REG_CONFIG_CHIPSELECT_MASK)
1134 << CQSPI_REG_CONFIG_CHIPSELECT_LSB;
1135 writel(reg, reg_base + CQSPI_REG_CONFIG);
1138 static unsigned int calculate_ticks_for_ns(const unsigned int ref_clk_hz,
1139 const unsigned int ns_val)
1143 ticks = ref_clk_hz / 1000; /* kHz */
1144 ticks = DIV_ROUND_UP(ticks * ns_val, 1000000);
1149 static void cqspi_delay(struct cqspi_flash_pdata *f_pdata)
1151 struct cqspi_st *cqspi = f_pdata->cqspi;
1152 void __iomem *iobase = cqspi->iobase;
1153 const unsigned int ref_clk_hz = cqspi->master_ref_clk_hz;
1154 unsigned int tshsl, tchsh, tslch, tsd2d;
1158 /* calculate the number of ref ticks for one sclk tick */
1159 tsclk = DIV_ROUND_UP(ref_clk_hz, cqspi->sclk);
1161 tshsl = calculate_ticks_for_ns(ref_clk_hz, f_pdata->tshsl_ns);
1162 /* this particular value must be at least one sclk */
1166 tchsh = calculate_ticks_for_ns(ref_clk_hz, f_pdata->tchsh_ns);
1167 tslch = calculate_ticks_for_ns(ref_clk_hz, f_pdata->tslch_ns);
1168 tsd2d = calculate_ticks_for_ns(ref_clk_hz, f_pdata->tsd2d_ns);
1170 reg = (tshsl & CQSPI_REG_DELAY_TSHSL_MASK)
1171 << CQSPI_REG_DELAY_TSHSL_LSB;
1172 reg |= (tchsh & CQSPI_REG_DELAY_TCHSH_MASK)
1173 << CQSPI_REG_DELAY_TCHSH_LSB;
1174 reg |= (tslch & CQSPI_REG_DELAY_TSLCH_MASK)
1175 << CQSPI_REG_DELAY_TSLCH_LSB;
1176 reg |= (tsd2d & CQSPI_REG_DELAY_TSD2D_MASK)
1177 << CQSPI_REG_DELAY_TSD2D_LSB;
1178 writel(reg, iobase + CQSPI_REG_DELAY);
1181 static void cqspi_config_baudrate_div(struct cqspi_st *cqspi)
1183 const unsigned int ref_clk_hz = cqspi->master_ref_clk_hz;
1184 void __iomem *reg_base = cqspi->iobase;
1187 /* Recalculate the baudrate divisor based on QSPI specification. */
1188 div = DIV_ROUND_UP(ref_clk_hz, 2 * cqspi->sclk) - 1;
1190 /* Maximum baud divisor */
1191 if (div > CQSPI_REG_CONFIG_BAUD_MASK) {
1192 div = CQSPI_REG_CONFIG_BAUD_MASK;
1193 dev_warn(&cqspi->pdev->dev,
1194 "Unable to adjust clock <= %d hz. Reduced to %d hz\n",
1195 cqspi->sclk, ref_clk_hz/((div+1)*2));
1198 reg = readl(reg_base + CQSPI_REG_CONFIG);
1199 reg &= ~(CQSPI_REG_CONFIG_BAUD_MASK << CQSPI_REG_CONFIG_BAUD_LSB);
1200 reg |= (div & CQSPI_REG_CONFIG_BAUD_MASK) << CQSPI_REG_CONFIG_BAUD_LSB;
1201 writel(reg, reg_base + CQSPI_REG_CONFIG);
1204 static void cqspi_readdata_capture(struct cqspi_st *cqspi,
1206 const unsigned int delay)
1208 void __iomem *reg_base = cqspi->iobase;
1211 reg = readl(reg_base + CQSPI_REG_READCAPTURE);
1214 reg |= (1 << CQSPI_REG_READCAPTURE_BYPASS_LSB);
1216 reg &= ~(1 << CQSPI_REG_READCAPTURE_BYPASS_LSB);
1218 reg &= ~(CQSPI_REG_READCAPTURE_DELAY_MASK
1219 << CQSPI_REG_READCAPTURE_DELAY_LSB);
1221 reg |= (delay & CQSPI_REG_READCAPTURE_DELAY_MASK)
1222 << CQSPI_REG_READCAPTURE_DELAY_LSB;
1224 writel(reg, reg_base + CQSPI_REG_READCAPTURE);
1227 static void cqspi_configure(struct cqspi_flash_pdata *f_pdata,
1230 struct cqspi_st *cqspi = f_pdata->cqspi;
1231 int switch_cs = (cqspi->current_cs != f_pdata->cs);
1232 int switch_ck = (cqspi->sclk != sclk);
1234 if (switch_cs || switch_ck)
1235 cqspi_controller_enable(cqspi, 0);
1237 /* Switch chip select. */
1239 cqspi->current_cs = f_pdata->cs;
1240 cqspi_chipselect(f_pdata);
1243 /* Setup baudrate divisor and delays */
1246 cqspi_config_baudrate_div(cqspi);
1247 cqspi_delay(f_pdata);
1248 cqspi_readdata_capture(cqspi, !cqspi->rclk_en,
1249 f_pdata->read_delay);
1252 if (switch_cs || switch_ck)
1253 cqspi_controller_enable(cqspi, 1);
1256 static ssize_t cqspi_write(struct cqspi_flash_pdata *f_pdata,
1257 const struct spi_mem_op *op)
1259 struct cqspi_st *cqspi = f_pdata->cqspi;
1260 loff_t to = op->addr.val;
1261 size_t len = op->data.nbytes;
1262 const u_char *buf = op->data.buf.out;
1265 ret = cqspi_write_setup(f_pdata, op);
1270 * Some flashes like the Cypress Semper flash expect a dummy 4-byte
1271 * address (all 0s) with the read status register command in DTR mode.
1272 * But this controller does not support sending dummy address bytes to
1273 * the flash when it is polling the write completion register in DTR
1274 * mode. So, we can not use direct mode when in DTR mode for writing
1277 if (!op->cmd.dtr && cqspi->use_direct_mode &&
1278 cqspi->use_direct_mode_wr && ((to + len) <= cqspi->ahb_size)) {
1279 memcpy_toio(cqspi->ahb_base + to, buf, len);
1280 return cqspi_wait_idle(cqspi);
1283 return cqspi_indirect_write_execute(f_pdata, to, buf, len);
1286 static void cqspi_rx_dma_callback(void *param)
1288 struct cqspi_st *cqspi = param;
1290 complete(&cqspi->rx_dma_complete);
1293 static int cqspi_direct_read_execute(struct cqspi_flash_pdata *f_pdata,
1294 u_char *buf, loff_t from, size_t len)
1296 struct cqspi_st *cqspi = f_pdata->cqspi;
1297 struct device *dev = &cqspi->pdev->dev;
1298 enum dma_ctrl_flags flags = DMA_CTRL_ACK | DMA_PREP_INTERRUPT;
1299 dma_addr_t dma_src = (dma_addr_t)cqspi->mmap_phys_base + from;
1301 struct dma_async_tx_descriptor *tx;
1302 dma_cookie_t cookie;
1304 struct device *ddev;
1306 if (!cqspi->rx_chan || !virt_addr_valid(buf)) {
1307 memcpy_fromio(buf, cqspi->ahb_base + from, len);
1311 ddev = cqspi->rx_chan->device->dev;
1312 dma_dst = dma_map_single(ddev, buf, len, DMA_FROM_DEVICE);
1313 if (dma_mapping_error(ddev, dma_dst)) {
1314 dev_err(dev, "dma mapping failed\n");
1317 tx = dmaengine_prep_dma_memcpy(cqspi->rx_chan, dma_dst, dma_src,
1320 dev_err(dev, "device_prep_dma_memcpy error\n");
1325 tx->callback = cqspi_rx_dma_callback;
1326 tx->callback_param = cqspi;
1327 cookie = tx->tx_submit(tx);
1328 reinit_completion(&cqspi->rx_dma_complete);
1330 ret = dma_submit_error(cookie);
1332 dev_err(dev, "dma_submit_error %d\n", cookie);
1337 dma_async_issue_pending(cqspi->rx_chan);
1338 if (!wait_for_completion_timeout(&cqspi->rx_dma_complete,
1339 msecs_to_jiffies(max_t(size_t, len, 500)))) {
1340 dmaengine_terminate_sync(cqspi->rx_chan);
1341 dev_err(dev, "DMA wait_for_completion_timeout\n");
1347 dma_unmap_single(ddev, dma_dst, len, DMA_FROM_DEVICE);
1352 static ssize_t cqspi_read(struct cqspi_flash_pdata *f_pdata,
1353 const struct spi_mem_op *op)
1355 struct cqspi_st *cqspi = f_pdata->cqspi;
1356 struct device *dev = &cqspi->pdev->dev;
1357 const struct cqspi_driver_platdata *ddata;
1358 loff_t from = op->addr.val;
1359 size_t len = op->data.nbytes;
1360 u_char *buf = op->data.buf.in;
1361 u64 dma_align = (u64)(uintptr_t)buf;
1364 ddata = of_device_get_match_data(dev);
1366 ret = cqspi_read_setup(f_pdata, op);
1370 if (cqspi->use_direct_mode && ((from + len) <= cqspi->ahb_size))
1371 return cqspi_direct_read_execute(f_pdata, buf, from, len);
1373 if (cqspi->use_dma_read && ddata && ddata->indirect_read_dma &&
1374 virt_addr_valid(buf) && ((dma_align & CQSPI_DMA_UNALIGN) == 0))
1375 return ddata->indirect_read_dma(f_pdata, buf, from, len);
1377 return cqspi_indirect_read_execute(f_pdata, buf, from, len);
1380 static int cqspi_mem_process(struct spi_mem *mem, const struct spi_mem_op *op)
1382 struct cqspi_st *cqspi = spi_controller_get_devdata(mem->spi->controller);
1383 struct cqspi_flash_pdata *f_pdata;
1385 f_pdata = &cqspi->f_pdata[spi_get_chipselect(mem->spi, 0)];
1386 cqspi_configure(f_pdata, mem->spi->max_speed_hz);
1388 if (op->data.dir == SPI_MEM_DATA_IN && op->data.buf.in) {
1390 * Performing reads in DAC mode forces to read minimum 4 bytes
1391 * which is unsupported on some flash devices during register
1392 * reads, prefer STIG mode for such small reads.
1394 if (!op->addr.nbytes ||
1395 op->data.nbytes <= CQSPI_STIG_DATA_LEN_MAX)
1396 return cqspi_command_read(f_pdata, op);
1398 return cqspi_read(f_pdata, op);
1401 if (!op->addr.nbytes || !op->data.buf.out)
1402 return cqspi_command_write(f_pdata, op);
1404 return cqspi_write(f_pdata, op);
1407 static int cqspi_exec_mem_op(struct spi_mem *mem, const struct spi_mem_op *op)
1411 ret = cqspi_mem_process(mem, op);
1413 dev_err(&mem->spi->dev, "operation failed with %d\n", ret);
1418 static bool cqspi_supports_mem_op(struct spi_mem *mem,
1419 const struct spi_mem_op *op)
1421 bool all_true, all_false;
1424 * op->dummy.dtr is required for converting nbytes into ncycles.
1425 * Also, don't check the dtr field of the op phase having zero nbytes.
1427 all_true = op->cmd.dtr &&
1428 (!op->addr.nbytes || op->addr.dtr) &&
1429 (!op->dummy.nbytes || op->dummy.dtr) &&
1430 (!op->data.nbytes || op->data.dtr);
1432 all_false = !op->cmd.dtr && !op->addr.dtr && !op->dummy.dtr &&
1436 /* Right now we only support 8-8-8 DTR mode. */
1437 if (op->cmd.nbytes && op->cmd.buswidth != 8)
1439 if (op->addr.nbytes && op->addr.buswidth != 8)
1441 if (op->data.nbytes && op->data.buswidth != 8)
1443 } else if (!all_false) {
1444 /* Mixed DTR modes are not supported. */
1448 return spi_mem_default_supports_op(mem, op);
1451 static int cqspi_of_get_flash_pdata(struct platform_device *pdev,
1452 struct cqspi_flash_pdata *f_pdata,
1453 struct device_node *np)
1455 if (of_property_read_u32(np, "cdns,read-delay", &f_pdata->read_delay)) {
1456 dev_err(&pdev->dev, "couldn't determine read-delay\n");
1460 if (of_property_read_u32(np, "cdns,tshsl-ns", &f_pdata->tshsl_ns)) {
1461 dev_err(&pdev->dev, "couldn't determine tshsl-ns\n");
1465 if (of_property_read_u32(np, "cdns,tsd2d-ns", &f_pdata->tsd2d_ns)) {
1466 dev_err(&pdev->dev, "couldn't determine tsd2d-ns\n");
1470 if (of_property_read_u32(np, "cdns,tchsh-ns", &f_pdata->tchsh_ns)) {
1471 dev_err(&pdev->dev, "couldn't determine tchsh-ns\n");
1475 if (of_property_read_u32(np, "cdns,tslch-ns", &f_pdata->tslch_ns)) {
1476 dev_err(&pdev->dev, "couldn't determine tslch-ns\n");
1480 if (of_property_read_u32(np, "spi-max-frequency", &f_pdata->clk_rate)) {
1481 dev_err(&pdev->dev, "couldn't determine spi-max-frequency\n");
1488 static int cqspi_of_get_pdata(struct cqspi_st *cqspi)
1490 struct device *dev = &cqspi->pdev->dev;
1491 struct device_node *np = dev->of_node;
1494 cqspi->is_decoded_cs = of_property_read_bool(np, "cdns,is-decoded-cs");
1496 if (of_property_read_u32(np, "cdns,fifo-depth", &cqspi->fifo_depth)) {
1497 dev_err(dev, "couldn't determine fifo-depth\n");
1501 if (of_property_read_u32(np, "cdns,fifo-width", &cqspi->fifo_width)) {
1502 dev_err(dev, "couldn't determine fifo-width\n");
1506 if (of_property_read_u32(np, "cdns,trigger-address",
1507 &cqspi->trigger_address)) {
1508 dev_err(dev, "couldn't determine trigger-address\n");
1512 if (of_property_read_u32(np, "num-cs", &cqspi->num_chipselect))
1513 cqspi->num_chipselect = CQSPI_MAX_CHIPSELECT;
1515 cqspi->rclk_en = of_property_read_bool(np, "cdns,rclk-en");
1517 if (!of_property_read_u32_array(np, "power-domains", id,
1519 cqspi->pd_dev_id = id[1];
1524 static void cqspi_controller_init(struct cqspi_st *cqspi)
1528 cqspi_controller_enable(cqspi, 0);
1530 /* Configure the remap address register, no remap */
1531 writel(0, cqspi->iobase + CQSPI_REG_REMAP);
1533 /* Disable all interrupts. */
1534 writel(0, cqspi->iobase + CQSPI_REG_IRQMASK);
1536 /* Configure the SRAM split to 1:1 . */
1537 writel(cqspi->fifo_depth / 2, cqspi->iobase + CQSPI_REG_SRAMPARTITION);
1539 /* Load indirect trigger address. */
1540 writel(cqspi->trigger_address,
1541 cqspi->iobase + CQSPI_REG_INDIRECTTRIGGER);
1543 /* Program read watermark -- 1/2 of the FIFO. */
1544 writel(cqspi->fifo_depth * cqspi->fifo_width / 2,
1545 cqspi->iobase + CQSPI_REG_INDIRECTRDWATERMARK);
1546 /* Program write watermark -- 1/8 of the FIFO. */
1547 writel(cqspi->fifo_depth * cqspi->fifo_width / 8,
1548 cqspi->iobase + CQSPI_REG_INDIRECTWRWATERMARK);
1550 /* Disable direct access controller */
1551 if (!cqspi->use_direct_mode) {
1552 reg = readl(cqspi->iobase + CQSPI_REG_CONFIG);
1553 reg &= ~CQSPI_REG_CONFIG_ENB_DIR_ACC_CTRL;
1554 writel(reg, cqspi->iobase + CQSPI_REG_CONFIG);
1557 /* Enable DMA interface */
1558 if (cqspi->use_dma_read) {
1559 reg = readl(cqspi->iobase + CQSPI_REG_CONFIG);
1560 reg |= CQSPI_REG_CONFIG_DMA_MASK;
1561 writel(reg, cqspi->iobase + CQSPI_REG_CONFIG);
1564 cqspi_controller_enable(cqspi, 1);
1567 static int cqspi_request_mmap_dma(struct cqspi_st *cqspi)
1569 dma_cap_mask_t mask;
1572 dma_cap_set(DMA_MEMCPY, mask);
1574 cqspi->rx_chan = dma_request_chan_by_mask(&mask);
1575 if (IS_ERR(cqspi->rx_chan)) {
1576 int ret = PTR_ERR(cqspi->rx_chan);
1578 cqspi->rx_chan = NULL;
1579 return dev_err_probe(&cqspi->pdev->dev, ret, "No Rx DMA available\n");
1581 init_completion(&cqspi->rx_dma_complete);
1586 static const char *cqspi_get_name(struct spi_mem *mem)
1588 struct cqspi_st *cqspi = spi_controller_get_devdata(mem->spi->controller);
1589 struct device *dev = &cqspi->pdev->dev;
1591 return devm_kasprintf(dev, GFP_KERNEL, "%s.%d", dev_name(dev),
1592 spi_get_chipselect(mem->spi, 0));
1595 static const struct spi_controller_mem_ops cqspi_mem_ops = {
1596 .exec_op = cqspi_exec_mem_op,
1597 .get_name = cqspi_get_name,
1598 .supports_op = cqspi_supports_mem_op,
1601 static const struct spi_controller_mem_caps cqspi_mem_caps = {
1605 static int cqspi_setup_flash(struct cqspi_st *cqspi)
1607 struct platform_device *pdev = cqspi->pdev;
1608 struct device *dev = &pdev->dev;
1609 struct device_node *np = dev->of_node;
1610 struct cqspi_flash_pdata *f_pdata;
1614 /* Get flash device data */
1615 for_each_available_child_of_node(dev->of_node, np) {
1616 ret = of_property_read_u32(np, "reg", &cs);
1618 dev_err(dev, "Couldn't determine chip select.\n");
1623 if (cs >= CQSPI_MAX_CHIPSELECT) {
1624 dev_err(dev, "Chip select %d out of range.\n", cs);
1629 f_pdata = &cqspi->f_pdata[cs];
1630 f_pdata->cqspi = cqspi;
1633 ret = cqspi_of_get_flash_pdata(pdev, f_pdata, np);
1643 static int cqspi_jh7110_clk_init(struct platform_device *pdev, struct cqspi_st *cqspi)
1645 static struct clk_bulk_data qspiclk[] = {
1652 ret = devm_clk_bulk_get(&pdev->dev, ARRAY_SIZE(qspiclk), qspiclk);
1654 dev_err(&pdev->dev, "%s: failed to get qspi clocks\n", __func__);
1658 cqspi->clks[CLK_QSPI_APB] = qspiclk[0].clk;
1659 cqspi->clks[CLK_QSPI_AHB] = qspiclk[1].clk;
1661 ret = clk_prepare_enable(cqspi->clks[CLK_QSPI_APB]);
1663 dev_err(&pdev->dev, "%s: failed to enable CLK_QSPI_APB\n", __func__);
1667 ret = clk_prepare_enable(cqspi->clks[CLK_QSPI_AHB]);
1669 dev_err(&pdev->dev, "%s: failed to enable CLK_QSPI_AHB\n", __func__);
1670 goto disable_apb_clk;
1673 cqspi->is_jh7110 = true;
1678 clk_disable_unprepare(cqspi->clks[CLK_QSPI_APB]);
1683 static void cqspi_jh7110_disable_clk(struct platform_device *pdev, struct cqspi_st *cqspi)
1685 clk_disable_unprepare(cqspi->clks[CLK_QSPI_AHB]);
1686 clk_disable_unprepare(cqspi->clks[CLK_QSPI_APB]);
1688 static int cqspi_probe(struct platform_device *pdev)
1690 const struct cqspi_driver_platdata *ddata;
1691 struct reset_control *rstc, *rstc_ocp, *rstc_ref;
1692 struct device *dev = &pdev->dev;
1693 struct spi_controller *host;
1694 struct resource *res_ahb;
1695 struct cqspi_st *cqspi;
1699 host = devm_spi_alloc_host(&pdev->dev, sizeof(*cqspi));
1701 dev_err(&pdev->dev, "devm_spi_alloc_host failed\n");
1704 host->mode_bits = SPI_RX_QUAD | SPI_RX_DUAL;
1705 host->mem_ops = &cqspi_mem_ops;
1706 host->mem_caps = &cqspi_mem_caps;
1707 host->dev.of_node = pdev->dev.of_node;
1709 cqspi = spi_controller_get_devdata(host);
1713 cqspi->is_jh7110 = false;
1714 platform_set_drvdata(pdev, cqspi);
1716 /* Obtain configuration from OF. */
1717 ret = cqspi_of_get_pdata(cqspi);
1719 dev_err(dev, "Cannot get mandatory OF data.\n");
1723 /* Obtain QSPI clock. */
1724 cqspi->clk = devm_clk_get(dev, NULL);
1725 if (IS_ERR(cqspi->clk)) {
1726 dev_err(dev, "Cannot claim QSPI clock.\n");
1727 ret = PTR_ERR(cqspi->clk);
1731 /* Obtain and remap controller address. */
1732 cqspi->iobase = devm_platform_ioremap_resource(pdev, 0);
1733 if (IS_ERR(cqspi->iobase)) {
1734 dev_err(dev, "Cannot remap controller address.\n");
1735 ret = PTR_ERR(cqspi->iobase);
1739 /* Obtain and remap AHB address. */
1740 cqspi->ahb_base = devm_platform_get_and_ioremap_resource(pdev, 1, &res_ahb);
1741 if (IS_ERR(cqspi->ahb_base)) {
1742 dev_err(dev, "Cannot remap AHB address.\n");
1743 ret = PTR_ERR(cqspi->ahb_base);
1746 cqspi->mmap_phys_base = (dma_addr_t)res_ahb->start;
1747 cqspi->ahb_size = resource_size(res_ahb);
1749 init_completion(&cqspi->transfer_complete);
1751 /* Obtain IRQ line. */
1752 irq = platform_get_irq(pdev, 0);
1756 pm_runtime_enable(dev);
1757 ret = pm_runtime_resume_and_get(dev);
1759 goto probe_pm_failed;
1761 ret = clk_prepare_enable(cqspi->clk);
1763 dev_err(dev, "Cannot enable QSPI clock.\n");
1764 goto probe_clk_failed;
1767 /* Obtain QSPI reset control */
1768 rstc = devm_reset_control_get_optional_exclusive(dev, "qspi");
1770 ret = PTR_ERR(rstc);
1771 dev_err(dev, "Cannot get QSPI reset.\n");
1772 goto probe_reset_failed;
1775 rstc_ocp = devm_reset_control_get_optional_exclusive(dev, "qspi-ocp");
1776 if (IS_ERR(rstc_ocp)) {
1777 ret = PTR_ERR(rstc_ocp);
1778 dev_err(dev, "Cannot get QSPI OCP reset.\n");
1779 goto probe_reset_failed;
1782 if (of_device_is_compatible(pdev->dev.of_node, "starfive,jh7110-qspi")) {
1783 rstc_ref = devm_reset_control_get_optional_exclusive(dev, "rstc_ref");
1784 if (IS_ERR(rstc_ref)) {
1785 ret = PTR_ERR(rstc_ref);
1786 dev_err(dev, "Cannot get QSPI REF reset.\n");
1787 goto probe_reset_failed;
1789 reset_control_assert(rstc_ref);
1790 reset_control_deassert(rstc_ref);
1793 reset_control_assert(rstc);
1794 reset_control_deassert(rstc);
1796 reset_control_assert(rstc_ocp);
1797 reset_control_deassert(rstc_ocp);
1799 cqspi->master_ref_clk_hz = clk_get_rate(cqspi->clk);
1800 host->max_speed_hz = cqspi->master_ref_clk_hz;
1802 /* write completion is supported by default */
1803 cqspi->wr_completion = true;
1805 ddata = of_device_get_match_data(dev);
1807 if (ddata->quirks & CQSPI_NEEDS_WR_DELAY)
1808 cqspi->wr_delay = 50 * DIV_ROUND_UP(NSEC_PER_SEC,
1809 cqspi->master_ref_clk_hz);
1810 if (ddata->hwcaps_mask & CQSPI_SUPPORTS_OCTAL)
1811 host->mode_bits |= SPI_RX_OCTAL | SPI_TX_OCTAL;
1812 if (!(ddata->quirks & CQSPI_DISABLE_DAC_MODE)) {
1813 cqspi->use_direct_mode = true;
1814 cqspi->use_direct_mode_wr = true;
1816 if (ddata->quirks & CQSPI_SUPPORT_EXTERNAL_DMA)
1817 cqspi->use_dma_read = true;
1818 if (ddata->quirks & CQSPI_NO_SUPPORT_WR_COMPLETION)
1819 cqspi->wr_completion = false;
1820 if (ddata->quirks & CQSPI_SLOW_SRAM)
1821 cqspi->slow_sram = true;
1822 if (ddata->quirks & CQSPI_NEEDS_APB_AHB_HAZARD_WAR)
1823 cqspi->apb_ahb_hazard = true;
1825 if (ddata->jh7110_clk_init) {
1826 ret = cqspi_jh7110_clk_init(pdev, cqspi);
1828 goto probe_clk_failed;
1831 if (of_device_is_compatible(pdev->dev.of_node,
1832 "xlnx,versal-ospi-1.0")) {
1833 ret = dma_set_mask(&pdev->dev, DMA_BIT_MASK(64));
1835 goto probe_reset_failed;
1839 ret = devm_request_irq(dev, irq, cqspi_irq_handler, 0,
1842 dev_err(dev, "Cannot request IRQ.\n");
1843 goto probe_reset_failed;
1846 cqspi_wait_idle(cqspi);
1847 cqspi_controller_init(cqspi);
1848 cqspi->current_cs = -1;
1851 host->num_chipselect = cqspi->num_chipselect;
1853 ret = cqspi_setup_flash(cqspi);
1855 dev_err(dev, "failed to setup flash parameters %d\n", ret);
1856 goto probe_setup_failed;
1859 if (cqspi->use_direct_mode) {
1860 ret = cqspi_request_mmap_dma(cqspi);
1861 if (ret == -EPROBE_DEFER)
1862 goto probe_setup_failed;
1865 ret = spi_register_controller(host);
1867 dev_err(&pdev->dev, "failed to register SPI ctlr %d\n", ret);
1868 goto probe_setup_failed;
1873 cqspi_controller_enable(cqspi, 0);
1875 clk_disable_unprepare(cqspi->clk);
1877 pm_runtime_put_sync(dev);
1879 pm_runtime_disable(dev);
1883 static void cqspi_remove(struct platform_device *pdev)
1885 struct cqspi_st *cqspi = platform_get_drvdata(pdev);
1887 spi_unregister_controller(cqspi->host);
1888 cqspi_controller_enable(cqspi, 0);
1891 dma_release_channel(cqspi->rx_chan);
1893 clk_disable_unprepare(cqspi->clk);
1895 if (cqspi->is_jh7110)
1896 cqspi_jh7110_disable_clk(pdev, cqspi);
1898 pm_runtime_put_sync(&pdev->dev);
1899 pm_runtime_disable(&pdev->dev);
1902 static int cqspi_suspend(struct device *dev)
1904 struct cqspi_st *cqspi = dev_get_drvdata(dev);
1905 struct spi_controller *host = dev_get_drvdata(dev);
1908 ret = spi_controller_suspend(host);
1909 cqspi_controller_enable(cqspi, 0);
1911 clk_disable_unprepare(cqspi->clk);
1916 static int cqspi_resume(struct device *dev)
1918 struct cqspi_st *cqspi = dev_get_drvdata(dev);
1919 struct spi_controller *host = dev_get_drvdata(dev);
1921 clk_prepare_enable(cqspi->clk);
1922 cqspi_wait_idle(cqspi);
1923 cqspi_controller_init(cqspi);
1925 cqspi->current_cs = -1;
1928 return spi_controller_resume(host);
1931 static DEFINE_SIMPLE_DEV_PM_OPS(cqspi_dev_pm_ops, cqspi_suspend, cqspi_resume);
1933 static const struct cqspi_driver_platdata cdns_qspi = {
1934 .quirks = CQSPI_DISABLE_DAC_MODE,
1937 static const struct cqspi_driver_platdata k2g_qspi = {
1938 .quirks = CQSPI_NEEDS_WR_DELAY,
1941 static const struct cqspi_driver_platdata am654_ospi = {
1942 .hwcaps_mask = CQSPI_SUPPORTS_OCTAL,
1943 .quirks = CQSPI_NEEDS_WR_DELAY,
1946 static const struct cqspi_driver_platdata intel_lgm_qspi = {
1947 .quirks = CQSPI_DISABLE_DAC_MODE,
1950 static const struct cqspi_driver_platdata socfpga_qspi = {
1951 .quirks = CQSPI_DISABLE_DAC_MODE
1952 | CQSPI_NO_SUPPORT_WR_COMPLETION
1956 static const struct cqspi_driver_platdata versal_ospi = {
1957 .hwcaps_mask = CQSPI_SUPPORTS_OCTAL,
1958 .quirks = CQSPI_DISABLE_DAC_MODE | CQSPI_SUPPORT_EXTERNAL_DMA,
1959 .indirect_read_dma = cqspi_versal_indirect_read_dma,
1960 .get_dma_status = cqspi_get_versal_dma_status,
1963 static const struct cqspi_driver_platdata jh7110_qspi = {
1964 .quirks = CQSPI_DISABLE_DAC_MODE,
1965 .jh7110_clk_init = cqspi_jh7110_clk_init,
1968 static const struct cqspi_driver_platdata pensando_cdns_qspi = {
1969 .quirks = CQSPI_NEEDS_APB_AHB_HAZARD_WAR | CQSPI_DISABLE_DAC_MODE,
1972 static const struct of_device_id cqspi_dt_ids[] = {
1974 .compatible = "cdns,qspi-nor",
1978 .compatible = "ti,k2g-qspi",
1982 .compatible = "ti,am654-ospi",
1983 .data = &am654_ospi,
1986 .compatible = "intel,lgm-qspi",
1987 .data = &intel_lgm_qspi,
1990 .compatible = "xlnx,versal-ospi-1.0",
1991 .data = &versal_ospi,
1994 .compatible = "intel,socfpga-qspi",
1995 .data = &socfpga_qspi,
1998 .compatible = "starfive,jh7110-qspi",
1999 .data = &jh7110_qspi,
2002 .compatible = "amd,pensando-elba-qspi",
2003 .data = &pensando_cdns_qspi,
2005 { /* end of table */ }
2008 MODULE_DEVICE_TABLE(of, cqspi_dt_ids);
2010 static struct platform_driver cqspi_platform_driver = {
2011 .probe = cqspi_probe,
2012 .remove_new = cqspi_remove,
2015 .pm = &cqspi_dev_pm_ops,
2016 .of_match_table = cqspi_dt_ids,
2020 module_platform_driver(cqspi_platform_driver);
2022 MODULE_DESCRIPTION("Cadence QSPI Controller Driver");
2023 MODULE_LICENSE("GPL v2");
2024 MODULE_ALIAS("platform:" CQSPI_NAME);
2025 MODULE_AUTHOR("Ley Foon Tan <lftan@altera.com>");
2026 MODULE_AUTHOR("Graham Moore <grmoore@opensource.altera.com>");
2027 MODULE_AUTHOR("Vadivel Murugan R <vadivel.muruganx.ramuthevar@intel.com>");
2028 MODULE_AUTHOR("Vignesh Raghavendra <vigneshr@ti.com>");
2029 MODULE_AUTHOR("Pratyush Yadav <p.yadav@ti.com>");