flash.h 19 KB
Newer Older
1
/*
2
 * This file is part of the flashrom project.
3
 *
4 5
 * Copyright (C) 2000 Silicon Integrated System Corporation
 * Copyright (C) 2000 Ronald G. Minnich <rminnich@gmail.com>
6
 * Copyright (C) 2005-2009 coresystems GmbH
7
 * Copyright (C) 2006-2009 Carl-Daniel Hailfinger
8
 *
9 10 11 12
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
13
 *
14 15 16 17
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
18
 *
19 20 21
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
22 23
 */

Ronald G. Minnich's avatar
Ronald G. Minnich committed
24 25 26
#ifndef __FLASH_H__
#define __FLASH_H__ 1

27
#include <unistd.h>
28
#include <stdint.h>
29
#include <stdio.h>
30
#include "hwaccess.h"
31

32 33
typedef unsigned long chipaddr;

34
enum programmer {
35
#if INTERNAL_SUPPORT == 1
36
	PROGRAMMER_INTERNAL,
37
#endif
38
#if DUMMY_SUPPORT == 1
39
	PROGRAMMER_DUMMY,
40 41
#endif
#if NIC3COM_SUPPORT == 1
42
	PROGRAMMER_NIC3COM,
43
#endif
44 45 46
#if GFXNVIDIA_SUPPORT == 1
	PROGRAMMER_GFXNVIDIA,
#endif
47
#if DRKAISER_SUPPORT == 1
48
	PROGRAMMER_DRKAISER,
49 50
#endif
#if SATASII_SUPPORT == 1
51
	PROGRAMMER_SATASII,
52
#endif
53
#if INTERNAL_SUPPORT == 1
54
	PROGRAMMER_IT87SPI,
55
#endif
56
#if FT2232_SPI_SUPPORT == 1
57
	PROGRAMMER_FT2232SPI,
58
#endif
59
#if SERPROG_SUPPORT == 1
60
	PROGRAMMER_SERPROG,
61 62 63
#endif
#if BUSPIRATE_SPI_SUPPORT == 1
	PROGRAMMER_BUSPIRATESPI,
64
#endif
65
	PROGRAMMER_INVALID /* This must always be the last entry. */
66 67 68
};

extern enum programmer programmer;
69 70 71 72 73 74 75 76

struct programmer_entry {
	const char *vendor;
	const char *name;

	int (*init) (void);
	int (*shutdown) (void);

Uwe Hermann's avatar
Uwe Hermann committed
77 78
	void * (*map_flash_region) (const char *descr, unsigned long phys_addr,
				    size_t len);
79 80
	void (*unmap_flash_region) (void *virt_addr, size_t len);

81 82 83
	void (*chip_writeb) (uint8_t val, chipaddr addr);
	void (*chip_writew) (uint16_t val, chipaddr addr);
	void (*chip_writel) (uint32_t val, chipaddr addr);
84
	void (*chip_writen) (uint8_t *buf, chipaddr addr, size_t len);
85 86 87
	uint8_t (*chip_readb) (const chipaddr addr);
	uint16_t (*chip_readw) (const chipaddr addr);
	uint32_t (*chip_readl) (const chipaddr addr);
88
	void (*chip_readn) (uint8_t *buf, const chipaddr addr, size_t len);
89
	void (*delay) (int usecs);
90 91 92 93
};

extern const struct programmer_entry programmer_table[];

94 95 96 97 98 99 100 101
int programmer_init(void);
int programmer_shutdown(void);
void *programmer_map_flash_region(const char *descr, unsigned long phys_addr,
				  size_t len);
void programmer_unmap_flash_region(void *virt_addr, size_t len);
void chip_writeb(uint8_t val, chipaddr addr);
void chip_writew(uint16_t val, chipaddr addr);
void chip_writel(uint32_t val, chipaddr addr);
102
void chip_writen(uint8_t *buf, chipaddr addr, size_t len);
103 104 105
uint8_t chip_readb(const chipaddr addr);
uint16_t chip_readw(const chipaddr addr);
uint32_t chip_readl(const chipaddr addr);
106
void chip_readn(uint8_t *buf, const chipaddr addr, size_t len);
107
void programmer_delay(int usecs);
108

109 110
enum bitbang_spi_master {
	BITBANG_SPI_INVALID /* This must always be the last entry. */
111 112
};

113
extern const int bitbang_spi_master_count;
114

115
extern enum bitbang_spi_master bitbang_spi_master;
116

117
struct bitbang_spi_master_entry {
118 119 120 121 122 123
	void (*set_cs) (int val);
	void (*set_sck) (int val);
	void (*set_mosi) (int val);
	int (*get_miso) (void);
};

124 125
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))

126
enum chipbustype {
127
	CHIP_BUSTYPE_NONE	= 0,
128 129 130 131 132 133 134 135
	CHIP_BUSTYPE_PARALLEL	= 1 << 0,
	CHIP_BUSTYPE_LPC	= 1 << 1,
	CHIP_BUSTYPE_FWH	= 1 << 2,
	CHIP_BUSTYPE_SPI	= 1 << 3,
	CHIP_BUSTYPE_NONSPI	= CHIP_BUSTYPE_PARALLEL | CHIP_BUSTYPE_LPC | CHIP_BUSTYPE_FWH,
	CHIP_BUSTYPE_UNKNOWN	= CHIP_BUSTYPE_PARALLEL | CHIP_BUSTYPE_LPC | CHIP_BUSTYPE_FWH | CHIP_BUSTYPE_SPI,
};

136 137 138 139 140 141 142 143 144 145 146
/*
 * How many different contiguous runs of erase blocks with one size each do
 * we have for a given erase function?
 */
#define NUM_ERASEREGIONS 5

/*
 * How many different erase functions do we have per chip?
 */
#define NUM_ERASEFUNCTIONS 5

147 148 149
#define FEATURE_REGISTERMAP (1 << 0)
#define FEATURE_BYTEWRITES (1 << 1)

150
struct flashchip {
151
	const char *vendor;
152
	const char *name;
153 154 155

	enum chipbustype bustype;

156 157
	/*
	 * With 32bit manufacture_id and model_id we can cover IDs up to
158 159 160 161 162
	 * (including) the 4th bank of JEDEC JEP106W Standard Manufacturer's
	 * Identification code.
	 */
	uint32_t manufacture_id;
	uint32_t model_id;
163 164 165

	int total_size;
	int page_size;
166
	int feature_bits;
167

168 169
	/*
	 * Indicate if flashrom has been tested with this flash chip and if
170 171 172 173
	 * everything worked correctly.
	 */
	uint32_t tested;

Uwe Hermann's avatar
Uwe Hermann committed
174
	int (*probe) (struct flashchip *flash);
175 176 177

	/* Delay after "enter/exit ID mode" commands in microseconds. */
	int probe_timing;
Uwe Hermann's avatar
Uwe Hermann committed
178
	int (*erase) (struct flashchip *flash);
179 180

	/*
181 182
	 * Erase blocks and associated erase function. Any chip erase function
	 * is stored as chip-sized virtual block together with said function.
183 184 185 186 187 188 189 190 191
	 */
	struct block_eraser {
		struct eraseblock{
			unsigned int size; /* Eraseblock size */
			unsigned int count; /* Number of contiguous blocks with that size */
		} eraseblocks[NUM_ERASEREGIONS];
		int (*block_erase) (struct flashchip *flash, unsigned int blockaddr, unsigned int blocklen);
	} block_erasers[NUM_ERASEFUNCTIONS];

Uwe Hermann's avatar
Uwe Hermann committed
192
	int (*write) (struct flashchip *flash, uint8_t *buf);
193
	int (*read) (struct flashchip *flash, uint8_t *buf, int start, int len);
Ronald G. Minnich's avatar
Ronald G. Minnich committed
194

195
	/* Some flash devices have an additional register space. */
196 197
	chipaddr virtual_memory;
	chipaddr virtual_registers;
198 199
};

200 201
#define TEST_UNTESTED	0

Uwe Hermann's avatar
Uwe Hermann committed
202 203 204 205 206 207
#define TEST_OK_PROBE	(1 << 0)
#define TEST_OK_READ	(1 << 1)
#define TEST_OK_ERASE	(1 << 2)
#define TEST_OK_WRITE	(1 << 3)
#define TEST_OK_PR	(TEST_OK_PROBE | TEST_OK_READ)
#define TEST_OK_PRE	(TEST_OK_PROBE | TEST_OK_READ | TEST_OK_ERASE)
208
#define TEST_OK_PRW	(TEST_OK_PROBE | TEST_OK_READ | TEST_OK_WRITE)
Uwe Hermann's avatar
Uwe Hermann committed
209
#define TEST_OK_PREW	(TEST_OK_PROBE | TEST_OK_READ | TEST_OK_ERASE | TEST_OK_WRITE)
210 211
#define TEST_OK_MASK	0x0f

Uwe Hermann's avatar
Uwe Hermann committed
212 213 214 215 216
#define TEST_BAD_PROBE	(1 << 4)
#define TEST_BAD_READ	(1 << 5)
#define TEST_BAD_ERASE	(1 << 6)
#define TEST_BAD_WRITE	(1 << 7)
#define TEST_BAD_PREW	(TEST_BAD_PROBE | TEST_BAD_READ | TEST_BAD_ERASE | TEST_BAD_WRITE)
217 218
#define TEST_BAD_MASK	0xf0

219 220 221 222 223 224 225 226 227 228
/* Timing used in probe routines. ZERO is -2 to differentiate between an unset
 * field and zero delay.
 * 
 * SPI devices will always have zero delay and ignore this field.
 */
#define TIMING_FIXME	-1
/* this is intentionally same value as fixme */
#define TIMING_IGNORED	-1
#define TIMING_ZERO	-2

229 230
extern struct flashchip flashchips[];

231
#if INTERNAL_SUPPORT == 1
Uwe Hermann's avatar
Uwe Hermann committed
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276
struct penable {
	uint16_t vendor_id;
	uint16_t device_id;
	int status;
	const char *vendor_name;
	const char *device_name;
	int (*doit) (struct pci_dev *dev, const char *name);
};

extern const struct penable chipset_enables[];

struct board_pciid_enable {
	/* Any device, but make it sensible, like the ISA bridge. */
	uint16_t first_vendor;
	uint16_t first_device;
	uint16_t first_card_vendor;
	uint16_t first_card_device;

	/* Any device, but make it sensible, like
	 * the host bridge. May be NULL.
	 */
	uint16_t second_vendor;
	uint16_t second_device;
	uint16_t second_card_vendor;
	uint16_t second_card_device;

	/* The vendor / part name from the coreboot table. */
	const char *lb_vendor;
	const char *lb_part;

	const char *vendor_name;
	const char *board_name;

	int (*enable) (const char *name);
};

extern struct board_pciid_enable board_pciid_enables[];

struct board_info {
	const char *vendor;
	const char *name;
};

extern const struct board_info boards_ok[];
extern const struct board_info boards_bad[];
277 278
extern const struct board_info laptops_ok[];
extern const struct board_info laptops_bad[];
279
#endif
Uwe Hermann's avatar
Uwe Hermann committed
280

281
/* udelay.c */
282
void myusec_delay(int usecs);
283
void myusec_calibrate_delay(void);
284
void internal_delay(int usecs);
285

286
#if NEED_PCI == 1
287 288 289
/* pcidev.c */
#define PCI_OK 0
#define PCI_NT 1    /* Not tested */
290

291 292 293
extern uint32_t io_base_addr;
extern struct pci_access *pacc;
extern struct pci_filter filter;
294
extern struct pci_dev *pcidev_dev;
295 296 297 298 299 300 301
struct pcidev_status {
	uint16_t vendor_id;
	uint16_t device_id;
	int status;
	const char *vendor_name;
	const char *device_name;
};
302 303
uint32_t pcidev_validate(struct pci_dev *dev, uint32_t bar, struct pcidev_status *devs);
uint32_t pcidev_init(uint16_t vendor_id, uint32_t bar, struct pcidev_status *devs, char *pcidev_bdf);
304
#endif
305 306 307

/* print.c */
char *flashbuses_to_text(enum chipbustype bustype);
308
void print_supported(void);
309
#if (NIC3COM_SUPPORT == 1) || (GFXNVIDIA_SUPPORT == 1) || (DRKAISER_SUPPORT == 1) || (SATASII_SUPPORT == 1)
310
void print_supported_pcidevs(struct pcidev_status *devs);
311
#endif
312
void print_supported_wiki(void);
313

314
/* board_enable.c */
315 316
void w836xx_ext_enter(uint16_t port);
void w836xx_ext_leave(uint16_t port);
317 318 319
uint8_t sio_read(uint16_t port, uint8_t reg);
void sio_write(uint16_t port, uint8_t reg, uint8_t data);
void sio_mask(uint16_t port, uint8_t reg, uint8_t data, uint8_t mask);
320
int board_flash_enable(const char *vendor, const char *part);
321

322 323
/* chipset_enable.c */
int chipset_flash_enable(void);
324

325 326 327
/* physmap.c */
void *physmap(const char *descr, unsigned long phys_addr, size_t len);
void physunmap(void *virt_addr, size_t len);
328 329
int setup_cpu_msr(int cpu);
void cleanup_cpu_msr(void);
330 331 332 333 334 335

/* cbtable.c */
void lb_vendor_dev_from_string(char *boardstring);
int coreboot_init(void);
extern char *lb_part, *lb_vendor;
extern int partvendor_from_cbtable;
336

337
/* internal.c */
338
#if NEED_PCI == 1
339 340 341 342 343 344 345 346
struct superio {
	uint16_t vendor;
	uint16_t port;
	uint16_t model;
};
extern struct superio superio;
#define SUPERIO_VENDOR_NONE	0x0
#define SUPERIO_VENDOR_ITE	0x1
347
struct pci_dev *pci_dev_find_filter(struct pci_filter filter);
348
struct pci_dev *pci_dev_find_vendorclass(uint16_t vendor, uint16_t class);
349 350 351
struct pci_dev *pci_dev_find(uint16_t vendor, uint16_t device);
struct pci_dev *pci_card_find(uint16_t vendor, uint16_t device,
			      uint16_t card_vendor, uint16_t card_device);
352
#endif
353
void get_io_perms(void);
354
void release_io_perms(void);
355
#if INTERNAL_SUPPORT == 1
356
void probe_superio(void);
357 358
int internal_init(void);
int internal_shutdown(void);
359 360 361 362 363 364
void internal_chip_writeb(uint8_t val, chipaddr addr);
void internal_chip_writew(uint16_t val, chipaddr addr);
void internal_chip_writel(uint32_t val, chipaddr addr);
uint8_t internal_chip_readb(const chipaddr addr);
uint16_t internal_chip_readw(const chipaddr addr);
uint32_t internal_chip_readl(const chipaddr addr);
365
void internal_chip_readn(uint8_t *buf, const chipaddr addr, size_t len);
366
#endif
367 368 369 370 371 372
void mmio_writeb(uint8_t val, void *addr);
void mmio_writew(uint16_t val, void *addr);
void mmio_writel(uint32_t val, void *addr);
uint8_t mmio_readb(void *addr);
uint16_t mmio_readw(void *addr);
uint32_t mmio_readl(void *addr);
373 374

/* programmer.c */
375
int noop_shutdown(void);
376 377
void *fallback_map(const char *descr, unsigned long phys_addr, size_t len);
void fallback_unmap(void *virt_addr, size_t len);
378 379
uint8_t noop_chip_readb(const chipaddr addr);
void noop_chip_writeb(uint8_t val, chipaddr addr);
380 381
void fallback_chip_writew(uint16_t val, chipaddr addr);
void fallback_chip_writel(uint32_t val, chipaddr addr);
382
void fallback_chip_writen(uint8_t *buf, chipaddr addr, size_t len);
383 384
uint16_t fallback_chip_readw(const chipaddr addr);
uint32_t fallback_chip_readl(const chipaddr addr);
385
void fallback_chip_readn(uint8_t *buf, const chipaddr addr, size_t len);
386

387
/* dummyflasher.c */
388
#if DUMMY_SUPPORT == 1
389 390
int dummy_init(void);
int dummy_shutdown(void);
391 392
void *dummy_map(const char *descr, unsigned long phys_addr, size_t len);
void dummy_unmap(void *virt_addr, size_t len);
393 394 395
void dummy_chip_writeb(uint8_t val, chipaddr addr);
void dummy_chip_writew(uint16_t val, chipaddr addr);
void dummy_chip_writel(uint32_t val, chipaddr addr);
396
void dummy_chip_writen(uint8_t *buf, chipaddr addr, size_t len);
397 398 399
uint8_t dummy_chip_readb(const chipaddr addr);
uint16_t dummy_chip_readw(const chipaddr addr);
uint32_t dummy_chip_readl(const chipaddr addr);
400
void dummy_chip_readn(uint8_t *buf, const chipaddr addr, size_t len);
401
int dummy_spi_send_command(unsigned int writecnt, unsigned int readcnt,
402
		      const unsigned char *writearr, unsigned char *readarr);
403
#endif
404

405
/* nic3com.c */
406
#if NIC3COM_SUPPORT == 1
407 408
int nic3com_init(void);
int nic3com_shutdown(void);
409 410
void nic3com_chip_writeb(uint8_t val, chipaddr addr);
uint8_t nic3com_chip_readb(const chipaddr addr);
411
extern struct pcidev_status nics_3com[];
412
#endif
413

414
/* gfxnvidia.c */
415
#if GFXNVIDIA_SUPPORT == 1
416 417 418 419 420
int gfxnvidia_init(void);
int gfxnvidia_shutdown(void);
void gfxnvidia_chip_writeb(uint8_t val, chipaddr addr);
uint8_t gfxnvidia_chip_readb(const chipaddr addr);
extern struct pcidev_status gfx_nvidia[];
421
#endif
422

423
/* drkaiser.c */
424
#if DRKAISER_SUPPORT == 1
425 426 427 428 429
int drkaiser_init(void);
int drkaiser_shutdown(void);
void drkaiser_chip_writeb(uint8_t val, chipaddr addr);
uint8_t drkaiser_chip_readb(const chipaddr addr);
extern struct pcidev_status drkaiser_pcidev[];
430
#endif
431

432
/* satasii.c */
433
#if SATASII_SUPPORT == 1
434 435 436 437 438
int satasii_init(void);
int satasii_shutdown(void);
void satasii_chip_writeb(uint8_t val, chipaddr addr);
uint8_t satasii_chip_readb(const chipaddr addr);
extern struct pcidev_status satas_sii[];
439
#endif
440

441
/* ft2232_spi.c */
442 443
#define FTDI_FT2232H 0x6010
#define FTDI_FT4232H 0x6011
444
int ft2232_spi_init(void);
445
int ft2232_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr);
446 447 448
int ft2232_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
int ft2232_spi_write_256(struct flashchip *flash, uint8_t *buf);

449
/* bitbang_spi.c */
450 451
extern int bitbang_spi_half_period;
extern const struct bitbang_spi_master_entry bitbang_spi_master_table[];
452 453 454 455 456
int bitbang_spi_init(void);
int bitbang_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr);
int bitbang_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
int bitbang_spi_write_256(struct flashchip *flash, uint8_t *buf);

457
/* buspirate_spi.c */
458 459 460 461
struct buspirate_spispeeds {
	const char *name;
	const int speed;
};
462 463 464 465 466
int buspirate_spi_init(void);
int buspirate_spi_shutdown(void);
int buspirate_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr);
int buspirate_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);

467
/* flashrom.c */
468 469 470 471 472 473 474 475
extern enum chipbustype buses_supported;
struct decode_sizes {
	uint32_t parallel;
	uint32_t lpc;
	uint32_t fwh;
	uint32_t spi;
};
extern struct decode_sizes max_rom_decode;
476
extern char *programmer_param;
477
extern unsigned long flashbase;
Uwe Hermann's avatar
Uwe Hermann committed
478
extern int verbose;
479
extern const char *flashrom_version;
Uwe Hermann's avatar
Uwe Hermann committed
480
#define printf_debug(x...) { if (verbose) printf(x); }
481
void map_flash_registers(struct flashchip *flash);
482
int read_memmapped(struct flashchip *flash, uint8_t *buf, int start, int len);
483
int erase_flash(struct flashchip *flash);
484
int min(int a, int b);
485
int max(int a, int b);
486
char *extract_param(char **haystack, char *needle, char *delim);
487 488
int check_erased_range(struct flashchip *flash, int start, int len);
int verify_range(struct flashchip *flash, uint8_t *cmpbuf, int start, int len, char *message);
489
char *strcat_realloc(char *dest, const char *src);
490
int doit(struct flashchip *flash, int force, char *filename, int read_it, int write_it, int erase_it, int verify_it);
491 492 493

#define OK 0
#define NT 1    /* Not tested */
494 495

/* layout.c */
Peter Stuge's avatar
Peter Stuge committed
496
int show_id(uint8_t *bios, int size, int force);
497 498
int read_romlayout(char *name);
int find_romentry(char *name);
499
int handle_romentries(uint8_t *buffer, struct flashchip *flash);
500

501
/* spi.c */
502 503
enum spi_controller {
	SPI_CONTROLLER_NONE,
504
#if INTERNAL_SUPPORT == 1
505 506 507 508 509 510
	SPI_CONTROLLER_ICH7,
	SPI_CONTROLLER_ICH9,
	SPI_CONTROLLER_IT87XX,
	SPI_CONTROLLER_SB600,
	SPI_CONTROLLER_VIA,
	SPI_CONTROLLER_WBSIO,
511
#endif
512
#if FT2232_SPI_SUPPORT == 1
513
	SPI_CONTROLLER_FT2232,
514
#endif
515
#if DUMMY_SUPPORT == 1
516
	SPI_CONTROLLER_DUMMY,
517 518 519
#endif
#if BUSPIRATE_SPI_SUPPORT == 1
	SPI_CONTROLLER_BUSPIRATE,
520
#endif
521
	SPI_CONTROLLER_INVALID /* This must always be the last entry. */
522
};
523
extern const int spi_programmer_count;
524 525 526 527 528 529
struct spi_command {
	unsigned int writecnt;
	unsigned int readcnt;
	const unsigned char *writearr;
	unsigned char *readarr;
};
530 531 532
struct spi_programmer {
	int (*command)(unsigned int writecnt, unsigned int readcnt,
		   const unsigned char *writearr, unsigned char *readarr);
533
	int (*multicommand)(struct spi_command *cmds);
534 535 536 537 538

	/* Optimized functions for this programmer */
	int (*read)(struct flashchip *flash, uint8_t *buf, int start, int len);
	int (*write_256)(struct flashchip *flash, uint8_t *buf);
};
539

540
extern enum spi_controller spi_controller;
541
extern const struct spi_programmer spi_programmer[];
542
extern void *spibar;
543
int spi_send_command(unsigned int writecnt, unsigned int readcnt,
544
		const unsigned char *writearr, unsigned char *readarr);
545
int spi_send_multicommand(struct spi_command *cmds);
546 547
int default_spi_send_command(unsigned int writecnt, unsigned int readcnt,
			     const unsigned char *writearr, unsigned char *readarr);
548
int default_spi_send_multicommand(struct spi_command *cmds);
549
uint32_t spi_get_valid_read_addr(void);
550

551
/* ichspi.c */
552
int ich_init_opcodes(void);
553
int ich_spi_send_command(unsigned int writecnt, unsigned int readcnt,
554
		    const unsigned char *writearr, unsigned char *readarr);
555
int ich_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
556
int ich_spi_write_256(struct flashchip *flash, uint8_t * buf);
557
int ich_spi_send_multicommand(struct spi_command *cmds);
558

559 560
/* it87spi.c */
extern uint16_t it8716f_flashport;
561 562
void enter_conf_mode_ite(uint16_t port);
void exit_conf_mode_ite(uint16_t port);
563
struct superio probe_superio_ite(void);
564
int it87spi_init(void);
565
int it87xx_probe_spi_flash(const char *name);
566
int it8716f_spi_send_command(unsigned int writecnt, unsigned int readcnt,
567
			const unsigned char *writearr, unsigned char *readarr);
568
int it8716f_spi_chip_read(struct flashchip *flash, uint8_t *buf, int start, int len);
569
int it8716f_spi_chip_write_256(struct flashchip *flash, uint8_t *buf);
570

571
/* sb600spi.c */
572
int sb600_spi_send_command(unsigned int writecnt, unsigned int readcnt,
573
		      const unsigned char *writearr, unsigned char *readarr);
574
int sb600_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
575
int sb600_spi_write_1(struct flashchip *flash, uint8_t *buf);
576
extern uint8_t *sb600_spibar;
577

Peter Stuge's avatar
Peter Stuge committed
578 579
/* wbsio_spi.c */
int wbsio_check_for_spi(const char *name);
580
int wbsio_spi_send_command(unsigned int writecnt, unsigned int readcnt,
Uwe Hermann's avatar
Uwe Hermann committed
581
		      const unsigned char *writearr, unsigned char *readarr);
582
int wbsio_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
583
int wbsio_spi_write_1(struct flashchip *flash, uint8_t *buf);
Peter Stuge's avatar
Peter Stuge committed
584

585 586 587 588 589 590 591
/* serprog.c */
int serprog_init(void);
int serprog_shutdown(void);
void serprog_chip_writeb(uint8_t val, chipaddr addr);
uint8_t serprog_chip_readb(const chipaddr addr);
void serprog_chip_readn(uint8_t *buf, const chipaddr addr, size_t len);
void serprog_delay(int delay);
592 593

/* serial.c */
594 595
void sp_flush_incoming(void);
int sp_openserport(char *dev, unsigned int baud);
596
void __attribute__((noreturn)) sp_die(char *msg);
597
extern int sp_fd;
598 599 600
int serialport_shutdown(void);
int serialport_write(unsigned char *buf, unsigned int writecnt);
int serialport_read(unsigned char *buf, unsigned int readcnt);
Uwe Hermann's avatar
Uwe Hermann committed
601

602 603
#include "chipdrivers.h"

604
#endif				/* !__FLASH_H__ */