Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2011-12 The Chromium OS Authors. |
| 4 | * |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 5 | * This file is derived from the flashrom project. |
| 6 | */ |
Bin Meng | 9eb4339 | 2016-02-01 01:40:36 -0800 | [diff] [blame] | 7 | |
Simon Glass | a550662 | 2019-12-06 21:42:41 -0700 | [diff] [blame] | 8 | #define LOG_CATEGORY UCLASS_SPI |
| 9 | |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 10 | #include <common.h> |
Simon Glass | 52f2423 | 2020-05-10 11:40:00 -0600 | [diff] [blame] | 11 | #include <bootstage.h> |
Simon Glass | b47aa26 | 2019-12-06 21:42:40 -0700 | [diff] [blame] | 12 | #include <div64.h> |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 13 | #include <dm.h> |
Simon Glass | 0d3ee3e | 2019-12-06 21:42:45 -0700 | [diff] [blame] | 14 | #include <dt-structs.h> |
Simon Glass | 5093bad | 2015-01-27 22:13:43 -0700 | [diff] [blame] | 15 | #include <errno.h> |
Simon Glass | f7ae49f | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 16 | #include <log.h> |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 17 | #include <malloc.h> |
Simon Glass | f2b85ab | 2016-01-18 20:19:21 -0700 | [diff] [blame] | 18 | #include <pch.h> |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 19 | #include <pci.h> |
| 20 | #include <pci_ids.h> |
Simon Glass | f2b85ab | 2016-01-18 20:19:21 -0700 | [diff] [blame] | 21 | #include <spi.h> |
Simon Glass | 1facebd | 2019-12-06 21:42:46 -0700 | [diff] [blame] | 22 | #include <spi_flash.h> |
Bernhard Messerklinger | 0709ddb | 2019-08-02 08:38:34 +0200 | [diff] [blame] | 23 | #include <spi-mem.h> |
Simon Glass | 636555a | 2019-12-06 21:42:48 -0700 | [diff] [blame] | 24 | #include <spl.h> |
Simon Glass | 1facebd | 2019-12-06 21:42:46 -0700 | [diff] [blame] | 25 | #include <asm/fast_spi.h> |
Simon Glass | b47aa26 | 2019-12-06 21:42:40 -0700 | [diff] [blame] | 26 | #include <asm/io.h> |
Simon Glass | 609b90a | 2020-05-27 06:58:47 -0600 | [diff] [blame] | 27 | #include <dm/uclass-internal.h> |
Simon Glass | 636555a | 2019-12-06 21:42:48 -0700 | [diff] [blame] | 28 | #include <asm/mtrr.h> |
Simon Glass | cd93d62 | 2020-05-10 11:40:13 -0600 | [diff] [blame] | 29 | #include <linux/bitops.h> |
Simon Glass | c05ed00 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 30 | #include <linux/delay.h> |
Simon Glass | 636555a | 2019-12-06 21:42:48 -0700 | [diff] [blame] | 31 | #include <linux/sizes.h> |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 32 | |
| 33 | #include "ich.h" |
| 34 | |
Simon Glass | fffe25d | 2016-01-18 20:19:20 -0700 | [diff] [blame] | 35 | #ifdef DEBUG_TRACE |
| 36 | #define debug_trace(fmt, args...) debug(fmt, ##args) |
| 37 | #else |
| 38 | #define debug_trace(x, args...) |
| 39 | #endif |
| 40 | |
Simon Glass | 75214b0 | 2019-12-06 21:42:42 -0700 | [diff] [blame] | 41 | struct ich_spi_platdata { |
Simon Glass | 0d3ee3e | 2019-12-06 21:42:45 -0700 | [diff] [blame] | 42 | #if CONFIG_IS_ENABLED(OF_PLATDATA) |
| 43 | struct dtd_intel_fast_spi dtplat; |
| 44 | #endif |
Simon Glass | 75214b0 | 2019-12-06 21:42:42 -0700 | [diff] [blame] | 45 | enum ich_version ich_version; /* Controller version, 7 or 9 */ |
| 46 | bool lockdown; /* lock down controller settings? */ |
| 47 | ulong mmio_base; /* Base of MMIO registers */ |
Simon Glass | 0d3ee3e | 2019-12-06 21:42:45 -0700 | [diff] [blame] | 48 | pci_dev_t bdf; /* PCI address used by of-platdata */ |
Simon Glass | 1facebd | 2019-12-06 21:42:46 -0700 | [diff] [blame] | 49 | bool hwseq; /* Use hardware sequencing (not s/w) */ |
Simon Glass | 75214b0 | 2019-12-06 21:42:42 -0700 | [diff] [blame] | 50 | }; |
| 51 | |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 52 | static u8 ich_readb(struct ich_spi_priv *priv, int reg) |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 53 | { |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 54 | u8 value = readb(priv->base + reg); |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 55 | |
Simon Glass | fffe25d | 2016-01-18 20:19:20 -0700 | [diff] [blame] | 56 | debug_trace("read %2.2x from %4.4x\n", value, reg); |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 57 | |
| 58 | return value; |
| 59 | } |
| 60 | |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 61 | static u16 ich_readw(struct ich_spi_priv *priv, int reg) |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 62 | { |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 63 | u16 value = readw(priv->base + reg); |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 64 | |
Simon Glass | fffe25d | 2016-01-18 20:19:20 -0700 | [diff] [blame] | 65 | debug_trace("read %4.4x from %4.4x\n", value, reg); |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 66 | |
| 67 | return value; |
| 68 | } |
| 69 | |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 70 | static u32 ich_readl(struct ich_spi_priv *priv, int reg) |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 71 | { |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 72 | u32 value = readl(priv->base + reg); |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 73 | |
Simon Glass | fffe25d | 2016-01-18 20:19:20 -0700 | [diff] [blame] | 74 | debug_trace("read %8.8x from %4.4x\n", value, reg); |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 75 | |
| 76 | return value; |
| 77 | } |
| 78 | |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 79 | static void ich_writeb(struct ich_spi_priv *priv, u8 value, int reg) |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 80 | { |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 81 | writeb(value, priv->base + reg); |
Simon Glass | fffe25d | 2016-01-18 20:19:20 -0700 | [diff] [blame] | 82 | debug_trace("wrote %2.2x to %4.4x\n", value, reg); |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 83 | } |
| 84 | |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 85 | static void ich_writew(struct ich_spi_priv *priv, u16 value, int reg) |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 86 | { |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 87 | writew(value, priv->base + reg); |
Simon Glass | fffe25d | 2016-01-18 20:19:20 -0700 | [diff] [blame] | 88 | debug_trace("wrote %4.4x to %4.4x\n", value, reg); |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 89 | } |
| 90 | |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 91 | static void ich_writel(struct ich_spi_priv *priv, u32 value, int reg) |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 92 | { |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 93 | writel(value, priv->base + reg); |
Simon Glass | fffe25d | 2016-01-18 20:19:20 -0700 | [diff] [blame] | 94 | debug_trace("wrote %8.8x to %4.4x\n", value, reg); |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 95 | } |
| 96 | |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 97 | static void write_reg(struct ich_spi_priv *priv, const void *value, |
| 98 | int dest_reg, uint32_t size) |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 99 | { |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 100 | memcpy_toio(priv->base + dest_reg, value, size); |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 101 | } |
| 102 | |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 103 | static void read_reg(struct ich_spi_priv *priv, int src_reg, void *value, |
| 104 | uint32_t size) |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 105 | { |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 106 | memcpy_fromio(value, priv->base + src_reg, size); |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 107 | } |
| 108 | |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 109 | static void ich_set_bbar(struct ich_spi_priv *ctlr, uint32_t minaddr) |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 110 | { |
| 111 | const uint32_t bbar_mask = 0x00ffff00; |
| 112 | uint32_t ichspi_bbar; |
| 113 | |
Simon Glass | 3937df3 | 2019-12-06 21:42:49 -0700 | [diff] [blame] | 114 | if (ctlr->bbar) { |
| 115 | minaddr &= bbar_mask; |
| 116 | ichspi_bbar = ich_readl(ctlr, ctlr->bbar) & ~bbar_mask; |
| 117 | ichspi_bbar |= minaddr; |
| 118 | ich_writel(ctlr, ichspi_bbar, ctlr->bbar); |
| 119 | } |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 120 | } |
| 121 | |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 122 | /* @return 1 if the SPI flash supports the 33MHz speed */ |
Simon Glass | a550662 | 2019-12-06 21:42:41 -0700 | [diff] [blame] | 123 | static bool ich9_can_do_33mhz(struct udevice *dev) |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 124 | { |
Simon Glass | 17e7544 | 2019-12-06 21:42:38 -0700 | [diff] [blame] | 125 | struct ich_spi_priv *priv = dev_get_priv(dev); |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 126 | u32 fdod, speed; |
| 127 | |
Simon Glass | 636555a | 2019-12-06 21:42:48 -0700 | [diff] [blame] | 128 | if (!CONFIG_IS_ENABLED(PCI)) |
| 129 | return false; |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 130 | /* Observe SPI Descriptor Component Section 0 */ |
Simon Glass | 17e7544 | 2019-12-06 21:42:38 -0700 | [diff] [blame] | 131 | dm_pci_write_config32(priv->pch, 0xb0, 0x1000); |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 132 | |
| 133 | /* Extract the Write/Erase SPI Frequency from descriptor */ |
Simon Glass | 17e7544 | 2019-12-06 21:42:38 -0700 | [diff] [blame] | 134 | dm_pci_read_config32(priv->pch, 0xb4, &fdod); |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 135 | |
| 136 | /* Bits 23:21 have the fast read clock frequency, 0=20MHz, 1=33MHz */ |
| 137 | speed = (fdod >> 21) & 7; |
| 138 | |
| 139 | return speed == 1; |
| 140 | } |
| 141 | |
Bin Meng | ab20107 | 2017-10-18 18:20:57 -0700 | [diff] [blame] | 142 | static void spi_lock_down(struct ich_spi_platdata *plat, void *sbase) |
| 143 | { |
| 144 | if (plat->ich_version == ICHV_7) { |
| 145 | struct ich7_spi_regs *ich7_spi = sbase; |
| 146 | |
| 147 | setbits_le16(&ich7_spi->spis, SPIS_LOCK); |
| 148 | } else if (plat->ich_version == ICHV_9) { |
| 149 | struct ich9_spi_regs *ich9_spi = sbase; |
| 150 | |
| 151 | setbits_le16(&ich9_spi->hsfs, HSFS_FLOCKDN); |
| 152 | } |
| 153 | } |
| 154 | |
Bin Meng | 3e79141 | 2017-08-15 22:38:29 -0700 | [diff] [blame] | 155 | static bool spi_lock_status(struct ich_spi_platdata *plat, void *sbase) |
| 156 | { |
| 157 | int lock = 0; |
| 158 | |
| 159 | if (plat->ich_version == ICHV_7) { |
| 160 | struct ich7_spi_regs *ich7_spi = sbase; |
| 161 | |
| 162 | lock = readw(&ich7_spi->spis) & SPIS_LOCK; |
| 163 | } else if (plat->ich_version == ICHV_9) { |
| 164 | struct ich9_spi_regs *ich9_spi = sbase; |
| 165 | |
| 166 | lock = readw(&ich9_spi->hsfs) & HSFS_FLOCKDN; |
| 167 | } |
| 168 | |
| 169 | return lock != 0; |
| 170 | } |
| 171 | |
Bin Meng | 3e79141 | 2017-08-15 22:38:29 -0700 | [diff] [blame] | 172 | static int spi_setup_opcode(struct ich_spi_priv *ctlr, struct spi_trans *trans, |
| 173 | bool lock) |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 174 | { |
| 175 | uint16_t optypes; |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 176 | uint8_t opmenu[ctlr->menubytes]; |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 177 | |
Bin Meng | 3e79141 | 2017-08-15 22:38:29 -0700 | [diff] [blame] | 178 | if (!lock) { |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 179 | /* The lock is off, so just use index 0. */ |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 180 | ich_writeb(ctlr, trans->opcode, ctlr->opmenu); |
| 181 | optypes = ich_readw(ctlr, ctlr->optype); |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 182 | optypes = (optypes & 0xfffc) | (trans->type & 0x3); |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 183 | ich_writew(ctlr, optypes, ctlr->optype); |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 184 | return 0; |
| 185 | } else { |
| 186 | /* The lock is on. See if what we need is on the menu. */ |
| 187 | uint8_t optype; |
| 188 | uint16_t opcode_index; |
| 189 | |
| 190 | /* Write Enable is handled as atomic prefix */ |
| 191 | if (trans->opcode == SPI_OPCODE_WREN) |
| 192 | return 0; |
| 193 | |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 194 | read_reg(ctlr, ctlr->opmenu, opmenu, sizeof(opmenu)); |
| 195 | for (opcode_index = 0; opcode_index < ctlr->menubytes; |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 196 | opcode_index++) { |
| 197 | if (opmenu[opcode_index] == trans->opcode) |
| 198 | break; |
| 199 | } |
| 200 | |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 201 | if (opcode_index == ctlr->menubytes) { |
Simon Glass | a550662 | 2019-12-06 21:42:41 -0700 | [diff] [blame] | 202 | debug("ICH SPI: Opcode %x not found\n", trans->opcode); |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 203 | return -EINVAL; |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 204 | } |
| 205 | |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 206 | optypes = ich_readw(ctlr, ctlr->optype); |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 207 | optype = (optypes >> (opcode_index * 2)) & 0x3; |
Bernhard Messerklinger | 0709ddb | 2019-08-02 08:38:34 +0200 | [diff] [blame] | 208 | |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 209 | if (optype != trans->type) { |
Simon Glass | a550662 | 2019-12-06 21:42:41 -0700 | [diff] [blame] | 210 | debug("ICH SPI: Transaction doesn't fit type %d\n", |
| 211 | optype); |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 212 | return -ENOSPC; |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 213 | } |
| 214 | return opcode_index; |
| 215 | } |
| 216 | } |
| 217 | |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 218 | /* |
| 219 | * Wait for up to 6s til status register bit(s) turn 1 (in case wait_til_set |
York Sun | 472d546 | 2013-04-01 11:29:11 -0700 | [diff] [blame] | 220 | * below is true) or 0. In case the wait was for the bit(s) to set - write |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 221 | * those bits back, which would cause resetting them. |
| 222 | * |
| 223 | * Return the last read status value on success or -1 on failure. |
| 224 | */ |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 225 | static int ich_status_poll(struct ich_spi_priv *ctlr, u16 bitmask, |
| 226 | int wait_til_set) |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 227 | { |
| 228 | int timeout = 600000; /* This will result in 6s */ |
| 229 | u16 status = 0; |
| 230 | |
| 231 | while (timeout--) { |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 232 | status = ich_readw(ctlr, ctlr->status); |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 233 | if (wait_til_set ^ ((status & bitmask) == 0)) { |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 234 | if (wait_til_set) { |
| 235 | ich_writew(ctlr, status & bitmask, |
| 236 | ctlr->status); |
| 237 | } |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 238 | return status; |
| 239 | } |
| 240 | udelay(10); |
| 241 | } |
Simon Glass | a550662 | 2019-12-06 21:42:41 -0700 | [diff] [blame] | 242 | debug("ICH SPI: SCIP timeout, read %x, expected %x, wts %x %x\n", |
| 243 | status, bitmask, wait_til_set, status & bitmask); |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 244 | |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 245 | return -ETIMEDOUT; |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 246 | } |
| 247 | |
Bernhard Messerklinger | 0709ddb | 2019-08-02 08:38:34 +0200 | [diff] [blame] | 248 | static void ich_spi_config_opcode(struct udevice *dev) |
Bin Meng | b42711f | 2017-08-15 22:38:30 -0700 | [diff] [blame] | 249 | { |
| 250 | struct ich_spi_priv *ctlr = dev_get_priv(dev); |
| 251 | |
| 252 | /* |
| 253 | * PREOP, OPTYPE, OPMENU1/OPMENU2 registers can be locked down |
| 254 | * to prevent accidental or intentional writes. Before they get |
| 255 | * locked down, these registers should be initialized properly. |
| 256 | */ |
| 257 | ich_writew(ctlr, SPI_OPPREFIX, ctlr->preop); |
| 258 | ich_writew(ctlr, SPI_OPTYPE, ctlr->optype); |
| 259 | ich_writel(ctlr, SPI_OPMENU_LOWER, ctlr->opmenu); |
| 260 | ich_writel(ctlr, SPI_OPMENU_UPPER, ctlr->opmenu + sizeof(u32)); |
| 261 | } |
| 262 | |
Simon Glass | 1facebd | 2019-12-06 21:42:46 -0700 | [diff] [blame] | 263 | static int ich_spi_exec_op_swseq(struct spi_slave *slave, |
| 264 | const struct spi_mem_op *op) |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 265 | { |
Bernhard Messerklinger | 0709ddb | 2019-08-02 08:38:34 +0200 | [diff] [blame] | 266 | struct udevice *bus = dev_get_parent(slave->dev); |
Simon Glass | e1e332c | 2015-07-03 18:28:21 -0600 | [diff] [blame] | 267 | struct ich_spi_platdata *plat = dev_get_platdata(bus); |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 268 | struct ich_spi_priv *ctlr = dev_get_priv(bus); |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 269 | uint16_t control; |
| 270 | int16_t opcode_index; |
| 271 | int with_address; |
| 272 | int status; |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 273 | struct spi_trans *trans = &ctlr->trans; |
Bin Meng | 3e79141 | 2017-08-15 22:38:29 -0700 | [diff] [blame] | 274 | bool lock = spi_lock_status(plat, ctlr->base); |
Bernhard Messerklinger | 0709ddb | 2019-08-02 08:38:34 +0200 | [diff] [blame] | 275 | int ret = 0; |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 276 | |
Bernhard Messerklinger | 0709ddb | 2019-08-02 08:38:34 +0200 | [diff] [blame] | 277 | trans->in = NULL; |
| 278 | trans->out = NULL; |
| 279 | trans->type = 0xFF; |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 280 | |
Bernhard Messerklinger | 0709ddb | 2019-08-02 08:38:34 +0200 | [diff] [blame] | 281 | if (op->data.nbytes) { |
| 282 | if (op->data.dir == SPI_MEM_DATA_IN) { |
| 283 | trans->in = op->data.buf.in; |
| 284 | trans->bytesin = op->data.nbytes; |
| 285 | } else { |
| 286 | trans->out = op->data.buf.out; |
| 287 | trans->bytesout = op->data.nbytes; |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 288 | } |
Bernhard Messerklinger | 0709ddb | 2019-08-02 08:38:34 +0200 | [diff] [blame] | 289 | } |
| 290 | |
| 291 | if (trans->opcode != op->cmd.opcode) |
| 292 | trans->opcode = op->cmd.opcode; |
| 293 | |
| 294 | if (lock && trans->opcode == SPI_OPCODE_WRDIS) |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 295 | return 0; |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 296 | |
| 297 | if (trans->opcode == SPI_OPCODE_WREN) { |
| 298 | /* |
| 299 | * Treat Write Enable as Atomic Pre-Op if possible |
| 300 | * in order to prevent the Management Engine from |
| 301 | * issuing a transaction between WREN and DATA. |
| 302 | */ |
Bin Meng | 3e79141 | 2017-08-15 22:38:29 -0700 | [diff] [blame] | 303 | if (!lock) |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 304 | ich_writew(ctlr, trans->opcode, ctlr->preop); |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 305 | return 0; |
| 306 | } |
| 307 | |
Bernhard Messerklinger | 0709ddb | 2019-08-02 08:38:34 +0200 | [diff] [blame] | 308 | ret = ich_status_poll(ctlr, SPIS_SCIP, 0); |
| 309 | if (ret < 0) |
| 310 | return ret; |
| 311 | |
| 312 | if (plat->ich_version == ICHV_7) |
| 313 | ich_writew(ctlr, SPIS_CDS | SPIS_FCERR, ctlr->status); |
| 314 | else |
| 315 | ich_writeb(ctlr, SPIS_CDS | SPIS_FCERR, ctlr->status); |
| 316 | |
| 317 | /* Try to guess spi transaction type */ |
| 318 | if (op->data.dir == SPI_MEM_DATA_OUT) { |
| 319 | if (op->addr.nbytes) |
| 320 | trans->type = SPI_OPCODE_TYPE_WRITE_WITH_ADDRESS; |
| 321 | else |
| 322 | trans->type = SPI_OPCODE_TYPE_WRITE_NO_ADDRESS; |
| 323 | } else { |
| 324 | if (op->addr.nbytes) |
| 325 | trans->type = SPI_OPCODE_TYPE_READ_WITH_ADDRESS; |
| 326 | else |
| 327 | trans->type = SPI_OPCODE_TYPE_READ_NO_ADDRESS; |
| 328 | } |
| 329 | /* Special erase case handling */ |
| 330 | if (op->addr.nbytes && !op->data.buswidth) |
| 331 | trans->type = SPI_OPCODE_TYPE_WRITE_WITH_ADDRESS; |
| 332 | |
| 333 | opcode_index = spi_setup_opcode(ctlr, trans, lock); |
| 334 | if (opcode_index < 0) |
| 335 | return -EINVAL; |
| 336 | |
| 337 | if (op->addr.nbytes) { |
| 338 | trans->offset = op->addr.val; |
| 339 | with_address = 1; |
| 340 | } |
| 341 | |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 342 | if (ctlr->speed && ctlr->max_speed >= 33000000) { |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 343 | int byte; |
| 344 | |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 345 | byte = ich_readb(ctlr, ctlr->speed); |
| 346 | if (ctlr->cur_speed >= 33000000) |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 347 | byte |= SSFC_SCF_33MHZ; |
| 348 | else |
| 349 | byte &= ~SSFC_SCF_33MHZ; |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 350 | ich_writeb(ctlr, byte, ctlr->speed); |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 351 | } |
| 352 | |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 353 | /* Preset control fields */ |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 354 | control = SPIC_SCGO | ((opcode_index & 0x07) << 4); |
| 355 | |
| 356 | /* Issue atomic preop cycle if needed */ |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 357 | if (ich_readw(ctlr, ctlr->preop)) |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 358 | control |= SPIC_ACS; |
| 359 | |
| 360 | if (!trans->bytesout && !trans->bytesin) { |
| 361 | /* SPI addresses are 24 bit only */ |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 362 | if (with_address) { |
| 363 | ich_writel(ctlr, trans->offset & 0x00FFFFFF, |
| 364 | ctlr->addr); |
| 365 | } |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 366 | /* |
| 367 | * This is a 'no data' command (like Write Enable), its |
| 368 | * bitesout size was 1, decremented to zero while executing |
| 369 | * spi_setup_opcode() above. Tell the chip to send the |
| 370 | * command. |
| 371 | */ |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 372 | ich_writew(ctlr, control, ctlr->control); |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 373 | |
| 374 | /* wait for the result */ |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 375 | status = ich_status_poll(ctlr, SPIS_CDS | SPIS_FCERR, 1); |
| 376 | if (status < 0) |
| 377 | return status; |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 378 | |
| 379 | if (status & SPIS_FCERR) { |
| 380 | debug("ICH SPI: Command transaction error\n"); |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 381 | return -EIO; |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 382 | } |
| 383 | |
| 384 | return 0; |
| 385 | } |
| 386 | |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 387 | while (trans->bytesout || trans->bytesin) { |
| 388 | uint32_t data_length; |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 389 | |
| 390 | /* SPI addresses are 24 bit only */ |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 391 | ich_writel(ctlr, trans->offset & 0x00FFFFFF, ctlr->addr); |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 392 | |
| 393 | if (trans->bytesout) |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 394 | data_length = min(trans->bytesout, ctlr->databytes); |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 395 | else |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 396 | data_length = min(trans->bytesin, ctlr->databytes); |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 397 | |
| 398 | /* Program data into FDATA0 to N */ |
| 399 | if (trans->bytesout) { |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 400 | write_reg(ctlr, trans->out, ctlr->data, data_length); |
Bernhard Messerklinger | 0709ddb | 2019-08-02 08:38:34 +0200 | [diff] [blame] | 401 | trans->bytesout -= data_length; |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 402 | } |
| 403 | |
| 404 | /* Add proper control fields' values */ |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 405 | control &= ~((ctlr->databytes - 1) << 8); |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 406 | control |= SPIC_DS; |
| 407 | control |= (data_length - 1) << 8; |
| 408 | |
| 409 | /* write it */ |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 410 | ich_writew(ctlr, control, ctlr->control); |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 411 | |
Bin Meng | 9eb4339 | 2016-02-01 01:40:36 -0800 | [diff] [blame] | 412 | /* Wait for Cycle Done Status or Flash Cycle Error */ |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 413 | status = ich_status_poll(ctlr, SPIS_CDS | SPIS_FCERR, 1); |
| 414 | if (status < 0) |
| 415 | return status; |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 416 | |
| 417 | if (status & SPIS_FCERR) { |
Simon Glass | 5d4a757 | 2015-06-07 08:50:33 -0600 | [diff] [blame] | 418 | debug("ICH SPI: Data transaction error %x\n", status); |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 419 | return -EIO; |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 420 | } |
| 421 | |
| 422 | if (trans->bytesin) { |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 423 | read_reg(ctlr, ctlr->data, trans->in, data_length); |
Bernhard Messerklinger | 0709ddb | 2019-08-02 08:38:34 +0200 | [diff] [blame] | 424 | trans->bytesin -= data_length; |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 425 | } |
| 426 | } |
| 427 | |
| 428 | /* Clear atomic preop now that xfer is done */ |
Bin Meng | d2ca80c | 2017-08-26 19:22:59 -0700 | [diff] [blame] | 429 | if (!lock) |
| 430 | ich_writew(ctlr, 0, ctlr->preop); |
Simon Glass | 1853030 | 2013-03-19 04:58:56 +0000 | [diff] [blame] | 431 | |
| 432 | return 0; |
| 433 | } |
| 434 | |
Simon Glass | 1facebd | 2019-12-06 21:42:46 -0700 | [diff] [blame] | 435 | /* |
| 436 | * Ensure read/write xfer len is not greater than SPIBAR_FDATA_FIFO_SIZE and |
| 437 | * that the operation does not cross page boundary. |
| 438 | */ |
| 439 | static uint get_xfer_len(u32 offset, int len, int page_size) |
| 440 | { |
| 441 | uint xfer_len = min(len, SPIBAR_FDATA_FIFO_SIZE); |
| 442 | uint bytes_left = ALIGN(offset, page_size) - offset; |
| 443 | |
| 444 | if (bytes_left) |
| 445 | xfer_len = min(xfer_len, bytes_left); |
| 446 | |
| 447 | return xfer_len; |
| 448 | } |
| 449 | |
| 450 | /* Fill FDATAn FIFO in preparation for a write transaction */ |
| 451 | static void fill_xfer_fifo(struct fast_spi_regs *regs, const void *data, |
| 452 | uint len) |
| 453 | { |
| 454 | memcpy(regs->fdata, data, len); |
| 455 | } |
| 456 | |
| 457 | /* Drain FDATAn FIFO after a read transaction populates data */ |
| 458 | static void drain_xfer_fifo(struct fast_spi_regs *regs, void *dest, uint len) |
| 459 | { |
| 460 | memcpy(dest, regs->fdata, len); |
| 461 | } |
| 462 | |
| 463 | /* Fire up a transfer using the hardware sequencer */ |
| 464 | static void start_hwseq_xfer(struct fast_spi_regs *regs, uint hsfsts_cycle, |
| 465 | uint offset, uint len) |
| 466 | { |
| 467 | /* Make sure all W1C status bits get cleared */ |
| 468 | u32 hsfsts; |
| 469 | |
| 470 | hsfsts = readl(®s->hsfsts_ctl); |
| 471 | hsfsts &= ~(HSFSTS_FCYCLE_MASK | HSFSTS_FDBC_MASK); |
| 472 | hsfsts |= HSFSTS_AEL | HSFSTS_FCERR | HSFSTS_FDONE; |
| 473 | |
| 474 | /* Set up transaction parameters */ |
| 475 | hsfsts |= hsfsts_cycle << HSFSTS_FCYCLE_SHIFT; |
| 476 | hsfsts |= ((len - 1) << HSFSTS_FDBC_SHIFT) & HSFSTS_FDBC_MASK; |
| 477 | hsfsts |= HSFSTS_FGO; |
| 478 | |
| 479 | writel(offset, ®s->faddr); |
| 480 | writel(hsfsts, ®s->hsfsts_ctl); |
| 481 | } |
| 482 | |
| 483 | static int wait_for_hwseq_xfer(struct fast_spi_regs *regs, uint offset) |
| 484 | { |
| 485 | ulong start; |
| 486 | u32 hsfsts; |
| 487 | |
| 488 | start = get_timer(0); |
| 489 | do { |
| 490 | hsfsts = readl(®s->hsfsts_ctl); |
| 491 | if (hsfsts & HSFSTS_FCERR) { |
| 492 | debug("SPI transaction error at offset %x HSFSTS = %08x\n", |
| 493 | offset, hsfsts); |
| 494 | return -EIO; |
| 495 | } |
| 496 | if (hsfsts & HSFSTS_AEL) |
| 497 | return -EPERM; |
| 498 | |
| 499 | if (hsfsts & HSFSTS_FDONE) |
| 500 | return 0; |
| 501 | } while (get_timer(start) < SPIBAR_HWSEQ_XFER_TIMEOUT_MS); |
| 502 | |
| 503 | debug("SPI transaction timeout at offset %x HSFSTS = %08x, timer %d\n", |
| 504 | offset, hsfsts, (uint)get_timer(start)); |
| 505 | |
| 506 | return -ETIMEDOUT; |
| 507 | } |
| 508 | |
| 509 | /** |
| 510 | * exec_sync_hwseq_xfer() - Execute flash transfer by hardware sequencing |
| 511 | * |
| 512 | * This waits until complete or timeout |
| 513 | * |
| 514 | * @regs: SPI registers |
| 515 | * @hsfsts_cycle: Cycle type (enum hsfsts_cycle_t) |
| 516 | * @offset: Offset to access |
| 517 | * @len: Number of bytes to transfer (can be 0) |
| 518 | * @return 0 if OK, -EIO on flash-cycle error (FCERR), -EPERM on access error |
| 519 | * (AEL), -ETIMEDOUT on timeout |
| 520 | */ |
| 521 | static int exec_sync_hwseq_xfer(struct fast_spi_regs *regs, uint hsfsts_cycle, |
| 522 | uint offset, uint len) |
| 523 | { |
| 524 | start_hwseq_xfer(regs, hsfsts_cycle, offset, len); |
| 525 | |
| 526 | return wait_for_hwseq_xfer(regs, offset); |
| 527 | } |
| 528 | |
| 529 | static int ich_spi_exec_op_hwseq(struct spi_slave *slave, |
| 530 | const struct spi_mem_op *op) |
| 531 | { |
| 532 | struct spi_flash *flash = dev_get_uclass_priv(slave->dev); |
| 533 | struct udevice *bus = dev_get_parent(slave->dev); |
| 534 | struct ich_spi_priv *priv = dev_get_priv(bus); |
| 535 | struct fast_spi_regs *regs = priv->base; |
| 536 | uint page_size; |
| 537 | uint offset; |
| 538 | int cycle; |
| 539 | uint len; |
| 540 | bool out; |
| 541 | int ret; |
| 542 | u8 *buf; |
| 543 | |
| 544 | offset = op->addr.val; |
| 545 | len = op->data.nbytes; |
| 546 | |
| 547 | switch (op->cmd.opcode) { |
| 548 | case SPINOR_OP_RDID: |
| 549 | cycle = HSFSTS_CYCLE_RDID; |
| 550 | break; |
| 551 | case SPINOR_OP_READ_FAST: |
| 552 | cycle = HSFSTS_CYCLE_READ; |
| 553 | break; |
| 554 | case SPINOR_OP_PP: |
| 555 | cycle = HSFSTS_CYCLE_WRITE; |
| 556 | break; |
| 557 | case SPINOR_OP_WREN: |
| 558 | /* Nothing needs to be done */ |
| 559 | return 0; |
| 560 | case SPINOR_OP_WRSR: |
| 561 | cycle = HSFSTS_CYCLE_WR_STATUS; |
| 562 | break; |
| 563 | case SPINOR_OP_RDSR: |
| 564 | cycle = HSFSTS_CYCLE_RD_STATUS; |
| 565 | break; |
| 566 | case SPINOR_OP_WRDI: |
| 567 | return 0; /* ignore */ |
| 568 | case SPINOR_OP_BE_4K: |
| 569 | cycle = HSFSTS_CYCLE_4K_ERASE; |
Wolfgang Wallner | 5e579cc | 2020-01-14 14:05:48 +0100 | [diff] [blame] | 570 | ret = exec_sync_hwseq_xfer(regs, cycle, offset, 0); |
| 571 | return ret; |
Simon Glass | 1facebd | 2019-12-06 21:42:46 -0700 | [diff] [blame] | 572 | default: |
| 573 | debug("Unknown cycle %x\n", op->cmd.opcode); |
| 574 | return -EINVAL; |
| 575 | }; |
| 576 | |
| 577 | out = op->data.dir == SPI_MEM_DATA_OUT; |
| 578 | buf = out ? (u8 *)op->data.buf.out : op->data.buf.in; |
| 579 | page_size = flash->page_size ? : 256; |
| 580 | |
| 581 | while (len) { |
| 582 | uint xfer_len = get_xfer_len(offset, len, page_size); |
| 583 | |
| 584 | if (out) |
| 585 | fill_xfer_fifo(regs, buf, xfer_len); |
| 586 | |
| 587 | ret = exec_sync_hwseq_xfer(regs, cycle, offset, xfer_len); |
| 588 | if (ret) |
| 589 | return ret; |
| 590 | |
| 591 | if (!out) |
| 592 | drain_xfer_fifo(regs, buf, xfer_len); |
| 593 | |
| 594 | offset += xfer_len; |
| 595 | buf += xfer_len; |
| 596 | len -= xfer_len; |
| 597 | } |
| 598 | |
| 599 | return 0; |
| 600 | } |
| 601 | |
| 602 | static int ich_spi_exec_op(struct spi_slave *slave, const struct spi_mem_op *op) |
| 603 | { |
| 604 | struct udevice *bus = dev_get_parent(slave->dev); |
| 605 | struct ich_spi_platdata *plat = dev_get_platdata(bus); |
| 606 | int ret; |
| 607 | |
| 608 | bootstage_start(BOOTSTAGE_ID_ACCUM_SPI, "fast_spi"); |
| 609 | if (plat->hwseq) |
| 610 | ret = ich_spi_exec_op_hwseq(slave, op); |
| 611 | else |
| 612 | ret = ich_spi_exec_op_swseq(slave, op); |
| 613 | bootstage_accum(BOOTSTAGE_ID_ACCUM_SPI); |
| 614 | |
| 615 | return ret; |
| 616 | } |
| 617 | |
Simon Glass | 609b90a | 2020-05-27 06:58:47 -0600 | [diff] [blame] | 618 | /** |
| 619 | * ich_spi_get_basics() - Get basic information about the ICH device |
| 620 | * |
| 621 | * This works without probing any devices if requested. |
| 622 | * |
| 623 | * @bus: SPI controller to use |
| 624 | * @can_probe: true if this function is allowed to probe the PCH |
| 625 | * @pchp: Returns a pointer to the pch, or NULL if not found |
| 626 | * @ich_versionp: Returns ICH version detected on success |
| 627 | * @mmio_basep: Returns the address of the SPI registers on success |
| 628 | * @return 0 if OK, -EPROTOTYPE if the PCH could not be found, -EAGAIN if |
| 629 | * the function cannot success without probing, possible another error if |
| 630 | * pch_get_spi_base() fails |
| 631 | */ |
| 632 | static int ich_spi_get_basics(struct udevice *bus, bool can_probe, |
| 633 | struct udevice **pchp, |
| 634 | enum ich_version *ich_versionp, ulong *mmio_basep) |
| 635 | { |
| 636 | struct udevice *pch = NULL; |
| 637 | int ret = 0; |
| 638 | |
| 639 | /* Find a PCH if there is one */ |
| 640 | if (can_probe) { |
| 641 | pch = dev_get_parent(bus); |
| 642 | if (device_get_uclass_id(pch) != UCLASS_PCH) { |
| 643 | uclass_first_device(UCLASS_PCH, &pch); |
| 644 | if (!pch) |
| 645 | return log_msg_ret("uclass", -EPROTOTYPE); |
| 646 | } |
| 647 | } |
| 648 | |
| 649 | *ich_versionp = dev_get_driver_data(bus); |
| 650 | if (*ich_versionp == ICHV_APL) |
| 651 | *mmio_basep = dm_pci_read_bar32(bus, 0); |
| 652 | else if (pch) |
| 653 | ret = pch_get_spi_base(pch, mmio_basep); |
| 654 | else |
| 655 | return -EAGAIN; |
| 656 | *pchp = pch; |
| 657 | |
| 658 | return ret; |
| 659 | } |
| 660 | |
| 661 | /** |
| 662 | * ich_get_mmap_bus() - Handle the get_mmap() method for a bus |
| 663 | * |
| 664 | * There are several cases to consider: |
| 665 | * 1. Using of-platdata, in which case we have the BDF and can access the |
| 666 | * registers by reading the BAR |
| 667 | * 2. Not using of-platdata, but still with a SPI controller that is on its own |
| 668 | * PCI PDF. In this case we read the BDF from the parent platdata and again get |
| 669 | * the registers by reading the BAR |
| 670 | * 3. Using a SPI controller that is a child of the PCH, in which case we try |
| 671 | * to find the registers by asking the PCH. This only works if the PCH has |
| 672 | * been probed (which it will be if the bus is probed since parents are |
| 673 | * probed before children), since the PCH may not have a PCI address until |
| 674 | * its parent (the PCI bus itself) has been probed. If you are using this |
| 675 | * method then you should make sure the SPI bus is probed. |
| 676 | * |
| 677 | * The first two cases are useful in early init. The last one is more useful |
| 678 | * afterwards. |
| 679 | */ |
Simon Glass | 9284214 | 2019-12-06 21:42:47 -0700 | [diff] [blame] | 680 | static int ich_get_mmap_bus(struct udevice *bus, ulong *map_basep, |
| 681 | uint *map_sizep, uint *offsetp) |
| 682 | { |
| 683 | pci_dev_t spi_bdf; |
Simon Glass | 9284214 | 2019-12-06 21:42:47 -0700 | [diff] [blame] | 684 | #if !CONFIG_IS_ENABLED(OF_PLATDATA) |
Simon Glass | 609b90a | 2020-05-27 06:58:47 -0600 | [diff] [blame] | 685 | if (device_is_on_pci_bus(bus)) { |
| 686 | struct pci_child_platdata *pplat; |
Simon Glass | 9284214 | 2019-12-06 21:42:47 -0700 | [diff] [blame] | 687 | |
Simon Glass | 609b90a | 2020-05-27 06:58:47 -0600 | [diff] [blame] | 688 | pplat = dev_get_parent_platdata(bus); |
| 689 | spi_bdf = pplat->devfn; |
| 690 | } else { |
| 691 | enum ich_version ich_version; |
| 692 | struct fast_spi_regs *regs; |
| 693 | struct udevice *pch; |
| 694 | ulong mmio_base; |
| 695 | int ret; |
| 696 | |
| 697 | ret = ich_spi_get_basics(bus, device_active(bus), &pch, |
| 698 | &ich_version, &mmio_base); |
| 699 | if (ret) |
| 700 | return log_msg_ret("basics", ret); |
| 701 | regs = (struct fast_spi_regs *)mmio_base; |
| 702 | |
| 703 | return fast_spi_get_bios_mmap_regs(regs, map_basep, map_sizep, |
| 704 | offsetp); |
| 705 | } |
Simon Glass | 9284214 | 2019-12-06 21:42:47 -0700 | [diff] [blame] | 706 | #else |
| 707 | struct ich_spi_platdata *plat = dev_get_platdata(bus); |
| 708 | |
| 709 | /* |
| 710 | * We cannot rely on plat->bdf being set up yet since this method can |
| 711 | * be called before the device is probed. Use the of-platdata directly |
| 712 | * instead. |
| 713 | */ |
| 714 | spi_bdf = pci_ofplat_get_devfn(plat->dtplat.reg[0]); |
| 715 | #endif |
| 716 | |
| 717 | return fast_spi_get_bios_mmap(spi_bdf, map_basep, map_sizep, offsetp); |
| 718 | } |
| 719 | |
| 720 | static int ich_get_mmap(struct udevice *dev, ulong *map_basep, uint *map_sizep, |
| 721 | uint *offsetp) |
| 722 | { |
| 723 | struct udevice *bus = dev_get_parent(dev); |
| 724 | |
| 725 | return ich_get_mmap_bus(bus, map_basep, map_sizep, offsetp); |
| 726 | } |
| 727 | |
Bernhard Messerklinger | 0709ddb | 2019-08-02 08:38:34 +0200 | [diff] [blame] | 728 | static int ich_spi_adjust_size(struct spi_slave *slave, struct spi_mem_op *op) |
| 729 | { |
| 730 | unsigned int page_offset; |
| 731 | int addr = op->addr.val; |
| 732 | unsigned int byte_count = op->data.nbytes; |
| 733 | |
| 734 | if (hweight32(ICH_BOUNDARY) == 1) { |
| 735 | page_offset = addr & (ICH_BOUNDARY - 1); |
| 736 | } else { |
| 737 | u64 aux = addr; |
| 738 | |
| 739 | page_offset = do_div(aux, ICH_BOUNDARY); |
| 740 | } |
| 741 | |
Simon Glass | 43c145b | 2019-12-06 21:42:44 -0700 | [diff] [blame] | 742 | if (op->data.dir == SPI_MEM_DATA_IN) { |
| 743 | if (slave->max_read_size) { |
| 744 | op->data.nbytes = min(ICH_BOUNDARY - page_offset, |
| 745 | slave->max_read_size); |
| 746 | } |
Bernhard Messerklinger | 0709ddb | 2019-08-02 08:38:34 +0200 | [diff] [blame] | 747 | } else if (slave->max_write_size) { |
| 748 | op->data.nbytes = min(ICH_BOUNDARY - page_offset, |
| 749 | slave->max_write_size); |
| 750 | } |
| 751 | |
| 752 | op->data.nbytes = min(op->data.nbytes, byte_count); |
| 753 | |
| 754 | return 0; |
| 755 | } |
| 756 | |
Simon Glass | 17e7544 | 2019-12-06 21:42:38 -0700 | [diff] [blame] | 757 | static int ich_protect_lockdown(struct udevice *dev) |
| 758 | { |
| 759 | struct ich_spi_platdata *plat = dev_get_platdata(dev); |
| 760 | struct ich_spi_priv *priv = dev_get_priv(dev); |
| 761 | int ret = -ENOSYS; |
| 762 | |
| 763 | /* Disable the BIOS write protect so write commands are allowed */ |
| 764 | if (priv->pch) |
| 765 | ret = pch_set_spi_protect(priv->pch, false); |
| 766 | if (ret == -ENOSYS) { |
| 767 | u8 bios_cntl; |
| 768 | |
| 769 | bios_cntl = ich_readb(priv, priv->bcr); |
| 770 | bios_cntl &= ~BIT(5); /* clear Enable InSMM_STS (EISS) */ |
| 771 | bios_cntl |= 1; /* Write Protect Disable (WPD) */ |
| 772 | ich_writeb(priv, bios_cntl, priv->bcr); |
| 773 | } else if (ret) { |
| 774 | debug("%s: Failed to disable write-protect: err=%d\n", |
| 775 | __func__, ret); |
| 776 | return ret; |
| 777 | } |
| 778 | |
| 779 | /* Lock down SPI controller settings if required */ |
| 780 | if (plat->lockdown) { |
| 781 | ich_spi_config_opcode(dev); |
| 782 | spi_lock_down(plat, priv->base); |
| 783 | } |
| 784 | |
| 785 | return 0; |
| 786 | } |
| 787 | |
Simon Glass | 674990c | 2019-12-06 21:42:37 -0700 | [diff] [blame] | 788 | static int ich_init_controller(struct udevice *dev, |
| 789 | struct ich_spi_platdata *plat, |
| 790 | struct ich_spi_priv *ctlr) |
| 791 | { |
Simon Glass | 636555a | 2019-12-06 21:42:48 -0700 | [diff] [blame] | 792 | if (spl_phase() == PHASE_TPL) { |
| 793 | struct ich_spi_platdata *plat = dev_get_platdata(dev); |
| 794 | int ret; |
| 795 | |
| 796 | ret = fast_spi_early_init(plat->bdf, plat->mmio_base); |
| 797 | if (ret) |
| 798 | return ret; |
| 799 | } |
| 800 | |
Simon Glass | 75214b0 | 2019-12-06 21:42:42 -0700 | [diff] [blame] | 801 | ctlr->base = (void *)plat->mmio_base; |
Simon Glass | 674990c | 2019-12-06 21:42:37 -0700 | [diff] [blame] | 802 | if (plat->ich_version == ICHV_7) { |
Simon Glass | 75214b0 | 2019-12-06 21:42:42 -0700 | [diff] [blame] | 803 | struct ich7_spi_regs *ich7_spi = ctlr->base; |
Simon Glass | 674990c | 2019-12-06 21:42:37 -0700 | [diff] [blame] | 804 | |
| 805 | ctlr->opmenu = offsetof(struct ich7_spi_regs, opmenu); |
| 806 | ctlr->menubytes = sizeof(ich7_spi->opmenu); |
| 807 | ctlr->optype = offsetof(struct ich7_spi_regs, optype); |
| 808 | ctlr->addr = offsetof(struct ich7_spi_regs, spia); |
| 809 | ctlr->data = offsetof(struct ich7_spi_regs, spid); |
| 810 | ctlr->databytes = sizeof(ich7_spi->spid); |
| 811 | ctlr->status = offsetof(struct ich7_spi_regs, spis); |
| 812 | ctlr->control = offsetof(struct ich7_spi_regs, spic); |
| 813 | ctlr->bbar = offsetof(struct ich7_spi_regs, bbar); |
| 814 | ctlr->preop = offsetof(struct ich7_spi_regs, preop); |
Simon Glass | 674990c | 2019-12-06 21:42:37 -0700 | [diff] [blame] | 815 | } else if (plat->ich_version == ICHV_9) { |
Simon Glass | 75214b0 | 2019-12-06 21:42:42 -0700 | [diff] [blame] | 816 | struct ich9_spi_regs *ich9_spi = ctlr->base; |
Simon Glass | 674990c | 2019-12-06 21:42:37 -0700 | [diff] [blame] | 817 | |
| 818 | ctlr->opmenu = offsetof(struct ich9_spi_regs, opmenu); |
| 819 | ctlr->menubytes = sizeof(ich9_spi->opmenu); |
| 820 | ctlr->optype = offsetof(struct ich9_spi_regs, optype); |
| 821 | ctlr->addr = offsetof(struct ich9_spi_regs, faddr); |
| 822 | ctlr->data = offsetof(struct ich9_spi_regs, fdata); |
| 823 | ctlr->databytes = sizeof(ich9_spi->fdata); |
| 824 | ctlr->status = offsetof(struct ich9_spi_regs, ssfs); |
| 825 | ctlr->control = offsetof(struct ich9_spi_regs, ssfc); |
| 826 | ctlr->speed = ctlr->control + 2; |
| 827 | ctlr->bbar = offsetof(struct ich9_spi_regs, bbar); |
| 828 | ctlr->preop = offsetof(struct ich9_spi_regs, preop); |
| 829 | ctlr->bcr = offsetof(struct ich9_spi_regs, bcr); |
| 830 | ctlr->pr = &ich9_spi->pr[0]; |
Simon Glass | 3937df3 | 2019-12-06 21:42:49 -0700 | [diff] [blame] | 831 | } else if (plat->ich_version == ICHV_APL) { |
Simon Glass | 674990c | 2019-12-06 21:42:37 -0700 | [diff] [blame] | 832 | } else { |
| 833 | debug("ICH SPI: Unrecognised ICH version %d\n", |
| 834 | plat->ich_version); |
| 835 | return -EINVAL; |
| 836 | } |
| 837 | |
| 838 | /* Work out the maximum speed we can support */ |
| 839 | ctlr->max_speed = 20000000; |
| 840 | if (plat->ich_version == ICHV_9 && ich9_can_do_33mhz(dev)) |
| 841 | ctlr->max_speed = 33000000; |
Simon Glass | 75214b0 | 2019-12-06 21:42:42 -0700 | [diff] [blame] | 842 | debug("ICH SPI: Version ID %d detected at %lx, speed %ld\n", |
| 843 | plat->ich_version, plat->mmio_base, ctlr->max_speed); |
Simon Glass | 674990c | 2019-12-06 21:42:37 -0700 | [diff] [blame] | 844 | |
| 845 | ich_set_bbar(ctlr, 0); |
| 846 | |
| 847 | return 0; |
| 848 | } |
| 849 | |
Simon Glass | 636555a | 2019-12-06 21:42:48 -0700 | [diff] [blame] | 850 | static int ich_cache_bios_region(struct udevice *dev) |
| 851 | { |
| 852 | ulong map_base; |
| 853 | uint map_size; |
| 854 | uint offset; |
| 855 | ulong base; |
| 856 | int ret; |
| 857 | |
| 858 | ret = ich_get_mmap_bus(dev, &map_base, &map_size, &offset); |
| 859 | if (ret) |
| 860 | return ret; |
| 861 | |
| 862 | /* Don't use WRBACK since we are not supposed to write to SPI flash */ |
| 863 | base = SZ_4G - map_size; |
| 864 | mtrr_set_next_var(MTRR_TYPE_WRPROT, base, map_size); |
| 865 | log_debug("BIOS cache base=%lx, size=%x\n", base, (uint)map_size); |
| 866 | |
| 867 | return 0; |
| 868 | } |
| 869 | |
Simon Glass | f2b85ab | 2016-01-18 20:19:21 -0700 | [diff] [blame] | 870 | static int ich_spi_probe(struct udevice *dev) |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 871 | { |
Simon Glass | f2b85ab | 2016-01-18 20:19:21 -0700 | [diff] [blame] | 872 | struct ich_spi_platdata *plat = dev_get_platdata(dev); |
| 873 | struct ich_spi_priv *priv = dev_get_priv(dev); |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 874 | int ret; |
| 875 | |
Simon Glass | f2b85ab | 2016-01-18 20:19:21 -0700 | [diff] [blame] | 876 | ret = ich_init_controller(dev, plat, priv); |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 877 | if (ret) |
| 878 | return ret; |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 879 | |
Simon Glass | 636555a | 2019-12-06 21:42:48 -0700 | [diff] [blame] | 880 | if (spl_phase() == PHASE_TPL) { |
| 881 | /* Cache the BIOS to speed things up */ |
| 882 | ret = ich_cache_bios_region(dev); |
| 883 | if (ret) |
| 884 | return ret; |
| 885 | } else { |
| 886 | ret = ich_protect_lockdown(dev); |
| 887 | if (ret) |
| 888 | return ret; |
| 889 | } |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 890 | priv->cur_speed = priv->max_speed; |
| 891 | |
| 892 | return 0; |
| 893 | } |
| 894 | |
Stefan Roese | 4759dff | 2017-04-24 09:48:04 +0200 | [diff] [blame] | 895 | static int ich_spi_remove(struct udevice *bus) |
| 896 | { |
Stefan Roese | 4759dff | 2017-04-24 09:48:04 +0200 | [diff] [blame] | 897 | /* |
| 898 | * Configure SPI controller so that the Linux MTD driver can fully |
| 899 | * access the SPI NOR chip |
| 900 | */ |
Bin Meng | b42711f | 2017-08-15 22:38:30 -0700 | [diff] [blame] | 901 | ich_spi_config_opcode(bus); |
Stefan Roese | 4759dff | 2017-04-24 09:48:04 +0200 | [diff] [blame] | 902 | |
| 903 | return 0; |
| 904 | } |
| 905 | |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 906 | static int ich_spi_set_speed(struct udevice *bus, uint speed) |
| 907 | { |
| 908 | struct ich_spi_priv *priv = dev_get_priv(bus); |
| 909 | |
| 910 | priv->cur_speed = speed; |
| 911 | |
| 912 | return 0; |
| 913 | } |
| 914 | |
| 915 | static int ich_spi_set_mode(struct udevice *bus, uint mode) |
| 916 | { |
| 917 | debug("%s: mode=%d\n", __func__, mode); |
| 918 | |
| 919 | return 0; |
| 920 | } |
| 921 | |
| 922 | static int ich_spi_child_pre_probe(struct udevice *dev) |
| 923 | { |
| 924 | struct udevice *bus = dev_get_parent(dev); |
| 925 | struct ich_spi_platdata *plat = dev_get_platdata(bus); |
| 926 | struct ich_spi_priv *priv = dev_get_priv(bus); |
Simon Glass | bcbe3d1 | 2015-09-28 23:32:01 -0600 | [diff] [blame] | 927 | struct spi_slave *slave = dev_get_parent_priv(dev); |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 928 | |
| 929 | /* |
| 930 | * Yes this controller can only write a small number of bytes at |
Simon Glass | 1facebd | 2019-12-06 21:42:46 -0700 | [diff] [blame] | 931 | * once! The limit is typically 64 bytes. For hardware sequencing a |
| 932 | * a loop is used to get around this. |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 933 | */ |
Simon Glass | 1facebd | 2019-12-06 21:42:46 -0700 | [diff] [blame] | 934 | if (!plat->hwseq) |
| 935 | slave->max_write_size = priv->databytes; |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 936 | /* |
| 937 | * ICH 7 SPI controller only supports array read command |
| 938 | * and byte program command for SST flash |
| 939 | */ |
Jagan Teki | 08fe9c2 | 2016-08-08 17:12:12 +0530 | [diff] [blame] | 940 | if (plat->ich_version == ICHV_7) |
| 941 | slave->mode = SPI_RX_SLOW | SPI_TX_BYTE; |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 942 | |
| 943 | return 0; |
| 944 | } |
| 945 | |
Bin Meng | 1f9eb59 | 2016-02-01 01:40:37 -0800 | [diff] [blame] | 946 | static int ich_spi_ofdata_to_platdata(struct udevice *dev) |
| 947 | { |
| 948 | struct ich_spi_platdata *plat = dev_get_platdata(dev); |
Simon Glass | 609b90a | 2020-05-27 06:58:47 -0600 | [diff] [blame] | 949 | int ret; |
Simon Glass | 0d3ee3e | 2019-12-06 21:42:45 -0700 | [diff] [blame] | 950 | |
| 951 | #if !CONFIG_IS_ENABLED(OF_PLATDATA) |
Simon Glass | 17e7544 | 2019-12-06 21:42:38 -0700 | [diff] [blame] | 952 | struct ich_spi_priv *priv = dev_get_priv(dev); |
Bin Meng | 1f9eb59 | 2016-02-01 01:40:37 -0800 | [diff] [blame] | 953 | |
Simon Glass | 609b90a | 2020-05-27 06:58:47 -0600 | [diff] [blame] | 954 | ret = ich_spi_get_basics(dev, true, &priv->pch, &plat->ich_version, |
| 955 | &plat->mmio_base); |
| 956 | if (ret) |
| 957 | return log_msg_ret("basics", ret); |
Simon Glass | 702b28a | 2019-12-06 21:42:39 -0700 | [diff] [blame] | 958 | plat->lockdown = dev_read_bool(dev, "intel,spi-lock-down"); |
Simon Glass | 1facebd | 2019-12-06 21:42:46 -0700 | [diff] [blame] | 959 | /* |
| 960 | * Use an int so that the property is present in of-platdata even |
| 961 | * when false. |
| 962 | */ |
| 963 | plat->hwseq = dev_read_u32_default(dev, "intel,hardware-seq", 0); |
Simon Glass | 0d3ee3e | 2019-12-06 21:42:45 -0700 | [diff] [blame] | 964 | #else |
| 965 | plat->ich_version = ICHV_APL; |
| 966 | plat->mmio_base = plat->dtplat.early_regs[0]; |
| 967 | plat->bdf = pci_ofplat_get_devfn(plat->dtplat.reg[0]); |
Simon Glass | 1facebd | 2019-12-06 21:42:46 -0700 | [diff] [blame] | 968 | plat->hwseq = plat->dtplat.intel_hardware_seq; |
Simon Glass | 0d3ee3e | 2019-12-06 21:42:45 -0700 | [diff] [blame] | 969 | #endif |
| 970 | debug("%s: mmio_base=%lx\n", __func__, plat->mmio_base); |
Simon Glass | 75214b0 | 2019-12-06 21:42:42 -0700 | [diff] [blame] | 971 | |
Simon Glass | 702b28a | 2019-12-06 21:42:39 -0700 | [diff] [blame] | 972 | return 0; |
Bin Meng | 1f9eb59 | 2016-02-01 01:40:37 -0800 | [diff] [blame] | 973 | } |
| 974 | |
Bernhard Messerklinger | 0709ddb | 2019-08-02 08:38:34 +0200 | [diff] [blame] | 975 | static const struct spi_controller_mem_ops ich_controller_mem_ops = { |
| 976 | .adjust_op_size = ich_spi_adjust_size, |
| 977 | .supports_op = NULL, |
| 978 | .exec_op = ich_spi_exec_op, |
| 979 | }; |
| 980 | |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 981 | static const struct dm_spi_ops ich_spi_ops = { |
Simon Glass | ccdabd8 | 2019-12-06 21:42:35 -0700 | [diff] [blame] | 982 | /* xfer is not supported */ |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 983 | .set_speed = ich_spi_set_speed, |
| 984 | .set_mode = ich_spi_set_mode, |
Bernhard Messerklinger | 0709ddb | 2019-08-02 08:38:34 +0200 | [diff] [blame] | 985 | .mem_ops = &ich_controller_mem_ops, |
Simon Glass | 9284214 | 2019-12-06 21:42:47 -0700 | [diff] [blame] | 986 | .get_mmap = ich_get_mmap, |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 987 | /* |
| 988 | * cs_info is not needed, since we require all chip selects to be |
| 989 | * in the device tree explicitly |
| 990 | */ |
| 991 | }; |
| 992 | |
| 993 | static const struct udevice_id ich_spi_ids[] = { |
Simon Glass | 702b28a | 2019-12-06 21:42:39 -0700 | [diff] [blame] | 994 | { .compatible = "intel,ich7-spi", ICHV_7 }, |
| 995 | { .compatible = "intel,ich9-spi", ICHV_9 }, |
Simon Glass | 3937df3 | 2019-12-06 21:42:49 -0700 | [diff] [blame] | 996 | { .compatible = "intel,fast-spi", ICHV_APL }, |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 997 | { } |
| 998 | }; |
| 999 | |
Simon Glass | 0d3ee3e | 2019-12-06 21:42:45 -0700 | [diff] [blame] | 1000 | U_BOOT_DRIVER(intel_fast_spi) = { |
| 1001 | .name = "intel_fast_spi", |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 1002 | .id = UCLASS_SPI, |
| 1003 | .of_match = ich_spi_ids, |
| 1004 | .ops = &ich_spi_ops, |
Bin Meng | 1f9eb59 | 2016-02-01 01:40:37 -0800 | [diff] [blame] | 1005 | .ofdata_to_platdata = ich_spi_ofdata_to_platdata, |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 1006 | .platdata_auto_alloc_size = sizeof(struct ich_spi_platdata), |
| 1007 | .priv_auto_alloc_size = sizeof(struct ich_spi_priv), |
| 1008 | .child_pre_probe = ich_spi_child_pre_probe, |
| 1009 | .probe = ich_spi_probe, |
Stefan Roese | 4759dff | 2017-04-24 09:48:04 +0200 | [diff] [blame] | 1010 | .remove = ich_spi_remove, |
| 1011 | .flags = DM_FLAG_OS_PREPARE, |
Simon Glass | ba45756 | 2015-03-26 09:29:26 -0600 | [diff] [blame] | 1012 | }; |