blob: aee95a363f226092ee153c98268b4d68138c4f61 [file] [log] [blame]
Adam Kaufman064b1f22007-02-06 19:47:50 +00001/*
Uwe Hermannd1107642007-08-29 17:52:32 +00002 * This file is part of the flashrom project.
Adam Kaufman064b1f22007-02-06 19:47:50 +00003 *
Uwe Hermannd22a1d42007-09-09 20:21:05 +00004 * Copyright (C) 2000 Silicon Integrated System Corporation
5 * Copyright (C) 2000 Ronald G. Minnich <rminnich@gmail.com>
Stefan Reinauer8fa64812009-08-12 09:27:45 +00006 * Copyright (C) 2005-2009 coresystems GmbH
Carl-Daniel Hailfingera0a6ae92009-06-15 12:10:57 +00007 * Copyright (C) 2006-2009 Carl-Daniel Hailfinger
Adam Kaufman064b1f22007-02-06 19:47:50 +00008 *
Uwe Hermannd1107642007-08-29 17:52:32 +00009 * 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 Kaufman064b1f22007-02-06 19:47:50 +000013 *
Uwe Hermannd1107642007-08-29 17:52:32 +000014 * 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 Kaufman064b1f22007-02-06 19:47:50 +000018 *
Uwe Hermannd1107642007-08-29 17:52:32 +000019 * 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 Kaufman064b1f22007-02-06 19:47:50 +000022 */
23
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +000024#ifndef __FLASH_H__
25#define __FLASH_H__ 1
26
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +000027#include <unistd.h>
Ollie Lho184a4042005-11-26 21:55:36 +000028#include <stdint.h>
Uwe Hermann0846f892007-08-23 13:34:59 +000029#include <stdio.h>
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +000030#include "hwaccess.h"
Patrick Georgie48654c2010-01-06 22:14:39 +000031#ifdef _WIN32
32#include <windows.h>
33#undef min
34#undef max
35#endif
Andriy Gapon65c1b862008-05-22 13:22:45 +000036
Carl-Daniel Hailfinger5820f422009-05-16 21:22:56 +000037typedef unsigned long chipaddr;
38
Carl-Daniel Hailfinger415e5132009-08-12 11:39:29 +000039enum programmer {
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +000040#if INTERNAL_SUPPORT == 1
Carl-Daniel Hailfinger415e5132009-08-12 11:39:29 +000041 PROGRAMMER_INTERNAL,
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +000042#endif
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +000043#if DUMMY_SUPPORT == 1
Carl-Daniel Hailfinger415e5132009-08-12 11:39:29 +000044 PROGRAMMER_DUMMY,
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +000045#endif
46#if NIC3COM_SUPPORT == 1
Carl-Daniel Hailfinger415e5132009-08-12 11:39:29 +000047 PROGRAMMER_NIC3COM,
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +000048#endif
Uwe Hermann2bc98f62009-09-30 18:29:55 +000049#if GFXNVIDIA_SUPPORT == 1
50 PROGRAMMER_GFXNVIDIA,
51#endif
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +000052#if DRKAISER_SUPPORT == 1
TURBO Jb0912c02009-09-02 23:00:46 +000053 PROGRAMMER_DRKAISER,
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +000054#endif
55#if SATASII_SUPPORT == 1
Carl-Daniel Hailfinger415e5132009-08-12 11:39:29 +000056 PROGRAMMER_SATASII,
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +000057#endif
Uwe Hermannddd5c9e2010-02-21 21:17:00 +000058#if ATAHPT_SUPPORT == 1
59 PROGRAMMER_ATAHPT,
60#endif
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +000061#if INTERNAL_SUPPORT == 1
Carl-Daniel Hailfinger415e5132009-08-12 11:39:29 +000062 PROGRAMMER_IT87SPI,
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +000063#endif
Carl-Daniel Hailfinger3426ef62009-08-19 13:27:58 +000064#if FT2232_SPI_SUPPORT == 1
Carl-Daniel Hailfinger415e5132009-08-12 11:39:29 +000065 PROGRAMMER_FT2232SPI,
Carl-Daniel Hailfinger3426ef62009-08-19 13:27:58 +000066#endif
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +000067#if SERPROG_SUPPORT == 1
Carl-Daniel Hailfinger415e5132009-08-12 11:39:29 +000068 PROGRAMMER_SERPROG,
Carl-Daniel Hailfinger6be74112009-08-12 16:17:41 +000069#endif
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +000070#if BUSPIRATE_SPI_SUPPORT == 1
71 PROGRAMMER_BUSPIRATESPI,
72#endif
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +000073#if DEDIPROG_SUPPORT == 1
74 PROGRAMMER_DEDIPROG,
75#endif
Carl-Daniel Hailfinger37fc4692009-08-12 14:34:35 +000076 PROGRAMMER_INVALID /* This must always be the last entry. */
Carl-Daniel Hailfinger415e5132009-08-12 11:39:29 +000077};
78
79extern enum programmer programmer;
Carl-Daniel Hailfinger702218d2009-05-08 17:43:22 +000080
81struct programmer_entry {
82 const char *vendor;
83 const char *name;
84
85 int (*init) (void);
86 int (*shutdown) (void);
87
Uwe Hermannd1129ac2009-05-28 15:07:42 +000088 void * (*map_flash_region) (const char *descr, unsigned long phys_addr,
89 size_t len);
Carl-Daniel Hailfinger1455b2b2009-05-11 14:13:25 +000090 void (*unmap_flash_region) (void *virt_addr, size_t len);
91
Carl-Daniel Hailfinger5820f422009-05-16 21:22:56 +000092 void (*chip_writeb) (uint8_t val, chipaddr addr);
93 void (*chip_writew) (uint16_t val, chipaddr addr);
94 void (*chip_writel) (uint32_t val, chipaddr addr);
Carl-Daniel Hailfinger0bd2a2b2009-06-05 18:32:07 +000095 void (*chip_writen) (uint8_t *buf, chipaddr addr, size_t len);
Carl-Daniel Hailfinger5820f422009-05-16 21:22:56 +000096 uint8_t (*chip_readb) (const chipaddr addr);
97 uint16_t (*chip_readw) (const chipaddr addr);
98 uint32_t (*chip_readl) (const chipaddr addr);
Carl-Daniel Hailfinger0bd2a2b2009-06-05 18:32:07 +000099 void (*chip_readn) (uint8_t *buf, const chipaddr addr, size_t len);
Carl-Daniel Hailfingerca8bfc62009-06-05 17:48:08 +0000100 void (*delay) (int usecs);
Carl-Daniel Hailfinger702218d2009-05-08 17:43:22 +0000101};
102
103extern const struct programmer_entry programmer_table[];
104
Carl-Daniel Hailfingercc389fc2010-02-14 01:20:28 +0000105int register_shutdown(void (*function) (void *data), void *data);
106
Uwe Hermann09e04f72009-05-16 22:36:00 +0000107int programmer_init(void);
108int programmer_shutdown(void);
109void *programmer_map_flash_region(const char *descr, unsigned long phys_addr,
110 size_t len);
111void programmer_unmap_flash_region(void *virt_addr, size_t len);
112void chip_writeb(uint8_t val, chipaddr addr);
113void chip_writew(uint16_t val, chipaddr addr);
114void chip_writel(uint32_t val, chipaddr addr);
Carl-Daniel Hailfinger0bd2a2b2009-06-05 18:32:07 +0000115void chip_writen(uint8_t *buf, chipaddr addr, size_t len);
Uwe Hermann09e04f72009-05-16 22:36:00 +0000116uint8_t chip_readb(const chipaddr addr);
117uint16_t chip_readw(const chipaddr addr);
118uint32_t chip_readl(const chipaddr addr);
Carl-Daniel Hailfinger0bd2a2b2009-06-05 18:32:07 +0000119void chip_readn(uint8_t *buf, const chipaddr addr, size_t len);
Carl-Daniel Hailfingerca8bfc62009-06-05 17:48:08 +0000120void programmer_delay(int usecs);
Carl-Daniel Hailfinger61a8bd22009-03-05 19:24:22 +0000121
Carl-Daniel Hailfinger3a4781e2009-10-01 14:51:25 +0000122enum bitbang_spi_master {
123 BITBANG_SPI_INVALID /* This must always be the last entry. */
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000124};
125
Carl-Daniel Hailfinger3a4781e2009-10-01 14:51:25 +0000126extern const int bitbang_spi_master_count;
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000127
Carl-Daniel Hailfinger3a4781e2009-10-01 14:51:25 +0000128extern enum bitbang_spi_master bitbang_spi_master;
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000129
Carl-Daniel Hailfinger3a4781e2009-10-01 14:51:25 +0000130struct bitbang_spi_master_entry {
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000131 void (*set_cs) (int val);
132 void (*set_sck) (int val);
133 void (*set_mosi) (int val);
134 int (*get_miso) (void);
135};
136
Uwe Hermanne5ac1642008-03-12 11:54:51 +0000137#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
138
Carl-Daniel Hailfinger1dfe0ff2009-05-31 17:57:34 +0000139enum chipbustype {
Carl-Daniel Hailfinger3504b532009-06-01 00:02:11 +0000140 CHIP_BUSTYPE_NONE = 0,
Carl-Daniel Hailfinger1dfe0ff2009-05-31 17:57:34 +0000141 CHIP_BUSTYPE_PARALLEL = 1 << 0,
142 CHIP_BUSTYPE_LPC = 1 << 1,
143 CHIP_BUSTYPE_FWH = 1 << 2,
144 CHIP_BUSTYPE_SPI = 1 << 3,
145 CHIP_BUSTYPE_NONSPI = CHIP_BUSTYPE_PARALLEL | CHIP_BUSTYPE_LPC | CHIP_BUSTYPE_FWH,
146 CHIP_BUSTYPE_UNKNOWN = CHIP_BUSTYPE_PARALLEL | CHIP_BUSTYPE_LPC | CHIP_BUSTYPE_FWH | CHIP_BUSTYPE_SPI,
147};
148
Carl-Daniel Hailfingerf38431a2009-09-05 02:30:58 +0000149/*
150 * How many different contiguous runs of erase blocks with one size each do
151 * we have for a given erase function?
152 */
153#define NUM_ERASEREGIONS 5
154
155/*
156 * How many different erase functions do we have per chip?
157 */
158#define NUM_ERASEFUNCTIONS 5
159
Carl-Daniel Hailfinger4bf4e792010-01-09 03:15:50 +0000160#define FEATURE_REGISTERMAP (1 << 0)
161#define FEATURE_BYTEWRITES (1 << 1)
Sean Nelson35727f72010-01-28 23:55:12 +0000162#define FEATURE_LONG_RESET (0 << 4)
163#define FEATURE_SHORT_RESET (1 << 4)
164#define FEATURE_EITHER_RESET FEATURE_LONG_RESET
Carl-Daniel Hailfinger4bf4e792010-01-09 03:15:50 +0000165#define FEATURE_ADDR_FULL (0 << 2)
166#define FEATURE_ADDR_MASK (3 << 2)
Sean Nelson35727f72010-01-28 23:55:12 +0000167#define FEATURE_ADDR_2AA (1 << 2)
168#define FEATURE_ADDR_AAA (2 << 2)
169#define FEATURE_ADDR_SHIFTED 0
Sean Nelsonc57a9202010-01-04 17:15:23 +0000170
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +0000171struct flashchip {
Uwe Hermann76158682008-03-14 23:55:58 +0000172 const char *vendor;
Uwe Hermann372eeb52007-12-04 21:49:06 +0000173 const char *name;
Carl-Daniel Hailfinger1dfe0ff2009-05-31 17:57:34 +0000174
175 enum chipbustype bustype;
176
Uwe Hermann394131e2008-10-18 21:14:13 +0000177 /*
178 * With 32bit manufacture_id and model_id we can cover IDs up to
Carl-Daniel Hailfingerae8afa92007-12-31 01:49:00 +0000179 * (including) the 4th bank of JEDEC JEP106W Standard Manufacturer's
180 * Identification code.
181 */
182 uint32_t manufacture_id;
183 uint32_t model_id;
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +0000184
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +0000185 int total_size;
186 int page_size;
Sean Nelsonc57a9202010-01-04 17:15:23 +0000187 int feature_bits;
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +0000188
Uwe Hermann394131e2008-10-18 21:14:13 +0000189 /*
190 * Indicate if flashrom has been tested with this flash chip and if
Peter Stuge1159d582008-05-03 04:34:37 +0000191 * everything worked correctly.
192 */
193 uint32_t tested;
194
Uwe Hermann0b7afe62007-04-01 19:44:21 +0000195 int (*probe) (struct flashchip *flash);
Maciej Pijankac6e11112009-06-03 14:46:22 +0000196
197 /* Delay after "enter/exit ID mode" commands in microseconds. */
198 int probe_timing;
Carl-Daniel Hailfingerf38431a2009-09-05 02:30:58 +0000199
200 /*
Carl-Daniel Hailfinger63ce4bb2009-12-22 13:04:53 +0000201 * Erase blocks and associated erase function. Any chip erase function
202 * is stored as chip-sized virtual block together with said function.
Carl-Daniel Hailfingerf38431a2009-09-05 02:30:58 +0000203 */
204 struct block_eraser {
205 struct eraseblock{
206 unsigned int size; /* Eraseblock size */
207 unsigned int count; /* Number of contiguous blocks with that size */
208 } eraseblocks[NUM_ERASEREGIONS];
209 int (*block_erase) (struct flashchip *flash, unsigned int blockaddr, unsigned int blocklen);
210 } block_erasers[NUM_ERASEFUNCTIONS];
211
Sean Nelson6e0b9122010-02-19 00:52:10 +0000212 int (*printlock) (struct flashchip *flash);
213 int (*unlock) (struct flashchip *flash);
Uwe Hermann0b7afe62007-04-01 19:44:21 +0000214 int (*write) (struct flashchip *flash, uint8_t *buf);
Carl-Daniel Hailfingercbf563c2009-06-16 08:55:44 +0000215 int (*read) (struct flashchip *flash, uint8_t *buf, int start, int len);
Ronald G. Minnicheaab50b2003-09-12 22:41:53 +0000216
Uwe Hermann372eeb52007-12-04 21:49:06 +0000217 /* Some flash devices have an additional register space. */
Carl-Daniel Hailfinger5820f422009-05-16 21:22:56 +0000218 chipaddr virtual_memory;
219 chipaddr virtual_registers;
Ronald G. Minnich5e5f75e2002-01-29 18:21:41 +0000220};
221
Peter Stuge1159d582008-05-03 04:34:37 +0000222#define TEST_UNTESTED 0
223
Uwe Hermannd1129ac2009-05-28 15:07:42 +0000224#define TEST_OK_PROBE (1 << 0)
225#define TEST_OK_READ (1 << 1)
226#define TEST_OK_ERASE (1 << 2)
227#define TEST_OK_WRITE (1 << 3)
228#define TEST_OK_PR (TEST_OK_PROBE | TEST_OK_READ)
229#define TEST_OK_PRE (TEST_OK_PROBE | TEST_OK_READ | TEST_OK_ERASE)
Carl-Daniel Hailfingera06287c2009-09-23 22:01:33 +0000230#define TEST_OK_PRW (TEST_OK_PROBE | TEST_OK_READ | TEST_OK_WRITE)
Uwe Hermannd1129ac2009-05-28 15:07:42 +0000231#define TEST_OK_PREW (TEST_OK_PROBE | TEST_OK_READ | TEST_OK_ERASE | TEST_OK_WRITE)
Peter Stuge1159d582008-05-03 04:34:37 +0000232#define TEST_OK_MASK 0x0f
233
Uwe Hermannd1129ac2009-05-28 15:07:42 +0000234#define TEST_BAD_PROBE (1 << 4)
235#define TEST_BAD_READ (1 << 5)
236#define TEST_BAD_ERASE (1 << 6)
237#define TEST_BAD_WRITE (1 << 7)
238#define TEST_BAD_PREW (TEST_BAD_PROBE | TEST_BAD_READ | TEST_BAD_ERASE | TEST_BAD_WRITE)
Peter Stuge1159d582008-05-03 04:34:37 +0000239#define TEST_BAD_MASK 0xf0
240
Maciej Pijankac6e11112009-06-03 14:46:22 +0000241/* Timing used in probe routines. ZERO is -2 to differentiate between an unset
242 * field and zero delay.
243 *
244 * SPI devices will always have zero delay and ignore this field.
245 */
246#define TIMING_FIXME -1
247/* this is intentionally same value as fixme */
248#define TIMING_IGNORED -1
249#define TIMING_ZERO -2
250
Ollie Lho184a4042005-11-26 21:55:36 +0000251extern struct flashchip flashchips[];
252
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000253#if INTERNAL_SUPPORT == 1
Uwe Hermann05fab752009-05-16 23:42:17 +0000254struct penable {
255 uint16_t vendor_id;
256 uint16_t device_id;
257 int status;
258 const char *vendor_name;
259 const char *device_name;
260 int (*doit) (struct pci_dev *dev, const char *name);
261};
262
263extern const struct penable chipset_enables[];
264
265struct board_pciid_enable {
266 /* Any device, but make it sensible, like the ISA bridge. */
267 uint16_t first_vendor;
268 uint16_t first_device;
269 uint16_t first_card_vendor;
270 uint16_t first_card_device;
271
272 /* Any device, but make it sensible, like
273 * the host bridge. May be NULL.
274 */
275 uint16_t second_vendor;
276 uint16_t second_device;
277 uint16_t second_card_vendor;
278 uint16_t second_card_device;
279
Michael Karcher6701ee82010-01-20 14:14:11 +0000280 /* Pattern to match DMI entries */
281 const char *dmi_pattern;
282
Uwe Hermann05fab752009-05-16 23:42:17 +0000283 /* The vendor / part name from the coreboot table. */
284 const char *lb_vendor;
285 const char *lb_part;
286
287 const char *vendor_name;
288 const char *board_name;
289
Luc Verhaegen93938c32010-01-20 14:45:03 +0000290 int max_rom_decode_parallel;
Michael Karcher0bdc0922010-02-28 01:33:48 +0000291 int status;
Uwe Hermann05fab752009-05-16 23:42:17 +0000292 int (*enable) (const char *name);
293};
294
295extern struct board_pciid_enable board_pciid_enables[];
296
297struct board_info {
298 const char *vendor;
299 const char *name;
300};
301
302extern const struct board_info boards_ok[];
303extern const struct board_info boards_bad[];
Uwe Hermanne1aa75e2009-06-18 14:04:44 +0000304extern const struct board_info laptops_ok[];
305extern const struct board_info laptops_bad[];
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000306#endif
Uwe Hermann05fab752009-05-16 23:42:17 +0000307
Uwe Hermann372eeb52007-12-04 21:49:06 +0000308/* udelay.c */
Carl-Daniel Hailfingerca8bfc62009-06-05 17:48:08 +0000309void myusec_delay(int usecs);
Carl-Daniel Hailfinger43634392009-05-01 12:22:17 +0000310void myusec_calibrate_delay(void);
Carl-Daniel Hailfinger36cc1c82009-12-24 03:11:55 +0000311void internal_delay(int usecs);
Luc Verhaegen8e3a6002007-04-04 22:45:58 +0000312
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000313#if NEED_PCI == 1
Uwe Hermann515ab3d2009-05-15 17:02:34 +0000314/* pcidev.c */
Rudolf Marek68720c72009-05-17 19:39:27 +0000315
Uwe Hermann515ab3d2009-05-15 17:02:34 +0000316extern uint32_t io_base_addr;
317extern struct pci_access *pacc;
Uwe Hermann8403ccb2009-05-16 21:39:19 +0000318extern struct pci_dev *pcidev_dev;
Uwe Hermann515ab3d2009-05-15 17:02:34 +0000319struct pcidev_status {
320 uint16_t vendor_id;
321 uint16_t device_id;
322 int status;
323 const char *vendor_name;
324 const char *device_name;
325};
TURBO Jb0912c02009-09-02 23:00:46 +0000326uint32_t pcidev_validate(struct pci_dev *dev, uint32_t bar, struct pcidev_status *devs);
327uint32_t pcidev_init(uint16_t vendor_id, uint32_t bar, struct pcidev_status *devs, char *pcidev_bdf);
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000328#endif
Uwe Hermannba290d12009-06-17 12:07:12 +0000329
330/* print.c */
331char *flashbuses_to_text(enum chipbustype bustype);
Carl-Daniel Hailfingerf5292052009-11-17 09:57:34 +0000332void print_supported(void);
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000333#if (NIC3COM_SUPPORT == 1) || (GFXNVIDIA_SUPPORT == 1) || (DRKAISER_SUPPORT == 1) || (SATASII_SUPPORT == 1) || (ATAHPT_SUPPORT == 1)
Uwe Hermann515ab3d2009-05-15 17:02:34 +0000334void print_supported_pcidevs(struct pcidev_status *devs);
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000335#endif
Carl-Daniel Hailfingerf5292052009-11-17 09:57:34 +0000336void print_supported_wiki(void);
Uwe Hermann515ab3d2009-05-15 17:02:34 +0000337
Uwe Hermann372eeb52007-12-04 21:49:06 +0000338/* board_enable.c */
Peter Stuge9d9399c2009-01-26 02:34:51 +0000339void w836xx_ext_enter(uint16_t port);
340void w836xx_ext_leave(uint16_t port);
Carl-Daniel Hailfinger24c1a162009-05-25 23:26:50 +0000341uint8_t sio_read(uint16_t port, uint8_t reg);
342void sio_write(uint16_t port, uint8_t reg, uint8_t data);
343void sio_mask(uint16_t port, uint8_t reg, uint8_t data, uint8_t mask);
Uwe Hermann372eeb52007-12-04 21:49:06 +0000344int board_flash_enable(const char *vendor, const char *part);
Adam Kaufman064b1f22007-02-06 19:47:50 +0000345
Uwe Hermann372eeb52007-12-04 21:49:06 +0000346/* chipset_enable.c */
347int chipset_flash_enable(void);
Stefan Reinauer9a6d1762008-12-03 21:24:40 +0000348
Stefan Reinauer0593f212009-01-26 01:10:48 +0000349/* physmap.c */
350void *physmap(const char *descr, unsigned long phys_addr, size_t len);
Carl-Daniel Hailfingerbaaffe02010-02-02 11:09:03 +0000351void *physmap_try_ro(const char *descr, unsigned long phys_addr, size_t len);
Stefan Reinauer0593f212009-01-26 01:10:48 +0000352void physunmap(void *virt_addr, size_t len);
Stefan Reinauer8fa64812009-08-12 09:27:45 +0000353int setup_cpu_msr(int cpu);
354void cleanup_cpu_msr(void);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000355
356/* cbtable.c */
357void lb_vendor_dev_from_string(char *boardstring);
358int coreboot_init(void);
359extern char *lb_part, *lb_vendor;
360extern int partvendor_from_cbtable;
Stefan Reinauer0593f212009-01-26 01:10:48 +0000361
Michael Karcher6701ee82010-01-20 14:14:11 +0000362/* dmi.c */
363extern int has_dmi_support;
364void dmi_init(void);
365int dmi_match(const char *pattern);
366
Carl-Daniel Hailfinger702218d2009-05-08 17:43:22 +0000367/* internal.c */
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000368#if NEED_PCI == 1
Carl-Daniel Hailfinger14e100c2009-12-22 23:42:04 +0000369struct superio {
370 uint16_t vendor;
371 uint16_t port;
372 uint16_t model;
373};
374extern struct superio superio;
375#define SUPERIO_VENDOR_NONE 0x0
376#define SUPERIO_VENDOR_ITE 0x1
Uwe Hermann2cac6862009-05-16 22:05:42 +0000377struct pci_dev *pci_dev_find_filter(struct pci_filter filter);
Carl-Daniel Hailfinger9f46cfc2009-11-15 17:13:29 +0000378struct pci_dev *pci_dev_find_vendorclass(uint16_t vendor, uint16_t class);
Uwe Hermann2cac6862009-05-16 22:05:42 +0000379struct pci_dev *pci_dev_find(uint16_t vendor, uint16_t device);
380struct pci_dev *pci_card_find(uint16_t vendor, uint16_t device,
381 uint16_t card_vendor, uint16_t card_device);
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000382#endif
Carl-Daniel Hailfinger3b7e75a2009-05-14 21:41:10 +0000383void get_io_perms(void);
Carl-Daniel Hailfingerdb41c592009-08-09 21:50:24 +0000384void release_io_perms(void);
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000385#if INTERNAL_SUPPORT == 1
Michael Karcher8c1df282010-02-26 09:51:20 +0000386extern int is_laptop;
Michael Karcher0bdc0922010-02-28 01:33:48 +0000387extern int force_boardenable;
Carl-Daniel Hailfinger14e100c2009-12-22 23:42:04 +0000388void probe_superio(void);
Carl-Daniel Hailfinger702218d2009-05-08 17:43:22 +0000389int internal_init(void);
390int internal_shutdown(void);
Carl-Daniel Hailfinger5820f422009-05-16 21:22:56 +0000391void internal_chip_writeb(uint8_t val, chipaddr addr);
392void internal_chip_writew(uint16_t val, chipaddr addr);
393void internal_chip_writel(uint32_t val, chipaddr addr);
394uint8_t internal_chip_readb(const chipaddr addr);
395uint16_t internal_chip_readw(const chipaddr addr);
396uint32_t internal_chip_readl(const chipaddr addr);
Carl-Daniel Hailfinger0bd2a2b2009-06-05 18:32:07 +0000397void internal_chip_readn(uint8_t *buf, const chipaddr addr, size_t len);
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000398#endif
Carl-Daniel Hailfinger78185dc2009-05-17 15:49:24 +0000399void mmio_writeb(uint8_t val, void *addr);
400void mmio_writew(uint16_t val, void *addr);
401void mmio_writel(uint32_t val, void *addr);
402uint8_t mmio_readb(void *addr);
403uint16_t mmio_readw(void *addr);
404uint32_t mmio_readl(void *addr);
Carl-Daniel Hailfingercc1802d2010-01-06 10:21:00 +0000405
406/* programmer.c */
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000407int noop_shutdown(void);
Uwe Hermannc6915932009-05-17 23:12:17 +0000408void *fallback_map(const char *descr, unsigned long phys_addr, size_t len);
409void fallback_unmap(void *virt_addr, size_t len);
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000410uint8_t noop_chip_readb(const chipaddr addr);
411void noop_chip_writeb(uint8_t val, chipaddr addr);
Carl-Daniel Hailfinger5820f422009-05-16 21:22:56 +0000412void fallback_chip_writew(uint16_t val, chipaddr addr);
413void fallback_chip_writel(uint32_t val, chipaddr addr);
Carl-Daniel Hailfinger0bd2a2b2009-06-05 18:32:07 +0000414void fallback_chip_writen(uint8_t *buf, chipaddr addr, size_t len);
Carl-Daniel Hailfinger5820f422009-05-16 21:22:56 +0000415uint16_t fallback_chip_readw(const chipaddr addr);
416uint32_t fallback_chip_readl(const chipaddr addr);
Carl-Daniel Hailfinger0bd2a2b2009-06-05 18:32:07 +0000417void fallback_chip_readn(uint8_t *buf, const chipaddr addr, size_t len);
Carl-Daniel Hailfinger702218d2009-05-08 17:43:22 +0000418
Carl-Daniel Hailfingerc3129202009-05-09 00:54:55 +0000419/* dummyflasher.c */
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000420#if DUMMY_SUPPORT == 1
Carl-Daniel Hailfingerc3129202009-05-09 00:54:55 +0000421int dummy_init(void);
422int dummy_shutdown(void);
Carl-Daniel Hailfinger1455b2b2009-05-11 14:13:25 +0000423void *dummy_map(const char *descr, unsigned long phys_addr, size_t len);
424void dummy_unmap(void *virt_addr, size_t len);
Carl-Daniel Hailfinger5820f422009-05-16 21:22:56 +0000425void dummy_chip_writeb(uint8_t val, chipaddr addr);
426void dummy_chip_writew(uint16_t val, chipaddr addr);
427void dummy_chip_writel(uint32_t val, chipaddr addr);
Carl-Daniel Hailfinger0bd2a2b2009-06-05 18:32:07 +0000428void dummy_chip_writen(uint8_t *buf, chipaddr addr, size_t len);
Carl-Daniel Hailfinger5820f422009-05-16 21:22:56 +0000429uint8_t dummy_chip_readb(const chipaddr addr);
430uint16_t dummy_chip_readw(const chipaddr addr);
431uint32_t dummy_chip_readl(const chipaddr addr);
Carl-Daniel Hailfinger0bd2a2b2009-06-05 18:32:07 +0000432void dummy_chip_readn(uint8_t *buf, const chipaddr addr, size_t len);
Carl-Daniel Hailfingerd0478292009-07-10 21:08:55 +0000433int dummy_spi_send_command(unsigned int writecnt, unsigned int readcnt,
Carl-Daniel Hailfingerbfe2e0c2009-05-14 12:59:36 +0000434 const unsigned char *writearr, unsigned char *readarr);
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000435#endif
Carl-Daniel Hailfingerc3129202009-05-09 00:54:55 +0000436
Uwe Hermannb4dcb712009-05-13 11:36:06 +0000437/* nic3com.c */
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000438#if NIC3COM_SUPPORT == 1
Uwe Hermannb4dcb712009-05-13 11:36:06 +0000439int nic3com_init(void);
440int nic3com_shutdown(void);
Carl-Daniel Hailfinger5820f422009-05-16 21:22:56 +0000441void nic3com_chip_writeb(uint8_t val, chipaddr addr);
442uint8_t nic3com_chip_readb(const chipaddr addr);
Uwe Hermann515ab3d2009-05-15 17:02:34 +0000443extern struct pcidev_status nics_3com[];
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000444#endif
Uwe Hermannb4dcb712009-05-13 11:36:06 +0000445
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000446/* gfxnvidia.c */
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000447#if GFXNVIDIA_SUPPORT == 1
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000448int gfxnvidia_init(void);
449int gfxnvidia_shutdown(void);
450void gfxnvidia_chip_writeb(uint8_t val, chipaddr addr);
451uint8_t gfxnvidia_chip_readb(const chipaddr addr);
452extern struct pcidev_status gfx_nvidia[];
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000453#endif
Uwe Hermann2bc98f62009-09-30 18:29:55 +0000454
TURBO Jb0912c02009-09-02 23:00:46 +0000455/* drkaiser.c */
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000456#if DRKAISER_SUPPORT == 1
TURBO Jb0912c02009-09-02 23:00:46 +0000457int drkaiser_init(void);
458int drkaiser_shutdown(void);
459void drkaiser_chip_writeb(uint8_t val, chipaddr addr);
460uint8_t drkaiser_chip_readb(const chipaddr addr);
461extern struct pcidev_status drkaiser_pcidev[];
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000462#endif
TURBO Jb0912c02009-09-02 23:00:46 +0000463
Rudolf Marek68720c72009-05-17 19:39:27 +0000464/* satasii.c */
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000465#if SATASII_SUPPORT == 1
Rudolf Marek68720c72009-05-17 19:39:27 +0000466int satasii_init(void);
467int satasii_shutdown(void);
Rudolf Marek68720c72009-05-17 19:39:27 +0000468void satasii_chip_writeb(uint8_t val, chipaddr addr);
469uint8_t satasii_chip_readb(const chipaddr addr);
470extern struct pcidev_status satas_sii[];
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000471#endif
Rudolf Marek68720c72009-05-17 19:39:27 +0000472
Uwe Hermannddd5c9e2010-02-21 21:17:00 +0000473/* atahpt.c */
474#if ATAHPT_SUPPORT == 1
475int atahpt_init(void);
476int atahpt_shutdown(void);
477void atahpt_chip_writeb(uint8_t val, chipaddr addr);
478uint8_t atahpt_chip_readb(const chipaddr addr);
479extern struct pcidev_status ata_hpt[];
480#endif
481
Paul Fox05dfbe62009-06-16 21:08:06 +0000482/* ft2232_spi.c */
Carl-Daniel Hailfingerfeea2722009-07-01 00:02:23 +0000483#define FTDI_FT2232H 0x6010
484#define FTDI_FT4232H 0x6011
Paul Fox05dfbe62009-06-16 21:08:06 +0000485int ft2232_spi_init(void);
Carl-Daniel Hailfingerd0478292009-07-10 21:08:55 +0000486int ft2232_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr);
Paul Fox05dfbe62009-06-16 21:08:06 +0000487int ft2232_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
Paul Fox05dfbe62009-06-16 21:08:06 +0000488int ft2232_spi_write_256(struct flashchip *flash, uint8_t *buf);
489
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000490/* bitbang_spi.c */
Carl-Daniel Hailfinger3a4781e2009-10-01 14:51:25 +0000491extern int bitbang_spi_half_period;
492extern const struct bitbang_spi_master_entry bitbang_spi_master_table[];
Carl-Daniel Hailfinger547872b2009-09-28 13:15:16 +0000493int bitbang_spi_init(void);
494int bitbang_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr);
495int bitbang_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
496int bitbang_spi_write_256(struct flashchip *flash, uint8_t *buf);
497
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000498/* buspirate_spi.c */
Carl-Daniel Hailfingerd5b28fa2009-11-24 18:27:10 +0000499struct buspirate_spispeeds {
500 const char *name;
501 const int speed;
502};
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000503int buspirate_spi_init(void);
504int buspirate_spi_shutdown(void);
505int buspirate_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr);
506int buspirate_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
Carl-Daniel Hailfinger408e47a2010-03-22 03:30:58 +0000507int buspirate_spi_write_256(struct flashchip *flash, uint8_t *buf);
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000508
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000509/* dediprog.c */
510int dediprog_init(void);
511int dediprog_shutdown(void);
512int dediprog_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr);
513int dediprog_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
514
Uwe Hermann0846f892007-08-23 13:34:59 +0000515/* flashrom.c */
Carl-Daniel Hailfingere8e369f2010-03-08 00:42:32 +0000516enum write_granularity {
517 write_gran_1bit,
518 write_gran_1byte,
519 write_gran_256bytes,
520};
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000521extern enum chipbustype buses_supported;
522struct decode_sizes {
523 uint32_t parallel;
524 uint32_t lpc;
525 uint32_t fwh;
526 uint32_t spi;
527};
528extern struct decode_sizes max_rom_decode;
Carl-Daniel Hailfingeref58a9c2009-08-12 13:32:56 +0000529extern char *programmer_param;
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000530extern unsigned long flashbase;
Uwe Hermannad216bf2009-04-24 16:17:41 +0000531extern int verbose;
Carl-Daniel Hailfingera80cfbc2009-07-22 20:13:00 +0000532extern const char *flashrom_version;
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000533extern char *chip_to_probe;
Uwe Hermannad216bf2009-04-24 16:17:41 +0000534#define printf_debug(x...) { if (verbose) printf(x); }
Peter Stuge776d2022009-01-26 00:39:57 +0000535void map_flash_registers(struct flashchip *flash);
Carl-Daniel Hailfingercbf563c2009-06-16 08:55:44 +0000536int read_memmapped(struct flashchip *flash, uint8_t *buf, int start, int len);
Carl-Daniel Hailfingerf38431a2009-09-05 02:30:58 +0000537int erase_flash(struct flashchip *flash);
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000538struct flashchip *probe_flash(struct flashchip *first_flash, int force);
539int read_flash(struct flashchip *flash, char *filename);
540void check_chip_supported(struct flashchip *flash);
541int check_max_decode(enum chipbustype buses, uint32_t size);
Carl-Daniel Hailfinger38a059d2009-06-13 12:04:03 +0000542int min(int a, int b);
Carl-Daniel Hailfinger30f7cb22009-06-15 17:23:36 +0000543int max(int a, int b);
Carl-Daniel Hailfingerd5b28fa2009-11-24 18:27:10 +0000544char *extract_param(char **haystack, char *needle, char *delim);
Carl-Daniel Hailfinger30f7cb22009-06-15 17:23:36 +0000545int check_erased_range(struct flashchip *flash, int start, int len);
546int verify_range(struct flashchip *flash, uint8_t *cmpbuf, int start, int len, char *message);
Carl-Daniel Hailfingere8e369f2010-03-08 00:42:32 +0000547int need_erase(uint8_t *have, uint8_t *want, int len, enum write_granularity gran);
Uwe Hermannba290d12009-06-17 12:07:12 +0000548char *strcat_realloc(char *dest, const char *src);
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000549void print_version(void);
550int selfcheck(void);
Carl-Daniel Hailfinger552420b2009-12-24 02:15:55 +0000551int doit(struct flashchip *flash, int force, char *filename, int read_it, int write_it, int erase_it, int verify_it);
Uwe Hermannba290d12009-06-17 12:07:12 +0000552
553#define OK 0
554#define NT 1 /* Not tested */
Uwe Hermann0846f892007-08-23 13:34:59 +0000555
Sean Nelson51e97d72010-01-07 20:09:33 +0000556/* cli_output.c */
557int print(int type, const char *fmt, ...);
Carl-Daniel Hailfingerf8dda682010-01-09 03:22:31 +0000558#define MSG_ERROR 0
559#define MSG_INFO 1
560#define MSG_DEBUG 2
561#define MSG_BARF 3
562#define msg_gerr(...) print(MSG_ERROR, __VA_ARGS__) /* general errors */
563#define msg_perr(...) print(MSG_ERROR, __VA_ARGS__) /* programmer errors */
564#define msg_cerr(...) print(MSG_ERROR, __VA_ARGS__) /* chip errors */
565#define msg_ginfo(...) print(MSG_INFO, __VA_ARGS__) /* general info */
566#define msg_pinfo(...) print(MSG_INFO, __VA_ARGS__) /* programmer info */
567#define msg_cinfo(...) print(MSG_INFO, __VA_ARGS__) /* chip info */
568#define msg_gdbg(...) print(MSG_DEBUG, __VA_ARGS__) /* general debug */
569#define msg_pdbg(...) print(MSG_DEBUG, __VA_ARGS__) /* programmer debug */
570#define msg_cdbg(...) print(MSG_DEBUG, __VA_ARGS__) /* chip debug */
571#define msg_gspew(...) print(MSG_BARF, __VA_ARGS__) /* general debug barf */
572#define msg_pspew(...) print(MSG_BARF, __VA_ARGS__) /* programmer debug barf */
573#define msg_cspew(...) print(MSG_BARF, __VA_ARGS__) /* chip debug barf */
Sean Nelson51e97d72010-01-07 20:09:33 +0000574
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000575/* cli_classic.c */
576int cli_classic(int argc, char *argv[]);
577
Uwe Hermann0846f892007-08-23 13:34:59 +0000578/* layout.c */
Peter Stuge7ffbc6f2008-06-18 02:08:40 +0000579int show_id(uint8_t *bios, int size, int force);
Uwe Hermann0846f892007-08-23 13:34:59 +0000580int read_romlayout(char *name);
581int find_romentry(char *name);
Carl-Daniel Hailfingerf5fb51c2009-08-19 15:19:18 +0000582int handle_romentries(uint8_t *buffer, struct flashchip *flash);
Uwe Hermann0846f892007-08-23 13:34:59 +0000583
Carl-Daniel Hailfinger00f911e2007-10-15 21:44:47 +0000584/* spi.c */
Carl-Daniel Hailfinger1dfe0ff2009-05-31 17:57:34 +0000585enum spi_controller {
586 SPI_CONTROLLER_NONE,
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000587#if INTERNAL_SUPPORT == 1
Carl-Daniel Hailfinger1dfe0ff2009-05-31 17:57:34 +0000588 SPI_CONTROLLER_ICH7,
589 SPI_CONTROLLER_ICH9,
590 SPI_CONTROLLER_IT87XX,
591 SPI_CONTROLLER_SB600,
592 SPI_CONTROLLER_VIA,
593 SPI_CONTROLLER_WBSIO,
Carl-Daniel Hailfinger66ef4e52009-12-13 22:28:00 +0000594#endif
Carl-Daniel Hailfinger3426ef62009-08-19 13:27:58 +0000595#if FT2232_SPI_SUPPORT == 1
Paul Fox05dfbe62009-06-16 21:08:06 +0000596 SPI_CONTROLLER_FT2232,
Carl-Daniel Hailfinger3426ef62009-08-19 13:27:58 +0000597#endif
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000598#if DUMMY_SUPPORT == 1
Carl-Daniel Hailfinger1dfe0ff2009-05-31 17:57:34 +0000599 SPI_CONTROLLER_DUMMY,
Carl-Daniel Hailfinger4740c6f2009-09-16 10:09:21 +0000600#endif
Carl-Daniel Hailfinger5cca01f2009-11-24 00:20:03 +0000601#if BUSPIRATE_SPI_SUPPORT == 1
602 SPI_CONTROLLER_BUSPIRATE,
603#endif
Carl-Daniel Hailfingerd38fac82010-01-19 11:15:48 +0000604#if DEDIPROG_SUPPORT == 1
605 SPI_CONTROLLER_DEDIPROG,
606#endif
Carl-Daniel Hailfinger3426ef62009-08-19 13:27:58 +0000607 SPI_CONTROLLER_INVALID /* This must always be the last entry. */
Carl-Daniel Hailfinger1dfe0ff2009-05-31 17:57:34 +0000608};
Carl-Daniel Hailfinger3426ef62009-08-19 13:27:58 +0000609extern const int spi_programmer_count;
Carl-Daniel Hailfingerd0478292009-07-10 21:08:55 +0000610struct spi_command {
611 unsigned int writecnt;
612 unsigned int readcnt;
613 const unsigned char *writearr;
614 unsigned char *readarr;
615};
Carl-Daniel Hailfinger02487aa2009-07-22 15:36:50 +0000616struct spi_programmer {
617 int (*command)(unsigned int writecnt, unsigned int readcnt,
618 const unsigned char *writearr, unsigned char *readarr);
Carl-Daniel Hailfinger26f7e642009-09-18 15:50:56 +0000619 int (*multicommand)(struct spi_command *cmds);
Carl-Daniel Hailfinger02487aa2009-07-22 15:36:50 +0000620
621 /* Optimized functions for this programmer */
622 int (*read)(struct flashchip *flash, uint8_t *buf, int start, int len);
623 int (*write_256)(struct flashchip *flash, uint8_t *buf);
624};
Carl-Daniel Hailfingerd0478292009-07-10 21:08:55 +0000625
Carl-Daniel Hailfinger1dfe0ff2009-05-31 17:57:34 +0000626extern enum spi_controller spi_controller;
Carl-Daniel Hailfinger02487aa2009-07-22 15:36:50 +0000627extern const struct spi_programmer spi_programmer[];
Carl-Daniel Hailfinger1dfe0ff2009-05-31 17:57:34 +0000628extern void *spibar;
Carl-Daniel Hailfingerd0478292009-07-10 21:08:55 +0000629int spi_send_command(unsigned int writecnt, unsigned int readcnt,
Uwe Hermann394131e2008-10-18 21:14:13 +0000630 const unsigned char *writearr, unsigned char *readarr);
Carl-Daniel Hailfinger26f7e642009-09-18 15:50:56 +0000631int spi_send_multicommand(struct spi_command *cmds);
Carl-Daniel Hailfinger02487aa2009-07-22 15:36:50 +0000632int default_spi_send_command(unsigned int writecnt, unsigned int readcnt,
633 const unsigned char *writearr, unsigned char *readarr);
Carl-Daniel Hailfinger26f7e642009-09-18 15:50:56 +0000634int default_spi_send_multicommand(struct spi_command *cmds);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000635uint32_t spi_get_valid_read_addr(void);
Mats Erik Andersson44e1a192008-09-26 13:19:02 +0000636
Dominik Geyerb46acba2008-05-16 12:55:55 +0000637/* ichspi.c */
Carl-Daniel Hailfinger43634392009-05-01 12:22:17 +0000638int ich_init_opcodes(void);
Carl-Daniel Hailfingerd0478292009-07-10 21:08:55 +0000639int ich_spi_send_command(unsigned int writecnt, unsigned int readcnt,
Uwe Hermann394131e2008-10-18 21:14:13 +0000640 const unsigned char *writearr, unsigned char *readarr);
Carl-Daniel Hailfingercbf563c2009-06-16 08:55:44 +0000641int ich_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
Carl-Daniel Hailfinger96930c32009-05-09 02:30:21 +0000642int ich_spi_write_256(struct flashchip *flash, uint8_t * buf);
Carl-Daniel Hailfinger26f7e642009-09-18 15:50:56 +0000643int ich_spi_send_multicommand(struct spi_command *cmds);
Dominik Geyerb46acba2008-05-16 12:55:55 +0000644
Carl-Daniel Hailfingerbfe5b4a2008-05-13 23:03:12 +0000645/* it87spi.c */
646extern uint16_t it8716f_flashport;
Carl-Daniel Hailfinger24c1a162009-05-25 23:26:50 +0000647void enter_conf_mode_ite(uint16_t port);
648void exit_conf_mode_ite(uint16_t port);
Carl-Daniel Hailfinger14e100c2009-12-22 23:42:04 +0000649struct superio probe_superio_ite(void);
Carl-Daniel Hailfingerb8afecd2009-05-31 18:00:57 +0000650int it87spi_init(void);
Dominik Geyerb46acba2008-05-16 12:55:55 +0000651int it87xx_probe_spi_flash(const char *name);
Carl-Daniel Hailfingerd0478292009-07-10 21:08:55 +0000652int it8716f_spi_send_command(unsigned int writecnt, unsigned int readcnt,
Uwe Hermann394131e2008-10-18 21:14:13 +0000653 const unsigned char *writearr, unsigned char *readarr);
Carl-Daniel Hailfingercbf563c2009-06-16 08:55:44 +0000654int it8716f_spi_chip_read(struct flashchip *flash, uint8_t *buf, int start, int len);
Carl-Daniel Hailfinger96930c32009-05-09 02:30:21 +0000655int it8716f_spi_chip_write_256(struct flashchip *flash, uint8_t *buf);
Carl-Daniel Hailfingerbfe5b4a2008-05-13 23:03:12 +0000656
Jason Wanga3f04be2008-11-28 21:36:51 +0000657/* sb600spi.c */
Carl-Daniel Hailfingerd0478292009-07-10 21:08:55 +0000658int sb600_spi_send_command(unsigned int writecnt, unsigned int readcnt,
Jason Wanga3f04be2008-11-28 21:36:51 +0000659 const unsigned char *writearr, unsigned char *readarr);
Carl-Daniel Hailfingercbf563c2009-06-16 08:55:44 +0000660int sb600_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
Carl-Daniel Hailfinger96930c32009-05-09 02:30:21 +0000661int sb600_spi_write_1(struct flashchip *flash, uint8_t *buf);
Carl-Daniel Hailfinger78185dc2009-05-17 15:49:24 +0000662extern uint8_t *sb600_spibar;
Jason Wanga3f04be2008-11-28 21:36:51 +0000663
Peter Stugebf196e92009-01-26 03:08:45 +0000664/* wbsio_spi.c */
665int wbsio_check_for_spi(const char *name);
Carl-Daniel Hailfingerd0478292009-07-10 21:08:55 +0000666int wbsio_spi_send_command(unsigned int writecnt, unsigned int readcnt,
Uwe Hermannd1129ac2009-05-28 15:07:42 +0000667 const unsigned char *writearr, unsigned char *readarr);
Carl-Daniel Hailfingercbf563c2009-06-16 08:55:44 +0000668int wbsio_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
Carl-Daniel Hailfinger96930c32009-05-09 02:30:21 +0000669int wbsio_spi_write_1(struct flashchip *flash, uint8_t *buf);
Peter Stugebf196e92009-01-26 03:08:45 +0000670
Urja Rannikko22915352009-06-23 11:33:43 +0000671/* serprog.c */
Urja Rannikko22915352009-06-23 11:33:43 +0000672int serprog_init(void);
673int serprog_shutdown(void);
674void serprog_chip_writeb(uint8_t val, chipaddr addr);
675uint8_t serprog_chip_readb(const chipaddr addr);
676void serprog_chip_readn(uint8_t *buf, const chipaddr addr, size_t len);
677void serprog_delay(int delay);
Carl-Daniel Hailfingere51ea102009-11-23 19:20:11 +0000678
679/* serial.c */
Patrick Georgie48654c2010-01-06 22:14:39 +0000680#if _WIN32
681typedef HANDLE fdtype;
682#else
683typedef int fdtype;
684#endif
685
Carl-Daniel Hailfingera4a9bfb2009-11-21 11:02:48 +0000686void sp_flush_incoming(void);
Patrick Georgie48654c2010-01-06 22:14:39 +0000687fdtype sp_openserport(char *dev, unsigned int baud);
Carl-Daniel Hailfingere51ea102009-11-23 19:20:11 +0000688void __attribute__((noreturn)) sp_die(char *msg);
Patrick Georgie48654c2010-01-06 22:14:39 +0000689extern fdtype sp_fd;
Carl-Daniel Hailfingerefa151e2010-01-06 16:09:10 +0000690int serialport_shutdown(void);
691int serialport_write(unsigned char *buf, unsigned int writecnt);
692int serialport_read(unsigned char *buf, unsigned int readcnt);
Uwe Hermann1432a602009-06-28 23:26:37 +0000693
Ollie Lho761bf1b2004-03-20 16:46:10 +0000694#endif /* !__FLASH_H__ */