Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 2 | |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 3 | /* |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 4 | * Freescale QuadSPI driver. |
| 5 | * |
| 6 | * Copyright (C) 2013 Freescale Semiconductor, Inc. |
| 7 | * Copyright (C) 2018 Bootlin |
| 8 | * Copyright (C) 2018 exceet electronics GmbH |
| 9 | * Copyright (C) 2018 Kontron Electronics GmbH |
| 10 | * Copyright 2019-2020 NXP |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 11 | * |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 12 | * This driver is a ported version of Linux Freescale QSPI driver taken from |
| 13 | * v5.5-rc1 tag having following information. |
| 14 | * |
| 15 | * Transition to SPI MEM interface: |
| 16 | * Authors: |
| 17 | * Boris Brezillon <bbrezillon@kernel.org> |
| 18 | * Frieder Schrempf <frieder.schrempf@kontron.de> |
| 19 | * Yogesh Gaur <yogeshnarayan.gaur@nxp.com> |
| 20 | * Suresh Gupta <suresh.gupta@nxp.com> |
| 21 | * |
| 22 | * Based on the original fsl-quadspi.c spi-nor driver. |
| 23 | * Transition to spi-mem in spi-fsl-qspi.c |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 24 | */ |
| 25 | |
| 26 | #include <common.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 27 | #include <log.h> |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 28 | #include <asm/io.h> |
Simon Glass | 4dcacfc | 2020-05-10 11:40:13 -0600 | [diff] [blame] | 29 | #include <linux/bitops.h> |
Simon Glass | dbd7954 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 30 | #include <linux/delay.h> |
Simon Glass | 2dc9c34 | 2020-05-10 11:40:01 -0600 | [diff] [blame] | 31 | #include <linux/libfdt.h> |
| 32 | #include <linux/sizes.h> |
| 33 | #include <linux/iopoll.h> |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 34 | #include <dm.h> |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 35 | #include <linux/iopoll.h> |
| 36 | #include <linux/sizes.h> |
| 37 | #include <linux/err.h> |
| 38 | #include <spi.h> |
| 39 | #include <spi-mem.h> |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 40 | |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 41 | DECLARE_GLOBAL_DATA_PTR; |
| 42 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 43 | /* |
| 44 | * The driver only uses one single LUT entry, that is updated on |
| 45 | * each call of exec_op(). Index 0 is preset at boot with a basic |
| 46 | * read operation, so let's use the last entry (15). |
| 47 | */ |
| 48 | #define SEQID_LUT 15 |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 49 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 50 | /* Registers used by the driver */ |
| 51 | #define QUADSPI_MCR 0x00 |
| 52 | #define QUADSPI_MCR_RESERVED_MASK GENMASK(19, 16) |
| 53 | #define QUADSPI_MCR_MDIS_MASK BIT(14) |
| 54 | #define QUADSPI_MCR_CLR_TXF_MASK BIT(11) |
| 55 | #define QUADSPI_MCR_CLR_RXF_MASK BIT(10) |
| 56 | #define QUADSPI_MCR_DDR_EN_MASK BIT(7) |
| 57 | #define QUADSPI_MCR_END_CFG_MASK GENMASK(3, 2) |
| 58 | #define QUADSPI_MCR_SWRSTHD_MASK BIT(1) |
| 59 | #define QUADSPI_MCR_SWRSTSD_MASK BIT(0) |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 60 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 61 | #define QUADSPI_IPCR 0x08 |
| 62 | #define QUADSPI_IPCR_SEQID(x) ((x) << 24) |
| 63 | #define QUADSPI_FLSHCR 0x0c |
| 64 | #define QUADSPI_FLSHCR_TCSS_MASK GENMASK(3, 0) |
| 65 | #define QUADSPI_FLSHCR_TCSH_MASK GENMASK(11, 8) |
| 66 | #define QUADSPI_FLSHCR_TDH_MASK GENMASK(17, 16) |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 67 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 68 | #define QUADSPI_BUF3CR 0x1c |
| 69 | #define QUADSPI_BUF3CR_ALLMST_MASK BIT(31) |
| 70 | #define QUADSPI_BUF3CR_ADATSZ(x) ((x) << 8) |
| 71 | #define QUADSPI_BUF3CR_ADATSZ_MASK GENMASK(15, 8) |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 72 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 73 | #define QUADSPI_BFGENCR 0x20 |
| 74 | #define QUADSPI_BFGENCR_SEQID(x) ((x) << 12) |
Peng Fan | 3a34448 | 2015-01-04 17:07:14 +0800 | [diff] [blame] | 75 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 76 | #define QUADSPI_BUF0IND 0x30 |
| 77 | #define QUADSPI_BUF1IND 0x34 |
| 78 | #define QUADSPI_BUF2IND 0x38 |
| 79 | #define QUADSPI_SFAR 0x100 |
Peng Fan | 3a34448 | 2015-01-04 17:07:14 +0800 | [diff] [blame] | 80 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 81 | #define QUADSPI_SMPR 0x108 |
| 82 | #define QUADSPI_SMPR_DDRSMP_MASK GENMASK(18, 16) |
| 83 | #define QUADSPI_SMPR_FSDLY_MASK BIT(6) |
| 84 | #define QUADSPI_SMPR_FSPHS_MASK BIT(5) |
| 85 | #define QUADSPI_SMPR_HSENA_MASK BIT(0) |
Yuan Yao | d719326 | 2016-03-15 14:36:42 +0800 | [diff] [blame] | 86 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 87 | #define QUADSPI_RBCT 0x110 |
| 88 | #define QUADSPI_RBCT_WMRK_MASK GENMASK(4, 0) |
| 89 | #define QUADSPI_RBCT_RXBRD_USEIPS BIT(8) |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 90 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 91 | #define QUADSPI_TBDR 0x154 |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 92 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 93 | #define QUADSPI_SR 0x15c |
| 94 | #define QUADSPI_SR_IP_ACC_MASK BIT(1) |
| 95 | #define QUADSPI_SR_AHB_ACC_MASK BIT(2) |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 96 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 97 | #define QUADSPI_FR 0x160 |
| 98 | #define QUADSPI_FR_TFF_MASK BIT(0) |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 99 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 100 | #define QUADSPI_RSER 0x164 |
| 101 | #define QUADSPI_RSER_TFIE BIT(0) |
Ye Li | 007b604 | 2019-08-14 11:31:36 +0000 | [diff] [blame] | 102 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 103 | #define QUADSPI_SPTRCLR 0x16c |
| 104 | #define QUADSPI_SPTRCLR_IPPTRC BIT(8) |
| 105 | #define QUADSPI_SPTRCLR_BFPTRC BIT(0) |
Ye Li | 007b604 | 2019-08-14 11:31:36 +0000 | [diff] [blame] | 106 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 107 | #define QUADSPI_SFA1AD 0x180 |
| 108 | #define QUADSPI_SFA2AD 0x184 |
| 109 | #define QUADSPI_SFB1AD 0x188 |
| 110 | #define QUADSPI_SFB2AD 0x18c |
| 111 | #define QUADSPI_RBDR(x) (0x200 + ((x) * 4)) |
Ye Li | 007b604 | 2019-08-14 11:31:36 +0000 | [diff] [blame] | 112 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 113 | #define QUADSPI_LUTKEY 0x300 |
| 114 | #define QUADSPI_LUTKEY_VALUE 0x5AF05AF0 |
| 115 | |
| 116 | #define QUADSPI_LCKCR 0x304 |
| 117 | #define QUADSPI_LCKER_LOCK BIT(0) |
| 118 | #define QUADSPI_LCKER_UNLOCK BIT(1) |
| 119 | |
| 120 | #define QUADSPI_LUT_BASE 0x310 |
| 121 | #define QUADSPI_LUT_OFFSET (SEQID_LUT * 4 * 4) |
| 122 | #define QUADSPI_LUT_REG(idx) \ |
| 123 | (QUADSPI_LUT_BASE + QUADSPI_LUT_OFFSET + (idx) * 4) |
| 124 | |
| 125 | /* Instruction set for the LUT register */ |
| 126 | #define LUT_STOP 0 |
| 127 | #define LUT_CMD 1 |
| 128 | #define LUT_ADDR 2 |
| 129 | #define LUT_DUMMY 3 |
| 130 | #define LUT_MODE 4 |
| 131 | #define LUT_MODE2 5 |
| 132 | #define LUT_MODE4 6 |
| 133 | #define LUT_FSL_READ 7 |
| 134 | #define LUT_FSL_WRITE 8 |
| 135 | #define LUT_JMP_ON_CS 9 |
| 136 | #define LUT_ADDR_DDR 10 |
| 137 | #define LUT_MODE_DDR 11 |
| 138 | #define LUT_MODE2_DDR 12 |
| 139 | #define LUT_MODE4_DDR 13 |
| 140 | #define LUT_FSL_READ_DDR 14 |
| 141 | #define LUT_FSL_WRITE_DDR 15 |
| 142 | #define LUT_DATA_LEARN 16 |
| 143 | |
| 144 | /* |
| 145 | * The PAD definitions for LUT register. |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 146 | * |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 147 | * The pad stands for the number of IO lines [0:3]. |
| 148 | * For example, the quad read needs four IO lines, |
| 149 | * so you should use LUT_PAD(4). |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 150 | */ |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 151 | #define LUT_PAD(x) (fls(x) - 1) |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 152 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 153 | /* |
| 154 | * Macro for constructing the LUT entries with the following |
| 155 | * register layout: |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 156 | * |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 157 | * --------------------------------------------------- |
| 158 | * | INSTR1 | PAD1 | OPRND1 | INSTR0 | PAD0 | OPRND0 | |
| 159 | * --------------------------------------------------- |
| 160 | */ |
| 161 | #define LUT_DEF(idx, ins, pad, opr) \ |
| 162 | ((((ins) << 10) | ((pad) << 8) | (opr)) << (((idx) % 2) * 16)) |
| 163 | |
| 164 | /* Controller needs driver to swap endianness */ |
| 165 | #define QUADSPI_QUIRK_SWAP_ENDIAN BIT(0) |
| 166 | |
| 167 | /* Controller needs 4x internal clock */ |
| 168 | #define QUADSPI_QUIRK_4X_INT_CLK BIT(1) |
| 169 | |
| 170 | /* |
| 171 | * TKT253890, the controller needs the driver to fill the txfifo with |
| 172 | * 16 bytes at least to trigger a data transfer, even though the extra |
| 173 | * data won't be transferred. |
| 174 | */ |
| 175 | #define QUADSPI_QUIRK_TKT253890 BIT(2) |
| 176 | |
| 177 | /* TKT245618, the controller cannot wake up from wait mode */ |
| 178 | #define QUADSPI_QUIRK_TKT245618 BIT(3) |
| 179 | |
| 180 | /* |
| 181 | * Controller adds QSPI_AMBA_BASE (base address of the mapped memory) |
| 182 | * internally. No need to add it when setting SFXXAD and SFAR registers |
| 183 | */ |
| 184 | #define QUADSPI_QUIRK_BASE_INTERNAL BIT(4) |
| 185 | |
| 186 | /* |
| 187 | * Controller uses TDH bits in register QUADSPI_FLSHCR. |
| 188 | * They need to be set in accordance with the DDR/SDR mode. |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 189 | */ |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 190 | #define QUADSPI_QUIRK_USE_TDH_SETTING BIT(5) |
| 191 | |
| 192 | struct fsl_qspi_devtype_data { |
| 193 | unsigned int rxfifo; |
| 194 | unsigned int txfifo; |
| 195 | unsigned int ahb_buf_size; |
| 196 | unsigned int quirks; |
| 197 | bool little_endian; |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 198 | }; |
| 199 | |
Ye Li | 007b604 | 2019-08-14 11:31:36 +0000 | [diff] [blame] | 200 | static const struct fsl_qspi_devtype_data vybrid_data = { |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 201 | .rxfifo = SZ_128, |
| 202 | .txfifo = SZ_64, |
| 203 | .ahb_buf_size = SZ_1K, |
| 204 | .quirks = QUADSPI_QUIRK_SWAP_ENDIAN, |
| 205 | .little_endian = true, |
Ye Li | 007b604 | 2019-08-14 11:31:36 +0000 | [diff] [blame] | 206 | }; |
| 207 | |
| 208 | static const struct fsl_qspi_devtype_data imx6sx_data = { |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 209 | .rxfifo = SZ_128, |
| 210 | .txfifo = SZ_512, |
| 211 | .ahb_buf_size = SZ_1K, |
| 212 | .quirks = QUADSPI_QUIRK_4X_INT_CLK | QUADSPI_QUIRK_TKT245618, |
| 213 | .little_endian = true, |
Ye Li | 007b604 | 2019-08-14 11:31:36 +0000 | [diff] [blame] | 214 | }; |
| 215 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 216 | static const struct fsl_qspi_devtype_data imx7d_data = { |
| 217 | .rxfifo = SZ_128, |
| 218 | .txfifo = SZ_512, |
| 219 | .ahb_buf_size = SZ_1K, |
| 220 | .quirks = QUADSPI_QUIRK_TKT253890 | QUADSPI_QUIRK_4X_INT_CLK | |
| 221 | QUADSPI_QUIRK_USE_TDH_SETTING, |
| 222 | .little_endian = true, |
Ye Li | 007b604 | 2019-08-14 11:31:36 +0000 | [diff] [blame] | 223 | }; |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 224 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 225 | static const struct fsl_qspi_devtype_data imx6ul_data = { |
| 226 | .rxfifo = SZ_128, |
| 227 | .txfifo = SZ_512, |
| 228 | .ahb_buf_size = SZ_1K, |
| 229 | .quirks = QUADSPI_QUIRK_TKT253890 | QUADSPI_QUIRK_4X_INT_CLK | |
| 230 | QUADSPI_QUIRK_USE_TDH_SETTING, |
| 231 | .little_endian = true, |
Ye Li | 57f6775 | 2019-08-14 11:31:40 +0000 | [diff] [blame] | 232 | }; |
| 233 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 234 | static const struct fsl_qspi_devtype_data ls1021a_data = { |
| 235 | .rxfifo = SZ_128, |
| 236 | .txfifo = SZ_64, |
| 237 | .ahb_buf_size = SZ_1K, |
| 238 | .quirks = 0, |
| 239 | .little_endian = false, |
| 240 | }; |
| 241 | |
| 242 | static const struct fsl_qspi_devtype_data ls1088a_data = { |
| 243 | .rxfifo = SZ_128, |
| 244 | .txfifo = SZ_128, |
| 245 | .ahb_buf_size = SZ_1K, |
| 246 | .quirks = QUADSPI_QUIRK_TKT253890, |
| 247 | .little_endian = true, |
| 248 | }; |
| 249 | |
| 250 | static const struct fsl_qspi_devtype_data ls2080a_data = { |
| 251 | .rxfifo = SZ_128, |
| 252 | .txfifo = SZ_64, |
| 253 | .ahb_buf_size = SZ_1K, |
| 254 | .quirks = QUADSPI_QUIRK_TKT253890 | QUADSPI_QUIRK_BASE_INTERNAL, |
| 255 | .little_endian = true, |
| 256 | }; |
| 257 | |
| 258 | struct fsl_qspi { |
| 259 | struct udevice *dev; |
| 260 | void __iomem *iobase; |
| 261 | void __iomem *ahb_addr; |
| 262 | u32 memmap_phy; |
| 263 | const struct fsl_qspi_devtype_data *devtype_data; |
| 264 | int selected; |
| 265 | }; |
| 266 | |
| 267 | static inline int needs_swap_endian(struct fsl_qspi *q) |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 268 | { |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 269 | return q->devtype_data->quirks & QUADSPI_QUIRK_SWAP_ENDIAN; |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 270 | } |
| 271 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 272 | static inline int needs_4x_clock(struct fsl_qspi *q) |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 273 | { |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 274 | return q->devtype_data->quirks & QUADSPI_QUIRK_4X_INT_CLK; |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 275 | } |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 276 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 277 | static inline int needs_fill_txfifo(struct fsl_qspi *q) |
Rajat Srivastava | 234daec | 2018-03-22 13:30:55 +0530 | [diff] [blame] | 278 | { |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 279 | return q->devtype_data->quirks & QUADSPI_QUIRK_TKT253890; |
Rajat Srivastava | 234daec | 2018-03-22 13:30:55 +0530 | [diff] [blame] | 280 | } |
| 281 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 282 | static inline int needs_wakeup_wait_mode(struct fsl_qspi *q) |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 283 | { |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 284 | return q->devtype_data->quirks & QUADSPI_QUIRK_TKT245618; |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 285 | } |
| 286 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 287 | static inline int needs_amba_base_offset(struct fsl_qspi *q) |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 288 | { |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 289 | return !(q->devtype_data->quirks & QUADSPI_QUIRK_BASE_INTERNAL); |
| 290 | } |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 291 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 292 | static inline int needs_tdh_setting(struct fsl_qspi *q) |
| 293 | { |
| 294 | return q->devtype_data->quirks & QUADSPI_QUIRK_USE_TDH_SETTING; |
| 295 | } |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 296 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 297 | /* |
| 298 | * An IC bug makes it necessary to rearrange the 32-bit data. |
| 299 | * Later chips, such as IMX6SLX, have fixed this bug. |
| 300 | */ |
| 301 | static inline u32 fsl_qspi_endian_xchg(struct fsl_qspi *q, u32 a) |
| 302 | { |
| 303 | return needs_swap_endian(q) ? __swab32(a) : a; |
| 304 | } |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 305 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 306 | /* |
| 307 | * R/W functions for big- or little-endian registers: |
| 308 | * The QSPI controller's endianness is independent of |
| 309 | * the CPU core's endianness. So far, although the CPU |
| 310 | * core is little-endian the QSPI controller can use |
| 311 | * big-endian or little-endian. |
| 312 | */ |
| 313 | static void qspi_writel(struct fsl_qspi *q, u32 val, void __iomem *addr) |
| 314 | { |
| 315 | if (q->devtype_data->little_endian) |
| 316 | out_le32(addr, val); |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 317 | else |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 318 | out_be32(addr, val); |
| 319 | } |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 320 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 321 | static u32 qspi_readl(struct fsl_qspi *q, void __iomem *addr) |
| 322 | { |
| 323 | if (q->devtype_data->little_endian) |
| 324 | return in_le32(addr); |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 325 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 326 | return in_be32(addr); |
| 327 | } |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 328 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 329 | static int fsl_qspi_check_buswidth(struct fsl_qspi *q, u8 width) |
| 330 | { |
| 331 | switch (width) { |
| 332 | case 1: |
| 333 | case 2: |
| 334 | case 4: |
| 335 | return 0; |
| 336 | } |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 337 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 338 | return -ENOTSUPP; |
| 339 | } |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 340 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 341 | static bool fsl_qspi_supports_op(struct spi_slave *slave, |
| 342 | const struct spi_mem_op *op) |
| 343 | { |
| 344 | struct fsl_qspi *q = dev_get_priv(slave->dev->parent); |
| 345 | int ret; |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 346 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 347 | ret = fsl_qspi_check_buswidth(q, op->cmd.buswidth); |
Peng Fan | 3642a87 | 2014-12-31 11:01:39 +0800 | [diff] [blame] | 348 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 349 | if (op->addr.nbytes) |
| 350 | ret |= fsl_qspi_check_buswidth(q, op->addr.buswidth); |
Peng Fan | 3a34448 | 2015-01-04 17:07:14 +0800 | [diff] [blame] | 351 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 352 | if (op->dummy.nbytes) |
| 353 | ret |= fsl_qspi_check_buswidth(q, op->dummy.buswidth); |
Peng Fan | 3a34448 | 2015-01-04 17:07:14 +0800 | [diff] [blame] | 354 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 355 | if (op->data.nbytes) |
| 356 | ret |= fsl_qspi_check_buswidth(q, op->data.buswidth); |
Peng Fan | 3a34448 | 2015-01-04 17:07:14 +0800 | [diff] [blame] | 357 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 358 | if (ret) |
| 359 | return false; |
Yuan Yao | d719326 | 2016-03-15 14:36:42 +0800 | [diff] [blame] | 360 | |
| 361 | /* |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 362 | * The number of instructions needed for the op, needs |
| 363 | * to fit into a single LUT entry. |
Yuan Yao | d719326 | 2016-03-15 14:36:42 +0800 | [diff] [blame] | 364 | */ |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 365 | if (op->addr.nbytes + |
| 366 | (op->dummy.nbytes ? 1 : 0) + |
| 367 | (op->data.nbytes ? 1 : 0) > 6) |
| 368 | return false; |
Yuan Yao | d719326 | 2016-03-15 14:36:42 +0800 | [diff] [blame] | 369 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 370 | /* Max 64 dummy clock cycles supported */ |
| 371 | if (op->dummy.nbytes && |
| 372 | (op->dummy.nbytes * 8 / op->dummy.buswidth > 64)) |
| 373 | return false; |
Yuan Yao | d719326 | 2016-03-15 14:36:42 +0800 | [diff] [blame] | 374 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 375 | /* Max data length, check controller limits and alignment */ |
| 376 | if (op->data.dir == SPI_MEM_DATA_IN && |
| 377 | (op->data.nbytes > q->devtype_data->ahb_buf_size || |
| 378 | (op->data.nbytes > q->devtype_data->rxfifo - 4 && |
| 379 | !IS_ALIGNED(op->data.nbytes, 8)))) |
| 380 | return false; |
| 381 | |
| 382 | if (op->data.dir == SPI_MEM_DATA_OUT && |
| 383 | op->data.nbytes > q->devtype_data->txfifo) |
| 384 | return false; |
| 385 | |
| 386 | return true; |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 387 | } |
| 388 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 389 | static void fsl_qspi_prepare_lut(struct fsl_qspi *q, |
| 390 | const struct spi_mem_op *op) |
Peng Fan | 1c5f966 | 2015-01-08 10:40:20 +0800 | [diff] [blame] | 391 | { |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 392 | void __iomem *base = q->iobase; |
| 393 | u32 lutval[4] = {}; |
| 394 | int lutidx = 1, i; |
Peng Fan | 1c5f966 | 2015-01-08 10:40:20 +0800 | [diff] [blame] | 395 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 396 | lutval[0] |= LUT_DEF(0, LUT_CMD, LUT_PAD(op->cmd.buswidth), |
| 397 | op->cmd.opcode); |
Peng Fan | 1c5f966 | 2015-01-08 10:40:20 +0800 | [diff] [blame] | 398 | |
| 399 | /* |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 400 | * For some unknown reason, using LUT_ADDR doesn't work in some |
| 401 | * cases (at least with only one byte long addresses), so |
| 402 | * let's use LUT_MODE to write the address bytes one by one |
Peng Fan | 1c5f966 | 2015-01-08 10:40:20 +0800 | [diff] [blame] | 403 | */ |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 404 | for (i = 0; i < op->addr.nbytes; i++) { |
| 405 | u8 addrbyte = op->addr.val >> (8 * (op->addr.nbytes - i - 1)); |
Peng Fan | 1c5f966 | 2015-01-08 10:40:20 +0800 | [diff] [blame] | 406 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 407 | lutval[lutidx / 2] |= LUT_DEF(lutidx, LUT_MODE, |
| 408 | LUT_PAD(op->addr.buswidth), |
| 409 | addrbyte); |
| 410 | lutidx++; |
| 411 | } |
Peng Fan | 1c5f966 | 2015-01-08 10:40:20 +0800 | [diff] [blame] | 412 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 413 | if (op->dummy.nbytes) { |
| 414 | lutval[lutidx / 2] |= LUT_DEF(lutidx, LUT_DUMMY, |
| 415 | LUT_PAD(op->dummy.buswidth), |
| 416 | op->dummy.nbytes * 8 / |
| 417 | op->dummy.buswidth); |
| 418 | lutidx++; |
| 419 | } |
Peng Fan | 1c5f966 | 2015-01-08 10:40:20 +0800 | [diff] [blame] | 420 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 421 | if (op->data.nbytes) { |
| 422 | lutval[lutidx / 2] |= LUT_DEF(lutidx, |
| 423 | op->data.dir == SPI_MEM_DATA_IN ? |
| 424 | LUT_FSL_READ : LUT_FSL_WRITE, |
| 425 | LUT_PAD(op->data.buswidth), |
| 426 | 0); |
| 427 | lutidx++; |
| 428 | } |
Peng Fan | 1c5f966 | 2015-01-08 10:40:20 +0800 | [diff] [blame] | 429 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 430 | lutval[lutidx / 2] |= LUT_DEF(lutidx, LUT_STOP, 0, 0); |
Peng Fan | 1c5f966 | 2015-01-08 10:40:20 +0800 | [diff] [blame] | 431 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 432 | /* unlock LUT */ |
| 433 | qspi_writel(q, QUADSPI_LUTKEY_VALUE, q->iobase + QUADSPI_LUTKEY); |
| 434 | qspi_writel(q, QUADSPI_LCKER_UNLOCK, q->iobase + QUADSPI_LCKCR); |
Peng Fan | 1c5f966 | 2015-01-08 10:40:20 +0800 | [diff] [blame] | 435 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 436 | dev_dbg(q->dev, "CMD[%x] lutval[0:%x \t 1:%x \t 2:%x \t 3:%x]\n", |
| 437 | op->cmd.opcode, lutval[0], lutval[1], lutval[2], lutval[3]); |
Peng Fan | 1c5f966 | 2015-01-08 10:40:20 +0800 | [diff] [blame] | 438 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 439 | /* fill LUT */ |
| 440 | for (i = 0; i < ARRAY_SIZE(lutval); i++) |
| 441 | qspi_writel(q, lutval[i], base + QUADSPI_LUT_REG(i)); |
Ye Li | 416d2ec | 2019-08-14 11:31:27 +0000 | [diff] [blame] | 442 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 443 | /* lock LUT */ |
| 444 | qspi_writel(q, QUADSPI_LUTKEY_VALUE, q->iobase + QUADSPI_LUTKEY); |
| 445 | qspi_writel(q, QUADSPI_LCKER_LOCK, q->iobase + QUADSPI_LCKCR); |
Peng Fan | 1c5f966 | 2015-01-08 10:40:20 +0800 | [diff] [blame] | 446 | } |
| 447 | |
| 448 | /* |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 449 | * If we have changed the content of the flash by writing or erasing, or if we |
| 450 | * read from flash with a different offset into the page buffer, we need to |
| 451 | * invalidate the AHB buffer. If we do not do so, we may read out the wrong |
| 452 | * data. The spec tells us reset the AHB domain and Serial Flash domain at |
| 453 | * the same time. |
Peng Fan | 1c5f966 | 2015-01-08 10:40:20 +0800 | [diff] [blame] | 454 | */ |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 455 | static void fsl_qspi_invalidate(struct fsl_qspi *q) |
Peng Fan | 1c5f966 | 2015-01-08 10:40:20 +0800 | [diff] [blame] | 456 | { |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 457 | u32 reg; |
Peng Fan | 1c5f966 | 2015-01-08 10:40:20 +0800 | [diff] [blame] | 458 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 459 | reg = qspi_readl(q, q->iobase + QUADSPI_MCR); |
| 460 | reg |= QUADSPI_MCR_SWRSTHD_MASK | QUADSPI_MCR_SWRSTSD_MASK; |
| 461 | qspi_writel(q, reg, q->iobase + QUADSPI_MCR); |
Peng Fan | 1c5f966 | 2015-01-08 10:40:20 +0800 | [diff] [blame] | 462 | |
| 463 | /* |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 464 | * The minimum delay : 1 AHB + 2 SFCK clocks. |
| 465 | * Delay 1 us is enough. |
Peng Fan | 1c5f966 | 2015-01-08 10:40:20 +0800 | [diff] [blame] | 466 | */ |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 467 | udelay(1); |
Peng Fan | 1c5f966 | 2015-01-08 10:40:20 +0800 | [diff] [blame] | 468 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 469 | reg &= ~(QUADSPI_MCR_SWRSTHD_MASK | QUADSPI_MCR_SWRSTSD_MASK); |
| 470 | qspi_writel(q, reg, q->iobase + QUADSPI_MCR); |
Peng Fan | 1c5f966 | 2015-01-08 10:40:20 +0800 | [diff] [blame] | 471 | } |
Peng Fan | 1c5f966 | 2015-01-08 10:40:20 +0800 | [diff] [blame] | 472 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 473 | static void fsl_qspi_select_mem(struct fsl_qspi *q, struct spi_slave *slave) |
Peng Fan | 3a34448 | 2015-01-04 17:07:14 +0800 | [diff] [blame] | 474 | { |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 475 | struct dm_spi_slave_platdata *plat = |
| 476 | dev_get_parent_platdata(slave->dev); |
Peng Fan | 3a34448 | 2015-01-04 17:07:14 +0800 | [diff] [blame] | 477 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 478 | if (q->selected == plat->cs) |
| 479 | return; |
Alexander Stein | 283eb4a | 2017-06-01 09:32:19 +0200 | [diff] [blame] | 480 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 481 | q->selected = plat->cs; |
| 482 | fsl_qspi_invalidate(q); |
Peng Fan | 3a34448 | 2015-01-04 17:07:14 +0800 | [diff] [blame] | 483 | } |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 484 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 485 | static void fsl_qspi_read_ahb(struct fsl_qspi *q, const struct spi_mem_op *op) |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 486 | { |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 487 | memcpy_fromio(op->data.buf.in, |
| 488 | q->ahb_addr + q->selected * q->devtype_data->ahb_buf_size, |
| 489 | op->data.nbytes); |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 490 | } |
| 491 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 492 | static void fsl_qspi_fill_txfifo(struct fsl_qspi *q, |
| 493 | const struct spi_mem_op *op) |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 494 | { |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 495 | void __iomem *base = q->iobase; |
| 496 | int i; |
| 497 | u32 val; |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 498 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 499 | for (i = 0; i < ALIGN_DOWN(op->data.nbytes, 4); i += 4) { |
| 500 | memcpy(&val, op->data.buf.out + i, 4); |
| 501 | val = fsl_qspi_endian_xchg(q, val); |
| 502 | qspi_writel(q, val, base + QUADSPI_TBDR); |
| 503 | } |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 504 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 505 | if (i < op->data.nbytes) { |
| 506 | memcpy(&val, op->data.buf.out + i, op->data.nbytes - i); |
| 507 | val = fsl_qspi_endian_xchg(q, val); |
| 508 | qspi_writel(q, val, base + QUADSPI_TBDR); |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 509 | } |
| 510 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 511 | if (needs_fill_txfifo(q)) { |
| 512 | for (i = op->data.nbytes; i < 16; i += 4) |
| 513 | qspi_writel(q, 0, base + QUADSPI_TBDR); |
| 514 | } |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 515 | } |
| 516 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 517 | static void fsl_qspi_read_rxfifo(struct fsl_qspi *q, |
| 518 | const struct spi_mem_op *op) |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 519 | { |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 520 | void __iomem *base = q->iobase; |
| 521 | int i; |
| 522 | u8 *buf = op->data.buf.in; |
| 523 | u32 val; |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 524 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 525 | for (i = 0; i < ALIGN_DOWN(op->data.nbytes, 4); i += 4) { |
| 526 | val = qspi_readl(q, base + QUADSPI_RBDR(i / 4)); |
| 527 | val = fsl_qspi_endian_xchg(q, val); |
| 528 | memcpy(buf + i, &val, 4); |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 529 | } |
| 530 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 531 | if (i < op->data.nbytes) { |
| 532 | val = qspi_readl(q, base + QUADSPI_RBDR(i / 4)); |
| 533 | val = fsl_qspi_endian_xchg(q, val); |
| 534 | memcpy(buf + i, &val, op->data.nbytes - i); |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 535 | } |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 536 | } |
| 537 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 538 | static int fsl_qspi_readl_poll_tout(struct fsl_qspi *q, void __iomem *base, |
| 539 | u32 mask, u32 delay_us, u32 timeout_us) |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 540 | { |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 541 | u32 reg; |
Alexander Stein | 283eb4a | 2017-06-01 09:32:19 +0200 | [diff] [blame] | 542 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 543 | if (!q->devtype_data->little_endian) |
| 544 | mask = (u32)cpu_to_be32(mask); |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 545 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 546 | return readl_poll_timeout(base, reg, !(reg & mask), timeout_us); |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 547 | } |
| 548 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 549 | static int fsl_qspi_do_op(struct fsl_qspi *q, const struct spi_mem_op *op) |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 550 | { |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 551 | void __iomem *base = q->iobase; |
| 552 | int err = 0; |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 553 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 554 | /* |
| 555 | * Always start the sequence at the same index since we update |
| 556 | * the LUT at each exec_op() call. And also specify the DATA |
| 557 | * length, since it's has not been specified in the LUT. |
| 558 | */ |
| 559 | qspi_writel(q, op->data.nbytes | QUADSPI_IPCR_SEQID(SEQID_LUT), |
| 560 | base + QUADSPI_IPCR); |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 561 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 562 | /* wait for the controller being ready */ |
| 563 | err = fsl_qspi_readl_poll_tout(q, base + QUADSPI_SR, |
| 564 | (QUADSPI_SR_IP_ACC_MASK | |
| 565 | QUADSPI_SR_AHB_ACC_MASK), |
| 566 | 10, 1000); |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 567 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 568 | if (!err && op->data.nbytes && op->data.dir == SPI_MEM_DATA_IN) |
| 569 | fsl_qspi_read_rxfifo(q, op); |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 570 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 571 | return err; |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 572 | } |
| 573 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 574 | static int fsl_qspi_exec_op(struct spi_slave *slave, |
| 575 | const struct spi_mem_op *op) |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 576 | { |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 577 | struct fsl_qspi *q = dev_get_priv(slave->dev->parent); |
| 578 | void __iomem *base = q->iobase; |
| 579 | u32 addr_offset = 0; |
| 580 | int err = 0; |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 581 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 582 | /* wait for the controller being ready */ |
| 583 | fsl_qspi_readl_poll_tout(q, base + QUADSPI_SR, (QUADSPI_SR_IP_ACC_MASK | |
| 584 | QUADSPI_SR_AHB_ACC_MASK), 10, 1000); |
Alexander Stein | 283eb4a | 2017-06-01 09:32:19 +0200 | [diff] [blame] | 585 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 586 | fsl_qspi_select_mem(q, slave); |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 587 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 588 | if (needs_amba_base_offset(q)) |
| 589 | addr_offset = q->memmap_phy; |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 590 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 591 | qspi_writel(q, |
| 592 | q->selected * q->devtype_data->ahb_buf_size + addr_offset, |
| 593 | base + QUADSPI_SFAR); |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 594 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 595 | qspi_writel(q, qspi_readl(q, base + QUADSPI_MCR) | |
| 596 | QUADSPI_MCR_CLR_RXF_MASK | QUADSPI_MCR_CLR_TXF_MASK, |
| 597 | base + QUADSPI_MCR); |
Alison Wang | c7410e3 | 2014-05-06 09:13:01 +0800 | [diff] [blame] | 598 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 599 | qspi_writel(q, QUADSPI_SPTRCLR_BFPTRC | QUADSPI_SPTRCLR_IPPTRC, |
| 600 | base + QUADSPI_SPTRCLR); |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 601 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 602 | fsl_qspi_prepare_lut(q, op); |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 603 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 604 | /* |
| 605 | * If we have large chunks of data, we read them through the AHB bus |
| 606 | * by accessing the mapped memory. In all other cases we use |
| 607 | * IP commands to access the flash. |
| 608 | */ |
| 609 | if (op->data.nbytes > (q->devtype_data->rxfifo - 4) && |
| 610 | op->data.dir == SPI_MEM_DATA_IN) { |
| 611 | fsl_qspi_read_ahb(q, op); |
| 612 | } else { |
| 613 | qspi_writel(q, QUADSPI_RBCT_WMRK_MASK | |
| 614 | QUADSPI_RBCT_RXBRD_USEIPS, base + QUADSPI_RBCT); |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 615 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 616 | if (op->data.nbytes && op->data.dir == SPI_MEM_DATA_OUT) |
| 617 | fsl_qspi_fill_txfifo(q, op); |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 618 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 619 | err = fsl_qspi_do_op(q, op); |
| 620 | } |
| 621 | |
| 622 | /* Invalidate the data in the AHB buffer. */ |
| 623 | fsl_qspi_invalidate(q); |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 624 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 625 | return err; |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 626 | } |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 627 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 628 | static int fsl_qspi_adjust_op_size(struct spi_slave *slave, |
| 629 | struct spi_mem_op *op) |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 630 | { |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 631 | struct fsl_qspi *q = dev_get_priv(slave->dev->parent); |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 632 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 633 | if (op->data.dir == SPI_MEM_DATA_OUT) { |
| 634 | if (op->data.nbytes > q->devtype_data->txfifo) |
| 635 | op->data.nbytes = q->devtype_data->txfifo; |
| 636 | } else { |
| 637 | if (op->data.nbytes > q->devtype_data->ahb_buf_size) |
| 638 | op->data.nbytes = q->devtype_data->ahb_buf_size; |
| 639 | else if (op->data.nbytes > (q->devtype_data->rxfifo - 4)) |
| 640 | op->data.nbytes = ALIGN_DOWN(op->data.nbytes, 8); |
| 641 | } |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 642 | |
| 643 | return 0; |
| 644 | } |
| 645 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 646 | static int fsl_qspi_default_setup(struct fsl_qspi *q) |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 647 | { |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 648 | void __iomem *base = q->iobase; |
| 649 | u32 reg, addr_offset = 0; |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 650 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 651 | /* Reset the module */ |
| 652 | qspi_writel(q, QUADSPI_MCR_SWRSTSD_MASK | QUADSPI_MCR_SWRSTHD_MASK, |
| 653 | base + QUADSPI_MCR); |
| 654 | udelay(1); |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 655 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 656 | /* Disable the module */ |
| 657 | qspi_writel(q, QUADSPI_MCR_MDIS_MASK | QUADSPI_MCR_RESERVED_MASK, |
| 658 | base + QUADSPI_MCR); |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 659 | |
Yuan Yao | ae41239 | 2016-03-15 14:36:40 +0800 | [diff] [blame] | 660 | /* |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 661 | * Previous boot stages (BootROM, bootloader) might have used DDR |
| 662 | * mode and did not clear the TDH bits. As we currently use SDR mode |
| 663 | * only, clear the TDH bits if necessary. |
Yuan Yao | ae41239 | 2016-03-15 14:36:40 +0800 | [diff] [blame] | 664 | */ |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 665 | if (needs_tdh_setting(q)) |
| 666 | qspi_writel(q, qspi_readl(q, base + QUADSPI_FLSHCR) & |
| 667 | ~QUADSPI_FLSHCR_TDH_MASK, |
| 668 | base + QUADSPI_FLSHCR); |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 669 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 670 | reg = qspi_readl(q, base + QUADSPI_SMPR); |
| 671 | qspi_writel(q, reg & ~(QUADSPI_SMPR_FSDLY_MASK |
| 672 | | QUADSPI_SMPR_FSPHS_MASK |
| 673 | | QUADSPI_SMPR_HSENA_MASK |
| 674 | | QUADSPI_SMPR_DDRSMP_MASK), base + QUADSPI_SMPR); |
Ye Li | 007b604 | 2019-08-14 11:31:36 +0000 | [diff] [blame] | 675 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 676 | /* We only use the buffer3 for AHB read */ |
| 677 | qspi_writel(q, 0, base + QUADSPI_BUF0IND); |
| 678 | qspi_writel(q, 0, base + QUADSPI_BUF1IND); |
| 679 | qspi_writel(q, 0, base + QUADSPI_BUF2IND); |
Suresh Gupta | 4945b87 | 2017-08-30 20:06:33 +0530 | [diff] [blame] | 680 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 681 | qspi_writel(q, QUADSPI_BFGENCR_SEQID(SEQID_LUT), |
| 682 | q->iobase + QUADSPI_BFGENCR); |
| 683 | qspi_writel(q, QUADSPI_RBCT_WMRK_MASK, base + QUADSPI_RBCT); |
| 684 | qspi_writel(q, QUADSPI_BUF3CR_ALLMST_MASK | |
| 685 | QUADSPI_BUF3CR_ADATSZ(q->devtype_data->ahb_buf_size / 8), |
| 686 | base + QUADSPI_BUF3CR); |
Suresh Gupta | 4945b87 | 2017-08-30 20:06:33 +0530 | [diff] [blame] | 687 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 688 | if (needs_amba_base_offset(q)) |
| 689 | addr_offset = q->memmap_phy; |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 690 | |
Yuan Yao | b4bfe10 | 2016-03-15 14:36:41 +0800 | [diff] [blame] | 691 | /* |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 692 | * In HW there can be a maximum of four chips on two buses with |
| 693 | * two chip selects on each bus. We use four chip selects in SW |
| 694 | * to differentiate between the four chips. |
| 695 | * We use ahb_buf_size for each chip and set SFA1AD, SFA2AD, SFB1AD, |
| 696 | * SFB2AD accordingly. |
Yuan Yao | b4bfe10 | 2016-03-15 14:36:41 +0800 | [diff] [blame] | 697 | */ |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 698 | qspi_writel(q, q->devtype_data->ahb_buf_size + addr_offset, |
| 699 | base + QUADSPI_SFA1AD); |
| 700 | qspi_writel(q, q->devtype_data->ahb_buf_size * 2 + addr_offset, |
| 701 | base + QUADSPI_SFA2AD); |
| 702 | qspi_writel(q, q->devtype_data->ahb_buf_size * 3 + addr_offset, |
| 703 | base + QUADSPI_SFB1AD); |
| 704 | qspi_writel(q, q->devtype_data->ahb_buf_size * 4 + addr_offset, |
| 705 | base + QUADSPI_SFB2AD); |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 706 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 707 | q->selected = -1; |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 708 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 709 | /* Enable the module */ |
| 710 | qspi_writel(q, QUADSPI_MCR_RESERVED_MASK | QUADSPI_MCR_END_CFG_MASK, |
| 711 | base + QUADSPI_MCR); |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 712 | return 0; |
| 713 | } |
| 714 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 715 | static const struct spi_controller_mem_ops fsl_qspi_mem_ops = { |
| 716 | .adjust_op_size = fsl_qspi_adjust_op_size, |
| 717 | .supports_op = fsl_qspi_supports_op, |
| 718 | .exec_op = fsl_qspi_exec_op, |
| 719 | }; |
| 720 | |
| 721 | static int fsl_qspi_probe(struct udevice *bus) |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 722 | { |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 723 | struct dm_spi_bus *dm_bus = bus->uclass_priv; |
| 724 | struct fsl_qspi *q = dev_get_priv(bus); |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 725 | const void *blob = gd->fdt_blob; |
Simon Glass | dd79d6e | 2017-01-17 16:52:55 -0700 | [diff] [blame] | 726 | int node = dev_of_offset(bus); |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 727 | struct fdt_resource res; |
| 728 | int ret; |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 729 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 730 | q->dev = bus; |
| 731 | q->devtype_data = (struct fsl_qspi_devtype_data *) |
| 732 | dev_get_driver_data(bus); |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 733 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 734 | /* find the resources */ |
| 735 | ret = fdt_get_named_resource(blob, node, "reg", "reg-names", "QuadSPI", |
| 736 | &res); |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 737 | if (ret) { |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 738 | dev_err(bus, "Can't get regs base addresses(ret = %d)!\n", ret); |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 739 | return -ENOMEM; |
| 740 | } |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 741 | |
| 742 | q->iobase = map_physmem(res.start, res.end - res.start, MAP_NOCACHE); |
| 743 | |
Yuan Yao | ae41239 | 2016-03-15 14:36:40 +0800 | [diff] [blame] | 744 | ret = fdt_get_named_resource(blob, node, "reg", "reg-names", |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 745 | "QuadSPI-memory", &res); |
Yuan Yao | ae41239 | 2016-03-15 14:36:40 +0800 | [diff] [blame] | 746 | if (ret) { |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 747 | dev_err(bus, "Can't get AMBA base addresses(ret = %d)!\n", ret); |
Yuan Yao | ae41239 | 2016-03-15 14:36:40 +0800 | [diff] [blame] | 748 | return -ENOMEM; |
| 749 | } |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 750 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 751 | q->ahb_addr = map_physmem(res.start, res.end - res.start, MAP_NOCACHE); |
| 752 | q->memmap_phy = res.start; |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 753 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 754 | dm_bus->max_hz = fdtdec_get_int(blob, node, "spi-max-frequency", |
| 755 | 66000000); |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 756 | |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 757 | fsl_qspi_default_setup(q); |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 758 | |
| 759 | return 0; |
| 760 | } |
| 761 | |
| 762 | static int fsl_qspi_xfer(struct udevice *dev, unsigned int bitlen, |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 763 | const void *dout, void *din, unsigned long flags) |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 764 | { |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 765 | return 0; |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 766 | } |
| 767 | |
| 768 | static int fsl_qspi_claim_bus(struct udevice *dev) |
| 769 | { |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 770 | return 0; |
| 771 | } |
| 772 | |
| 773 | static int fsl_qspi_release_bus(struct udevice *dev) |
| 774 | { |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 775 | return 0; |
| 776 | } |
| 777 | |
| 778 | static int fsl_qspi_set_speed(struct udevice *bus, uint speed) |
| 779 | { |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 780 | return 0; |
| 781 | } |
| 782 | |
| 783 | static int fsl_qspi_set_mode(struct udevice *bus, uint mode) |
| 784 | { |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 785 | return 0; |
| 786 | } |
| 787 | |
| 788 | static const struct dm_spi_ops fsl_qspi_ops = { |
| 789 | .claim_bus = fsl_qspi_claim_bus, |
| 790 | .release_bus = fsl_qspi_release_bus, |
| 791 | .xfer = fsl_qspi_xfer, |
| 792 | .set_speed = fsl_qspi_set_speed, |
| 793 | .set_mode = fsl_qspi_set_mode, |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 794 | .mem_ops = &fsl_qspi_mem_ops, |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 795 | }; |
| 796 | |
| 797 | static const struct udevice_id fsl_qspi_ids[] = { |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 798 | { .compatible = "fsl,vf610-qspi", .data = (ulong)&vybrid_data, }, |
| 799 | { .compatible = "fsl,imx6sx-qspi", .data = (ulong)&imx6sx_data, }, |
| 800 | { .compatible = "fsl,imx6ul-qspi", .data = (ulong)&imx6ul_data, }, |
| 801 | { .compatible = "fsl,imx7d-qspi", .data = (ulong)&imx7d_data, }, |
| 802 | { .compatible = "fsl,ls1021a-qspi", .data = (ulong)&ls1021a_data, }, |
| 803 | { .compatible = "fsl,ls1088a-qspi", .data = (ulong)&ls1088a_data, }, |
| 804 | { .compatible = "fsl,ls2080a-qspi", .data = (ulong)&ls2080a_data, }, |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 805 | { } |
| 806 | }; |
| 807 | |
| 808 | U_BOOT_DRIVER(fsl_qspi) = { |
| 809 | .name = "fsl_qspi", |
| 810 | .id = UCLASS_SPI, |
| 811 | .of_match = fsl_qspi_ids, |
| 812 | .ops = &fsl_qspi_ops, |
Kuldeep Singh | d8429a1 | 2020-02-20 22:57:52 +0530 | [diff] [blame] | 813 | .priv_auto_alloc_size = sizeof(struct fsl_qspi), |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 814 | .probe = fsl_qspi_probe, |
Haikun.Wang@freescale.com | 221f2e1 | 2015-04-01 11:10:40 +0800 | [diff] [blame] | 815 | }; |