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