Carl-Daniel Hailfinger | 7053926 | 2007-10-15 21:45:29 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the flashrom project. |
| 3 | * |
Carl-Daniel Hailfinger | 3431bb7 | 2009-06-24 08:28:39 +0000 | [diff] [blame] | 4 | * Copyright (C) 2007, 2008, 2009 Carl-Daniel Hailfinger |
Stefan Reinauer | a9424d5 | 2008-06-27 16:28:34 +0000 | [diff] [blame] | 5 | * Copyright (C) 2008 coresystems GmbH |
Carl-Daniel Hailfinger | 7053926 | 2007-10-15 21:45:29 +0000 | [diff] [blame] | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; version 2 of the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | */ |
| 20 | |
| 21 | /* |
| 22 | * Contains the generic SPI framework |
| 23 | */ |
| 24 | |
Patrick Georgi | 97bc95c | 2011-03-08 07:17:44 +0000 | [diff] [blame] | 25 | #include <strings.h> |
Carl-Daniel Hailfinger | ec489e4 | 2010-09-15 00:13:02 +0000 | [diff] [blame] | 26 | #include <string.h> |
Carl-Daniel Hailfinger | 7053926 | 2007-10-15 21:45:29 +0000 | [diff] [blame] | 27 | #include "flash.h" |
Carl-Daniel Hailfinger | 0845464 | 2009-06-15 14:14:48 +0000 | [diff] [blame] | 28 | #include "flashchips.h" |
Sean Nelson | 14ba668 | 2010-02-26 05:48:29 +0000 | [diff] [blame] | 29 | #include "chipdrivers.h" |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 30 | #include "programmer.h" |
Carl-Daniel Hailfinger | d6cbf76 | 2008-05-13 14:58:23 +0000 | [diff] [blame] | 31 | #include "spi.h" |
Carl-Daniel Hailfinger | 7053926 | 2007-10-15 21:45:29 +0000 | [diff] [blame] | 32 | |
Carl-Daniel Hailfinger | 1dfe0ff | 2009-05-31 17:57:34 +0000 | [diff] [blame] | 33 | enum spi_controller spi_controller = SPI_CONTROLLER_NONE; |
Carl-Daniel Hailfinger | 1dfe0ff | 2009-05-31 17:57:34 +0000 | [diff] [blame] | 34 | |
Carl-Daniel Hailfinger | 02487aa | 2009-07-22 15:36:50 +0000 | [diff] [blame] | 35 | const struct spi_programmer spi_programmer[] = { |
| 36 | { /* SPI_CONTROLLER_NONE */ |
| 37 | .command = NULL, |
| 38 | .multicommand = NULL, |
| 39 | .read = NULL, |
| 40 | .write_256 = NULL, |
| 41 | }, |
| 42 | |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 43 | #if CONFIG_INTERNAL == 1 |
Carl-Daniel Hailfinger | cceafa2 | 2010-05-26 01:45:41 +0000 | [diff] [blame] | 44 | #if defined(__i386__) || defined(__x86_64__) |
Carl-Daniel Hailfinger | 02487aa | 2009-07-22 15:36:50 +0000 | [diff] [blame] | 45 | { /* SPI_CONTROLLER_ICH7 */ |
| 46 | .command = ich_spi_send_command, |
| 47 | .multicommand = ich_spi_send_multicommand, |
| 48 | .read = ich_spi_read, |
| 49 | .write_256 = ich_spi_write_256, |
| 50 | }, |
| 51 | |
| 52 | { /* SPI_CONTROLLER_ICH9 */ |
| 53 | .command = ich_spi_send_command, |
| 54 | .multicommand = ich_spi_send_multicommand, |
| 55 | .read = ich_spi_read, |
| 56 | .write_256 = ich_spi_write_256, |
| 57 | }, |
| 58 | |
David Hendricks | 4e74839 | 2011-02-28 23:58:15 +0000 | [diff] [blame] | 59 | { /* SPI_CONTROLLER_IT85XX */ |
| 60 | .command = it85xx_spi_send_command, |
| 61 | .multicommand = default_spi_send_multicommand, |
Carl-Daniel Hailfinger | 7f517a7 | 2011-03-08 00:23:49 +0000 | [diff] [blame] | 62 | .read = it85_spi_read, |
| 63 | .write_256 = it85_spi_write_256, |
David Hendricks | 4e74839 | 2011-02-28 23:58:15 +0000 | [diff] [blame] | 64 | }, |
| 65 | |
Carl-Daniel Hailfinger | 02487aa | 2009-07-22 15:36:50 +0000 | [diff] [blame] | 66 | { /* SPI_CONTROLLER_IT87XX */ |
| 67 | .command = it8716f_spi_send_command, |
| 68 | .multicommand = default_spi_send_multicommand, |
| 69 | .read = it8716f_spi_chip_read, |
| 70 | .write_256 = it8716f_spi_chip_write_256, |
| 71 | }, |
| 72 | |
| 73 | { /* SPI_CONTROLLER_SB600 */ |
| 74 | .command = sb600_spi_send_command, |
| 75 | .multicommand = default_spi_send_multicommand, |
| 76 | .read = sb600_spi_read, |
Carl-Daniel Hailfinger | 9a795d8 | 2010-07-14 16:19:05 +0000 | [diff] [blame] | 77 | .write_256 = sb600_spi_write_256, |
Carl-Daniel Hailfinger | 02487aa | 2009-07-22 15:36:50 +0000 | [diff] [blame] | 78 | }, |
| 79 | |
| 80 | { /* SPI_CONTROLLER_VIA */ |
| 81 | .command = ich_spi_send_command, |
| 82 | .multicommand = ich_spi_send_multicommand, |
| 83 | .read = ich_spi_read, |
| 84 | .write_256 = ich_spi_write_256, |
| 85 | }, |
| 86 | |
| 87 | { /* SPI_CONTROLLER_WBSIO */ |
| 88 | .command = wbsio_spi_send_command, |
| 89 | .multicommand = default_spi_send_multicommand, |
| 90 | .read = wbsio_spi_read, |
Carl-Daniel Hailfinger | 75a58f9 | 2010-10-13 22:26:56 +0000 | [diff] [blame] | 91 | .write_256 = spi_chip_write_1, |
Carl-Daniel Hailfinger | 02487aa | 2009-07-22 15:36:50 +0000 | [diff] [blame] | 92 | }, |
Carl-Daniel Hailfinger | 2f43616 | 2010-07-28 15:08:35 +0000 | [diff] [blame] | 93 | |
| 94 | { /* SPI_CONTROLLER_MCP6X_BITBANG */ |
| 95 | .command = bitbang_spi_send_command, |
| 96 | .multicommand = default_spi_send_multicommand, |
| 97 | .read = bitbang_spi_read, |
| 98 | .write_256 = bitbang_spi_write_256, |
| 99 | }, |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 100 | #endif |
Carl-Daniel Hailfinger | cceafa2 | 2010-05-26 01:45:41 +0000 | [diff] [blame] | 101 | #endif |
Carl-Daniel Hailfinger | 02487aa | 2009-07-22 15:36:50 +0000 | [diff] [blame] | 102 | |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 103 | #if CONFIG_FT2232_SPI == 1 |
Carl-Daniel Hailfinger | 02487aa | 2009-07-22 15:36:50 +0000 | [diff] [blame] | 104 | { /* SPI_CONTROLLER_FT2232 */ |
| 105 | .command = ft2232_spi_send_command, |
| 106 | .multicommand = default_spi_send_multicommand, |
| 107 | .read = ft2232_spi_read, |
| 108 | .write_256 = ft2232_spi_write_256, |
| 109 | }, |
Carl-Daniel Hailfinger | 3426ef6 | 2009-08-19 13:27:58 +0000 | [diff] [blame] | 110 | #endif |
Carl-Daniel Hailfinger | 02487aa | 2009-07-22 15:36:50 +0000 | [diff] [blame] | 111 | |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 112 | #if CONFIG_DUMMY == 1 |
Carl-Daniel Hailfinger | 02487aa | 2009-07-22 15:36:50 +0000 | [diff] [blame] | 113 | { /* SPI_CONTROLLER_DUMMY */ |
| 114 | .command = dummy_spi_send_command, |
| 115 | .multicommand = default_spi_send_multicommand, |
Carl-Daniel Hailfinger | 1b0ba89 | 2010-06-20 10:58:32 +0000 | [diff] [blame] | 116 | .read = dummy_spi_read, |
Carl-Daniel Hailfinger | 9a795d8 | 2010-07-14 16:19:05 +0000 | [diff] [blame] | 117 | .write_256 = dummy_spi_write_256, |
Carl-Daniel Hailfinger | 02487aa | 2009-07-22 15:36:50 +0000 | [diff] [blame] | 118 | }, |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 119 | #endif |
Carl-Daniel Hailfinger | 3426ef6 | 2009-08-19 13:27:58 +0000 | [diff] [blame] | 120 | |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 121 | #if CONFIG_BUSPIRATE_SPI == 1 |
Carl-Daniel Hailfinger | 5cca01f | 2009-11-24 00:20:03 +0000 | [diff] [blame] | 122 | { /* SPI_CONTROLLER_BUSPIRATE */ |
| 123 | .command = buspirate_spi_send_command, |
| 124 | .multicommand = default_spi_send_multicommand, |
| 125 | .read = buspirate_spi_read, |
Carl-Daniel Hailfinger | 408e47a | 2010-03-22 03:30:58 +0000 | [diff] [blame] | 126 | .write_256 = buspirate_spi_write_256, |
Carl-Daniel Hailfinger | 5cca01f | 2009-11-24 00:20:03 +0000 | [diff] [blame] | 127 | }, |
| 128 | #endif |
| 129 | |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 130 | #if CONFIG_DEDIPROG == 1 |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 131 | { /* SPI_CONTROLLER_DEDIPROG */ |
| 132 | .command = dediprog_spi_send_command, |
| 133 | .multicommand = default_spi_send_multicommand, |
| 134 | .read = dediprog_spi_read, |
Carl-Daniel Hailfinger | 306b818 | 2010-11-23 21:28:16 +0000 | [diff] [blame] | 135 | .write_256 = dediprog_spi_write_256, |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 136 | }, |
| 137 | #endif |
| 138 | |
Carl-Daniel Hailfinger | e7fdd6e | 2010-07-21 10:26:01 +0000 | [diff] [blame] | 139 | #if CONFIG_RAYER_SPI == 1 |
| 140 | { /* SPI_CONTROLLER_RAYER */ |
| 141 | .command = bitbang_spi_send_command, |
| 142 | .multicommand = default_spi_send_multicommand, |
| 143 | .read = bitbang_spi_read, |
| 144 | .write_256 = bitbang_spi_write_256, |
| 145 | }, |
| 146 | #endif |
| 147 | |
Idwer Vollering | 004f4b7 | 2010-09-03 18:21:21 +0000 | [diff] [blame] | 148 | #if CONFIG_NICINTEL_SPI == 1 |
| 149 | { /* SPI_CONTROLLER_NICINTEL */ |
| 150 | .command = bitbang_spi_send_command, |
| 151 | .multicommand = default_spi_send_multicommand, |
| 152 | .read = bitbang_spi_read, |
| 153 | .write_256 = bitbang_spi_write_256, |
| 154 | }, |
| 155 | #endif |
| 156 | |
Mark Marshall | 90021f2 | 2010-12-03 14:48:11 +0000 | [diff] [blame] | 157 | #if CONFIG_OGP_SPI == 1 |
| 158 | { /* SPI_CONTROLLER_OGP */ |
| 159 | .command = bitbang_spi_send_command, |
| 160 | .multicommand = default_spi_send_multicommand, |
| 161 | .read = bitbang_spi_read, |
| 162 | .write_256 = bitbang_spi_write_256, |
| 163 | }, |
| 164 | #endif |
| 165 | |
Carl-Daniel Hailfinger | 3426ef6 | 2009-08-19 13:27:58 +0000 | [diff] [blame] | 166 | {}, /* This entry corresponds to SPI_CONTROLLER_INVALID. */ |
Carl-Daniel Hailfinger | 02487aa | 2009-07-22 15:36:50 +0000 | [diff] [blame] | 167 | }; |
| 168 | |
Carl-Daniel Hailfinger | 3426ef6 | 2009-08-19 13:27:58 +0000 | [diff] [blame] | 169 | const int spi_programmer_count = ARRAY_SIZE(spi_programmer); |
Carl-Daniel Hailfinger | 02487aa | 2009-07-22 15:36:50 +0000 | [diff] [blame] | 170 | |
Carl-Daniel Hailfinger | d047829 | 2009-07-10 21:08:55 +0000 | [diff] [blame] | 171 | int spi_send_command(unsigned int writecnt, unsigned int readcnt, |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 172 | const unsigned char *writearr, unsigned char *readarr) |
Carl-Daniel Hailfinger | 3d94a0e | 2007-10-16 21:09:06 +0000 | [diff] [blame] | 173 | { |
Carl-Daniel Hailfinger | 02487aa | 2009-07-22 15:36:50 +0000 | [diff] [blame] | 174 | if (!spi_programmer[spi_controller].command) { |
Sean Nelson | 316a29f | 2010-05-07 20:09:04 +0000 | [diff] [blame] | 175 | msg_perr("%s called, but SPI is unsupported on this " |
Carl-Daniel Hailfinger | 8ae500e | 2010-06-20 10:39:33 +0000 | [diff] [blame] | 176 | "hardware. Please report a bug at " |
| 177 | "flashrom@flashrom.org\n", __func__); |
Carl-Daniel Hailfinger | 02487aa | 2009-07-22 15:36:50 +0000 | [diff] [blame] | 178 | return 1; |
Stefan Reinauer | 2cb94e1 | 2008-06-30 23:45:22 +0000 | [diff] [blame] | 179 | } |
Carl-Daniel Hailfinger | 02487aa | 2009-07-22 15:36:50 +0000 | [diff] [blame] | 180 | |
| 181 | return spi_programmer[spi_controller].command(writecnt, readcnt, |
| 182 | writearr, readarr); |
Carl-Daniel Hailfinger | 3d94a0e | 2007-10-16 21:09:06 +0000 | [diff] [blame] | 183 | } |
| 184 | |
Carl-Daniel Hailfinger | 26f7e64 | 2009-09-18 15:50:56 +0000 | [diff] [blame] | 185 | int spi_send_multicommand(struct spi_command *cmds) |
Carl-Daniel Hailfinger | d047829 | 2009-07-10 21:08:55 +0000 | [diff] [blame] | 186 | { |
Carl-Daniel Hailfinger | 02487aa | 2009-07-22 15:36:50 +0000 | [diff] [blame] | 187 | if (!spi_programmer[spi_controller].multicommand) { |
Sean Nelson | 316a29f | 2010-05-07 20:09:04 +0000 | [diff] [blame] | 188 | msg_perr("%s called, but SPI is unsupported on this " |
Carl-Daniel Hailfinger | 8ae500e | 2010-06-20 10:39:33 +0000 | [diff] [blame] | 189 | "hardware. Please report a bug at " |
| 190 | "flashrom@flashrom.org\n", __func__); |
Carl-Daniel Hailfinger | 02487aa | 2009-07-22 15:36:50 +0000 | [diff] [blame] | 191 | return 1; |
Carl-Daniel Hailfinger | d047829 | 2009-07-10 21:08:55 +0000 | [diff] [blame] | 192 | } |
Carl-Daniel Hailfinger | 02487aa | 2009-07-22 15:36:50 +0000 | [diff] [blame] | 193 | |
Carl-Daniel Hailfinger | 26f7e64 | 2009-09-18 15:50:56 +0000 | [diff] [blame] | 194 | return spi_programmer[spi_controller].multicommand(cmds); |
Carl-Daniel Hailfinger | 02487aa | 2009-07-22 15:36:50 +0000 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | int default_spi_send_command(unsigned int writecnt, unsigned int readcnt, |
| 198 | const unsigned char *writearr, unsigned char *readarr) |
| 199 | { |
| 200 | struct spi_command cmd[] = { |
| 201 | { |
| 202 | .writecnt = writecnt, |
| 203 | .readcnt = readcnt, |
| 204 | .writearr = writearr, |
| 205 | .readarr = readarr, |
| 206 | }, { |
| 207 | .writecnt = 0, |
| 208 | .writearr = NULL, |
| 209 | .readcnt = 0, |
| 210 | .readarr = NULL, |
| 211 | }}; |
| 212 | |
| 213 | return spi_send_multicommand(cmd); |
| 214 | } |
| 215 | |
Carl-Daniel Hailfinger | 26f7e64 | 2009-09-18 15:50:56 +0000 | [diff] [blame] | 216 | int default_spi_send_multicommand(struct spi_command *cmds) |
Carl-Daniel Hailfinger | 02487aa | 2009-07-22 15:36:50 +0000 | [diff] [blame] | 217 | { |
| 218 | int result = 0; |
Carl-Daniel Hailfinger | 26f7e64 | 2009-09-18 15:50:56 +0000 | [diff] [blame] | 219 | for (; (cmds->writecnt || cmds->readcnt) && !result; cmds++) { |
| 220 | result = spi_send_command(cmds->writecnt, cmds->readcnt, |
| 221 | cmds->writearr, cmds->readarr); |
Carl-Daniel Hailfinger | 02487aa | 2009-07-22 15:36:50 +0000 | [diff] [blame] | 222 | } |
| 223 | return result; |
Carl-Daniel Hailfinger | d047829 | 2009-07-10 21:08:55 +0000 | [diff] [blame] | 224 | } |
| 225 | |
Carl-Daniel Hailfinger | cbf563c | 2009-06-16 08:55:44 +0000 | [diff] [blame] | 226 | int spi_chip_read(struct flashchip *flash, uint8_t *buf, int start, int len) |
Ronald Hoogenboom | 7ff530b | 2008-01-19 00:04:46 +0000 | [diff] [blame] | 227 | { |
Carl-Daniel Hailfinger | ec489e4 | 2010-09-15 00:13:02 +0000 | [diff] [blame] | 228 | int addrbase = 0; |
Carl-Daniel Hailfinger | 02487aa | 2009-07-22 15:36:50 +0000 | [diff] [blame] | 229 | if (!spi_programmer[spi_controller].read) { |
Carl-Daniel Hailfinger | 8ae500e | 2010-06-20 10:39:33 +0000 | [diff] [blame] | 230 | msg_perr("%s called, but SPI read is unsupported on this " |
| 231 | "hardware. Please report a bug at " |
| 232 | "flashrom@flashrom.org\n", __func__); |
Carl-Daniel Hailfinger | 02487aa | 2009-07-22 15:36:50 +0000 | [diff] [blame] | 233 | return 1; |
Stefan Reinauer | 2cb94e1 | 2008-06-30 23:45:22 +0000 | [diff] [blame] | 234 | } |
| 235 | |
Carl-Daniel Hailfinger | ec489e4 | 2010-09-15 00:13:02 +0000 | [diff] [blame] | 236 | /* Check if the chip fits between lowest valid and highest possible |
| 237 | * address. Highest possible address with the current SPI implementation |
| 238 | * means 0xffffff, the highest unsigned 24bit number. |
| 239 | */ |
| 240 | addrbase = spi_get_valid_read_addr(); |
| 241 | if (addrbase + flash->total_size * 1024 > (1 << 24)) { |
| 242 | msg_perr("Flash chip size exceeds the allowed access window. "); |
| 243 | msg_perr("Read will probably fail.\n"); |
| 244 | /* Try to get the best alignment subject to constraints. */ |
| 245 | addrbase = (1 << 24) - flash->total_size * 1024; |
| 246 | } |
| 247 | /* Check if alignment is native (at least the largest power of two which |
| 248 | * is a factor of the mapped size of the chip). |
| 249 | */ |
| 250 | if (ffs(flash->total_size * 1024) > (ffs(addrbase) ? : 33)) { |
| 251 | msg_perr("Flash chip is not aligned natively in the allowed " |
| 252 | "access window.\n"); |
| 253 | msg_perr("Read will probably return garbage.\n"); |
| 254 | } |
| 255 | return spi_programmer[spi_controller].read(flash, buf, addrbase + start, len); |
Ronald Hoogenboom | 7ff530b | 2008-01-19 00:04:46 +0000 | [diff] [blame] | 256 | } |
| 257 | |
Carl-Daniel Hailfinger | 96930c3 | 2009-05-09 02:30:21 +0000 | [diff] [blame] | 258 | /* |
Carl-Daniel Hailfinger | 96930c3 | 2009-05-09 02:30:21 +0000 | [diff] [blame] | 259 | * Program chip using page (256 bytes) programming. |
| 260 | * Some SPI masters can't do this, they use single byte programming instead. |
Carl-Daniel Hailfinger | 9a795d8 | 2010-07-14 16:19:05 +0000 | [diff] [blame] | 261 | * The redirect to single byte programming is achieved by setting |
| 262 | * .write_256 = spi_chip_write_1 |
Carl-Daniel Hailfinger | 96930c3 | 2009-05-09 02:30:21 +0000 | [diff] [blame] | 263 | */ |
Carl-Daniel Hailfinger | 9a795d8 | 2010-07-14 16:19:05 +0000 | [diff] [blame] | 264 | /* real chunksize is up to 256, logical chunksize is 256 */ |
Carl-Daniel Hailfinger | 75a58f9 | 2010-10-13 22:26:56 +0000 | [diff] [blame] | 265 | int spi_chip_write_256(struct flashchip *flash, uint8_t *buf, int start, int len) |
Carl-Daniel Hailfinger | bfe5b4a | 2008-05-13 23:03:12 +0000 | [diff] [blame] | 266 | { |
Carl-Daniel Hailfinger | 02487aa | 2009-07-22 15:36:50 +0000 | [diff] [blame] | 267 | if (!spi_programmer[spi_controller].write_256) { |
Carl-Daniel Hailfinger | 8ae500e | 2010-06-20 10:39:33 +0000 | [diff] [blame] | 268 | msg_perr("%s called, but SPI page write is unsupported on this " |
| 269 | "hardware. Please report a bug at " |
| 270 | "flashrom@flashrom.org\n", __func__); |
Carl-Daniel Hailfinger | 02487aa | 2009-07-22 15:36:50 +0000 | [diff] [blame] | 271 | return 1; |
Stefan Reinauer | 2cb94e1 | 2008-06-30 23:45:22 +0000 | [diff] [blame] | 272 | } |
| 273 | |
Carl-Daniel Hailfinger | 9a795d8 | 2010-07-14 16:19:05 +0000 | [diff] [blame] | 274 | return spi_programmer[spi_controller].write_256(flash, buf, start, len); |
| 275 | } |
| 276 | |
Carl-Daniel Hailfinger | 80f3d05 | 2010-05-28 15:53:08 +0000 | [diff] [blame] | 277 | /* |
| 278 | * Get the lowest allowed address for read accesses. This often happens to |
| 279 | * be the lowest allowed address for all commands which take an address. |
| 280 | * This is a programmer limitation. |
| 281 | */ |
Carl-Daniel Hailfinger | 3e9dbea | 2009-05-13 11:40:08 +0000 | [diff] [blame] | 282 | uint32_t spi_get_valid_read_addr(void) |
| 283 | { |
Carl-Daniel Hailfinger | 80f3d05 | 2010-05-28 15:53:08 +0000 | [diff] [blame] | 284 | switch (spi_controller) { |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 285 | #if CONFIG_INTERNAL == 1 |
Carl-Daniel Hailfinger | 80f3d05 | 2010-05-28 15:53:08 +0000 | [diff] [blame] | 286 | #if defined(__i386__) || defined(__x86_64__) |
| 287 | case SPI_CONTROLLER_ICH7: |
| 288 | /* Return BBAR for ICH chipsets. */ |
| 289 | return ichspi_bbar; |
| 290 | #endif |
| 291 | #endif |
| 292 | default: |
| 293 | return 0; |
| 294 | } |
Carl-Daniel Hailfinger | 3e9dbea | 2009-05-13 11:40:08 +0000 | [diff] [blame] | 295 | } |