Adam Kaufman | 064b1f2 | 2007-02-06 19:47:50 +0000 | [diff] [blame] | 1 | /* |
Uwe Hermann | d110764 | 2007-08-29 17:52:32 +0000 | [diff] [blame] | 2 | * This file is part of the flashrom project. |
Adam Kaufman | 064b1f2 | 2007-02-06 19:47:50 +0000 | [diff] [blame] | 3 | * |
Uwe Hermann | d22a1d4 | 2007-09-09 20:21:05 +0000 | [diff] [blame] | 4 | * Copyright (C) 2000 Silicon Integrated System Corporation |
| 5 | * Copyright (C) 2000 Ronald G. Minnich <rminnich@gmail.com> |
Stefan Reinauer | 8fa6481 | 2009-08-12 09:27:45 +0000 | [diff] [blame] | 6 | * Copyright (C) 2005-2009 coresystems GmbH |
Carl-Daniel Hailfinger | a0a6ae9 | 2009-06-15 12:10:57 +0000 | [diff] [blame] | 7 | * Copyright (C) 2006-2009 Carl-Daniel Hailfinger |
Adam Kaufman | 064b1f2 | 2007-02-06 19:47:50 +0000 | [diff] [blame] | 8 | * |
Uwe Hermann | d110764 | 2007-08-29 17:52:32 +0000 | [diff] [blame] | 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation; either version 2 of the License, or |
| 12 | * (at your option) any later version. |
Adam Kaufman | 064b1f2 | 2007-02-06 19:47:50 +0000 | [diff] [blame] | 13 | * |
Uwe Hermann | d110764 | 2007-08-29 17:52:32 +0000 | [diff] [blame] | 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
Adam Kaufman | 064b1f2 | 2007-02-06 19:47:50 +0000 | [diff] [blame] | 18 | * |
Uwe Hermann | d110764 | 2007-08-29 17:52:32 +0000 | [diff] [blame] | 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
Adam Kaufman | 064b1f2 | 2007-02-06 19:47:50 +0000 | [diff] [blame] | 22 | */ |
| 23 | |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 24 | #ifndef __FLASH_H__ |
| 25 | #define __FLASH_H__ 1 |
| 26 | |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 27 | #include <stdint.h> |
Carl-Daniel Hailfinger | dd128c9 | 2010-06-03 00:49:50 +0000 | [diff] [blame] | 28 | #include <stddef.h> |
Carl-Daniel Hailfinger | 5d5c072 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 29 | #include "hwaccess.h" |
Patrick Georgi | e48654c | 2010-01-06 22:14:39 +0000 | [diff] [blame] | 30 | #ifdef _WIN32 |
| 31 | #include <windows.h> |
| 32 | #undef min |
| 33 | #undef max |
| 34 | #endif |
Andriy Gapon | 65c1b86 | 2008-05-22 13:22:45 +0000 | [diff] [blame] | 35 | |
Carl-Daniel Hailfinger | 5820f42 | 2009-05-16 21:22:56 +0000 | [diff] [blame] | 36 | typedef unsigned long chipaddr; |
| 37 | |
Carl-Daniel Hailfinger | 415e513 | 2009-08-12 11:39:29 +0000 | [diff] [blame] | 38 | enum programmer { |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 39 | #if CONFIG_INTERNAL == 1 |
Carl-Daniel Hailfinger | 415e513 | 2009-08-12 11:39:29 +0000 | [diff] [blame] | 40 | PROGRAMMER_INTERNAL, |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 41 | #endif |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 42 | #if CONFIG_DUMMY == 1 |
Carl-Daniel Hailfinger | 415e513 | 2009-08-12 11:39:29 +0000 | [diff] [blame] | 43 | PROGRAMMER_DUMMY, |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 44 | #endif |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 45 | #if CONFIG_NIC3COM == 1 |
Carl-Daniel Hailfinger | 415e513 | 2009-08-12 11:39:29 +0000 | [diff] [blame] | 46 | PROGRAMMER_NIC3COM, |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 47 | #endif |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 48 | #if CONFIG_NICREALTEK == 1 |
Joerg Fischer | 5665ef3 | 2010-05-21 21:54:07 +0000 | [diff] [blame] | 49 | PROGRAMMER_NICREALTEK, |
| 50 | PROGRAMMER_NICREALTEK2, |
| 51 | #endif |
Andrew Morgan | c29c2e7 | 2010-06-07 22:37:54 +0000 | [diff] [blame] | 52 | #if CONFIG_NICNATSEMI == 1 |
| 53 | PROGRAMMER_NICNATSEMI, |
| 54 | #endif |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 55 | #if CONFIG_GFXNVIDIA == 1 |
Uwe Hermann | 2bc98f6 | 2009-09-30 18:29:55 +0000 | [diff] [blame] | 56 | PROGRAMMER_GFXNVIDIA, |
| 57 | #endif |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 58 | #if CONFIG_DRKAISER == 1 |
TURBO J | b0912c0 | 2009-09-02 23:00:46 +0000 | [diff] [blame] | 59 | PROGRAMMER_DRKAISER, |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 60 | #endif |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 61 | #if CONFIG_SATASII == 1 |
Carl-Daniel Hailfinger | 415e513 | 2009-08-12 11:39:29 +0000 | [diff] [blame] | 62 | PROGRAMMER_SATASII, |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 63 | #endif |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 64 | #if CONFIG_ATAHPT == 1 |
Uwe Hermann | ddd5c9e | 2010-02-21 21:17:00 +0000 | [diff] [blame] | 65 | PROGRAMMER_ATAHPT, |
| 66 | #endif |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 67 | #if CONFIG_INTERNAL == 1 |
Carl-Daniel Hailfinger | cceafa2 | 2010-05-26 01:45:41 +0000 | [diff] [blame] | 68 | #if defined(__i386__) || defined(__x86_64__) |
Carl-Daniel Hailfinger | 415e513 | 2009-08-12 11:39:29 +0000 | [diff] [blame] | 69 | PROGRAMMER_IT87SPI, |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 70 | #endif |
Carl-Daniel Hailfinger | cceafa2 | 2010-05-26 01:45:41 +0000 | [diff] [blame] | 71 | #endif |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 72 | #if CONFIG_FT2232_SPI == 1 |
| 73 | PROGRAMMER_FT2232_SPI, |
Carl-Daniel Hailfinger | 3426ef6 | 2009-08-19 13:27:58 +0000 | [diff] [blame] | 74 | #endif |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 75 | #if CONFIG_SERPROG == 1 |
Carl-Daniel Hailfinger | 415e513 | 2009-08-12 11:39:29 +0000 | [diff] [blame] | 76 | PROGRAMMER_SERPROG, |
Carl-Daniel Hailfinger | 6be7411 | 2009-08-12 16:17:41 +0000 | [diff] [blame] | 77 | #endif |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 78 | #if CONFIG_BUSPIRATE_SPI == 1 |
| 79 | PROGRAMMER_BUSPIRATE_SPI, |
Carl-Daniel Hailfinger | 5cca01f | 2009-11-24 00:20:03 +0000 | [diff] [blame] | 80 | #endif |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 81 | #if CONFIG_DEDIPROG == 1 |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 82 | PROGRAMMER_DEDIPROG, |
| 83 | #endif |
Carl-Daniel Hailfinger | e7fdd6e | 2010-07-21 10:26:01 +0000 | [diff] [blame] | 84 | #if CONFIG_RAYER_SPI == 1 |
| 85 | PROGRAMMER_RAYER_SPI, |
| 86 | #endif |
Carl-Daniel Hailfinger | 37fc469 | 2009-08-12 14:34:35 +0000 | [diff] [blame] | 87 | PROGRAMMER_INVALID /* This must always be the last entry. */ |
Carl-Daniel Hailfinger | 415e513 | 2009-08-12 11:39:29 +0000 | [diff] [blame] | 88 | }; |
| 89 | |
| 90 | extern enum programmer programmer; |
Carl-Daniel Hailfinger | 702218d | 2009-05-08 17:43:22 +0000 | [diff] [blame] | 91 | |
| 92 | struct programmer_entry { |
| 93 | const char *vendor; |
| 94 | const char *name; |
| 95 | |
| 96 | int (*init) (void); |
| 97 | int (*shutdown) (void); |
| 98 | |
Uwe Hermann | d1129ac | 2009-05-28 15:07:42 +0000 | [diff] [blame] | 99 | void * (*map_flash_region) (const char *descr, unsigned long phys_addr, |
| 100 | size_t len); |
Carl-Daniel Hailfinger | 1455b2b | 2009-05-11 14:13:25 +0000 | [diff] [blame] | 101 | void (*unmap_flash_region) (void *virt_addr, size_t len); |
| 102 | |
Carl-Daniel Hailfinger | 5820f42 | 2009-05-16 21:22:56 +0000 | [diff] [blame] | 103 | void (*chip_writeb) (uint8_t val, chipaddr addr); |
| 104 | void (*chip_writew) (uint16_t val, chipaddr addr); |
| 105 | void (*chip_writel) (uint32_t val, chipaddr addr); |
Carl-Daniel Hailfinger | 0bd2a2b | 2009-06-05 18:32:07 +0000 | [diff] [blame] | 106 | void (*chip_writen) (uint8_t *buf, chipaddr addr, size_t len); |
Carl-Daniel Hailfinger | 5820f42 | 2009-05-16 21:22:56 +0000 | [diff] [blame] | 107 | uint8_t (*chip_readb) (const chipaddr addr); |
| 108 | uint16_t (*chip_readw) (const chipaddr addr); |
| 109 | uint32_t (*chip_readl) (const chipaddr addr); |
Carl-Daniel Hailfinger | 0bd2a2b | 2009-06-05 18:32:07 +0000 | [diff] [blame] | 110 | void (*chip_readn) (uint8_t *buf, const chipaddr addr, size_t len); |
Carl-Daniel Hailfinger | ca8bfc6 | 2009-06-05 17:48:08 +0000 | [diff] [blame] | 111 | void (*delay) (int usecs); |
Carl-Daniel Hailfinger | 702218d | 2009-05-08 17:43:22 +0000 | [diff] [blame] | 112 | }; |
| 113 | |
| 114 | extern const struct programmer_entry programmer_table[]; |
| 115 | |
Carl-Daniel Hailfinger | cc389fc | 2010-02-14 01:20:28 +0000 | [diff] [blame] | 116 | int register_shutdown(void (*function) (void *data), void *data); |
| 117 | |
Carl-Daniel Hailfinger | ad3cc55 | 2010-07-03 11:02:10 +0000 | [diff] [blame] | 118 | int programmer_init(char *param); |
Uwe Hermann | 09e04f7 | 2009-05-16 22:36:00 +0000 | [diff] [blame] | 119 | int programmer_shutdown(void); |
| 120 | void *programmer_map_flash_region(const char *descr, unsigned long phys_addr, |
| 121 | size_t len); |
| 122 | void programmer_unmap_flash_region(void *virt_addr, size_t len); |
| 123 | void chip_writeb(uint8_t val, chipaddr addr); |
| 124 | void chip_writew(uint16_t val, chipaddr addr); |
| 125 | void chip_writel(uint32_t val, chipaddr addr); |
Carl-Daniel Hailfinger | 0bd2a2b | 2009-06-05 18:32:07 +0000 | [diff] [blame] | 126 | void chip_writen(uint8_t *buf, chipaddr addr, size_t len); |
Uwe Hermann | 09e04f7 | 2009-05-16 22:36:00 +0000 | [diff] [blame] | 127 | uint8_t chip_readb(const chipaddr addr); |
| 128 | uint16_t chip_readw(const chipaddr addr); |
| 129 | uint32_t chip_readl(const chipaddr addr); |
Carl-Daniel Hailfinger | 0bd2a2b | 2009-06-05 18:32:07 +0000 | [diff] [blame] | 130 | void chip_readn(uint8_t *buf, const chipaddr addr, size_t len); |
Carl-Daniel Hailfinger | ca8bfc6 | 2009-06-05 17:48:08 +0000 | [diff] [blame] | 131 | void programmer_delay(int usecs); |
Carl-Daniel Hailfinger | 61a8bd2 | 2009-03-05 19:24:22 +0000 | [diff] [blame] | 132 | |
Michael Karcher | 62175a0 | 2010-07-17 23:27:47 +0000 | [diff] [blame] | 133 | enum bitbang_spi_master_type { |
Carl-Daniel Hailfinger | 17e23ac | 2010-07-18 14:42:28 +0000 | [diff] [blame] | 134 | BITBANG_SPI_INVALID = 0, /* This must always be the first entry. */ |
Carl-Daniel Hailfinger | e7fdd6e | 2010-07-21 10:26:01 +0000 | [diff] [blame] | 135 | #if CONFIG_RAYER_SPI == 1 |
| 136 | BITBANG_SPI_MASTER_RAYER, |
| 137 | #endif |
Carl-Daniel Hailfinger | 547872b | 2009-09-28 13:15:16 +0000 | [diff] [blame] | 138 | }; |
| 139 | |
Michael Karcher | 62175a0 | 2010-07-17 23:27:47 +0000 | [diff] [blame] | 140 | struct bitbang_spi_master { |
| 141 | enum bitbang_spi_master_type type; |
Carl-Daniel Hailfinger | 547872b | 2009-09-28 13:15:16 +0000 | [diff] [blame] | 142 | |
Michael Karcher | 62175a0 | 2010-07-17 23:27:47 +0000 | [diff] [blame] | 143 | /* Note that CS# is active low, so val=0 means the chip is active. */ |
Carl-Daniel Hailfinger | 547872b | 2009-09-28 13:15:16 +0000 | [diff] [blame] | 144 | void (*set_cs) (int val); |
| 145 | void (*set_sck) (int val); |
| 146 | void (*set_mosi) (int val); |
| 147 | int (*get_miso) (void); |
| 148 | }; |
| 149 | |
Uwe Hermann | e5ac164 | 2008-03-12 11:54:51 +0000 | [diff] [blame] | 150 | #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) |
| 151 | |
Carl-Daniel Hailfinger | 1dfe0ff | 2009-05-31 17:57:34 +0000 | [diff] [blame] | 152 | enum chipbustype { |
Carl-Daniel Hailfinger | 3504b53 | 2009-06-01 00:02:11 +0000 | [diff] [blame] | 153 | CHIP_BUSTYPE_NONE = 0, |
Carl-Daniel Hailfinger | 1dfe0ff | 2009-05-31 17:57:34 +0000 | [diff] [blame] | 154 | CHIP_BUSTYPE_PARALLEL = 1 << 0, |
| 155 | CHIP_BUSTYPE_LPC = 1 << 1, |
| 156 | CHIP_BUSTYPE_FWH = 1 << 2, |
| 157 | CHIP_BUSTYPE_SPI = 1 << 3, |
| 158 | CHIP_BUSTYPE_NONSPI = CHIP_BUSTYPE_PARALLEL | CHIP_BUSTYPE_LPC | CHIP_BUSTYPE_FWH, |
| 159 | CHIP_BUSTYPE_UNKNOWN = CHIP_BUSTYPE_PARALLEL | CHIP_BUSTYPE_LPC | CHIP_BUSTYPE_FWH | CHIP_BUSTYPE_SPI, |
| 160 | }; |
| 161 | |
Carl-Daniel Hailfinger | f38431a | 2009-09-05 02:30:58 +0000 | [diff] [blame] | 162 | /* |
| 163 | * How many different contiguous runs of erase blocks with one size each do |
| 164 | * we have for a given erase function? |
| 165 | */ |
| 166 | #define NUM_ERASEREGIONS 5 |
| 167 | |
| 168 | /* |
| 169 | * How many different erase functions do we have per chip? |
| 170 | */ |
| 171 | #define NUM_ERASEFUNCTIONS 5 |
| 172 | |
Carl-Daniel Hailfinger | 4bf4e79 | 2010-01-09 03:15:50 +0000 | [diff] [blame] | 173 | #define FEATURE_REGISTERMAP (1 << 0) |
| 174 | #define FEATURE_BYTEWRITES (1 << 1) |
Sean Nelson | 35727f7 | 2010-01-28 23:55:12 +0000 | [diff] [blame] | 175 | #define FEATURE_LONG_RESET (0 << 4) |
| 176 | #define FEATURE_SHORT_RESET (1 << 4) |
| 177 | #define FEATURE_EITHER_RESET FEATURE_LONG_RESET |
Carl-Daniel Hailfinger | 4bf4e79 | 2010-01-09 03:15:50 +0000 | [diff] [blame] | 178 | #define FEATURE_ADDR_FULL (0 << 2) |
| 179 | #define FEATURE_ADDR_MASK (3 << 2) |
Sean Nelson | 35727f7 | 2010-01-28 23:55:12 +0000 | [diff] [blame] | 180 | #define FEATURE_ADDR_2AA (1 << 2) |
| 181 | #define FEATURE_ADDR_AAA (2 << 2) |
Michael Karcher | ad0010a | 2010-04-03 10:27:08 +0000 | [diff] [blame] | 182 | #define FEATURE_ADDR_SHIFTED (1 << 5) |
Sean Nelson | c57a920 | 2010-01-04 17:15:23 +0000 | [diff] [blame] | 183 | |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 184 | struct flashchip { |
Uwe Hermann | 7615868 | 2008-03-14 23:55:58 +0000 | [diff] [blame] | 185 | const char *vendor; |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 186 | const char *name; |
Carl-Daniel Hailfinger | 1dfe0ff | 2009-05-31 17:57:34 +0000 | [diff] [blame] | 187 | |
| 188 | enum chipbustype bustype; |
| 189 | |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 190 | /* |
| 191 | * With 32bit manufacture_id and model_id we can cover IDs up to |
Carl-Daniel Hailfinger | ae8afa9 | 2007-12-31 01:49:00 +0000 | [diff] [blame] | 192 | * (including) the 4th bank of JEDEC JEP106W Standard Manufacturer's |
| 193 | * Identification code. |
| 194 | */ |
| 195 | uint32_t manufacture_id; |
| 196 | uint32_t model_id; |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 197 | |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 198 | int total_size; |
| 199 | int page_size; |
Sean Nelson | c57a920 | 2010-01-04 17:15:23 +0000 | [diff] [blame] | 200 | int feature_bits; |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 201 | |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 202 | /* |
| 203 | * Indicate if flashrom has been tested with this flash chip and if |
Peter Stuge | 1159d58 | 2008-05-03 04:34:37 +0000 | [diff] [blame] | 204 | * everything worked correctly. |
| 205 | */ |
| 206 | uint32_t tested; |
| 207 | |
Uwe Hermann | 0b7afe6 | 2007-04-01 19:44:21 +0000 | [diff] [blame] | 208 | int (*probe) (struct flashchip *flash); |
Maciej Pijanka | c6e1111 | 2009-06-03 14:46:22 +0000 | [diff] [blame] | 209 | |
| 210 | /* Delay after "enter/exit ID mode" commands in microseconds. */ |
| 211 | int probe_timing; |
Carl-Daniel Hailfinger | f38431a | 2009-09-05 02:30:58 +0000 | [diff] [blame] | 212 | |
| 213 | /* |
Carl-Daniel Hailfinger | 63ce4bb | 2009-12-22 13:04:53 +0000 | [diff] [blame] | 214 | * Erase blocks and associated erase function. Any chip erase function |
| 215 | * is stored as chip-sized virtual block together with said function. |
Carl-Daniel Hailfinger | f38431a | 2009-09-05 02:30:58 +0000 | [diff] [blame] | 216 | */ |
| 217 | struct block_eraser { |
| 218 | struct eraseblock{ |
| 219 | unsigned int size; /* Eraseblock size */ |
| 220 | unsigned int count; /* Number of contiguous blocks with that size */ |
| 221 | } eraseblocks[NUM_ERASEREGIONS]; |
| 222 | int (*block_erase) (struct flashchip *flash, unsigned int blockaddr, unsigned int blocklen); |
| 223 | } block_erasers[NUM_ERASEFUNCTIONS]; |
| 224 | |
Sean Nelson | 6e0b912 | 2010-02-19 00:52:10 +0000 | [diff] [blame] | 225 | int (*printlock) (struct flashchip *flash); |
| 226 | int (*unlock) (struct flashchip *flash); |
Uwe Hermann | 0b7afe6 | 2007-04-01 19:44:21 +0000 | [diff] [blame] | 227 | int (*write) (struct flashchip *flash, uint8_t *buf); |
Carl-Daniel Hailfinger | cbf563c | 2009-06-16 08:55:44 +0000 | [diff] [blame] | 228 | int (*read) (struct flashchip *flash, uint8_t *buf, int start, int len); |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 229 | |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 230 | /* Some flash devices have an additional register space. */ |
Carl-Daniel Hailfinger | 5820f42 | 2009-05-16 21:22:56 +0000 | [diff] [blame] | 231 | chipaddr virtual_memory; |
| 232 | chipaddr virtual_registers; |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 233 | }; |
| 234 | |
Peter Stuge | 1159d58 | 2008-05-03 04:34:37 +0000 | [diff] [blame] | 235 | #define TEST_UNTESTED 0 |
| 236 | |
Uwe Hermann | d1129ac | 2009-05-28 15:07:42 +0000 | [diff] [blame] | 237 | #define TEST_OK_PROBE (1 << 0) |
| 238 | #define TEST_OK_READ (1 << 1) |
| 239 | #define TEST_OK_ERASE (1 << 2) |
| 240 | #define TEST_OK_WRITE (1 << 3) |
| 241 | #define TEST_OK_PR (TEST_OK_PROBE | TEST_OK_READ) |
| 242 | #define TEST_OK_PRE (TEST_OK_PROBE | TEST_OK_READ | TEST_OK_ERASE) |
Carl-Daniel Hailfinger | a06287c | 2009-09-23 22:01:33 +0000 | [diff] [blame] | 243 | #define TEST_OK_PRW (TEST_OK_PROBE | TEST_OK_READ | TEST_OK_WRITE) |
Uwe Hermann | d1129ac | 2009-05-28 15:07:42 +0000 | [diff] [blame] | 244 | #define TEST_OK_PREW (TEST_OK_PROBE | TEST_OK_READ | TEST_OK_ERASE | TEST_OK_WRITE) |
Peter Stuge | 1159d58 | 2008-05-03 04:34:37 +0000 | [diff] [blame] | 245 | #define TEST_OK_MASK 0x0f |
| 246 | |
Uwe Hermann | d1129ac | 2009-05-28 15:07:42 +0000 | [diff] [blame] | 247 | #define TEST_BAD_PROBE (1 << 4) |
| 248 | #define TEST_BAD_READ (1 << 5) |
| 249 | #define TEST_BAD_ERASE (1 << 6) |
| 250 | #define TEST_BAD_WRITE (1 << 7) |
| 251 | #define TEST_BAD_PREW (TEST_BAD_PROBE | TEST_BAD_READ | TEST_BAD_ERASE | TEST_BAD_WRITE) |
Peter Stuge | 1159d58 | 2008-05-03 04:34:37 +0000 | [diff] [blame] | 252 | #define TEST_BAD_MASK 0xf0 |
| 253 | |
Maciej Pijanka | c6e1111 | 2009-06-03 14:46:22 +0000 | [diff] [blame] | 254 | /* Timing used in probe routines. ZERO is -2 to differentiate between an unset |
| 255 | * field and zero delay. |
| 256 | * |
| 257 | * SPI devices will always have zero delay and ignore this field. |
| 258 | */ |
| 259 | #define TIMING_FIXME -1 |
| 260 | /* this is intentionally same value as fixme */ |
| 261 | #define TIMING_IGNORED -1 |
| 262 | #define TIMING_ZERO -2 |
| 263 | |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 264 | extern struct flashchip flashchips[]; |
| 265 | |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 266 | #if CONFIG_INTERNAL == 1 |
Uwe Hermann | 05fab75 | 2009-05-16 23:42:17 +0000 | [diff] [blame] | 267 | struct penable { |
| 268 | uint16_t vendor_id; |
| 269 | uint16_t device_id; |
| 270 | int status; |
| 271 | const char *vendor_name; |
| 272 | const char *device_name; |
| 273 | int (*doit) (struct pci_dev *dev, const char *name); |
| 274 | }; |
| 275 | |
| 276 | extern const struct penable chipset_enables[]; |
| 277 | |
| 278 | struct board_pciid_enable { |
| 279 | /* Any device, but make it sensible, like the ISA bridge. */ |
| 280 | uint16_t first_vendor; |
| 281 | uint16_t first_device; |
| 282 | uint16_t first_card_vendor; |
| 283 | uint16_t first_card_device; |
| 284 | |
| 285 | /* Any device, but make it sensible, like |
| 286 | * the host bridge. May be NULL. |
| 287 | */ |
| 288 | uint16_t second_vendor; |
| 289 | uint16_t second_device; |
| 290 | uint16_t second_card_vendor; |
| 291 | uint16_t second_card_device; |
| 292 | |
Michael Karcher | 6701ee8 | 2010-01-20 14:14:11 +0000 | [diff] [blame] | 293 | /* Pattern to match DMI entries */ |
| 294 | const char *dmi_pattern; |
| 295 | |
Uwe Hermann | 05fab75 | 2009-05-16 23:42:17 +0000 | [diff] [blame] | 296 | /* The vendor / part name from the coreboot table. */ |
| 297 | const char *lb_vendor; |
| 298 | const char *lb_part; |
| 299 | |
| 300 | const char *vendor_name; |
| 301 | const char *board_name; |
| 302 | |
Luc Verhaegen | 93938c3 | 2010-01-20 14:45:03 +0000 | [diff] [blame] | 303 | int max_rom_decode_parallel; |
Michael Karcher | 0bdc092 | 2010-02-28 01:33:48 +0000 | [diff] [blame] | 304 | int status; |
Uwe Hermann | 36dec8b | 2010-06-07 19:06:26 +0000 | [diff] [blame] | 305 | int (*enable) (void); |
Uwe Hermann | 05fab75 | 2009-05-16 23:42:17 +0000 | [diff] [blame] | 306 | }; |
| 307 | |
Carl-Daniel Hailfinger | ad3cc55 | 2010-07-03 11:02:10 +0000 | [diff] [blame] | 308 | extern const struct board_pciid_enable board_pciid_enables[]; |
Uwe Hermann | 05fab75 | 2009-05-16 23:42:17 +0000 | [diff] [blame] | 309 | |
| 310 | struct board_info { |
| 311 | const char *vendor; |
| 312 | const char *name; |
Peter Lemenkov | 4adf8a6 | 2010-06-01 10:13:17 +0000 | [diff] [blame] | 313 | const int working; |
| 314 | #ifdef CONFIG_PRINT_WIKI |
| 315 | const char *url; |
| 316 | const char *note; |
| 317 | #endif |
Uwe Hermann | 05fab75 | 2009-05-16 23:42:17 +0000 | [diff] [blame] | 318 | }; |
| 319 | |
Peter Lemenkov | 4adf8a6 | 2010-06-01 10:13:17 +0000 | [diff] [blame] | 320 | extern const struct board_info boards_known[]; |
| 321 | extern const struct board_info laptops_known[]; |
| 322 | |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 323 | #endif |
Uwe Hermann | 05fab75 | 2009-05-16 23:42:17 +0000 | [diff] [blame] | 324 | |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 325 | /* udelay.c */ |
Carl-Daniel Hailfinger | ca8bfc6 | 2009-06-05 17:48:08 +0000 | [diff] [blame] | 326 | void myusec_delay(int usecs); |
Carl-Daniel Hailfinger | 4363439 | 2009-05-01 12:22:17 +0000 | [diff] [blame] | 327 | void myusec_calibrate_delay(void); |
Carl-Daniel Hailfinger | 36cc1c8 | 2009-12-24 03:11:55 +0000 | [diff] [blame] | 328 | void internal_delay(int usecs); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 329 | |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 330 | #if NEED_PCI == 1 |
Uwe Hermann | 515ab3d | 2009-05-15 17:02:34 +0000 | [diff] [blame] | 331 | /* pcidev.c */ |
Rudolf Marek | 68720c7 | 2009-05-17 19:39:27 +0000 | [diff] [blame] | 332 | |
Uwe Hermann | 515ab3d | 2009-05-15 17:02:34 +0000 | [diff] [blame] | 333 | extern uint32_t io_base_addr; |
| 334 | extern struct pci_access *pacc; |
Uwe Hermann | 8403ccb | 2009-05-16 21:39:19 +0000 | [diff] [blame] | 335 | extern struct pci_dev *pcidev_dev; |
Uwe Hermann | 515ab3d | 2009-05-15 17:02:34 +0000 | [diff] [blame] | 336 | struct pcidev_status { |
| 337 | uint16_t vendor_id; |
| 338 | uint16_t device_id; |
| 339 | int status; |
| 340 | const char *vendor_name; |
| 341 | const char *device_name; |
| 342 | }; |
Carl-Daniel Hailfinger | ad3cc55 | 2010-07-03 11:02:10 +0000 | [diff] [blame] | 343 | uint32_t pcidev_validate(struct pci_dev *dev, uint32_t bar, const struct pcidev_status *devs); |
Carl-Daniel Hailfinger | 744132a | 2010-07-06 09:55:48 +0000 | [diff] [blame] | 344 | uint32_t pcidev_init(uint16_t vendor_id, uint32_t bar, const struct pcidev_status *devs); |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 345 | #endif |
Uwe Hermann | ba290d1 | 2009-06-17 12:07:12 +0000 | [diff] [blame] | 346 | |
| 347 | /* print.c */ |
| 348 | char *flashbuses_to_text(enum chipbustype bustype); |
Carl-Daniel Hailfinger | f529205 | 2009-11-17 09:57:34 +0000 | [diff] [blame] | 349 | void print_supported(void); |
Andrew Morgan | c29c2e7 | 2010-06-07 22:37:54 +0000 | [diff] [blame] | 350 | #if CONFIG_NIC3COM+CONFIG_NICREALTEK+CONFIG_NICNATSEMI+CONFIG_GFXNVIDIA+CONFIG_DRKAISER+CONFIG_SATASII+CONFIG_ATAHPT >= 1 |
Carl-Daniel Hailfinger | ad3cc55 | 2010-07-03 11:02:10 +0000 | [diff] [blame] | 351 | void print_supported_pcidevs(const struct pcidev_status *devs); |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 352 | #endif |
Carl-Daniel Hailfinger | f529205 | 2009-11-17 09:57:34 +0000 | [diff] [blame] | 353 | void print_supported_wiki(void); |
Uwe Hermann | 515ab3d | 2009-05-15 17:02:34 +0000 | [diff] [blame] | 354 | |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 355 | /* board_enable.c */ |
Peter Stuge | 9d9399c | 2009-01-26 02:34:51 +0000 | [diff] [blame] | 356 | void w836xx_ext_enter(uint16_t port); |
| 357 | void w836xx_ext_leave(uint16_t port); |
Carl-Daniel Hailfinger | 76d4b37 | 2010-07-10 16:56:32 +0000 | [diff] [blame] | 358 | int it8705f_write_enable(uint8_t port); |
Carl-Daniel Hailfinger | 24c1a16 | 2009-05-25 23:26:50 +0000 | [diff] [blame] | 359 | uint8_t sio_read(uint16_t port, uint8_t reg); |
| 360 | void sio_write(uint16_t port, uint8_t reg, uint8_t data); |
| 361 | void sio_mask(uint16_t port, uint8_t reg, uint8_t data, uint8_t mask); |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 362 | int board_flash_enable(const char *vendor, const char *part); |
Adam Kaufman | 064b1f2 | 2007-02-06 19:47:50 +0000 | [diff] [blame] | 363 | |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 364 | /* chipset_enable.c */ |
| 365 | int chipset_flash_enable(void); |
Stefan Reinauer | 9a6d176 | 2008-12-03 21:24:40 +0000 | [diff] [blame] | 366 | |
Carl-Daniel Hailfinger | b5b161b | 2010-06-04 19:05:39 +0000 | [diff] [blame] | 367 | /* processor_enable.c */ |
| 368 | int processor_flash_enable(void); |
| 369 | |
Stefan Reinauer | 0593f21 | 2009-01-26 01:10:48 +0000 | [diff] [blame] | 370 | /* physmap.c */ |
| 371 | void *physmap(const char *descr, unsigned long phys_addr, size_t len); |
Carl-Daniel Hailfinger | baaffe0 | 2010-02-02 11:09:03 +0000 | [diff] [blame] | 372 | void *physmap_try_ro(const char *descr, unsigned long phys_addr, size_t len); |
Stefan Reinauer | 0593f21 | 2009-01-26 01:10:48 +0000 | [diff] [blame] | 373 | void physunmap(void *virt_addr, size_t len); |
Stefan Reinauer | 8fa6481 | 2009-08-12 09:27:45 +0000 | [diff] [blame] | 374 | int setup_cpu_msr(int cpu); |
| 375 | void cleanup_cpu_msr(void); |
Carl-Daniel Hailfinger | 5d5c072 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 376 | |
| 377 | /* cbtable.c */ |
| 378 | void lb_vendor_dev_from_string(char *boardstring); |
| 379 | int coreboot_init(void); |
| 380 | extern char *lb_part, *lb_vendor; |
| 381 | extern int partvendor_from_cbtable; |
Stefan Reinauer | 0593f21 | 2009-01-26 01:10:48 +0000 | [diff] [blame] | 382 | |
Michael Karcher | 6701ee8 | 2010-01-20 14:14:11 +0000 | [diff] [blame] | 383 | /* dmi.c */ |
| 384 | extern int has_dmi_support; |
| 385 | void dmi_init(void); |
| 386 | int dmi_match(const char *pattern); |
| 387 | |
Carl-Daniel Hailfinger | 702218d | 2009-05-08 17:43:22 +0000 | [diff] [blame] | 388 | /* internal.c */ |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 389 | #if NEED_PCI == 1 |
Carl-Daniel Hailfinger | 14e100c | 2009-12-22 23:42:04 +0000 | [diff] [blame] | 390 | struct superio { |
| 391 | uint16_t vendor; |
| 392 | uint16_t port; |
| 393 | uint16_t model; |
| 394 | }; |
| 395 | extern struct superio superio; |
| 396 | #define SUPERIO_VENDOR_NONE 0x0 |
| 397 | #define SUPERIO_VENDOR_ITE 0x1 |
Uwe Hermann | 2cac686 | 2009-05-16 22:05:42 +0000 | [diff] [blame] | 398 | struct pci_dev *pci_dev_find_filter(struct pci_filter filter); |
Carl-Daniel Hailfinger | 9f46cfc | 2009-11-15 17:13:29 +0000 | [diff] [blame] | 399 | struct pci_dev *pci_dev_find_vendorclass(uint16_t vendor, uint16_t class); |
Uwe Hermann | 2cac686 | 2009-05-16 22:05:42 +0000 | [diff] [blame] | 400 | struct pci_dev *pci_dev_find(uint16_t vendor, uint16_t device); |
| 401 | struct pci_dev *pci_card_find(uint16_t vendor, uint16_t device, |
| 402 | uint16_t card_vendor, uint16_t card_device); |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 403 | #endif |
Carl-Daniel Hailfinger | 3b7e75a | 2009-05-14 21:41:10 +0000 | [diff] [blame] | 404 | void get_io_perms(void); |
Carl-Daniel Hailfinger | db41c59 | 2009-08-09 21:50:24 +0000 | [diff] [blame] | 405 | void release_io_perms(void); |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 406 | #if CONFIG_INTERNAL == 1 |
Michael Karcher | 8c1df28 | 2010-02-26 09:51:20 +0000 | [diff] [blame] | 407 | extern int is_laptop; |
Michael Karcher | 0bdc092 | 2010-02-28 01:33:48 +0000 | [diff] [blame] | 408 | extern int force_boardenable; |
Carl-Daniel Hailfinger | 2702376 | 2010-04-28 15:22:14 +0000 | [diff] [blame] | 409 | extern int force_boardmismatch; |
Carl-Daniel Hailfinger | 14e100c | 2009-12-22 23:42:04 +0000 | [diff] [blame] | 410 | void probe_superio(void); |
Carl-Daniel Hailfinger | 702218d | 2009-05-08 17:43:22 +0000 | [diff] [blame] | 411 | int internal_init(void); |
| 412 | int internal_shutdown(void); |
Carl-Daniel Hailfinger | 5820f42 | 2009-05-16 21:22:56 +0000 | [diff] [blame] | 413 | void internal_chip_writeb(uint8_t val, chipaddr addr); |
| 414 | void internal_chip_writew(uint16_t val, chipaddr addr); |
| 415 | void internal_chip_writel(uint32_t val, chipaddr addr); |
| 416 | uint8_t internal_chip_readb(const chipaddr addr); |
| 417 | uint16_t internal_chip_readw(const chipaddr addr); |
| 418 | uint32_t internal_chip_readl(const chipaddr addr); |
Carl-Daniel Hailfinger | 0bd2a2b | 2009-06-05 18:32:07 +0000 | [diff] [blame] | 419 | void internal_chip_readn(uint8_t *buf, const chipaddr addr, size_t len); |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 420 | #endif |
Carl-Daniel Hailfinger | 78185dc | 2009-05-17 15:49:24 +0000 | [diff] [blame] | 421 | void mmio_writeb(uint8_t val, void *addr); |
| 422 | void mmio_writew(uint16_t val, void *addr); |
| 423 | void mmio_writel(uint32_t val, void *addr); |
| 424 | uint8_t mmio_readb(void *addr); |
| 425 | uint16_t mmio_readw(void *addr); |
| 426 | uint32_t mmio_readl(void *addr); |
Carl-Daniel Hailfinger | cceafa2 | 2010-05-26 01:45:41 +0000 | [diff] [blame] | 427 | void mmio_le_writeb(uint8_t val, void *addr); |
| 428 | void mmio_le_writew(uint16_t val, void *addr); |
| 429 | void mmio_le_writel(uint32_t val, void *addr); |
| 430 | uint8_t mmio_le_readb(void *addr); |
| 431 | uint16_t mmio_le_readw(void *addr); |
| 432 | uint32_t mmio_le_readl(void *addr); |
Carl-Daniel Hailfinger | cc1802d | 2010-01-06 10:21:00 +0000 | [diff] [blame] | 433 | |
| 434 | /* programmer.c */ |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 435 | int noop_shutdown(void); |
Uwe Hermann | c691593 | 2009-05-17 23:12:17 +0000 | [diff] [blame] | 436 | void *fallback_map(const char *descr, unsigned long phys_addr, size_t len); |
| 437 | void fallback_unmap(void *virt_addr, size_t len); |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 438 | uint8_t noop_chip_readb(const chipaddr addr); |
| 439 | void noop_chip_writeb(uint8_t val, chipaddr addr); |
Carl-Daniel Hailfinger | 5820f42 | 2009-05-16 21:22:56 +0000 | [diff] [blame] | 440 | void fallback_chip_writew(uint16_t val, chipaddr addr); |
| 441 | void fallback_chip_writel(uint32_t val, chipaddr addr); |
Carl-Daniel Hailfinger | 0bd2a2b | 2009-06-05 18:32:07 +0000 | [diff] [blame] | 442 | void fallback_chip_writen(uint8_t *buf, chipaddr addr, size_t len); |
Carl-Daniel Hailfinger | 5820f42 | 2009-05-16 21:22:56 +0000 | [diff] [blame] | 443 | uint16_t fallback_chip_readw(const chipaddr addr); |
| 444 | uint32_t fallback_chip_readl(const chipaddr addr); |
Carl-Daniel Hailfinger | 0bd2a2b | 2009-06-05 18:32:07 +0000 | [diff] [blame] | 445 | void fallback_chip_readn(uint8_t *buf, const chipaddr addr, size_t len); |
Carl-Daniel Hailfinger | 702218d | 2009-05-08 17:43:22 +0000 | [diff] [blame] | 446 | |
Carl-Daniel Hailfinger | c312920 | 2009-05-09 00:54:55 +0000 | [diff] [blame] | 447 | /* dummyflasher.c */ |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 448 | #if CONFIG_DUMMY == 1 |
Carl-Daniel Hailfinger | c312920 | 2009-05-09 00:54:55 +0000 | [diff] [blame] | 449 | int dummy_init(void); |
| 450 | int dummy_shutdown(void); |
Carl-Daniel Hailfinger | 1455b2b | 2009-05-11 14:13:25 +0000 | [diff] [blame] | 451 | void *dummy_map(const char *descr, unsigned long phys_addr, size_t len); |
| 452 | void dummy_unmap(void *virt_addr, size_t len); |
Carl-Daniel Hailfinger | 5820f42 | 2009-05-16 21:22:56 +0000 | [diff] [blame] | 453 | void dummy_chip_writeb(uint8_t val, chipaddr addr); |
| 454 | void dummy_chip_writew(uint16_t val, chipaddr addr); |
| 455 | void dummy_chip_writel(uint32_t val, chipaddr addr); |
Carl-Daniel Hailfinger | 0bd2a2b | 2009-06-05 18:32:07 +0000 | [diff] [blame] | 456 | void dummy_chip_writen(uint8_t *buf, chipaddr addr, size_t len); |
Carl-Daniel Hailfinger | 5820f42 | 2009-05-16 21:22:56 +0000 | [diff] [blame] | 457 | uint8_t dummy_chip_readb(const chipaddr addr); |
| 458 | uint16_t dummy_chip_readw(const chipaddr addr); |
| 459 | uint32_t dummy_chip_readl(const chipaddr addr); |
Carl-Daniel Hailfinger | 0bd2a2b | 2009-06-05 18:32:07 +0000 | [diff] [blame] | 460 | void dummy_chip_readn(uint8_t *buf, const chipaddr addr, size_t len); |
Carl-Daniel Hailfinger | d047829 | 2009-07-10 21:08:55 +0000 | [diff] [blame] | 461 | int dummy_spi_send_command(unsigned int writecnt, unsigned int readcnt, |
Carl-Daniel Hailfinger | bfe2e0c | 2009-05-14 12:59:36 +0000 | [diff] [blame] | 462 | const unsigned char *writearr, unsigned char *readarr); |
Carl-Daniel Hailfinger | 1b0ba89 | 2010-06-20 10:58:32 +0000 | [diff] [blame] | 463 | int dummy_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len); |
Carl-Daniel Hailfinger | 9a795d8 | 2010-07-14 16:19:05 +0000 | [diff] [blame] | 464 | int dummy_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len); |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 465 | #endif |
Carl-Daniel Hailfinger | c312920 | 2009-05-09 00:54:55 +0000 | [diff] [blame] | 466 | |
Uwe Hermann | b4dcb71 | 2009-05-13 11:36:06 +0000 | [diff] [blame] | 467 | /* nic3com.c */ |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 468 | #if CONFIG_NIC3COM == 1 |
Uwe Hermann | b4dcb71 | 2009-05-13 11:36:06 +0000 | [diff] [blame] | 469 | int nic3com_init(void); |
| 470 | int nic3com_shutdown(void); |
Carl-Daniel Hailfinger | 5820f42 | 2009-05-16 21:22:56 +0000 | [diff] [blame] | 471 | void nic3com_chip_writeb(uint8_t val, chipaddr addr); |
| 472 | uint8_t nic3com_chip_readb(const chipaddr addr); |
Carl-Daniel Hailfinger | ad3cc55 | 2010-07-03 11:02:10 +0000 | [diff] [blame] | 473 | extern const struct pcidev_status nics_3com[]; |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 474 | #endif |
Uwe Hermann | b4dcb71 | 2009-05-13 11:36:06 +0000 | [diff] [blame] | 475 | |
Uwe Hermann | 2bc98f6 | 2009-09-30 18:29:55 +0000 | [diff] [blame] | 476 | /* gfxnvidia.c */ |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 477 | #if CONFIG_GFXNVIDIA == 1 |
Uwe Hermann | 2bc98f6 | 2009-09-30 18:29:55 +0000 | [diff] [blame] | 478 | int gfxnvidia_init(void); |
| 479 | int gfxnvidia_shutdown(void); |
| 480 | void gfxnvidia_chip_writeb(uint8_t val, chipaddr addr); |
| 481 | uint8_t gfxnvidia_chip_readb(const chipaddr addr); |
Carl-Daniel Hailfinger | ad3cc55 | 2010-07-03 11:02:10 +0000 | [diff] [blame] | 482 | extern const struct pcidev_status gfx_nvidia[]; |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 483 | #endif |
Uwe Hermann | 2bc98f6 | 2009-09-30 18:29:55 +0000 | [diff] [blame] | 484 | |
TURBO J | b0912c0 | 2009-09-02 23:00:46 +0000 | [diff] [blame] | 485 | /* drkaiser.c */ |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 486 | #if CONFIG_DRKAISER == 1 |
TURBO J | b0912c0 | 2009-09-02 23:00:46 +0000 | [diff] [blame] | 487 | int drkaiser_init(void); |
| 488 | int drkaiser_shutdown(void); |
| 489 | void drkaiser_chip_writeb(uint8_t val, chipaddr addr); |
| 490 | uint8_t drkaiser_chip_readb(const chipaddr addr); |
Carl-Daniel Hailfinger | ad3cc55 | 2010-07-03 11:02:10 +0000 | [diff] [blame] | 491 | extern const struct pcidev_status drkaiser_pcidev[]; |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 492 | #endif |
TURBO J | b0912c0 | 2009-09-02 23:00:46 +0000 | [diff] [blame] | 493 | |
Joerg Fischer | 5665ef3 | 2010-05-21 21:54:07 +0000 | [diff] [blame] | 494 | /* nicrealtek.c */ |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 495 | #if CONFIG_NICREALTEK == 1 |
Joerg Fischer | 5665ef3 | 2010-05-21 21:54:07 +0000 | [diff] [blame] | 496 | int nicrealtek_init(void); |
| 497 | int nicsmc1211_init(void); |
| 498 | int nicrealtek_shutdown(void); |
| 499 | void nicrealtek_chip_writeb(uint8_t val, chipaddr addr); |
| 500 | uint8_t nicrealtek_chip_readb(const chipaddr addr); |
Carl-Daniel Hailfinger | ad3cc55 | 2010-07-03 11:02:10 +0000 | [diff] [blame] | 501 | extern const struct pcidev_status nics_realtek[]; |
| 502 | extern const struct pcidev_status nics_realteksmc1211[]; |
Joerg Fischer | 5665ef3 | 2010-05-21 21:54:07 +0000 | [diff] [blame] | 503 | #endif |
| 504 | |
Andrew Morgan | c29c2e7 | 2010-06-07 22:37:54 +0000 | [diff] [blame] | 505 | /* nicnatsemi.c */ |
| 506 | #if CONFIG_NICNATSEMI == 1 |
| 507 | int nicnatsemi_init(void); |
| 508 | int nicnatsemi_shutdown(void); |
| 509 | void nicnatsemi_chip_writeb(uint8_t val, chipaddr addr); |
| 510 | uint8_t nicnatsemi_chip_readb(const chipaddr addr); |
Carl-Daniel Hailfinger | ad3cc55 | 2010-07-03 11:02:10 +0000 | [diff] [blame] | 511 | extern const struct pcidev_status nics_natsemi[]; |
Andrew Morgan | c29c2e7 | 2010-06-07 22:37:54 +0000 | [diff] [blame] | 512 | #endif |
Joerg Fischer | 5665ef3 | 2010-05-21 21:54:07 +0000 | [diff] [blame] | 513 | |
Rudolf Marek | 68720c7 | 2009-05-17 19:39:27 +0000 | [diff] [blame] | 514 | /* satasii.c */ |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 515 | #if CONFIG_SATASII == 1 |
Rudolf Marek | 68720c7 | 2009-05-17 19:39:27 +0000 | [diff] [blame] | 516 | int satasii_init(void); |
| 517 | int satasii_shutdown(void); |
Rudolf Marek | 68720c7 | 2009-05-17 19:39:27 +0000 | [diff] [blame] | 518 | void satasii_chip_writeb(uint8_t val, chipaddr addr); |
| 519 | uint8_t satasii_chip_readb(const chipaddr addr); |
Carl-Daniel Hailfinger | ad3cc55 | 2010-07-03 11:02:10 +0000 | [diff] [blame] | 520 | extern const struct pcidev_status satas_sii[]; |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 521 | #endif |
Rudolf Marek | 68720c7 | 2009-05-17 19:39:27 +0000 | [diff] [blame] | 522 | |
Uwe Hermann | ddd5c9e | 2010-02-21 21:17:00 +0000 | [diff] [blame] | 523 | /* atahpt.c */ |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 524 | #if CONFIG_ATAHPT == 1 |
Uwe Hermann | ddd5c9e | 2010-02-21 21:17:00 +0000 | [diff] [blame] | 525 | int atahpt_init(void); |
| 526 | int atahpt_shutdown(void); |
| 527 | void atahpt_chip_writeb(uint8_t val, chipaddr addr); |
| 528 | uint8_t atahpt_chip_readb(const chipaddr addr); |
Carl-Daniel Hailfinger | ad3cc55 | 2010-07-03 11:02:10 +0000 | [diff] [blame] | 529 | extern const struct pcidev_status ata_hpt[]; |
Uwe Hermann | ddd5c9e | 2010-02-21 21:17:00 +0000 | [diff] [blame] | 530 | #endif |
| 531 | |
Paul Fox | 05dfbe6 | 2009-06-16 21:08:06 +0000 | [diff] [blame] | 532 | /* ft2232_spi.c */ |
Carl-Daniel Hailfinger | feea272 | 2009-07-01 00:02:23 +0000 | [diff] [blame] | 533 | #define FTDI_FT2232H 0x6010 |
| 534 | #define FTDI_FT4232H 0x6011 |
Paul Fox | 05dfbe6 | 2009-06-16 21:08:06 +0000 | [diff] [blame] | 535 | int ft2232_spi_init(void); |
Carl-Daniel Hailfinger | d047829 | 2009-07-10 21:08:55 +0000 | [diff] [blame] | 536 | int ft2232_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr); |
Paul Fox | 05dfbe6 | 2009-06-16 21:08:06 +0000 | [diff] [blame] | 537 | int ft2232_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len); |
Carl-Daniel Hailfinger | 9a795d8 | 2010-07-14 16:19:05 +0000 | [diff] [blame] | 538 | int ft2232_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len); |
Paul Fox | 05dfbe6 | 2009-06-16 21:08:06 +0000 | [diff] [blame] | 539 | |
Carl-Daniel Hailfinger | e7fdd6e | 2010-07-21 10:26:01 +0000 | [diff] [blame] | 540 | /* rayer_spi.c */ |
| 541 | #if CONFIG_RAYER_SPI == 1 |
| 542 | int rayer_spi_init(void); |
| 543 | #endif |
| 544 | |
Carl-Daniel Hailfinger | 547872b | 2009-09-28 13:15:16 +0000 | [diff] [blame] | 545 | /* bitbang_spi.c */ |
Michael Karcher | 62175a0 | 2010-07-17 23:27:47 +0000 | [diff] [blame] | 546 | int bitbang_spi_init(const struct bitbang_spi_master *master, int halfperiod); |
Carl-Daniel Hailfinger | 547872b | 2009-09-28 13:15:16 +0000 | [diff] [blame] | 547 | int bitbang_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr); |
| 548 | int bitbang_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len); |
Carl-Daniel Hailfinger | 9a795d8 | 2010-07-14 16:19:05 +0000 | [diff] [blame] | 549 | int bitbang_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len); |
Carl-Daniel Hailfinger | 547872b | 2009-09-28 13:15:16 +0000 | [diff] [blame] | 550 | |
Carl-Daniel Hailfinger | 5cca01f | 2009-11-24 00:20:03 +0000 | [diff] [blame] | 551 | /* buspirate_spi.c */ |
Carl-Daniel Hailfinger | d5b28fa | 2009-11-24 18:27:10 +0000 | [diff] [blame] | 552 | struct buspirate_spispeeds { |
| 553 | const char *name; |
| 554 | const int speed; |
| 555 | }; |
Carl-Daniel Hailfinger | 5cca01f | 2009-11-24 00:20:03 +0000 | [diff] [blame] | 556 | int buspirate_spi_init(void); |
| 557 | int buspirate_spi_shutdown(void); |
| 558 | int buspirate_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr); |
| 559 | int buspirate_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len); |
Carl-Daniel Hailfinger | 9a795d8 | 2010-07-14 16:19:05 +0000 | [diff] [blame] | 560 | int buspirate_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len); |
Carl-Daniel Hailfinger | 5cca01f | 2009-11-24 00:20:03 +0000 | [diff] [blame] | 561 | |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 562 | /* dediprog.c */ |
| 563 | int dediprog_init(void); |
| 564 | int dediprog_shutdown(void); |
| 565 | int dediprog_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr); |
| 566 | int dediprog_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len); |
| 567 | |
Uwe Hermann | 0846f89 | 2007-08-23 13:34:59 +0000 | [diff] [blame] | 568 | /* flashrom.c */ |
Carl-Daniel Hailfinger | e8e369f | 2010-03-08 00:42:32 +0000 | [diff] [blame] | 569 | enum write_granularity { |
| 570 | write_gran_1bit, |
| 571 | write_gran_1byte, |
| 572 | write_gran_256bytes, |
| 573 | }; |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 574 | extern enum chipbustype buses_supported; |
| 575 | struct decode_sizes { |
| 576 | uint32_t parallel; |
| 577 | uint32_t lpc; |
| 578 | uint32_t fwh; |
| 579 | uint32_t spi; |
| 580 | }; |
| 581 | extern struct decode_sizes max_rom_decode; |
Carl-Daniel Hailfinger | d1be52d | 2010-07-03 12:14:25 +0000 | [diff] [blame] | 582 | extern int programmer_may_write; |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 583 | extern unsigned long flashbase; |
Uwe Hermann | ad216bf | 2009-04-24 16:17:41 +0000 | [diff] [blame] | 584 | extern int verbose; |
Carl-Daniel Hailfinger | ad3cc55 | 2010-07-03 11:02:10 +0000 | [diff] [blame] | 585 | extern const char * const flashrom_version; |
Carl-Daniel Hailfinger | a84835a | 2010-01-07 03:24:05 +0000 | [diff] [blame] | 586 | extern char *chip_to_probe; |
Peter Stuge | 776d202 | 2009-01-26 00:39:57 +0000 | [diff] [blame] | 587 | void map_flash_registers(struct flashchip *flash); |
Carl-Daniel Hailfinger | cbf563c | 2009-06-16 08:55:44 +0000 | [diff] [blame] | 588 | int read_memmapped(struct flashchip *flash, uint8_t *buf, int start, int len); |
Carl-Daniel Hailfinger | f38431a | 2009-09-05 02:30:58 +0000 | [diff] [blame] | 589 | int erase_flash(struct flashchip *flash); |
Carl-Daniel Hailfinger | a84835a | 2010-01-07 03:24:05 +0000 | [diff] [blame] | 590 | struct flashchip *probe_flash(struct flashchip *first_flash, int force); |
Carl-Daniel Hailfinger | 1748c57 | 2010-07-13 23:56:13 +0000 | [diff] [blame] | 591 | int read_flash_to_file(struct flashchip *flash, char *filename); |
Carl-Daniel Hailfinger | a84835a | 2010-01-07 03:24:05 +0000 | [diff] [blame] | 592 | void check_chip_supported(struct flashchip *flash); |
| 593 | int check_max_decode(enum chipbustype buses, uint32_t size); |
Carl-Daniel Hailfinger | 38a059d | 2009-06-13 12:04:03 +0000 | [diff] [blame] | 594 | int min(int a, int b); |
Carl-Daniel Hailfinger | 30f7cb2 | 2009-06-15 17:23:36 +0000 | [diff] [blame] | 595 | int max(int a, int b); |
Carl-Daniel Hailfinger | d5b28fa | 2009-11-24 18:27:10 +0000 | [diff] [blame] | 596 | char *extract_param(char **haystack, char *needle, char *delim); |
Carl-Daniel Hailfinger | 2b6dcb3 | 2010-07-08 10:13:37 +0000 | [diff] [blame] | 597 | char *extract_programmer_param(char *param_name); |
Carl-Daniel Hailfinger | 30f7cb2 | 2009-06-15 17:23:36 +0000 | [diff] [blame] | 598 | int check_erased_range(struct flashchip *flash, int start, int len); |
| 599 | int verify_range(struct flashchip *flash, uint8_t *cmpbuf, int start, int len, char *message); |
Carl-Daniel Hailfinger | e8e369f | 2010-03-08 00:42:32 +0000 | [diff] [blame] | 600 | int need_erase(uint8_t *have, uint8_t *want, int len, enum write_granularity gran); |
Uwe Hermann | ba290d1 | 2009-06-17 12:07:12 +0000 | [diff] [blame] | 601 | char *strcat_realloc(char *dest, const char *src); |
Carl-Daniel Hailfinger | a84835a | 2010-01-07 03:24:05 +0000 | [diff] [blame] | 602 | void print_version(void); |
Carl-Daniel Hailfinger | 8841d3e | 2010-05-15 15:04:37 +0000 | [diff] [blame] | 603 | void print_banner(void); |
Carl-Daniel Hailfinger | a84835a | 2010-01-07 03:24:05 +0000 | [diff] [blame] | 604 | int selfcheck(void); |
Carl-Daniel Hailfinger | 552420b | 2009-12-24 02:15:55 +0000 | [diff] [blame] | 605 | int doit(struct flashchip *flash, int force, char *filename, int read_it, int write_it, int erase_it, int verify_it); |
Uwe Hermann | ba290d1 | 2009-06-17 12:07:12 +0000 | [diff] [blame] | 606 | |
| 607 | #define OK 0 |
| 608 | #define NT 1 /* Not tested */ |
Uwe Hermann | 0846f89 | 2007-08-23 13:34:59 +0000 | [diff] [blame] | 609 | |
Michael Karcher | a4448d9 | 2010-07-22 18:04:15 +0000 | [diff] [blame] | 610 | /* Something happened that shouldn't happen, but we can go on */ |
| 611 | #define ERROR_NONFATAL 0x100 |
| 612 | |
Sean Nelson | 51e97d7 | 2010-01-07 20:09:33 +0000 | [diff] [blame] | 613 | /* cli_output.c */ |
Carl-Daniel Hailfinger | 9f5f215 | 2010-06-04 23:20:21 +0000 | [diff] [blame] | 614 | /* Let gcc and clang check for correct printf-style format strings. */ |
| 615 | int print(int type, const char *fmt, ...) __attribute__((format(printf, 2, 3))); |
Carl-Daniel Hailfinger | f8dda68 | 2010-01-09 03:22:31 +0000 | [diff] [blame] | 616 | #define MSG_ERROR 0 |
| 617 | #define MSG_INFO 1 |
| 618 | #define MSG_DEBUG 2 |
| 619 | #define MSG_BARF 3 |
| 620 | #define msg_gerr(...) print(MSG_ERROR, __VA_ARGS__) /* general errors */ |
| 621 | #define msg_perr(...) print(MSG_ERROR, __VA_ARGS__) /* programmer errors */ |
| 622 | #define msg_cerr(...) print(MSG_ERROR, __VA_ARGS__) /* chip errors */ |
| 623 | #define msg_ginfo(...) print(MSG_INFO, __VA_ARGS__) /* general info */ |
| 624 | #define msg_pinfo(...) print(MSG_INFO, __VA_ARGS__) /* programmer info */ |
| 625 | #define msg_cinfo(...) print(MSG_INFO, __VA_ARGS__) /* chip info */ |
| 626 | #define msg_gdbg(...) print(MSG_DEBUG, __VA_ARGS__) /* general debug */ |
| 627 | #define msg_pdbg(...) print(MSG_DEBUG, __VA_ARGS__) /* programmer debug */ |
| 628 | #define msg_cdbg(...) print(MSG_DEBUG, __VA_ARGS__) /* chip debug */ |
| 629 | #define msg_gspew(...) print(MSG_BARF, __VA_ARGS__) /* general debug barf */ |
| 630 | #define msg_pspew(...) print(MSG_BARF, __VA_ARGS__) /* programmer debug barf */ |
| 631 | #define msg_cspew(...) print(MSG_BARF, __VA_ARGS__) /* chip debug barf */ |
Sean Nelson | 51e97d7 | 2010-01-07 20:09:33 +0000 | [diff] [blame] | 632 | |
Carl-Daniel Hailfinger | a84835a | 2010-01-07 03:24:05 +0000 | [diff] [blame] | 633 | /* cli_classic.c */ |
| 634 | int cli_classic(int argc, char *argv[]); |
| 635 | |
Uwe Hermann | 0846f89 | 2007-08-23 13:34:59 +0000 | [diff] [blame] | 636 | /* layout.c */ |
Peter Stuge | 7ffbc6f | 2008-06-18 02:08:40 +0000 | [diff] [blame] | 637 | int show_id(uint8_t *bios, int size, int force); |
Uwe Hermann | 0846f89 | 2007-08-23 13:34:59 +0000 | [diff] [blame] | 638 | int read_romlayout(char *name); |
| 639 | int find_romentry(char *name); |
Carl-Daniel Hailfinger | f5fb51c | 2009-08-19 15:19:18 +0000 | [diff] [blame] | 640 | int handle_romentries(uint8_t *buffer, struct flashchip *flash); |
Uwe Hermann | 0846f89 | 2007-08-23 13:34:59 +0000 | [diff] [blame] | 641 | |
Carl-Daniel Hailfinger | 00f911e | 2007-10-15 21:44:47 +0000 | [diff] [blame] | 642 | /* spi.c */ |
Carl-Daniel Hailfinger | 1dfe0ff | 2009-05-31 17:57:34 +0000 | [diff] [blame] | 643 | enum spi_controller { |
| 644 | SPI_CONTROLLER_NONE, |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 645 | #if CONFIG_INTERNAL == 1 |
Carl-Daniel Hailfinger | cceafa2 | 2010-05-26 01:45:41 +0000 | [diff] [blame] | 646 | #if defined(__i386__) || defined(__x86_64__) |
Carl-Daniel Hailfinger | 1dfe0ff | 2009-05-31 17:57:34 +0000 | [diff] [blame] | 647 | SPI_CONTROLLER_ICH7, |
| 648 | SPI_CONTROLLER_ICH9, |
| 649 | SPI_CONTROLLER_IT87XX, |
| 650 | SPI_CONTROLLER_SB600, |
| 651 | SPI_CONTROLLER_VIA, |
| 652 | SPI_CONTROLLER_WBSIO, |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 653 | #endif |
Carl-Daniel Hailfinger | cceafa2 | 2010-05-26 01:45:41 +0000 | [diff] [blame] | 654 | #endif |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 655 | #if CONFIG_FT2232_SPI == 1 |
Paul Fox | 05dfbe6 | 2009-06-16 21:08:06 +0000 | [diff] [blame] | 656 | SPI_CONTROLLER_FT2232, |
Carl-Daniel Hailfinger | 3426ef6 | 2009-08-19 13:27:58 +0000 | [diff] [blame] | 657 | #endif |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 658 | #if CONFIG_DUMMY == 1 |
Carl-Daniel Hailfinger | 1dfe0ff | 2009-05-31 17:57:34 +0000 | [diff] [blame] | 659 | SPI_CONTROLLER_DUMMY, |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 660 | #endif |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 661 | #if CONFIG_BUSPIRATE_SPI == 1 |
Carl-Daniel Hailfinger | 5cca01f | 2009-11-24 00:20:03 +0000 | [diff] [blame] | 662 | SPI_CONTROLLER_BUSPIRATE, |
| 663 | #endif |
Carl-Daniel Hailfinger | 7112772 | 2010-05-31 15:27:27 +0000 | [diff] [blame] | 664 | #if CONFIG_DEDIPROG == 1 |
Carl-Daniel Hailfinger | d38fac8 | 2010-01-19 11:15:48 +0000 | [diff] [blame] | 665 | SPI_CONTROLLER_DEDIPROG, |
| 666 | #endif |
Carl-Daniel Hailfinger | e7fdd6e | 2010-07-21 10:26:01 +0000 | [diff] [blame] | 667 | #if CONFIG_RAYER_SPI == 1 |
| 668 | SPI_CONTROLLER_RAYER, |
| 669 | #endif |
Carl-Daniel Hailfinger | 3426ef6 | 2009-08-19 13:27:58 +0000 | [diff] [blame] | 670 | SPI_CONTROLLER_INVALID /* This must always be the last entry. */ |
Carl-Daniel Hailfinger | 1dfe0ff | 2009-05-31 17:57:34 +0000 | [diff] [blame] | 671 | }; |
Carl-Daniel Hailfinger | 3426ef6 | 2009-08-19 13:27:58 +0000 | [diff] [blame] | 672 | extern const int spi_programmer_count; |
Carl-Daniel Hailfinger | d047829 | 2009-07-10 21:08:55 +0000 | [diff] [blame] | 673 | struct spi_command { |
| 674 | unsigned int writecnt; |
| 675 | unsigned int readcnt; |
| 676 | const unsigned char *writearr; |
| 677 | unsigned char *readarr; |
| 678 | }; |
Carl-Daniel Hailfinger | 02487aa | 2009-07-22 15:36:50 +0000 | [diff] [blame] | 679 | struct spi_programmer { |
| 680 | int (*command)(unsigned int writecnt, unsigned int readcnt, |
| 681 | const unsigned char *writearr, unsigned char *readarr); |
Carl-Daniel Hailfinger | 26f7e64 | 2009-09-18 15:50:56 +0000 | [diff] [blame] | 682 | int (*multicommand)(struct spi_command *cmds); |
Carl-Daniel Hailfinger | 02487aa | 2009-07-22 15:36:50 +0000 | [diff] [blame] | 683 | |
| 684 | /* Optimized functions for this programmer */ |
| 685 | int (*read)(struct flashchip *flash, uint8_t *buf, int start, int len); |
Carl-Daniel Hailfinger | 9a795d8 | 2010-07-14 16:19:05 +0000 | [diff] [blame] | 686 | int (*write_256)(struct flashchip *flash, uint8_t *buf, int start, int len); |
Carl-Daniel Hailfinger | 02487aa | 2009-07-22 15:36:50 +0000 | [diff] [blame] | 687 | }; |
Carl-Daniel Hailfinger | d047829 | 2009-07-10 21:08:55 +0000 | [diff] [blame] | 688 | |
Carl-Daniel Hailfinger | 1dfe0ff | 2009-05-31 17:57:34 +0000 | [diff] [blame] | 689 | extern enum spi_controller spi_controller; |
Carl-Daniel Hailfinger | 02487aa | 2009-07-22 15:36:50 +0000 | [diff] [blame] | 690 | extern const struct spi_programmer spi_programmer[]; |
Carl-Daniel Hailfinger | d047829 | 2009-07-10 21:08:55 +0000 | [diff] [blame] | 691 | int spi_send_command(unsigned int writecnt, unsigned int readcnt, |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 692 | const unsigned char *writearr, unsigned char *readarr); |
Carl-Daniel Hailfinger | 26f7e64 | 2009-09-18 15:50:56 +0000 | [diff] [blame] | 693 | int spi_send_multicommand(struct spi_command *cmds); |
Carl-Daniel Hailfinger | 02487aa | 2009-07-22 15:36:50 +0000 | [diff] [blame] | 694 | int default_spi_send_command(unsigned int writecnt, unsigned int readcnt, |
| 695 | const unsigned char *writearr, unsigned char *readarr); |
Carl-Daniel Hailfinger | 26f7e64 | 2009-09-18 15:50:56 +0000 | [diff] [blame] | 696 | int default_spi_send_multicommand(struct spi_command *cmds); |
Carl-Daniel Hailfinger | 5d5c072 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 697 | uint32_t spi_get_valid_read_addr(void); |
Mats Erik Andersson | 44e1a19 | 2008-09-26 13:19:02 +0000 | [diff] [blame] | 698 | |
Dominik Geyer | b46acba | 2008-05-16 12:55:55 +0000 | [diff] [blame] | 699 | /* ichspi.c */ |
Michael Karcher | 9a9b984 | 2010-07-24 22:07:52 +0000 | [diff] [blame] | 700 | #if CONFIG_INTERNAL == 1 |
Carl-Daniel Hailfinger | 80f3d05 | 2010-05-28 15:53:08 +0000 | [diff] [blame] | 701 | extern uint32_t ichspi_bbar; |
Michael Karcher | a4448d9 | 2010-07-22 18:04:15 +0000 | [diff] [blame] | 702 | int ich_init_spi(struct pci_dev *dev, uint32_t base, void *rcrb, |
| 703 | int ich_generation); |
| 704 | int via_init_spi(struct pci_dev *dev); |
Carl-Daniel Hailfinger | d047829 | 2009-07-10 21:08:55 +0000 | [diff] [blame] | 705 | int ich_spi_send_command(unsigned int writecnt, unsigned int readcnt, |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 706 | const unsigned char *writearr, unsigned char *readarr); |
Carl-Daniel Hailfinger | cbf563c | 2009-06-16 08:55:44 +0000 | [diff] [blame] | 707 | int ich_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len); |
Carl-Daniel Hailfinger | 9a795d8 | 2010-07-14 16:19:05 +0000 | [diff] [blame] | 708 | int ich_spi_write_256(struct flashchip *flash, uint8_t * buf, int start, int len); |
Carl-Daniel Hailfinger | 26f7e64 | 2009-09-18 15:50:56 +0000 | [diff] [blame] | 709 | int ich_spi_send_multicommand(struct spi_command *cmds); |
Michael Karcher | 9a9b984 | 2010-07-24 22:07:52 +0000 | [diff] [blame] | 710 | #endif |
Dominik Geyer | b46acba | 2008-05-16 12:55:55 +0000 | [diff] [blame] | 711 | |
Carl-Daniel Hailfinger | bfe5b4a | 2008-05-13 23:03:12 +0000 | [diff] [blame] | 712 | /* it87spi.c */ |
Carl-Daniel Hailfinger | 24c1a16 | 2009-05-25 23:26:50 +0000 | [diff] [blame] | 713 | void enter_conf_mode_ite(uint16_t port); |
| 714 | void exit_conf_mode_ite(uint16_t port); |
Carl-Daniel Hailfinger | 14e100c | 2009-12-22 23:42:04 +0000 | [diff] [blame] | 715 | struct superio probe_superio_ite(void); |
Carl-Daniel Hailfinger | 76d4b37 | 2010-07-10 16:56:32 +0000 | [diff] [blame] | 716 | int init_superio_ite(void); |
Carl-Daniel Hailfinger | b8afecd | 2009-05-31 18:00:57 +0000 | [diff] [blame] | 717 | int it87spi_init(void); |
Carl-Daniel Hailfinger | d047829 | 2009-07-10 21:08:55 +0000 | [diff] [blame] | 718 | int it8716f_spi_send_command(unsigned int writecnt, unsigned int readcnt, |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 719 | const unsigned char *writearr, unsigned char *readarr); |
Carl-Daniel Hailfinger | cbf563c | 2009-06-16 08:55:44 +0000 | [diff] [blame] | 720 | int it8716f_spi_chip_read(struct flashchip *flash, uint8_t *buf, int start, int len); |
Carl-Daniel Hailfinger | 9a795d8 | 2010-07-14 16:19:05 +0000 | [diff] [blame] | 721 | int it8716f_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] | 722 | |
Jason Wang | a3f04be | 2008-11-28 21:36:51 +0000 | [diff] [blame] | 723 | /* sb600spi.c */ |
Michael Karcher | 9a9b984 | 2010-07-24 22:07:52 +0000 | [diff] [blame] | 724 | #if CONFIG_INTERNAL == 1 |
Michael Karcher | b05b9e1 | 2010-07-22 18:04:19 +0000 | [diff] [blame] | 725 | int sb600_probe_spi(struct pci_dev *dev); |
Carl-Daniel Hailfinger | d047829 | 2009-07-10 21:08:55 +0000 | [diff] [blame] | 726 | int sb600_spi_send_command(unsigned int writecnt, unsigned int readcnt, |
Jason Wang | a3f04be | 2008-11-28 21:36:51 +0000 | [diff] [blame] | 727 | const unsigned char *writearr, unsigned char *readarr); |
Carl-Daniel Hailfinger | cbf563c | 2009-06-16 08:55:44 +0000 | [diff] [blame] | 728 | int sb600_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len); |
Carl-Daniel Hailfinger | 9a795d8 | 2010-07-14 16:19:05 +0000 | [diff] [blame] | 729 | int sb600_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len); |
Michael Karcher | 9a9b984 | 2010-07-24 22:07:52 +0000 | [diff] [blame] | 730 | #endif |
Jason Wang | a3f04be | 2008-11-28 21:36:51 +0000 | [diff] [blame] | 731 | |
Peter Stuge | bf196e9 | 2009-01-26 03:08:45 +0000 | [diff] [blame] | 732 | /* wbsio_spi.c */ |
Michael Karcher | 9a9b984 | 2010-07-24 22:07:52 +0000 | [diff] [blame] | 733 | #if CONFIG_INTERNAL == 1 |
Uwe Hermann | 36dec8b | 2010-06-07 19:06:26 +0000 | [diff] [blame] | 734 | int wbsio_check_for_spi(void); |
Carl-Daniel Hailfinger | d047829 | 2009-07-10 21:08:55 +0000 | [diff] [blame] | 735 | int wbsio_spi_send_command(unsigned int writecnt, unsigned int readcnt, |
Uwe Hermann | d1129ac | 2009-05-28 15:07:42 +0000 | [diff] [blame] | 736 | const unsigned char *writearr, unsigned char *readarr); |
Carl-Daniel Hailfinger | cbf563c | 2009-06-16 08:55:44 +0000 | [diff] [blame] | 737 | int wbsio_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len); |
Michael Karcher | 9a9b984 | 2010-07-24 22:07:52 +0000 | [diff] [blame] | 738 | #endif |
Peter Stuge | bf196e9 | 2009-01-26 03:08:45 +0000 | [diff] [blame] | 739 | |
Urja Rannikko | 2291535 | 2009-06-23 11:33:43 +0000 | [diff] [blame] | 740 | /* serprog.c */ |
Urja Rannikko | 2291535 | 2009-06-23 11:33:43 +0000 | [diff] [blame] | 741 | int serprog_init(void); |
| 742 | int serprog_shutdown(void); |
| 743 | void serprog_chip_writeb(uint8_t val, chipaddr addr); |
| 744 | uint8_t serprog_chip_readb(const chipaddr addr); |
| 745 | void serprog_chip_readn(uint8_t *buf, const chipaddr addr, size_t len); |
| 746 | void serprog_delay(int delay); |
Carl-Daniel Hailfinger | e51ea10 | 2009-11-23 19:20:11 +0000 | [diff] [blame] | 747 | |
| 748 | /* serial.c */ |
Patrick Georgi | e48654c | 2010-01-06 22:14:39 +0000 | [diff] [blame] | 749 | #if _WIN32 |
| 750 | typedef HANDLE fdtype; |
| 751 | #else |
| 752 | typedef int fdtype; |
| 753 | #endif |
| 754 | |
Carl-Daniel Hailfinger | a4a9bfb | 2009-11-21 11:02:48 +0000 | [diff] [blame] | 755 | void sp_flush_incoming(void); |
Patrick Georgi | e48654c | 2010-01-06 22:14:39 +0000 | [diff] [blame] | 756 | fdtype sp_openserport(char *dev, unsigned int baud); |
Carl-Daniel Hailfinger | e51ea10 | 2009-11-23 19:20:11 +0000 | [diff] [blame] | 757 | void __attribute__((noreturn)) sp_die(char *msg); |
Patrick Georgi | e48654c | 2010-01-06 22:14:39 +0000 | [diff] [blame] | 758 | extern fdtype sp_fd; |
Carl-Daniel Hailfinger | efa151e | 2010-01-06 16:09:10 +0000 | [diff] [blame] | 759 | int serialport_shutdown(void); |
| 760 | int serialport_write(unsigned char *buf, unsigned int writecnt); |
| 761 | int serialport_read(unsigned char *buf, unsigned int readcnt); |
Uwe Hermann | 1432a60 | 2009-06-28 23:26:37 +0000 | [diff] [blame] | 762 | |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 763 | #endif /* !__FLASH_H__ */ |