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 | |
Carl-Daniel Hailfinger | 63fd902 | 2011-12-14 22:25:15 +0000 | [diff] [blame] | 27 | #include "flash.h" /* for chipaddr and flashctx */ |
Carl-Daniel Hailfinger | 532c717 | 2011-11-04 21:35:26 +0000 | [diff] [blame] | 28 | |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 29 | enum programmer { |
| 30 | #if CONFIG_INTERNAL == 1 |
| 31 | PROGRAMMER_INTERNAL, |
| 32 | #endif |
| 33 | #if CONFIG_DUMMY == 1 |
| 34 | PROGRAMMER_DUMMY, |
| 35 | #endif |
| 36 | #if CONFIG_NIC3COM == 1 |
| 37 | PROGRAMMER_NIC3COM, |
| 38 | #endif |
| 39 | #if CONFIG_NICREALTEK == 1 |
| 40 | PROGRAMMER_NICREALTEK, |
Idwer Vollering | 004f4b7 | 2010-09-03 18:21:21 +0000 | [diff] [blame] | 41 | #endif |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 42 | #if CONFIG_NICNATSEMI == 1 |
| 43 | PROGRAMMER_NICNATSEMI, |
Idwer Vollering | 004f4b7 | 2010-09-03 18:21:21 +0000 | [diff] [blame] | 44 | #endif |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 45 | #if CONFIG_GFXNVIDIA == 1 |
| 46 | PROGRAMMER_GFXNVIDIA, |
| 47 | #endif |
| 48 | #if CONFIG_DRKAISER == 1 |
| 49 | PROGRAMMER_DRKAISER, |
| 50 | #endif |
| 51 | #if CONFIG_SATASII == 1 |
| 52 | PROGRAMMER_SATASII, |
| 53 | #endif |
| 54 | #if CONFIG_ATAHPT == 1 |
| 55 | PROGRAMMER_ATAHPT, |
| 56 | #endif |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 57 | #if CONFIG_FT2232_SPI == 1 |
| 58 | PROGRAMMER_FT2232_SPI, |
| 59 | #endif |
| 60 | #if CONFIG_SERPROG == 1 |
| 61 | PROGRAMMER_SERPROG, |
| 62 | #endif |
| 63 | #if CONFIG_BUSPIRATE_SPI == 1 |
| 64 | PROGRAMMER_BUSPIRATE_SPI, |
| 65 | #endif |
| 66 | #if CONFIG_DEDIPROG == 1 |
| 67 | PROGRAMMER_DEDIPROG, |
| 68 | #endif |
| 69 | #if CONFIG_RAYER_SPI == 1 |
| 70 | PROGRAMMER_RAYER_SPI, |
| 71 | #endif |
Virgil-Adrian Teaca | da7c545 | 2012-04-30 23:11:06 +0000 | [diff] [blame] | 72 | #if CONFIG_PONY_SPI == 1 |
| 73 | PROGRAMMER_PONY_SPI, |
| 74 | #endif |
Carl-Daniel Hailfinger | b713d2e | 2011-05-08 00:24:18 +0000 | [diff] [blame] | 75 | #if CONFIG_NICINTEL == 1 |
| 76 | PROGRAMMER_NICINTEL, |
| 77 | #endif |
Idwer Vollering | 004f4b7 | 2010-09-03 18:21:21 +0000 | [diff] [blame] | 78 | #if CONFIG_NICINTEL_SPI == 1 |
| 79 | PROGRAMMER_NICINTEL_SPI, |
| 80 | #endif |
Mark Marshall | 90021f2 | 2010-12-03 14:48:11 +0000 | [diff] [blame] | 81 | #if CONFIG_OGP_SPI == 1 |
| 82 | PROGRAMMER_OGP_SPI, |
| 83 | #endif |
Carl-Daniel Hailfinger | 9a1105c | 2011-02-04 21:37:59 +0000 | [diff] [blame] | 84 | #if CONFIG_SATAMV == 1 |
| 85 | PROGRAMMER_SATAMV, |
| 86 | #endif |
Sven Schnelle | 5ce5f70 | 2011-09-03 18:37:52 +0000 | [diff] [blame] | 87 | #if CONFIG_LINUX_SPI == 1 |
| 88 | PROGRAMMER_LINUX_SPI, |
| 89 | #endif |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 90 | PROGRAMMER_INVALID /* This must always be the last entry. */ |
| 91 | }; |
| 92 | |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 93 | struct programmer_entry { |
| 94 | const char *vendor; |
| 95 | const char *name; |
| 96 | |
| 97 | int (*init) (void); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 98 | |
Carl-Daniel Hailfinger | 8a3c60c | 2011-12-18 15:01:24 +0000 | [diff] [blame] | 99 | void *(*map_flash_region) (const char *descr, unsigned long phys_addr, |
| 100 | size_t len); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 101 | void (*unmap_flash_region) (void *virt_addr, size_t len); |
| 102 | |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 103 | void (*delay) (int usecs); |
| 104 | }; |
| 105 | |
| 106 | extern const struct programmer_entry programmer_table[]; |
| 107 | |
Carl-Daniel Hailfinger | 2e68160 | 2011-09-08 00:00:29 +0000 | [diff] [blame] | 108 | int programmer_init(enum programmer prog, char *param); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 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 |
Virgil-Adrian Teaca | da7c545 | 2012-04-30 23:11:06 +0000 | [diff] [blame] | 116 | #if CONFIG_PONY_SPI == 1 |
| 117 | BITBANG_SPI_MASTER_PONY, |
| 118 | #endif |
Idwer Vollering | 004f4b7 | 2010-09-03 18:21:21 +0000 | [diff] [blame] | 119 | #if CONFIG_NICINTEL_SPI == 1 |
| 120 | BITBANG_SPI_MASTER_NICINTEL, |
| 121 | #endif |
Carl-Daniel Hailfinger | 2f43616 | 2010-07-28 15:08:35 +0000 | [diff] [blame] | 122 | #if CONFIG_INTERNAL == 1 |
| 123 | #if defined(__i386__) || defined(__x86_64__) |
| 124 | BITBANG_SPI_MASTER_MCP, |
| 125 | #endif |
| 126 | #endif |
Mark Marshall | 90021f2 | 2010-12-03 14:48:11 +0000 | [diff] [blame] | 127 | #if CONFIG_OGP_SPI == 1 |
| 128 | BITBANG_SPI_MASTER_OGP, |
| 129 | #endif |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 130 | }; |
| 131 | |
| 132 | struct bitbang_spi_master { |
| 133 | enum bitbang_spi_master_type type; |
| 134 | |
| 135 | /* Note that CS# is active low, so val=0 means the chip is active. */ |
| 136 | void (*set_cs) (int val); |
| 137 | void (*set_sck) (int val); |
| 138 | void (*set_mosi) (int val); |
| 139 | int (*get_miso) (void); |
Carl-Daniel Hailfinger | 2822888 | 2010-09-15 00:17:37 +0000 | [diff] [blame] | 140 | void (*request_bus) (void); |
| 141 | void (*release_bus) (void); |
Carl-Daniel Hailfinger | c40cff7 | 2011-12-20 00:19:29 +0000 | [diff] [blame] | 142 | /* Length of half a clock period in usecs. */ |
| 143 | unsigned int half_period; |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 144 | }; |
| 145 | |
| 146 | #if CONFIG_INTERNAL == 1 |
Patrick Georgi | 32508eb | 2012-07-20 20:35:14 +0000 | [diff] [blame] | 147 | struct pci_dev; |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 148 | struct penable { |
| 149 | uint16_t vendor_id; |
| 150 | uint16_t device_id; |
Stefan Tauner | 2c20b28 | 2012-07-28 19:35:26 +0000 | [diff] [blame] | 151 | const enum test_state status; |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 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 | |
Carl-Daniel Hailfinger | 580d29a | 2011-05-05 07:12:40 +0000 | [diff] [blame] | 159 | enum board_match_phase { |
| 160 | P1, |
| 161 | P2, |
| 162 | P3 |
| 163 | }; |
| 164 | |
Carl-Daniel Hailfinger | 97d5b12 | 2011-08-31 16:19:50 +0000 | [diff] [blame] | 165 | struct board_match { |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 166 | /* Any device, but make it sensible, like the ISA bridge. */ |
| 167 | uint16_t first_vendor; |
| 168 | uint16_t first_device; |
| 169 | uint16_t first_card_vendor; |
| 170 | uint16_t first_card_device; |
| 171 | |
| 172 | /* Any device, but make it sensible, like |
| 173 | * the host bridge. May be NULL. |
| 174 | */ |
| 175 | uint16_t second_vendor; |
| 176 | uint16_t second_device; |
| 177 | uint16_t second_card_vendor; |
| 178 | uint16_t second_card_device; |
| 179 | |
Stefan Tauner | 7bcacb1 | 2011-05-26 01:35:19 +0000 | [diff] [blame] | 180 | /* Pattern to match DMI entries. May be NULL. */ |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 181 | const char *dmi_pattern; |
| 182 | |
Stefan Tauner | 7bcacb1 | 2011-05-26 01:35:19 +0000 | [diff] [blame] | 183 | /* The vendor / part name from the coreboot table. May be NULL. */ |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 184 | const char *lb_vendor; |
| 185 | const char *lb_part; |
| 186 | |
Carl-Daniel Hailfinger | 580d29a | 2011-05-05 07:12:40 +0000 | [diff] [blame] | 187 | enum board_match_phase phase; |
| 188 | |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 189 | const char *vendor_name; |
| 190 | const char *board_name; |
| 191 | |
| 192 | int max_rom_decode_parallel; |
Stefan Tauner | 2c20b28 | 2012-07-28 19:35:26 +0000 | [diff] [blame] | 193 | const enum test_state status; |
Stefan Tauner | 7bcacb1 | 2011-05-26 01:35:19 +0000 | [diff] [blame] | 194 | int (*enable) (void); /* May be NULL. */ |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 195 | }; |
| 196 | |
Carl-Daniel Hailfinger | 97d5b12 | 2011-08-31 16:19:50 +0000 | [diff] [blame] | 197 | extern const struct board_match board_matches[]; |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 198 | |
| 199 | struct board_info { |
| 200 | const char *vendor; |
| 201 | const char *name; |
Stefan Tauner | 2c20b28 | 2012-07-28 19:35:26 +0000 | [diff] [blame] | 202 | const enum test_state working; |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 203 | #ifdef CONFIG_PRINT_WIKI |
| 204 | const char *url; |
| 205 | const char *note; |
| 206 | #endif |
| 207 | }; |
| 208 | |
| 209 | extern const struct board_info boards_known[]; |
| 210 | extern const struct board_info laptops_known[]; |
| 211 | #endif |
| 212 | |
| 213 | /* udelay.c */ |
| 214 | void myusec_delay(int usecs); |
| 215 | void myusec_calibrate_delay(void); |
| 216 | void internal_delay(int usecs); |
| 217 | |
| 218 | #if NEED_PCI == 1 |
| 219 | /* pcidev.c */ |
Carl-Daniel Hailfinger | c40cff7 | 2011-12-20 00:19:29 +0000 | [diff] [blame] | 220 | // FIXME: These need to be local, not global |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 221 | extern uint32_t io_base_addr; |
| 222 | extern struct pci_access *pacc; |
| 223 | extern struct pci_dev *pcidev_dev; |
| 224 | struct pcidev_status { |
| 225 | uint16_t vendor_id; |
| 226 | uint16_t device_id; |
Stefan Tauner | 2c20b28 | 2012-07-28 19:35:26 +0000 | [diff] [blame] | 227 | const enum test_state status; |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 228 | const char *vendor_name; |
| 229 | const char *device_name; |
| 230 | }; |
Carl-Daniel Hailfinger | 3834c2d | 2012-07-16 21:32:19 +0000 | [diff] [blame] | 231 | uintptr_t pcidev_readbar(struct pci_dev *dev, int bar); |
Carl-Daniel Hailfinger | 40446ee | 2011-03-07 01:08:09 +0000 | [diff] [blame] | 232 | uintptr_t pcidev_init(int bar, const struct pcidev_status *devs); |
Carl-Daniel Hailfinger | 2bee8cf | 2010-11-10 15:25:18 +0000 | [diff] [blame] | 233 | /* rpci_write_* are reversible writes. The original PCI config space register |
| 234 | * contents will be restored on shutdown. |
| 235 | */ |
Idwer Vollering | 1a6162e | 2010-12-26 23:55:19 +0000 | [diff] [blame] | 236 | int rpci_write_byte(struct pci_dev *dev, int reg, uint8_t data); |
| 237 | int rpci_write_word(struct pci_dev *dev, int reg, uint16_t data); |
| 238 | 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] | 239 | #endif |
| 240 | |
| 241 | /* print.c */ |
Carl-Daniel Hailfinger | b713d2e | 2011-05-08 00:24:18 +0000 | [diff] [blame] | 242 | #if CONFIG_NIC3COM+CONFIG_NICREALTEK+CONFIG_NICNATSEMI+CONFIG_GFXNVIDIA+CONFIG_DRKAISER+CONFIG_SATASII+CONFIG_ATAHPT+CONFIG_NICINTEL+CONFIG_NICINTEL_SPI+CONFIG_OGP_SPI+CONFIG_SATAMV >= 1 |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 243 | void print_supported_pcidevs(const struct pcidev_status *devs); |
| 244 | #endif |
| 245 | |
Carl-Daniel Hailfinger | c422484 | 2011-06-09 20:06:34 +0000 | [diff] [blame] | 246 | #if CONFIG_INTERNAL == 1 |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 247 | /* board_enable.c */ |
| 248 | void w836xx_ext_enter(uint16_t port); |
| 249 | void w836xx_ext_leave(uint16_t port); |
Carl-Daniel Hailfinger | f5e62cb | 2012-05-06 22:48:01 +0000 | [diff] [blame] | 250 | void probe_superio_winbond(void); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 251 | int it8705f_write_enable(uint8_t port); |
| 252 | uint8_t sio_read(uint16_t port, uint8_t reg); |
| 253 | void sio_write(uint16_t port, uint8_t reg, uint8_t data); |
| 254 | void sio_mask(uint16_t port, uint8_t reg, uint8_t data, uint8_t mask); |
Carl-Daniel Hailfinger | 580d29a | 2011-05-05 07:12:40 +0000 | [diff] [blame] | 255 | void board_handle_before_superio(void); |
| 256 | void board_handle_before_laptop(void); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 257 | int board_flash_enable(const char *vendor, const char *part); |
| 258 | |
| 259 | /* chipset_enable.c */ |
| 260 | int chipset_flash_enable(void); |
| 261 | |
| 262 | /* processor_enable.c */ |
| 263 | int processor_flash_enable(void); |
Carl-Daniel Hailfinger | 580d29a | 2011-05-05 07:12:40 +0000 | [diff] [blame] | 264 | #endif |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 265 | |
| 266 | /* physmap.c */ |
| 267 | void *physmap(const char *descr, unsigned long phys_addr, size_t len); |
| 268 | void *physmap_try_ro(const char *descr, unsigned long phys_addr, size_t len); |
| 269 | void physunmap(void *virt_addr, size_t len); |
Carl-Daniel Hailfinger | c422484 | 2011-06-09 20:06:34 +0000 | [diff] [blame] | 270 | #if CONFIG_INTERNAL == 1 |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 271 | int setup_cpu_msr(int cpu); |
| 272 | void cleanup_cpu_msr(void); |
| 273 | |
| 274 | /* cbtable.c */ |
Carl-Daniel Hailfinger | 2d927fb | 2012-01-04 00:48:27 +0000 | [diff] [blame] | 275 | void lb_vendor_dev_from_string(const char *boardstring); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 276 | int coreboot_init(void); |
| 277 | extern char *lb_part, *lb_vendor; |
| 278 | extern int partvendor_from_cbtable; |
| 279 | |
| 280 | /* dmi.c */ |
| 281 | extern int has_dmi_support; |
| 282 | void dmi_init(void); |
| 283 | int dmi_match(const char *pattern); |
| 284 | |
| 285 | /* internal.c */ |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 286 | struct superio { |
| 287 | uint16_t vendor; |
| 288 | uint16_t port; |
| 289 | uint16_t model; |
| 290 | }; |
Carl-Daniel Hailfinger | bfecef6 | 2011-04-27 14:34:08 +0000 | [diff] [blame] | 291 | extern struct superio superios[]; |
| 292 | extern int superio_count; |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 293 | #define SUPERIO_VENDOR_NONE 0x0 |
| 294 | #define SUPERIO_VENDOR_ITE 0x1 |
Carl-Daniel Hailfinger | f5e62cb | 2012-05-06 22:48:01 +0000 | [diff] [blame] | 295 | #define SUPERIO_VENDOR_WINBOND 0x2 |
Carl-Daniel Hailfinger | c422484 | 2011-06-09 20:06:34 +0000 | [diff] [blame] | 296 | #endif |
| 297 | #if NEED_PCI == 1 |
Patrick Georgi | 32508eb | 2012-07-20 20:35:14 +0000 | [diff] [blame] | 298 | struct pci_filter; |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 299 | struct pci_dev *pci_dev_find_filter(struct pci_filter filter); |
Uwe Hermann | 24c35e4 | 2011-07-13 11:22:03 +0000 | [diff] [blame] | 300 | struct pci_dev *pci_dev_find_vendorclass(uint16_t vendor, uint16_t devclass); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 301 | struct pci_dev *pci_dev_find(uint16_t vendor, uint16_t device); |
| 302 | struct pci_dev *pci_card_find(uint16_t vendor, uint16_t device, |
| 303 | uint16_t card_vendor, uint16_t card_device); |
| 304 | #endif |
Carl-Daniel Hailfinger | d6bb828 | 2012-07-21 17:27:08 +0000 | [diff] [blame] | 305 | int rget_io_perms(void); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 306 | #if CONFIG_INTERNAL == 1 |
| 307 | extern int is_laptop; |
Carl-Daniel Hailfinger | 580d29a | 2011-05-05 07:12:40 +0000 | [diff] [blame] | 308 | extern int laptop_ok; |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 309 | extern int force_boardenable; |
| 310 | extern int force_boardmismatch; |
| 311 | void probe_superio(void); |
Carl-Daniel Hailfinger | bfecef6 | 2011-04-27 14:34:08 +0000 | [diff] [blame] | 312 | int register_superio(struct superio s); |
Carl-Daniel Hailfinger | eaacd2d | 2011-11-09 23:40:00 +0000 | [diff] [blame] | 313 | extern enum chipbustype internal_buses_supported; |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 314 | int internal_init(void); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 315 | #endif |
| 316 | |
| 317 | /* hwaccess.c */ |
| 318 | void mmio_writeb(uint8_t val, void *addr); |
| 319 | void mmio_writew(uint16_t val, void *addr); |
| 320 | void mmio_writel(uint32_t val, void *addr); |
| 321 | uint8_t mmio_readb(void *addr); |
| 322 | uint16_t mmio_readw(void *addr); |
| 323 | uint32_t mmio_readl(void *addr); |
Carl-Daniel Hailfinger | ccd71c2 | 2012-03-01 22:38:27 +0000 | [diff] [blame] | 324 | void mmio_readn(void *addr, uint8_t *buf, size_t len); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 325 | void mmio_le_writeb(uint8_t val, void *addr); |
| 326 | void mmio_le_writew(uint16_t val, void *addr); |
| 327 | void mmio_le_writel(uint32_t val, void *addr); |
| 328 | uint8_t mmio_le_readb(void *addr); |
| 329 | uint16_t mmio_le_readw(void *addr); |
| 330 | uint32_t mmio_le_readl(void *addr); |
| 331 | #define pci_mmio_writeb mmio_le_writeb |
| 332 | #define pci_mmio_writew mmio_le_writew |
| 333 | #define pci_mmio_writel mmio_le_writel |
| 334 | #define pci_mmio_readb mmio_le_readb |
| 335 | #define pci_mmio_readw mmio_le_readw |
| 336 | #define pci_mmio_readl mmio_le_readl |
Carl-Daniel Hailfinger | 54ce73a | 2011-05-03 21:49:41 +0000 | [diff] [blame] | 337 | void rmmio_writeb(uint8_t val, void *addr); |
| 338 | void rmmio_writew(uint16_t val, void *addr); |
| 339 | void rmmio_writel(uint32_t val, void *addr); |
| 340 | void rmmio_le_writeb(uint8_t val, void *addr); |
| 341 | void rmmio_le_writew(uint16_t val, void *addr); |
| 342 | void rmmio_le_writel(uint32_t val, void *addr); |
| 343 | #define pci_rmmio_writeb rmmio_le_writeb |
| 344 | #define pci_rmmio_writew rmmio_le_writew |
| 345 | #define pci_rmmio_writel rmmio_le_writel |
| 346 | void rmmio_valb(void *addr); |
| 347 | void rmmio_valw(void *addr); |
| 348 | void rmmio_vall(void *addr); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 349 | |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 350 | /* dummyflasher.c */ |
| 351 | #if CONFIG_DUMMY == 1 |
| 352 | int dummy_init(void); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 353 | void *dummy_map(const char *descr, unsigned long phys_addr, size_t len); |
| 354 | void dummy_unmap(void *virt_addr, size_t len); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 355 | #endif |
| 356 | |
| 357 | /* nic3com.c */ |
| 358 | #if CONFIG_NIC3COM == 1 |
| 359 | int nic3com_init(void); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 360 | extern const struct pcidev_status nics_3com[]; |
| 361 | #endif |
| 362 | |
| 363 | /* gfxnvidia.c */ |
| 364 | #if CONFIG_GFXNVIDIA == 1 |
| 365 | int gfxnvidia_init(void); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 366 | extern const struct pcidev_status gfx_nvidia[]; |
| 367 | #endif |
| 368 | |
| 369 | /* drkaiser.c */ |
| 370 | #if CONFIG_DRKAISER == 1 |
| 371 | int drkaiser_init(void); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 372 | extern const struct pcidev_status drkaiser_pcidev[]; |
| 373 | #endif |
| 374 | |
| 375 | /* nicrealtek.c */ |
| 376 | #if CONFIG_NICREALTEK == 1 |
| 377 | int nicrealtek_init(void); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 378 | extern const struct pcidev_status nics_realtek[]; |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 379 | #endif |
| 380 | |
| 381 | /* nicnatsemi.c */ |
| 382 | #if CONFIG_NICNATSEMI == 1 |
| 383 | int nicnatsemi_init(void); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 384 | extern const struct pcidev_status nics_natsemi[]; |
| 385 | #endif |
| 386 | |
Carl-Daniel Hailfinger | b713d2e | 2011-05-08 00:24:18 +0000 | [diff] [blame] | 387 | /* nicintel.c */ |
| 388 | #if CONFIG_NICINTEL == 1 |
| 389 | int nicintel_init(void); |
Carl-Daniel Hailfinger | b713d2e | 2011-05-08 00:24:18 +0000 | [diff] [blame] | 390 | extern const struct pcidev_status nics_intel[]; |
| 391 | #endif |
| 392 | |
Idwer Vollering | 004f4b7 | 2010-09-03 18:21:21 +0000 | [diff] [blame] | 393 | /* nicintel_spi.c */ |
| 394 | #if CONFIG_NICINTEL_SPI == 1 |
| 395 | int nicintel_spi_init(void); |
Idwer Vollering | 004f4b7 | 2010-09-03 18:21:21 +0000 | [diff] [blame] | 396 | extern const struct pcidev_status nics_intel_spi[]; |
| 397 | #endif |
| 398 | |
Mark Marshall | 90021f2 | 2010-12-03 14:48:11 +0000 | [diff] [blame] | 399 | /* ogp_spi.c */ |
| 400 | #if CONFIG_OGP_SPI == 1 |
| 401 | int ogp_spi_init(void); |
Mark Marshall | 90021f2 | 2010-12-03 14:48:11 +0000 | [diff] [blame] | 402 | extern const struct pcidev_status ogp_spi[]; |
| 403 | #endif |
| 404 | |
Carl-Daniel Hailfinger | 9a1105c | 2011-02-04 21:37:59 +0000 | [diff] [blame] | 405 | /* satamv.c */ |
| 406 | #if CONFIG_SATAMV == 1 |
| 407 | int satamv_init(void); |
Carl-Daniel Hailfinger | 9a1105c | 2011-02-04 21:37:59 +0000 | [diff] [blame] | 408 | extern const struct pcidev_status satas_mv[]; |
| 409 | #endif |
| 410 | |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 411 | /* satasii.c */ |
| 412 | #if CONFIG_SATASII == 1 |
| 413 | int satasii_init(void); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 414 | extern const struct pcidev_status satas_sii[]; |
| 415 | #endif |
| 416 | |
| 417 | /* atahpt.c */ |
| 418 | #if CONFIG_ATAHPT == 1 |
| 419 | int atahpt_init(void); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 420 | extern const struct pcidev_status ata_hpt[]; |
| 421 | #endif |
| 422 | |
| 423 | /* ft2232_spi.c */ |
Jörg Fischer | 6529b9f | 2010-07-29 15:54:53 +0000 | [diff] [blame] | 424 | #if CONFIG_FT2232_SPI == 1 |
| 425 | struct usbdev_status { |
Uwe Hermann | 48ec1b1 | 2010-08-08 17:01:18 +0000 | [diff] [blame] | 426 | uint16_t vendor_id; |
| 427 | uint16_t device_id; |
Stefan Tauner | 2c20b28 | 2012-07-28 19:35:26 +0000 | [diff] [blame] | 428 | const enum test_state status; |
Uwe Hermann | 48ec1b1 | 2010-08-08 17:01:18 +0000 | [diff] [blame] | 429 | const char *vendor_name; |
| 430 | const char *device_name; |
Jörg Fischer | 6529b9f | 2010-07-29 15:54:53 +0000 | [diff] [blame] | 431 | }; |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 432 | int ft2232_spi_init(void); |
Jörg Fischer | 6529b9f | 2010-07-29 15:54:53 +0000 | [diff] [blame] | 433 | extern const struct usbdev_status devs_ft2232spi[]; |
| 434 | void print_supported_usbdevs(const struct usbdev_status *devs); |
| 435 | #endif |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 436 | |
| 437 | /* rayer_spi.c */ |
| 438 | #if CONFIG_RAYER_SPI == 1 |
| 439 | int rayer_spi_init(void); |
| 440 | #endif |
| 441 | |
Virgil-Adrian Teaca | da7c545 | 2012-04-30 23:11:06 +0000 | [diff] [blame] | 442 | /* pony_spi.c */ |
| 443 | #if CONFIG_PONY_SPI == 1 |
| 444 | int pony_spi_init(void); |
| 445 | #endif |
| 446 | |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 447 | /* bitbang_spi.c */ |
Carl-Daniel Hailfinger | c40cff7 | 2011-12-20 00:19:29 +0000 | [diff] [blame] | 448 | int bitbang_spi_init(const struct bitbang_spi_master *master); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 449 | |
| 450 | /* buspirate_spi.c */ |
Carl-Daniel Hailfinger | c422484 | 2011-06-09 20:06:34 +0000 | [diff] [blame] | 451 | #if CONFIG_BUSPIRATE_SPI == 1 |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 452 | int buspirate_spi_init(void); |
Carl-Daniel Hailfinger | c422484 | 2011-06-09 20:06:34 +0000 | [diff] [blame] | 453 | #endif |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 454 | |
Sven Schnelle | 5ce5f70 | 2011-09-03 18:37:52 +0000 | [diff] [blame] | 455 | /* linux_spi.c */ |
| 456 | #if CONFIG_LINUX_SPI == 1 |
| 457 | int linux_spi_init(void); |
| 458 | #endif |
| 459 | |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 460 | /* dediprog.c */ |
Carl-Daniel Hailfinger | c422484 | 2011-06-09 20:06:34 +0000 | [diff] [blame] | 461 | #if CONFIG_DEDIPROG == 1 |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 462 | int dediprog_init(void); |
Carl-Daniel Hailfinger | c422484 | 2011-06-09 20:06:34 +0000 | [diff] [blame] | 463 | #endif |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 464 | |
| 465 | /* flashrom.c */ |
| 466 | struct decode_sizes { |
| 467 | uint32_t parallel; |
| 468 | uint32_t lpc; |
| 469 | uint32_t fwh; |
| 470 | uint32_t spi; |
| 471 | }; |
Carl-Daniel Hailfinger | c40cff7 | 2011-12-20 00:19:29 +0000 | [diff] [blame] | 472 | // FIXME: These need to be local, not global |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 473 | extern struct decode_sizes max_rom_decode; |
| 474 | extern int programmer_may_write; |
| 475 | extern unsigned long flashbase; |
Carl-Daniel Hailfinger | 63fd902 | 2011-12-14 22:25:15 +0000 | [diff] [blame] | 476 | void check_chip_supported(const struct flashctx *flash); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 477 | int check_max_decode(enum chipbustype buses, uint32_t size); |
Stefan Tauner | 6665244 | 2011-06-26 17:38:17 +0000 | [diff] [blame] | 478 | char *extract_programmer_param(const char *param_name); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 479 | |
| 480 | /* layout.c */ |
| 481 | int show_id(uint8_t *bios, int size, int force); |
| 482 | |
| 483 | /* spi.c */ |
| 484 | enum spi_controller { |
| 485 | SPI_CONTROLLER_NONE, |
| 486 | #if CONFIG_INTERNAL == 1 |
| 487 | #if defined(__i386__) || defined(__x86_64__) |
| 488 | SPI_CONTROLLER_ICH7, |
| 489 | SPI_CONTROLLER_ICH9, |
David Hendricks | 4e74839 | 2011-02-28 23:58:15 +0000 | [diff] [blame] | 490 | SPI_CONTROLLER_IT85XX, |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 491 | SPI_CONTROLLER_IT87XX, |
| 492 | SPI_CONTROLLER_SB600, |
| 493 | SPI_CONTROLLER_VIA, |
| 494 | SPI_CONTROLLER_WBSIO, |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 495 | #endif |
| 496 | #endif |
| 497 | #if CONFIG_FT2232_SPI == 1 |
| 498 | SPI_CONTROLLER_FT2232, |
| 499 | #endif |
| 500 | #if CONFIG_DUMMY == 1 |
| 501 | SPI_CONTROLLER_DUMMY, |
| 502 | #endif |
| 503 | #if CONFIG_BUSPIRATE_SPI == 1 |
| 504 | SPI_CONTROLLER_BUSPIRATE, |
| 505 | #endif |
| 506 | #if CONFIG_DEDIPROG == 1 |
| 507 | SPI_CONTROLLER_DEDIPROG, |
| 508 | #endif |
Virgil-Adrian Teaca | da7c545 | 2012-04-30 23:11:06 +0000 | [diff] [blame] | 509 | #if CONFIG_OGP_SPI == 1 || CONFIG_NICINTEL_SPI == 1 || CONFIG_RAYER_SPI == 1 || CONFIG_PONY_SPI == 1 || (CONFIG_INTERNAL == 1 && (defined(__i386__) || defined(__x86_64__))) |
Michael Karcher | b9dbe48 | 2011-05-11 17:07:07 +0000 | [diff] [blame] | 510 | SPI_CONTROLLER_BITBANG, |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 511 | #endif |
Sven Schnelle | 5ce5f70 | 2011-09-03 18:37:52 +0000 | [diff] [blame] | 512 | #if CONFIG_LINUX_SPI == 1 |
| 513 | SPI_CONTROLLER_LINUX, |
| 514 | #endif |
Urja Rannikko | c93f5f1 | 2011-09-15 23:38:14 +0000 | [diff] [blame] | 515 | #if CONFIG_SERPROG == 1 |
| 516 | SPI_CONTROLLER_SERPROG, |
| 517 | #endif |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 518 | }; |
Michael Karcher | 6279751 | 2011-05-11 17:07:02 +0000 | [diff] [blame] | 519 | |
| 520 | #define MAX_DATA_UNSPECIFIED 0 |
| 521 | #define MAX_DATA_READ_UNLIMITED 64 * 1024 |
| 522 | #define MAX_DATA_WRITE_UNLIMITED 256 |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 523 | struct spi_programmer { |
Michael Karcher | b9dbe48 | 2011-05-11 17:07:07 +0000 | [diff] [blame] | 524 | enum spi_controller type; |
Stefan Tauner | c69c9c8 | 2011-11-23 09:13:48 +0000 | [diff] [blame] | 525 | unsigned int max_data_read; |
| 526 | unsigned int max_data_write; |
Carl-Daniel Hailfinger | 8a3c60c | 2011-12-18 15:01:24 +0000 | [diff] [blame] | 527 | int (*command)(struct flashctx *flash, unsigned int writecnt, unsigned int readcnt, |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 528 | const unsigned char *writearr, unsigned char *readarr); |
Carl-Daniel Hailfinger | 8a3c60c | 2011-12-18 15:01:24 +0000 | [diff] [blame] | 529 | int (*multicommand)(struct flashctx *flash, struct spi_command *cmds); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 530 | |
| 531 | /* Optimized functions for this programmer */ |
Carl-Daniel Hailfinger | 63fd902 | 2011-12-14 22:25:15 +0000 | [diff] [blame] | 532 | int (*read)(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len); |
| 533 | int (*write_256)(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len); |
Nico Huber | 7bca126 | 2012-06-15 22:28:12 +0000 | [diff] [blame] | 534 | int (*write_aai)(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len); |
Carl-Daniel Hailfinger | c40cff7 | 2011-12-20 00:19:29 +0000 | [diff] [blame] | 535 | const void *data; |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 536 | }; |
| 537 | |
Carl-Daniel Hailfinger | 8a3c60c | 2011-12-18 15:01:24 +0000 | [diff] [blame] | 538 | int default_spi_send_command(struct flashctx *flash, unsigned int writecnt, unsigned int readcnt, |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 539 | const unsigned char *writearr, unsigned char *readarr); |
Carl-Daniel Hailfinger | 8a3c60c | 2011-12-18 15:01:24 +0000 | [diff] [blame] | 540 | int default_spi_send_multicommand(struct flashctx *flash, struct spi_command *cmds); |
Carl-Daniel Hailfinger | 63fd902 | 2011-12-14 22:25:15 +0000 | [diff] [blame] | 541 | int default_spi_read(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len); |
| 542 | int default_spi_write_256(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len); |
Nico Huber | 7bca126 | 2012-06-15 22:28:12 +0000 | [diff] [blame] | 543 | int default_spi_write_aai(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len); |
Carl-Daniel Hailfinger | c40cff7 | 2011-12-20 00:19:29 +0000 | [diff] [blame] | 544 | int register_spi_programmer(const struct spi_programmer *programmer); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 545 | |
Stefan Tauner | 2abab94 | 2012-04-27 20:41:23 +0000 | [diff] [blame] | 546 | /* The following enum is needed by ich_descriptor_tool and ich* code. */ |
Stefan Tauner | a8d838d | 2011-11-06 23:51:09 +0000 | [diff] [blame] | 547 | enum ich_chipset { |
| 548 | CHIPSET_ICH_UNKNOWN, |
| 549 | CHIPSET_ICH7 = 7, |
| 550 | CHIPSET_ICH8, |
| 551 | CHIPSET_ICH9, |
| 552 | CHIPSET_ICH10, |
| 553 | CHIPSET_5_SERIES_IBEX_PEAK, |
| 554 | CHIPSET_6_SERIES_COUGAR_POINT, |
Stefan Tauner | 2abab94 | 2012-04-27 20:41:23 +0000 | [diff] [blame] | 555 | CHIPSET_7_SERIES_PANTHER_POINT, |
| 556 | CHIPSET_8_SERIES_LYNX_POINT |
Stefan Tauner | a8d838d | 2011-11-06 23:51:09 +0000 | [diff] [blame] | 557 | }; |
| 558 | |
Stefan Tauner | 2abab94 | 2012-04-27 20:41:23 +0000 | [diff] [blame] | 559 | /* ichspi.c */ |
| 560 | #if CONFIG_INTERNAL == 1 |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 561 | extern uint32_t ichspi_bbar; |
| 562 | int ich_init_spi(struct pci_dev *dev, uint32_t base, void *rcrb, |
Stefan Tauner | a8d838d | 2011-11-06 23:51:09 +0000 | [diff] [blame] | 563 | enum ich_chipset ich_generation); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 564 | int via_init_spi(struct pci_dev *dev); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 565 | |
David Hendricks | 4e74839 | 2011-02-28 23:58:15 +0000 | [diff] [blame] | 566 | /* it85spi.c */ |
Carl-Daniel Hailfinger | bfecef6 | 2011-04-27 14:34:08 +0000 | [diff] [blame] | 567 | int it85xx_spi_init(struct superio s); |
David Hendricks | 4e74839 | 2011-02-28 23:58:15 +0000 | [diff] [blame] | 568 | |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 569 | /* it87spi.c */ |
| 570 | void enter_conf_mode_ite(uint16_t port); |
| 571 | void exit_conf_mode_ite(uint16_t port); |
Carl-Daniel Hailfinger | bfecef6 | 2011-04-27 14:34:08 +0000 | [diff] [blame] | 572 | void probe_superio_ite(void); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 573 | int init_superio_ite(void); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 574 | |
Carl-Daniel Hailfinger | c422484 | 2011-06-09 20:06:34 +0000 | [diff] [blame] | 575 | /* mcp6x_spi.c */ |
| 576 | int mcp6x_spi_init(int want_spi); |
| 577 | |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 578 | /* sb600spi.c */ |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 579 | int sb600_probe_spi(struct pci_dev *dev); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 580 | |
| 581 | /* wbsio_spi.c */ |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 582 | int wbsio_check_for_spi(void); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 583 | #endif |
| 584 | |
Carl-Daniel Hailfinger | 532c717 | 2011-11-04 21:35:26 +0000 | [diff] [blame] | 585 | /* opaque.c */ |
| 586 | struct opaque_programmer { |
| 587 | int max_data_read; |
| 588 | int max_data_write; |
| 589 | /* Specific functions for this programmer */ |
Carl-Daniel Hailfinger | 63fd902 | 2011-12-14 22:25:15 +0000 | [diff] [blame] | 590 | int (*probe) (struct flashctx *flash); |
| 591 | int (*read) (struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len); |
| 592 | int (*write) (struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len); |
| 593 | int (*erase) (struct flashctx *flash, unsigned int blockaddr, unsigned int blocklen); |
Carl-Daniel Hailfinger | c40cff7 | 2011-12-20 00:19:29 +0000 | [diff] [blame] | 594 | const void *data; |
Carl-Daniel Hailfinger | 532c717 | 2011-11-04 21:35:26 +0000 | [diff] [blame] | 595 | }; |
Carl-Daniel Hailfinger | c40cff7 | 2011-12-20 00:19:29 +0000 | [diff] [blame] | 596 | int register_opaque_programmer(const struct opaque_programmer *pgm); |
Carl-Daniel Hailfinger | 532c717 | 2011-11-04 21:35:26 +0000 | [diff] [blame] | 597 | |
Carl-Daniel Hailfinger | 8a3c60c | 2011-12-18 15:01:24 +0000 | [diff] [blame] | 598 | /* programmer.c */ |
| 599 | int noop_shutdown(void); |
| 600 | void *fallback_map(const char *descr, unsigned long phys_addr, size_t len); |
| 601 | void fallback_unmap(void *virt_addr, size_t len); |
Carl-Daniel Hailfinger | 8a3c60c | 2011-12-18 15:01:24 +0000 | [diff] [blame] | 602 | void noop_chip_writeb(const struct flashctx *flash, uint8_t val, chipaddr addr); |
| 603 | void fallback_chip_writew(const struct flashctx *flash, uint16_t val, chipaddr addr); |
| 604 | void fallback_chip_writel(const struct flashctx *flash, uint32_t val, chipaddr addr); |
| 605 | void fallback_chip_writen(const struct flashctx *flash, uint8_t *buf, chipaddr addr, size_t len); |
| 606 | uint16_t fallback_chip_readw(const struct flashctx *flash, const chipaddr addr); |
| 607 | uint32_t fallback_chip_readl(const struct flashctx *flash, const chipaddr addr); |
| 608 | void fallback_chip_readn(const struct flashctx *flash, uint8_t *buf, const chipaddr addr, size_t len); |
| 609 | struct par_programmer { |
| 610 | void (*chip_writeb) (const struct flashctx *flash, uint8_t val, chipaddr addr); |
| 611 | void (*chip_writew) (const struct flashctx *flash, uint16_t val, chipaddr addr); |
| 612 | void (*chip_writel) (const struct flashctx *flash, uint32_t val, chipaddr addr); |
| 613 | void (*chip_writen) (const struct flashctx *flash, uint8_t *buf, chipaddr addr, size_t len); |
| 614 | uint8_t (*chip_readb) (const struct flashctx *flash, const chipaddr addr); |
| 615 | uint16_t (*chip_readw) (const struct flashctx *flash, const chipaddr addr); |
| 616 | uint32_t (*chip_readl) (const struct flashctx *flash, const chipaddr addr); |
| 617 | void (*chip_readn) (const struct flashctx *flash, uint8_t *buf, const chipaddr addr, size_t len); |
Carl-Daniel Hailfinger | c40cff7 | 2011-12-20 00:19:29 +0000 | [diff] [blame] | 618 | const void *data; |
Carl-Daniel Hailfinger | 8a3c60c | 2011-12-18 15:01:24 +0000 | [diff] [blame] | 619 | }; |
Carl-Daniel Hailfinger | c40cff7 | 2011-12-20 00:19:29 +0000 | [diff] [blame] | 620 | int register_par_programmer(const struct par_programmer *pgm, const enum chipbustype buses); |
| 621 | struct registered_programmer { |
| 622 | enum chipbustype buses_supported; |
| 623 | union { |
| 624 | struct par_programmer par; |
| 625 | struct spi_programmer spi; |
| 626 | struct opaque_programmer opaque; |
| 627 | }; |
| 628 | }; |
| 629 | extern struct registered_programmer registered_programmers[]; |
| 630 | extern int registered_programmer_count; |
| 631 | int register_programmer(struct registered_programmer *pgm); |
Carl-Daniel Hailfinger | 8a3c60c | 2011-12-18 15:01:24 +0000 | [diff] [blame] | 632 | |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 633 | /* serprog.c */ |
Carl-Daniel Hailfinger | c422484 | 2011-06-09 20:06:34 +0000 | [diff] [blame] | 634 | #if CONFIG_SERPROG == 1 |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 635 | int serprog_init(void); |
Stefan Tauner | 31019d4 | 2011-10-22 21:45:27 +0000 | [diff] [blame] | 636 | void serprog_delay(int usecs); |
Carl-Daniel Hailfinger | c422484 | 2011-06-09 20:06:34 +0000 | [diff] [blame] | 637 | #endif |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 638 | |
| 639 | /* serial.c */ |
| 640 | #if _WIN32 |
| 641 | typedef HANDLE fdtype; |
| 642 | #else |
| 643 | typedef int fdtype; |
| 644 | #endif |
| 645 | |
| 646 | void sp_flush_incoming(void); |
| 647 | fdtype sp_openserport(char *dev, unsigned int baud); |
| 648 | void __attribute__((noreturn)) sp_die(char *msg); |
| 649 | extern fdtype sp_fd; |
David Hendricks | 8bb2021 | 2011-06-14 01:35:36 +0000 | [diff] [blame] | 650 | /* expose serialport_shutdown as it's currently used by buspirate */ |
| 651 | int serialport_shutdown(void *data); |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 652 | int serialport_write(unsigned char *buf, unsigned int writecnt); |
| 653 | int serialport_read(unsigned char *buf, unsigned int readcnt); |
| 654 | |
Virgil-Adrian Teaca | da7c545 | 2012-04-30 23:11:06 +0000 | [diff] [blame] | 655 | /* Serial port/pin mapping: |
| 656 | |
| 657 | 1 CD <- |
| 658 | 2 RXD <- |
| 659 | 3 TXD -> |
| 660 | 4 DTR -> |
| 661 | 5 GND -- |
| 662 | 6 DSR <- |
| 663 | 7 RTS -> |
| 664 | 8 CTS <- |
| 665 | 9 RI <- |
| 666 | */ |
| 667 | enum SP_PIN { |
| 668 | PIN_CD = 1, |
| 669 | PIN_RXD, |
| 670 | PIN_TXD, |
| 671 | PIN_DTR, |
| 672 | PIN_GND, |
| 673 | PIN_DSR, |
| 674 | PIN_RTS, |
| 675 | PIN_CTS, |
| 676 | PIN_RI, |
| 677 | }; |
| 678 | |
| 679 | void sp_set_pin(enum SP_PIN pin, int val); |
| 680 | int sp_get_pin(enum SP_PIN pin); |
| 681 | |
Carl-Daniel Hailfinger | 5b997c3 | 2010-07-27 22:41:39 +0000 | [diff] [blame] | 682 | #endif /* !__PROGRAMMER_H__ */ |