blob: 7698ef05cb0ef6d921ffbfe862c9d5176471a0ae [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,
Idwer Vollering004f4b72010-09-03 18:21:21 +000039#endif
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +000040#if CONFIG_NICNATSEMI == 1
41 PROGRAMMER_NICNATSEMI,
Idwer Vollering004f4b72010-09-03 18:21:21 +000042#endif
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +000043#if CONFIG_GFXNVIDIA == 1
44 PROGRAMMER_GFXNVIDIA,
45#endif
46#if CONFIG_DRKAISER == 1
47 PROGRAMMER_DRKAISER,
48#endif
49#if CONFIG_SATASII == 1
50 PROGRAMMER_SATASII,
51#endif
52#if CONFIG_ATAHPT == 1
53 PROGRAMMER_ATAHPT,
54#endif
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +000055#if CONFIG_FT2232_SPI == 1
56 PROGRAMMER_FT2232_SPI,
57#endif
58#if CONFIG_SERPROG == 1
59 PROGRAMMER_SERPROG,
60#endif
61#if CONFIG_BUSPIRATE_SPI == 1
62 PROGRAMMER_BUSPIRATE_SPI,
63#endif
64#if CONFIG_DEDIPROG == 1
65 PROGRAMMER_DEDIPROG,
66#endif
67#if CONFIG_RAYER_SPI == 1
68 PROGRAMMER_RAYER_SPI,
69#endif
Idwer Vollering004f4b72010-09-03 18:21:21 +000070#if CONFIG_NICINTEL_SPI == 1
71 PROGRAMMER_NICINTEL_SPI,
72#endif
Mark Marshall90021f22010-12-03 14:48:11 +000073#if CONFIG_OGP_SPI == 1
74 PROGRAMMER_OGP_SPI,
75#endif
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +000076#if CONFIG_SATAMV == 1
77 PROGRAMMER_SATAMV,
78#endif
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +000079 PROGRAMMER_INVALID /* This must always be the last entry. */
80};
81
82extern enum programmer programmer;
83
84struct programmer_entry {
85 const char *vendor;
86 const char *name;
87
88 int (*init) (void);
89 int (*shutdown) (void);
90
91 void * (*map_flash_region) (const char *descr, unsigned long phys_addr,
92 size_t len);
93 void (*unmap_flash_region) (void *virt_addr, size_t len);
94
95 void (*chip_writeb) (uint8_t val, chipaddr addr);
96 void (*chip_writew) (uint16_t val, chipaddr addr);
97 void (*chip_writel) (uint32_t val, chipaddr addr);
98 void (*chip_writen) (uint8_t *buf, chipaddr addr, size_t len);
99 uint8_t (*chip_readb) (const chipaddr addr);
100 uint16_t (*chip_readw) (const chipaddr addr);
101 uint32_t (*chip_readl) (const chipaddr addr);
102 void (*chip_readn) (uint8_t *buf, const chipaddr addr, size_t len);
103 void (*delay) (int usecs);
104};
105
106extern const struct programmer_entry programmer_table[];
107
108int programmer_init(char *param);
109int programmer_shutdown(void);
110
111enum bitbang_spi_master_type {
112 BITBANG_SPI_INVALID = 0, /* This must always be the first entry. */
113#if CONFIG_RAYER_SPI == 1
114 BITBANG_SPI_MASTER_RAYER,
115#endif
Idwer Vollering004f4b72010-09-03 18:21:21 +0000116#if CONFIG_NICINTEL_SPI == 1
117 BITBANG_SPI_MASTER_NICINTEL,
118#endif
Carl-Daniel Hailfinger2f436162010-07-28 15:08:35 +0000119#if CONFIG_INTERNAL == 1
120#if defined(__i386__) || defined(__x86_64__)
121 BITBANG_SPI_MASTER_MCP,
122#endif
123#endif
Mark Marshall90021f22010-12-03 14:48:11 +0000124#if CONFIG_OGP_SPI == 1
125 BITBANG_SPI_MASTER_OGP,
126#endif
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000127};
128
129struct bitbang_spi_master {
130 enum bitbang_spi_master_type type;
131
132 /* Note that CS# is active low, so val=0 means the chip is active. */
133 void (*set_cs) (int val);
134 void (*set_sck) (int val);
135 void (*set_mosi) (int val);
136 int (*get_miso) (void);
Carl-Daniel Hailfinger28228882010-09-15 00:17:37 +0000137 void (*request_bus) (void);
138 void (*release_bus) (void);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000139};
140
141#if CONFIG_INTERNAL == 1
142struct penable {
143 uint16_t vendor_id;
144 uint16_t device_id;
145 int status;
146 const char *vendor_name;
147 const char *device_name;
148 int (*doit) (struct pci_dev *dev, const char *name);
149};
150
151extern const struct penable chipset_enables[];
152
153struct board_pciid_enable {
154 /* Any device, but make it sensible, like the ISA bridge. */
155 uint16_t first_vendor;
156 uint16_t first_device;
157 uint16_t first_card_vendor;
158 uint16_t first_card_device;
159
160 /* Any device, but make it sensible, like
161 * the host bridge. May be NULL.
162 */
163 uint16_t second_vendor;
164 uint16_t second_device;
165 uint16_t second_card_vendor;
166 uint16_t second_card_device;
167
168 /* Pattern to match DMI entries */
169 const char *dmi_pattern;
170
171 /* The vendor / part name from the coreboot table. */
172 const char *lb_vendor;
173 const char *lb_part;
174
175 const char *vendor_name;
176 const char *board_name;
177
178 int max_rom_decode_parallel;
179 int status;
180 int (*enable) (void);
181};
182
183extern const struct board_pciid_enable board_pciid_enables[];
184
185struct board_info {
186 const char *vendor;
187 const char *name;
188 const int working;
189#ifdef CONFIG_PRINT_WIKI
190 const char *url;
191 const char *note;
192#endif
193};
194
195extern const struct board_info boards_known[];
196extern const struct board_info laptops_known[];
197#endif
198
199/* udelay.c */
200void myusec_delay(int usecs);
201void myusec_calibrate_delay(void);
202void internal_delay(int usecs);
203
204#if NEED_PCI == 1
205/* pcidev.c */
206extern uint32_t io_base_addr;
207extern struct pci_access *pacc;
208extern struct pci_dev *pcidev_dev;
209struct pcidev_status {
210 uint16_t vendor_id;
211 uint16_t device_id;
212 int status;
213 const char *vendor_name;
214 const char *device_name;
215};
Carl-Daniel Hailfinger8a19ef12011-02-15 22:44:27 +0000216uintptr_t pcidev_validate(struct pci_dev *dev, int bar, const struct pcidev_status *devs);
Carl-Daniel Hailfinger40446ee2011-03-07 01:08:09 +0000217uintptr_t pcidev_init(int bar, const struct pcidev_status *devs);
Carl-Daniel Hailfinger2bee8cf2010-11-10 15:25:18 +0000218/* rpci_write_* are reversible writes. The original PCI config space register
219 * contents will be restored on shutdown.
220 */
Idwer Vollering1a6162e2010-12-26 23:55:19 +0000221int rpci_write_byte(struct pci_dev *dev, int reg, uint8_t data);
222int rpci_write_word(struct pci_dev *dev, int reg, uint16_t data);
223int rpci_write_long(struct pci_dev *dev, int reg, uint32_t data);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000224#endif
225
226/* print.c */
Carl-Daniel Hailfingerd9535582011-03-08 00:09:11 +0000227#if CONFIG_NIC3COM+CONFIG_NICREALTEK+CONFIG_NICNATSEMI+CONFIG_GFXNVIDIA+CONFIG_DRKAISER+CONFIG_SATASII+CONFIG_ATAHPT+CONFIG_NICINTEL_SPI+CONFIG_OGP_SPI+CONFIG_SATAMV >= 1
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000228void print_supported_pcidevs(const struct pcidev_status *devs);
229#endif
230
231/* board_enable.c */
232void w836xx_ext_enter(uint16_t port);
233void w836xx_ext_leave(uint16_t port);
234int it8705f_write_enable(uint8_t port);
235uint8_t sio_read(uint16_t port, uint8_t reg);
236void sio_write(uint16_t port, uint8_t reg, uint8_t data);
237void sio_mask(uint16_t port, uint8_t reg, uint8_t data, uint8_t mask);
238int board_flash_enable(const char *vendor, const char *part);
239
240/* chipset_enable.c */
241int chipset_flash_enable(void);
242
243/* processor_enable.c */
244int processor_flash_enable(void);
245
246/* physmap.c */
247void *physmap(const char *descr, unsigned long phys_addr, size_t len);
248void *physmap_try_ro(const char *descr, unsigned long phys_addr, size_t len);
249void physunmap(void *virt_addr, size_t len);
250int setup_cpu_msr(int cpu);
251void cleanup_cpu_msr(void);
252
253/* cbtable.c */
254void lb_vendor_dev_from_string(char *boardstring);
255int coreboot_init(void);
256extern char *lb_part, *lb_vendor;
257extern int partvendor_from_cbtable;
258
259/* dmi.c */
260extern int has_dmi_support;
261void dmi_init(void);
262int dmi_match(const char *pattern);
263
264/* internal.c */
265#if NEED_PCI == 1
266struct superio {
267 uint16_t vendor;
268 uint16_t port;
269 uint16_t model;
270};
Carl-Daniel Hailfingerbfecef62011-04-27 14:34:08 +0000271extern struct superio superios[];
272extern int superio_count;
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000273#define SUPERIO_VENDOR_NONE 0x0
274#define SUPERIO_VENDOR_ITE 0x1
275struct pci_dev *pci_dev_find_filter(struct pci_filter filter);
276struct pci_dev *pci_dev_find_vendorclass(uint16_t vendor, uint16_t class);
277struct pci_dev *pci_dev_find(uint16_t vendor, uint16_t device);
278struct pci_dev *pci_card_find(uint16_t vendor, uint16_t device,
279 uint16_t card_vendor, uint16_t card_device);
280#endif
281void get_io_perms(void);
282void release_io_perms(void);
283#if CONFIG_INTERNAL == 1
284extern int is_laptop;
285extern int force_boardenable;
286extern int force_boardmismatch;
287void probe_superio(void);
Carl-Daniel Hailfingerbfecef62011-04-27 14:34:08 +0000288int register_superio(struct superio s);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000289int internal_init(void);
290int internal_shutdown(void);
291void internal_chip_writeb(uint8_t val, chipaddr addr);
292void internal_chip_writew(uint16_t val, chipaddr addr);
293void internal_chip_writel(uint32_t val, chipaddr addr);
294uint8_t internal_chip_readb(const chipaddr addr);
295uint16_t internal_chip_readw(const chipaddr addr);
296uint32_t internal_chip_readl(const chipaddr addr);
297void internal_chip_readn(uint8_t *buf, const chipaddr addr, size_t len);
298#endif
299
300/* hwaccess.c */
301void mmio_writeb(uint8_t val, void *addr);
302void mmio_writew(uint16_t val, void *addr);
303void mmio_writel(uint32_t val, void *addr);
304uint8_t mmio_readb(void *addr);
305uint16_t mmio_readw(void *addr);
306uint32_t mmio_readl(void *addr);
307void mmio_le_writeb(uint8_t val, void *addr);
308void mmio_le_writew(uint16_t val, void *addr);
309void mmio_le_writel(uint32_t val, void *addr);
310uint8_t mmio_le_readb(void *addr);
311uint16_t mmio_le_readw(void *addr);
312uint32_t mmio_le_readl(void *addr);
313#define pci_mmio_writeb mmio_le_writeb
314#define pci_mmio_writew mmio_le_writew
315#define pci_mmio_writel mmio_le_writel
316#define pci_mmio_readb mmio_le_readb
317#define pci_mmio_readw mmio_le_readw
318#define pci_mmio_readl mmio_le_readl
319
320/* programmer.c */
321int noop_shutdown(void);
322void *fallback_map(const char *descr, unsigned long phys_addr, size_t len);
323void fallback_unmap(void *virt_addr, size_t len);
324uint8_t noop_chip_readb(const chipaddr addr);
325void noop_chip_writeb(uint8_t val, chipaddr addr);
326void fallback_chip_writew(uint16_t val, chipaddr addr);
327void fallback_chip_writel(uint32_t val, chipaddr addr);
328void fallback_chip_writen(uint8_t *buf, chipaddr addr, size_t len);
329uint16_t fallback_chip_readw(const chipaddr addr);
330uint32_t fallback_chip_readl(const chipaddr addr);
331void fallback_chip_readn(uint8_t *buf, const chipaddr addr, size_t len);
332
333/* dummyflasher.c */
334#if CONFIG_DUMMY == 1
335int dummy_init(void);
336int dummy_shutdown(void);
337void *dummy_map(const char *descr, unsigned long phys_addr, size_t len);
338void dummy_unmap(void *virt_addr, size_t len);
339void dummy_chip_writeb(uint8_t val, chipaddr addr);
340void dummy_chip_writew(uint16_t val, chipaddr addr);
341void dummy_chip_writel(uint32_t val, chipaddr addr);
342void dummy_chip_writen(uint8_t *buf, chipaddr addr, size_t len);
343uint8_t dummy_chip_readb(const chipaddr addr);
344uint16_t dummy_chip_readw(const chipaddr addr);
345uint32_t dummy_chip_readl(const chipaddr addr);
346void dummy_chip_readn(uint8_t *buf, const chipaddr addr, size_t len);
347int dummy_spi_send_command(unsigned int writecnt, unsigned int readcnt,
348 const unsigned char *writearr, unsigned char *readarr);
349int dummy_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
350int dummy_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len);
351#endif
352
353/* nic3com.c */
354#if CONFIG_NIC3COM == 1
355int nic3com_init(void);
356int nic3com_shutdown(void);
357void nic3com_chip_writeb(uint8_t val, chipaddr addr);
358uint8_t nic3com_chip_readb(const chipaddr addr);
359extern const struct pcidev_status nics_3com[];
360#endif
361
362/* gfxnvidia.c */
363#if CONFIG_GFXNVIDIA == 1
364int gfxnvidia_init(void);
365int gfxnvidia_shutdown(void);
366void gfxnvidia_chip_writeb(uint8_t val, chipaddr addr);
367uint8_t gfxnvidia_chip_readb(const chipaddr addr);
368extern const struct pcidev_status gfx_nvidia[];
369#endif
370
371/* drkaiser.c */
372#if CONFIG_DRKAISER == 1
373int drkaiser_init(void);
374int drkaiser_shutdown(void);
375void drkaiser_chip_writeb(uint8_t val, chipaddr addr);
376uint8_t drkaiser_chip_readb(const chipaddr addr);
377extern const struct pcidev_status drkaiser_pcidev[];
378#endif
379
380/* nicrealtek.c */
381#if CONFIG_NICREALTEK == 1
382int nicrealtek_init(void);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000383int nicrealtek_shutdown(void);
384void nicrealtek_chip_writeb(uint8_t val, chipaddr addr);
385uint8_t nicrealtek_chip_readb(const chipaddr addr);
386extern const struct pcidev_status nics_realtek[];
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000387#endif
388
389/* nicnatsemi.c */
390#if CONFIG_NICNATSEMI == 1
391int nicnatsemi_init(void);
392int nicnatsemi_shutdown(void);
393void nicnatsemi_chip_writeb(uint8_t val, chipaddr addr);
394uint8_t nicnatsemi_chip_readb(const chipaddr addr);
395extern const struct pcidev_status nics_natsemi[];
396#endif
397
Idwer Vollering004f4b72010-09-03 18:21:21 +0000398/* nicintel_spi.c */
399#if CONFIG_NICINTEL_SPI == 1
400int nicintel_spi_init(void);
401int nicintel_spi_shutdown(void);
402int nicintel_spi_send_command(unsigned int writecnt, unsigned int readcnt,
403 const unsigned char *writearr, unsigned char *readarr);
404void nicintel_spi_chip_writeb(uint8_t val, chipaddr addr);
405extern const struct pcidev_status nics_intel_spi[];
406#endif
407
Mark Marshall90021f22010-12-03 14:48:11 +0000408/* ogp_spi.c */
409#if CONFIG_OGP_SPI == 1
410int ogp_spi_init(void);
411int ogp_spi_shutdown(void);
412extern const struct pcidev_status ogp_spi[];
413#endif
414
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000415/* satamv.c */
416#if CONFIG_SATAMV == 1
417int satamv_init(void);
418int satamv_shutdown(void);
419void satamv_chip_writeb(uint8_t val, chipaddr addr);
420uint8_t satamv_chip_readb(const chipaddr addr);
421extern const struct pcidev_status satas_mv[];
422#endif
423
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000424/* satasii.c */
425#if CONFIG_SATASII == 1
426int satasii_init(void);
427int satasii_shutdown(void);
428void satasii_chip_writeb(uint8_t val, chipaddr addr);
429uint8_t satasii_chip_readb(const chipaddr addr);
430extern const struct pcidev_status satas_sii[];
431#endif
432
433/* atahpt.c */
434#if CONFIG_ATAHPT == 1
435int atahpt_init(void);
436int atahpt_shutdown(void);
437void atahpt_chip_writeb(uint8_t val, chipaddr addr);
438uint8_t atahpt_chip_readb(const chipaddr addr);
439extern const struct pcidev_status ata_hpt[];
440#endif
441
442/* ft2232_spi.c */
Jörg Fischer6529b9f2010-07-29 15:54:53 +0000443#if CONFIG_FT2232_SPI == 1
444struct usbdev_status {
Uwe Hermann48ec1b12010-08-08 17:01:18 +0000445 uint16_t vendor_id;
446 uint16_t device_id;
447 int status;
448 const char *vendor_name;
449 const char *device_name;
Jörg Fischer6529b9f2010-07-29 15:54:53 +0000450};
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000451int ft2232_spi_init(void);
452int ft2232_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr);
453int ft2232_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
454int ft2232_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len);
Jörg Fischer6529b9f2010-07-29 15:54:53 +0000455extern const struct usbdev_status devs_ft2232spi[];
456void print_supported_usbdevs(const struct usbdev_status *devs);
457#endif
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000458
459/* rayer_spi.c */
460#if CONFIG_RAYER_SPI == 1
461int rayer_spi_init(void);
462#endif
463
Carl-Daniel Hailfinger2f436162010-07-28 15:08:35 +0000464/* mcp6x_spi.c */
465#if CONFIG_INTERNAL == 1
466#if defined(__i386__) || defined(__x86_64__)
467int mcp6x_spi_init(int want_spi);
468#endif
469#endif
470
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000471/* bitbang_spi.c */
472int bitbang_spi_init(const struct bitbang_spi_master *master, int halfperiod);
Carl-Daniel Hailfinger28228882010-09-15 00:17:37 +0000473int bitbang_spi_shutdown(const struct bitbang_spi_master *master);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000474int bitbang_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr);
475int bitbang_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
476int bitbang_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len);
477
478/* buspirate_spi.c */
479struct buspirate_spispeeds {
480 const char *name;
481 const int speed;
482};
483int buspirate_spi_init(void);
484int buspirate_spi_shutdown(void);
485int buspirate_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr);
486int buspirate_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
487int buspirate_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len);
488
489/* dediprog.c */
490int dediprog_init(void);
491int dediprog_shutdown(void);
492int dediprog_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr);
493int dediprog_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
Carl-Daniel Hailfinger306b8182010-11-23 21:28:16 +0000494int dediprog_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000495
496/* flashrom.c */
497struct decode_sizes {
498 uint32_t parallel;
499 uint32_t lpc;
500 uint32_t fwh;
501 uint32_t spi;
502};
503extern struct decode_sizes max_rom_decode;
504extern int programmer_may_write;
505extern unsigned long flashbase;
506void check_chip_supported(struct flashchip *flash);
507int check_max_decode(enum chipbustype buses, uint32_t size);
508char *extract_programmer_param(char *param_name);
509
510/* layout.c */
511int show_id(uint8_t *bios, int size, int force);
512
513/* spi.c */
514enum spi_controller {
515 SPI_CONTROLLER_NONE,
516#if CONFIG_INTERNAL == 1
517#if defined(__i386__) || defined(__x86_64__)
518 SPI_CONTROLLER_ICH7,
519 SPI_CONTROLLER_ICH9,
David Hendricks4e748392011-02-28 23:58:15 +0000520 SPI_CONTROLLER_IT85XX,
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000521 SPI_CONTROLLER_IT87XX,
522 SPI_CONTROLLER_SB600,
523 SPI_CONTROLLER_VIA,
524 SPI_CONTROLLER_WBSIO,
Carl-Daniel Hailfinger2f436162010-07-28 15:08:35 +0000525 SPI_CONTROLLER_MCP6X_BITBANG,
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000526#endif
527#endif
528#if CONFIG_FT2232_SPI == 1
529 SPI_CONTROLLER_FT2232,
530#endif
531#if CONFIG_DUMMY == 1
532 SPI_CONTROLLER_DUMMY,
533#endif
534#if CONFIG_BUSPIRATE_SPI == 1
535 SPI_CONTROLLER_BUSPIRATE,
536#endif
537#if CONFIG_DEDIPROG == 1
538 SPI_CONTROLLER_DEDIPROG,
539#endif
540#if CONFIG_RAYER_SPI == 1
541 SPI_CONTROLLER_RAYER,
542#endif
Idwer Vollering004f4b72010-09-03 18:21:21 +0000543#if CONFIG_NICINTEL_SPI == 1
544 SPI_CONTROLLER_NICINTEL,
545#endif
Mark Marshall90021f22010-12-03 14:48:11 +0000546#if CONFIG_OGP_SPI == 1
547 SPI_CONTROLLER_OGP,
548#endif
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000549 SPI_CONTROLLER_INVALID /* This must always be the last entry. */
550};
551extern const int spi_programmer_count;
552struct spi_programmer {
553 int (*command)(unsigned int writecnt, unsigned int readcnt,
554 const unsigned char *writearr, unsigned char *readarr);
555 int (*multicommand)(struct spi_command *cmds);
556
557 /* Optimized functions for this programmer */
558 int (*read)(struct flashchip *flash, uint8_t *buf, int start, int len);
559 int (*write_256)(struct flashchip *flash, uint8_t *buf, int start, int len);
560};
561
562extern enum spi_controller spi_controller;
563extern const struct spi_programmer spi_programmer[];
564int default_spi_send_command(unsigned int writecnt, unsigned int readcnt,
565 const unsigned char *writearr, unsigned char *readarr);
566int default_spi_send_multicommand(struct spi_command *cmds);
567
568/* ichspi.c */
569#if CONFIG_INTERNAL == 1
570extern uint32_t ichspi_bbar;
571int ich_init_spi(struct pci_dev *dev, uint32_t base, void *rcrb,
572 int ich_generation);
573int via_init_spi(struct pci_dev *dev);
574int ich_spi_send_command(unsigned int writecnt, unsigned int readcnt,
575 const unsigned char *writearr, unsigned char *readarr);
576int ich_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
577int ich_spi_write_256(struct flashchip *flash, uint8_t * buf, int start, int len);
578int ich_spi_send_multicommand(struct spi_command *cmds);
579#endif
580
David Hendricks4e748392011-02-28 23:58:15 +0000581/* it85spi.c */
Carl-Daniel Hailfingerbfecef62011-04-27 14:34:08 +0000582int it85xx_spi_init(struct superio s);
David Hendricks4e748392011-02-28 23:58:15 +0000583int it85xx_shutdown(void);
David Hendricks4e748392011-02-28 23:58:15 +0000584int it85xx_spi_send_command(unsigned int writecnt, unsigned int readcnt,
585 const unsigned char *writearr, unsigned char *readarr);
Carl-Daniel Hailfinger7f517a72011-03-08 00:23:49 +0000586int it85_spi_read(struct flashchip *flash, uint8_t * buf, int start, int len);
587int it85_spi_write_256(struct flashchip *flash, uint8_t * buf, int start, int len);
David Hendricks4e748392011-02-28 23:58:15 +0000588
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000589/* it87spi.c */
590void enter_conf_mode_ite(uint16_t port);
591void exit_conf_mode_ite(uint16_t port);
Carl-Daniel Hailfingerbfecef62011-04-27 14:34:08 +0000592void probe_superio_ite(void);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000593int init_superio_ite(void);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000594int it8716f_spi_send_command(unsigned int writecnt, unsigned int readcnt,
595 const unsigned char *writearr, unsigned char *readarr);
596int it8716f_spi_chip_read(struct flashchip *flash, uint8_t *buf, int start, int len);
597int it8716f_spi_chip_write_256(struct flashchip *flash, uint8_t *buf, int start, int len);
598
599/* sb600spi.c */
600#if CONFIG_INTERNAL == 1
601int sb600_probe_spi(struct pci_dev *dev);
602int sb600_spi_send_command(unsigned int writecnt, unsigned int readcnt,
603 const unsigned char *writearr, unsigned char *readarr);
604int sb600_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
605int sb600_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len);
606#endif
607
608/* wbsio_spi.c */
609#if CONFIG_INTERNAL == 1
610int wbsio_check_for_spi(void);
611int wbsio_spi_send_command(unsigned int writecnt, unsigned int readcnt,
612 const unsigned char *writearr, unsigned char *readarr);
613int wbsio_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
614#endif
615
616/* serprog.c */
617int serprog_init(void);
618int serprog_shutdown(void);
619void serprog_chip_writeb(uint8_t val, chipaddr addr);
620uint8_t serprog_chip_readb(const chipaddr addr);
621void serprog_chip_readn(uint8_t *buf, const chipaddr addr, size_t len);
622void serprog_delay(int delay);
623
624/* serial.c */
625#if _WIN32
626typedef HANDLE fdtype;
627#else
628typedef int fdtype;
629#endif
630
631void sp_flush_incoming(void);
632fdtype sp_openserport(char *dev, unsigned int baud);
633void __attribute__((noreturn)) sp_die(char *msg);
634extern fdtype sp_fd;
635int serialport_shutdown(void);
636int serialport_write(unsigned char *buf, unsigned int writecnt);
637int serialport_read(unsigned char *buf, unsigned int readcnt);
638
639#endif /* !__PROGRAMMER_H__ */