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