Adam Kaufman | 064b1f2 | 2007-02-06 19:47:50 +0000 | [diff] [blame] | 1 | /* |
Uwe Hermann | d110764 | 2007-08-29 17:52:32 +0000 | [diff] [blame] | 2 | * This file is part of the flashrom project. |
Adam Kaufman | 064b1f2 | 2007-02-06 19:47:50 +0000 | [diff] [blame] | 3 | * |
Uwe Hermann | d22a1d4 | 2007-09-09 20:21:05 +0000 | [diff] [blame] | 4 | * Copyright (C) 2000 Silicon Integrated System Corporation |
| 5 | * Copyright (C) 2000 Ronald G. Minnich <rminnich@gmail.com> |
Stefan Reinauer | 8fa6481 | 2009-08-12 09:27:45 +0000 | [diff] [blame] | 6 | * Copyright (C) 2005-2009 coresystems GmbH |
Carl-Daniel Hailfinger | a0a6ae9 | 2009-06-15 12:10:57 +0000 | [diff] [blame] | 7 | * Copyright (C) 2006-2009 Carl-Daniel Hailfinger |
Adam Kaufman | 064b1f2 | 2007-02-06 19:47:50 +0000 | [diff] [blame] | 8 | * |
Uwe Hermann | d110764 | 2007-08-29 17:52:32 +0000 | [diff] [blame] | 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. |
Adam Kaufman | 064b1f2 | 2007-02-06 19:47:50 +0000 | [diff] [blame] | 13 | * |
Uwe Hermann | d110764 | 2007-08-29 17:52:32 +0000 | [diff] [blame] | 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. |
Adam Kaufman | 064b1f2 | 2007-02-06 19:47:50 +0000 | [diff] [blame] | 18 | * |
Uwe Hermann | d110764 | 2007-08-29 17:52:32 +0000 | [diff] [blame] | 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 |
Adam Kaufman | 064b1f2 | 2007-02-06 19:47:50 +0000 | [diff] [blame] | 22 | */ |
| 23 | |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 24 | #ifndef __FLASH_H__ |
| 25 | #define __FLASH_H__ 1 |
| 26 | |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 27 | #include <unistd.h> |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 28 | #include <stdint.h> |
Uwe Hermann | 0846f89 | 2007-08-23 13:34:59 +0000 | [diff] [blame] | 29 | #include <stdio.h> |
Carl-Daniel Hailfinger | 5d5c072 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 30 | #include "hwaccess.h" |
Andriy Gapon | 65c1b86 | 2008-05-22 13:22:45 +0000 | [diff] [blame] | 31 | |
Carl-Daniel Hailfinger | 5820f42 | 2009-05-16 21:22:56 +0000 | [diff] [blame] | 32 | typedef unsigned long chipaddr; |
| 33 | |
Carl-Daniel Hailfinger | 415e513 | 2009-08-12 11:39:29 +0000 | [diff] [blame] | 34 | enum programmer { |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 35 | #if INTERNAL_SUPPORT == 1 |
Carl-Daniel Hailfinger | 415e513 | 2009-08-12 11:39:29 +0000 | [diff] [blame] | 36 | PROGRAMMER_INTERNAL, |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 37 | #endif |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 38 | #if DUMMY_SUPPORT == 1 |
Carl-Daniel Hailfinger | 415e513 | 2009-08-12 11:39:29 +0000 | [diff] [blame] | 39 | PROGRAMMER_DUMMY, |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 40 | #endif |
| 41 | #if NIC3COM_SUPPORT == 1 |
Carl-Daniel Hailfinger | 415e513 | 2009-08-12 11:39:29 +0000 | [diff] [blame] | 42 | PROGRAMMER_NIC3COM, |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 43 | #endif |
Uwe Hermann | 2bc98f6 | 2009-09-30 18:29:55 +0000 | [diff] [blame] | 44 | #if GFXNVIDIA_SUPPORT == 1 |
| 45 | PROGRAMMER_GFXNVIDIA, |
| 46 | #endif |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 47 | #if DRKAISER_SUPPORT == 1 |
TURBO J | b0912c0 | 2009-09-02 23:00:46 +0000 | [diff] [blame] | 48 | PROGRAMMER_DRKAISER, |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 49 | #endif |
| 50 | #if SATASII_SUPPORT == 1 |
Carl-Daniel Hailfinger | 415e513 | 2009-08-12 11:39:29 +0000 | [diff] [blame] | 51 | PROGRAMMER_SATASII, |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 52 | #endif |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 53 | #if INTERNAL_SUPPORT == 1 |
Carl-Daniel Hailfinger | 415e513 | 2009-08-12 11:39:29 +0000 | [diff] [blame] | 54 | PROGRAMMER_IT87SPI, |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 55 | #endif |
Carl-Daniel Hailfinger | 3426ef6 | 2009-08-19 13:27:58 +0000 | [diff] [blame] | 56 | #if FT2232_SPI_SUPPORT == 1 |
Carl-Daniel Hailfinger | 415e513 | 2009-08-12 11:39:29 +0000 | [diff] [blame] | 57 | PROGRAMMER_FT2232SPI, |
Carl-Daniel Hailfinger | 3426ef6 | 2009-08-19 13:27:58 +0000 | [diff] [blame] | 58 | #endif |
Carl-Daniel Hailfinger | 6be7411 | 2009-08-12 16:17:41 +0000 | [diff] [blame] | 59 | #if SERPROG_SUPPORT == 1 |
Carl-Daniel Hailfinger | 415e513 | 2009-08-12 11:39:29 +0000 | [diff] [blame] | 60 | PROGRAMMER_SERPROG, |
Carl-Daniel Hailfinger | 6be7411 | 2009-08-12 16:17:41 +0000 | [diff] [blame] | 61 | #endif |
Carl-Daniel Hailfinger | 5cca01f | 2009-11-24 00:20:03 +0000 | [diff] [blame] | 62 | #if BUSPIRATE_SPI_SUPPORT == 1 |
| 63 | PROGRAMMER_BUSPIRATESPI, |
| 64 | #endif |
Carl-Daniel Hailfinger | 37fc469 | 2009-08-12 14:34:35 +0000 | [diff] [blame] | 65 | PROGRAMMER_INVALID /* This must always be the last entry. */ |
Carl-Daniel Hailfinger | 415e513 | 2009-08-12 11:39:29 +0000 | [diff] [blame] | 66 | }; |
| 67 | |
| 68 | extern enum programmer programmer; |
Carl-Daniel Hailfinger | 702218d | 2009-05-08 17:43:22 +0000 | [diff] [blame] | 69 | |
| 70 | struct programmer_entry { |
| 71 | const char *vendor; |
| 72 | const char *name; |
| 73 | |
| 74 | int (*init) (void); |
| 75 | int (*shutdown) (void); |
| 76 | |
Uwe Hermann | d1129ac | 2009-05-28 15:07:42 +0000 | [diff] [blame] | 77 | void * (*map_flash_region) (const char *descr, unsigned long phys_addr, |
| 78 | size_t len); |
Carl-Daniel Hailfinger | 1455b2b | 2009-05-11 14:13:25 +0000 | [diff] [blame] | 79 | void (*unmap_flash_region) (void *virt_addr, size_t len); |
| 80 | |
Carl-Daniel Hailfinger | 5820f42 | 2009-05-16 21:22:56 +0000 | [diff] [blame] | 81 | void (*chip_writeb) (uint8_t val, chipaddr addr); |
| 82 | void (*chip_writew) (uint16_t val, chipaddr addr); |
| 83 | void (*chip_writel) (uint32_t val, chipaddr addr); |
Carl-Daniel Hailfinger | 0bd2a2b | 2009-06-05 18:32:07 +0000 | [diff] [blame] | 84 | void (*chip_writen) (uint8_t *buf, chipaddr addr, size_t len); |
Carl-Daniel Hailfinger | 5820f42 | 2009-05-16 21:22:56 +0000 | [diff] [blame] | 85 | uint8_t (*chip_readb) (const chipaddr addr); |
| 86 | uint16_t (*chip_readw) (const chipaddr addr); |
| 87 | uint32_t (*chip_readl) (const chipaddr addr); |
Carl-Daniel Hailfinger | 0bd2a2b | 2009-06-05 18:32:07 +0000 | [diff] [blame] | 88 | void (*chip_readn) (uint8_t *buf, const chipaddr addr, size_t len); |
Carl-Daniel Hailfinger | ca8bfc6 | 2009-06-05 17:48:08 +0000 | [diff] [blame] | 89 | void (*delay) (int usecs); |
Carl-Daniel Hailfinger | 702218d | 2009-05-08 17:43:22 +0000 | [diff] [blame] | 90 | }; |
| 91 | |
| 92 | extern const struct programmer_entry programmer_table[]; |
| 93 | |
Uwe Hermann | 09e04f7 | 2009-05-16 22:36:00 +0000 | [diff] [blame] | 94 | int programmer_init(void); |
| 95 | int programmer_shutdown(void); |
| 96 | void *programmer_map_flash_region(const char *descr, unsigned long phys_addr, |
| 97 | size_t len); |
| 98 | void programmer_unmap_flash_region(void *virt_addr, size_t len); |
| 99 | void chip_writeb(uint8_t val, chipaddr addr); |
| 100 | void chip_writew(uint16_t val, chipaddr addr); |
| 101 | void chip_writel(uint32_t val, chipaddr addr); |
Carl-Daniel Hailfinger | 0bd2a2b | 2009-06-05 18:32:07 +0000 | [diff] [blame] | 102 | void chip_writen(uint8_t *buf, chipaddr addr, size_t len); |
Uwe Hermann | 09e04f7 | 2009-05-16 22:36:00 +0000 | [diff] [blame] | 103 | uint8_t chip_readb(const chipaddr addr); |
| 104 | uint16_t chip_readw(const chipaddr addr); |
| 105 | uint32_t chip_readl(const chipaddr addr); |
Carl-Daniel Hailfinger | 0bd2a2b | 2009-06-05 18:32:07 +0000 | [diff] [blame] | 106 | void chip_readn(uint8_t *buf, const chipaddr addr, size_t len); |
Carl-Daniel Hailfinger | ca8bfc6 | 2009-06-05 17:48:08 +0000 | [diff] [blame] | 107 | void programmer_delay(int usecs); |
Carl-Daniel Hailfinger | 61a8bd2 | 2009-03-05 19:24:22 +0000 | [diff] [blame] | 108 | |
Carl-Daniel Hailfinger | 3a4781e | 2009-10-01 14:51:25 +0000 | [diff] [blame] | 109 | enum bitbang_spi_master { |
| 110 | BITBANG_SPI_INVALID /* This must always be the last entry. */ |
Carl-Daniel Hailfinger | 547872b | 2009-09-28 13:15:16 +0000 | [diff] [blame] | 111 | }; |
| 112 | |
Carl-Daniel Hailfinger | 3a4781e | 2009-10-01 14:51:25 +0000 | [diff] [blame] | 113 | extern const int bitbang_spi_master_count; |
Carl-Daniel Hailfinger | 547872b | 2009-09-28 13:15:16 +0000 | [diff] [blame] | 114 | |
Carl-Daniel Hailfinger | 3a4781e | 2009-10-01 14:51:25 +0000 | [diff] [blame] | 115 | extern enum bitbang_spi_master bitbang_spi_master; |
Carl-Daniel Hailfinger | 547872b | 2009-09-28 13:15:16 +0000 | [diff] [blame] | 116 | |
Carl-Daniel Hailfinger | 3a4781e | 2009-10-01 14:51:25 +0000 | [diff] [blame] | 117 | struct bitbang_spi_master_entry { |
Carl-Daniel Hailfinger | 547872b | 2009-09-28 13:15:16 +0000 | [diff] [blame] | 118 | void (*set_cs) (int val); |
| 119 | void (*set_sck) (int val); |
| 120 | void (*set_mosi) (int val); |
| 121 | int (*get_miso) (void); |
| 122 | }; |
| 123 | |
Uwe Hermann | e5ac164 | 2008-03-12 11:54:51 +0000 | [diff] [blame] | 124 | #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) |
| 125 | |
Carl-Daniel Hailfinger | 1dfe0ff | 2009-05-31 17:57:34 +0000 | [diff] [blame] | 126 | enum chipbustype { |
Carl-Daniel Hailfinger | 3504b53 | 2009-06-01 00:02:11 +0000 | [diff] [blame] | 127 | CHIP_BUSTYPE_NONE = 0, |
Carl-Daniel Hailfinger | 1dfe0ff | 2009-05-31 17:57:34 +0000 | [diff] [blame] | 128 | CHIP_BUSTYPE_PARALLEL = 1 << 0, |
| 129 | CHIP_BUSTYPE_LPC = 1 << 1, |
| 130 | CHIP_BUSTYPE_FWH = 1 << 2, |
| 131 | CHIP_BUSTYPE_SPI = 1 << 3, |
| 132 | CHIP_BUSTYPE_NONSPI = CHIP_BUSTYPE_PARALLEL | CHIP_BUSTYPE_LPC | CHIP_BUSTYPE_FWH, |
| 133 | CHIP_BUSTYPE_UNKNOWN = CHIP_BUSTYPE_PARALLEL | CHIP_BUSTYPE_LPC | CHIP_BUSTYPE_FWH | CHIP_BUSTYPE_SPI, |
| 134 | }; |
| 135 | |
Carl-Daniel Hailfinger | f38431a | 2009-09-05 02:30:58 +0000 | [diff] [blame] | 136 | /* |
| 137 | * How many different contiguous runs of erase blocks with one size each do |
| 138 | * we have for a given erase function? |
| 139 | */ |
| 140 | #define NUM_ERASEREGIONS 5 |
| 141 | |
| 142 | /* |
| 143 | * How many different erase functions do we have per chip? |
| 144 | */ |
| 145 | #define NUM_ERASEFUNCTIONS 5 |
| 146 | |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 147 | struct flashchip { |
Uwe Hermann | 7615868 | 2008-03-14 23:55:58 +0000 | [diff] [blame] | 148 | const char *vendor; |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 149 | const char *name; |
Carl-Daniel Hailfinger | 1dfe0ff | 2009-05-31 17:57:34 +0000 | [diff] [blame] | 150 | |
| 151 | enum chipbustype bustype; |
| 152 | |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 153 | /* |
| 154 | * With 32bit manufacture_id and model_id we can cover IDs up to |
Carl-Daniel Hailfinger | ae8afa9 | 2007-12-31 01:49:00 +0000 | [diff] [blame] | 155 | * (including) the 4th bank of JEDEC JEP106W Standard Manufacturer's |
| 156 | * Identification code. |
| 157 | */ |
| 158 | uint32_t manufacture_id; |
| 159 | uint32_t model_id; |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 160 | |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 161 | int total_size; |
| 162 | int page_size; |
| 163 | |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 164 | /* |
| 165 | * Indicate if flashrom has been tested with this flash chip and if |
Peter Stuge | 1159d58 | 2008-05-03 04:34:37 +0000 | [diff] [blame] | 166 | * everything worked correctly. |
| 167 | */ |
| 168 | uint32_t tested; |
| 169 | |
Uwe Hermann | 0b7afe6 | 2007-04-01 19:44:21 +0000 | [diff] [blame] | 170 | int (*probe) (struct flashchip *flash); |
Maciej Pijanka | c6e1111 | 2009-06-03 14:46:22 +0000 | [diff] [blame] | 171 | |
| 172 | /* Delay after "enter/exit ID mode" commands in microseconds. */ |
| 173 | int probe_timing; |
Uwe Hermann | 0b7afe6 | 2007-04-01 19:44:21 +0000 | [diff] [blame] | 174 | int (*erase) (struct flashchip *flash); |
Carl-Daniel Hailfinger | f38431a | 2009-09-05 02:30:58 +0000 | [diff] [blame] | 175 | |
| 176 | /* |
| 177 | * Erase blocks and associated erase function. The default entry is a |
| 178 | * chip-sized virtual block together with the chip erase function. |
| 179 | */ |
| 180 | struct block_eraser { |
| 181 | struct eraseblock{ |
| 182 | unsigned int size; /* Eraseblock size */ |
| 183 | unsigned int count; /* Number of contiguous blocks with that size */ |
| 184 | } eraseblocks[NUM_ERASEREGIONS]; |
| 185 | int (*block_erase) (struct flashchip *flash, unsigned int blockaddr, unsigned int blocklen); |
| 186 | } block_erasers[NUM_ERASEFUNCTIONS]; |
| 187 | |
Uwe Hermann | 0b7afe6 | 2007-04-01 19:44:21 +0000 | [diff] [blame] | 188 | int (*write) (struct flashchip *flash, uint8_t *buf); |
Carl-Daniel Hailfinger | cbf563c | 2009-06-16 08:55:44 +0000 | [diff] [blame] | 189 | int (*read) (struct flashchip *flash, uint8_t *buf, int start, int len); |
Ronald G. Minnich | eaab50b | 2003-09-12 22:41:53 +0000 | [diff] [blame] | 190 | |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 191 | /* Some flash devices have an additional register space. */ |
Carl-Daniel Hailfinger | 5820f42 | 2009-05-16 21:22:56 +0000 | [diff] [blame] | 192 | chipaddr virtual_memory; |
| 193 | chipaddr virtual_registers; |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 194 | }; |
| 195 | |
Peter Stuge | 1159d58 | 2008-05-03 04:34:37 +0000 | [diff] [blame] | 196 | #define TEST_UNTESTED 0 |
| 197 | |
Uwe Hermann | d1129ac | 2009-05-28 15:07:42 +0000 | [diff] [blame] | 198 | #define TEST_OK_PROBE (1 << 0) |
| 199 | #define TEST_OK_READ (1 << 1) |
| 200 | #define TEST_OK_ERASE (1 << 2) |
| 201 | #define TEST_OK_WRITE (1 << 3) |
| 202 | #define TEST_OK_PR (TEST_OK_PROBE | TEST_OK_READ) |
| 203 | #define TEST_OK_PRE (TEST_OK_PROBE | TEST_OK_READ | TEST_OK_ERASE) |
Carl-Daniel Hailfinger | a06287c | 2009-09-23 22:01:33 +0000 | [diff] [blame] | 204 | #define TEST_OK_PRW (TEST_OK_PROBE | TEST_OK_READ | TEST_OK_WRITE) |
Uwe Hermann | d1129ac | 2009-05-28 15:07:42 +0000 | [diff] [blame] | 205 | #define TEST_OK_PREW (TEST_OK_PROBE | TEST_OK_READ | TEST_OK_ERASE | TEST_OK_WRITE) |
Peter Stuge | 1159d58 | 2008-05-03 04:34:37 +0000 | [diff] [blame] | 206 | #define TEST_OK_MASK 0x0f |
| 207 | |
Uwe Hermann | d1129ac | 2009-05-28 15:07:42 +0000 | [diff] [blame] | 208 | #define TEST_BAD_PROBE (1 << 4) |
| 209 | #define TEST_BAD_READ (1 << 5) |
| 210 | #define TEST_BAD_ERASE (1 << 6) |
| 211 | #define TEST_BAD_WRITE (1 << 7) |
| 212 | #define TEST_BAD_PREW (TEST_BAD_PROBE | TEST_BAD_READ | TEST_BAD_ERASE | TEST_BAD_WRITE) |
Peter Stuge | 1159d58 | 2008-05-03 04:34:37 +0000 | [diff] [blame] | 213 | #define TEST_BAD_MASK 0xf0 |
| 214 | |
Maciej Pijanka | c6e1111 | 2009-06-03 14:46:22 +0000 | [diff] [blame] | 215 | /* Timing used in probe routines. ZERO is -2 to differentiate between an unset |
| 216 | * field and zero delay. |
| 217 | * |
| 218 | * SPI devices will always have zero delay and ignore this field. |
| 219 | */ |
| 220 | #define TIMING_FIXME -1 |
| 221 | /* this is intentionally same value as fixme */ |
| 222 | #define TIMING_IGNORED -1 |
| 223 | #define TIMING_ZERO -2 |
| 224 | |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 225 | extern struct flashchip flashchips[]; |
| 226 | |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 227 | #if INTERNAL_SUPPORT == 1 |
Uwe Hermann | 05fab75 | 2009-05-16 23:42:17 +0000 | [diff] [blame] | 228 | struct penable { |
| 229 | uint16_t vendor_id; |
| 230 | uint16_t device_id; |
| 231 | int status; |
| 232 | const char *vendor_name; |
| 233 | const char *device_name; |
| 234 | int (*doit) (struct pci_dev *dev, const char *name); |
| 235 | }; |
| 236 | |
| 237 | extern const struct penable chipset_enables[]; |
| 238 | |
| 239 | struct board_pciid_enable { |
| 240 | /* Any device, but make it sensible, like the ISA bridge. */ |
| 241 | uint16_t first_vendor; |
| 242 | uint16_t first_device; |
| 243 | uint16_t first_card_vendor; |
| 244 | uint16_t first_card_device; |
| 245 | |
| 246 | /* Any device, but make it sensible, like |
| 247 | * the host bridge. May be NULL. |
| 248 | */ |
| 249 | uint16_t second_vendor; |
| 250 | uint16_t second_device; |
| 251 | uint16_t second_card_vendor; |
| 252 | uint16_t second_card_device; |
| 253 | |
| 254 | /* The vendor / part name from the coreboot table. */ |
| 255 | const char *lb_vendor; |
| 256 | const char *lb_part; |
| 257 | |
| 258 | const char *vendor_name; |
| 259 | const char *board_name; |
| 260 | |
| 261 | int (*enable) (const char *name); |
| 262 | }; |
| 263 | |
| 264 | extern struct board_pciid_enable board_pciid_enables[]; |
| 265 | |
| 266 | struct board_info { |
| 267 | const char *vendor; |
| 268 | const char *name; |
| 269 | }; |
| 270 | |
| 271 | extern const struct board_info boards_ok[]; |
| 272 | extern const struct board_info boards_bad[]; |
Uwe Hermann | e1aa75e | 2009-06-18 14:04:44 +0000 | [diff] [blame] | 273 | extern const struct board_info laptops_ok[]; |
| 274 | extern const struct board_info laptops_bad[]; |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 275 | #endif |
Uwe Hermann | 05fab75 | 2009-05-16 23:42:17 +0000 | [diff] [blame] | 276 | |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 277 | /* udelay.c */ |
Carl-Daniel Hailfinger | ca8bfc6 | 2009-06-05 17:48:08 +0000 | [diff] [blame] | 278 | void myusec_delay(int usecs); |
Carl-Daniel Hailfinger | 4363439 | 2009-05-01 12:22:17 +0000 | [diff] [blame] | 279 | void myusec_calibrate_delay(void); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 280 | |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 281 | #if NEED_PCI == 1 |
Uwe Hermann | 515ab3d | 2009-05-15 17:02:34 +0000 | [diff] [blame] | 282 | /* pcidev.c */ |
| 283 | #define PCI_OK 0 |
| 284 | #define PCI_NT 1 /* Not tested */ |
Rudolf Marek | 68720c7 | 2009-05-17 19:39:27 +0000 | [diff] [blame] | 285 | |
Uwe Hermann | 515ab3d | 2009-05-15 17:02:34 +0000 | [diff] [blame] | 286 | extern uint32_t io_base_addr; |
| 287 | extern struct pci_access *pacc; |
| 288 | extern struct pci_filter filter; |
Uwe Hermann | 8403ccb | 2009-05-16 21:39:19 +0000 | [diff] [blame] | 289 | extern struct pci_dev *pcidev_dev; |
Uwe Hermann | 515ab3d | 2009-05-15 17:02:34 +0000 | [diff] [blame] | 290 | struct pcidev_status { |
| 291 | uint16_t vendor_id; |
| 292 | uint16_t device_id; |
| 293 | int status; |
| 294 | const char *vendor_name; |
| 295 | const char *device_name; |
| 296 | }; |
TURBO J | b0912c0 | 2009-09-02 23:00:46 +0000 | [diff] [blame] | 297 | uint32_t pcidev_validate(struct pci_dev *dev, uint32_t bar, struct pcidev_status *devs); |
| 298 | uint32_t pcidev_init(uint16_t vendor_id, uint32_t bar, struct pcidev_status *devs, char *pcidev_bdf); |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 299 | #endif |
Uwe Hermann | ba290d1 | 2009-06-17 12:07:12 +0000 | [diff] [blame] | 300 | |
| 301 | /* print.c */ |
| 302 | char *flashbuses_to_text(enum chipbustype bustype); |
Carl-Daniel Hailfinger | f529205 | 2009-11-17 09:57:34 +0000 | [diff] [blame] | 303 | void print_supported(void); |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 304 | #if (NIC3COM_SUPPORT == 1) || (GFXNVIDIA_SUPPORT == 1) || (DRKAISER_SUPPORT == 1) || (SATASII_SUPPORT == 1) |
Uwe Hermann | 515ab3d | 2009-05-15 17:02:34 +0000 | [diff] [blame] | 305 | void print_supported_pcidevs(struct pcidev_status *devs); |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 306 | #endif |
Carl-Daniel Hailfinger | f529205 | 2009-11-17 09:57:34 +0000 | [diff] [blame] | 307 | void print_supported_wiki(void); |
Uwe Hermann | 515ab3d | 2009-05-15 17:02:34 +0000 | [diff] [blame] | 308 | |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 309 | /* board_enable.c */ |
Peter Stuge | 9d9399c | 2009-01-26 02:34:51 +0000 | [diff] [blame] | 310 | void w836xx_ext_enter(uint16_t port); |
| 311 | void w836xx_ext_leave(uint16_t port); |
Carl-Daniel Hailfinger | 24c1a16 | 2009-05-25 23:26:50 +0000 | [diff] [blame] | 312 | uint8_t sio_read(uint16_t port, uint8_t reg); |
| 313 | void sio_write(uint16_t port, uint8_t reg, uint8_t data); |
| 314 | void sio_mask(uint16_t port, uint8_t reg, uint8_t data, uint8_t mask); |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 315 | int board_flash_enable(const char *vendor, const char *part); |
Adam Kaufman | 064b1f2 | 2007-02-06 19:47:50 +0000 | [diff] [blame] | 316 | |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 317 | /* chipset_enable.c */ |
| 318 | int chipset_flash_enable(void); |
Stefan Reinauer | 9a6d176 | 2008-12-03 21:24:40 +0000 | [diff] [blame] | 319 | |
Stefan Reinauer | 0593f21 | 2009-01-26 01:10:48 +0000 | [diff] [blame] | 320 | /* physmap.c */ |
| 321 | void *physmap(const char *descr, unsigned long phys_addr, size_t len); |
| 322 | void physunmap(void *virt_addr, size_t len); |
Stefan Reinauer | 8fa6481 | 2009-08-12 09:27:45 +0000 | [diff] [blame] | 323 | int setup_cpu_msr(int cpu); |
| 324 | void cleanup_cpu_msr(void); |
Carl-Daniel Hailfinger | 5d5c072 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 325 | |
| 326 | /* cbtable.c */ |
| 327 | void lb_vendor_dev_from_string(char *boardstring); |
| 328 | int coreboot_init(void); |
| 329 | extern char *lb_part, *lb_vendor; |
| 330 | extern int partvendor_from_cbtable; |
Stefan Reinauer | 0593f21 | 2009-01-26 01:10:48 +0000 | [diff] [blame] | 331 | |
Carl-Daniel Hailfinger | 702218d | 2009-05-08 17:43:22 +0000 | [diff] [blame] | 332 | /* internal.c */ |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 333 | #if NEED_PCI == 1 |
Uwe Hermann | 2cac686 | 2009-05-16 22:05:42 +0000 | [diff] [blame] | 334 | struct pci_dev *pci_dev_find_filter(struct pci_filter filter); |
Carl-Daniel Hailfinger | 9f46cfc | 2009-11-15 17:13:29 +0000 | [diff] [blame] | 335 | struct pci_dev *pci_dev_find_vendorclass(uint16_t vendor, uint16_t class); |
Uwe Hermann | 2cac686 | 2009-05-16 22:05:42 +0000 | [diff] [blame] | 336 | struct pci_dev *pci_dev_find(uint16_t vendor, uint16_t device); |
| 337 | struct pci_dev *pci_card_find(uint16_t vendor, uint16_t device, |
| 338 | uint16_t card_vendor, uint16_t card_device); |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 339 | #endif |
Carl-Daniel Hailfinger | 3b7e75a | 2009-05-14 21:41:10 +0000 | [diff] [blame] | 340 | void get_io_perms(void); |
Carl-Daniel Hailfinger | db41c59 | 2009-08-09 21:50:24 +0000 | [diff] [blame] | 341 | void release_io_perms(void); |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 342 | #if INTERNAL_SUPPORT == 1 |
Carl-Daniel Hailfinger | 702218d | 2009-05-08 17:43:22 +0000 | [diff] [blame] | 343 | int internal_init(void); |
| 344 | int internal_shutdown(void); |
Carl-Daniel Hailfinger | 5820f42 | 2009-05-16 21:22:56 +0000 | [diff] [blame] | 345 | void internal_chip_writeb(uint8_t val, chipaddr addr); |
| 346 | void internal_chip_writew(uint16_t val, chipaddr addr); |
| 347 | void internal_chip_writel(uint32_t val, chipaddr addr); |
| 348 | uint8_t internal_chip_readb(const chipaddr addr); |
| 349 | uint16_t internal_chip_readw(const chipaddr addr); |
| 350 | uint32_t internal_chip_readl(const chipaddr addr); |
Carl-Daniel Hailfinger | 0bd2a2b | 2009-06-05 18:32:07 +0000 | [diff] [blame] | 351 | void internal_chip_readn(uint8_t *buf, const chipaddr addr, size_t len); |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 352 | #endif |
Carl-Daniel Hailfinger | 78185dc | 2009-05-17 15:49:24 +0000 | [diff] [blame] | 353 | void mmio_writeb(uint8_t val, void *addr); |
| 354 | void mmio_writew(uint16_t val, void *addr); |
| 355 | void mmio_writel(uint32_t val, void *addr); |
| 356 | uint8_t mmio_readb(void *addr); |
| 357 | uint16_t mmio_readw(void *addr); |
| 358 | uint32_t mmio_readl(void *addr); |
Carl-Daniel Hailfinger | ca8bfc6 | 2009-06-05 17:48:08 +0000 | [diff] [blame] | 359 | void internal_delay(int usecs); |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 360 | int noop_shutdown(void); |
Uwe Hermann | c691593 | 2009-05-17 23:12:17 +0000 | [diff] [blame] | 361 | void *fallback_map(const char *descr, unsigned long phys_addr, size_t len); |
| 362 | void fallback_unmap(void *virt_addr, size_t len); |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 363 | uint8_t noop_chip_readb(const chipaddr addr); |
| 364 | void noop_chip_writeb(uint8_t val, chipaddr addr); |
Carl-Daniel Hailfinger | 5820f42 | 2009-05-16 21:22:56 +0000 | [diff] [blame] | 365 | void fallback_chip_writew(uint16_t val, chipaddr addr); |
| 366 | void fallback_chip_writel(uint32_t val, chipaddr addr); |
Carl-Daniel Hailfinger | 0bd2a2b | 2009-06-05 18:32:07 +0000 | [diff] [blame] | 367 | void fallback_chip_writen(uint8_t *buf, chipaddr addr, size_t len); |
Carl-Daniel Hailfinger | 5820f42 | 2009-05-16 21:22:56 +0000 | [diff] [blame] | 368 | uint16_t fallback_chip_readw(const chipaddr addr); |
| 369 | uint32_t fallback_chip_readl(const chipaddr addr); |
Carl-Daniel Hailfinger | 0bd2a2b | 2009-06-05 18:32:07 +0000 | [diff] [blame] | 370 | void fallback_chip_readn(uint8_t *buf, const chipaddr addr, size_t len); |
Carl-Daniel Hailfinger | 702218d | 2009-05-08 17:43:22 +0000 | [diff] [blame] | 371 | |
Carl-Daniel Hailfinger | c312920 | 2009-05-09 00:54:55 +0000 | [diff] [blame] | 372 | /* dummyflasher.c */ |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 373 | #if DUMMY_SUPPORT == 1 |
Carl-Daniel Hailfinger | c312920 | 2009-05-09 00:54:55 +0000 | [diff] [blame] | 374 | int dummy_init(void); |
| 375 | int dummy_shutdown(void); |
Carl-Daniel Hailfinger | 1455b2b | 2009-05-11 14:13:25 +0000 | [diff] [blame] | 376 | void *dummy_map(const char *descr, unsigned long phys_addr, size_t len); |
| 377 | void dummy_unmap(void *virt_addr, size_t len); |
Carl-Daniel Hailfinger | 5820f42 | 2009-05-16 21:22:56 +0000 | [diff] [blame] | 378 | void dummy_chip_writeb(uint8_t val, chipaddr addr); |
| 379 | void dummy_chip_writew(uint16_t val, chipaddr addr); |
| 380 | void dummy_chip_writel(uint32_t val, chipaddr addr); |
Carl-Daniel Hailfinger | 0bd2a2b | 2009-06-05 18:32:07 +0000 | [diff] [blame] | 381 | void dummy_chip_writen(uint8_t *buf, chipaddr addr, size_t len); |
Carl-Daniel Hailfinger | 5820f42 | 2009-05-16 21:22:56 +0000 | [diff] [blame] | 382 | uint8_t dummy_chip_readb(const chipaddr addr); |
| 383 | uint16_t dummy_chip_readw(const chipaddr addr); |
| 384 | uint32_t dummy_chip_readl(const chipaddr addr); |
Carl-Daniel Hailfinger | 0bd2a2b | 2009-06-05 18:32:07 +0000 | [diff] [blame] | 385 | void dummy_chip_readn(uint8_t *buf, const chipaddr addr, size_t len); |
Carl-Daniel Hailfinger | d047829 | 2009-07-10 21:08:55 +0000 | [diff] [blame] | 386 | int dummy_spi_send_command(unsigned int writecnt, unsigned int readcnt, |
Carl-Daniel Hailfinger | bfe2e0c | 2009-05-14 12:59:36 +0000 | [diff] [blame] | 387 | const unsigned char *writearr, unsigned char *readarr); |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 388 | #endif |
Carl-Daniel Hailfinger | c312920 | 2009-05-09 00:54:55 +0000 | [diff] [blame] | 389 | |
Uwe Hermann | b4dcb71 | 2009-05-13 11:36:06 +0000 | [diff] [blame] | 390 | /* nic3com.c */ |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 391 | #if NIC3COM_SUPPORT == 1 |
Uwe Hermann | b4dcb71 | 2009-05-13 11:36:06 +0000 | [diff] [blame] | 392 | int nic3com_init(void); |
| 393 | int nic3com_shutdown(void); |
Carl-Daniel Hailfinger | 5820f42 | 2009-05-16 21:22:56 +0000 | [diff] [blame] | 394 | void nic3com_chip_writeb(uint8_t val, chipaddr addr); |
| 395 | uint8_t nic3com_chip_readb(const chipaddr addr); |
Uwe Hermann | 515ab3d | 2009-05-15 17:02:34 +0000 | [diff] [blame] | 396 | extern struct pcidev_status nics_3com[]; |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 397 | #endif |
Uwe Hermann | b4dcb71 | 2009-05-13 11:36:06 +0000 | [diff] [blame] | 398 | |
Uwe Hermann | 2bc98f6 | 2009-09-30 18:29:55 +0000 | [diff] [blame] | 399 | /* gfxnvidia.c */ |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 400 | #if GFXNVIDIA_SUPPORT == 1 |
Uwe Hermann | 2bc98f6 | 2009-09-30 18:29:55 +0000 | [diff] [blame] | 401 | int gfxnvidia_init(void); |
| 402 | int gfxnvidia_shutdown(void); |
| 403 | void gfxnvidia_chip_writeb(uint8_t val, chipaddr addr); |
| 404 | uint8_t gfxnvidia_chip_readb(const chipaddr addr); |
| 405 | extern struct pcidev_status gfx_nvidia[]; |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 406 | #endif |
Uwe Hermann | 2bc98f6 | 2009-09-30 18:29:55 +0000 | [diff] [blame] | 407 | |
TURBO J | b0912c0 | 2009-09-02 23:00:46 +0000 | [diff] [blame] | 408 | /* drkaiser.c */ |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 409 | #if DRKAISER_SUPPORT == 1 |
TURBO J | b0912c0 | 2009-09-02 23:00:46 +0000 | [diff] [blame] | 410 | int drkaiser_init(void); |
| 411 | int drkaiser_shutdown(void); |
| 412 | void drkaiser_chip_writeb(uint8_t val, chipaddr addr); |
| 413 | uint8_t drkaiser_chip_readb(const chipaddr addr); |
| 414 | extern struct pcidev_status drkaiser_pcidev[]; |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 415 | #endif |
TURBO J | b0912c0 | 2009-09-02 23:00:46 +0000 | [diff] [blame] | 416 | |
Rudolf Marek | 68720c7 | 2009-05-17 19:39:27 +0000 | [diff] [blame] | 417 | /* satasii.c */ |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 418 | #if SATASII_SUPPORT == 1 |
Rudolf Marek | 68720c7 | 2009-05-17 19:39:27 +0000 | [diff] [blame] | 419 | int satasii_init(void); |
| 420 | int satasii_shutdown(void); |
Rudolf Marek | 68720c7 | 2009-05-17 19:39:27 +0000 | [diff] [blame] | 421 | void satasii_chip_writeb(uint8_t val, chipaddr addr); |
| 422 | uint8_t satasii_chip_readb(const chipaddr addr); |
| 423 | extern struct pcidev_status satas_sii[]; |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 424 | #endif |
Rudolf Marek | 68720c7 | 2009-05-17 19:39:27 +0000 | [diff] [blame] | 425 | |
Paul Fox | 05dfbe6 | 2009-06-16 21:08:06 +0000 | [diff] [blame] | 426 | /* ft2232_spi.c */ |
Carl-Daniel Hailfinger | feea272 | 2009-07-01 00:02:23 +0000 | [diff] [blame] | 427 | #define FTDI_FT2232H 0x6010 |
| 428 | #define FTDI_FT4232H 0x6011 |
Paul Fox | 05dfbe6 | 2009-06-16 21:08:06 +0000 | [diff] [blame] | 429 | int ft2232_spi_init(void); |
Carl-Daniel Hailfinger | d047829 | 2009-07-10 21:08:55 +0000 | [diff] [blame] | 430 | int ft2232_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr); |
Paul Fox | 05dfbe6 | 2009-06-16 21:08:06 +0000 | [diff] [blame] | 431 | int ft2232_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len); |
Paul Fox | 05dfbe6 | 2009-06-16 21:08:06 +0000 | [diff] [blame] | 432 | int ft2232_spi_write_256(struct flashchip *flash, uint8_t *buf); |
| 433 | |
Carl-Daniel Hailfinger | 547872b | 2009-09-28 13:15:16 +0000 | [diff] [blame] | 434 | /* bitbang_spi.c */ |
Carl-Daniel Hailfinger | 3a4781e | 2009-10-01 14:51:25 +0000 | [diff] [blame] | 435 | extern int bitbang_spi_half_period; |
| 436 | extern const struct bitbang_spi_master_entry bitbang_spi_master_table[]; |
Carl-Daniel Hailfinger | 547872b | 2009-09-28 13:15:16 +0000 | [diff] [blame] | 437 | int bitbang_spi_init(void); |
| 438 | int bitbang_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr); |
| 439 | int bitbang_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len); |
| 440 | int bitbang_spi_write_256(struct flashchip *flash, uint8_t *buf); |
| 441 | |
Carl-Daniel Hailfinger | 5cca01f | 2009-11-24 00:20:03 +0000 | [diff] [blame] | 442 | /* buspirate_spi.c */ |
Carl-Daniel Hailfinger | d5b28fa | 2009-11-24 18:27:10 +0000 | [diff] [blame] | 443 | struct buspirate_spispeeds { |
| 444 | const char *name; |
| 445 | const int speed; |
| 446 | }; |
Carl-Daniel Hailfinger | 5cca01f | 2009-11-24 00:20:03 +0000 | [diff] [blame] | 447 | int buspirate_spi_init(void); |
| 448 | int buspirate_spi_shutdown(void); |
| 449 | int buspirate_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr); |
| 450 | int buspirate_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len); |
| 451 | |
Uwe Hermann | 0846f89 | 2007-08-23 13:34:59 +0000 | [diff] [blame] | 452 | /* flashrom.c */ |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 453 | extern enum chipbustype buses_supported; |
| 454 | struct decode_sizes { |
| 455 | uint32_t parallel; |
| 456 | uint32_t lpc; |
| 457 | uint32_t fwh; |
| 458 | uint32_t spi; |
| 459 | }; |
| 460 | extern struct decode_sizes max_rom_decode; |
Carl-Daniel Hailfinger | ef58a9c | 2009-08-12 13:32:56 +0000 | [diff] [blame] | 461 | extern char *programmer_param; |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 462 | extern unsigned long flashbase; |
Uwe Hermann | ad216bf | 2009-04-24 16:17:41 +0000 | [diff] [blame] | 463 | extern int verbose; |
Carl-Daniel Hailfinger | a80cfbc | 2009-07-22 20:13:00 +0000 | [diff] [blame] | 464 | extern const char *flashrom_version; |
Uwe Hermann | ad216bf | 2009-04-24 16:17:41 +0000 | [diff] [blame] | 465 | #define printf_debug(x...) { if (verbose) printf(x); } |
Peter Stuge | 776d202 | 2009-01-26 00:39:57 +0000 | [diff] [blame] | 466 | void map_flash_registers(struct flashchip *flash); |
Carl-Daniel Hailfinger | cbf563c | 2009-06-16 08:55:44 +0000 | [diff] [blame] | 467 | int read_memmapped(struct flashchip *flash, uint8_t *buf, int start, int len); |
Carl-Daniel Hailfinger | f38431a | 2009-09-05 02:30:58 +0000 | [diff] [blame] | 468 | int erase_flash(struct flashchip *flash); |
Carl-Daniel Hailfinger | 38a059d | 2009-06-13 12:04:03 +0000 | [diff] [blame] | 469 | int min(int a, int b); |
Carl-Daniel Hailfinger | 30f7cb2 | 2009-06-15 17:23:36 +0000 | [diff] [blame] | 470 | int max(int a, int b); |
Carl-Daniel Hailfinger | d5b28fa | 2009-11-24 18:27:10 +0000 | [diff] [blame] | 471 | char *extract_param(char **haystack, char *needle, char *delim); |
Carl-Daniel Hailfinger | 30f7cb2 | 2009-06-15 17:23:36 +0000 | [diff] [blame] | 472 | int check_erased_range(struct flashchip *flash, int start, int len); |
| 473 | int verify_range(struct flashchip *flash, uint8_t *cmpbuf, int start, int len, char *message); |
Uwe Hermann | ba290d1 | 2009-06-17 12:07:12 +0000 | [diff] [blame] | 474 | char *strcat_realloc(char *dest, const char *src); |
| 475 | |
| 476 | #define OK 0 |
| 477 | #define NT 1 /* Not tested */ |
Uwe Hermann | 0846f89 | 2007-08-23 13:34:59 +0000 | [diff] [blame] | 478 | |
| 479 | /* layout.c */ |
Peter Stuge | 7ffbc6f | 2008-06-18 02:08:40 +0000 | [diff] [blame] | 480 | int show_id(uint8_t *bios, int size, int force); |
Uwe Hermann | 0846f89 | 2007-08-23 13:34:59 +0000 | [diff] [blame] | 481 | int read_romlayout(char *name); |
| 482 | int find_romentry(char *name); |
Carl-Daniel Hailfinger | f5fb51c | 2009-08-19 15:19:18 +0000 | [diff] [blame] | 483 | int handle_romentries(uint8_t *buffer, struct flashchip *flash); |
Uwe Hermann | 0846f89 | 2007-08-23 13:34:59 +0000 | [diff] [blame] | 484 | |
Carl-Daniel Hailfinger | 00f911e | 2007-10-15 21:44:47 +0000 | [diff] [blame] | 485 | /* spi.c */ |
Carl-Daniel Hailfinger | 1dfe0ff | 2009-05-31 17:57:34 +0000 | [diff] [blame] | 486 | enum spi_controller { |
| 487 | SPI_CONTROLLER_NONE, |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 488 | #if INTERNAL_SUPPORT == 1 |
Carl-Daniel Hailfinger | 1dfe0ff | 2009-05-31 17:57:34 +0000 | [diff] [blame] | 489 | SPI_CONTROLLER_ICH7, |
| 490 | SPI_CONTROLLER_ICH9, |
| 491 | SPI_CONTROLLER_IT87XX, |
| 492 | SPI_CONTROLLER_SB600, |
| 493 | SPI_CONTROLLER_VIA, |
| 494 | SPI_CONTROLLER_WBSIO, |
Carl-Daniel Hailfinger | 66ef4e5 | 2009-12-13 22:28:00 +0000 | [diff] [blame] | 495 | #endif |
Carl-Daniel Hailfinger | 3426ef6 | 2009-08-19 13:27:58 +0000 | [diff] [blame] | 496 | #if FT2232_SPI_SUPPORT == 1 |
Paul Fox | 05dfbe6 | 2009-06-16 21:08:06 +0000 | [diff] [blame] | 497 | SPI_CONTROLLER_FT2232, |
Carl-Daniel Hailfinger | 3426ef6 | 2009-08-19 13:27:58 +0000 | [diff] [blame] | 498 | #endif |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 499 | #if DUMMY_SUPPORT == 1 |
Carl-Daniel Hailfinger | 1dfe0ff | 2009-05-31 17:57:34 +0000 | [diff] [blame] | 500 | SPI_CONTROLLER_DUMMY, |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 501 | #endif |
Carl-Daniel Hailfinger | 5cca01f | 2009-11-24 00:20:03 +0000 | [diff] [blame] | 502 | #if BUSPIRATE_SPI_SUPPORT == 1 |
| 503 | SPI_CONTROLLER_BUSPIRATE, |
| 504 | #endif |
Carl-Daniel Hailfinger | 3426ef6 | 2009-08-19 13:27:58 +0000 | [diff] [blame] | 505 | SPI_CONTROLLER_INVALID /* This must always be the last entry. */ |
Carl-Daniel Hailfinger | 1dfe0ff | 2009-05-31 17:57:34 +0000 | [diff] [blame] | 506 | }; |
Carl-Daniel Hailfinger | 3426ef6 | 2009-08-19 13:27:58 +0000 | [diff] [blame] | 507 | extern const int spi_programmer_count; |
Carl-Daniel Hailfinger | d047829 | 2009-07-10 21:08:55 +0000 | [diff] [blame] | 508 | struct spi_command { |
| 509 | unsigned int writecnt; |
| 510 | unsigned int readcnt; |
| 511 | const unsigned char *writearr; |
| 512 | unsigned char *readarr; |
| 513 | }; |
Carl-Daniel Hailfinger | 02487aa | 2009-07-22 15:36:50 +0000 | [diff] [blame] | 514 | struct spi_programmer { |
| 515 | int (*command)(unsigned int writecnt, unsigned int readcnt, |
| 516 | const unsigned char *writearr, unsigned char *readarr); |
Carl-Daniel Hailfinger | 26f7e64 | 2009-09-18 15:50:56 +0000 | [diff] [blame] | 517 | int (*multicommand)(struct spi_command *cmds); |
Carl-Daniel Hailfinger | 02487aa | 2009-07-22 15:36:50 +0000 | [diff] [blame] | 518 | |
| 519 | /* Optimized functions for this programmer */ |
| 520 | int (*read)(struct flashchip *flash, uint8_t *buf, int start, int len); |
| 521 | int (*write_256)(struct flashchip *flash, uint8_t *buf); |
| 522 | }; |
Carl-Daniel Hailfinger | d047829 | 2009-07-10 21:08:55 +0000 | [diff] [blame] | 523 | |
Carl-Daniel Hailfinger | 1dfe0ff | 2009-05-31 17:57:34 +0000 | [diff] [blame] | 524 | extern enum spi_controller spi_controller; |
Carl-Daniel Hailfinger | 02487aa | 2009-07-22 15:36:50 +0000 | [diff] [blame] | 525 | extern const struct spi_programmer spi_programmer[]; |
Carl-Daniel Hailfinger | 1dfe0ff | 2009-05-31 17:57:34 +0000 | [diff] [blame] | 526 | extern void *spibar; |
Carl-Daniel Hailfinger | d047829 | 2009-07-10 21:08:55 +0000 | [diff] [blame] | 527 | int spi_send_command(unsigned int writecnt, unsigned int readcnt, |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 528 | const unsigned char *writearr, unsigned char *readarr); |
Carl-Daniel Hailfinger | 26f7e64 | 2009-09-18 15:50:56 +0000 | [diff] [blame] | 529 | int spi_send_multicommand(struct spi_command *cmds); |
Carl-Daniel Hailfinger | 02487aa | 2009-07-22 15:36:50 +0000 | [diff] [blame] | 530 | int default_spi_send_command(unsigned int writecnt, unsigned int readcnt, |
| 531 | const unsigned char *writearr, unsigned char *readarr); |
Carl-Daniel Hailfinger | 26f7e64 | 2009-09-18 15:50:56 +0000 | [diff] [blame] | 532 | int default_spi_send_multicommand(struct spi_command *cmds); |
Carl-Daniel Hailfinger | 5d5c072 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 533 | uint32_t spi_get_valid_read_addr(void); |
Mats Erik Andersson | 44e1a19 | 2008-09-26 13:19:02 +0000 | [diff] [blame] | 534 | |
Dominik Geyer | b46acba | 2008-05-16 12:55:55 +0000 | [diff] [blame] | 535 | /* ichspi.c */ |
Carl-Daniel Hailfinger | 4363439 | 2009-05-01 12:22:17 +0000 | [diff] [blame] | 536 | int ich_init_opcodes(void); |
Carl-Daniel Hailfinger | d047829 | 2009-07-10 21:08:55 +0000 | [diff] [blame] | 537 | int ich_spi_send_command(unsigned int writecnt, unsigned int readcnt, |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 538 | const unsigned char *writearr, unsigned char *readarr); |
Carl-Daniel Hailfinger | cbf563c | 2009-06-16 08:55:44 +0000 | [diff] [blame] | 539 | int ich_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len); |
Carl-Daniel Hailfinger | 96930c3 | 2009-05-09 02:30:21 +0000 | [diff] [blame] | 540 | int ich_spi_write_256(struct flashchip *flash, uint8_t * buf); |
Carl-Daniel Hailfinger | 26f7e64 | 2009-09-18 15:50:56 +0000 | [diff] [blame] | 541 | int ich_spi_send_multicommand(struct spi_command *cmds); |
Dominik Geyer | b46acba | 2008-05-16 12:55:55 +0000 | [diff] [blame] | 542 | |
Carl-Daniel Hailfinger | bfe5b4a | 2008-05-13 23:03:12 +0000 | [diff] [blame] | 543 | /* it87spi.c */ |
| 544 | extern uint16_t it8716f_flashport; |
Carl-Daniel Hailfinger | 24c1a16 | 2009-05-25 23:26:50 +0000 | [diff] [blame] | 545 | void enter_conf_mode_ite(uint16_t port); |
| 546 | void exit_conf_mode_ite(uint16_t port); |
Carl-Daniel Hailfinger | b8afecd | 2009-05-31 18:00:57 +0000 | [diff] [blame] | 547 | int it87spi_init(void); |
Dominik Geyer | b46acba | 2008-05-16 12:55:55 +0000 | [diff] [blame] | 548 | int it87xx_probe_spi_flash(const char *name); |
Carl-Daniel Hailfinger | d047829 | 2009-07-10 21:08:55 +0000 | [diff] [blame] | 549 | int it8716f_spi_send_command(unsigned int writecnt, unsigned int readcnt, |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 550 | const unsigned char *writearr, unsigned char *readarr); |
Carl-Daniel Hailfinger | cbf563c | 2009-06-16 08:55:44 +0000 | [diff] [blame] | 551 | int it8716f_spi_chip_read(struct flashchip *flash, uint8_t *buf, int start, int len); |
Carl-Daniel Hailfinger | 96930c3 | 2009-05-09 02:30:21 +0000 | [diff] [blame] | 552 | int it8716f_spi_chip_write_256(struct flashchip *flash, uint8_t *buf); |
Carl-Daniel Hailfinger | bfe5b4a | 2008-05-13 23:03:12 +0000 | [diff] [blame] | 553 | |
Jason Wang | a3f04be | 2008-11-28 21:36:51 +0000 | [diff] [blame] | 554 | /* sb600spi.c */ |
Carl-Daniel Hailfinger | d047829 | 2009-07-10 21:08:55 +0000 | [diff] [blame] | 555 | int sb600_spi_send_command(unsigned int writecnt, unsigned int readcnt, |
Jason Wang | a3f04be | 2008-11-28 21:36:51 +0000 | [diff] [blame] | 556 | const unsigned char *writearr, unsigned char *readarr); |
Carl-Daniel Hailfinger | cbf563c | 2009-06-16 08:55:44 +0000 | [diff] [blame] | 557 | int sb600_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len); |
Carl-Daniel Hailfinger | 96930c3 | 2009-05-09 02:30:21 +0000 | [diff] [blame] | 558 | int sb600_spi_write_1(struct flashchip *flash, uint8_t *buf); |
Carl-Daniel Hailfinger | 78185dc | 2009-05-17 15:49:24 +0000 | [diff] [blame] | 559 | extern uint8_t *sb600_spibar; |
Jason Wang | a3f04be | 2008-11-28 21:36:51 +0000 | [diff] [blame] | 560 | |
Peter Stuge | bf196e9 | 2009-01-26 03:08:45 +0000 | [diff] [blame] | 561 | /* wbsio_spi.c */ |
| 562 | int wbsio_check_for_spi(const char *name); |
Carl-Daniel Hailfinger | d047829 | 2009-07-10 21:08:55 +0000 | [diff] [blame] | 563 | int wbsio_spi_send_command(unsigned int writecnt, unsigned int readcnt, |
Uwe Hermann | d1129ac | 2009-05-28 15:07:42 +0000 | [diff] [blame] | 564 | const unsigned char *writearr, unsigned char *readarr); |
Carl-Daniel Hailfinger | cbf563c | 2009-06-16 08:55:44 +0000 | [diff] [blame] | 565 | int wbsio_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len); |
Carl-Daniel Hailfinger | 96930c3 | 2009-05-09 02:30:21 +0000 | [diff] [blame] | 566 | int wbsio_spi_write_1(struct flashchip *flash, uint8_t *buf); |
Peter Stuge | bf196e9 | 2009-01-26 03:08:45 +0000 | [diff] [blame] | 567 | |
Urja Rannikko | 2291535 | 2009-06-23 11:33:43 +0000 | [diff] [blame] | 568 | /* serprog.c */ |
Urja Rannikko | 2291535 | 2009-06-23 11:33:43 +0000 | [diff] [blame] | 569 | int serprog_init(void); |
| 570 | int serprog_shutdown(void); |
| 571 | void serprog_chip_writeb(uint8_t val, chipaddr addr); |
| 572 | uint8_t serprog_chip_readb(const chipaddr addr); |
| 573 | void serprog_chip_readn(uint8_t *buf, const chipaddr addr, size_t len); |
| 574 | void serprog_delay(int delay); |
Carl-Daniel Hailfinger | e51ea10 | 2009-11-23 19:20:11 +0000 | [diff] [blame] | 575 | |
| 576 | /* serial.c */ |
Carl-Daniel Hailfinger | a4a9bfb | 2009-11-21 11:02:48 +0000 | [diff] [blame] | 577 | void sp_flush_incoming(void); |
| 578 | int sp_openserport(char *dev, unsigned int baud); |
Carl-Daniel Hailfinger | e51ea10 | 2009-11-23 19:20:11 +0000 | [diff] [blame] | 579 | void __attribute__((noreturn)) sp_die(char *msg); |
Carl-Daniel Hailfinger | a4a9bfb | 2009-11-21 11:02:48 +0000 | [diff] [blame] | 580 | extern int sp_fd; |
Uwe Hermann | 1432a60 | 2009-06-28 23:26:37 +0000 | [diff] [blame] | 581 | |
Carl-Daniel Hailfinger | 5d5c072 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 582 | #include "chipdrivers.h" |
| 583 | |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 584 | #endif /* !__FLASH_H__ */ |