blob: 19c3a308d547004204a0fcf94fe41d378d6584be [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
Carl-Daniel Hailfinger54ce73a2011-05-03 21:49:41 +0000319void rmmio_writeb(uint8_t val, void *addr);
320void rmmio_writew(uint16_t val, void *addr);
321void rmmio_writel(uint32_t val, void *addr);
322void rmmio_le_writeb(uint8_t val, void *addr);
323void rmmio_le_writew(uint16_t val, void *addr);
324void rmmio_le_writel(uint32_t val, void *addr);
325#define pci_rmmio_writeb rmmio_le_writeb
326#define pci_rmmio_writew rmmio_le_writew
327#define pci_rmmio_writel rmmio_le_writel
328void rmmio_valb(void *addr);
329void rmmio_valw(void *addr);
330void rmmio_vall(void *addr);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000331
332/* programmer.c */
333int noop_shutdown(void);
334void *fallback_map(const char *descr, unsigned long phys_addr, size_t len);
335void fallback_unmap(void *virt_addr, size_t len);
336uint8_t noop_chip_readb(const chipaddr addr);
337void noop_chip_writeb(uint8_t val, chipaddr addr);
338void fallback_chip_writew(uint16_t val, chipaddr addr);
339void fallback_chip_writel(uint32_t val, chipaddr addr);
340void fallback_chip_writen(uint8_t *buf, chipaddr addr, size_t len);
341uint16_t fallback_chip_readw(const chipaddr addr);
342uint32_t fallback_chip_readl(const chipaddr addr);
343void fallback_chip_readn(uint8_t *buf, const chipaddr addr, size_t len);
344
345/* dummyflasher.c */
346#if CONFIG_DUMMY == 1
347int dummy_init(void);
348int dummy_shutdown(void);
349void *dummy_map(const char *descr, unsigned long phys_addr, size_t len);
350void dummy_unmap(void *virt_addr, size_t len);
351void dummy_chip_writeb(uint8_t val, chipaddr addr);
352void dummy_chip_writew(uint16_t val, chipaddr addr);
353void dummy_chip_writel(uint32_t val, chipaddr addr);
354void dummy_chip_writen(uint8_t *buf, chipaddr addr, size_t len);
355uint8_t dummy_chip_readb(const chipaddr addr);
356uint16_t dummy_chip_readw(const chipaddr addr);
357uint32_t dummy_chip_readl(const chipaddr addr);
358void dummy_chip_readn(uint8_t *buf, const chipaddr addr, size_t len);
359int dummy_spi_send_command(unsigned int writecnt, unsigned int readcnt,
360 const unsigned char *writearr, unsigned char *readarr);
361int dummy_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
362int dummy_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len);
363#endif
364
365/* nic3com.c */
366#if CONFIG_NIC3COM == 1
367int nic3com_init(void);
368int nic3com_shutdown(void);
369void nic3com_chip_writeb(uint8_t val, chipaddr addr);
370uint8_t nic3com_chip_readb(const chipaddr addr);
371extern const struct pcidev_status nics_3com[];
372#endif
373
374/* gfxnvidia.c */
375#if CONFIG_GFXNVIDIA == 1
376int gfxnvidia_init(void);
377int gfxnvidia_shutdown(void);
378void gfxnvidia_chip_writeb(uint8_t val, chipaddr addr);
379uint8_t gfxnvidia_chip_readb(const chipaddr addr);
380extern const struct pcidev_status gfx_nvidia[];
381#endif
382
383/* drkaiser.c */
384#if CONFIG_DRKAISER == 1
385int drkaiser_init(void);
386int drkaiser_shutdown(void);
387void drkaiser_chip_writeb(uint8_t val, chipaddr addr);
388uint8_t drkaiser_chip_readb(const chipaddr addr);
389extern const struct pcidev_status drkaiser_pcidev[];
390#endif
391
392/* nicrealtek.c */
393#if CONFIG_NICREALTEK == 1
394int nicrealtek_init(void);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000395int nicrealtek_shutdown(void);
396void nicrealtek_chip_writeb(uint8_t val, chipaddr addr);
397uint8_t nicrealtek_chip_readb(const chipaddr addr);
398extern const struct pcidev_status nics_realtek[];
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000399#endif
400
401/* nicnatsemi.c */
402#if CONFIG_NICNATSEMI == 1
403int nicnatsemi_init(void);
404int nicnatsemi_shutdown(void);
405void nicnatsemi_chip_writeb(uint8_t val, chipaddr addr);
406uint8_t nicnatsemi_chip_readb(const chipaddr addr);
407extern const struct pcidev_status nics_natsemi[];
408#endif
409
Idwer Vollering004f4b72010-09-03 18:21:21 +0000410/* nicintel_spi.c */
411#if CONFIG_NICINTEL_SPI == 1
412int nicintel_spi_init(void);
413int nicintel_spi_shutdown(void);
414int nicintel_spi_send_command(unsigned int writecnt, unsigned int readcnt,
415 const unsigned char *writearr, unsigned char *readarr);
416void nicintel_spi_chip_writeb(uint8_t val, chipaddr addr);
417extern const struct pcidev_status nics_intel_spi[];
418#endif
419
Mark Marshall90021f22010-12-03 14:48:11 +0000420/* ogp_spi.c */
421#if CONFIG_OGP_SPI == 1
422int ogp_spi_init(void);
423int ogp_spi_shutdown(void);
424extern const struct pcidev_status ogp_spi[];
425#endif
426
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000427/* satamv.c */
428#if CONFIG_SATAMV == 1
429int satamv_init(void);
430int satamv_shutdown(void);
431void satamv_chip_writeb(uint8_t val, chipaddr addr);
432uint8_t satamv_chip_readb(const chipaddr addr);
433extern const struct pcidev_status satas_mv[];
434#endif
435
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000436/* satasii.c */
437#if CONFIG_SATASII == 1
438int satasii_init(void);
439int satasii_shutdown(void);
440void satasii_chip_writeb(uint8_t val, chipaddr addr);
441uint8_t satasii_chip_readb(const chipaddr addr);
442extern const struct pcidev_status satas_sii[];
443#endif
444
445/* atahpt.c */
446#if CONFIG_ATAHPT == 1
447int atahpt_init(void);
448int atahpt_shutdown(void);
449void atahpt_chip_writeb(uint8_t val, chipaddr addr);
450uint8_t atahpt_chip_readb(const chipaddr addr);
451extern const struct pcidev_status ata_hpt[];
452#endif
453
454/* ft2232_spi.c */
Jörg Fischer6529b9f2010-07-29 15:54:53 +0000455#if CONFIG_FT2232_SPI == 1
456struct usbdev_status {
Uwe Hermann48ec1b12010-08-08 17:01:18 +0000457 uint16_t vendor_id;
458 uint16_t device_id;
459 int status;
460 const char *vendor_name;
461 const char *device_name;
Jörg Fischer6529b9f2010-07-29 15:54:53 +0000462};
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000463int ft2232_spi_init(void);
464int ft2232_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr);
465int ft2232_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
466int ft2232_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len);
Jörg Fischer6529b9f2010-07-29 15:54:53 +0000467extern const struct usbdev_status devs_ft2232spi[];
468void print_supported_usbdevs(const struct usbdev_status *devs);
469#endif
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000470
471/* rayer_spi.c */
472#if CONFIG_RAYER_SPI == 1
473int rayer_spi_init(void);
474#endif
475
Carl-Daniel Hailfinger2f436162010-07-28 15:08:35 +0000476/* mcp6x_spi.c */
477#if CONFIG_INTERNAL == 1
478#if defined(__i386__) || defined(__x86_64__)
479int mcp6x_spi_init(int want_spi);
480#endif
481#endif
482
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000483/* bitbang_spi.c */
484int bitbang_spi_init(const struct bitbang_spi_master *master, int halfperiod);
Carl-Daniel Hailfinger28228882010-09-15 00:17:37 +0000485int bitbang_spi_shutdown(const struct bitbang_spi_master *master);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000486int bitbang_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr);
487int bitbang_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
488int bitbang_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len);
489
490/* buspirate_spi.c */
491struct buspirate_spispeeds {
492 const char *name;
493 const int speed;
494};
495int buspirate_spi_init(void);
496int buspirate_spi_shutdown(void);
497int buspirate_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr);
498int buspirate_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
499int buspirate_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len);
500
501/* dediprog.c */
502int dediprog_init(void);
503int dediprog_shutdown(void);
504int dediprog_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr);
505int dediprog_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
Carl-Daniel Hailfinger306b8182010-11-23 21:28:16 +0000506int dediprog_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000507
508/* flashrom.c */
509struct decode_sizes {
510 uint32_t parallel;
511 uint32_t lpc;
512 uint32_t fwh;
513 uint32_t spi;
514};
515extern struct decode_sizes max_rom_decode;
516extern int programmer_may_write;
517extern unsigned long flashbase;
Carl-Daniel Hailfinger4c823182011-05-04 00:39:50 +0000518void check_chip_supported(const struct flashchip *flash);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000519int check_max_decode(enum chipbustype buses, uint32_t size);
520char *extract_programmer_param(char *param_name);
521
522/* layout.c */
523int show_id(uint8_t *bios, int size, int force);
524
525/* spi.c */
526enum spi_controller {
527 SPI_CONTROLLER_NONE,
528#if CONFIG_INTERNAL == 1
529#if defined(__i386__) || defined(__x86_64__)
530 SPI_CONTROLLER_ICH7,
531 SPI_CONTROLLER_ICH9,
David Hendricks4e748392011-02-28 23:58:15 +0000532 SPI_CONTROLLER_IT85XX,
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000533 SPI_CONTROLLER_IT87XX,
534 SPI_CONTROLLER_SB600,
535 SPI_CONTROLLER_VIA,
536 SPI_CONTROLLER_WBSIO,
Carl-Daniel Hailfinger2f436162010-07-28 15:08:35 +0000537 SPI_CONTROLLER_MCP6X_BITBANG,
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000538#endif
539#endif
540#if CONFIG_FT2232_SPI == 1
541 SPI_CONTROLLER_FT2232,
542#endif
543#if CONFIG_DUMMY == 1
544 SPI_CONTROLLER_DUMMY,
545#endif
546#if CONFIG_BUSPIRATE_SPI == 1
547 SPI_CONTROLLER_BUSPIRATE,
548#endif
549#if CONFIG_DEDIPROG == 1
550 SPI_CONTROLLER_DEDIPROG,
551#endif
552#if CONFIG_RAYER_SPI == 1
553 SPI_CONTROLLER_RAYER,
554#endif
Idwer Vollering004f4b72010-09-03 18:21:21 +0000555#if CONFIG_NICINTEL_SPI == 1
556 SPI_CONTROLLER_NICINTEL,
557#endif
Mark Marshall90021f22010-12-03 14:48:11 +0000558#if CONFIG_OGP_SPI == 1
559 SPI_CONTROLLER_OGP,
560#endif
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000561 SPI_CONTROLLER_INVALID /* This must always be the last entry. */
562};
563extern const int spi_programmer_count;
564struct spi_programmer {
565 int (*command)(unsigned int writecnt, unsigned int readcnt,
566 const unsigned char *writearr, unsigned char *readarr);
567 int (*multicommand)(struct spi_command *cmds);
568
569 /* Optimized functions for this programmer */
570 int (*read)(struct flashchip *flash, uint8_t *buf, int start, int len);
571 int (*write_256)(struct flashchip *flash, uint8_t *buf, int start, int len);
572};
573
574extern enum spi_controller spi_controller;
575extern const struct spi_programmer spi_programmer[];
576int default_spi_send_command(unsigned int writecnt, unsigned int readcnt,
577 const unsigned char *writearr, unsigned char *readarr);
578int default_spi_send_multicommand(struct spi_command *cmds);
579
580/* ichspi.c */
581#if CONFIG_INTERNAL == 1
582extern uint32_t ichspi_bbar;
583int ich_init_spi(struct pci_dev *dev, uint32_t base, void *rcrb,
584 int ich_generation);
585int via_init_spi(struct pci_dev *dev);
586int ich_spi_send_command(unsigned int writecnt, unsigned int readcnt,
587 const unsigned char *writearr, unsigned char *readarr);
588int ich_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
589int ich_spi_write_256(struct flashchip *flash, uint8_t * buf, int start, int len);
590int ich_spi_send_multicommand(struct spi_command *cmds);
591#endif
592
David Hendricks4e748392011-02-28 23:58:15 +0000593/* it85spi.c */
Carl-Daniel Hailfingerbfecef62011-04-27 14:34:08 +0000594int it85xx_spi_init(struct superio s);
David Hendricks4e748392011-02-28 23:58:15 +0000595int it85xx_shutdown(void);
David Hendricks4e748392011-02-28 23:58:15 +0000596int it85xx_spi_send_command(unsigned int writecnt, unsigned int readcnt,
597 const unsigned char *writearr, unsigned char *readarr);
Carl-Daniel Hailfinger7f517a72011-03-08 00:23:49 +0000598int it85_spi_read(struct flashchip *flash, uint8_t * buf, int start, int len);
599int it85_spi_write_256(struct flashchip *flash, uint8_t * buf, int start, int len);
David Hendricks4e748392011-02-28 23:58:15 +0000600
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000601/* it87spi.c */
602void enter_conf_mode_ite(uint16_t port);
603void exit_conf_mode_ite(uint16_t port);
Carl-Daniel Hailfingerbfecef62011-04-27 14:34:08 +0000604void probe_superio_ite(void);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000605int init_superio_ite(void);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000606int it8716f_spi_send_command(unsigned int writecnt, unsigned int readcnt,
607 const unsigned char *writearr, unsigned char *readarr);
608int it8716f_spi_chip_read(struct flashchip *flash, uint8_t *buf, int start, int len);
609int it8716f_spi_chip_write_256(struct flashchip *flash, uint8_t *buf, int start, int len);
610
611/* sb600spi.c */
612#if CONFIG_INTERNAL == 1
613int sb600_probe_spi(struct pci_dev *dev);
614int sb600_spi_send_command(unsigned int writecnt, unsigned int readcnt,
615 const unsigned char *writearr, unsigned char *readarr);
616int sb600_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
617int sb600_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len);
618#endif
619
620/* wbsio_spi.c */
621#if CONFIG_INTERNAL == 1
622int wbsio_check_for_spi(void);
623int wbsio_spi_send_command(unsigned int writecnt, unsigned int readcnt,
624 const unsigned char *writearr, unsigned char *readarr);
625int wbsio_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
626#endif
627
628/* serprog.c */
629int serprog_init(void);
630int serprog_shutdown(void);
631void serprog_chip_writeb(uint8_t val, chipaddr addr);
632uint8_t serprog_chip_readb(const chipaddr addr);
633void serprog_chip_readn(uint8_t *buf, const chipaddr addr, size_t len);
634void serprog_delay(int delay);
635
636/* serial.c */
637#if _WIN32
638typedef HANDLE fdtype;
639#else
640typedef int fdtype;
641#endif
642
643void sp_flush_incoming(void);
644fdtype sp_openserport(char *dev, unsigned int baud);
645void __attribute__((noreturn)) sp_die(char *msg);
646extern fdtype sp_fd;
647int serialport_shutdown(void);
648int serialport_write(unsigned char *buf, unsigned int writecnt);
649int serialport_read(unsigned char *buf, unsigned int readcnt);
650
651#endif /* !__PROGRAMMER_H__ */