blob: 1817e2756fdb4887f396235f881ba5fcc2663dc2 [file] [log] [blame]
hailfinger428f6852010-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,
uwe6764e922010-09-03 18:21:21 +000039#endif
hailfinger428f6852010-07-27 22:41:39 +000040#if CONFIG_NICNATSEMI == 1
41 PROGRAMMER_NICNATSEMI,
uwe6764e922010-09-03 18:21:21 +000042#endif
hailfinger428f6852010-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
hailfinger428f6852010-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
hailfinger7949b652011-05-08 00:24:18 +000070#if CONFIG_NICINTEL == 1
71 PROGRAMMER_NICINTEL,
72#endif
uwe6764e922010-09-03 18:21:21 +000073#if CONFIG_NICINTEL_SPI == 1
74 PROGRAMMER_NICINTEL_SPI,
75#endif
hailfingerfb1f31f2010-12-03 14:48:11 +000076#if CONFIG_OGP_SPI == 1
77 PROGRAMMER_OGP_SPI,
78#endif
hailfinger935365d2011-02-04 21:37:59 +000079#if CONFIG_SATAMV == 1
80 PROGRAMMER_SATAMV,
81#endif
uwe7df6dda2011-09-03 18:37:52 +000082#if CONFIG_LINUX_SPI == 1
83 PROGRAMMER_LINUX_SPI,
84#endif
hailfinger428f6852010-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);
hailfinger428f6852010-07-27 22:41:39 +000095
96 void * (*map_flash_region) (const char *descr, unsigned long phys_addr,
97 size_t len);
98 void (*unmap_flash_region) (void *virt_addr, size_t len);
99
100 void (*chip_writeb) (uint8_t val, chipaddr addr);
101 void (*chip_writew) (uint16_t val, chipaddr addr);
102 void (*chip_writel) (uint32_t val, chipaddr addr);
103 void (*chip_writen) (uint8_t *buf, chipaddr addr, size_t len);
104 uint8_t (*chip_readb) (const chipaddr addr);
105 uint16_t (*chip_readw) (const chipaddr addr);
106 uint32_t (*chip_readl) (const chipaddr addr);
107 void (*chip_readn) (uint8_t *buf, const chipaddr addr, size_t len);
108 void (*delay) (int usecs);
109};
110
111extern const struct programmer_entry programmer_table[];
112
113int programmer_init(char *param);
114int programmer_shutdown(void);
115
116enum bitbang_spi_master_type {
117 BITBANG_SPI_INVALID = 0, /* This must always be the first entry. */
118#if CONFIG_RAYER_SPI == 1
119 BITBANG_SPI_MASTER_RAYER,
120#endif
uwe6764e922010-09-03 18:21:21 +0000121#if CONFIG_NICINTEL_SPI == 1
122 BITBANG_SPI_MASTER_NICINTEL,
123#endif
hailfinger52384c92010-07-28 15:08:35 +0000124#if CONFIG_INTERNAL == 1
125#if defined(__i386__) || defined(__x86_64__)
126 BITBANG_SPI_MASTER_MCP,
127#endif
128#endif
hailfingerfb1f31f2010-12-03 14:48:11 +0000129#if CONFIG_OGP_SPI == 1
130 BITBANG_SPI_MASTER_OGP,
131#endif
hailfinger428f6852010-07-27 22:41:39 +0000132};
133
134struct bitbang_spi_master {
135 enum bitbang_spi_master_type type;
136
137 /* Note that CS# is active low, so val=0 means the chip is active. */
138 void (*set_cs) (int val);
139 void (*set_sck) (int val);
140 void (*set_mosi) (int val);
141 int (*get_miso) (void);
hailfinger12cba9a2010-09-15 00:17:37 +0000142 void (*request_bus) (void);
143 void (*release_bus) (void);
hailfinger428f6852010-07-27 22:41:39 +0000144};
145
146#if CONFIG_INTERNAL == 1
147struct penable {
148 uint16_t vendor_id;
149 uint16_t device_id;
stefanct6d836ba2011-05-26 01:35:19 +0000150 int status; /* OK=0 and NT=1 are defines only. Beware! */
hailfinger428f6852010-07-27 22:41:39 +0000151 const char *vendor_name;
152 const char *device_name;
153 int (*doit) (struct pci_dev *dev, const char *name);
154};
155
156extern const struct penable chipset_enables[];
157
hailfingere52e9f82011-05-05 07:12:40 +0000158enum board_match_phase {
159 P1,
160 P2,
161 P3
162};
163
hailfinger4640bdb2011-08-31 16:19:50 +0000164struct board_match {
hailfinger428f6852010-07-27 22:41:39 +0000165 /* Any device, but make it sensible, like the ISA bridge. */
166 uint16_t first_vendor;
167 uint16_t first_device;
168 uint16_t first_card_vendor;
169 uint16_t first_card_device;
170
171 /* Any device, but make it sensible, like
172 * the host bridge. May be NULL.
173 */
174 uint16_t second_vendor;
175 uint16_t second_device;
176 uint16_t second_card_vendor;
177 uint16_t second_card_device;
178
stefanct6d836ba2011-05-26 01:35:19 +0000179 /* Pattern to match DMI entries. May be NULL. */
hailfinger428f6852010-07-27 22:41:39 +0000180 const char *dmi_pattern;
181
stefanct6d836ba2011-05-26 01:35:19 +0000182 /* The vendor / part name from the coreboot table. May be NULL. */
hailfinger428f6852010-07-27 22:41:39 +0000183 const char *lb_vendor;
184 const char *lb_part;
185
hailfingere52e9f82011-05-05 07:12:40 +0000186 enum board_match_phase phase;
187
hailfinger428f6852010-07-27 22:41:39 +0000188 const char *vendor_name;
189 const char *board_name;
190
191 int max_rom_decode_parallel;
192 int status;
stefanct6d836ba2011-05-26 01:35:19 +0000193 int (*enable) (void); /* May be NULL. */
hailfinger428f6852010-07-27 22:41:39 +0000194};
195
hailfinger4640bdb2011-08-31 16:19:50 +0000196extern const struct board_match board_matches[];
hailfinger428f6852010-07-27 22:41:39 +0000197
198struct board_info {
199 const char *vendor;
200 const char *name;
201 const int working;
202#ifdef CONFIG_PRINT_WIKI
203 const char *url;
204 const char *note;
205#endif
206};
207
208extern const struct board_info boards_known[];
209extern const struct board_info laptops_known[];
210#endif
211
212/* udelay.c */
213void myusec_delay(int usecs);
214void myusec_calibrate_delay(void);
215void internal_delay(int usecs);
216
217#if NEED_PCI == 1
218/* pcidev.c */
219extern uint32_t io_base_addr;
220extern struct pci_access *pacc;
221extern struct pci_dev *pcidev_dev;
222struct pcidev_status {
223 uint16_t vendor_id;
224 uint16_t device_id;
225 int status;
226 const char *vendor_name;
227 const char *device_name;
228};
hailfingerbf923c32011-02-15 22:44:27 +0000229uintptr_t pcidev_validate(struct pci_dev *dev, int bar, const struct pcidev_status *devs);
hailfinger0d703d42011-03-07 01:08:09 +0000230uintptr_t pcidev_init(int bar, const struct pcidev_status *devs);
hailfingerf31cbdc2010-11-10 15:25:18 +0000231/* rpci_write_* are reversible writes. The original PCI config space register
232 * contents will be restored on shutdown.
233 */
mkarcher08a24552010-12-26 23:55:19 +0000234int rpci_write_byte(struct pci_dev *dev, int reg, uint8_t data);
235int rpci_write_word(struct pci_dev *dev, int reg, uint16_t data);
236int rpci_write_long(struct pci_dev *dev, int reg, uint32_t data);
hailfinger428f6852010-07-27 22:41:39 +0000237#endif
238
239/* print.c */
hailfinger7949b652011-05-08 00:24:18 +0000240#if CONFIG_NIC3COM+CONFIG_NICREALTEK+CONFIG_NICNATSEMI+CONFIG_GFXNVIDIA+CONFIG_DRKAISER+CONFIG_SATASII+CONFIG_ATAHPT+CONFIG_NICINTEL+CONFIG_NICINTEL_SPI+CONFIG_OGP_SPI+CONFIG_SATAMV >= 1
hailfinger428f6852010-07-27 22:41:39 +0000241void print_supported_pcidevs(const struct pcidev_status *devs);
242#endif
243
hailfingere20dc562011-06-09 20:06:34 +0000244#if CONFIG_INTERNAL == 1
hailfinger428f6852010-07-27 22:41:39 +0000245/* board_enable.c */
246void w836xx_ext_enter(uint16_t port);
247void w836xx_ext_leave(uint16_t port);
248int it8705f_write_enable(uint8_t port);
249uint8_t sio_read(uint16_t port, uint8_t reg);
250void sio_write(uint16_t port, uint8_t reg, uint8_t data);
251void sio_mask(uint16_t port, uint8_t reg, uint8_t data, uint8_t mask);
hailfingere52e9f82011-05-05 07:12:40 +0000252void board_handle_before_superio(void);
253void board_handle_before_laptop(void);
hailfinger428f6852010-07-27 22:41:39 +0000254int board_flash_enable(const char *vendor, const char *part);
255
256/* chipset_enable.c */
257int chipset_flash_enable(void);
Louis Yung-Chieh Lo6b8f0462011-01-06 12:49:46 +0800258int get_target_bus_from_chipset(enum chipbustype *target_bus);
hailfinger428f6852010-07-27 22:41:39 +0000259
260/* processor_enable.c */
261int processor_flash_enable(void);
hailfingere52e9f82011-05-05 07:12:40 +0000262#endif
hailfinger428f6852010-07-27 22:41:39 +0000263
264/* physmap.c */
265void *physmap(const char *descr, unsigned long phys_addr, size_t len);
266void *physmap_try_ro(const char *descr, unsigned long phys_addr, size_t len);
267void physunmap(void *virt_addr, size_t len);
hailfingere20dc562011-06-09 20:06:34 +0000268#if CONFIG_INTERNAL == 1
hailfinger428f6852010-07-27 22:41:39 +0000269int setup_cpu_msr(int cpu);
270void cleanup_cpu_msr(void);
271
272/* cbtable.c */
273void lb_vendor_dev_from_string(char *boardstring);
274int coreboot_init(void);
275extern char *lb_part, *lb_vendor;
276extern int partvendor_from_cbtable;
277
278/* dmi.c */
279extern int has_dmi_support;
280void dmi_init(void);
281int dmi_match(const char *pattern);
282
283/* internal.c */
hailfinger428f6852010-07-27 22:41:39 +0000284struct superio {
285 uint16_t vendor;
286 uint16_t port;
287 uint16_t model;
288};
hailfinger94e090c2011-04-27 14:34:08 +0000289extern struct superio superios[];
290extern int superio_count;
hailfinger428f6852010-07-27 22:41:39 +0000291#define SUPERIO_VENDOR_NONE 0x0
292#define SUPERIO_VENDOR_ITE 0x1
hailfingere20dc562011-06-09 20:06:34 +0000293#endif
294#if NEED_PCI == 1
hailfinger428f6852010-07-27 22:41:39 +0000295struct pci_dev *pci_dev_find_filter(struct pci_filter filter);
uwe922946a2011-07-13 11:22:03 +0000296struct pci_dev *pci_dev_find_vendorclass(uint16_t vendor, uint16_t devclass);
hailfinger428f6852010-07-27 22:41:39 +0000297struct pci_dev *pci_dev_find(uint16_t vendor, uint16_t device);
298struct pci_dev *pci_card_find(uint16_t vendor, uint16_t device,
299 uint16_t card_vendor, uint16_t card_device);
300#endif
301void get_io_perms(void);
302void release_io_perms(void);
303#if CONFIG_INTERNAL == 1
304extern int is_laptop;
hailfingere52e9f82011-05-05 07:12:40 +0000305extern int laptop_ok;
hailfinger428f6852010-07-27 22:41:39 +0000306extern int force_boardenable;
307extern int force_boardmismatch;
308void probe_superio(void);
hailfinger94e090c2011-04-27 14:34:08 +0000309int register_superio(struct superio s);
hailfinger428f6852010-07-27 22:41:39 +0000310int internal_init(void);
hailfinger428f6852010-07-27 22:41:39 +0000311void internal_chip_writeb(uint8_t val, chipaddr addr);
312void internal_chip_writew(uint16_t val, chipaddr addr);
313void internal_chip_writel(uint32_t val, chipaddr addr);
314uint8_t internal_chip_readb(const chipaddr addr);
315uint16_t internal_chip_readw(const chipaddr addr);
316uint32_t internal_chip_readl(const chipaddr addr);
317void internal_chip_readn(uint8_t *buf, const chipaddr addr, size_t len);
318#endif
319
320/* hwaccess.c */
321void mmio_writeb(uint8_t val, void *addr);
322void mmio_writew(uint16_t val, void *addr);
323void mmio_writel(uint32_t val, void *addr);
324uint8_t mmio_readb(void *addr);
325uint16_t mmio_readw(void *addr);
326uint32_t mmio_readl(void *addr);
327void mmio_le_writeb(uint8_t val, void *addr);
328void mmio_le_writew(uint16_t val, void *addr);
329void mmio_le_writel(uint32_t val, void *addr);
330uint8_t mmio_le_readb(void *addr);
331uint16_t mmio_le_readw(void *addr);
332uint32_t mmio_le_readl(void *addr);
333#define pci_mmio_writeb mmio_le_writeb
334#define pci_mmio_writew mmio_le_writew
335#define pci_mmio_writel mmio_le_writel
336#define pci_mmio_readb mmio_le_readb
337#define pci_mmio_readw mmio_le_readw
338#define pci_mmio_readl mmio_le_readl
hailfinger1e2e3442011-05-03 21:49:41 +0000339void rmmio_writeb(uint8_t val, void *addr);
340void rmmio_writew(uint16_t val, void *addr);
341void rmmio_writel(uint32_t val, void *addr);
342void rmmio_le_writeb(uint8_t val, void *addr);
343void rmmio_le_writew(uint16_t val, void *addr);
344void rmmio_le_writel(uint32_t val, void *addr);
345#define pci_rmmio_writeb rmmio_le_writeb
346#define pci_rmmio_writew rmmio_le_writew
347#define pci_rmmio_writel rmmio_le_writel
348void rmmio_valb(void *addr);
349void rmmio_valw(void *addr);
350void rmmio_vall(void *addr);
hailfinger428f6852010-07-27 22:41:39 +0000351
352/* programmer.c */
353int noop_shutdown(void);
354void *fallback_map(const char *descr, unsigned long phys_addr, size_t len);
355void fallback_unmap(void *virt_addr, size_t len);
356uint8_t noop_chip_readb(const chipaddr addr);
357void noop_chip_writeb(uint8_t val, chipaddr addr);
358void fallback_chip_writew(uint16_t val, chipaddr addr);
359void fallback_chip_writel(uint32_t val, chipaddr addr);
360void fallback_chip_writen(uint8_t *buf, chipaddr addr, size_t len);
361uint16_t fallback_chip_readw(const chipaddr addr);
362uint32_t fallback_chip_readl(const chipaddr addr);
363void fallback_chip_readn(uint8_t *buf, const chipaddr addr, size_t len);
364
365/* dummyflasher.c */
366#if CONFIG_DUMMY == 1
367int dummy_init(void);
hailfinger428f6852010-07-27 22:41:39 +0000368void *dummy_map(const char *descr, unsigned long phys_addr, size_t len);
369void dummy_unmap(void *virt_addr, size_t len);
370void dummy_chip_writeb(uint8_t val, chipaddr addr);
371void dummy_chip_writew(uint16_t val, chipaddr addr);
372void dummy_chip_writel(uint32_t val, chipaddr addr);
373void dummy_chip_writen(uint8_t *buf, chipaddr addr, size_t len);
374uint8_t dummy_chip_readb(const chipaddr addr);
375uint16_t dummy_chip_readw(const chipaddr addr);
376uint32_t dummy_chip_readl(const chipaddr addr);
377void dummy_chip_readn(uint8_t *buf, const chipaddr addr, size_t len);
hailfinger428f6852010-07-27 22:41:39 +0000378#endif
379
380/* nic3com.c */
381#if CONFIG_NIC3COM == 1
382int nic3com_init(void);
hailfinger428f6852010-07-27 22:41:39 +0000383void nic3com_chip_writeb(uint8_t val, chipaddr addr);
384uint8_t nic3com_chip_readb(const chipaddr addr);
385extern const struct pcidev_status nics_3com[];
386#endif
387
388/* gfxnvidia.c */
389#if CONFIG_GFXNVIDIA == 1
390int gfxnvidia_init(void);
hailfinger428f6852010-07-27 22:41:39 +0000391void gfxnvidia_chip_writeb(uint8_t val, chipaddr addr);
392uint8_t gfxnvidia_chip_readb(const chipaddr addr);
393extern const struct pcidev_status gfx_nvidia[];
394#endif
395
396/* drkaiser.c */
397#if CONFIG_DRKAISER == 1
398int drkaiser_init(void);
hailfinger428f6852010-07-27 22:41:39 +0000399void drkaiser_chip_writeb(uint8_t val, chipaddr addr);
400uint8_t drkaiser_chip_readb(const chipaddr addr);
401extern const struct pcidev_status drkaiser_pcidev[];
402#endif
403
404/* nicrealtek.c */
405#if CONFIG_NICREALTEK == 1
406int nicrealtek_init(void);
hailfinger428f6852010-07-27 22:41:39 +0000407void nicrealtek_chip_writeb(uint8_t val, chipaddr addr);
408uint8_t nicrealtek_chip_readb(const chipaddr addr);
409extern const struct pcidev_status nics_realtek[];
hailfinger428f6852010-07-27 22:41:39 +0000410#endif
411
412/* nicnatsemi.c */
413#if CONFIG_NICNATSEMI == 1
414int nicnatsemi_init(void);
hailfinger428f6852010-07-27 22:41:39 +0000415void nicnatsemi_chip_writeb(uint8_t val, chipaddr addr);
416uint8_t nicnatsemi_chip_readb(const chipaddr addr);
417extern const struct pcidev_status nics_natsemi[];
418#endif
419
hailfinger7949b652011-05-08 00:24:18 +0000420/* nicintel.c */
421#if CONFIG_NICINTEL == 1
422int nicintel_init(void);
hailfinger7949b652011-05-08 00:24:18 +0000423void nicintel_chip_writeb(uint8_t val, chipaddr addr);
424uint8_t nicintel_chip_readb(const chipaddr addr);
425extern const struct pcidev_status nics_intel[];
426#endif
427
uwe6764e922010-09-03 18:21:21 +0000428/* nicintel_spi.c */
429#if CONFIG_NICINTEL_SPI == 1
430int nicintel_spi_init(void);
uwe6764e922010-09-03 18:21:21 +0000431extern const struct pcidev_status nics_intel_spi[];
432#endif
433
hailfingerfb1f31f2010-12-03 14:48:11 +0000434/* ogp_spi.c */
435#if CONFIG_OGP_SPI == 1
436int ogp_spi_init(void);
hailfingerfb1f31f2010-12-03 14:48:11 +0000437extern const struct pcidev_status ogp_spi[];
438#endif
439
hailfinger935365d2011-02-04 21:37:59 +0000440/* satamv.c */
441#if CONFIG_SATAMV == 1
442int satamv_init(void);
hailfinger935365d2011-02-04 21:37:59 +0000443void satamv_chip_writeb(uint8_t val, chipaddr addr);
444uint8_t satamv_chip_readb(const chipaddr addr);
445extern const struct pcidev_status satas_mv[];
446#endif
447
hailfinger428f6852010-07-27 22:41:39 +0000448/* satasii.c */
449#if CONFIG_SATASII == 1
450int satasii_init(void);
hailfinger428f6852010-07-27 22:41:39 +0000451void satasii_chip_writeb(uint8_t val, chipaddr addr);
452uint8_t satasii_chip_readb(const chipaddr addr);
453extern const struct pcidev_status satas_sii[];
454#endif
455
456/* atahpt.c */
457#if CONFIG_ATAHPT == 1
458int atahpt_init(void);
hailfinger428f6852010-07-27 22:41:39 +0000459void atahpt_chip_writeb(uint8_t val, chipaddr addr);
460uint8_t atahpt_chip_readb(const chipaddr addr);
461extern const struct pcidev_status ata_hpt[];
462#endif
463
464/* ft2232_spi.c */
hailfinger888410e2010-07-29 15:54:53 +0000465#if CONFIG_FT2232_SPI == 1
466struct usbdev_status {
uwee15beb92010-08-08 17:01:18 +0000467 uint16_t vendor_id;
468 uint16_t device_id;
469 int status;
470 const char *vendor_name;
471 const char *device_name;
hailfinger888410e2010-07-29 15:54:53 +0000472};
hailfinger428f6852010-07-27 22:41:39 +0000473int ft2232_spi_init(void);
hailfinger888410e2010-07-29 15:54:53 +0000474extern const struct usbdev_status devs_ft2232spi[];
475void print_supported_usbdevs(const struct usbdev_status *devs);
476#endif
hailfinger428f6852010-07-27 22:41:39 +0000477
478/* rayer_spi.c */
479#if CONFIG_RAYER_SPI == 1
480int rayer_spi_init(void);
481#endif
482
483/* bitbang_spi.c */
484int bitbang_spi_init(const struct bitbang_spi_master *master, int halfperiod);
hailfinger12cba9a2010-09-15 00:17:37 +0000485int bitbang_spi_shutdown(const struct bitbang_spi_master *master);
hailfinger428f6852010-07-27 22:41:39 +0000486
487/* buspirate_spi.c */
hailfingere20dc562011-06-09 20:06:34 +0000488#if CONFIG_BUSPIRATE_SPI == 1
hailfinger428f6852010-07-27 22:41:39 +0000489int buspirate_spi_init(void);
hailfingere20dc562011-06-09 20:06:34 +0000490#endif
hailfinger428f6852010-07-27 22:41:39 +0000491
uwe7df6dda2011-09-03 18:37:52 +0000492/* linux_spi.c */
493#if CONFIG_LINUX_SPI == 1
494int linux_spi_init(void);
495#endif
496
hailfinger428f6852010-07-27 22:41:39 +0000497/* dediprog.c */
hailfingere20dc562011-06-09 20:06:34 +0000498#if CONFIG_DEDIPROG == 1
hailfinger428f6852010-07-27 22:41:39 +0000499int dediprog_init(void);
hailfingere20dc562011-06-09 20:06:34 +0000500#endif
hailfinger428f6852010-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;
hailfinger48ed3e22011-05-04 00:39:50 +0000512void check_chip_supported(const struct flashchip *flash);
hailfinger428f6852010-07-27 22:41:39 +0000513int check_max_decode(enum chipbustype buses, uint32_t size);
stefanct52700282011-06-26 17:38:17 +0000514char *extract_programmer_param(const char *param_name);
hailfinger428f6852010-07-27 22:41:39 +0000515
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,
David Hendricks07af3a42011-07-11 22:13:02 -0700526 SPI_CONTROLLER_ICH_HWSEQ,
hailfinger2b46a862011-02-28 23:58:15 +0000527 SPI_CONTROLLER_IT85XX,
hailfinger428f6852010-07-27 22:41:39 +0000528 SPI_CONTROLLER_IT87XX,
David Hendricks46d32e32011-01-19 16:01:52 -0800529 SPI_CONTROLLER_MEC1308,
hailfinger428f6852010-07-27 22:41:39 +0000530 SPI_CONTROLLER_SB600,
531 SPI_CONTROLLER_VIA,
532 SPI_CONTROLLER_WBSIO,
David Hendricksc801adb2010-12-09 16:58:56 -0800533 SPI_CONTROLLER_WPCE775X,
David Hendricks82fd8ae2010-08-04 14:34:54 -0700534#endif
Louis Yung-Chieh Lobc351d02011-03-31 13:09:21 +0800535#if defined(__arm__)
536 SPI_CONTROLLER_TEGRA2,
hailfinger428f6852010-07-27 22:41:39 +0000537#endif
538#endif
539#if CONFIG_FT2232_SPI == 1
540 SPI_CONTROLLER_FT2232,
541#endif
542#if CONFIG_DUMMY == 1
543 SPI_CONTROLLER_DUMMY,
544#endif
545#if CONFIG_BUSPIRATE_SPI == 1
546 SPI_CONTROLLER_BUSPIRATE,
547#endif
548#if CONFIG_DEDIPROG == 1
549 SPI_CONTROLLER_DEDIPROG,
550#endif
David Hendricks91040832011-07-08 20:01:09 -0700551#if CONFIG_OGP_SPI == 1 || CONFIG_NICINTEL_SPI == 1 || CONFIG_RAYER_SPI == 1 || (CONFIG_INTERNAL == 1 && (defined(__i386__) || defined(__x86_64__) || defined(__arm__)))
mkarcherd264e9e2011-05-11 17:07:07 +0000552 SPI_CONTROLLER_BITBANG,
hailfinger428f6852010-07-27 22:41:39 +0000553#endif
uwe7df6dda2011-09-03 18:37:52 +0000554#if CONFIG_LINUX_SPI == 1
555 SPI_CONTROLLER_LINUX,
556#endif
hailfinger428f6852010-07-27 22:41:39 +0000557};
558extern const int spi_programmer_count;
mkarcher8fb57592011-05-11 17:07:02 +0000559
560#define MAX_DATA_UNSPECIFIED 0
561#define MAX_DATA_READ_UNLIMITED 64 * 1024
562#define MAX_DATA_WRITE_UNLIMITED 256
hailfinger428f6852010-07-27 22:41:39 +0000563struct spi_programmer {
mkarcherd264e9e2011-05-11 17:07:07 +0000564 enum spi_controller type;
mkarcher8fb57592011-05-11 17:07:02 +0000565 int max_data_read;
566 int max_data_write;
hailfinger428f6852010-07-27 22:41:39 +0000567 int (*command)(unsigned int writecnt, unsigned int readcnt,
568 const unsigned char *writearr, unsigned char *readarr);
569 int (*multicommand)(struct spi_command *cmds);
570
571 /* Optimized functions for this programmer */
572 int (*read)(struct flashchip *flash, uint8_t *buf, int start, int len);
573 int (*write_256)(struct flashchip *flash, uint8_t *buf, int start, int len);
574};
575
mkarcherd264e9e2011-05-11 17:07:07 +0000576extern const struct spi_programmer *spi_programmer;
hailfinger428f6852010-07-27 22:41:39 +0000577int default_spi_send_command(unsigned int writecnt, unsigned int readcnt,
578 const unsigned char *writearr, unsigned char *readarr);
579int default_spi_send_multicommand(struct spi_command *cmds);
mkarcher8fb57592011-05-11 17:07:02 +0000580int default_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
581int default_spi_write_256(struct flashchip *flash, uint8_t *buf, int start, int len);
mkarcherd264e9e2011-05-11 17:07:07 +0000582void register_spi_programmer(const struct spi_programmer *programmer);
hailfinger428f6852010-07-27 22:41:39 +0000583
584/* ichspi.c */
585#if CONFIG_INTERNAL == 1
586extern uint32_t ichspi_bbar;
587int ich_init_spi(struct pci_dev *dev, uint32_t base, void *rcrb,
588 int ich_generation);
589int via_init_spi(struct pci_dev *dev);
hailfinger428f6852010-07-27 22:41:39 +0000590
hailfinger2b46a862011-02-28 23:58:15 +0000591/* it85spi.c */
hailfinger94e090c2011-04-27 14:34:08 +0000592int it85xx_spi_init(struct superio s);
hailfinger2b46a862011-02-28 23:58:15 +0000593
hailfinger428f6852010-07-27 22:41:39 +0000594/* it87spi.c */
595void enter_conf_mode_ite(uint16_t port);
596void exit_conf_mode_ite(uint16_t port);
hailfinger94e090c2011-04-27 14:34:08 +0000597void probe_superio_ite(void);
hailfinger428f6852010-07-27 22:41:39 +0000598int init_superio_ite(void);
hailfinger428f6852010-07-27 22:41:39 +0000599
hailfingere20dc562011-06-09 20:06:34 +0000600/* mcp6x_spi.c */
601int mcp6x_spi_init(int want_spi);
602
David Hendricks46d32e32011-01-19 16:01:52 -0800603/* mec1308.c */
604struct superio probe_superio_mec1308(void);
David Hendricks46d32e32011-01-19 16:01:52 -0800605int mec1308_probe_spi_flash(const char *name);
606int mec1308_spi_read(struct flashchip *flash,
607 uint8_t * buf, int start, int len);
608int mec1308_spi_write_256(struct flashchip *flash,
609 uint8_t *buf, int start, int len);
610int mec1308_spi_send_command(unsigned int writecnt, unsigned int readcnt,
611 const unsigned char *writearr,
612 unsigned char *readarr);
613
hailfinger428f6852010-07-27 22:41:39 +0000614/* sb600spi.c */
hailfinger428f6852010-07-27 22:41:39 +0000615int sb600_probe_spi(struct pci_dev *dev);
hailfinger428f6852010-07-27 22:41:39 +0000616
David Hendricks91040832011-07-08 20:01:09 -0700617/* tegra2_spi.c */
618int tegra2_spi_init(void);
619int tegra2_spi_shutdown(void *);
620int tegra2_spi_send_command(unsigned int writecnt, unsigned int readcnt,
David Hendricks82fd8ae2010-08-04 14:34:54 -0700621 const unsigned char *writearr, unsigned char *readarr);
David Hendricks91040832011-07-08 20:01:09 -0700622int tegra2_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
623int tegra2_spi_write(struct flashchip *flash, uint8_t *buf, int start, int len);
David Hendricks82fd8ae2010-08-04 14:34:54 -0700624
hailfinger428f6852010-07-27 22:41:39 +0000625/* wbsio_spi.c */
hailfinger428f6852010-07-27 22:41:39 +0000626int wbsio_check_for_spi(void);
hailfinger428f6852010-07-27 22:41:39 +0000627#endif
628
629/* serprog.c */
hailfingere20dc562011-06-09 20:06:34 +0000630#if CONFIG_SERPROG == 1
hailfinger428f6852010-07-27 22:41:39 +0000631int serprog_init(void);
hailfinger428f6852010-07-27 22:41:39 +0000632void serprog_chip_writeb(uint8_t val, chipaddr addr);
633uint8_t serprog_chip_readb(const chipaddr addr);
634void serprog_chip_readn(uint8_t *buf, const chipaddr addr, size_t len);
635void serprog_delay(int delay);
hailfingere20dc562011-06-09 20:06:34 +0000636#endif
hailfinger428f6852010-07-27 22:41:39 +0000637
638/* serial.c */
639#if _WIN32
640typedef HANDLE fdtype;
641#else
642typedef int fdtype;
643#endif
644
David Hendricksc801adb2010-12-09 16:58:56 -0800645/* wpce775x.c */
646struct superio probe_superio_wpce775x(void);
David Hendricksc801adb2010-12-09 16:58:56 -0800647int wpce775x_probe_spi_flash(const char *name);
648int wpce775x_spi_read(struct flashchip *flash,
649 uint8_t * buf, int start, int len);
650int wpce775x_spi_write_256(struct flashchip *flash,
651 uint8_t *buf, int start, int len);
652int wpce775x_spi_send_command(unsigned int writecnt, unsigned int readcnt,
653 const unsigned char *writearr,
654 unsigned char *readarr);
655
hailfinger428f6852010-07-27 22:41:39 +0000656void sp_flush_incoming(void);
657fdtype sp_openserport(char *dev, unsigned int baud);
658void __attribute__((noreturn)) sp_die(char *msg);
659extern fdtype sp_fd;
dhendrix0ffc2eb2011-06-14 01:35:36 +0000660/* expose serialport_shutdown as it's currently used by buspirate */
661int serialport_shutdown(void *data);
hailfinger428f6852010-07-27 22:41:39 +0000662int serialport_write(unsigned char *buf, unsigned int writecnt);
663int serialport_read(unsigned char *buf, unsigned int readcnt);
664
665#endif /* !__PROGRAMMER_H__ */