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 */ |
| 400 | #define FTDI_FT2232H 0x6010 |
| 401 | #define FTDI_FT4232H 0x6011 |
| 402 | int ft2232_spi_init(void); |
| 403 | int ft2232_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr); |
| 404 | int ft2232_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len); |
| 405 | int ft2232_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len); |
| 406 | |
| 407 | /* rayer_spi.c */ |
| 408 | #if CONFIG_RAYER_SPI == 1 |
| 409 | int rayer_spi_init(void); |
| 410 | #endif |
| 411 | |
Carl-Daniel Hailfinger | 2f43616 | 2010-07-28 15:08:35 +0000 | [diff] [blame^] | 412 | /* mcp6x_spi.c */ |
| 413 | #if CONFIG_INTERNAL == 1 |
| 414 | #if defined(__i386__) || defined(__x86_64__) |
| 415 | int mcp6x_spi_init(int want_spi); |
| 416 | #endif |
| 417 | #endif |
| 418 | |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 419 | /* bitbang_spi.c */ |
| 420 | int bitbang_spi_init(const struct bitbang_spi_master *master, int halfperiod); |
| 421 | int bitbang_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr); |
| 422 | int bitbang_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len); |
| 423 | int bitbang_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len); |
| 424 | |
| 425 | /* buspirate_spi.c */ |
| 426 | struct buspirate_spispeeds { |
| 427 | const char *name; |
| 428 | const int speed; |
| 429 | }; |
| 430 | int buspirate_spi_init(void); |
| 431 | int buspirate_spi_shutdown(void); |
| 432 | int buspirate_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr); |
| 433 | int buspirate_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len); |
| 434 | int buspirate_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len); |
| 435 | |
| 436 | /* dediprog.c */ |
| 437 | int dediprog_init(void); |
| 438 | int dediprog_shutdown(void); |
| 439 | int dediprog_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr); |
| 440 | int dediprog_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len); |
| 441 | |
| 442 | /* flashrom.c */ |
| 443 | struct decode_sizes { |
| 444 | uint32_t parallel; |
| 445 | uint32_t lpc; |
| 446 | uint32_t fwh; |
| 447 | uint32_t spi; |
| 448 | }; |
| 449 | extern struct decode_sizes max_rom_decode; |
| 450 | extern int programmer_may_write; |
| 451 | extern unsigned long flashbase; |
| 452 | void check_chip_supported(struct flashchip *flash); |
| 453 | int check_max_decode(enum chipbustype buses, uint32_t size); |
| 454 | char *extract_programmer_param(char *param_name); |
| 455 | |
| 456 | /* layout.c */ |
| 457 | int show_id(uint8_t *bios, int size, int force); |
| 458 | |
| 459 | /* spi.c */ |
| 460 | enum spi_controller { |
| 461 | SPI_CONTROLLER_NONE, |
| 462 | #if CONFIG_INTERNAL == 1 |
| 463 | #if defined(__i386__) || defined(__x86_64__) |
| 464 | SPI_CONTROLLER_ICH7, |
| 465 | SPI_CONTROLLER_ICH9, |
| 466 | SPI_CONTROLLER_IT87XX, |
| 467 | SPI_CONTROLLER_SB600, |
| 468 | SPI_CONTROLLER_VIA, |
| 469 | SPI_CONTROLLER_WBSIO, |
Carl-Daniel Hailfinger | 2f43616 | 2010-07-28 15:08:35 +0000 | [diff] [blame^] | 470 | SPI_CONTROLLER_MCP6X_BITBANG, |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 471 | #endif |
| 472 | #endif |
| 473 | #if CONFIG_FT2232_SPI == 1 |
| 474 | SPI_CONTROLLER_FT2232, |
| 475 | #endif |
| 476 | #if CONFIG_DUMMY == 1 |
| 477 | SPI_CONTROLLER_DUMMY, |
| 478 | #endif |
| 479 | #if CONFIG_BUSPIRATE_SPI == 1 |
| 480 | SPI_CONTROLLER_BUSPIRATE, |
| 481 | #endif |
| 482 | #if CONFIG_DEDIPROG == 1 |
| 483 | SPI_CONTROLLER_DEDIPROG, |
| 484 | #endif |
| 485 | #if CONFIG_RAYER_SPI == 1 |
| 486 | SPI_CONTROLLER_RAYER, |
| 487 | #endif |
| 488 | SPI_CONTROLLER_INVALID /* This must always be the last entry. */ |
| 489 | }; |
| 490 | extern const int spi_programmer_count; |
| 491 | struct spi_programmer { |
| 492 | int (*command)(unsigned int writecnt, unsigned int readcnt, |
| 493 | const unsigned char *writearr, unsigned char *readarr); |
| 494 | int (*multicommand)(struct spi_command *cmds); |
| 495 | |
| 496 | /* Optimized functions for this programmer */ |
| 497 | int (*read)(struct flashchip *flash, uint8_t *buf, int start, int len); |
| 498 | int (*write_256)(struct flashchip *flash, uint8_t *buf, int start, int len); |
| 499 | }; |
| 500 | |
| 501 | extern enum spi_controller spi_controller; |
| 502 | extern const struct spi_programmer spi_programmer[]; |
| 503 | int default_spi_send_command(unsigned int writecnt, unsigned int readcnt, |
| 504 | const unsigned char *writearr, unsigned char *readarr); |
| 505 | int default_spi_send_multicommand(struct spi_command *cmds); |
| 506 | |
| 507 | /* ichspi.c */ |
| 508 | #if CONFIG_INTERNAL == 1 |
| 509 | extern uint32_t ichspi_bbar; |
| 510 | int ich_init_spi(struct pci_dev *dev, uint32_t base, void *rcrb, |
| 511 | int ich_generation); |
| 512 | int via_init_spi(struct pci_dev *dev); |
| 513 | int ich_spi_send_command(unsigned int writecnt, unsigned int readcnt, |
| 514 | const unsigned char *writearr, unsigned char *readarr); |
| 515 | int ich_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len); |
| 516 | int ich_spi_write_256(struct flashchip *flash, uint8_t * buf, int start, int len); |
| 517 | int ich_spi_send_multicommand(struct spi_command *cmds); |
| 518 | #endif |
| 519 | |
| 520 | /* it87spi.c */ |
| 521 | void enter_conf_mode_ite(uint16_t port); |
| 522 | void exit_conf_mode_ite(uint16_t port); |
| 523 | struct superio probe_superio_ite(void); |
| 524 | int init_superio_ite(void); |
| 525 | int it87spi_init(void); |
| 526 | int it8716f_spi_send_command(unsigned int writecnt, unsigned int readcnt, |
| 527 | const unsigned char *writearr, unsigned char *readarr); |
| 528 | int it8716f_spi_chip_read(struct flashchip *flash, uint8_t *buf, int start, int len); |
| 529 | int it8716f_spi_chip_write_256(struct flashchip *flash, uint8_t *buf, int start, int len); |
| 530 | |
| 531 | /* sb600spi.c */ |
| 532 | #if CONFIG_INTERNAL == 1 |
| 533 | int sb600_probe_spi(struct pci_dev *dev); |
| 534 | int sb600_spi_send_command(unsigned int writecnt, unsigned int readcnt, |
| 535 | const unsigned char *writearr, unsigned char *readarr); |
| 536 | int sb600_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len); |
| 537 | int sb600_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len); |
| 538 | #endif |
| 539 | |
| 540 | /* wbsio_spi.c */ |
| 541 | #if CONFIG_INTERNAL == 1 |
| 542 | int wbsio_check_for_spi(void); |
| 543 | int wbsio_spi_send_command(unsigned int writecnt, unsigned int readcnt, |
| 544 | const unsigned char *writearr, unsigned char *readarr); |
| 545 | int wbsio_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len); |
| 546 | #endif |
| 547 | |
| 548 | /* serprog.c */ |
| 549 | int serprog_init(void); |
| 550 | int serprog_shutdown(void); |
| 551 | void serprog_chip_writeb(uint8_t val, chipaddr addr); |
| 552 | uint8_t serprog_chip_readb(const chipaddr addr); |
| 553 | void serprog_chip_readn(uint8_t *buf, const chipaddr addr, size_t len); |
| 554 | void serprog_delay(int delay); |
| 555 | |
| 556 | /* serial.c */ |
| 557 | #if _WIN32 |
| 558 | typedef HANDLE fdtype; |
| 559 | #else |
| 560 | typedef int fdtype; |
| 561 | #endif |
| 562 | |
| 563 | void sp_flush_incoming(void); |
| 564 | fdtype sp_openserport(char *dev, unsigned int baud); |
| 565 | void __attribute__((noreturn)) sp_die(char *msg); |
| 566 | extern fdtype sp_fd; |
| 567 | int serialport_shutdown(void); |
| 568 | int serialport_write(unsigned char *buf, unsigned int writecnt); |
| 569 | int serialport_read(unsigned char *buf, unsigned int readcnt); |
| 570 | |
| 571 | #endif /* !__PROGRAMMER_H__ */ |