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