blob: 7bd140530e36d22428ac6b540ab15ed10536078e [file] [log] [blame]
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +00001/*
2 * This file is part of the flashrom project.
3 *
4 * Copyright (C) 2000 Silicon Integrated System Corporation
5 * Copyright (C) 2000 Ronald G. Minnich <rminnich@gmail.com>
6 * Copyright (C) 2005-2009 coresystems GmbH
7 * Copyright (C) 2006-2009 Carl-Daniel Hailfinger
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24#ifndef __PROGRAMMER_H__
25#define __PROGRAMMER_H__ 1
26
27enum programmer {
28#if CONFIG_INTERNAL == 1
29 PROGRAMMER_INTERNAL,
30#endif
31#if CONFIG_DUMMY == 1
32 PROGRAMMER_DUMMY,
33#endif
34#if CONFIG_NIC3COM == 1
35 PROGRAMMER_NIC3COM,
36#endif
37#if CONFIG_NICREALTEK == 1
38 PROGRAMMER_NICREALTEK,
39 PROGRAMMER_NICREALTEK2,
Idwer Vollering004f4b72010-09-03 18:21:21 +000040#endif
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +000041#if CONFIG_NICNATSEMI == 1
42 PROGRAMMER_NICNATSEMI,
Idwer Vollering004f4b72010-09-03 18:21:21 +000043#endif
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +000044#if CONFIG_GFXNVIDIA == 1
45 PROGRAMMER_GFXNVIDIA,
46#endif
47#if CONFIG_DRKAISER == 1
48 PROGRAMMER_DRKAISER,
49#endif
50#if CONFIG_SATASII == 1
51 PROGRAMMER_SATASII,
52#endif
53#if CONFIG_ATAHPT == 1
54 PROGRAMMER_ATAHPT,
55#endif
56#if CONFIG_INTERNAL == 1
57#if defined(__i386__) || defined(__x86_64__)
58 PROGRAMMER_IT87SPI,
59#endif
60#endif
61#if CONFIG_FT2232_SPI == 1
62 PROGRAMMER_FT2232_SPI,
63#endif
64#if CONFIG_SERPROG == 1
65 PROGRAMMER_SERPROG,
66#endif
67#if CONFIG_BUSPIRATE_SPI == 1
68 PROGRAMMER_BUSPIRATE_SPI,
69#endif
70#if CONFIG_DEDIPROG == 1
71 PROGRAMMER_DEDIPROG,
72#endif
73#if CONFIG_RAYER_SPI == 1
74 PROGRAMMER_RAYER_SPI,
75#endif
Idwer Vollering004f4b72010-09-03 18:21:21 +000076#if CONFIG_NICINTEL_SPI == 1
77 PROGRAMMER_NICINTEL_SPI,
78#endif
Mark Marshall90021f22010-12-03 14:48:11 +000079#if CONFIG_OGP_SPI == 1
80 PROGRAMMER_OGP_SPI,
81#endif
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +000082 PROGRAMMER_INVALID /* This must always be the last entry. */
83};
84
85extern enum programmer programmer;
86
87struct programmer_entry {
88 const char *vendor;
89 const char *name;
90
91 int (*init) (void);
92 int (*shutdown) (void);
93
94 void * (*map_flash_region) (const char *descr, unsigned long phys_addr,
95 size_t len);
96 void (*unmap_flash_region) (void *virt_addr, size_t len);
97
98 void (*chip_writeb) (uint8_t val, chipaddr addr);
99 void (*chip_writew) (uint16_t val, chipaddr addr);
100 void (*chip_writel) (uint32_t val, chipaddr addr);
101 void (*chip_writen) (uint8_t *buf, chipaddr addr, size_t len);
102 uint8_t (*chip_readb) (const chipaddr addr);
103 uint16_t (*chip_readw) (const chipaddr addr);
104 uint32_t (*chip_readl) (const chipaddr addr);
105 void (*chip_readn) (uint8_t *buf, const chipaddr addr, size_t len);
106 void (*delay) (int usecs);
107};
108
109extern const struct programmer_entry programmer_table[];
110
111int programmer_init(char *param);
112int programmer_shutdown(void);
113
114enum bitbang_spi_master_type {
115 BITBANG_SPI_INVALID = 0, /* This must always be the first entry. */
116#if CONFIG_RAYER_SPI == 1
117 BITBANG_SPI_MASTER_RAYER,
118#endif
Idwer Vollering004f4b72010-09-03 18:21:21 +0000119#if CONFIG_NICINTEL_SPI == 1
120 BITBANG_SPI_MASTER_NICINTEL,
121#endif
Carl-Daniel Hailfinger2f436162010-07-28 15:08:35 +0000122#if CONFIG_INTERNAL == 1
123#if defined(__i386__) || defined(__x86_64__)
124 BITBANG_SPI_MASTER_MCP,
125#endif
126#endif
Mark Marshall90021f22010-12-03 14:48:11 +0000127#if CONFIG_OGP_SPI == 1
128 BITBANG_SPI_MASTER_OGP,
129#endif
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000130};
131
132struct bitbang_spi_master {
133 enum bitbang_spi_master_type type;
134
135 /* Note that CS# is active low, so val=0 means the chip is active. */
136 void (*set_cs) (int val);
137 void (*set_sck) (int val);
138 void (*set_mosi) (int val);
139 int (*get_miso) (void);
Carl-Daniel Hailfinger28228882010-09-15 00:17:37 +0000140 void (*request_bus) (void);
141 void (*release_bus) (void);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000142};
143
144#if CONFIG_INTERNAL == 1
145struct penable {
146 uint16_t vendor_id;
147 uint16_t device_id;
148 int status;
149 const char *vendor_name;
150 const char *device_name;
151 int (*doit) (struct pci_dev *dev, const char *name);
152};
153
154extern const struct penable chipset_enables[];
155
156struct board_pciid_enable {
157 /* Any device, but make it sensible, like the ISA bridge. */
158 uint16_t first_vendor;
159 uint16_t first_device;
160 uint16_t first_card_vendor;
161 uint16_t first_card_device;
162
163 /* Any device, but make it sensible, like
164 * the host bridge. May be NULL.
165 */
166 uint16_t second_vendor;
167 uint16_t second_device;
168 uint16_t second_card_vendor;
169 uint16_t second_card_device;
170
171 /* Pattern to match DMI entries */
172 const char *dmi_pattern;
173
174 /* The vendor / part name from the coreboot table. */
175 const char *lb_vendor;
176 const char *lb_part;
177
178 const char *vendor_name;
179 const char *board_name;
180
181 int max_rom_decode_parallel;
182 int status;
183 int (*enable) (void);
184};
185
186extern const struct board_pciid_enable board_pciid_enables[];
187
188struct board_info {
189 const char *vendor;
190 const char *name;
191 const int working;
192#ifdef CONFIG_PRINT_WIKI
193 const char *url;
194 const char *note;
195#endif
196};
197
198extern const struct board_info boards_known[];
199extern const struct board_info laptops_known[];
200#endif
201
202/* udelay.c */
203void myusec_delay(int usecs);
204void myusec_calibrate_delay(void);
205void internal_delay(int usecs);
206
207#if NEED_PCI == 1
208/* pcidev.c */
209extern uint32_t io_base_addr;
210extern struct pci_access *pacc;
211extern struct pci_dev *pcidev_dev;
212struct pcidev_status {
213 uint16_t vendor_id;
214 uint16_t device_id;
215 int status;
216 const char *vendor_name;
217 const char *device_name;
218};
219uint32_t pcidev_validate(struct pci_dev *dev, uint32_t bar, const struct pcidev_status *devs);
220uint32_t pcidev_init(uint16_t vendor_id, uint32_t bar, const struct pcidev_status *devs);
Carl-Daniel Hailfinger2bee8cf2010-11-10 15:25:18 +0000221/* rpci_write_* are reversible writes. The original PCI config space register
222 * contents will be restored on shutdown.
223 */
Idwer Vollering1a6162e2010-12-26 23:55:19 +0000224int rpci_write_byte(struct pci_dev *dev, int reg, uint8_t data);
225int rpci_write_word(struct pci_dev *dev, int reg, uint16_t data);
226int rpci_write_long(struct pci_dev *dev, int reg, uint32_t data);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000227#endif
228
229/* print.c */
Mark Marshall90021f22010-12-03 14:48:11 +0000230#if CONFIG_NIC3COM+CONFIG_NICREALTEK+CONFIG_NICNATSEMI+CONFIG_GFXNVIDIA+CONFIG_DRKAISER+CONFIG_SATASII+CONFIG_ATAHPT+CONFIG_NICINTEL_SPI+CONFIG_OGP_SPI >= 1
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000231void print_supported_pcidevs(const struct pcidev_status *devs);
232#endif
233
234/* board_enable.c */
235void w836xx_ext_enter(uint16_t port);
236void w836xx_ext_leave(uint16_t port);
237int it8705f_write_enable(uint8_t port);
238uint8_t sio_read(uint16_t port, uint8_t reg);
239void sio_write(uint16_t port, uint8_t reg, uint8_t data);
240void sio_mask(uint16_t port, uint8_t reg, uint8_t data, uint8_t mask);
241int board_flash_enable(const char *vendor, const char *part);
242
243/* chipset_enable.c */
244int chipset_flash_enable(void);
245
246/* processor_enable.c */
247int processor_flash_enable(void);
248
249/* physmap.c */
250void *physmap(const char *descr, unsigned long phys_addr, size_t len);
251void *physmap_try_ro(const char *descr, unsigned long phys_addr, size_t len);
252void physunmap(void *virt_addr, size_t len);
253int setup_cpu_msr(int cpu);
254void cleanup_cpu_msr(void);
255
256/* cbtable.c */
257void lb_vendor_dev_from_string(char *boardstring);
258int coreboot_init(void);
259extern char *lb_part, *lb_vendor;
260extern int partvendor_from_cbtable;
261
262/* dmi.c */
263extern int has_dmi_support;
264void dmi_init(void);
265int dmi_match(const char *pattern);
266
267/* internal.c */
268#if NEED_PCI == 1
269struct superio {
270 uint16_t vendor;
271 uint16_t port;
272 uint16_t model;
273};
274extern struct superio superio;
275#define SUPERIO_VENDOR_NONE 0x0
276#define SUPERIO_VENDOR_ITE 0x1
277struct pci_dev *pci_dev_find_filter(struct pci_filter filter);
278struct pci_dev *pci_dev_find_vendorclass(uint16_t vendor, uint16_t class);
279struct pci_dev *pci_dev_find(uint16_t vendor, uint16_t device);
280struct pci_dev *pci_card_find(uint16_t vendor, uint16_t device,
281 uint16_t card_vendor, uint16_t card_device);
282#endif
283void get_io_perms(void);
284void release_io_perms(void);
285#if CONFIG_INTERNAL == 1
286extern int is_laptop;
287extern int force_boardenable;
288extern int force_boardmismatch;
289void probe_superio(void);
290int internal_init(void);
291int internal_shutdown(void);
292void internal_chip_writeb(uint8_t val, chipaddr addr);
293void internal_chip_writew(uint16_t val, chipaddr addr);
294void internal_chip_writel(uint32_t val, chipaddr addr);
295uint8_t internal_chip_readb(const chipaddr addr);
296uint16_t internal_chip_readw(const chipaddr addr);
297uint32_t internal_chip_readl(const chipaddr addr);
298void internal_chip_readn(uint8_t *buf, const chipaddr addr, size_t len);
299#endif
300
301/* hwaccess.c */
302void mmio_writeb(uint8_t val, void *addr);
303void mmio_writew(uint16_t val, void *addr);
304void mmio_writel(uint32_t val, void *addr);
305uint8_t mmio_readb(void *addr);
306uint16_t mmio_readw(void *addr);
307uint32_t mmio_readl(void *addr);
308void mmio_le_writeb(uint8_t val, void *addr);
309void mmio_le_writew(uint16_t val, void *addr);
310void mmio_le_writel(uint32_t val, void *addr);
311uint8_t mmio_le_readb(void *addr);
312uint16_t mmio_le_readw(void *addr);
313uint32_t mmio_le_readl(void *addr);
314#define pci_mmio_writeb mmio_le_writeb
315#define pci_mmio_writew mmio_le_writew
316#define pci_mmio_writel mmio_le_writel
317#define pci_mmio_readb mmio_le_readb
318#define pci_mmio_readw mmio_le_readw
319#define pci_mmio_readl mmio_le_readl
320
321/* programmer.c */
322int noop_shutdown(void);
323void *fallback_map(const char *descr, unsigned long phys_addr, size_t len);
324void fallback_unmap(void *virt_addr, size_t len);
325uint8_t noop_chip_readb(const chipaddr addr);
326void noop_chip_writeb(uint8_t val, chipaddr addr);
327void fallback_chip_writew(uint16_t val, chipaddr addr);
328void fallback_chip_writel(uint32_t val, chipaddr addr);
329void fallback_chip_writen(uint8_t *buf, chipaddr addr, size_t len);
330uint16_t fallback_chip_readw(const chipaddr addr);
331uint32_t fallback_chip_readl(const chipaddr addr);
332void fallback_chip_readn(uint8_t *buf, const chipaddr addr, size_t len);
333
334/* dummyflasher.c */
335#if CONFIG_DUMMY == 1
336int dummy_init(void);
337int dummy_shutdown(void);
338void *dummy_map(const char *descr, unsigned long phys_addr, size_t len);
339void dummy_unmap(void *virt_addr, size_t len);
340void dummy_chip_writeb(uint8_t val, chipaddr addr);
341void dummy_chip_writew(uint16_t val, chipaddr addr);
342void dummy_chip_writel(uint32_t val, chipaddr addr);
343void dummy_chip_writen(uint8_t *buf, chipaddr addr, size_t len);
344uint8_t dummy_chip_readb(const chipaddr addr);
345uint16_t dummy_chip_readw(const chipaddr addr);
346uint32_t dummy_chip_readl(const chipaddr addr);
347void dummy_chip_readn(uint8_t *buf, const chipaddr addr, size_t len);
348int dummy_spi_send_command(unsigned int writecnt, unsigned int readcnt,
349 const unsigned char *writearr, unsigned char *readarr);
350int dummy_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
351int dummy_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len);
352#endif
353
354/* nic3com.c */
355#if CONFIG_NIC3COM == 1
356int nic3com_init(void);
357int nic3com_shutdown(void);
358void nic3com_chip_writeb(uint8_t val, chipaddr addr);
359uint8_t nic3com_chip_readb(const chipaddr addr);
360extern const struct pcidev_status nics_3com[];
361#endif
362
363/* gfxnvidia.c */
364#if CONFIG_GFXNVIDIA == 1
365int gfxnvidia_init(void);
366int gfxnvidia_shutdown(void);
367void gfxnvidia_chip_writeb(uint8_t val, chipaddr addr);
368uint8_t gfxnvidia_chip_readb(const chipaddr addr);
369extern const struct pcidev_status gfx_nvidia[];
370#endif
371
372/* drkaiser.c */
373#if CONFIG_DRKAISER == 1
374int drkaiser_init(void);
375int drkaiser_shutdown(void);
376void drkaiser_chip_writeb(uint8_t val, chipaddr addr);
377uint8_t drkaiser_chip_readb(const chipaddr addr);
378extern const struct pcidev_status drkaiser_pcidev[];
379#endif
380
381/* nicrealtek.c */
382#if CONFIG_NICREALTEK == 1
383int nicrealtek_init(void);
384int nicsmc1211_init(void);
385int nicrealtek_shutdown(void);
386void nicrealtek_chip_writeb(uint8_t val, chipaddr addr);
387uint8_t nicrealtek_chip_readb(const chipaddr addr);
388extern const struct pcidev_status nics_realtek[];
389extern const struct pcidev_status nics_realteksmc1211[];
390#endif
391
392/* nicnatsemi.c */
393#if CONFIG_NICNATSEMI == 1
394int nicnatsemi_init(void);
395int nicnatsemi_shutdown(void);
396void nicnatsemi_chip_writeb(uint8_t val, chipaddr addr);
397uint8_t nicnatsemi_chip_readb(const chipaddr addr);
398extern const struct pcidev_status nics_natsemi[];
399#endif
400
Idwer Vollering004f4b72010-09-03 18:21:21 +0000401/* nicintel_spi.c */
402#if CONFIG_NICINTEL_SPI == 1
403int nicintel_spi_init(void);
404int nicintel_spi_shutdown(void);
405int nicintel_spi_send_command(unsigned int writecnt, unsigned int readcnt,
406 const unsigned char *writearr, unsigned char *readarr);
407void nicintel_spi_chip_writeb(uint8_t val, chipaddr addr);
408extern const struct pcidev_status nics_intel_spi[];
409#endif
410
Mark Marshall90021f22010-12-03 14:48:11 +0000411/* ogp_spi.c */
412#if CONFIG_OGP_SPI == 1
413int ogp_spi_init(void);
414int ogp_spi_shutdown(void);
415extern const struct pcidev_status ogp_spi[];
416#endif
417
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000418/* satasii.c */
419#if CONFIG_SATASII == 1
420int satasii_init(void);
421int satasii_shutdown(void);
422void satasii_chip_writeb(uint8_t val, chipaddr addr);
423uint8_t satasii_chip_readb(const chipaddr addr);
424extern const struct pcidev_status satas_sii[];
425#endif
426
427/* atahpt.c */
428#if CONFIG_ATAHPT == 1
429int atahpt_init(void);
430int atahpt_shutdown(void);
431void atahpt_chip_writeb(uint8_t val, chipaddr addr);
432uint8_t atahpt_chip_readb(const chipaddr addr);
433extern const struct pcidev_status ata_hpt[];
434#endif
435
436/* ft2232_spi.c */
Jörg Fischer6529b9f2010-07-29 15:54:53 +0000437#if CONFIG_FT2232_SPI == 1
438struct usbdev_status {
Uwe Hermann48ec1b12010-08-08 17:01:18 +0000439 uint16_t vendor_id;
440 uint16_t device_id;
441 int status;
442 const char *vendor_name;
443 const char *device_name;
Jörg Fischer6529b9f2010-07-29 15:54:53 +0000444};
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000445int ft2232_spi_init(void);
446int ft2232_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr);
447int ft2232_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
448int ft2232_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len);
Jörg Fischer6529b9f2010-07-29 15:54:53 +0000449extern const struct usbdev_status devs_ft2232spi[];
450void print_supported_usbdevs(const struct usbdev_status *devs);
451#endif
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000452
453/* rayer_spi.c */
454#if CONFIG_RAYER_SPI == 1
455int rayer_spi_init(void);
456#endif
457
Carl-Daniel Hailfinger2f436162010-07-28 15:08:35 +0000458/* mcp6x_spi.c */
459#if CONFIG_INTERNAL == 1
460#if defined(__i386__) || defined(__x86_64__)
461int mcp6x_spi_init(int want_spi);
462#endif
463#endif
464
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000465/* bitbang_spi.c */
466int bitbang_spi_init(const struct bitbang_spi_master *master, int halfperiod);
Carl-Daniel Hailfinger28228882010-09-15 00:17:37 +0000467int bitbang_spi_shutdown(const struct bitbang_spi_master *master);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000468int bitbang_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr);
469int bitbang_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
470int bitbang_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len);
471
472/* buspirate_spi.c */
473struct buspirate_spispeeds {
474 const char *name;
475 const int speed;
476};
477int buspirate_spi_init(void);
478int buspirate_spi_shutdown(void);
479int buspirate_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr);
480int buspirate_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
481int buspirate_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len);
482
483/* dediprog.c */
484int dediprog_init(void);
485int dediprog_shutdown(void);
486int dediprog_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr);
487int dediprog_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
Carl-Daniel Hailfinger306b8182010-11-23 21:28:16 +0000488int dediprog_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000489
490/* flashrom.c */
491struct decode_sizes {
492 uint32_t parallel;
493 uint32_t lpc;
494 uint32_t fwh;
495 uint32_t spi;
496};
497extern struct decode_sizes max_rom_decode;
498extern int programmer_may_write;
499extern unsigned long flashbase;
500void check_chip_supported(struct flashchip *flash);
501int check_max_decode(enum chipbustype buses, uint32_t size);
502char *extract_programmer_param(char *param_name);
503
504/* layout.c */
505int show_id(uint8_t *bios, int size, int force);
506
507/* spi.c */
508enum spi_controller {
509 SPI_CONTROLLER_NONE,
510#if CONFIG_INTERNAL == 1
511#if defined(__i386__) || defined(__x86_64__)
512 SPI_CONTROLLER_ICH7,
513 SPI_CONTROLLER_ICH9,
514 SPI_CONTROLLER_IT87XX,
515 SPI_CONTROLLER_SB600,
516 SPI_CONTROLLER_VIA,
517 SPI_CONTROLLER_WBSIO,
Carl-Daniel Hailfinger2f436162010-07-28 15:08:35 +0000518 SPI_CONTROLLER_MCP6X_BITBANG,
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000519#endif
520#endif
521#if CONFIG_FT2232_SPI == 1
522 SPI_CONTROLLER_FT2232,
523#endif
524#if CONFIG_DUMMY == 1
525 SPI_CONTROLLER_DUMMY,
526#endif
527#if CONFIG_BUSPIRATE_SPI == 1
528 SPI_CONTROLLER_BUSPIRATE,
529#endif
530#if CONFIG_DEDIPROG == 1
531 SPI_CONTROLLER_DEDIPROG,
532#endif
533#if CONFIG_RAYER_SPI == 1
534 SPI_CONTROLLER_RAYER,
535#endif
Idwer Vollering004f4b72010-09-03 18:21:21 +0000536#if CONFIG_NICINTEL_SPI == 1
537 SPI_CONTROLLER_NICINTEL,
538#endif
Mark Marshall90021f22010-12-03 14:48:11 +0000539#if CONFIG_OGP_SPI == 1
540 SPI_CONTROLLER_OGP,
541#endif
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000542 SPI_CONTROLLER_INVALID /* This must always be the last entry. */
543};
544extern const int spi_programmer_count;
545struct spi_programmer {
546 int (*command)(unsigned int writecnt, unsigned int readcnt,
547 const unsigned char *writearr, unsigned char *readarr);
548 int (*multicommand)(struct spi_command *cmds);
549
550 /* Optimized functions for this programmer */
551 int (*read)(struct flashchip *flash, uint8_t *buf, int start, int len);
552 int (*write_256)(struct flashchip *flash, uint8_t *buf, int start, int len);
553};
554
555extern enum spi_controller spi_controller;
556extern const struct spi_programmer spi_programmer[];
557int default_spi_send_command(unsigned int writecnt, unsigned int readcnt,
558 const unsigned char *writearr, unsigned char *readarr);
559int default_spi_send_multicommand(struct spi_command *cmds);
560
561/* ichspi.c */
562#if CONFIG_INTERNAL == 1
563extern uint32_t ichspi_bbar;
564int ich_init_spi(struct pci_dev *dev, uint32_t base, void *rcrb,
565 int ich_generation);
566int via_init_spi(struct pci_dev *dev);
567int ich_spi_send_command(unsigned int writecnt, unsigned int readcnt,
568 const unsigned char *writearr, unsigned char *readarr);
569int ich_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
570int ich_spi_write_256(struct flashchip *flash, uint8_t * buf, int start, int len);
571int ich_spi_send_multicommand(struct spi_command *cmds);
572#endif
573
574/* it87spi.c */
575void enter_conf_mode_ite(uint16_t port);
576void exit_conf_mode_ite(uint16_t port);
577struct superio probe_superio_ite(void);
578int init_superio_ite(void);
579int it87spi_init(void);
580int it8716f_spi_send_command(unsigned int writecnt, unsigned int readcnt,
581 const unsigned char *writearr, unsigned char *readarr);
582int it8716f_spi_chip_read(struct flashchip *flash, uint8_t *buf, int start, int len);
583int it8716f_spi_chip_write_256(struct flashchip *flash, uint8_t *buf, int start, int len);
584
585/* sb600spi.c */
586#if CONFIG_INTERNAL == 1
587int sb600_probe_spi(struct pci_dev *dev);
588int sb600_spi_send_command(unsigned int writecnt, unsigned int readcnt,
589 const unsigned char *writearr, unsigned char *readarr);
590int sb600_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
591int sb600_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len);
592#endif
593
594/* wbsio_spi.c */
595#if CONFIG_INTERNAL == 1
596int wbsio_check_for_spi(void);
597int wbsio_spi_send_command(unsigned int writecnt, unsigned int readcnt,
598 const unsigned char *writearr, unsigned char *readarr);
599int wbsio_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
600#endif
601
602/* serprog.c */
603int serprog_init(void);
604int serprog_shutdown(void);
605void serprog_chip_writeb(uint8_t val, chipaddr addr);
606uint8_t serprog_chip_readb(const chipaddr addr);
607void serprog_chip_readn(uint8_t *buf, const chipaddr addr, size_t len);
608void serprog_delay(int delay);
609
610/* serial.c */
611#if _WIN32
612typedef HANDLE fdtype;
613#else
614typedef int fdtype;
615#endif
616
617void sp_flush_incoming(void);
618fdtype sp_openserport(char *dev, unsigned int baud);
619void __attribute__((noreturn)) sp_die(char *msg);
620extern fdtype sp_fd;
621int serialport_shutdown(void);
622int serialport_write(unsigned char *buf, unsigned int writecnt);
623int serialport_read(unsigned char *buf, unsigned int readcnt);
624
625#endif /* !__PROGRAMMER_H__ */