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