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