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 | |
Adam Kaufman | 064b1f2 | 2007-02-06 19:47:50 +0000 | [diff] [blame] | 27 | #if defined(__GLIBC__) |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 28 | #include <sys/io.h> |
Adam Kaufman | 064b1f2 | 2007-02-06 19:47:50 +0000 | [diff] [blame] | 29 | #endif |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 30 | #include <unistd.h> |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 31 | #include <stdint.h> |
Uwe Hermann | 0846f89 | 2007-08-23 13:34:59 +0000 | [diff] [blame] | 32 | #include <stdio.h> |
Christian Ruppert | 0cdb031 | 2009-05-14 18:57:26 +0000 | [diff] [blame] | 33 | #include <pci/pci.h> |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 34 | |
Carl-Daniel Hailfinger | 9abf529 | 2009-05-01 16:34:32 +0000 | [diff] [blame] | 35 | /* for iopl and outb under Solaris */ |
| 36 | #if defined (__sun) && (defined(__i386) || defined(__amd64)) |
| 37 | #include <strings.h> |
| 38 | #include <sys/sysi86.h> |
| 39 | #include <sys/psw.h> |
| 40 | #include <asm/sunddi.h> |
| 41 | #endif |
| 42 | |
Stefan Reinauer | f79edb9 | 2009-01-26 01:23:31 +0000 | [diff] [blame] | 43 | #if (defined(__MACH__) && defined(__APPLE__)) |
| 44 | #define __DARWIN__ |
| 45 | #endif |
| 46 | |
Patrick Georgi | 60622e2 | 2009-04-28 12:56:04 +0000 | [diff] [blame] | 47 | #if defined(__FreeBSD__) || defined(__DragonFly__) |
Andriy Gapon | 65c1b86 | 2008-05-22 13:22:45 +0000 | [diff] [blame] | 48 | #include <machine/cpufunc.h> |
| 49 | #define off64_t off_t |
| 50 | #define lseek64 lseek |
| 51 | #define OUTB(x, y) do { u_int tmp = (y); outb(tmp, (x)); } while (0) |
| 52 | #define OUTW(x, y) do { u_int tmp = (y); outw(tmp, (x)); } while (0) |
| 53 | #define OUTL(x, y) do { u_int tmp = (y); outl(tmp, (x)); } while (0) |
| 54 | #define INB(x) __extension__ ({ u_int tmp = (x); inb(tmp); }) |
| 55 | #define INW(x) __extension__ ({ u_int tmp = (x); inw(tmp); }) |
| 56 | #define INL(x) __extension__ ({ u_int tmp = (x); inl(tmp); }) |
| 57 | #else |
Stefan Reinauer | f79edb9 | 2009-01-26 01:23:31 +0000 | [diff] [blame] | 58 | #if defined(__DARWIN__) |
| 59 | #include <DirectIO/darwinio.h> |
| 60 | #define off64_t off_t |
| 61 | #define lseek64 lseek |
| 62 | #endif |
Carl-Daniel Hailfinger | 9abf529 | 2009-05-01 16:34:32 +0000 | [diff] [blame] | 63 | #if defined (__sun) && (defined(__i386) || defined(__amd64)) |
| 64 | /* Note different order for outb */ |
| 65 | #define OUTB(x,y) outb(y, x) |
| 66 | #define OUTW(x,y) outw(y, x) |
| 67 | #define OUTL(x,y) outl(y, x) |
| 68 | #define INB inb |
| 69 | #define INW inw |
| 70 | #define INL inl |
| 71 | #else |
Andriy Gapon | 65c1b86 | 2008-05-22 13:22:45 +0000 | [diff] [blame] | 72 | #define OUTB outb |
| 73 | #define OUTW outw |
| 74 | #define OUTL outl |
| 75 | #define INB inb |
| 76 | #define INW inw |
| 77 | #define INL inl |
| 78 | #endif |
Carl-Daniel Hailfinger | 9abf529 | 2009-05-01 16:34:32 +0000 | [diff] [blame] | 79 | #endif |
Andriy Gapon | 65c1b86 | 2008-05-22 13:22:45 +0000 | [diff] [blame] | 80 | |
Carl-Daniel Hailfinger | 5820f42 | 2009-05-16 21:22:56 +0000 | [diff] [blame] | 81 | typedef unsigned long chipaddr; |
| 82 | |
Carl-Daniel Hailfinger | 415e513 | 2009-08-12 11:39:29 +0000 | [diff] [blame] | 83 | enum programmer { |
| 84 | PROGRAMMER_INTERNAL, |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 85 | #if DUMMY_SUPPORT == 1 |
Carl-Daniel Hailfinger | 415e513 | 2009-08-12 11:39:29 +0000 | [diff] [blame] | 86 | PROGRAMMER_DUMMY, |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 87 | #endif |
| 88 | #if NIC3COM_SUPPORT == 1 |
Carl-Daniel Hailfinger | 415e513 | 2009-08-12 11:39:29 +0000 | [diff] [blame] | 89 | PROGRAMMER_NIC3COM, |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 90 | #endif |
Uwe Hermann | 2bc98f6 | 2009-09-30 18:29:55 +0000 | [diff] [blame] | 91 | #if GFXNVIDIA_SUPPORT == 1 |
| 92 | PROGRAMMER_GFXNVIDIA, |
| 93 | #endif |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 94 | #if DRKAISER_SUPPORT == 1 |
TURBO J | b0912c0 | 2009-09-02 23:00:46 +0000 | [diff] [blame] | 95 | PROGRAMMER_DRKAISER, |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 96 | #endif |
| 97 | #if SATASII_SUPPORT == 1 |
Carl-Daniel Hailfinger | 415e513 | 2009-08-12 11:39:29 +0000 | [diff] [blame] | 98 | PROGRAMMER_SATASII, |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 99 | #endif |
Carl-Daniel Hailfinger | 415e513 | 2009-08-12 11:39:29 +0000 | [diff] [blame] | 100 | PROGRAMMER_IT87SPI, |
Carl-Daniel Hailfinger | 3426ef6 | 2009-08-19 13:27:58 +0000 | [diff] [blame] | 101 | #if FT2232_SPI_SUPPORT == 1 |
Carl-Daniel Hailfinger | 415e513 | 2009-08-12 11:39:29 +0000 | [diff] [blame] | 102 | PROGRAMMER_FT2232SPI, |
Carl-Daniel Hailfinger | 3426ef6 | 2009-08-19 13:27:58 +0000 | [diff] [blame] | 103 | #endif |
Carl-Daniel Hailfinger | 6be7411 | 2009-08-12 16:17:41 +0000 | [diff] [blame] | 104 | #if SERPROG_SUPPORT == 1 |
Carl-Daniel Hailfinger | 415e513 | 2009-08-12 11:39:29 +0000 | [diff] [blame] | 105 | PROGRAMMER_SERPROG, |
Carl-Daniel Hailfinger | 6be7411 | 2009-08-12 16:17:41 +0000 | [diff] [blame] | 106 | #endif |
Carl-Daniel Hailfinger | 37fc469 | 2009-08-12 14:34:35 +0000 | [diff] [blame] | 107 | PROGRAMMER_INVALID /* This must always be the last entry. */ |
Carl-Daniel Hailfinger | 415e513 | 2009-08-12 11:39:29 +0000 | [diff] [blame] | 108 | }; |
| 109 | |
| 110 | extern enum programmer programmer; |
Carl-Daniel Hailfinger | 702218d | 2009-05-08 17:43:22 +0000 | [diff] [blame] | 111 | |
| 112 | struct programmer_entry { |
| 113 | const char *vendor; |
| 114 | const char *name; |
| 115 | |
| 116 | int (*init) (void); |
| 117 | int (*shutdown) (void); |
| 118 | |
Uwe Hermann | d1129ac | 2009-05-28 15:07:42 +0000 | [diff] [blame] | 119 | void * (*map_flash_region) (const char *descr, unsigned long phys_addr, |
| 120 | size_t len); |
Carl-Daniel Hailfinger | 1455b2b | 2009-05-11 14:13:25 +0000 | [diff] [blame] | 121 | void (*unmap_flash_region) (void *virt_addr, size_t len); |
| 122 | |
Carl-Daniel Hailfinger | 5820f42 | 2009-05-16 21:22:56 +0000 | [diff] [blame] | 123 | void (*chip_writeb) (uint8_t val, chipaddr addr); |
| 124 | void (*chip_writew) (uint16_t val, chipaddr addr); |
| 125 | void (*chip_writel) (uint32_t val, chipaddr addr); |
Carl-Daniel Hailfinger | 0bd2a2b | 2009-06-05 18:32:07 +0000 | [diff] [blame] | 126 | void (*chip_writen) (uint8_t *buf, chipaddr addr, size_t len); |
Carl-Daniel Hailfinger | 5820f42 | 2009-05-16 21:22:56 +0000 | [diff] [blame] | 127 | uint8_t (*chip_readb) (const chipaddr addr); |
| 128 | uint16_t (*chip_readw) (const chipaddr addr); |
| 129 | uint32_t (*chip_readl) (const chipaddr addr); |
Carl-Daniel Hailfinger | 0bd2a2b | 2009-06-05 18:32:07 +0000 | [diff] [blame] | 130 | 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] | 131 | void (*delay) (int usecs); |
Carl-Daniel Hailfinger | 702218d | 2009-05-08 17:43:22 +0000 | [diff] [blame] | 132 | }; |
| 133 | |
| 134 | extern const struct programmer_entry programmer_table[]; |
| 135 | |
Uwe Hermann | 09e04f7 | 2009-05-16 22:36:00 +0000 | [diff] [blame] | 136 | int programmer_init(void); |
| 137 | int programmer_shutdown(void); |
| 138 | void *programmer_map_flash_region(const char *descr, unsigned long phys_addr, |
| 139 | size_t len); |
| 140 | void programmer_unmap_flash_region(void *virt_addr, size_t len); |
| 141 | void chip_writeb(uint8_t val, chipaddr addr); |
| 142 | void chip_writew(uint16_t val, chipaddr addr); |
| 143 | void chip_writel(uint32_t val, chipaddr addr); |
Carl-Daniel Hailfinger | 0bd2a2b | 2009-06-05 18:32:07 +0000 | [diff] [blame] | 144 | void chip_writen(uint8_t *buf, chipaddr addr, size_t len); |
Uwe Hermann | 09e04f7 | 2009-05-16 22:36:00 +0000 | [diff] [blame] | 145 | uint8_t chip_readb(const chipaddr addr); |
| 146 | uint16_t chip_readw(const chipaddr addr); |
| 147 | uint32_t chip_readl(const chipaddr addr); |
Carl-Daniel Hailfinger | 0bd2a2b | 2009-06-05 18:32:07 +0000 | [diff] [blame] | 148 | 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] | 149 | void programmer_delay(int usecs); |
Carl-Daniel Hailfinger | 61a8bd2 | 2009-03-05 19:24:22 +0000 | [diff] [blame] | 150 | |
Carl-Daniel Hailfinger | 3a4781e | 2009-10-01 14:51:25 +0000 | [diff] [blame] | 151 | enum bitbang_spi_master { |
| 152 | BITBANG_SPI_INVALID /* This must always be the last entry. */ |
Carl-Daniel Hailfinger | 547872b | 2009-09-28 13:15:16 +0000 | [diff] [blame] | 153 | }; |
| 154 | |
Carl-Daniel Hailfinger | 3a4781e | 2009-10-01 14:51:25 +0000 | [diff] [blame] | 155 | extern const int bitbang_spi_master_count; |
Carl-Daniel Hailfinger | 547872b | 2009-09-28 13:15:16 +0000 | [diff] [blame] | 156 | |
Carl-Daniel Hailfinger | 3a4781e | 2009-10-01 14:51:25 +0000 | [diff] [blame] | 157 | extern enum bitbang_spi_master bitbang_spi_master; |
Carl-Daniel Hailfinger | 547872b | 2009-09-28 13:15:16 +0000 | [diff] [blame] | 158 | |
Carl-Daniel Hailfinger | 3a4781e | 2009-10-01 14:51:25 +0000 | [diff] [blame] | 159 | struct bitbang_spi_master_entry { |
Carl-Daniel Hailfinger | 547872b | 2009-09-28 13:15:16 +0000 | [diff] [blame] | 160 | void (*set_cs) (int val); |
| 161 | void (*set_sck) (int val); |
| 162 | void (*set_mosi) (int val); |
| 163 | int (*get_miso) (void); |
| 164 | }; |
| 165 | |
Uwe Hermann | e5ac164 | 2008-03-12 11:54:51 +0000 | [diff] [blame] | 166 | #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) |
| 167 | |
Carl-Daniel Hailfinger | 1dfe0ff | 2009-05-31 17:57:34 +0000 | [diff] [blame] | 168 | enum chipbustype { |
Carl-Daniel Hailfinger | 3504b53 | 2009-06-01 00:02:11 +0000 | [diff] [blame] | 169 | CHIP_BUSTYPE_NONE = 0, |
Carl-Daniel Hailfinger | 1dfe0ff | 2009-05-31 17:57:34 +0000 | [diff] [blame] | 170 | CHIP_BUSTYPE_PARALLEL = 1 << 0, |
| 171 | CHIP_BUSTYPE_LPC = 1 << 1, |
| 172 | CHIP_BUSTYPE_FWH = 1 << 2, |
| 173 | CHIP_BUSTYPE_SPI = 1 << 3, |
| 174 | CHIP_BUSTYPE_NONSPI = CHIP_BUSTYPE_PARALLEL | CHIP_BUSTYPE_LPC | CHIP_BUSTYPE_FWH, |
| 175 | CHIP_BUSTYPE_UNKNOWN = CHIP_BUSTYPE_PARALLEL | CHIP_BUSTYPE_LPC | CHIP_BUSTYPE_FWH | CHIP_BUSTYPE_SPI, |
| 176 | }; |
| 177 | |
Carl-Daniel Hailfinger | f38431a | 2009-09-05 02:30:58 +0000 | [diff] [blame] | 178 | /* |
| 179 | * How many different contiguous runs of erase blocks with one size each do |
| 180 | * we have for a given erase function? |
| 181 | */ |
| 182 | #define NUM_ERASEREGIONS 5 |
| 183 | |
| 184 | /* |
| 185 | * How many different erase functions do we have per chip? |
| 186 | */ |
| 187 | #define NUM_ERASEFUNCTIONS 5 |
| 188 | |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 189 | struct flashchip { |
Uwe Hermann | 7615868 | 2008-03-14 23:55:58 +0000 | [diff] [blame] | 190 | const char *vendor; |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 191 | const char *name; |
Carl-Daniel Hailfinger | 1dfe0ff | 2009-05-31 17:57:34 +0000 | [diff] [blame] | 192 | |
| 193 | enum chipbustype bustype; |
| 194 | |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 195 | /* |
| 196 | * 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] | 197 | * (including) the 4th bank of JEDEC JEP106W Standard Manufacturer's |
| 198 | * Identification code. |
| 199 | */ |
| 200 | uint32_t manufacture_id; |
| 201 | uint32_t model_id; |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 202 | |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 203 | int total_size; |
| 204 | int page_size; |
| 205 | |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 206 | /* |
| 207 | * Indicate if flashrom has been tested with this flash chip and if |
Peter Stuge | 1159d58 | 2008-05-03 04:34:37 +0000 | [diff] [blame] | 208 | * everything worked correctly. |
| 209 | */ |
| 210 | uint32_t tested; |
| 211 | |
Uwe Hermann | 0b7afe6 | 2007-04-01 19:44:21 +0000 | [diff] [blame] | 212 | int (*probe) (struct flashchip *flash); |
Maciej Pijanka | c6e1111 | 2009-06-03 14:46:22 +0000 | [diff] [blame] | 213 | |
| 214 | /* Delay after "enter/exit ID mode" commands in microseconds. */ |
| 215 | int probe_timing; |
Uwe Hermann | 0b7afe6 | 2007-04-01 19:44:21 +0000 | [diff] [blame] | 216 | int (*erase) (struct flashchip *flash); |
Carl-Daniel Hailfinger | f38431a | 2009-09-05 02:30:58 +0000 | [diff] [blame] | 217 | |
| 218 | /* |
| 219 | * Erase blocks and associated erase function. The default entry is a |
| 220 | * chip-sized virtual block together with the chip erase function. |
| 221 | */ |
| 222 | struct block_eraser { |
| 223 | struct eraseblock{ |
| 224 | unsigned int size; /* Eraseblock size */ |
| 225 | unsigned int count; /* Number of contiguous blocks with that size */ |
| 226 | } eraseblocks[NUM_ERASEREGIONS]; |
| 227 | int (*block_erase) (struct flashchip *flash, unsigned int blockaddr, unsigned int blocklen); |
| 228 | } block_erasers[NUM_ERASEFUNCTIONS]; |
| 229 | |
Uwe Hermann | 0b7afe6 | 2007-04-01 19:44:21 +0000 | [diff] [blame] | 230 | int (*write) (struct flashchip *flash, uint8_t *buf); |
Carl-Daniel Hailfinger | cbf563c | 2009-06-16 08:55:44 +0000 | [diff] [blame] | 231 | 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] | 232 | |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 233 | /* Some flash devices have an additional register space. */ |
Carl-Daniel Hailfinger | 5820f42 | 2009-05-16 21:22:56 +0000 | [diff] [blame] | 234 | chipaddr virtual_memory; |
| 235 | chipaddr virtual_registers; |
Ronald G. Minnich | 5e5f75e | 2002-01-29 18:21:41 +0000 | [diff] [blame] | 236 | }; |
| 237 | |
Peter Stuge | 1159d58 | 2008-05-03 04:34:37 +0000 | [diff] [blame] | 238 | #define TEST_UNTESTED 0 |
| 239 | |
Uwe Hermann | d1129ac | 2009-05-28 15:07:42 +0000 | [diff] [blame] | 240 | #define TEST_OK_PROBE (1 << 0) |
| 241 | #define TEST_OK_READ (1 << 1) |
| 242 | #define TEST_OK_ERASE (1 << 2) |
| 243 | #define TEST_OK_WRITE (1 << 3) |
| 244 | #define TEST_OK_PR (TEST_OK_PROBE | TEST_OK_READ) |
| 245 | #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] | 246 | #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] | 247 | #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] | 248 | #define TEST_OK_MASK 0x0f |
| 249 | |
Uwe Hermann | d1129ac | 2009-05-28 15:07:42 +0000 | [diff] [blame] | 250 | #define TEST_BAD_PROBE (1 << 4) |
| 251 | #define TEST_BAD_READ (1 << 5) |
| 252 | #define TEST_BAD_ERASE (1 << 6) |
| 253 | #define TEST_BAD_WRITE (1 << 7) |
| 254 | #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] | 255 | #define TEST_BAD_MASK 0xf0 |
| 256 | |
Maciej Pijanka | c6e1111 | 2009-06-03 14:46:22 +0000 | [diff] [blame] | 257 | /* Timing used in probe routines. ZERO is -2 to differentiate between an unset |
| 258 | * field and zero delay. |
| 259 | * |
| 260 | * SPI devices will always have zero delay and ignore this field. |
| 261 | */ |
| 262 | #define TIMING_FIXME -1 |
| 263 | /* this is intentionally same value as fixme */ |
| 264 | #define TIMING_IGNORED -1 |
| 265 | #define TIMING_ZERO -2 |
| 266 | |
Ollie Lho | 184a404 | 2005-11-26 21:55:36 +0000 | [diff] [blame] | 267 | extern struct flashchip flashchips[]; |
| 268 | |
Uwe Hermann | 05fab75 | 2009-05-16 23:42:17 +0000 | [diff] [blame] | 269 | struct penable { |
| 270 | uint16_t vendor_id; |
| 271 | uint16_t device_id; |
| 272 | int status; |
| 273 | const char *vendor_name; |
| 274 | const char *device_name; |
| 275 | int (*doit) (struct pci_dev *dev, const char *name); |
| 276 | }; |
| 277 | |
| 278 | extern const struct penable chipset_enables[]; |
| 279 | |
| 280 | struct board_pciid_enable { |
| 281 | /* Any device, but make it sensible, like the ISA bridge. */ |
| 282 | uint16_t first_vendor; |
| 283 | uint16_t first_device; |
| 284 | uint16_t first_card_vendor; |
| 285 | uint16_t first_card_device; |
| 286 | |
| 287 | /* Any device, but make it sensible, like |
| 288 | * the host bridge. May be NULL. |
| 289 | */ |
| 290 | uint16_t second_vendor; |
| 291 | uint16_t second_device; |
| 292 | uint16_t second_card_vendor; |
| 293 | uint16_t second_card_device; |
| 294 | |
| 295 | /* The vendor / part name from the coreboot table. */ |
| 296 | const char *lb_vendor; |
| 297 | const char *lb_part; |
| 298 | |
| 299 | const char *vendor_name; |
| 300 | const char *board_name; |
| 301 | |
| 302 | int (*enable) (const char *name); |
| 303 | }; |
| 304 | |
| 305 | extern struct board_pciid_enable board_pciid_enables[]; |
| 306 | |
| 307 | struct board_info { |
| 308 | const char *vendor; |
| 309 | const char *name; |
| 310 | }; |
| 311 | |
| 312 | extern const struct board_info boards_ok[]; |
| 313 | extern const struct board_info boards_bad[]; |
Uwe Hermann | e1aa75e | 2009-06-18 14:04:44 +0000 | [diff] [blame] | 314 | extern const struct board_info laptops_ok[]; |
| 315 | extern const struct board_info laptops_bad[]; |
Uwe Hermann | 05fab75 | 2009-05-16 23:42:17 +0000 | [diff] [blame] | 316 | |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 317 | /* udelay.c */ |
Carl-Daniel Hailfinger | ca8bfc6 | 2009-06-05 17:48:08 +0000 | [diff] [blame] | 318 | void myusec_delay(int usecs); |
Carl-Daniel Hailfinger | 4363439 | 2009-05-01 12:22:17 +0000 | [diff] [blame] | 319 | void myusec_calibrate_delay(void); |
Luc Verhaegen | 8e3a600 | 2007-04-04 22:45:58 +0000 | [diff] [blame] | 320 | |
Uwe Hermann | 515ab3d | 2009-05-15 17:02:34 +0000 | [diff] [blame] | 321 | /* pcidev.c */ |
| 322 | #define PCI_OK 0 |
| 323 | #define PCI_NT 1 /* Not tested */ |
Rudolf Marek | 68720c7 | 2009-05-17 19:39:27 +0000 | [diff] [blame] | 324 | |
Uwe Hermann | 515ab3d | 2009-05-15 17:02:34 +0000 | [diff] [blame] | 325 | extern uint32_t io_base_addr; |
| 326 | extern struct pci_access *pacc; |
| 327 | extern struct pci_filter filter; |
Uwe Hermann | 8403ccb | 2009-05-16 21:39:19 +0000 | [diff] [blame] | 328 | extern struct pci_dev *pcidev_dev; |
Uwe Hermann | 515ab3d | 2009-05-15 17:02:34 +0000 | [diff] [blame] | 329 | struct pcidev_status { |
| 330 | uint16_t vendor_id; |
| 331 | uint16_t device_id; |
| 332 | int status; |
| 333 | const char *vendor_name; |
| 334 | const char *device_name; |
| 335 | }; |
TURBO J | b0912c0 | 2009-09-02 23:00:46 +0000 | [diff] [blame] | 336 | uint32_t pcidev_validate(struct pci_dev *dev, uint32_t bar, struct pcidev_status *devs); |
| 337 | uint32_t pcidev_init(uint16_t vendor_id, uint32_t bar, struct pcidev_status *devs, char *pcidev_bdf); |
Uwe Hermann | ba290d1 | 2009-06-17 12:07:12 +0000 | [diff] [blame] | 338 | |
| 339 | /* print.c */ |
| 340 | char *flashbuses_to_text(enum chipbustype bustype); |
Carl-Daniel Hailfinger | f529205 | 2009-11-17 09:57:34 +0000 | [diff] [blame] | 341 | void print_supported(void); |
Uwe Hermann | 515ab3d | 2009-05-15 17:02:34 +0000 | [diff] [blame] | 342 | void print_supported_pcidevs(struct pcidev_status *devs); |
Carl-Daniel Hailfinger | f529205 | 2009-11-17 09:57:34 +0000 | [diff] [blame] | 343 | void print_supported_wiki(void); |
Uwe Hermann | 515ab3d | 2009-05-15 17:02:34 +0000 | [diff] [blame] | 344 | |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 345 | /* board_enable.c */ |
Peter Stuge | 9d9399c | 2009-01-26 02:34:51 +0000 | [diff] [blame] | 346 | void w836xx_ext_enter(uint16_t port); |
| 347 | void w836xx_ext_leave(uint16_t port); |
Carl-Daniel Hailfinger | 24c1a16 | 2009-05-25 23:26:50 +0000 | [diff] [blame] | 348 | uint8_t sio_read(uint16_t port, uint8_t reg); |
| 349 | void sio_write(uint16_t port, uint8_t reg, uint8_t data); |
| 350 | 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] | 351 | int board_flash_enable(const char *vendor, const char *part); |
Adam Kaufman | 064b1f2 | 2007-02-06 19:47:50 +0000 | [diff] [blame] | 352 | |
Carl-Daniel Hailfinger | 115d390 | 2009-10-31 01:53:09 +0000 | [diff] [blame] | 353 | struct decode_sizes { |
| 354 | uint32_t parallel; |
| 355 | uint32_t lpc; |
| 356 | uint32_t fwh; |
| 357 | uint32_t spi; |
| 358 | }; |
| 359 | |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 360 | /* chipset_enable.c */ |
Carl-Daniel Hailfinger | 1dfe0ff | 2009-05-31 17:57:34 +0000 | [diff] [blame] | 361 | extern enum chipbustype buses_supported; |
Uwe Hermann | 372eeb5 | 2007-12-04 21:49:06 +0000 | [diff] [blame] | 362 | int chipset_flash_enable(void); |
Carl-Daniel Hailfinger | 115d390 | 2009-10-31 01:53:09 +0000 | [diff] [blame] | 363 | extern struct decode_sizes max_rom_decode; |
Stefan Reinauer | 2cb94e1 | 2008-06-30 23:45:22 +0000 | [diff] [blame] | 364 | |
Stefan Reinauer | 9a6d176 | 2008-12-03 21:24:40 +0000 | [diff] [blame] | 365 | extern unsigned long flashbase; |
| 366 | |
Stefan Reinauer | 0593f21 | 2009-01-26 01:10:48 +0000 | [diff] [blame] | 367 | /* physmap.c */ |
| 368 | void *physmap(const char *descr, unsigned long phys_addr, size_t len); |
| 369 | void physunmap(void *virt_addr, size_t len); |
Stefan Reinauer | 8fa6481 | 2009-08-12 09:27:45 +0000 | [diff] [blame] | 370 | int setup_cpu_msr(int cpu); |
| 371 | void cleanup_cpu_msr(void); |
Stefan Reinauer | 173e3ea | 2009-08-19 10:46:23 +0000 | [diff] [blame] | 372 | #if !defined(__DARWIN__) && !defined(__FreeBSD__) && !defined(__DragonFly__) |
Stefan Reinauer | 8fa6481 | 2009-08-12 09:27:45 +0000 | [diff] [blame] | 373 | typedef struct { uint32_t hi, lo; } msr_t; |
| 374 | msr_t rdmsr(int addr); |
| 375 | int wrmsr(int addr, msr_t msr); |
| 376 | #endif |
Stefan Reinauer | 173e3ea | 2009-08-19 10:46:23 +0000 | [diff] [blame] | 377 | #if defined(__FreeBSD__) || defined(__DragonFly__) |
| 378 | /* FreeBSD already has conflicting definitions for wrmsr/rdmsr. */ |
| 379 | #undef rdmsr |
| 380 | #undef wrmsr |
| 381 | #define rdmsr freebsd_rdmsr |
| 382 | #define wrmsr freebsd_wrmsr |
| 383 | typedef struct { uint32_t hi, lo; } msr_t; |
| 384 | msr_t freebsd_rdmsr(int addr); |
| 385 | int freebsd_wrmsr(int addr, msr_t msr); |
| 386 | #endif |
Stefan Reinauer | 0593f21 | 2009-01-26 01:10:48 +0000 | [diff] [blame] | 387 | |
Carl-Daniel Hailfinger | 702218d | 2009-05-08 17:43:22 +0000 | [diff] [blame] | 388 | /* internal.c */ |
Uwe Hermann | 2cac686 | 2009-05-16 22:05:42 +0000 | [diff] [blame] | 389 | struct pci_dev *pci_dev_find_filter(struct pci_filter filter); |
Carl-Daniel Hailfinger | 9f46cfc | 2009-11-15 17:13:29 +0000 | [diff] [blame] | 390 | 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] | 391 | struct pci_dev *pci_dev_find(uint16_t vendor, uint16_t device); |
| 392 | struct pci_dev *pci_card_find(uint16_t vendor, uint16_t device, |
| 393 | uint16_t card_vendor, uint16_t card_device); |
Carl-Daniel Hailfinger | 3b7e75a | 2009-05-14 21:41:10 +0000 | [diff] [blame] | 394 | void get_io_perms(void); |
Carl-Daniel Hailfinger | db41c59 | 2009-08-09 21:50:24 +0000 | [diff] [blame] | 395 | void release_io_perms(void); |
Carl-Daniel Hailfinger | 702218d | 2009-05-08 17:43:22 +0000 | [diff] [blame] | 396 | int internal_init(void); |
| 397 | int internal_shutdown(void); |
Carl-Daniel Hailfinger | 5820f42 | 2009-05-16 21:22:56 +0000 | [diff] [blame] | 398 | void internal_chip_writeb(uint8_t val, chipaddr addr); |
| 399 | void internal_chip_writew(uint16_t val, chipaddr addr); |
| 400 | void internal_chip_writel(uint32_t val, chipaddr addr); |
| 401 | uint8_t internal_chip_readb(const chipaddr addr); |
| 402 | uint16_t internal_chip_readw(const chipaddr addr); |
| 403 | uint32_t internal_chip_readl(const chipaddr addr); |
Carl-Daniel Hailfinger | 0bd2a2b | 2009-06-05 18:32:07 +0000 | [diff] [blame] | 404 | void internal_chip_readn(uint8_t *buf, const chipaddr addr, size_t len); |
Carl-Daniel Hailfinger | 78185dc | 2009-05-17 15:49:24 +0000 | [diff] [blame] | 405 | void mmio_writeb(uint8_t val, void *addr); |
| 406 | void mmio_writew(uint16_t val, void *addr); |
| 407 | void mmio_writel(uint32_t val, void *addr); |
| 408 | uint8_t mmio_readb(void *addr); |
| 409 | uint16_t mmio_readw(void *addr); |
| 410 | uint32_t mmio_readl(void *addr); |
Carl-Daniel Hailfinger | ca8bfc6 | 2009-06-05 17:48:08 +0000 | [diff] [blame] | 411 | void internal_delay(int usecs); |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 412 | int noop_shutdown(void); |
Uwe Hermann | c691593 | 2009-05-17 23:12:17 +0000 | [diff] [blame] | 413 | void *fallback_map(const char *descr, unsigned long phys_addr, size_t len); |
| 414 | void fallback_unmap(void *virt_addr, size_t len); |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 415 | uint8_t noop_chip_readb(const chipaddr addr); |
| 416 | void noop_chip_writeb(uint8_t val, chipaddr addr); |
Carl-Daniel Hailfinger | 5820f42 | 2009-05-16 21:22:56 +0000 | [diff] [blame] | 417 | void fallback_chip_writew(uint16_t val, chipaddr addr); |
| 418 | void fallback_chip_writel(uint32_t val, chipaddr addr); |
Carl-Daniel Hailfinger | 0bd2a2b | 2009-06-05 18:32:07 +0000 | [diff] [blame] | 419 | 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] | 420 | uint16_t fallback_chip_readw(const chipaddr addr); |
| 421 | uint32_t fallback_chip_readl(const chipaddr addr); |
Carl-Daniel Hailfinger | 0bd2a2b | 2009-06-05 18:32:07 +0000 | [diff] [blame] | 422 | void fallback_chip_readn(uint8_t *buf, const chipaddr addr, size_t len); |
Uwe Hermann | a086932 | 2009-05-14 20:41:57 +0000 | [diff] [blame] | 423 | #if defined(__FreeBSD__) || defined(__DragonFly__) |
| 424 | extern int io_fd; |
| 425 | #endif |
Carl-Daniel Hailfinger | 702218d | 2009-05-08 17:43:22 +0000 | [diff] [blame] | 426 | |
Carl-Daniel Hailfinger | c312920 | 2009-05-09 00:54:55 +0000 | [diff] [blame] | 427 | /* dummyflasher.c */ |
| 428 | int dummy_init(void); |
| 429 | int dummy_shutdown(void); |
Carl-Daniel Hailfinger | 1455b2b | 2009-05-11 14:13:25 +0000 | [diff] [blame] | 430 | void *dummy_map(const char *descr, unsigned long phys_addr, size_t len); |
| 431 | void dummy_unmap(void *virt_addr, size_t len); |
Carl-Daniel Hailfinger | 5820f42 | 2009-05-16 21:22:56 +0000 | [diff] [blame] | 432 | void dummy_chip_writeb(uint8_t val, chipaddr addr); |
| 433 | void dummy_chip_writew(uint16_t val, chipaddr addr); |
| 434 | void dummy_chip_writel(uint32_t val, chipaddr addr); |
Carl-Daniel Hailfinger | 0bd2a2b | 2009-06-05 18:32:07 +0000 | [diff] [blame] | 435 | 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] | 436 | uint8_t dummy_chip_readb(const chipaddr addr); |
| 437 | uint16_t dummy_chip_readw(const chipaddr addr); |
| 438 | uint32_t dummy_chip_readl(const chipaddr addr); |
Carl-Daniel Hailfinger | 0bd2a2b | 2009-06-05 18:32:07 +0000 | [diff] [blame] | 439 | 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] | 440 | int dummy_spi_send_command(unsigned int writecnt, unsigned int readcnt, |
Carl-Daniel Hailfinger | bfe2e0c | 2009-05-14 12:59:36 +0000 | [diff] [blame] | 441 | const unsigned char *writearr, unsigned char *readarr); |
Carl-Daniel Hailfinger | c312920 | 2009-05-09 00:54:55 +0000 | [diff] [blame] | 442 | |
Uwe Hermann | b4dcb71 | 2009-05-13 11:36:06 +0000 | [diff] [blame] | 443 | /* nic3com.c */ |
| 444 | int nic3com_init(void); |
| 445 | int nic3com_shutdown(void); |
Carl-Daniel Hailfinger | 5820f42 | 2009-05-16 21:22:56 +0000 | [diff] [blame] | 446 | void nic3com_chip_writeb(uint8_t val, chipaddr addr); |
| 447 | uint8_t nic3com_chip_readb(const chipaddr addr); |
Uwe Hermann | 515ab3d | 2009-05-15 17:02:34 +0000 | [diff] [blame] | 448 | extern struct pcidev_status nics_3com[]; |
Uwe Hermann | b4dcb71 | 2009-05-13 11:36:06 +0000 | [diff] [blame] | 449 | |
Uwe Hermann | 2bc98f6 | 2009-09-30 18:29:55 +0000 | [diff] [blame] | 450 | /* gfxnvidia.c */ |
| 451 | int gfxnvidia_init(void); |
| 452 | int gfxnvidia_shutdown(void); |
| 453 | void gfxnvidia_chip_writeb(uint8_t val, chipaddr addr); |
| 454 | uint8_t gfxnvidia_chip_readb(const chipaddr addr); |
| 455 | extern struct pcidev_status gfx_nvidia[]; |
| 456 | |
TURBO J | b0912c0 | 2009-09-02 23:00:46 +0000 | [diff] [blame] | 457 | /* drkaiser.c */ |
| 458 | int drkaiser_init(void); |
| 459 | int drkaiser_shutdown(void); |
| 460 | void drkaiser_chip_writeb(uint8_t val, chipaddr addr); |
| 461 | uint8_t drkaiser_chip_readb(const chipaddr addr); |
| 462 | extern struct pcidev_status drkaiser_pcidev[]; |
| 463 | |
Rudolf Marek | 68720c7 | 2009-05-17 19:39:27 +0000 | [diff] [blame] | 464 | /* satasii.c */ |
| 465 | int satasii_init(void); |
| 466 | int satasii_shutdown(void); |
Rudolf Marek | 68720c7 | 2009-05-17 19:39:27 +0000 | [diff] [blame] | 467 | void satasii_chip_writeb(uint8_t val, chipaddr addr); |
| 468 | uint8_t satasii_chip_readb(const chipaddr addr); |
| 469 | extern struct pcidev_status satas_sii[]; |
| 470 | |
Paul Fox | 05dfbe6 | 2009-06-16 21:08:06 +0000 | [diff] [blame] | 471 | /* ft2232_spi.c */ |
Carl-Daniel Hailfinger | feea272 | 2009-07-01 00:02:23 +0000 | [diff] [blame] | 472 | #define FTDI_FT2232H 0x6010 |
| 473 | #define FTDI_FT4232H 0x6011 |
Paul Fox | 05dfbe6 | 2009-06-16 21:08:06 +0000 | [diff] [blame] | 474 | int ft2232_spi_init(void); |
Carl-Daniel Hailfinger | d047829 | 2009-07-10 21:08:55 +0000 | [diff] [blame] | 475 | 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] | 476 | 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] | 477 | int ft2232_spi_write_256(struct flashchip *flash, uint8_t *buf); |
| 478 | |
Carl-Daniel Hailfinger | 547872b | 2009-09-28 13:15:16 +0000 | [diff] [blame] | 479 | /* bitbang_spi.c */ |
Carl-Daniel Hailfinger | 3a4781e | 2009-10-01 14:51:25 +0000 | [diff] [blame] | 480 | extern int bitbang_spi_half_period; |
| 481 | extern const struct bitbang_spi_master_entry bitbang_spi_master_table[]; |
Carl-Daniel Hailfinger | 547872b | 2009-09-28 13:15:16 +0000 | [diff] [blame] | 482 | int bitbang_spi_init(void); |
| 483 | int bitbang_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr); |
| 484 | int bitbang_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len); |
| 485 | int bitbang_spi_write_256(struct flashchip *flash, uint8_t *buf); |
| 486 | |
Uwe Hermann | 0846f89 | 2007-08-23 13:34:59 +0000 | [diff] [blame] | 487 | /* flashrom.c */ |
Carl-Daniel Hailfinger | ef58a9c | 2009-08-12 13:32:56 +0000 | [diff] [blame] | 488 | extern char *programmer_param; |
Uwe Hermann | ad216bf | 2009-04-24 16:17:41 +0000 | [diff] [blame] | 489 | extern int verbose; |
Carl-Daniel Hailfinger | a80cfbc | 2009-07-22 20:13:00 +0000 | [diff] [blame] | 490 | extern const char *flashrom_version; |
Uwe Hermann | ad216bf | 2009-04-24 16:17:41 +0000 | [diff] [blame] | 491 | #define printf_debug(x...) { if (verbose) printf(x); } |
Peter Stuge | 776d202 | 2009-01-26 00:39:57 +0000 | [diff] [blame] | 492 | void map_flash_registers(struct flashchip *flash); |
Carl-Daniel Hailfinger | cbf563c | 2009-06-16 08:55:44 +0000 | [diff] [blame] | 493 | 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] | 494 | int erase_flash(struct flashchip *flash); |
Carl-Daniel Hailfinger | 38a059d | 2009-06-13 12:04:03 +0000 | [diff] [blame] | 495 | int min(int a, int b); |
Carl-Daniel Hailfinger | 30f7cb2 | 2009-06-15 17:23:36 +0000 | [diff] [blame] | 496 | int max(int a, int b); |
| 497 | int check_erased_range(struct flashchip *flash, int start, int len); |
| 498 | 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] | 499 | char *strcat_realloc(char *dest, const char *src); |
| 500 | |
| 501 | #define OK 0 |
| 502 | #define NT 1 /* Not tested */ |
Uwe Hermann | 0846f89 | 2007-08-23 13:34:59 +0000 | [diff] [blame] | 503 | |
| 504 | /* layout.c */ |
Peter Stuge | 7ffbc6f | 2008-06-18 02:08:40 +0000 | [diff] [blame] | 505 | int show_id(uint8_t *bios, int size, int force); |
Uwe Hermann | 0846f89 | 2007-08-23 13:34:59 +0000 | [diff] [blame] | 506 | int read_romlayout(char *name); |
| 507 | int find_romentry(char *name); |
Carl-Daniel Hailfinger | f5fb51c | 2009-08-19 15:19:18 +0000 | [diff] [blame] | 508 | int handle_romentries(uint8_t *buffer, struct flashchip *flash); |
Uwe Hermann | 0846f89 | 2007-08-23 13:34:59 +0000 | [diff] [blame] | 509 | |
Uwe Hermann | ad216bf | 2009-04-24 16:17:41 +0000 | [diff] [blame] | 510 | /* cbtable.c */ |
Stefan Reinauer | e3f3e2e | 2008-01-18 15:33:10 +0000 | [diff] [blame] | 511 | int coreboot_init(void); |
Uwe Hermann | 0846f89 | 2007-08-23 13:34:59 +0000 | [diff] [blame] | 512 | extern char *lb_part, *lb_vendor; |
Carl-Daniel Hailfinger | bc25f94 | 2009-07-30 13:30:17 +0000 | [diff] [blame] | 513 | extern int partvendor_from_cbtable; |
Uwe Hermann | 0846f89 | 2007-08-23 13:34:59 +0000 | [diff] [blame] | 514 | |
Carl-Daniel Hailfinger | 00f911e | 2007-10-15 21:44:47 +0000 | [diff] [blame] | 515 | /* spi.c */ |
Carl-Daniel Hailfinger | 1dfe0ff | 2009-05-31 17:57:34 +0000 | [diff] [blame] | 516 | enum spi_controller { |
| 517 | SPI_CONTROLLER_NONE, |
| 518 | SPI_CONTROLLER_ICH7, |
| 519 | SPI_CONTROLLER_ICH9, |
| 520 | SPI_CONTROLLER_IT87XX, |
| 521 | SPI_CONTROLLER_SB600, |
| 522 | SPI_CONTROLLER_VIA, |
| 523 | SPI_CONTROLLER_WBSIO, |
Carl-Daniel Hailfinger | 3426ef6 | 2009-08-19 13:27:58 +0000 | [diff] [blame] | 524 | #if FT2232_SPI_SUPPORT == 1 |
Paul Fox | 05dfbe6 | 2009-06-16 21:08:06 +0000 | [diff] [blame] | 525 | SPI_CONTROLLER_FT2232, |
Carl-Daniel Hailfinger | 3426ef6 | 2009-08-19 13:27:58 +0000 | [diff] [blame] | 526 | #endif |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 527 | #if DUMMY_SUPPORT == 1 |
Carl-Daniel Hailfinger | 1dfe0ff | 2009-05-31 17:57:34 +0000 | [diff] [blame] | 528 | SPI_CONTROLLER_DUMMY, |
Carl-Daniel Hailfinger | 4740c6f | 2009-09-16 10:09:21 +0000 | [diff] [blame] | 529 | #endif |
Carl-Daniel Hailfinger | 3426ef6 | 2009-08-19 13:27:58 +0000 | [diff] [blame] | 530 | SPI_CONTROLLER_INVALID /* This must always be the last entry. */ |
Carl-Daniel Hailfinger | 1dfe0ff | 2009-05-31 17:57:34 +0000 | [diff] [blame] | 531 | }; |
Carl-Daniel Hailfinger | 3426ef6 | 2009-08-19 13:27:58 +0000 | [diff] [blame] | 532 | extern const int spi_programmer_count; |
Carl-Daniel Hailfinger | d047829 | 2009-07-10 21:08:55 +0000 | [diff] [blame] | 533 | struct spi_command { |
| 534 | unsigned int writecnt; |
| 535 | unsigned int readcnt; |
| 536 | const unsigned char *writearr; |
| 537 | unsigned char *readarr; |
| 538 | }; |
Carl-Daniel Hailfinger | 02487aa | 2009-07-22 15:36:50 +0000 | [diff] [blame] | 539 | struct spi_programmer { |
| 540 | int (*command)(unsigned int writecnt, unsigned int readcnt, |
| 541 | const unsigned char *writearr, unsigned char *readarr); |
Carl-Daniel Hailfinger | 26f7e64 | 2009-09-18 15:50:56 +0000 | [diff] [blame] | 542 | int (*multicommand)(struct spi_command *cmds); |
Carl-Daniel Hailfinger | 02487aa | 2009-07-22 15:36:50 +0000 | [diff] [blame] | 543 | |
| 544 | /* Optimized functions for this programmer */ |
| 545 | int (*read)(struct flashchip *flash, uint8_t *buf, int start, int len); |
| 546 | int (*write_256)(struct flashchip *flash, uint8_t *buf); |
| 547 | }; |
Carl-Daniel Hailfinger | d047829 | 2009-07-10 21:08:55 +0000 | [diff] [blame] | 548 | |
Carl-Daniel Hailfinger | 1dfe0ff | 2009-05-31 17:57:34 +0000 | [diff] [blame] | 549 | extern enum spi_controller spi_controller; |
Carl-Daniel Hailfinger | 02487aa | 2009-07-22 15:36:50 +0000 | [diff] [blame] | 550 | extern const struct spi_programmer spi_programmer[]; |
Carl-Daniel Hailfinger | 1dfe0ff | 2009-05-31 17:57:34 +0000 | [diff] [blame] | 551 | extern void *spibar; |
Carl-Daniel Hailfinger | 42c5497 | 2008-05-15 03:19:49 +0000 | [diff] [blame] | 552 | int probe_spi_rdid(struct flashchip *flash); |
Rudolf Marek | 48a85e4 | 2008-06-30 21:45:17 +0000 | [diff] [blame] | 553 | int probe_spi_rdid4(struct flashchip *flash); |
Carl-Daniel Hailfinger | 14e50ac | 2008-11-28 01:25:00 +0000 | [diff] [blame] | 554 | int probe_spi_rems(struct flashchip *flash); |
Carl-Daniel Hailfinger | 42c5497 | 2008-05-15 03:19:49 +0000 | [diff] [blame] | 555 | int probe_spi_res(struct flashchip *flash); |
Carl-Daniel Hailfinger | d047829 | 2009-07-10 21:08:55 +0000 | [diff] [blame] | 556 | int spi_send_command(unsigned int writecnt, unsigned int readcnt, |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 557 | const unsigned char *writearr, unsigned char *readarr); |
Carl-Daniel Hailfinger | 26f7e64 | 2009-09-18 15:50:56 +0000 | [diff] [blame] | 558 | int spi_send_multicommand(struct spi_command *cmds); |
Carl-Daniel Hailfinger | 4363439 | 2009-05-01 12:22:17 +0000 | [diff] [blame] | 559 | int spi_write_enable(void); |
| 560 | int spi_write_disable(void); |
Carl-Daniel Hailfinger | 6afb613 | 2008-11-03 00:02:11 +0000 | [diff] [blame] | 561 | int spi_chip_erase_60(struct flashchip *flash); |
Peter Stuge | fa8c550 | 2008-05-10 23:07:52 +0000 | [diff] [blame] | 562 | int spi_chip_erase_c7(struct flashchip *flash); |
Carl-Daniel Hailfinger | 598ec58 | 2008-11-18 00:41:02 +0000 | [diff] [blame] | 563 | int spi_chip_erase_60_c7(struct flashchip *flash); |
Stefan Reinauer | 424ed22 | 2008-10-29 22:13:20 +0000 | [diff] [blame] | 564 | int spi_chip_erase_d8(struct flashchip *flash); |
Carl-Daniel Hailfinger | 3431bb7 | 2009-06-24 08:28:39 +0000 | [diff] [blame] | 565 | int spi_block_erase_20(struct flashchip *flash, unsigned int addr, unsigned int blocklen); |
| 566 | int spi_block_erase_52(struct flashchip *flash, unsigned int addr, unsigned int blocklen); |
| 567 | int spi_block_erase_d8(struct flashchip *flash, unsigned int addr, unsigned int blocklen); |
| 568 | int spi_block_erase_60(struct flashchip *flash, unsigned int addr, unsigned int blocklen); |
| 569 | int spi_block_erase_c7(struct flashchip *flash, unsigned int addr, unsigned int blocklen); |
Carl-Daniel Hailfinger | 96930c3 | 2009-05-09 02:30:21 +0000 | [diff] [blame] | 570 | int spi_chip_write_1(struct flashchip *flash, uint8_t *buf); |
Carl-Daniel Hailfinger | 8d49701 | 2009-05-09 02:34:18 +0000 | [diff] [blame] | 571 | int spi_chip_write_256(struct flashchip *flash, uint8_t *buf); |
Carl-Daniel Hailfinger | cbf563c | 2009-06-16 08:55:44 +0000 | [diff] [blame] | 572 | int spi_chip_read(struct flashchip *flash, uint8_t *buf, int start, int len); |
Carl-Daniel Hailfinger | 4363439 | 2009-05-01 12:22:17 +0000 | [diff] [blame] | 573 | uint8_t spi_read_status_register(void); |
Carl-Daniel Hailfinger | 598ec58 | 2008-11-18 00:41:02 +0000 | [diff] [blame] | 574 | int spi_disable_blockprotect(void); |
Carl-Daniel Hailfinger | 2f1b36f | 2009-07-12 12:06:18 +0000 | [diff] [blame] | 575 | int spi_byte_program(int addr, uint8_t byte); |
| 576 | int spi_nbyte_program(int addr, uint8_t *bytes, int len); |
| 577 | int spi_nbyte_read(int addr, uint8_t *bytes, int len); |
Carl-Daniel Hailfinger | cbf563c | 2009-06-16 08:55:44 +0000 | [diff] [blame] | 578 | int spi_read_chunked(struct flashchip *flash, uint8_t *buf, int start, int len, int chunksize); |
Peter Stuge | fd9217d | 2009-01-26 03:37:40 +0000 | [diff] [blame] | 579 | int spi_aai_write(struct flashchip *flash, uint8_t *buf); |
Carl-Daniel Hailfinger | 3e9dbea | 2009-05-13 11:40:08 +0000 | [diff] [blame] | 580 | uint32_t spi_get_valid_read_addr(void); |
Carl-Daniel Hailfinger | 02487aa | 2009-07-22 15:36:50 +0000 | [diff] [blame] | 581 | int default_spi_send_command(unsigned int writecnt, unsigned int readcnt, |
| 582 | const unsigned char *writearr, unsigned char *readarr); |
Carl-Daniel Hailfinger | 26f7e64 | 2009-09-18 15:50:56 +0000 | [diff] [blame] | 583 | int default_spi_send_multicommand(struct spi_command *cmds); |
Carl-Daniel Hailfinger | e151499 | 2007-10-02 15:49:25 +0000 | [diff] [blame] | 584 | |
Uwe Hermann | 0846f89 | 2007-08-23 13:34:59 +0000 | [diff] [blame] | 585 | /* 82802ab.c */ |
Uwe Hermann | a0cc53d | 2007-09-09 20:24:29 +0000 | [diff] [blame] | 586 | int probe_82802ab(struct flashchip *flash); |
| 587 | int erase_82802ab(struct flashchip *flash); |
| 588 | int write_82802ab(struct flashchip *flash, uint8_t *buf); |
Uwe Hermann | 0846f89 | 2007-08-23 13:34:59 +0000 | [diff] [blame] | 589 | |
| 590 | /* am29f040b.c */ |
Uwe Hermann | a0cc53d | 2007-09-09 20:24:29 +0000 | [diff] [blame] | 591 | int probe_29f040b(struct flashchip *flash); |
| 592 | int erase_29f040b(struct flashchip *flash); |
| 593 | int write_29f040b(struct flashchip *flash, uint8_t *buf); |
Uwe Hermann | 0846f89 | 2007-08-23 13:34:59 +0000 | [diff] [blame] | 594 | |
Uwe Hermann | f983d9f | 2009-06-14 21:53:26 +0000 | [diff] [blame] | 595 | /* pm29f002.c */ |
| 596 | int write_pm29f002(struct flashchip *flash, uint8_t *buf); |
| 597 | |
Mats Erik Andersson | 44e1a19 | 2008-09-26 13:19:02 +0000 | [diff] [blame] | 598 | /* en29f002a.c */ |
| 599 | int probe_en29f002a(struct flashchip *flash); |
| 600 | int erase_en29f002a(struct flashchip *flash); |
| 601 | int write_en29f002a(struct flashchip *flash, uint8_t *buf); |
| 602 | |
Dominik Geyer | b46acba | 2008-05-16 12:55:55 +0000 | [diff] [blame] | 603 | /* ichspi.c */ |
Carl-Daniel Hailfinger | 4363439 | 2009-05-01 12:22:17 +0000 | [diff] [blame] | 604 | int ich_init_opcodes(void); |
Carl-Daniel Hailfinger | d047829 | 2009-07-10 21:08:55 +0000 | [diff] [blame] | 605 | int ich_spi_send_command(unsigned int writecnt, unsigned int readcnt, |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 606 | const unsigned char *writearr, unsigned char *readarr); |
Carl-Daniel Hailfinger | cbf563c | 2009-06-16 08:55:44 +0000 | [diff] [blame] | 607 | 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] | 608 | int ich_spi_write_256(struct flashchip *flash, uint8_t * buf); |
Carl-Daniel Hailfinger | 26f7e64 | 2009-09-18 15:50:56 +0000 | [diff] [blame] | 609 | int ich_spi_send_multicommand(struct spi_command *cmds); |
Dominik Geyer | b46acba | 2008-05-16 12:55:55 +0000 | [diff] [blame] | 610 | |
Carl-Daniel Hailfinger | bfe5b4a | 2008-05-13 23:03:12 +0000 | [diff] [blame] | 611 | /* it87spi.c */ |
| 612 | extern uint16_t it8716f_flashport; |
Carl-Daniel Hailfinger | 24c1a16 | 2009-05-25 23:26:50 +0000 | [diff] [blame] | 613 | void enter_conf_mode_ite(uint16_t port); |
| 614 | void exit_conf_mode_ite(uint16_t port); |
Carl-Daniel Hailfinger | b8afecd | 2009-05-31 18:00:57 +0000 | [diff] [blame] | 615 | int it87spi_init(void); |
Dominik Geyer | b46acba | 2008-05-16 12:55:55 +0000 | [diff] [blame] | 616 | int it87xx_probe_spi_flash(const char *name); |
Carl-Daniel Hailfinger | d047829 | 2009-07-10 21:08:55 +0000 | [diff] [blame] | 617 | int it8716f_spi_send_command(unsigned int writecnt, unsigned int readcnt, |
Uwe Hermann | 394131e | 2008-10-18 21:14:13 +0000 | [diff] [blame] | 618 | const unsigned char *writearr, unsigned char *readarr); |
Carl-Daniel Hailfinger | cbf563c | 2009-06-16 08:55:44 +0000 | [diff] [blame] | 619 | 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] | 620 | 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] | 621 | |
Jason Wang | a3f04be | 2008-11-28 21:36:51 +0000 | [diff] [blame] | 622 | /* sb600spi.c */ |
Carl-Daniel Hailfinger | d047829 | 2009-07-10 21:08:55 +0000 | [diff] [blame] | 623 | int sb600_spi_send_command(unsigned int writecnt, unsigned int readcnt, |
Jason Wang | a3f04be | 2008-11-28 21:36:51 +0000 | [diff] [blame] | 624 | const unsigned char *writearr, unsigned char *readarr); |
Carl-Daniel Hailfinger | cbf563c | 2009-06-16 08:55:44 +0000 | [diff] [blame] | 625 | 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] | 626 | int sb600_spi_write_1(struct flashchip *flash, uint8_t *buf); |
Carl-Daniel Hailfinger | 78185dc | 2009-05-17 15:49:24 +0000 | [diff] [blame] | 627 | extern uint8_t *sb600_spibar; |
Jason Wang | a3f04be | 2008-11-28 21:36:51 +0000 | [diff] [blame] | 628 | |
Uwe Hermann | 0846f89 | 2007-08-23 13:34:59 +0000 | [diff] [blame] | 629 | /* jedec.c */ |
Carl-Daniel Hailfinger | a758f51 | 2008-05-14 12:03:06 +0000 | [diff] [blame] | 630 | uint8_t oddparity(uint8_t val); |
Carl-Daniel Hailfinger | 5820f42 | 2009-05-16 21:22:56 +0000 | [diff] [blame] | 631 | void toggle_ready_jedec(chipaddr dst); |
| 632 | void data_polling_jedec(chipaddr dst, uint8_t data); |
| 633 | void unprotect_jedec(chipaddr bios); |
| 634 | void protect_jedec(chipaddr bios); |
| 635 | int write_byte_program_jedec(chipaddr bios, uint8_t *src, |
| 636 | chipaddr dst); |
Uwe Hermann | a0cc53d | 2007-09-09 20:24:29 +0000 | [diff] [blame] | 637 | int probe_jedec(struct flashchip *flash); |
| 638 | int erase_chip_jedec(struct flashchip *flash); |
| 639 | int write_jedec(struct flashchip *flash, uint8_t *buf); |
Carl-Daniel Hailfinger | a06287c | 2009-09-23 22:01:33 +0000 | [diff] [blame] | 640 | int erase_sector_jedec(struct flashchip *flash, unsigned int page, unsigned int pagesize); |
| 641 | int erase_block_jedec(struct flashchip *flash, unsigned int page, unsigned int blocksize); |
Carl-Daniel Hailfinger | 5820f42 | 2009-05-16 21:22:56 +0000 | [diff] [blame] | 642 | int write_sector_jedec(chipaddr bios, uint8_t *src, |
| 643 | chipaddr dst, unsigned int page_size); |
Uwe Hermann | 0846f89 | 2007-08-23 13:34:59 +0000 | [diff] [blame] | 644 | |
Peter Stuge | af8ffac | 2009-01-26 06:42:02 +0000 | [diff] [blame] | 645 | /* m29f002.c */ |
| 646 | int erase_m29f002(struct flashchip *flash); |
| 647 | int write_m29f002t(struct flashchip *flash, uint8_t *buf); |
| 648 | int write_m29f002b(struct flashchip *flash, uint8_t *buf); |
| 649 | |
Uwe Hermann | 0846f89 | 2007-08-23 13:34:59 +0000 | [diff] [blame] | 650 | /* m29f400bt.c */ |
Uwe Hermann | a0cc53d | 2007-09-09 20:24:29 +0000 | [diff] [blame] | 651 | int probe_m29f400bt(struct flashchip *flash); |
| 652 | int erase_m29f400bt(struct flashchip *flash); |
Carl-Daniel Hailfinger | 30f7cb2 | 2009-06-15 17:23:36 +0000 | [diff] [blame] | 653 | int block_erase_m29f400bt(struct flashchip *flash, int start, int len); |
Uwe Hermann | a0cc53d | 2007-09-09 20:24:29 +0000 | [diff] [blame] | 654 | int write_m29f400bt(struct flashchip *flash, uint8_t *buf); |
Stefan Reinauer | e3f3e2e | 2008-01-18 15:33:10 +0000 | [diff] [blame] | 655 | int write_coreboot_m29f400bt(struct flashchip *flash, uint8_t *buf); |
Carl-Daniel Hailfinger | 5820f42 | 2009-05-16 21:22:56 +0000 | [diff] [blame] | 656 | void toggle_ready_m29f400bt(chipaddr dst); |
| 657 | void data_polling_m29f400bt(chipaddr dst, uint8_t data); |
| 658 | void protect_m29f400bt(chipaddr bios); |
| 659 | void write_page_m29f400bt(chipaddr bios, uint8_t *src, |
| 660 | chipaddr dst, int page_size); |
Uwe Hermann | 0846f89 | 2007-08-23 13:34:59 +0000 | [diff] [blame] | 661 | |
| 662 | /* mx29f002.c */ |
Uwe Hermann | a0cc53d | 2007-09-09 20:24:29 +0000 | [diff] [blame] | 663 | int probe_29f002(struct flashchip *flash); |
| 664 | int erase_29f002(struct flashchip *flash); |
| 665 | int write_29f002(struct flashchip *flash, uint8_t *buf); |
Uwe Hermann | 0846f89 | 2007-08-23 13:34:59 +0000 | [diff] [blame] | 666 | |
Nikolay Petukhov | 4784c47 | 2008-05-17 01:08:58 +0000 | [diff] [blame] | 667 | /* pm49fl00x.c */ |
| 668 | int probe_49fl00x(struct flashchip *flash); |
| 669 | int erase_49fl00x(struct flashchip *flash); |
| 670 | int write_49fl00x(struct flashchip *flash, uint8_t *buf); |
Uwe Hermann | 0846f89 | 2007-08-23 13:34:59 +0000 | [diff] [blame] | 671 | |
| 672 | /* sharplhf00l04.c */ |
Uwe Hermann | a0cc53d | 2007-09-09 20:24:29 +0000 | [diff] [blame] | 673 | int probe_lhf00l04(struct flashchip *flash); |
| 674 | int erase_lhf00l04(struct flashchip *flash); |
| 675 | int write_lhf00l04(struct flashchip *flash, uint8_t *buf); |
Carl-Daniel Hailfinger | 5820f42 | 2009-05-16 21:22:56 +0000 | [diff] [blame] | 676 | void toggle_ready_lhf00l04(chipaddr dst); |
| 677 | void data_polling_lhf00l04(chipaddr dst, uint8_t data); |
| 678 | void protect_lhf00l04(chipaddr bios); |
Uwe Hermann | 0846f89 | 2007-08-23 13:34:59 +0000 | [diff] [blame] | 679 | |
| 680 | /* sst28sf040.c */ |
Uwe Hermann | a0cc53d | 2007-09-09 20:24:29 +0000 | [diff] [blame] | 681 | int probe_28sf040(struct flashchip *flash); |
| 682 | int erase_28sf040(struct flashchip *flash); |
| 683 | int write_28sf040(struct flashchip *flash, uint8_t *buf); |
Uwe Hermann | 0846f89 | 2007-08-23 13:34:59 +0000 | [diff] [blame] | 684 | |
| 685 | /* sst39sf020.c */ |
Uwe Hermann | a0cc53d | 2007-09-09 20:24:29 +0000 | [diff] [blame] | 686 | int probe_39sf020(struct flashchip *flash); |
| 687 | int write_39sf020(struct flashchip *flash, uint8_t *buf); |
Uwe Hermann | 0846f89 | 2007-08-23 13:34:59 +0000 | [diff] [blame] | 688 | |
| 689 | /* sst49lf040.c */ |
Uwe Hermann | a0cc53d | 2007-09-09 20:24:29 +0000 | [diff] [blame] | 690 | int erase_49lf040(struct flashchip *flash); |
| 691 | int write_49lf040(struct flashchip *flash, uint8_t *buf); |
Uwe Hermann | 0846f89 | 2007-08-23 13:34:59 +0000 | [diff] [blame] | 692 | |
| 693 | /* sst49lfxxxc.c */ |
Uwe Hermann | a0cc53d | 2007-09-09 20:24:29 +0000 | [diff] [blame] | 694 | int probe_49lfxxxc(struct flashchip *flash); |
| 695 | int erase_49lfxxxc(struct flashchip *flash); |
| 696 | int write_49lfxxxc(struct flashchip *flash, uint8_t *buf); |
Uwe Hermann | 0846f89 | 2007-08-23 13:34:59 +0000 | [diff] [blame] | 697 | |
| 698 | /* sst_fwhub.c */ |
Uwe Hermann | a0cc53d | 2007-09-09 20:24:29 +0000 | [diff] [blame] | 699 | int probe_sst_fwhub(struct flashchip *flash); |
| 700 | int erase_sst_fwhub(struct flashchip *flash); |
Carl-Daniel Hailfinger | a06287c | 2009-09-23 22:01:33 +0000 | [diff] [blame] | 701 | int erase_sst_fwhub_block(struct flashchip *flash, unsigned int offset, unsigned int page_size); |
Uwe Hermann | a0cc53d | 2007-09-09 20:24:29 +0000 | [diff] [blame] | 702 | int write_sst_fwhub(struct flashchip *flash, uint8_t *buf); |
Uwe Hermann | 0846f89 | 2007-08-23 13:34:59 +0000 | [diff] [blame] | 703 | |
Peter Stuge | cce2682 | 2008-07-21 17:48:40 +0000 | [diff] [blame] | 704 | /* w39v040c.c */ |
| 705 | int probe_w39v040c(struct flashchip *flash); |
| 706 | int erase_w39v040c(struct flashchip *flash); |
| 707 | int write_w39v040c(struct flashchip *flash, uint8_t *buf); |
| 708 | |
Stefan Reinauer | ac37897 | 2008-03-17 22:59:40 +0000 | [diff] [blame] | 709 | /* w39V080fa.c */ |
| 710 | int probe_winbond_fwhub(struct flashchip *flash); |
| 711 | int erase_winbond_fwhub(struct flashchip *flash); |
| 712 | int write_winbond_fwhub(struct flashchip *flash, uint8_t *buf); |
| 713 | |
Markus Boas | d2ac6fc | 2007-08-30 10:17:50 +0000 | [diff] [blame] | 714 | /* w29ee011.c */ |
Uwe Hermann | a0cc53d | 2007-09-09 20:24:29 +0000 | [diff] [blame] | 715 | int probe_w29ee011(struct flashchip *flash); |
Markus Boas | d2ac6fc | 2007-08-30 10:17:50 +0000 | [diff] [blame] | 716 | |
Uwe Hermann | 0846f89 | 2007-08-23 13:34:59 +0000 | [diff] [blame] | 717 | /* w49f002u.c */ |
Uwe Hermann | a0cc53d | 2007-09-09 20:24:29 +0000 | [diff] [blame] | 718 | int write_49f002(struct flashchip *flash, uint8_t *buf); |
Stefan Reinauer | ff4f197 | 2007-05-24 08:48:10 +0000 | [diff] [blame] | 719 | |
Peter Stuge | bf196e9 | 2009-01-26 03:08:45 +0000 | [diff] [blame] | 720 | /* wbsio_spi.c */ |
| 721 | int wbsio_check_for_spi(const char *name); |
Carl-Daniel Hailfinger | d047829 | 2009-07-10 21:08:55 +0000 | [diff] [blame] | 722 | int wbsio_spi_send_command(unsigned int writecnt, unsigned int readcnt, |
Uwe Hermann | d1129ac | 2009-05-28 15:07:42 +0000 | [diff] [blame] | 723 | const unsigned char *writearr, unsigned char *readarr); |
Carl-Daniel Hailfinger | cbf563c | 2009-06-16 08:55:44 +0000 | [diff] [blame] | 724 | 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] | 725 | int wbsio_spi_write_1(struct flashchip *flash, uint8_t *buf); |
Peter Stuge | bf196e9 | 2009-01-26 03:08:45 +0000 | [diff] [blame] | 726 | |
Claus Gindhart | a7b3551 | 2008-04-28 17:51:09 +0000 | [diff] [blame] | 727 | /* stm50flw0x0x.c */ |
| 728 | int probe_stm50flw0x0x(struct flashchip *flash); |
| 729 | int erase_stm50flw0x0x(struct flashchip *flash); |
| 730 | int write_stm50flw0x0x(struct flashchip *flash, uint8_t *buf); |
Dominik Geyer | b46acba | 2008-05-16 12:55:55 +0000 | [diff] [blame] | 731 | |
Urja Rannikko | 2291535 | 2009-06-23 11:33:43 +0000 | [diff] [blame] | 732 | /* serprog.c */ |
Urja Rannikko | 2291535 | 2009-06-23 11:33:43 +0000 | [diff] [blame] | 733 | int serprog_init(void); |
| 734 | int serprog_shutdown(void); |
| 735 | void serprog_chip_writeb(uint8_t val, chipaddr addr); |
| 736 | uint8_t serprog_chip_readb(const chipaddr addr); |
| 737 | void serprog_chip_readn(uint8_t *buf, const chipaddr addr, size_t len); |
| 738 | void serprog_delay(int delay); |
Carl-Daniel Hailfinger | e51ea10 | 2009-11-23 19:20:11 +0000 | [diff] [blame^] | 739 | |
| 740 | /* serial.c */ |
Carl-Daniel Hailfinger | a4a9bfb | 2009-11-21 11:02:48 +0000 | [diff] [blame] | 741 | void sp_flush_incoming(void); |
| 742 | int sp_openserport(char *dev, unsigned int baud); |
Carl-Daniel Hailfinger | e51ea10 | 2009-11-23 19:20:11 +0000 | [diff] [blame^] | 743 | void __attribute__((noreturn)) sp_die(char *msg); |
Carl-Daniel Hailfinger | a4a9bfb | 2009-11-21 11:02:48 +0000 | [diff] [blame] | 744 | extern int sp_fd; |
Uwe Hermann | 1432a60 | 2009-06-28 23:26:37 +0000 | [diff] [blame] | 745 | |
Ollie Lho | 761bf1b | 2004-03-20 16:46:10 +0000 | [diff] [blame] | 746 | #endif /* !__FLASH_H__ */ |