Angel Pons | 1ddb894 | 2020-04-04 18:51:26 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 2 | |
Kyösti Mälkki | 13f6650 | 2019-03-03 08:01:05 +0200 | [diff] [blame] | 3 | #include <device/mmio.h> |
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 4 | #include <assert.h> |
Julius Werner | 9b1f3cc | 2020-12-30 17:30:12 -0800 | [diff] [blame] | 5 | #include <cbfs.h> |
Julius Werner | 80af442 | 2014-10-20 13:18:56 -0700 | [diff] [blame] | 6 | #include <console/console.h> |
| 7 | #include <soc/cpu.h> |
| 8 | #include <soc/spi.h> |
Furquan Shaikh | c28984d | 2016-11-20 21:04:00 -0800 | [diff] [blame] | 9 | #include <spi-generic.h> |
Elyes HAOUAS | 7884c22 | 2020-07-27 08:12:59 +0200 | [diff] [blame] | 10 | #include <stddef.h> |
| 11 | #include <stdint.h> |
Gabe Black | 967058f | 2014-03-21 21:32:12 -0700 | [diff] [blame] | 12 | #include <string.h> |
Aaron Durbin | c6588c5 | 2015-05-15 13:15:34 -0500 | [diff] [blame] | 13 | #include <symbols.h> |
Hung-Te Lin | 45d524d2 | 2013-06-26 20:03:47 +0800 | [diff] [blame] | 14 | |
Hung-Te Lin | 8644207 | 2013-06-26 20:29:06 +0800 | [diff] [blame] | 15 | #define EXYNOS_SPI_MAX_TRANSFER_BYTES (65535) |
| 16 | |
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 17 | #if defined(CONFIG_DEBUG_SPI) && CONFIG_DEBUG_SPI |
| 18 | # define DEBUG_SPI(x,...) printk(BIOS_DEBUG, "EXYNOS_SPI: " x) |
| 19 | #else |
| 20 | # define DEBUG_SPI(x,...) |
| 21 | #endif |
| 22 | |
Hung-Te Lin | ffa5bad | 2013-06-26 20:16:13 +0800 | [diff] [blame] | 23 | struct exynos_spi_slave { |
| 24 | struct spi_slave slave; |
| 25 | struct exynos_spi *regs; |
Gabe Black | 967058f | 2014-03-21 21:32:12 -0700 | [diff] [blame] | 26 | int initialized; |
Hung-Te Lin | ffa5bad | 2013-06-26 20:16:13 +0800 | [diff] [blame] | 27 | }; |
| 28 | |
Hung-Te Lin | ed1742c | 2013-06-26 20:17:42 +0800 | [diff] [blame] | 29 | /* TODO(hungte) Move the SPI param list to per-board configuration, probably |
| 30 | * Kconfig or mainboard.c */ |
| 31 | static struct exynos_spi_slave exynos_spi_slaves[3] = { |
| 32 | // SPI 0 |
| 33 | { |
| 34 | .slave = { .bus = 0, }, |
Julius Werner | fa938c7 | 2013-08-29 14:17:36 -0700 | [diff] [blame] | 35 | .regs = (void *)EXYNOS5_SPI0_BASE, |
Hung-Te Lin | ed1742c | 2013-06-26 20:17:42 +0800 | [diff] [blame] | 36 | }, |
| 37 | // SPI 1 |
| 38 | { |
Furquan Shaikh | c28984d | 2016-11-20 21:04:00 -0800 | [diff] [blame] | 39 | .slave = { .bus = 1, }, |
Julius Werner | fa938c7 | 2013-08-29 14:17:36 -0700 | [diff] [blame] | 40 | .regs = (void *)EXYNOS5_SPI1_BASE, |
Hung-Te Lin | ed1742c | 2013-06-26 20:17:42 +0800 | [diff] [blame] | 41 | }, |
| 42 | // SPI 2 |
| 43 | { |
Furquan Shaikh | c28984d | 2016-11-20 21:04:00 -0800 | [diff] [blame] | 44 | .slave = { .bus = 2, }, |
Julius Werner | fa938c7 | 2013-08-29 14:17:36 -0700 | [diff] [blame] | 45 | .regs = (void *)EXYNOS5_SPI2_BASE, |
Hung-Te Lin | ed1742c | 2013-06-26 20:17:42 +0800 | [diff] [blame] | 46 | }, |
| 47 | }; |
| 48 | |
Furquan Shaikh | 0dba025 | 2016-11-30 04:34:22 -0800 | [diff] [blame] | 49 | static inline struct exynos_spi_slave *to_exynos_spi(const struct spi_slave *slave) |
Hung-Te Lin | ffa5bad | 2013-06-26 20:16:13 +0800 | [diff] [blame] | 50 | { |
Furquan Shaikh | 36b81af | 2016-12-01 01:02:44 -0800 | [diff] [blame] | 51 | return &exynos_spi_slaves[slave->bus]; |
Hung-Te Lin | ffa5bad | 2013-06-26 20:16:13 +0800 | [diff] [blame] | 52 | } |
| 53 | |
Gabe Black | 967058f | 2014-03-21 21:32:12 -0700 | [diff] [blame] | 54 | static void spi_sw_reset(struct exynos_spi *regs, int word) |
| 55 | { |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 56 | const uint32_t orig_mode_cfg = read32(®s->mode_cfg); |
Gabe Black | 967058f | 2014-03-21 21:32:12 -0700 | [diff] [blame] | 57 | uint32_t mode_cfg = orig_mode_cfg; |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 58 | const uint32_t orig_swap_cfg = read32(®s->swap_cfg); |
Gabe Black | 967058f | 2014-03-21 21:32:12 -0700 | [diff] [blame] | 59 | uint32_t swap_cfg = orig_swap_cfg; |
| 60 | |
| 61 | mode_cfg &= ~(SPI_MODE_CH_WIDTH_MASK | SPI_MODE_BUS_WIDTH_MASK); |
| 62 | if (word) { |
| 63 | mode_cfg |= SPI_MODE_CH_WIDTH_WORD | SPI_MODE_BUS_WIDTH_WORD; |
| 64 | swap_cfg |= SPI_RX_SWAP_EN | |
| 65 | SPI_RX_BYTE_SWAP | |
| 66 | SPI_RX_HWORD_SWAP | |
| 67 | SPI_TX_SWAP_EN | |
| 68 | SPI_TX_BYTE_SWAP | |
| 69 | SPI_TX_HWORD_SWAP; |
| 70 | } else { |
| 71 | mode_cfg |= SPI_MODE_CH_WIDTH_BYTE | SPI_MODE_BUS_WIDTH_BYTE; |
| 72 | swap_cfg = 0; |
| 73 | } |
| 74 | |
| 75 | if (mode_cfg != orig_mode_cfg) |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 76 | write32(®s->mode_cfg, mode_cfg); |
Gabe Black | 967058f | 2014-03-21 21:32:12 -0700 | [diff] [blame] | 77 | if (swap_cfg != orig_swap_cfg) |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 78 | write32(®s->swap_cfg, swap_cfg); |
Gabe Black | 967058f | 2014-03-21 21:32:12 -0700 | [diff] [blame] | 79 | |
Julius Werner | 55009af | 2019-12-02 22:03:27 -0800 | [diff] [blame] | 80 | clrbits32(®s->ch_cfg, SPI_RX_CH_ON | SPI_TX_CH_ON); |
| 81 | setbits32(®s->ch_cfg, SPI_CH_RST); |
| 82 | clrbits32(®s->ch_cfg, SPI_CH_RST); |
| 83 | setbits32(®s->ch_cfg, SPI_RX_CH_ON | SPI_TX_CH_ON); |
Gabe Black | 967058f | 2014-03-21 21:32:12 -0700 | [diff] [blame] | 84 | } |
| 85 | |
Gabe Black | 967058f | 2014-03-21 21:32:12 -0700 | [diff] [blame] | 86 | static void exynos_spi_init(struct exynos_spi *regs) |
| 87 | { |
| 88 | // Set FB_CLK_SEL. |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 89 | write32(®s->fb_clk, SPI_FB_DELAY_180); |
Gabe Black | 967058f | 2014-03-21 21:32:12 -0700 | [diff] [blame] | 90 | // CPOL: Active high. |
Julius Werner | 55009af | 2019-12-02 22:03:27 -0800 | [diff] [blame] | 91 | clrbits32(®s->ch_cfg, SPI_CH_CPOL_L); |
Gabe Black | 967058f | 2014-03-21 21:32:12 -0700 | [diff] [blame] | 92 | |
Elyes HAOUAS | 1b296ee | 2020-02-19 20:48:29 +0100 | [diff] [blame] | 93 | // Clear rx and tx channel if set previously. |
Julius Werner | 55009af | 2019-12-02 22:03:27 -0800 | [diff] [blame] | 94 | clrbits32(®s->ch_cfg, SPI_RX_CH_ON | SPI_TX_CH_ON); |
Gabe Black | 967058f | 2014-03-21 21:32:12 -0700 | [diff] [blame] | 95 | |
Julius Werner | 55009af | 2019-12-02 22:03:27 -0800 | [diff] [blame] | 96 | setbits32(®s->swap_cfg, |
Gabe Black | 967058f | 2014-03-21 21:32:12 -0700 | [diff] [blame] | 97 | SPI_RX_SWAP_EN | SPI_RX_BYTE_SWAP | SPI_RX_HWORD_SWAP); |
Julius Werner | 55009af | 2019-12-02 22:03:27 -0800 | [diff] [blame] | 98 | clrbits32(®s->ch_cfg, SPI_CH_HS_EN); |
Gabe Black | 967058f | 2014-03-21 21:32:12 -0700 | [diff] [blame] | 99 | |
| 100 | // Do a soft reset, which will also enable both channels. |
| 101 | spi_sw_reset(regs, 1); |
Hung-Te Lin | ffa5bad | 2013-06-26 20:16:13 +0800 | [diff] [blame] | 102 | } |
| 103 | |
Furquan Shaikh | 94f8699 | 2016-12-01 07:12:32 -0800 | [diff] [blame] | 104 | static int spi_ctrlr_claim_bus(const struct spi_slave *slave) |
Hung-Te Lin | ffa5bad | 2013-06-26 20:16:13 +0800 | [diff] [blame] | 105 | { |
| 106 | struct exynos_spi *regs = to_exynos_spi(slave)->regs; |
| 107 | // TODO(hungte) Add some delay if too many transactions happen at once. |
Julius Werner | 55009af | 2019-12-02 22:03:27 -0800 | [diff] [blame] | 108 | clrbits32(®s->cs_reg, SPI_SLAVE_SIG_INACT); |
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 109 | return 0; |
| 110 | } |
| 111 | |
Gabe Black | 967058f | 2014-03-21 21:32:12 -0700 | [diff] [blame] | 112 | static void spi_transfer(struct exynos_spi *regs, void *in, const void *out, |
Furquan Shaikh | 0dba025 | 2016-11-30 04:34:22 -0800 | [diff] [blame] | 113 | size_t size) |
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 114 | { |
Gabe Black | 967058f | 2014-03-21 21:32:12 -0700 | [diff] [blame] | 115 | u8 *inb = in; |
| 116 | const u8 *outb = out; |
Hung-Te Lin | a965a37 | 2013-06-26 20:31:22 +0800 | [diff] [blame] | 117 | |
Furquan Shaikh | 0dba025 | 2016-11-30 04:34:22 -0800 | [diff] [blame] | 118 | size_t width = (size % 4) ? 1 : 4; |
Hung-Te Lin | a965a37 | 2013-06-26 20:31:22 +0800 | [diff] [blame] | 119 | |
Gabe Black | 967058f | 2014-03-21 21:32:12 -0700 | [diff] [blame] | 120 | while (size) { |
Furquan Shaikh | 0dba025 | 2016-11-30 04:34:22 -0800 | [diff] [blame] | 121 | size_t packets = size / width; |
Gabe Black | 967058f | 2014-03-21 21:32:12 -0700 | [diff] [blame] | 122 | // The packet count field is 16 bits wide. |
| 123 | packets = MIN(packets, (1 << 16) - 1); |
| 124 | |
Furquan Shaikh | 0dba025 | 2016-11-30 04:34:22 -0800 | [diff] [blame] | 125 | size_t out_bytes, in_bytes; |
Gabe Black | 967058f | 2014-03-21 21:32:12 -0700 | [diff] [blame] | 126 | out_bytes = in_bytes = packets * width; |
| 127 | |
| 128 | spi_sw_reset(regs, width == 4); |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 129 | write32(®s->pkt_cnt, packets | SPI_PACKET_CNT_EN); |
Gabe Black | 967058f | 2014-03-21 21:32:12 -0700 | [diff] [blame] | 130 | |
| 131 | while (out_bytes || in_bytes) { |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 132 | uint32_t spi_sts = read32(®s->spi_sts); |
Gabe Black | 967058f | 2014-03-21 21:32:12 -0700 | [diff] [blame] | 133 | int rx_lvl = ((spi_sts >> 15) & 0x1ff); |
| 134 | int tx_lvl = ((spi_sts >> 6) & 0x1ff); |
| 135 | |
| 136 | if (tx_lvl < 32 && tx_lvl < out_bytes) { |
| 137 | uint32_t data = 0xffffffff; |
| 138 | |
| 139 | if (outb) { |
| 140 | memcpy(&data, outb, width); |
| 141 | outb += width; |
| 142 | } |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 143 | write32(®s->tx_data, data); |
Gabe Black | 967058f | 2014-03-21 21:32:12 -0700 | [diff] [blame] | 144 | |
| 145 | out_bytes -= width; |
| 146 | } |
| 147 | |
| 148 | if (rx_lvl >= width) { |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 149 | uint32_t data = read32(®s->rx_data); |
Gabe Black | 967058f | 2014-03-21 21:32:12 -0700 | [diff] [blame] | 150 | |
| 151 | if (inb) { |
| 152 | memcpy(inb, &data, width); |
| 153 | inb += width; |
| 154 | } |
| 155 | |
| 156 | in_bytes -= width; |
| 157 | } |
Hung-Te Lin | a965a37 | 2013-06-26 20:31:22 +0800 | [diff] [blame] | 158 | } |
Gabe Black | 967058f | 2014-03-21 21:32:12 -0700 | [diff] [blame] | 159 | |
| 160 | size -= packets * width; |
Hung-Te Lin | a965a37 | 2013-06-26 20:31:22 +0800 | [diff] [blame] | 161 | } |
Gabe Black | 967058f | 2014-03-21 21:32:12 -0700 | [diff] [blame] | 162 | } |
Hung-Te Lin | a965a37 | 2013-06-26 20:31:22 +0800 | [diff] [blame] | 163 | |
Furquan Shaikh | 94f8699 | 2016-12-01 07:12:32 -0800 | [diff] [blame] | 164 | static int spi_ctrlr_xfer(const struct spi_slave *slave, const void *dout, size_t bytes_out, |
Furquan Shaikh | 0dba025 | 2016-11-30 04:34:22 -0800 | [diff] [blame] | 165 | void *din, size_t bytes_in) |
Gabe Black | 967058f | 2014-03-21 21:32:12 -0700 | [diff] [blame] | 166 | { |
| 167 | struct exynos_spi *regs = to_exynos_spi(slave)->regs; |
| 168 | |
| 169 | if (bytes_out && bytes_in) { |
Furquan Shaikh | 0dba025 | 2016-11-30 04:34:22 -0800 | [diff] [blame] | 170 | size_t min_size = MIN(bytes_out, bytes_in); |
Gabe Black | 967058f | 2014-03-21 21:32:12 -0700 | [diff] [blame] | 171 | |
| 172 | spi_transfer(regs, din, dout, min_size); |
| 173 | |
| 174 | bytes_out -= min_size; |
| 175 | bytes_in -= min_size; |
| 176 | |
| 177 | din = (uint8_t *)din + min_size; |
| 178 | dout = (const uint8_t *)dout + min_size; |
| 179 | } |
| 180 | |
| 181 | if (bytes_in) |
| 182 | spi_transfer(regs, din, NULL, bytes_in); |
| 183 | else if (bytes_out) |
| 184 | spi_transfer(regs, NULL, dout, bytes_out); |
| 185 | |
| 186 | return 0; |
| 187 | } |
| 188 | |
Furquan Shaikh | 94f8699 | 2016-12-01 07:12:32 -0800 | [diff] [blame] | 189 | static void spi_ctrlr_release_bus(const struct spi_slave *slave) |
Gabe Black | 967058f | 2014-03-21 21:32:12 -0700 | [diff] [blame] | 190 | { |
Gabe Black | ec9293f | 2014-03-27 21:26:46 -0700 | [diff] [blame] | 191 | struct exynos_spi *regs = to_exynos_spi(slave)->regs; |
Julius Werner | 55009af | 2019-12-02 22:03:27 -0800 | [diff] [blame] | 192 | setbits32(®s->cs_reg, SPI_SLAVE_SIG_INACT); |
Hung-Te Lin | ffa5bad | 2013-06-26 20:16:13 +0800 | [diff] [blame] | 193 | } |
| 194 | |
Furquan Shaikh | f8662ca | 2017-05-18 14:44:04 -0700 | [diff] [blame] | 195 | static int spi_ctrlr_setup(const struct spi_slave *slave) |
Furquan Shaikh | 94f8699 | 2016-12-01 07:12:32 -0800 | [diff] [blame] | 196 | { |
Julius Werner | 7c712bb | 2019-05-01 16:51:20 -0700 | [diff] [blame] | 197 | ASSERT(slave->bus < 3); |
Furquan Shaikh | 94f8699 | 2016-12-01 07:12:32 -0800 | [diff] [blame] | 198 | struct exynos_spi_slave *eslave; |
| 199 | |
Furquan Shaikh | 94f8699 | 2016-12-01 07:12:32 -0800 | [diff] [blame] | 200 | eslave = to_exynos_spi(slave); |
| 201 | if (!eslave->initialized) { |
| 202 | exynos_spi_init(eslave->regs); |
| 203 | eslave->initialized = 1; |
| 204 | } |
| 205 | return 0; |
| 206 | } |
| 207 | |
Furquan Shaikh | f8662ca | 2017-05-18 14:44:04 -0700 | [diff] [blame] | 208 | static const struct spi_ctrlr spi_ctrlr = { |
| 209 | .setup = spi_ctrlr_setup, |
| 210 | .claim_bus = spi_ctrlr_claim_bus, |
| 211 | .release_bus = spi_ctrlr_release_bus, |
| 212 | .xfer = spi_ctrlr_xfer, |
| 213 | .max_xfer_size = SPI_CTRLR_DEFAULT_MAX_XFER_SIZE, |
| 214 | }; |
| 215 | |
| 216 | const struct spi_ctrlr_buses spi_ctrlr_bus_map[] = { |
| 217 | { |
| 218 | .ctrlr = &spi_ctrlr, |
| 219 | .bus_start = 0, |
| 220 | .bus_end = 2, |
| 221 | }, |
| 222 | }; |
| 223 | |
| 224 | const size_t spi_ctrlr_bus_map_count = ARRAY_SIZE(spi_ctrlr_bus_map); |
| 225 | |
Hung-Te Lin | ffa5bad | 2013-06-26 20:16:13 +0800 | [diff] [blame] | 226 | static int exynos_spi_read(struct spi_slave *slave, void *dest, uint32_t len, |
| 227 | uint32_t off) |
| 228 | { |
| 229 | struct exynos_spi *regs = to_exynos_spi(slave)->regs; |
Gabe Black | 967058f | 2014-03-21 21:32:12 -0700 | [diff] [blame] | 230 | u32 command; |
| 231 | spi_claim_bus(slave); |
Hung-Te Lin | e42030d | 2013-06-23 08:14:30 +0800 | [diff] [blame] | 232 | |
Gabe Black | 967058f | 2014-03-21 21:32:12 -0700 | [diff] [blame] | 233 | // Send address. |
Hung-Te Lin | a965a37 | 2013-06-26 20:31:22 +0800 | [diff] [blame] | 234 | ASSERT(off < (1 << 24)); |
Gabe Black | 967058f | 2014-03-21 21:32:12 -0700 | [diff] [blame] | 235 | command = htonl(SF_READ_DATA_CMD << 24 | off); |
| 236 | spi_transfer(regs, NULL, &command, sizeof(command)); |
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 237 | |
Gabe Black | 967058f | 2014-03-21 21:32:12 -0700 | [diff] [blame] | 238 | // Read the data. |
| 239 | spi_transfer(regs, dest, NULL, len); |
| 240 | spi_release_bus(slave); |
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 241 | |
Gabe Black | 967058f | 2014-03-21 21:32:12 -0700 | [diff] [blame] | 242 | return len; |
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 243 | } |
| 244 | |
Aaron Durbin | c6588c5 | 2015-05-15 13:15:34 -0500 | [diff] [blame] | 245 | static struct exynos_spi_slave *boot_slave; |
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 246 | |
Aaron Durbin | c6588c5 | 2015-05-15 13:15:34 -0500 | [diff] [blame] | 247 | static ssize_t exynos_spi_readat(const struct region_device *rdev, void *dest, |
| 248 | size_t offset, size_t count) |
Stefan Reinauer | ff0df2b | 2013-09-17 14:08:29 -0700 | [diff] [blame] | 249 | { |
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 250 | DEBUG_SPI("exynos_spi_cbfs_read(%u)\n", count); |
Aaron Durbin | c6588c5 | 2015-05-15 13:15:34 -0500 | [diff] [blame] | 251 | return exynos_spi_read(&boot_slave->slave, dest, count, offset); |
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 252 | } |
| 253 | |
Aaron Durbin | c6588c5 | 2015-05-15 13:15:34 -0500 | [diff] [blame] | 254 | static void *exynos_spi_map(const struct region_device *rdev, |
| 255 | size_t offset, size_t count) |
Stefan Reinauer | ff0df2b | 2013-09-17 14:08:29 -0700 | [diff] [blame] | 256 | { |
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 257 | DEBUG_SPI("exynos_spi_cbfs_map\n"); |
Hung-Te Lin | a965a37 | 2013-06-26 20:31:22 +0800 | [diff] [blame] | 258 | // exynos: spi_rx_tx may work in 4 byte-width-transmission mode and |
| 259 | // requires buffer memory address to be aligned. |
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 260 | if (count % 4) |
| 261 | count += 4 - (count % 4); |
Aaron Durbin | c6588c5 | 2015-05-15 13:15:34 -0500 | [diff] [blame] | 262 | return mmap_helper_rdev_mmap(rdev, offset, count); |
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 263 | } |
| 264 | |
Aaron Durbin | c6588c5 | 2015-05-15 13:15:34 -0500 | [diff] [blame] | 265 | static const struct region_device_ops exynos_spi_ops = { |
| 266 | .mmap = exynos_spi_map, |
| 267 | .munmap = mmap_helper_rdev_munmap, |
| 268 | .readat = exynos_spi_readat, |
| 269 | }; |
| 270 | |
| 271 | static struct mmap_helper_region_device mdev = |
Julius Werner | 9b1f3cc | 2020-12-30 17:30:12 -0800 | [diff] [blame] | 272 | MMAP_HELPER_DEV_INIT(&exynos_spi_ops, 0, CONFIG_ROM_SIZE, &cbfs_cache); |
Aaron Durbin | c6588c5 | 2015-05-15 13:15:34 -0500 | [diff] [blame] | 273 | |
| 274 | void exynos_init_spi_boot_device(void) |
Stefan Reinauer | ff0df2b | 2013-09-17 14:08:29 -0700 | [diff] [blame] | 275 | { |
Aaron Durbin | c6588c5 | 2015-05-15 13:15:34 -0500 | [diff] [blame] | 276 | boot_slave = &exynos_spi_slaves[1]; |
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 277 | } |
| 278 | |
Aaron Durbin | c6588c5 | 2015-05-15 13:15:34 -0500 | [diff] [blame] | 279 | const struct region_device *exynos_spi_boot_device(void) |
Stefan Reinauer | ff0df2b | 2013-09-17 14:08:29 -0700 | [diff] [blame] | 280 | { |
Aaron Durbin | c6588c5 | 2015-05-15 13:15:34 -0500 | [diff] [blame] | 281 | return &mdev.rdev; |
Gabe Black | 607c0b6 | 2013-05-16 05:45:57 -0700 | [diff] [blame] | 282 | } |