Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the flashrom project. |
| 3 | * |
| 4 | * Copyright (C) 2000 Silicon Integrated System Corporation |
| 5 | * Copyright (C) 2000 Ronald G. Minnich <rminnich@gmail.com> |
| 6 | * Copyright (C) 2005-2009 coresystems GmbH |
| 7 | * Copyright (C) 2006-2009 Carl-Daniel Hailfinger |
| 8 | * |
| 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. |
| 13 | * |
| 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. |
| 18 | * |
| 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 |
| 22 | */ |
| 23 | |
| 24 | #ifndef __PROGRAMMER_H__ |
| 25 | #define __PROGRAMMER_H__ 1 |
| 26 | |
| 27 | enum programmer { |
| 28 | #if CONFIG_INTERNAL == 1 |
| 29 | PROGRAMMER_INTERNAL, |
| 30 | #endif |
| 31 | #if CONFIG_DUMMY == 1 |
| 32 | PROGRAMMER_DUMMY, |
| 33 | #endif |
| 34 | #if CONFIG_NIC3COM == 1 |
| 35 | PROGRAMMER_NIC3COM, |
| 36 | #endif |
| 37 | #if CONFIG_NICREALTEK == 1 |
| 38 | PROGRAMMER_NICREALTEK, |
Idwer Vollering | 004f4b7 | 2010-09-03 18:21:21 +0000 | [diff] [blame] | 39 | #endif |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 40 | #if CONFIG_NICNATSEMI == 1 |
| 41 | PROGRAMMER_NICNATSEMI, |
Idwer Vollering | 004f4b7 | 2010-09-03 18:21:21 +0000 | [diff] [blame] | 42 | #endif |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 43 | #if CONFIG_GFXNVIDIA == 1 |
| 44 | PROGRAMMER_GFXNVIDIA, |
| 45 | #endif |
| 46 | #if CONFIG_DRKAISER == 1 |
| 47 | PROGRAMMER_DRKAISER, |
| 48 | #endif |
| 49 | #if CONFIG_SATASII == 1 |
| 50 | PROGRAMMER_SATASII, |
| 51 | #endif |
| 52 | #if CONFIG_ATAHPT == 1 |
| 53 | PROGRAMMER_ATAHPT, |
| 54 | #endif |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 55 | #if CONFIG_FT2232_SPI == 1 |
| 56 | PROGRAMMER_FT2232_SPI, |
| 57 | #endif |
| 58 | #if CONFIG_SERPROG == 1 |
| 59 | PROGRAMMER_SERPROG, |
| 60 | #endif |
| 61 | #if CONFIG_BUSPIRATE_SPI == 1 |
| 62 | PROGRAMMER_BUSPIRATE_SPI, |
| 63 | #endif |
| 64 | #if CONFIG_DEDIPROG == 1 |
| 65 | PROGRAMMER_DEDIPROG, |
| 66 | #endif |
| 67 | #if CONFIG_RAYER_SPI == 1 |
| 68 | PROGRAMMER_RAYER_SPI, |
| 69 | #endif |
Carl-Daniel Hailfinger | b713d2e | 2011-05-08 00:24:18 +0000 | [diff] [blame] | 70 | #if CONFIG_NICINTEL == 1 |
| 71 | PROGRAMMER_NICINTEL, |
| 72 | #endif |
Idwer Vollering | 004f4b7 | 2010-09-03 18:21:21 +0000 | [diff] [blame] | 73 | #if CONFIG_NICINTEL_SPI == 1 |
| 74 | PROGRAMMER_NICINTEL_SPI, |
| 75 | #endif |
Mark Marshall | 90021f2 | 2010-12-03 14:48:11 +0000 | [diff] [blame] | 76 | #if CONFIG_OGP_SPI == 1 |
| 77 | PROGRAMMER_OGP_SPI, |
| 78 | #endif |
Carl-Daniel Hailfinger | 9a1105c | 2011-02-04 21:37:59 +0000 | [diff] [blame] | 79 | #if CONFIG_SATAMV == 1 |
| 80 | PROGRAMMER_SATAMV, |
| 81 | #endif |
Sven Schnelle | 5ce5f70 | 2011-09-03 18:37:52 +0000 | [diff] [blame] | 82 | #if CONFIG_LINUX_SPI == 1 |
| 83 | PROGRAMMER_LINUX_SPI, |
| 84 | #endif |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 85 | PROGRAMMER_INVALID /* This must always be the last entry. */ |
| 86 | }; |
| 87 | |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 88 | struct programmer_entry { |
| 89 | const char *vendor; |
| 90 | const char *name; |
| 91 | |
| 92 | int (*init) (void); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 93 | |
| 94 | void * (*map_flash_region) (const char *descr, unsigned long phys_addr, |
| 95 | size_t len); |
| 96 | void (*unmap_flash_region) (void *virt_addr, size_t len); |
| 97 | |
| 98 | void (*chip_writeb) (uint8_t val, chipaddr addr); |
| 99 | void (*chip_writew) (uint16_t val, chipaddr addr); |
| 100 | void (*chip_writel) (uint32_t val, chipaddr addr); |
| 101 | void (*chip_writen) (uint8_t *buf, chipaddr addr, size_t len); |
| 102 | uint8_t (*chip_readb) (const chipaddr addr); |
| 103 | uint16_t (*chip_readw) (const chipaddr addr); |
| 104 | uint32_t (*chip_readl) (const chipaddr addr); |
| 105 | void (*chip_readn) (uint8_t *buf, const chipaddr addr, size_t len); |
| 106 | void (*delay) (int usecs); |
| 107 | }; |
| 108 | |
| 109 | extern const struct programmer_entry programmer_table[]; |
| 110 | |
Carl-Daniel Hailfinger | 2e68160 | 2011-09-08 00:00:29 +0000 | [diff] [blame] | 111 | int programmer_init(enum programmer prog, char *param); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 112 | int programmer_shutdown(void); |
| 113 | |
| 114 | enum bitbang_spi_master_type { |
| 115 | BITBANG_SPI_INVALID = 0, /* This must always be the first entry. */ |
| 116 | #if CONFIG_RAYER_SPI == 1 |
| 117 | BITBANG_SPI_MASTER_RAYER, |
| 118 | #endif |
Idwer Vollering | 004f4b7 | 2010-09-03 18:21:21 +0000 | [diff] [blame] | 119 | #if CONFIG_NICINTEL_SPI == 1 |
| 120 | BITBANG_SPI_MASTER_NICINTEL, |
| 121 | #endif |
Carl-Daniel Hailfinger | 2f43616 | 2010-07-28 15:08:35 +0000 | [diff] [blame] | 122 | #if CONFIG_INTERNAL == 1 |
| 123 | #if defined(__i386__) || defined(__x86_64__) |
| 124 | BITBANG_SPI_MASTER_MCP, |
| 125 | #endif |
| 126 | #endif |
Mark Marshall | 90021f2 | 2010-12-03 14:48:11 +0000 | [diff] [blame] | 127 | #if CONFIG_OGP_SPI == 1 |
| 128 | BITBANG_SPI_MASTER_OGP, |
| 129 | #endif |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 130 | }; |
| 131 | |
| 132 | struct bitbang_spi_master { |
| 133 | enum bitbang_spi_master_type type; |
| 134 | |
| 135 | /* Note that CS# is active low, so val=0 means the chip is active. */ |
| 136 | void (*set_cs) (int val); |
| 137 | void (*set_sck) (int val); |
| 138 | void (*set_mosi) (int val); |
| 139 | int (*get_miso) (void); |
Carl-Daniel Hailfinger | 2822888 | 2010-09-15 00:17:37 +0000 | [diff] [blame] | 140 | void (*request_bus) (void); |
| 141 | void (*release_bus) (void); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 142 | }; |
| 143 | |
| 144 | #if CONFIG_INTERNAL == 1 |
| 145 | struct penable { |
| 146 | uint16_t vendor_id; |
| 147 | uint16_t device_id; |
Stefan Tauner | 7bcacb1 | 2011-05-26 01:35:19 +0000 | [diff] [blame] | 148 | int status; /* OK=0 and NT=1 are defines only. Beware! */ |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 149 | const char *vendor_name; |
| 150 | const char *device_name; |
| 151 | int (*doit) (struct pci_dev *dev, const char *name); |
| 152 | }; |
| 153 | |
| 154 | extern const struct penable chipset_enables[]; |
| 155 | |
Carl-Daniel Hailfinger | 580d29a | 2011-05-05 07:12:40 +0000 | [diff] [blame] | 156 | enum board_match_phase { |
| 157 | P1, |
| 158 | P2, |
| 159 | P3 |
| 160 | }; |
| 161 | |
Carl-Daniel Hailfinger | 97d5b12 | 2011-08-31 16:19:50 +0000 | [diff] [blame] | 162 | struct board_match { |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 163 | /* Any device, but make it sensible, like the ISA bridge. */ |
| 164 | uint16_t first_vendor; |
| 165 | uint16_t first_device; |
| 166 | uint16_t first_card_vendor; |
| 167 | uint16_t first_card_device; |
| 168 | |
| 169 | /* Any device, but make it sensible, like |
| 170 | * the host bridge. May be NULL. |
| 171 | */ |
| 172 | uint16_t second_vendor; |
| 173 | uint16_t second_device; |
| 174 | uint16_t second_card_vendor; |
| 175 | uint16_t second_card_device; |
| 176 | |
Stefan Tauner | 7bcacb1 | 2011-05-26 01:35:19 +0000 | [diff] [blame] | 177 | /* Pattern to match DMI entries. May be NULL. */ |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 178 | const char *dmi_pattern; |
| 179 | |
Stefan Tauner | 7bcacb1 | 2011-05-26 01:35:19 +0000 | [diff] [blame] | 180 | /* The vendor / part name from the coreboot table. May be NULL. */ |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 181 | const char *lb_vendor; |
| 182 | const char *lb_part; |
| 183 | |
Carl-Daniel Hailfinger | 580d29a | 2011-05-05 07:12:40 +0000 | [diff] [blame] | 184 | enum board_match_phase phase; |
| 185 | |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 186 | const char *vendor_name; |
| 187 | const char *board_name; |
| 188 | |
| 189 | int max_rom_decode_parallel; |
| 190 | int status; |
Stefan Tauner | 7bcacb1 | 2011-05-26 01:35:19 +0000 | [diff] [blame] | 191 | int (*enable) (void); /* May be NULL. */ |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 192 | }; |
| 193 | |
Carl-Daniel Hailfinger | 97d5b12 | 2011-08-31 16:19:50 +0000 | [diff] [blame] | 194 | extern const struct board_match board_matches[]; |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 195 | |
| 196 | struct board_info { |
| 197 | const char *vendor; |
| 198 | const char *name; |
| 199 | const int working; |
| 200 | #ifdef CONFIG_PRINT_WIKI |
| 201 | const char *url; |
| 202 | const char *note; |
| 203 | #endif |
| 204 | }; |
| 205 | |
| 206 | extern const struct board_info boards_known[]; |
| 207 | extern const struct board_info laptops_known[]; |
| 208 | #endif |
| 209 | |
| 210 | /* udelay.c */ |
| 211 | void myusec_delay(int usecs); |
| 212 | void myusec_calibrate_delay(void); |
| 213 | void internal_delay(int usecs); |
| 214 | |
| 215 | #if NEED_PCI == 1 |
| 216 | /* pcidev.c */ |
| 217 | extern uint32_t io_base_addr; |
| 218 | extern struct pci_access *pacc; |
| 219 | extern struct pci_dev *pcidev_dev; |
| 220 | struct pcidev_status { |
| 221 | uint16_t vendor_id; |
| 222 | uint16_t device_id; |
| 223 | int status; |
| 224 | const char *vendor_name; |
| 225 | const char *device_name; |
| 226 | }; |
Carl-Daniel Hailfinger | 8a19ef1 | 2011-02-15 22:44:27 +0000 | [diff] [blame] | 227 | uintptr_t pcidev_validate(struct pci_dev *dev, int bar, const struct pcidev_status *devs); |
Carl-Daniel Hailfinger | 40446ee | 2011-03-07 01:08:09 +0000 | [diff] [blame] | 228 | uintptr_t pcidev_init(int bar, const struct pcidev_status *devs); |
Carl-Daniel Hailfinger | 2bee8cf | 2010-11-10 15:25:18 +0000 | [diff] [blame] | 229 | /* rpci_write_* are reversible writes. The original PCI config space register |
| 230 | * contents will be restored on shutdown. |
| 231 | */ |
Idwer Vollering | 1a6162e | 2010-12-26 23:55:19 +0000 | [diff] [blame] | 232 | int rpci_write_byte(struct pci_dev *dev, int reg, uint8_t data); |
| 233 | int rpci_write_word(struct pci_dev *dev, int reg, uint16_t data); |
| 234 | int rpci_write_long(struct pci_dev *dev, int reg, uint32_t data); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 235 | #endif |
| 236 | |
| 237 | /* print.c */ |
Carl-Daniel Hailfinger | b713d2e | 2011-05-08 00:24:18 +0000 | [diff] [blame] | 238 | #if CONFIG_NIC3COM+CONFIG_NICREALTEK+CONFIG_NICNATSEMI+CONFIG_GFXNVIDIA+CONFIG_DRKAISER+CONFIG_SATASII+CONFIG_ATAHPT+CONFIG_NICINTEL+CONFIG_NICINTEL_SPI+CONFIG_OGP_SPI+CONFIG_SATAMV >= 1 |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 239 | void print_supported_pcidevs(const struct pcidev_status *devs); |
| 240 | #endif |
| 241 | |
Carl-Daniel Hailfinger | c422484 | 2011-06-09 20:06:34 +0000 | [diff] [blame] | 242 | #if CONFIG_INTERNAL == 1 |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 243 | /* board_enable.c */ |
| 244 | void w836xx_ext_enter(uint16_t port); |
| 245 | void w836xx_ext_leave(uint16_t port); |
| 246 | int it8705f_write_enable(uint8_t port); |
| 247 | uint8_t sio_read(uint16_t port, uint8_t reg); |
| 248 | void sio_write(uint16_t port, uint8_t reg, uint8_t data); |
| 249 | void sio_mask(uint16_t port, uint8_t reg, uint8_t data, uint8_t mask); |
Carl-Daniel Hailfinger | 580d29a | 2011-05-05 07:12:40 +0000 | [diff] [blame] | 250 | void board_handle_before_superio(void); |
| 251 | void board_handle_before_laptop(void); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 252 | int board_flash_enable(const char *vendor, const char *part); |
| 253 | |
| 254 | /* chipset_enable.c */ |
| 255 | int chipset_flash_enable(void); |
| 256 | |
| 257 | /* processor_enable.c */ |
| 258 | int processor_flash_enable(void); |
Carl-Daniel Hailfinger | 580d29a | 2011-05-05 07:12:40 +0000 | [diff] [blame] | 259 | #endif |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 260 | |
| 261 | /* physmap.c */ |
| 262 | void *physmap(const char *descr, unsigned long phys_addr, size_t len); |
| 263 | void *physmap_try_ro(const char *descr, unsigned long phys_addr, size_t len); |
| 264 | void physunmap(void *virt_addr, size_t len); |
Carl-Daniel Hailfinger | c422484 | 2011-06-09 20:06:34 +0000 | [diff] [blame] | 265 | #if CONFIG_INTERNAL == 1 |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 266 | int setup_cpu_msr(int cpu); |
| 267 | void cleanup_cpu_msr(void); |
| 268 | |
| 269 | /* cbtable.c */ |
| 270 | void lb_vendor_dev_from_string(char *boardstring); |
| 271 | int coreboot_init(void); |
| 272 | extern char *lb_part, *lb_vendor; |
| 273 | extern int partvendor_from_cbtable; |
| 274 | |
| 275 | /* dmi.c */ |
| 276 | extern int has_dmi_support; |
| 277 | void dmi_init(void); |
| 278 | int dmi_match(const char *pattern); |
| 279 | |
| 280 | /* internal.c */ |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 281 | struct superio { |
| 282 | uint16_t vendor; |
| 283 | uint16_t port; |
| 284 | uint16_t model; |
| 285 | }; |
Carl-Daniel Hailfinger | bfecef6 | 2011-04-27 14:34:08 +0000 | [diff] [blame] | 286 | extern struct superio superios[]; |
| 287 | extern int superio_count; |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 288 | #define SUPERIO_VENDOR_NONE 0x0 |
| 289 | #define SUPERIO_VENDOR_ITE 0x1 |
Carl-Daniel Hailfinger | c422484 | 2011-06-09 20:06:34 +0000 | [diff] [blame] | 290 | #endif |
| 291 | #if NEED_PCI == 1 |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 292 | struct pci_dev *pci_dev_find_filter(struct pci_filter filter); |
Uwe Hermann | 24c35e4 | 2011-07-13 11:22:03 +0000 | [diff] [blame] | 293 | struct pci_dev *pci_dev_find_vendorclass(uint16_t vendor, uint16_t devclass); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 294 | struct pci_dev *pci_dev_find(uint16_t vendor, uint16_t device); |
| 295 | struct pci_dev *pci_card_find(uint16_t vendor, uint16_t device, |
| 296 | uint16_t card_vendor, uint16_t card_device); |
| 297 | #endif |
| 298 | void get_io_perms(void); |
| 299 | void release_io_perms(void); |
| 300 | #if CONFIG_INTERNAL == 1 |
| 301 | extern int is_laptop; |
Carl-Daniel Hailfinger | 580d29a | 2011-05-05 07:12:40 +0000 | [diff] [blame] | 302 | extern int laptop_ok; |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 303 | extern int force_boardenable; |
| 304 | extern int force_boardmismatch; |
| 305 | void probe_superio(void); |
Carl-Daniel Hailfinger | bfecef6 | 2011-04-27 14:34:08 +0000 | [diff] [blame] | 306 | int register_superio(struct superio s); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 307 | int internal_init(void); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 308 | void internal_chip_writeb(uint8_t val, chipaddr addr); |
| 309 | void internal_chip_writew(uint16_t val, chipaddr addr); |
| 310 | void internal_chip_writel(uint32_t val, chipaddr addr); |
| 311 | uint8_t internal_chip_readb(const chipaddr addr); |
| 312 | uint16_t internal_chip_readw(const chipaddr addr); |
| 313 | uint32_t internal_chip_readl(const chipaddr addr); |
| 314 | void internal_chip_readn(uint8_t *buf, const chipaddr addr, size_t len); |
| 315 | #endif |
| 316 | |
| 317 | /* hwaccess.c */ |
| 318 | void mmio_writeb(uint8_t val, void *addr); |
| 319 | void mmio_writew(uint16_t val, void *addr); |
| 320 | void mmio_writel(uint32_t val, void *addr); |
| 321 | uint8_t mmio_readb(void *addr); |
| 322 | uint16_t mmio_readw(void *addr); |
| 323 | uint32_t mmio_readl(void *addr); |
| 324 | void mmio_le_writeb(uint8_t val, void *addr); |
| 325 | void mmio_le_writew(uint16_t val, void *addr); |
| 326 | void mmio_le_writel(uint32_t val, void *addr); |
| 327 | uint8_t mmio_le_readb(void *addr); |
| 328 | uint16_t mmio_le_readw(void *addr); |
| 329 | uint32_t mmio_le_readl(void *addr); |
| 330 | #define pci_mmio_writeb mmio_le_writeb |
| 331 | #define pci_mmio_writew mmio_le_writew |
| 332 | #define pci_mmio_writel mmio_le_writel |
| 333 | #define pci_mmio_readb mmio_le_readb |
| 334 | #define pci_mmio_readw mmio_le_readw |
| 335 | #define pci_mmio_readl mmio_le_readl |
Carl-Daniel Hailfinger | 54ce73a | 2011-05-03 21:49:41 +0000 | [diff] [blame] | 336 | void rmmio_writeb(uint8_t val, void *addr); |
| 337 | void rmmio_writew(uint16_t val, void *addr); |
| 338 | void rmmio_writel(uint32_t val, void *addr); |
| 339 | void rmmio_le_writeb(uint8_t val, void *addr); |
| 340 | void rmmio_le_writew(uint16_t val, void *addr); |
| 341 | void rmmio_le_writel(uint32_t val, void *addr); |
| 342 | #define pci_rmmio_writeb rmmio_le_writeb |
| 343 | #define pci_rmmio_writew rmmio_le_writew |
| 344 | #define pci_rmmio_writel rmmio_le_writel |
| 345 | void rmmio_valb(void *addr); |
| 346 | void rmmio_valw(void *addr); |
| 347 | void rmmio_vall(void *addr); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 348 | |
| 349 | /* programmer.c */ |
| 350 | int noop_shutdown(void); |
| 351 | void *fallback_map(const char *descr, unsigned long phys_addr, size_t len); |
| 352 | void fallback_unmap(void *virt_addr, size_t len); |
| 353 | uint8_t noop_chip_readb(const chipaddr addr); |
| 354 | void noop_chip_writeb(uint8_t val, chipaddr addr); |
| 355 | void fallback_chip_writew(uint16_t val, chipaddr addr); |
| 356 | void fallback_chip_writel(uint32_t val, chipaddr addr); |
| 357 | void fallback_chip_writen(uint8_t *buf, chipaddr addr, size_t len); |
| 358 | uint16_t fallback_chip_readw(const chipaddr addr); |
| 359 | uint32_t fallback_chip_readl(const chipaddr addr); |
| 360 | void fallback_chip_readn(uint8_t *buf, const chipaddr addr, size_t len); |
| 361 | |
| 362 | /* dummyflasher.c */ |
| 363 | #if CONFIG_DUMMY == 1 |
| 364 | int dummy_init(void); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 365 | void *dummy_map(const char *descr, unsigned long phys_addr, size_t len); |
| 366 | void dummy_unmap(void *virt_addr, size_t len); |
| 367 | void dummy_chip_writeb(uint8_t val, chipaddr addr); |
| 368 | void dummy_chip_writew(uint16_t val, chipaddr addr); |
| 369 | void dummy_chip_writel(uint32_t val, chipaddr addr); |
| 370 | void dummy_chip_writen(uint8_t *buf, chipaddr addr, size_t len); |
| 371 | uint8_t dummy_chip_readb(const chipaddr addr); |
| 372 | uint16_t dummy_chip_readw(const chipaddr addr); |
| 373 | uint32_t dummy_chip_readl(const chipaddr addr); |
| 374 | void dummy_chip_readn(uint8_t *buf, const chipaddr addr, size_t len); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 375 | #endif |
| 376 | |
| 377 | /* nic3com.c */ |
| 378 | #if CONFIG_NIC3COM == 1 |
| 379 | int nic3com_init(void); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 380 | void nic3com_chip_writeb(uint8_t val, chipaddr addr); |
| 381 | uint8_t nic3com_chip_readb(const chipaddr addr); |
| 382 | extern const struct pcidev_status nics_3com[]; |
| 383 | #endif |
| 384 | |
| 385 | /* gfxnvidia.c */ |
| 386 | #if CONFIG_GFXNVIDIA == 1 |
| 387 | int gfxnvidia_init(void); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 388 | void gfxnvidia_chip_writeb(uint8_t val, chipaddr addr); |
| 389 | uint8_t gfxnvidia_chip_readb(const chipaddr addr); |
| 390 | extern const struct pcidev_status gfx_nvidia[]; |
| 391 | #endif |
| 392 | |
| 393 | /* drkaiser.c */ |
| 394 | #if CONFIG_DRKAISER == 1 |
| 395 | int drkaiser_init(void); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 396 | void drkaiser_chip_writeb(uint8_t val, chipaddr addr); |
| 397 | uint8_t drkaiser_chip_readb(const chipaddr addr); |
| 398 | extern const struct pcidev_status drkaiser_pcidev[]; |
| 399 | #endif |
| 400 | |
| 401 | /* nicrealtek.c */ |
| 402 | #if CONFIG_NICREALTEK == 1 |
| 403 | int nicrealtek_init(void); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 404 | void nicrealtek_chip_writeb(uint8_t val, chipaddr addr); |
| 405 | uint8_t nicrealtek_chip_readb(const chipaddr addr); |
| 406 | extern const struct pcidev_status nics_realtek[]; |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 407 | #endif |
| 408 | |
| 409 | /* nicnatsemi.c */ |
| 410 | #if CONFIG_NICNATSEMI == 1 |
| 411 | int nicnatsemi_init(void); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 412 | void nicnatsemi_chip_writeb(uint8_t val, chipaddr addr); |
| 413 | uint8_t nicnatsemi_chip_readb(const chipaddr addr); |
| 414 | extern const struct pcidev_status nics_natsemi[]; |
| 415 | #endif |
| 416 | |
Carl-Daniel Hailfinger | b713d2e | 2011-05-08 00:24:18 +0000 | [diff] [blame] | 417 | /* nicintel.c */ |
| 418 | #if CONFIG_NICINTEL == 1 |
| 419 | int nicintel_init(void); |
Carl-Daniel Hailfinger | b713d2e | 2011-05-08 00:24:18 +0000 | [diff] [blame] | 420 | void nicintel_chip_writeb(uint8_t val, chipaddr addr); |
| 421 | uint8_t nicintel_chip_readb(const chipaddr addr); |
| 422 | extern const struct pcidev_status nics_intel[]; |
| 423 | #endif |
| 424 | |
Idwer Vollering | 004f4b7 | 2010-09-03 18:21:21 +0000 | [diff] [blame] | 425 | /* nicintel_spi.c */ |
| 426 | #if CONFIG_NICINTEL_SPI == 1 |
| 427 | int nicintel_spi_init(void); |
Idwer Vollering | 004f4b7 | 2010-09-03 18:21:21 +0000 | [diff] [blame] | 428 | extern const struct pcidev_status nics_intel_spi[]; |
| 429 | #endif |
| 430 | |
Mark Marshall | 90021f2 | 2010-12-03 14:48:11 +0000 | [diff] [blame] | 431 | /* ogp_spi.c */ |
| 432 | #if CONFIG_OGP_SPI == 1 |
| 433 | int ogp_spi_init(void); |
Mark Marshall | 90021f2 | 2010-12-03 14:48:11 +0000 | [diff] [blame] | 434 | extern const struct pcidev_status ogp_spi[]; |
| 435 | #endif |
| 436 | |
Carl-Daniel Hailfinger | 9a1105c | 2011-02-04 21:37:59 +0000 | [diff] [blame] | 437 | /* satamv.c */ |
| 438 | #if CONFIG_SATAMV == 1 |
| 439 | int satamv_init(void); |
Carl-Daniel Hailfinger | 9a1105c | 2011-02-04 21:37:59 +0000 | [diff] [blame] | 440 | void satamv_chip_writeb(uint8_t val, chipaddr addr); |
| 441 | uint8_t satamv_chip_readb(const chipaddr addr); |
| 442 | extern const struct pcidev_status satas_mv[]; |
| 443 | #endif |
| 444 | |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 445 | /* satasii.c */ |
| 446 | #if CONFIG_SATASII == 1 |
| 447 | int satasii_init(void); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 448 | void satasii_chip_writeb(uint8_t val, chipaddr addr); |
| 449 | uint8_t satasii_chip_readb(const chipaddr addr); |
| 450 | extern const struct pcidev_status satas_sii[]; |
| 451 | #endif |
| 452 | |
| 453 | /* atahpt.c */ |
| 454 | #if CONFIG_ATAHPT == 1 |
| 455 | int atahpt_init(void); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 456 | void atahpt_chip_writeb(uint8_t val, chipaddr addr); |
| 457 | uint8_t atahpt_chip_readb(const chipaddr addr); |
| 458 | extern const struct pcidev_status ata_hpt[]; |
| 459 | #endif |
| 460 | |
| 461 | /* ft2232_spi.c */ |
Jörg Fischer | 6529b9f | 2010-07-29 15:54:53 +0000 | [diff] [blame] | 462 | #if CONFIG_FT2232_SPI == 1 |
| 463 | struct usbdev_status { |
Uwe Hermann | 48ec1b1 | 2010-08-08 17:01:18 +0000 | [diff] [blame] | 464 | uint16_t vendor_id; |
| 465 | uint16_t device_id; |
| 466 | int status; |
| 467 | const char *vendor_name; |
| 468 | const char *device_name; |
Jörg Fischer | 6529b9f | 2010-07-29 15:54:53 +0000 | [diff] [blame] | 469 | }; |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 470 | int ft2232_spi_init(void); |
Jörg Fischer | 6529b9f | 2010-07-29 15:54:53 +0000 | [diff] [blame] | 471 | extern const struct usbdev_status devs_ft2232spi[]; |
| 472 | void print_supported_usbdevs(const struct usbdev_status *devs); |
| 473 | #endif |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 474 | |
| 475 | /* rayer_spi.c */ |
| 476 | #if CONFIG_RAYER_SPI == 1 |
| 477 | int rayer_spi_init(void); |
| 478 | #endif |
| 479 | |
| 480 | /* bitbang_spi.c */ |
| 481 | int bitbang_spi_init(const struct bitbang_spi_master *master, int halfperiod); |
Carl-Daniel Hailfinger | 2822888 | 2010-09-15 00:17:37 +0000 | [diff] [blame] | 482 | int bitbang_spi_shutdown(const struct bitbang_spi_master *master); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 483 | |
| 484 | /* buspirate_spi.c */ |
Carl-Daniel Hailfinger | c422484 | 2011-06-09 20:06:34 +0000 | [diff] [blame] | 485 | #if CONFIG_BUSPIRATE_SPI == 1 |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 486 | int buspirate_spi_init(void); |
Carl-Daniel Hailfinger | c422484 | 2011-06-09 20:06:34 +0000 | [diff] [blame] | 487 | #endif |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 488 | |
Sven Schnelle | 5ce5f70 | 2011-09-03 18:37:52 +0000 | [diff] [blame] | 489 | /* linux_spi.c */ |
| 490 | #if CONFIG_LINUX_SPI == 1 |
| 491 | int linux_spi_init(void); |
| 492 | #endif |
| 493 | |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 494 | /* dediprog.c */ |
Carl-Daniel Hailfinger | c422484 | 2011-06-09 20:06:34 +0000 | [diff] [blame] | 495 | #if CONFIG_DEDIPROG == 1 |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 496 | int dediprog_init(void); |
Carl-Daniel Hailfinger | c422484 | 2011-06-09 20:06:34 +0000 | [diff] [blame] | 497 | #endif |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 498 | |
| 499 | /* flashrom.c */ |
| 500 | struct decode_sizes { |
| 501 | uint32_t parallel; |
| 502 | uint32_t lpc; |
| 503 | uint32_t fwh; |
| 504 | uint32_t spi; |
| 505 | }; |
| 506 | extern struct decode_sizes max_rom_decode; |
| 507 | extern int programmer_may_write; |
| 508 | extern unsigned long flashbase; |
Carl-Daniel Hailfinger | 4c82318 | 2011-05-04 00:39:50 +0000 | [diff] [blame] | 509 | void check_chip_supported(const struct flashchip *flash); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 510 | int check_max_decode(enum chipbustype buses, uint32_t size); |
Stefan Tauner | 6665244 | 2011-06-26 17:38:17 +0000 | [diff] [blame] | 511 | char *extract_programmer_param(const char *param_name); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 512 | |
| 513 | /* layout.c */ |
| 514 | int show_id(uint8_t *bios, int size, int force); |
| 515 | |
| 516 | /* spi.c */ |
| 517 | enum spi_controller { |
| 518 | SPI_CONTROLLER_NONE, |
| 519 | #if CONFIG_INTERNAL == 1 |
| 520 | #if defined(__i386__) || defined(__x86_64__) |
| 521 | SPI_CONTROLLER_ICH7, |
| 522 | SPI_CONTROLLER_ICH9, |
David Hendricks | 4e74839 | 2011-02-28 23:58:15 +0000 | [diff] [blame] | 523 | SPI_CONTROLLER_IT85XX, |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 524 | SPI_CONTROLLER_IT87XX, |
| 525 | SPI_CONTROLLER_SB600, |
| 526 | SPI_CONTROLLER_VIA, |
| 527 | SPI_CONTROLLER_WBSIO, |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 528 | #endif |
| 529 | #endif |
| 530 | #if CONFIG_FT2232_SPI == 1 |
| 531 | SPI_CONTROLLER_FT2232, |
| 532 | #endif |
| 533 | #if CONFIG_DUMMY == 1 |
| 534 | SPI_CONTROLLER_DUMMY, |
| 535 | #endif |
| 536 | #if CONFIG_BUSPIRATE_SPI == 1 |
| 537 | SPI_CONTROLLER_BUSPIRATE, |
| 538 | #endif |
| 539 | #if CONFIG_DEDIPROG == 1 |
| 540 | SPI_CONTROLLER_DEDIPROG, |
| 541 | #endif |
Michael Karcher | b9dbe48 | 2011-05-11 17:07:07 +0000 | [diff] [blame] | 542 | #if CONFIG_OGP_SPI == 1 || CONFIG_NICINTEL_SPI == 1 || CONFIG_RAYER_SPI == 1 || (CONFIG_INTERNAL == 1 && (defined(__i386__) || defined(__x86_64__))) |
| 543 | SPI_CONTROLLER_BITBANG, |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 544 | #endif |
Sven Schnelle | 5ce5f70 | 2011-09-03 18:37:52 +0000 | [diff] [blame] | 545 | #if CONFIG_LINUX_SPI == 1 |
| 546 | SPI_CONTROLLER_LINUX, |
| 547 | #endif |
Urja Rannikko | c93f5f1 | 2011-09-15 23:38:14 +0000 | [diff] [blame] | 548 | #if CONFIG_SERPROG == 1 |
| 549 | SPI_CONTROLLER_SERPROG, |
| 550 | #endif |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 551 | }; |
| 552 | extern const int spi_programmer_count; |
Michael Karcher | 6279751 | 2011-05-11 17:07:02 +0000 | [diff] [blame] | 553 | |
| 554 | #define MAX_DATA_UNSPECIFIED 0 |
| 555 | #define MAX_DATA_READ_UNLIMITED 64 * 1024 |
| 556 | #define MAX_DATA_WRITE_UNLIMITED 256 |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 557 | struct spi_programmer { |
Michael Karcher | b9dbe48 | 2011-05-11 17:07:07 +0000 | [diff] [blame] | 558 | enum spi_controller type; |
Stefan Tauner | 8c35745 | 2011-09-18 22:42:18 +0000 | [diff] [blame^] | 559 | int max_data_read; |
| 560 | int max_data_write; |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 561 | int (*command)(unsigned int writecnt, unsigned int readcnt, |
| 562 | const unsigned char *writearr, unsigned char *readarr); |
| 563 | int (*multicommand)(struct spi_command *cmds); |
| 564 | |
| 565 | /* Optimized functions for this programmer */ |
Stefan Tauner | 8c35745 | 2011-09-18 22:42:18 +0000 | [diff] [blame^] | 566 | int (*read)(struct flashchip *flash, uint8_t *buf, int start, int len); |
| 567 | int (*write_256)(struct flashchip *flash, uint8_t *buf, int start, int len); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 568 | }; |
| 569 | |
Michael Karcher | b9dbe48 | 2011-05-11 17:07:07 +0000 | [diff] [blame] | 570 | extern const struct spi_programmer *spi_programmer; |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 571 | int default_spi_send_command(unsigned int writecnt, unsigned int readcnt, |
| 572 | const unsigned char *writearr, unsigned char *readarr); |
| 573 | int default_spi_send_multicommand(struct spi_command *cmds); |
Stefan Tauner | 8c35745 | 2011-09-18 22:42:18 +0000 | [diff] [blame^] | 574 | int default_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len); |
| 575 | int default_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len); |
Michael Karcher | b9dbe48 | 2011-05-11 17:07:07 +0000 | [diff] [blame] | 576 | void register_spi_programmer(const struct spi_programmer *programmer); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 577 | |
| 578 | /* ichspi.c */ |
| 579 | #if CONFIG_INTERNAL == 1 |
| 580 | extern uint32_t ichspi_bbar; |
| 581 | int ich_init_spi(struct pci_dev *dev, uint32_t base, void *rcrb, |
| 582 | int ich_generation); |
| 583 | int via_init_spi(struct pci_dev *dev); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 584 | |
David Hendricks | 4e74839 | 2011-02-28 23:58:15 +0000 | [diff] [blame] | 585 | /* it85spi.c */ |
Carl-Daniel Hailfinger | bfecef6 | 2011-04-27 14:34:08 +0000 | [diff] [blame] | 586 | int it85xx_spi_init(struct superio s); |
David Hendricks | 4e74839 | 2011-02-28 23:58:15 +0000 | [diff] [blame] | 587 | |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 588 | /* it87spi.c */ |
| 589 | void enter_conf_mode_ite(uint16_t port); |
| 590 | void exit_conf_mode_ite(uint16_t port); |
Carl-Daniel Hailfinger | bfecef6 | 2011-04-27 14:34:08 +0000 | [diff] [blame] | 591 | void probe_superio_ite(void); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 592 | int init_superio_ite(void); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 593 | |
Carl-Daniel Hailfinger | c422484 | 2011-06-09 20:06:34 +0000 | [diff] [blame] | 594 | /* mcp6x_spi.c */ |
| 595 | int mcp6x_spi_init(int want_spi); |
| 596 | |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 597 | /* sb600spi.c */ |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 598 | int sb600_probe_spi(struct pci_dev *dev); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 599 | |
| 600 | /* wbsio_spi.c */ |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 601 | int wbsio_check_for_spi(void); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 602 | #endif |
| 603 | |
| 604 | /* serprog.c */ |
Carl-Daniel Hailfinger | c422484 | 2011-06-09 20:06:34 +0000 | [diff] [blame] | 605 | #if CONFIG_SERPROG == 1 |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 606 | int serprog_init(void); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 607 | void serprog_chip_writeb(uint8_t val, chipaddr addr); |
| 608 | uint8_t serprog_chip_readb(const chipaddr addr); |
| 609 | void serprog_chip_readn(uint8_t *buf, const chipaddr addr, size_t len); |
| 610 | void serprog_delay(int delay); |
Urja Rannikko | c93f5f1 | 2011-09-15 23:38:14 +0000 | [diff] [blame] | 611 | int serprog_spi_send_command(unsigned int writecnt, unsigned int readcnt, |
| 612 | const unsigned char *writearr, unsigned char *readarr); |
Stefan Tauner | 8c35745 | 2011-09-18 22:42:18 +0000 | [diff] [blame^] | 613 | int serprog_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len); |
Carl-Daniel Hailfinger | c422484 | 2011-06-09 20:06:34 +0000 | [diff] [blame] | 614 | #endif |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 615 | |
| 616 | /* serial.c */ |
| 617 | #if _WIN32 |
| 618 | typedef HANDLE fdtype; |
| 619 | #else |
| 620 | typedef int fdtype; |
| 621 | #endif |
| 622 | |
| 623 | void sp_flush_incoming(void); |
| 624 | fdtype sp_openserport(char *dev, unsigned int baud); |
| 625 | void __attribute__((noreturn)) sp_die(char *msg); |
| 626 | extern fdtype sp_fd; |
David Hendricks | 8bb2021 | 2011-06-14 01:35:36 +0000 | [diff] [blame] | 627 | /* expose serialport_shutdown as it's currently used by buspirate */ |
| 628 | int serialport_shutdown(void *data); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 629 | int serialport_write(unsigned char *buf, unsigned int writecnt); |
| 630 | int serialport_read(unsigned char *buf, unsigned int readcnt); |
| 631 | |
| 632 | #endif /* !__PROGRAMMER_H__ */ |