blob: d6e06cb883216a37563643d5393ce19a118c823b [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
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +000027#include "flash.h" /* for chipaddr and flashctx */
Carl-Daniel Hailfinger532c7172011-11-04 21:35:26 +000028
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +000029enum programmer {
30#if CONFIG_INTERNAL == 1
31 PROGRAMMER_INTERNAL,
32#endif
33#if CONFIG_DUMMY == 1
34 PROGRAMMER_DUMMY,
35#endif
36#if CONFIG_NIC3COM == 1
37 PROGRAMMER_NIC3COM,
38#endif
39#if CONFIG_NICREALTEK == 1
40 PROGRAMMER_NICREALTEK,
Idwer Vollering004f4b72010-09-03 18:21:21 +000041#endif
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +000042#if CONFIG_NICNATSEMI == 1
43 PROGRAMMER_NICNATSEMI,
Idwer Vollering004f4b72010-09-03 18:21:21 +000044#endif
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +000045#if CONFIG_GFXNVIDIA == 1
46 PROGRAMMER_GFXNVIDIA,
47#endif
48#if CONFIG_DRKAISER == 1
49 PROGRAMMER_DRKAISER,
50#endif
51#if CONFIG_SATASII == 1
52 PROGRAMMER_SATASII,
53#endif
54#if CONFIG_ATAHPT == 1
55 PROGRAMMER_ATAHPT,
56#endif
Jonathan Kollasch7f0f3fa2014-06-01 10:26:23 +000057#if CONFIG_ATAVIA == 1
58 PROGRAMMER_ATAVIA,
59#endif
Kyösti Mälkki72d42f82014-06-01 23:48:31 +000060#if CONFIG_IT8212 == 1
61 PROGRAMMER_IT8212,
62#endif
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +000063#if CONFIG_FT2232_SPI == 1
64 PROGRAMMER_FT2232_SPI,
65#endif
66#if CONFIG_SERPROG == 1
67 PROGRAMMER_SERPROG,
68#endif
69#if CONFIG_BUSPIRATE_SPI == 1
70 PROGRAMMER_BUSPIRATE_SPI,
71#endif
72#if CONFIG_DEDIPROG == 1
73 PROGRAMMER_DEDIPROG,
74#endif
75#if CONFIG_RAYER_SPI == 1
76 PROGRAMMER_RAYER_SPI,
77#endif
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +000078#if CONFIG_PONY_SPI == 1
79 PROGRAMMER_PONY_SPI,
80#endif
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +000081#if CONFIG_NICINTEL == 1
82 PROGRAMMER_NICINTEL,
83#endif
Idwer Vollering004f4b72010-09-03 18:21:21 +000084#if CONFIG_NICINTEL_SPI == 1
85 PROGRAMMER_NICINTEL_SPI,
86#endif
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +000087#if CONFIG_NICINTEL_EEPROM == 1
88 PROGRAMMER_NICINTEL_EEPROM,
89#endif
Mark Marshall90021f22010-12-03 14:48:11 +000090#if CONFIG_OGP_SPI == 1
91 PROGRAMMER_OGP_SPI,
92#endif
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +000093#if CONFIG_SATAMV == 1
94 PROGRAMMER_SATAMV,
95#endif
Sven Schnelle5ce5f702011-09-03 18:37:52 +000096#if CONFIG_LINUX_SPI == 1
97 PROGRAMMER_LINUX_SPI,
98#endif
James Lairdc60de0e2013-03-27 13:00:23 +000099#if CONFIG_USBBLASTER_SPI == 1
100 PROGRAMMER_USBBLASTER_SPI,
101#endif
Alexandre Boeglin80e64712014-12-20 20:25:19 +0000102#if CONFIG_MSTARDDC_SPI == 1
103 PROGRAMMER_MSTARDDC_SPI,
104#endif
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000105 PROGRAMMER_INVALID /* This must always be the last entry. */
106};
107
Stefan Tauneraf358d62012-12-27 18:40:26 +0000108enum programmer_type {
109 PCI = 1, /* to detect uninitialized values */
110 USB,
111 OTHER,
112};
113
Stefan Tauner4b24a2d2012-12-27 18:40:36 +0000114struct dev_entry {
115 uint16_t vendor_id;
116 uint16_t device_id;
117 const enum test_state status;
118 const char *vendor_name;
119 const char *device_name;
120};
121
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000122struct programmer_entry {
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000123 const char *name;
Stefan Tauneraf358d62012-12-27 18:40:26 +0000124 const enum programmer_type type;
125 union {
Stefan Tauner4b24a2d2012-12-27 18:40:36 +0000126 const struct dev_entry *const dev;
Stefan Tauneraf358d62012-12-27 18:40:26 +0000127 const char *const note;
128 } devs;
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000129
130 int (*init) (void);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000131
Stefan Tauner305e0b92013-07-17 23:46:44 +0000132 void *(*map_flash_region) (const char *descr, uintptr_t phys_addr, size_t len);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000133 void (*unmap_flash_region) (void *virt_addr, size_t len);
134
Stefan Taunerf80419c2014-05-02 15:41:42 +0000135 void (*delay) (unsigned int usecs);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000136};
137
138extern const struct programmer_entry programmer_table[];
139
Nico Huberbcb2e5a2012-12-30 01:23:17 +0000140int programmer_init(enum programmer prog, const char *param);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000141int programmer_shutdown(void);
142
143enum bitbang_spi_master_type {
144 BITBANG_SPI_INVALID = 0, /* This must always be the first entry. */
145#if CONFIG_RAYER_SPI == 1
146 BITBANG_SPI_MASTER_RAYER,
147#endif
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000148#if CONFIG_PONY_SPI == 1
149 BITBANG_SPI_MASTER_PONY,
150#endif
Idwer Vollering004f4b72010-09-03 18:21:21 +0000151#if CONFIG_NICINTEL_SPI == 1
152 BITBANG_SPI_MASTER_NICINTEL,
153#endif
Carl-Daniel Hailfinger2f436162010-07-28 15:08:35 +0000154#if CONFIG_INTERNAL == 1
155#if defined(__i386__) || defined(__x86_64__)
156 BITBANG_SPI_MASTER_MCP,
157#endif
158#endif
Mark Marshall90021f22010-12-03 14:48:11 +0000159#if CONFIG_OGP_SPI == 1
160 BITBANG_SPI_MASTER_OGP,
161#endif
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000162};
163
164struct bitbang_spi_master {
165 enum bitbang_spi_master_type type;
166
167 /* Note that CS# is active low, so val=0 means the chip is active. */
168 void (*set_cs) (int val);
169 void (*set_sck) (int val);
170 void (*set_mosi) (int val);
171 int (*get_miso) (void);
Carl-Daniel Hailfinger28228882010-09-15 00:17:37 +0000172 void (*request_bus) (void);
173 void (*release_bus) (void);
Carl-Daniel Hailfingerc40cff72011-12-20 00:19:29 +0000174 /* Length of half a clock period in usecs. */
175 unsigned int half_period;
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000176};
177
Carl-Daniel Hailfingera2faddf2013-01-05 23:52:45 +0000178#if NEED_PCI == 1
Patrick Georgi32508eb2012-07-20 20:35:14 +0000179struct pci_dev;
Carl-Daniel Hailfingera2faddf2013-01-05 23:52:45 +0000180
181/* pcidev.c */
Stefan Tauner0ccec8f2014-06-01 23:49:03 +0000182// FIXME: This needs to be local, not global(?)
Carl-Daniel Hailfingera2faddf2013-01-05 23:52:45 +0000183extern struct pci_access *pacc;
184int pci_init_common(void);
185uintptr_t pcidev_readbar(struct pci_dev *dev, int bar);
186struct pci_dev *pcidev_init(const struct dev_entry *devs, int bar);
187/* rpci_write_* are reversible writes. The original PCI config space register
188 * contents will be restored on shutdown.
189 */
190int rpci_write_byte(struct pci_dev *dev, int reg, uint8_t data);
191int rpci_write_word(struct pci_dev *dev, int reg, uint16_t data);
192int rpci_write_long(struct pci_dev *dev, int reg, uint32_t data);
193#endif
194
195#if CONFIG_INTERNAL == 1
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000196struct penable {
197 uint16_t vendor_id;
198 uint16_t device_id;
Stefan Tauner2c20b282012-07-28 19:35:26 +0000199 const enum test_state status;
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000200 const char *vendor_name;
201 const char *device_name;
202 int (*doit) (struct pci_dev *dev, const char *name);
203};
204
205extern const struct penable chipset_enables[];
206
Carl-Daniel Hailfinger580d29a2011-05-05 07:12:40 +0000207enum board_match_phase {
208 P1,
209 P2,
210 P3
211};
212
Carl-Daniel Hailfinger97d5b122011-08-31 16:19:50 +0000213struct board_match {
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000214 /* Any device, but make it sensible, like the ISA bridge. */
215 uint16_t first_vendor;
216 uint16_t first_device;
217 uint16_t first_card_vendor;
218 uint16_t first_card_device;
219
220 /* Any device, but make it sensible, like
221 * the host bridge. May be NULL.
222 */
223 uint16_t second_vendor;
224 uint16_t second_device;
225 uint16_t second_card_vendor;
226 uint16_t second_card_device;
227
Stefan Tauner7bcacb12011-05-26 01:35:19 +0000228 /* Pattern to match DMI entries. May be NULL. */
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000229 const char *dmi_pattern;
230
Stefan Tauner7bcacb12011-05-26 01:35:19 +0000231 /* The vendor / part name from the coreboot table. May be NULL. */
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000232 const char *lb_vendor;
233 const char *lb_part;
234
Carl-Daniel Hailfinger580d29a2011-05-05 07:12:40 +0000235 enum board_match_phase phase;
236
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000237 const char *vendor_name;
238 const char *board_name;
239
240 int max_rom_decode_parallel;
Stefan Tauner2c20b282012-07-28 19:35:26 +0000241 const enum test_state status;
Stefan Tauner7bcacb12011-05-26 01:35:19 +0000242 int (*enable) (void); /* May be NULL. */
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000243};
244
Carl-Daniel Hailfinger97d5b122011-08-31 16:19:50 +0000245extern const struct board_match board_matches[];
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000246
247struct board_info {
248 const char *vendor;
249 const char *name;
Stefan Tauner2c20b282012-07-28 19:35:26 +0000250 const enum test_state working;
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000251#ifdef CONFIG_PRINT_WIKI
252 const char *url;
253 const char *note;
254#endif
255};
256
257extern const struct board_info boards_known[];
258extern const struct board_info laptops_known[];
259#endif
260
261/* udelay.c */
Stefan Taunerf80419c2014-05-02 15:41:42 +0000262void myusec_delay(unsigned int usecs);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000263void myusec_calibrate_delay(void);
Stefan Taunerf80419c2014-05-02 15:41:42 +0000264void internal_sleep(unsigned int usecs);
265void internal_delay(unsigned int usecs);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000266
Carl-Daniel Hailfingerc4224842011-06-09 20:06:34 +0000267#if CONFIG_INTERNAL == 1
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000268/* board_enable.c */
Stefan Tauner600576b2014-06-12 22:57:36 +0000269int selfcheck_board_enables(void);
Stefan Taunerb4e06bd2012-08-20 00:24:22 +0000270int board_parse_parameter(const char *boardstring, const char **vendor, const char **model);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000271void w836xx_ext_enter(uint16_t port);
272void w836xx_ext_leave(uint16_t port);
Carl-Daniel Hailfingerf5e62cb2012-05-06 22:48:01 +0000273void probe_superio_winbond(void);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000274int it8705f_write_enable(uint8_t port);
275uint8_t sio_read(uint16_t port, uint8_t reg);
276void sio_write(uint16_t port, uint8_t reg, uint8_t data);
277void sio_mask(uint16_t port, uint8_t reg, uint8_t data, uint8_t mask);
Carl-Daniel Hailfinger580d29a2011-05-05 07:12:40 +0000278void board_handle_before_superio(void);
279void board_handle_before_laptop(void);
Stefan Taunerfa9fa712012-09-24 21:29:29 +0000280int board_flash_enable(const char *vendor, const char *model, const char *cb_vendor, const char *cb_model);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000281
282/* chipset_enable.c */
283int chipset_flash_enable(void);
284
285/* processor_enable.c */
286int processor_flash_enable(void);
Carl-Daniel Hailfinger580d29a2011-05-05 07:12:40 +0000287#endif
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000288
289/* physmap.c */
Stefan Tauner305e0b92013-07-17 23:46:44 +0000290void *physmap(const char *descr, uintptr_t phys_addr, size_t len);
Stefan Tauner7fb5aa02013-08-14 15:48:44 +0000291void *rphysmap(const char *descr, uintptr_t phys_addr, size_t len);
Niklas Söderlund5d307202013-09-14 09:02:27 +0000292void *physmap_ro(const char *descr, uintptr_t phys_addr, size_t len);
Carl-Daniel Hailfinger43eac032014-03-05 00:16:16 +0000293void *physmap_ro_unaligned(const char *descr, uintptr_t phys_addr, size_t len);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000294void physunmap(void *virt_addr, size_t len);
Carl-Daniel Hailfinger43eac032014-03-05 00:16:16 +0000295void physunmap_unaligned(void *virt_addr, size_t len);
Carl-Daniel Hailfingerc4224842011-06-09 20:06:34 +0000296#if CONFIG_INTERNAL == 1
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000297int setup_cpu_msr(int cpu);
298void cleanup_cpu_msr(void);
299
300/* cbtable.c */
Stefan Taunerb4e06bd2012-08-20 00:24:22 +0000301int cb_parse_table(const char **vendor, const char **model);
302int cb_check_image(uint8_t *bios, int size);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000303
304/* dmi.c */
Sean Nelson4c6d3a42013-09-11 23:35:03 +0000305#if defined(__i386__) || defined(__x86_64__)
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000306extern int has_dmi_support;
307void dmi_init(void);
308int dmi_match(const char *pattern);
Sean Nelson4c6d3a42013-09-11 23:35:03 +0000309#endif // defined(__i386__) || defined(__x86_64__)
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000310
311/* internal.c */
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000312struct superio {
313 uint16_t vendor;
314 uint16_t port;
315 uint16_t model;
316};
Carl-Daniel Hailfingerbfecef62011-04-27 14:34:08 +0000317extern struct superio superios[];
318extern int superio_count;
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000319#define SUPERIO_VENDOR_NONE 0x0
320#define SUPERIO_VENDOR_ITE 0x1
Carl-Daniel Hailfingerf5e62cb2012-05-06 22:48:01 +0000321#define SUPERIO_VENDOR_WINBOND 0x2
Carl-Daniel Hailfingerc4224842011-06-09 20:06:34 +0000322#endif
323#if NEED_PCI == 1
Patrick Georgi32508eb2012-07-20 20:35:14 +0000324struct pci_filter;
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000325struct pci_dev *pci_dev_find_filter(struct pci_filter filter);
Uwe Hermann24c35e42011-07-13 11:22:03 +0000326struct pci_dev *pci_dev_find_vendorclass(uint16_t vendor, uint16_t devclass);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000327struct pci_dev *pci_dev_find(uint16_t vendor, uint16_t device);
328struct pci_dev *pci_card_find(uint16_t vendor, uint16_t device,
329 uint16_t card_vendor, uint16_t card_device);
330#endif
Carl-Daniel Hailfingerd6bb8282012-07-21 17:27:08 +0000331int rget_io_perms(void);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000332#if CONFIG_INTERNAL == 1
333extern int is_laptop;
Carl-Daniel Hailfinger580d29a2011-05-05 07:12:40 +0000334extern int laptop_ok;
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000335extern int force_boardenable;
336extern int force_boardmismatch;
337void probe_superio(void);
Carl-Daniel Hailfingerbfecef62011-04-27 14:34:08 +0000338int register_superio(struct superio s);
Carl-Daniel Hailfingereaacd2d2011-11-09 23:40:00 +0000339extern enum chipbustype internal_buses_supported;
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000340int internal_init(void);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000341#endif
342
343/* hwaccess.c */
344void mmio_writeb(uint8_t val, void *addr);
345void mmio_writew(uint16_t val, void *addr);
346void mmio_writel(uint32_t val, void *addr);
347uint8_t mmio_readb(void *addr);
348uint16_t mmio_readw(void *addr);
349uint32_t mmio_readl(void *addr);
Carl-Daniel Hailfingerccd71c22012-03-01 22:38:27 +0000350void mmio_readn(void *addr, uint8_t *buf, size_t len);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000351void mmio_le_writeb(uint8_t val, void *addr);
352void mmio_le_writew(uint16_t val, void *addr);
353void mmio_le_writel(uint32_t val, void *addr);
354uint8_t mmio_le_readb(void *addr);
355uint16_t mmio_le_readw(void *addr);
356uint32_t mmio_le_readl(void *addr);
357#define pci_mmio_writeb mmio_le_writeb
358#define pci_mmio_writew mmio_le_writew
359#define pci_mmio_writel mmio_le_writel
360#define pci_mmio_readb mmio_le_readb
361#define pci_mmio_readw mmio_le_readw
362#define pci_mmio_readl mmio_le_readl
Carl-Daniel Hailfinger54ce73a2011-05-03 21:49:41 +0000363void rmmio_writeb(uint8_t val, void *addr);
364void rmmio_writew(uint16_t val, void *addr);
365void rmmio_writel(uint32_t val, void *addr);
366void rmmio_le_writeb(uint8_t val, void *addr);
367void rmmio_le_writew(uint16_t val, void *addr);
368void rmmio_le_writel(uint32_t val, void *addr);
369#define pci_rmmio_writeb rmmio_le_writeb
370#define pci_rmmio_writew rmmio_le_writew
371#define pci_rmmio_writel rmmio_le_writel
372void rmmio_valb(void *addr);
373void rmmio_valw(void *addr);
374void rmmio_vall(void *addr);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000375
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000376/* dummyflasher.c */
377#if CONFIG_DUMMY == 1
378int dummy_init(void);
Stefan Tauner305e0b92013-07-17 23:46:44 +0000379void *dummy_map(const char *descr, uintptr_t phys_addr, size_t len);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000380void dummy_unmap(void *virt_addr, size_t len);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000381#endif
382
383/* nic3com.c */
384#if CONFIG_NIC3COM == 1
385int nic3com_init(void);
Stefan Tauner4b24a2d2012-12-27 18:40:36 +0000386extern const struct dev_entry nics_3com[];
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000387#endif
388
389/* gfxnvidia.c */
390#if CONFIG_GFXNVIDIA == 1
391int gfxnvidia_init(void);
Stefan Tauner4b24a2d2012-12-27 18:40:36 +0000392extern const struct dev_entry gfx_nvidia[];
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000393#endif
394
395/* drkaiser.c */
396#if CONFIG_DRKAISER == 1
397int drkaiser_init(void);
Stefan Tauner4b24a2d2012-12-27 18:40:36 +0000398extern const struct dev_entry drkaiser_pcidev[];
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000399#endif
400
401/* nicrealtek.c */
402#if CONFIG_NICREALTEK == 1
403int nicrealtek_init(void);
Stefan Tauner4b24a2d2012-12-27 18:40:36 +0000404extern const struct dev_entry nics_realtek[];
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000405#endif
406
407/* nicnatsemi.c */
408#if CONFIG_NICNATSEMI == 1
409int nicnatsemi_init(void);
Stefan Tauner4b24a2d2012-12-27 18:40:36 +0000410extern const struct dev_entry nics_natsemi[];
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000411#endif
412
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000413/* nicintel.c */
414#if CONFIG_NICINTEL == 1
415int nicintel_init(void);
Stefan Tauner4b24a2d2012-12-27 18:40:36 +0000416extern const struct dev_entry nics_intel[];
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000417#endif
418
Idwer Vollering004f4b72010-09-03 18:21:21 +0000419/* nicintel_spi.c */
420#if CONFIG_NICINTEL_SPI == 1
421int nicintel_spi_init(void);
Stefan Tauner4b24a2d2012-12-27 18:40:36 +0000422extern const struct dev_entry nics_intel_spi[];
Idwer Vollering004f4b72010-09-03 18:21:21 +0000423#endif
424
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +0000425/* nicintel_eeprom.c */
426#if CONFIG_NICINTEL_EEPROM == 1
427int nicintel_ee_init(void);
428extern const struct dev_entry nics_intel_ee[];
429#endif
430
Mark Marshall90021f22010-12-03 14:48:11 +0000431/* ogp_spi.c */
432#if CONFIG_OGP_SPI == 1
433int ogp_spi_init(void);
Stefan Tauner4b24a2d2012-12-27 18:40:36 +0000434extern const struct dev_entry ogp_spi[];
Mark Marshall90021f22010-12-03 14:48:11 +0000435#endif
436
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000437/* satamv.c */
438#if CONFIG_SATAMV == 1
439int satamv_init(void);
Stefan Tauner4b24a2d2012-12-27 18:40:36 +0000440extern const struct dev_entry satas_mv[];
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000441#endif
442
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000443/* satasii.c */
444#if CONFIG_SATASII == 1
445int satasii_init(void);
Stefan Tauner4b24a2d2012-12-27 18:40:36 +0000446extern const struct dev_entry satas_sii[];
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000447#endif
448
449/* atahpt.c */
450#if CONFIG_ATAHPT == 1
451int atahpt_init(void);
Stefan Tauner4b24a2d2012-12-27 18:40:36 +0000452extern const struct dev_entry ata_hpt[];
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000453#endif
454
Jonathan Kollasch7f0f3fa2014-06-01 10:26:23 +0000455/* atavia.c */
456#if CONFIG_ATAVIA == 1
457int atavia_init(void);
458void *atavia_map(const char *descr, uintptr_t phys_addr, size_t len);
459extern const struct dev_entry ata_via[];
460#endif
461
Kyösti Mälkki72d42f82014-06-01 23:48:31 +0000462/* it8212.c */
463#if CONFIG_IT8212 == 1
464int it8212_init(void);
465extern const struct dev_entry devs_it8212[];
466#endif
467
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000468/* ft2232_spi.c */
Jörg Fischer6529b9f2010-07-29 15:54:53 +0000469#if CONFIG_FT2232_SPI == 1
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000470int ft2232_spi_init(void);
Stefan Tauner4b24a2d2012-12-27 18:40:36 +0000471extern const struct dev_entry devs_ft2232spi[];
Jörg Fischer6529b9f2010-07-29 15:54:53 +0000472#endif
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000473
James Lairdc60de0e2013-03-27 13:00:23 +0000474/* usbblaster_spi.c */
475#if CONFIG_USBBLASTER_SPI == 1
476int usbblaster_spi_init(void);
477extern const struct dev_entry devs_usbblasterspi[];
478#endif
479
Alexandre Boeglin80e64712014-12-20 20:25:19 +0000480/* mstarddc_spi.c */
481#if CONFIG_MSTARDDC_SPI == 1
482int mstarddc_spi_init(void);
483#endif
484
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000485/* rayer_spi.c */
486#if CONFIG_RAYER_SPI == 1
487int rayer_spi_init(void);
488#endif
489
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000490/* pony_spi.c */
491#if CONFIG_PONY_SPI == 1
492int pony_spi_init(void);
493#endif
494
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000495/* bitbang_spi.c */
Carl-Daniel Hailfingera5bcbce2014-07-19 22:03:29 +0000496int register_spi_bitbang_master(const struct bitbang_spi_master *master);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000497
498/* buspirate_spi.c */
Carl-Daniel Hailfingerc4224842011-06-09 20:06:34 +0000499#if CONFIG_BUSPIRATE_SPI == 1
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000500int buspirate_spi_init(void);
Carl-Daniel Hailfingerc4224842011-06-09 20:06:34 +0000501#endif
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000502
Sven Schnelle5ce5f702011-09-03 18:37:52 +0000503/* linux_spi.c */
504#if CONFIG_LINUX_SPI == 1
505int linux_spi_init(void);
506#endif
507
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000508/* dediprog.c */
Carl-Daniel Hailfingerc4224842011-06-09 20:06:34 +0000509#if CONFIG_DEDIPROG == 1
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000510int dediprog_init(void);
Carl-Daniel Hailfingerc4224842011-06-09 20:06:34 +0000511#endif
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000512
513/* flashrom.c */
514struct decode_sizes {
515 uint32_t parallel;
516 uint32_t lpc;
517 uint32_t fwh;
518 uint32_t spi;
519};
Carl-Daniel Hailfingerc40cff72011-12-20 00:19:29 +0000520// FIXME: These need to be local, not global
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000521extern struct decode_sizes max_rom_decode;
522extern int programmer_may_write;
523extern unsigned long flashbase;
Stefan Tauner9e3a6982014-08-15 17:17:59 +0000524unsigned int count_max_decode_exceedings(const struct flashctx *flash);
Stefan Tauner66652442011-06-26 17:38:17 +0000525char *extract_programmer_param(const char *param_name);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000526
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000527/* spi.c */
528enum spi_controller {
529 SPI_CONTROLLER_NONE,
530#if CONFIG_INTERNAL == 1
531#if defined(__i386__) || defined(__x86_64__)
532 SPI_CONTROLLER_ICH7,
533 SPI_CONTROLLER_ICH9,
David Hendricks4e748392011-02-28 23:58:15 +0000534 SPI_CONTROLLER_IT85XX,
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000535 SPI_CONTROLLER_IT87XX,
536 SPI_CONTROLLER_SB600,
Wei Hu31402ee2014-05-16 21:39:33 +0000537 SPI_CONTROLLER_YANGTZE,
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000538 SPI_CONTROLLER_VIA,
539 SPI_CONTROLLER_WBSIO,
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000540#endif
541#endif
542#if CONFIG_FT2232_SPI == 1
543 SPI_CONTROLLER_FT2232,
544#endif
545#if CONFIG_DUMMY == 1
546 SPI_CONTROLLER_DUMMY,
547#endif
548#if CONFIG_BUSPIRATE_SPI == 1
549 SPI_CONTROLLER_BUSPIRATE,
550#endif
551#if CONFIG_DEDIPROG == 1
552 SPI_CONTROLLER_DEDIPROG,
553#endif
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000554#if CONFIG_OGP_SPI == 1 || CONFIG_NICINTEL_SPI == 1 || CONFIG_RAYER_SPI == 1 || CONFIG_PONY_SPI == 1 || (CONFIG_INTERNAL == 1 && (defined(__i386__) || defined(__x86_64__)))
Michael Karcherb9dbe482011-05-11 17:07:07 +0000555 SPI_CONTROLLER_BITBANG,
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000556#endif
Sven Schnelle5ce5f702011-09-03 18:37:52 +0000557#if CONFIG_LINUX_SPI == 1
558 SPI_CONTROLLER_LINUX,
559#endif
Urja Rannikkoc93f5f12011-09-15 23:38:14 +0000560#if CONFIG_SERPROG == 1
561 SPI_CONTROLLER_SERPROG,
562#endif
James Lairdc60de0e2013-03-27 13:00:23 +0000563#if CONFIG_USBBLASTER_SPI == 1
564 SPI_CONTROLLER_USBBLASTER,
565#endif
Alexandre Boeglin80e64712014-12-20 20:25:19 +0000566#if CONFIG_MSTARDDC_SPI == 1
567 SPI_CONTROLLER_MSTARDDC,
568#endif
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000569};
Michael Karcher62797512011-05-11 17:07:02 +0000570
571#define MAX_DATA_UNSPECIFIED 0
572#define MAX_DATA_READ_UNLIMITED 64 * 1024
573#define MAX_DATA_WRITE_UNLIMITED 256
Carl-Daniel Hailfingera5bcbce2014-07-19 22:03:29 +0000574struct spi_master {
Michael Karcherb9dbe482011-05-11 17:07:07 +0000575 enum spi_controller type;
Stefan Taunerc69c9c82011-11-23 09:13:48 +0000576 unsigned int max_data_read;
577 unsigned int max_data_write;
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +0000578 int (*command)(struct flashctx *flash, unsigned int writecnt, unsigned int readcnt,
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000579 const unsigned char *writearr, unsigned char *readarr);
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +0000580 int (*multicommand)(struct flashctx *flash, struct spi_command *cmds);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000581
Carl-Daniel Hailfingera5bcbce2014-07-19 22:03:29 +0000582 /* Optimized functions for this master */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000583 int (*read)(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
Mark Marshallf20b7be2014-05-09 21:16:21 +0000584 int (*write_256)(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
585 int (*write_aai)(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
Carl-Daniel Hailfingerc40cff72011-12-20 00:19:29 +0000586 const void *data;
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000587};
588
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +0000589int default_spi_send_command(struct flashctx *flash, unsigned int writecnt, unsigned int readcnt,
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000590 const unsigned char *writearr, unsigned char *readarr);
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +0000591int default_spi_send_multicommand(struct flashctx *flash, struct spi_command *cmds);
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000592int default_spi_read(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
Mark Marshallf20b7be2014-05-09 21:16:21 +0000593int default_spi_write_256(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
594int default_spi_write_aai(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
Carl-Daniel Hailfingera5bcbce2014-07-19 22:03:29 +0000595int register_spi_master(const struct spi_master *mst);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000596
Kyösti Mälkki78cd0872013-09-14 23:36:57 +0000597/* The following enum is needed by ich_descriptor_tool and ich* code as well as in chipset_enable.c. */
Stefan Taunera8d838d2011-11-06 23:51:09 +0000598enum ich_chipset {
599 CHIPSET_ICH_UNKNOWN,
Stefan Tauner92d6a862013-10-25 00:33:37 +0000600 CHIPSET_ICH,
601 CHIPSET_ICH2345,
Kyösti Mälkki78cd0872013-09-14 23:36:57 +0000602 CHIPSET_ICH6,
Stefan Tauner92d6a862013-10-25 00:33:37 +0000603 CHIPSET_POULSBO, /* SCH U* */
604 CHIPSET_TUNNEL_CREEK, /* Atom E6xx */
605 CHIPSET_CENTERTON, /* Atom S1220 S1240 S1260 */
Kyösti Mälkki78cd0872013-09-14 23:36:57 +0000606 CHIPSET_ICH7,
Stefan Taunera8d838d2011-11-06 23:51:09 +0000607 CHIPSET_ICH8,
608 CHIPSET_ICH9,
609 CHIPSET_ICH10,
610 CHIPSET_5_SERIES_IBEX_PEAK,
611 CHIPSET_6_SERIES_COUGAR_POINT,
Stefan Tauner2abab942012-04-27 20:41:23 +0000612 CHIPSET_7_SERIES_PANTHER_POINT,
Duncan Laurie90eb2262013-03-15 03:12:29 +0000613 CHIPSET_8_SERIES_LYNX_POINT,
Duncan Laurie4095ed72014-08-20 15:39:32 +0000614 CHIPSET_BAYTRAIL, /* Actually all with Silvermont architecture: Bay Trail, Avoton/Rangeley */
Duncan Laurie90eb2262013-03-15 03:12:29 +0000615 CHIPSET_8_SERIES_LYNX_POINT_LP,
616 CHIPSET_8_SERIES_WELLSBURG,
Duncan Laurie823096e2014-08-20 15:39:38 +0000617 CHIPSET_9_SERIES_WILDCAT_POINT,
Stefan Taunera8d838d2011-11-06 23:51:09 +0000618};
619
Stefan Tauner2abab942012-04-27 20:41:23 +0000620/* ichspi.c */
621#if CONFIG_INTERNAL == 1
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000622extern uint32_t ichspi_bbar;
Stefan Tauner92d6a862013-10-25 00:33:37 +0000623int ich_init_spi(struct pci_dev *dev, void *spibar, enum ich_chipset ich_generation);
Helge Wagnerdd73d832012-08-24 23:03:46 +0000624int via_init_spi(struct pci_dev *dev, uint32_t mmio_base);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000625
Stefan Taunerdbac46c2013-08-13 22:10:41 +0000626/* amd_imc.c */
Rudolf Marek70e14592013-07-25 22:58:56 +0000627int amd_imc_shutdown(struct pci_dev *dev);
628
David Hendricks4e748392011-02-28 23:58:15 +0000629/* it85spi.c */
Carl-Daniel Hailfingerbfecef62011-04-27 14:34:08 +0000630int it85xx_spi_init(struct superio s);
David Hendricks4e748392011-02-28 23:58:15 +0000631
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000632/* it87spi.c */
633void enter_conf_mode_ite(uint16_t port);
634void exit_conf_mode_ite(uint16_t port);
Carl-Daniel Hailfingerbfecef62011-04-27 14:34:08 +0000635void probe_superio_ite(void);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000636int init_superio_ite(void);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000637
Carl-Daniel Hailfingerc4224842011-06-09 20:06:34 +0000638/* mcp6x_spi.c */
639int mcp6x_spi_init(int want_spi);
640
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000641/* sb600spi.c */
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000642int sb600_probe_spi(struct pci_dev *dev);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000643
644/* wbsio_spi.c */
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000645int wbsio_check_for_spi(void);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000646#endif
647
Carl-Daniel Hailfinger532c7172011-11-04 21:35:26 +0000648/* opaque.c */
Carl-Daniel Hailfingera5bcbce2014-07-19 22:03:29 +0000649struct opaque_master {
Carl-Daniel Hailfinger532c7172011-11-04 21:35:26 +0000650 int max_data_read;
651 int max_data_write;
Carl-Daniel Hailfingera5bcbce2014-07-19 22:03:29 +0000652 /* Specific functions for this master */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000653 int (*probe) (struct flashctx *flash);
654 int (*read) (struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
Mark Marshallf20b7be2014-05-09 21:16:21 +0000655 int (*write) (struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000656 int (*erase) (struct flashctx *flash, unsigned int blockaddr, unsigned int blocklen);
Carl-Daniel Hailfingerc40cff72011-12-20 00:19:29 +0000657 const void *data;
Carl-Daniel Hailfinger532c7172011-11-04 21:35:26 +0000658};
Carl-Daniel Hailfingera5bcbce2014-07-19 22:03:29 +0000659int register_opaque_master(const struct opaque_master *mst);
Carl-Daniel Hailfinger532c7172011-11-04 21:35:26 +0000660
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +0000661/* programmer.c */
662int noop_shutdown(void);
Stefan Tauner305e0b92013-07-17 23:46:44 +0000663void *fallback_map(const char *descr, uintptr_t phys_addr, size_t len);
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +0000664void fallback_unmap(void *virt_addr, size_t len);
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +0000665void noop_chip_writeb(const struct flashctx *flash, uint8_t val, chipaddr addr);
666void fallback_chip_writew(const struct flashctx *flash, uint16_t val, chipaddr addr);
667void fallback_chip_writel(const struct flashctx *flash, uint32_t val, chipaddr addr);
Mark Marshallf20b7be2014-05-09 21:16:21 +0000668void fallback_chip_writen(const struct flashctx *flash, const uint8_t *buf, chipaddr addr, size_t len);
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +0000669uint16_t fallback_chip_readw(const struct flashctx *flash, const chipaddr addr);
670uint32_t fallback_chip_readl(const struct flashctx *flash, const chipaddr addr);
671void fallback_chip_readn(const struct flashctx *flash, uint8_t *buf, const chipaddr addr, size_t len);
Carl-Daniel Hailfingera5bcbce2014-07-19 22:03:29 +0000672struct par_master {
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +0000673 void (*chip_writeb) (const struct flashctx *flash, uint8_t val, chipaddr addr);
674 void (*chip_writew) (const struct flashctx *flash, uint16_t val, chipaddr addr);
675 void (*chip_writel) (const struct flashctx *flash, uint32_t val, chipaddr addr);
Mark Marshallf20b7be2014-05-09 21:16:21 +0000676 void (*chip_writen) (const struct flashctx *flash, const uint8_t *buf, chipaddr addr, size_t len);
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +0000677 uint8_t (*chip_readb) (const struct flashctx *flash, const chipaddr addr);
678 uint16_t (*chip_readw) (const struct flashctx *flash, const chipaddr addr);
679 uint32_t (*chip_readl) (const struct flashctx *flash, const chipaddr addr);
680 void (*chip_readn) (const struct flashctx *flash, uint8_t *buf, const chipaddr addr, size_t len);
Carl-Daniel Hailfingerc40cff72011-12-20 00:19:29 +0000681 const void *data;
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +0000682};
Carl-Daniel Hailfingera5bcbce2014-07-19 22:03:29 +0000683int register_par_master(const struct par_master *mst, const enum chipbustype buses);
684struct registered_master {
Carl-Daniel Hailfingerc40cff72011-12-20 00:19:29 +0000685 enum chipbustype buses_supported;
686 union {
Carl-Daniel Hailfingera5bcbce2014-07-19 22:03:29 +0000687 struct par_master par;
688 struct spi_master spi;
689 struct opaque_master opaque;
Carl-Daniel Hailfingerc40cff72011-12-20 00:19:29 +0000690 };
691};
Carl-Daniel Hailfingera5bcbce2014-07-19 22:03:29 +0000692extern struct registered_master registered_masters[];
693extern int registered_master_count;
694int register_master(struct registered_master *mst);
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +0000695
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000696/* serprog.c */
Carl-Daniel Hailfingerc4224842011-06-09 20:06:34 +0000697#if CONFIG_SERPROG == 1
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000698int serprog_init(void);
Stefan Taunerf80419c2014-05-02 15:41:42 +0000699void serprog_delay(unsigned int usecs);
Carl-Daniel Hailfingerc4224842011-06-09 20:06:34 +0000700#endif
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000701
702/* serial.c */
Carl-Daniel Hailfinger60d9bd22012-08-09 23:34:41 +0000703#ifdef _WIN32
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000704typedef HANDLE fdtype;
Stefan Taunerbb4fed72012-09-01 21:47:19 +0000705#define SER_INV_FD INVALID_HANDLE_VALUE
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000706#else
707typedef int fdtype;
Stefan Taunerbb4fed72012-09-01 21:47:19 +0000708#define SER_INV_FD -1
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000709#endif
710
711void sp_flush_incoming(void);
712fdtype sp_openserport(char *dev, unsigned int baud);
Stefan Tauner184c52c2013-08-23 21:51:32 +0000713int serialport_config(fdtype fd, unsigned int baud);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000714extern fdtype sp_fd;
David Hendricks8bb20212011-06-14 01:35:36 +0000715/* expose serialport_shutdown as it's currently used by buspirate */
716int serialport_shutdown(void *data);
Mark Marshallf20b7be2014-05-09 21:16:21 +0000717int serialport_write(const unsigned char *buf, unsigned int writecnt);
718int serialport_write_nonblock(const unsigned char *buf, unsigned int writecnt, unsigned int timeout, unsigned int *really_wrote);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000719int serialport_read(unsigned char *buf, unsigned int readcnt);
Stefan Tauner00e16082013-04-01 00:45:38 +0000720int serialport_read_nonblock(unsigned char *c, unsigned int readcnt, unsigned int timeout, unsigned int *really_read);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000721
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000722/* Serial port/pin mapping:
723
724 1 CD <-
725 2 RXD <-
726 3 TXD ->
727 4 DTR ->
728 5 GND --
729 6 DSR <-
730 7 RTS ->
731 8 CTS <-
732 9 RI <-
733*/
734enum SP_PIN {
735 PIN_CD = 1,
736 PIN_RXD,
737 PIN_TXD,
738 PIN_DTR,
739 PIN_GND,
740 PIN_DSR,
741 PIN_RTS,
742 PIN_CTS,
743 PIN_RI,
744};
745
746void sp_set_pin(enum SP_PIN pin, int val);
747int sp_get_pin(enum SP_PIN pin);
748
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000749#endif /* !__PROGRAMMER_H__ */