Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Prafulla Wadaskar | 5710de4 | 2009-05-30 01:13:33 +0530 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2009 |
| 4 | * Marvell Semiconductor <www.marvell.com> |
| 5 | * Written-by: Prafulla Wadaskar <prafulla@marvell.com> |
| 6 | * |
| 7 | * Derived from drivers/spi/mpc8xxx_spi.c |
Prafulla Wadaskar | 5710de4 | 2009-05-30 01:13:33 +0530 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #include <common.h> |
Stefan Roese | 9985bdb | 2015-11-20 13:39:43 +0100 | [diff] [blame] | 11 | #include <dm.h> |
Simon Glass | f7ae49f | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 12 | #include <log.h> |
Prafulla Wadaskar | 5710de4 | 2009-05-30 01:13:33 +0530 | [diff] [blame] | 13 | #include <malloc.h> |
| 14 | #include <spi.h> |
Lei Wen | a7efd71 | 2011-10-18 20:11:42 +0530 | [diff] [blame] | 15 | #include <asm/io.h> |
Stefan Roese | 3dc23f7 | 2014-10-22 12:13:06 +0200 | [diff] [blame] | 16 | #include <asm/arch/soc.h> |
Trevor Woerner | bb0fb4c | 2020-05-06 08:02:40 -0400 | [diff] [blame] | 17 | #ifdef CONFIG_ARCH_KIRKWOOD |
Prafulla Wadaskar | 5710de4 | 2009-05-30 01:13:33 +0530 | [diff] [blame] | 18 | #include <asm/arch/mpp.h> |
Stefan Roese | 4aceea2 | 2014-10-22 12:13:10 +0200 | [diff] [blame] | 19 | #endif |
Stefan Roese | 3e972cb | 2014-10-22 12:13:07 +0200 | [diff] [blame] | 20 | #include <asm/arch-mvebu/spi.h> |
Prafulla Wadaskar | 5710de4 | 2009-05-30 01:13:33 +0530 | [diff] [blame] | 21 | |
Stefan Roese | 9985bdb | 2015-11-20 13:39:43 +0100 | [diff] [blame] | 22 | static void _spi_cs_activate(struct kwspi_registers *reg) |
| 23 | { |
| 24 | setbits_le32(®->ctrl, KWSPI_CSN_ACT); |
| 25 | } |
| 26 | |
| 27 | static void _spi_cs_deactivate(struct kwspi_registers *reg) |
| 28 | { |
| 29 | clrbits_le32(®->ctrl, KWSPI_CSN_ACT); |
| 30 | } |
| 31 | |
| 32 | static int _spi_xfer(struct kwspi_registers *reg, unsigned int bitlen, |
| 33 | const void *dout, void *din, unsigned long flags) |
| 34 | { |
| 35 | unsigned int tmpdout, tmpdin; |
| 36 | int tm, isread = 0; |
| 37 | |
| 38 | debug("spi_xfer: dout %p din %p bitlen %u\n", dout, din, bitlen); |
| 39 | |
| 40 | if (flags & SPI_XFER_BEGIN) |
| 41 | _spi_cs_activate(reg); |
| 42 | |
| 43 | /* |
| 44 | * handle data in 8-bit chunks |
| 45 | * TBD: 2byte xfer mode to be enabled |
| 46 | */ |
| 47 | clrsetbits_le32(®->cfg, KWSPI_XFERLEN_MASK, KWSPI_XFERLEN_1BYTE); |
| 48 | |
| 49 | while (bitlen > 4) { |
| 50 | debug("loopstart bitlen %d\n", bitlen); |
| 51 | tmpdout = 0; |
| 52 | |
| 53 | /* Shift data so it's msb-justified */ |
| 54 | if (dout) |
| 55 | tmpdout = *(u32 *)dout & 0xff; |
| 56 | |
| 57 | clrbits_le32(®->irq_cause, KWSPI_SMEMRDIRQ); |
| 58 | writel(tmpdout, ®->dout); /* Write the data out */ |
| 59 | debug("*** spi_xfer: ... %08x written, bitlen %d\n", |
| 60 | tmpdout, bitlen); |
| 61 | |
| 62 | /* |
| 63 | * Wait for SPI transmit to get out |
| 64 | * or time out (1 second = 1000 ms) |
| 65 | * The NE event must be read and cleared first |
| 66 | */ |
| 67 | for (tm = 0, isread = 0; tm < KWSPI_TIMEOUT; ++tm) { |
| 68 | if (readl(®->irq_cause) & KWSPI_SMEMRDIRQ) { |
| 69 | isread = 1; |
| 70 | tmpdin = readl(®->din); |
| 71 | debug("spi_xfer: din %p..%08x read\n", |
| 72 | din, tmpdin); |
| 73 | |
| 74 | if (din) { |
| 75 | *((u8 *)din) = (u8)tmpdin; |
| 76 | din += 1; |
| 77 | } |
| 78 | if (dout) |
| 79 | dout += 1; |
| 80 | bitlen -= 8; |
| 81 | } |
| 82 | if (isread) |
| 83 | break; |
| 84 | } |
| 85 | if (tm >= KWSPI_TIMEOUT) |
| 86 | printf("*** spi_xfer: Time out during SPI transfer\n"); |
| 87 | |
| 88 | debug("loopend bitlen %d\n", bitlen); |
| 89 | } |
| 90 | |
| 91 | if (flags & SPI_XFER_END) |
| 92 | _spi_cs_deactivate(reg); |
| 93 | |
| 94 | return 0; |
| 95 | } |
| 96 | |
| 97 | #ifndef CONFIG_DM_SPI |
| 98 | |
Stefan Roese | 4fd7717 | 2014-10-22 12:13:12 +0200 | [diff] [blame] | 99 | static struct kwspi_registers *spireg = |
| 100 | (struct kwspi_registers *)MVEBU_SPI_BASE; |
Prafulla Wadaskar | 5710de4 | 2009-05-30 01:13:33 +0530 | [diff] [blame] | 101 | |
Trevor Woerner | bb0fb4c | 2020-05-06 08:02:40 -0400 | [diff] [blame] | 102 | #ifdef CONFIG_ARCH_KIRKWOOD |
Stefan Roese | 0299046 | 2014-09-02 14:02:52 +0200 | [diff] [blame] | 103 | static u32 cs_spi_mpp_back[2]; |
Stefan Roese | 4aceea2 | 2014-10-22 12:13:10 +0200 | [diff] [blame] | 104 | #endif |
Valentin Longchamp | ca88067 | 2012-06-01 01:31:01 +0000 | [diff] [blame] | 105 | |
Prafulla Wadaskar | 5710de4 | 2009-05-30 01:13:33 +0530 | [diff] [blame] | 106 | struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs, |
| 107 | unsigned int max_hz, unsigned int mode) |
| 108 | { |
| 109 | struct spi_slave *slave; |
| 110 | u32 data; |
Trevor Woerner | bb0fb4c | 2020-05-06 08:02:40 -0400 | [diff] [blame] | 111 | #ifdef CONFIG_ARCH_KIRKWOOD |
Albert ARIBAUD | 9d86f0c | 2012-11-26 11:27:36 +0000 | [diff] [blame] | 112 | static const u32 kwspi_mpp_config[2][2] = { |
| 113 | { MPP0_SPI_SCn, 0 }, /* if cs == 0 */ |
| 114 | { MPP7_SPI_SCn, 0 } /* if cs != 0 */ |
| 115 | }; |
Stefan Roese | 4aceea2 | 2014-10-22 12:13:10 +0200 | [diff] [blame] | 116 | #endif |
Prafulla Wadaskar | 5710de4 | 2009-05-30 01:13:33 +0530 | [diff] [blame] | 117 | |
| 118 | if (!spi_cs_is_valid(bus, cs)) |
| 119 | return NULL; |
| 120 | |
Simon Glass | d3504fe | 2013-03-18 19:23:40 +0000 | [diff] [blame] | 121 | slave = spi_alloc_slave_base(bus, cs); |
Prafulla Wadaskar | 5710de4 | 2009-05-30 01:13:33 +0530 | [diff] [blame] | 122 | if (!slave) |
| 123 | return NULL; |
| 124 | |
Stefan Roese | c032174 | 2014-09-02 14:02:51 +0200 | [diff] [blame] | 125 | writel(KWSPI_SMEMRDY, &spireg->ctrl); |
Prafulla Wadaskar | 5710de4 | 2009-05-30 01:13:33 +0530 | [diff] [blame] | 126 | |
| 127 | /* calculate spi clock prescaller using max_hz */ |
Valentin Longchamp | 8203b20 | 2012-08-15 05:31:49 +0000 | [diff] [blame] | 128 | data = ((CONFIG_SYS_TCLK / 2) / max_hz) + 0x10; |
| 129 | data = data < KWSPI_CLKPRESCL_MIN ? KWSPI_CLKPRESCL_MIN : data; |
| 130 | data = data > KWSPI_CLKPRESCL_MASK ? KWSPI_CLKPRESCL_MASK : data; |
Prafulla Wadaskar | 5710de4 | 2009-05-30 01:13:33 +0530 | [diff] [blame] | 131 | |
| 132 | /* program spi clock prescaller using max_hz */ |
| 133 | writel(KWSPI_ADRLEN_3BYTE | data, &spireg->cfg); |
Stefan Roese | bf9b86d | 2014-09-02 14:02:53 +0200 | [diff] [blame] | 134 | debug("data = 0x%08x\n", data); |
Prafulla Wadaskar | 5710de4 | 2009-05-30 01:13:33 +0530 | [diff] [blame] | 135 | |
| 136 | writel(KWSPI_SMEMRDIRQ, &spireg->irq_cause); |
Ian Campbell | 3f84355 | 2012-01-12 06:10:22 +0000 | [diff] [blame] | 137 | writel(KWSPI_IRQMASK, &spireg->irq_mask); |
Prafulla Wadaskar | 5710de4 | 2009-05-30 01:13:33 +0530 | [diff] [blame] | 138 | |
Trevor Woerner | bb0fb4c | 2020-05-06 08:02:40 -0400 | [diff] [blame] | 139 | #ifdef CONFIG_ARCH_KIRKWOOD |
Prafulla Wadaskar | 5710de4 | 2009-05-30 01:13:33 +0530 | [diff] [blame] | 140 | /* program mpp registers to select SPI_CSn */ |
Albert ARIBAUD | 9d86f0c | 2012-11-26 11:27:36 +0000 | [diff] [blame] | 141 | kirkwood_mpp_conf(kwspi_mpp_config[cs ? 1 : 0], cs_spi_mpp_back); |
Stefan Roese | 4aceea2 | 2014-10-22 12:13:10 +0200 | [diff] [blame] | 142 | #endif |
Prafulla Wadaskar | 5710de4 | 2009-05-30 01:13:33 +0530 | [diff] [blame] | 143 | |
| 144 | return slave; |
| 145 | } |
| 146 | |
| 147 | void spi_free_slave(struct spi_slave *slave) |
| 148 | { |
Trevor Woerner | bb0fb4c | 2020-05-06 08:02:40 -0400 | [diff] [blame] | 149 | #ifdef CONFIG_ARCH_KIRKWOOD |
Valentin Longchamp | ca88067 | 2012-06-01 01:31:01 +0000 | [diff] [blame] | 150 | kirkwood_mpp_conf(cs_spi_mpp_back, NULL); |
Stefan Roese | 4aceea2 | 2014-10-22 12:13:10 +0200 | [diff] [blame] | 151 | #endif |
Prafulla Wadaskar | 5710de4 | 2009-05-30 01:13:33 +0530 | [diff] [blame] | 152 | free(slave); |
| 153 | } |
| 154 | |
Valentin Longchamp | 24934fe | 2012-06-01 01:31:03 +0000 | [diff] [blame] | 155 | __attribute__((weak)) int board_spi_claim_bus(struct spi_slave *slave) |
| 156 | { |
| 157 | return 0; |
| 158 | } |
| 159 | |
Prafulla Wadaskar | 5710de4 | 2009-05-30 01:13:33 +0530 | [diff] [blame] | 160 | int spi_claim_bus(struct spi_slave *slave) |
| 161 | { |
Valentin Longchamp | 24934fe | 2012-06-01 01:31:03 +0000 | [diff] [blame] | 162 | return board_spi_claim_bus(slave); |
| 163 | } |
| 164 | |
| 165 | __attribute__((weak)) void board_spi_release_bus(struct spi_slave *slave) |
| 166 | { |
Prafulla Wadaskar | 5710de4 | 2009-05-30 01:13:33 +0530 | [diff] [blame] | 167 | } |
| 168 | |
| 169 | void spi_release_bus(struct spi_slave *slave) |
| 170 | { |
Valentin Longchamp | 24934fe | 2012-06-01 01:31:03 +0000 | [diff] [blame] | 171 | board_spi_release_bus(slave); |
Prafulla Wadaskar | 5710de4 | 2009-05-30 01:13:33 +0530 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | #ifndef CONFIG_SPI_CS_IS_VALID |
| 175 | /* |
| 176 | * you can define this function board specific |
| 177 | * define above CONFIG in board specific config file and |
| 178 | * provide the function in board specific src file |
| 179 | */ |
| 180 | int spi_cs_is_valid(unsigned int bus, unsigned int cs) |
| 181 | { |
Stefan Roese | bf9b86d | 2014-09-02 14:02:53 +0200 | [diff] [blame] | 182 | return bus == 0 && (cs == 0 || cs == 1); |
Prafulla Wadaskar | 5710de4 | 2009-05-30 01:13:33 +0530 | [diff] [blame] | 183 | } |
| 184 | #endif |
| 185 | |
| 186 | void spi_cs_activate(struct spi_slave *slave) |
| 187 | { |
Stefan Roese | 18dd3b2 | 2015-11-20 08:44:21 +0100 | [diff] [blame] | 188 | _spi_cs_activate(spireg); |
Prafulla Wadaskar | 5710de4 | 2009-05-30 01:13:33 +0530 | [diff] [blame] | 189 | } |
| 190 | |
| 191 | void spi_cs_deactivate(struct spi_slave *slave) |
| 192 | { |
Stefan Roese | 18dd3b2 | 2015-11-20 08:44:21 +0100 | [diff] [blame] | 193 | _spi_cs_deactivate(spireg); |
Prafulla Wadaskar | 5710de4 | 2009-05-30 01:13:33 +0530 | [diff] [blame] | 194 | } |
| 195 | |
Stefan Roese | 18dd3b2 | 2015-11-20 08:44:21 +0100 | [diff] [blame] | 196 | int spi_xfer(struct spi_slave *slave, unsigned int bitlen, |
| 197 | const void *dout, void *din, unsigned long flags) |
| 198 | { |
| 199 | return _spi_xfer(spireg, bitlen, dout, din, flags); |
| 200 | } |
Stefan Roese | 9985bdb | 2015-11-20 13:39:43 +0100 | [diff] [blame] | 201 | |
| 202 | #else |
| 203 | |
| 204 | /* Here now the DM part */ |
| 205 | |
Chris Packham | df16881 | 2018-01-22 22:44:20 +1300 | [diff] [blame] | 206 | struct mvebu_spi_dev { |
| 207 | bool is_errata_50mhz_ac; |
| 208 | }; |
| 209 | |
Stefan Roese | 9985bdb | 2015-11-20 13:39:43 +0100 | [diff] [blame] | 210 | struct mvebu_spi_platdata { |
| 211 | struct kwspi_registers *spireg; |
Jagan Teki | f5ff46f | 2018-03-15 17:03:22 +0530 | [diff] [blame] | 212 | bool is_errata_50mhz_ac; |
Stefan Roese | 9985bdb | 2015-11-20 13:39:43 +0100 | [diff] [blame] | 213 | }; |
| 214 | |
| 215 | struct mvebu_spi_priv { |
| 216 | struct kwspi_registers *spireg; |
| 217 | }; |
| 218 | |
| 219 | static int mvebu_spi_set_speed(struct udevice *bus, uint hz) |
| 220 | { |
| 221 | struct mvebu_spi_platdata *plat = dev_get_platdata(bus); |
| 222 | struct kwspi_registers *reg = plat->spireg; |
| 223 | u32 data; |
| 224 | |
| 225 | /* calculate spi clock prescaller using max_hz */ |
| 226 | data = ((CONFIG_SYS_TCLK / 2) / hz) + 0x10; |
| 227 | data = data < KWSPI_CLKPRESCL_MIN ? KWSPI_CLKPRESCL_MIN : data; |
| 228 | data = data > KWSPI_CLKPRESCL_MASK ? KWSPI_CLKPRESCL_MASK : data; |
| 229 | |
| 230 | /* program spi clock prescaler using max_hz */ |
| 231 | writel(KWSPI_ADRLEN_3BYTE | data, ®->cfg); |
| 232 | debug("data = 0x%08x\n", data); |
| 233 | |
| 234 | return 0; |
| 235 | } |
| 236 | |
Chris Packham | df16881 | 2018-01-22 22:44:20 +1300 | [diff] [blame] | 237 | static void mvebu_spi_50mhz_ac_timing_erratum(struct udevice *bus, uint mode) |
| 238 | { |
| 239 | struct mvebu_spi_platdata *plat = dev_get_platdata(bus); |
| 240 | struct kwspi_registers *reg = plat->spireg; |
| 241 | u32 data; |
| 242 | |
| 243 | /* |
| 244 | * Erratum description: (Erratum NO. FE-9144572) The device |
| 245 | * SPI interface supports frequencies of up to 50 MHz. |
| 246 | * However, due to this erratum, when the device core clock is |
| 247 | * 250 MHz and the SPI interfaces is configured for 50MHz SPI |
| 248 | * clock and CPOL=CPHA=1 there might occur data corruption on |
| 249 | * reads from the SPI device. |
| 250 | * Erratum Workaround: |
| 251 | * Work in one of the following configurations: |
| 252 | * 1. Set CPOL=CPHA=0 in "SPI Interface Configuration |
| 253 | * Register". |
| 254 | * 2. Set TMISO_SAMPLE value to 0x2 in "SPI Timing Parameters 1 |
| 255 | * Register" before setting the interface. |
| 256 | */ |
| 257 | data = readl(®->timing1); |
| 258 | data &= ~KW_SPI_TMISO_SAMPLE_MASK; |
| 259 | |
| 260 | if (CONFIG_SYS_TCLK == 250000000 && |
| 261 | mode & SPI_CPOL && |
| 262 | mode & SPI_CPHA) |
| 263 | data |= KW_SPI_TMISO_SAMPLE_2; |
| 264 | else |
| 265 | data |= KW_SPI_TMISO_SAMPLE_1; |
| 266 | |
| 267 | writel(data, ®->timing1); |
| 268 | } |
| 269 | |
Stefan Roese | 9985bdb | 2015-11-20 13:39:43 +0100 | [diff] [blame] | 270 | static int mvebu_spi_set_mode(struct udevice *bus, uint mode) |
| 271 | { |
Chris Packham | ebfa18c | 2016-10-27 21:16:05 +1300 | [diff] [blame] | 272 | struct mvebu_spi_platdata *plat = dev_get_platdata(bus); |
| 273 | struct kwspi_registers *reg = plat->spireg; |
| 274 | u32 data = readl(®->cfg); |
| 275 | |
| 276 | data &= ~(KWSPI_CPHA | KWSPI_CPOL | KWSPI_RXLSBF | KWSPI_TXLSBF); |
| 277 | |
| 278 | if (mode & SPI_CPHA) |
| 279 | data |= KWSPI_CPHA; |
| 280 | if (mode & SPI_CPOL) |
| 281 | data |= KWSPI_CPOL; |
| 282 | if (mode & SPI_LSB_FIRST) |
| 283 | data |= (KWSPI_RXLSBF | KWSPI_TXLSBF); |
| 284 | |
| 285 | writel(data, ®->cfg); |
| 286 | |
Jagan Teki | f5ff46f | 2018-03-15 17:03:22 +0530 | [diff] [blame] | 287 | if (plat->is_errata_50mhz_ac) |
Chris Packham | df16881 | 2018-01-22 22:44:20 +1300 | [diff] [blame] | 288 | mvebu_spi_50mhz_ac_timing_erratum(bus, mode); |
| 289 | |
Stefan Roese | 9985bdb | 2015-11-20 13:39:43 +0100 | [diff] [blame] | 290 | return 0; |
| 291 | } |
| 292 | |
| 293 | static int mvebu_spi_xfer(struct udevice *dev, unsigned int bitlen, |
| 294 | const void *dout, void *din, unsigned long flags) |
| 295 | { |
| 296 | struct udevice *bus = dev->parent; |
| 297 | struct mvebu_spi_platdata *plat = dev_get_platdata(bus); |
| 298 | |
| 299 | return _spi_xfer(plat->spireg, bitlen, dout, din, flags); |
| 300 | } |
| 301 | |
Pascal Linder | f169653 | 2019-06-18 08:41:01 +0200 | [diff] [blame] | 302 | __attribute__((weak)) int mvebu_board_spi_claim_bus(struct udevice *dev) |
| 303 | { |
| 304 | return 0; |
| 305 | } |
| 306 | |
Stefan Roese | 9fc5663 | 2016-02-11 11:37:38 +0100 | [diff] [blame] | 307 | static int mvebu_spi_claim_bus(struct udevice *dev) |
| 308 | { |
| 309 | struct udevice *bus = dev->parent; |
| 310 | struct mvebu_spi_platdata *plat = dev_get_platdata(bus); |
| 311 | |
| 312 | /* Configure the chip-select in the CTRL register */ |
| 313 | clrsetbits_le32(&plat->spireg->ctrl, |
| 314 | KWSPI_CS_MASK << KWSPI_CS_SHIFT, |
| 315 | spi_chip_select(dev) << KWSPI_CS_SHIFT); |
| 316 | |
Pascal Linder | f169653 | 2019-06-18 08:41:01 +0200 | [diff] [blame] | 317 | return mvebu_board_spi_claim_bus(dev); |
| 318 | } |
| 319 | |
| 320 | __attribute__((weak)) int mvebu_board_spi_release_bus(struct udevice *dev) |
| 321 | { |
Stefan Roese | 9fc5663 | 2016-02-11 11:37:38 +0100 | [diff] [blame] | 322 | return 0; |
| 323 | } |
| 324 | |
Pascal Linder | f169653 | 2019-06-18 08:41:01 +0200 | [diff] [blame] | 325 | static int mvebu_spi_release_bus(struct udevice *dev) |
| 326 | { |
| 327 | return mvebu_board_spi_release_bus(dev); |
| 328 | } |
| 329 | |
Stefan Roese | 9985bdb | 2015-11-20 13:39:43 +0100 | [diff] [blame] | 330 | static int mvebu_spi_probe(struct udevice *bus) |
| 331 | { |
| 332 | struct mvebu_spi_platdata *plat = dev_get_platdata(bus); |
| 333 | struct kwspi_registers *reg = plat->spireg; |
| 334 | |
| 335 | writel(KWSPI_SMEMRDY, ®->ctrl); |
| 336 | writel(KWSPI_SMEMRDIRQ, ®->irq_cause); |
| 337 | writel(KWSPI_IRQMASK, ®->irq_mask); |
| 338 | |
| 339 | return 0; |
| 340 | } |
| 341 | |
| 342 | static int mvebu_spi_ofdata_to_platdata(struct udevice *bus) |
| 343 | { |
| 344 | struct mvebu_spi_platdata *plat = dev_get_platdata(bus); |
Jagan Teki | f5ff46f | 2018-03-15 17:03:22 +0530 | [diff] [blame] | 345 | const struct mvebu_spi_dev *drvdata = |
| 346 | (struct mvebu_spi_dev *)dev_get_driver_data(bus); |
Stefan Roese | 9985bdb | 2015-11-20 13:39:43 +0100 | [diff] [blame] | 347 | |
Simon Glass | a821c4a | 2017-05-17 17:18:05 -0600 | [diff] [blame] | 348 | plat->spireg = (struct kwspi_registers *)devfdt_get_addr(bus); |
Jagan Teki | f5ff46f | 2018-03-15 17:03:22 +0530 | [diff] [blame] | 349 | plat->is_errata_50mhz_ac = drvdata->is_errata_50mhz_ac; |
Stefan Roese | 9985bdb | 2015-11-20 13:39:43 +0100 | [diff] [blame] | 350 | |
| 351 | return 0; |
| 352 | } |
| 353 | |
| 354 | static const struct dm_spi_ops mvebu_spi_ops = { |
Stefan Roese | 9fc5663 | 2016-02-11 11:37:38 +0100 | [diff] [blame] | 355 | .claim_bus = mvebu_spi_claim_bus, |
Pascal Linder | f169653 | 2019-06-18 08:41:01 +0200 | [diff] [blame] | 356 | .release_bus = mvebu_spi_release_bus, |
Stefan Roese | 9985bdb | 2015-11-20 13:39:43 +0100 | [diff] [blame] | 357 | .xfer = mvebu_spi_xfer, |
| 358 | .set_speed = mvebu_spi_set_speed, |
| 359 | .set_mode = mvebu_spi_set_mode, |
| 360 | /* |
| 361 | * cs_info is not needed, since we require all chip selects to be |
| 362 | * in the device tree explicitly |
| 363 | */ |
| 364 | }; |
| 365 | |
Chris Packham | 4f4dde0 | 2018-08-01 12:19:26 +0530 | [diff] [blame] | 366 | static const struct mvebu_spi_dev armada_spi_dev_data = { |
| 367 | .is_errata_50mhz_ac = false, |
| 368 | }; |
| 369 | |
Chris Packham | df16881 | 2018-01-22 22:44:20 +1300 | [diff] [blame] | 370 | static const struct mvebu_spi_dev armada_xp_spi_dev_data = { |
| 371 | .is_errata_50mhz_ac = false, |
| 372 | }; |
| 373 | |
| 374 | static const struct mvebu_spi_dev armada_375_spi_dev_data = { |
| 375 | .is_errata_50mhz_ac = false, |
| 376 | }; |
| 377 | |
| 378 | static const struct mvebu_spi_dev armada_380_spi_dev_data = { |
| 379 | .is_errata_50mhz_ac = true, |
| 380 | }; |
| 381 | |
Stefan Roese | 9985bdb | 2015-11-20 13:39:43 +0100 | [diff] [blame] | 382 | static const struct udevice_id mvebu_spi_ids[] = { |
Chris Packham | df16881 | 2018-01-22 22:44:20 +1300 | [diff] [blame] | 383 | { |
Chris Packham | 4f4dde0 | 2018-08-01 12:19:26 +0530 | [diff] [blame] | 384 | .compatible = "marvell,orion-spi", |
| 385 | .data = (ulong)&armada_spi_dev_data, |
| 386 | }, |
| 387 | { |
Chris Packham | df16881 | 2018-01-22 22:44:20 +1300 | [diff] [blame] | 388 | .compatible = "marvell,armada-375-spi", |
| 389 | .data = (ulong)&armada_375_spi_dev_data |
| 390 | }, |
| 391 | { |
| 392 | .compatible = "marvell,armada-380-spi", |
| 393 | .data = (ulong)&armada_380_spi_dev_data |
| 394 | }, |
| 395 | { |
| 396 | .compatible = "marvell,armada-xp-spi", |
| 397 | .data = (ulong)&armada_xp_spi_dev_data |
| 398 | }, |
Stefan Roese | 9985bdb | 2015-11-20 13:39:43 +0100 | [diff] [blame] | 399 | { } |
| 400 | }; |
| 401 | |
| 402 | U_BOOT_DRIVER(mvebu_spi) = { |
| 403 | .name = "mvebu_spi", |
| 404 | .id = UCLASS_SPI, |
| 405 | .of_match = mvebu_spi_ids, |
| 406 | .ops = &mvebu_spi_ops, |
| 407 | .ofdata_to_platdata = mvebu_spi_ofdata_to_platdata, |
| 408 | .platdata_auto_alloc_size = sizeof(struct mvebu_spi_platdata), |
| 409 | .priv_auto_alloc_size = sizeof(struct mvebu_spi_priv), |
| 410 | .probe = mvebu_spi_probe, |
| 411 | }; |
| 412 | #endif |