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