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