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