blob: c61f42964cac58b173513d92323ea5efcabc26f3 [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
Uwe Hermann24c35e42011-07-13 11:22:03 +0000324struct pci_dev *pci_dev_find_vendorclass(uint16_t vendor, uint16_t devclass);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000325struct pci_dev *pci_dev_find(uint16_t vendor, uint16_t device);
326struct pci_dev *pci_card_find(uint16_t vendor, uint16_t device,
327 uint16_t card_vendor, uint16_t card_device);
328#endif
Carl-Daniel Hailfingerd6bb8282012-07-21 17:27:08 +0000329int rget_io_perms(void);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000330#if CONFIG_INTERNAL == 1
331extern int is_laptop;
Carl-Daniel Hailfinger580d29a2011-05-05 07:12:40 +0000332extern int laptop_ok;
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000333extern int force_boardenable;
334extern int force_boardmismatch;
335void probe_superio(void);
Carl-Daniel Hailfingerbfecef62011-04-27 14:34:08 +0000336int register_superio(struct superio s);
Carl-Daniel Hailfingereaacd2d2011-11-09 23:40:00 +0000337extern enum chipbustype internal_buses_supported;
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000338int internal_init(void);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000339#endif
340
341/* hwaccess.c */
342void mmio_writeb(uint8_t val, void *addr);
343void mmio_writew(uint16_t val, void *addr);
344void mmio_writel(uint32_t val, void *addr);
345uint8_t mmio_readb(void *addr);
346uint16_t mmio_readw(void *addr);
347uint32_t mmio_readl(void *addr);
Carl-Daniel Hailfingerccd71c22012-03-01 22:38:27 +0000348void mmio_readn(void *addr, uint8_t *buf, size_t len);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000349void mmio_le_writeb(uint8_t val, void *addr);
350void mmio_le_writew(uint16_t val, void *addr);
351void mmio_le_writel(uint32_t val, void *addr);
352uint8_t mmio_le_readb(void *addr);
353uint16_t mmio_le_readw(void *addr);
354uint32_t mmio_le_readl(void *addr);
355#define pci_mmio_writeb mmio_le_writeb
356#define pci_mmio_writew mmio_le_writew
357#define pci_mmio_writel mmio_le_writel
358#define pci_mmio_readb mmio_le_readb
359#define pci_mmio_readw mmio_le_readw
360#define pci_mmio_readl mmio_le_readl
Carl-Daniel Hailfinger54ce73a2011-05-03 21:49:41 +0000361void rmmio_writeb(uint8_t val, void *addr);
362void rmmio_writew(uint16_t val, void *addr);
363void rmmio_writel(uint32_t val, void *addr);
364void rmmio_le_writeb(uint8_t val, void *addr);
365void rmmio_le_writew(uint16_t val, void *addr);
366void rmmio_le_writel(uint32_t val, void *addr);
367#define pci_rmmio_writeb rmmio_le_writeb
368#define pci_rmmio_writew rmmio_le_writew
369#define pci_rmmio_writel rmmio_le_writel
370void rmmio_valb(void *addr);
371void rmmio_valw(void *addr);
372void rmmio_vall(void *addr);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000373
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000374/* dummyflasher.c */
375#if CONFIG_DUMMY == 1
376int dummy_init(void);
Stefan Tauner305e0b92013-07-17 23:46:44 +0000377void *dummy_map(const char *descr, uintptr_t phys_addr, size_t len);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000378void dummy_unmap(void *virt_addr, size_t len);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000379#endif
380
381/* nic3com.c */
382#if CONFIG_NIC3COM == 1
383int nic3com_init(void);
Stefan Tauner4b24a2d2012-12-27 18:40:36 +0000384extern const struct dev_entry nics_3com[];
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000385#endif
386
387/* gfxnvidia.c */
388#if CONFIG_GFXNVIDIA == 1
389int gfxnvidia_init(void);
Stefan Tauner4b24a2d2012-12-27 18:40:36 +0000390extern const struct dev_entry gfx_nvidia[];
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000391#endif
392
393/* drkaiser.c */
394#if CONFIG_DRKAISER == 1
395int drkaiser_init(void);
Stefan Tauner4b24a2d2012-12-27 18:40:36 +0000396extern const struct dev_entry drkaiser_pcidev[];
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000397#endif
398
399/* nicrealtek.c */
400#if CONFIG_NICREALTEK == 1
401int nicrealtek_init(void);
Stefan Tauner4b24a2d2012-12-27 18:40:36 +0000402extern const struct dev_entry nics_realtek[];
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000403#endif
404
405/* nicnatsemi.c */
406#if CONFIG_NICNATSEMI == 1
407int nicnatsemi_init(void);
Stefan Tauner4b24a2d2012-12-27 18:40:36 +0000408extern const struct dev_entry nics_natsemi[];
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000409#endif
410
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000411/* nicintel.c */
412#if CONFIG_NICINTEL == 1
413int nicintel_init(void);
Stefan Tauner4b24a2d2012-12-27 18:40:36 +0000414extern const struct dev_entry nics_intel[];
Carl-Daniel Hailfingerb713d2e2011-05-08 00:24:18 +0000415#endif
416
Idwer Vollering004f4b72010-09-03 18:21:21 +0000417/* nicintel_spi.c */
418#if CONFIG_NICINTEL_SPI == 1
419int nicintel_spi_init(void);
Stefan Tauner4b24a2d2012-12-27 18:40:36 +0000420extern const struct dev_entry nics_intel_spi[];
Idwer Vollering004f4b72010-09-03 18:21:21 +0000421#endif
422
Ricardo Ribalda Delgado2a41f0a2014-07-28 20:35:21 +0000423/* nicintel_eeprom.c */
424#if CONFIG_NICINTEL_EEPROM == 1
425int nicintel_ee_init(void);
426extern const struct dev_entry nics_intel_ee[];
427#endif
428
Mark Marshall90021f22010-12-03 14:48:11 +0000429/* ogp_spi.c */
430#if CONFIG_OGP_SPI == 1
431int ogp_spi_init(void);
Stefan Tauner4b24a2d2012-12-27 18:40:36 +0000432extern const struct dev_entry ogp_spi[];
Mark Marshall90021f22010-12-03 14:48:11 +0000433#endif
434
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000435/* satamv.c */
436#if CONFIG_SATAMV == 1
437int satamv_init(void);
Stefan Tauner4b24a2d2012-12-27 18:40:36 +0000438extern const struct dev_entry satas_mv[];
Carl-Daniel Hailfinger9a1105c2011-02-04 21:37:59 +0000439#endif
440
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000441/* satasii.c */
442#if CONFIG_SATASII == 1
443int satasii_init(void);
Stefan Tauner4b24a2d2012-12-27 18:40:36 +0000444extern const struct dev_entry satas_sii[];
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000445#endif
446
447/* atahpt.c */
448#if CONFIG_ATAHPT == 1
449int atahpt_init(void);
Stefan Tauner4b24a2d2012-12-27 18:40:36 +0000450extern const struct dev_entry ata_hpt[];
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000451#endif
452
Jonathan Kollasch7f0f3fa2014-06-01 10:26:23 +0000453/* atavia.c */
454#if CONFIG_ATAVIA == 1
455int atavia_init(void);
456void *atavia_map(const char *descr, uintptr_t phys_addr, size_t len);
457extern const struct dev_entry ata_via[];
458#endif
459
Kyösti Mälkki72d42f82014-06-01 23:48:31 +0000460/* it8212.c */
461#if CONFIG_IT8212 == 1
462int it8212_init(void);
463extern const struct dev_entry devs_it8212[];
464#endif
465
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000466/* ft2232_spi.c */
Jörg Fischer6529b9f2010-07-29 15:54:53 +0000467#if CONFIG_FT2232_SPI == 1
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000468int ft2232_spi_init(void);
Stefan Tauner4b24a2d2012-12-27 18:40:36 +0000469extern const struct dev_entry devs_ft2232spi[];
Jörg Fischer6529b9f2010-07-29 15:54:53 +0000470#endif
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000471
James Lairdc60de0e2013-03-27 13:00:23 +0000472/* usbblaster_spi.c */
473#if CONFIG_USBBLASTER_SPI == 1
474int usbblaster_spi_init(void);
475extern const struct dev_entry devs_usbblasterspi[];
476#endif
477
Alexandre Boeglin80e64712014-12-20 20:25:19 +0000478/* mstarddc_spi.c */
479#if CONFIG_MSTARDDC_SPI == 1
480int mstarddc_spi_init(void);
481#endif
482
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000483/* rayer_spi.c */
484#if CONFIG_RAYER_SPI == 1
485int rayer_spi_init(void);
486#endif
487
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000488/* pony_spi.c */
489#if CONFIG_PONY_SPI == 1
490int pony_spi_init(void);
491#endif
492
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000493/* bitbang_spi.c */
Carl-Daniel Hailfingera5bcbce2014-07-19 22:03:29 +0000494int register_spi_bitbang_master(const struct bitbang_spi_master *master);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000495
496/* buspirate_spi.c */
Carl-Daniel Hailfingerc4224842011-06-09 20:06:34 +0000497#if CONFIG_BUSPIRATE_SPI == 1
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000498int buspirate_spi_init(void);
Carl-Daniel Hailfingerc4224842011-06-09 20:06:34 +0000499#endif
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000500
Sven Schnelle5ce5f702011-09-03 18:37:52 +0000501/* linux_spi.c */
502#if CONFIG_LINUX_SPI == 1
503int linux_spi_init(void);
504#endif
505
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000506/* dediprog.c */
Carl-Daniel Hailfingerc4224842011-06-09 20:06:34 +0000507#if CONFIG_DEDIPROG == 1
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000508int dediprog_init(void);
Carl-Daniel Hailfingerc4224842011-06-09 20:06:34 +0000509#endif
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000510
511/* flashrom.c */
512struct decode_sizes {
513 uint32_t parallel;
514 uint32_t lpc;
515 uint32_t fwh;
516 uint32_t spi;
517};
Carl-Daniel Hailfingerc40cff72011-12-20 00:19:29 +0000518// FIXME: These need to be local, not global
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000519extern struct decode_sizes max_rom_decode;
520extern int programmer_may_write;
521extern unsigned long flashbase;
Stefan Tauner9e3a6982014-08-15 17:17:59 +0000522unsigned int count_max_decode_exceedings(const struct flashctx *flash);
Stefan Tauner66652442011-06-26 17:38:17 +0000523char *extract_programmer_param(const char *param_name);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000524
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000525/* 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,
Wei Hu31402ee2014-05-16 21:39:33 +0000535 SPI_CONTROLLER_YANGTZE,
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000536 SPI_CONTROLLER_VIA,
537 SPI_CONTROLLER_WBSIO,
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
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000552#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 +0000553 SPI_CONTROLLER_BITBANG,
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000554#endif
Sven Schnelle5ce5f702011-09-03 18:37:52 +0000555#if CONFIG_LINUX_SPI == 1
556 SPI_CONTROLLER_LINUX,
557#endif
Urja Rannikkoc93f5f12011-09-15 23:38:14 +0000558#if CONFIG_SERPROG == 1
559 SPI_CONTROLLER_SERPROG,
560#endif
James Lairdc60de0e2013-03-27 13:00:23 +0000561#if CONFIG_USBBLASTER_SPI == 1
562 SPI_CONTROLLER_USBBLASTER,
563#endif
Alexandre Boeglin80e64712014-12-20 20:25:19 +0000564#if CONFIG_MSTARDDC_SPI == 1
565 SPI_CONTROLLER_MSTARDDC,
566#endif
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000567};
Michael Karcher62797512011-05-11 17:07:02 +0000568
569#define MAX_DATA_UNSPECIFIED 0
570#define MAX_DATA_READ_UNLIMITED 64 * 1024
571#define MAX_DATA_WRITE_UNLIMITED 256
Carl-Daniel Hailfingera5bcbce2014-07-19 22:03:29 +0000572struct spi_master {
Michael Karcherb9dbe482011-05-11 17:07:07 +0000573 enum spi_controller type;
Stefan Taunerc69c9c82011-11-23 09:13:48 +0000574 unsigned int max_data_read;
575 unsigned int max_data_write;
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +0000576 int (*command)(struct flashctx *flash, unsigned int writecnt, unsigned int readcnt,
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000577 const unsigned char *writearr, unsigned char *readarr);
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +0000578 int (*multicommand)(struct flashctx *flash, struct spi_command *cmds);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000579
Carl-Daniel Hailfingera5bcbce2014-07-19 22:03:29 +0000580 /* Optimized functions for this master */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000581 int (*read)(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
Mark Marshallf20b7be2014-05-09 21:16:21 +0000582 int (*write_256)(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
583 int (*write_aai)(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
Carl-Daniel Hailfingerc40cff72011-12-20 00:19:29 +0000584 const void *data;
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000585};
586
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +0000587int default_spi_send_command(struct flashctx *flash, unsigned int writecnt, unsigned int readcnt,
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000588 const unsigned char *writearr, unsigned char *readarr);
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +0000589int default_spi_send_multicommand(struct flashctx *flash, struct spi_command *cmds);
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000590int default_spi_read(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
Mark Marshallf20b7be2014-05-09 21:16:21 +0000591int default_spi_write_256(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
592int 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 +0000593int register_spi_master(const struct spi_master *mst);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000594
Kyösti Mälkki78cd0872013-09-14 23:36:57 +0000595/* 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 +0000596enum ich_chipset {
597 CHIPSET_ICH_UNKNOWN,
Stefan Tauner92d6a862013-10-25 00:33:37 +0000598 CHIPSET_ICH,
599 CHIPSET_ICH2345,
Kyösti Mälkki78cd0872013-09-14 23:36:57 +0000600 CHIPSET_ICH6,
Stefan Tauner92d6a862013-10-25 00:33:37 +0000601 CHIPSET_POULSBO, /* SCH U* */
602 CHIPSET_TUNNEL_CREEK, /* Atom E6xx */
603 CHIPSET_CENTERTON, /* Atom S1220 S1240 S1260 */
Kyösti Mälkki78cd0872013-09-14 23:36:57 +0000604 CHIPSET_ICH7,
Stefan Taunera8d838d2011-11-06 23:51:09 +0000605 CHIPSET_ICH8,
606 CHIPSET_ICH9,
607 CHIPSET_ICH10,
608 CHIPSET_5_SERIES_IBEX_PEAK,
609 CHIPSET_6_SERIES_COUGAR_POINT,
Stefan Tauner2abab942012-04-27 20:41:23 +0000610 CHIPSET_7_SERIES_PANTHER_POINT,
Duncan Laurie90eb2262013-03-15 03:12:29 +0000611 CHIPSET_8_SERIES_LYNX_POINT,
Duncan Laurie4095ed72014-08-20 15:39:32 +0000612 CHIPSET_BAYTRAIL, /* Actually all with Silvermont architecture: Bay Trail, Avoton/Rangeley */
Duncan Laurie90eb2262013-03-15 03:12:29 +0000613 CHIPSET_8_SERIES_LYNX_POINT_LP,
614 CHIPSET_8_SERIES_WELLSBURG,
Duncan Laurie823096e2014-08-20 15:39:38 +0000615 CHIPSET_9_SERIES_WILDCAT_POINT,
Stefan Taunera8d838d2011-11-06 23:51:09 +0000616};
617
Stefan Tauner2abab942012-04-27 20:41:23 +0000618/* ichspi.c */
619#if CONFIG_INTERNAL == 1
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000620extern uint32_t ichspi_bbar;
Stefan Tauner92d6a862013-10-25 00:33:37 +0000621int ich_init_spi(struct pci_dev *dev, void *spibar, enum ich_chipset ich_generation);
Helge Wagnerdd73d832012-08-24 23:03:46 +0000622int via_init_spi(struct pci_dev *dev, uint32_t mmio_base);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000623
Stefan Taunerdbac46c2013-08-13 22:10:41 +0000624/* amd_imc.c */
Rudolf Marek70e14592013-07-25 22:58:56 +0000625int amd_imc_shutdown(struct pci_dev *dev);
626
David Hendricks4e748392011-02-28 23:58:15 +0000627/* it85spi.c */
Carl-Daniel Hailfingerbfecef62011-04-27 14:34:08 +0000628int it85xx_spi_init(struct superio s);
David Hendricks4e748392011-02-28 23:58:15 +0000629
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000630/* it87spi.c */
631void enter_conf_mode_ite(uint16_t port);
632void exit_conf_mode_ite(uint16_t port);
Carl-Daniel Hailfingerbfecef62011-04-27 14:34:08 +0000633void probe_superio_ite(void);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000634int init_superio_ite(void);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000635
Carl-Daniel Hailfingerc4224842011-06-09 20:06:34 +0000636/* mcp6x_spi.c */
637int mcp6x_spi_init(int want_spi);
638
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000639/* sb600spi.c */
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000640int sb600_probe_spi(struct pci_dev *dev);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000641
642/* wbsio_spi.c */
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000643int wbsio_check_for_spi(void);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000644#endif
645
Carl-Daniel Hailfinger532c7172011-11-04 21:35:26 +0000646/* opaque.c */
Carl-Daniel Hailfingera5bcbce2014-07-19 22:03:29 +0000647struct opaque_master {
Carl-Daniel Hailfinger532c7172011-11-04 21:35:26 +0000648 int max_data_read;
649 int max_data_write;
Carl-Daniel Hailfingera5bcbce2014-07-19 22:03:29 +0000650 /* Specific functions for this master */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000651 int (*probe) (struct flashctx *flash);
652 int (*read) (struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
Mark Marshallf20b7be2014-05-09 21:16:21 +0000653 int (*write) (struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000654 int (*erase) (struct flashctx *flash, unsigned int blockaddr, unsigned int blocklen);
Carl-Daniel Hailfingerc40cff72011-12-20 00:19:29 +0000655 const void *data;
Carl-Daniel Hailfinger532c7172011-11-04 21:35:26 +0000656};
Carl-Daniel Hailfingera5bcbce2014-07-19 22:03:29 +0000657int register_opaque_master(const struct opaque_master *mst);
Carl-Daniel Hailfinger532c7172011-11-04 21:35:26 +0000658
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +0000659/* programmer.c */
660int noop_shutdown(void);
Stefan Tauner305e0b92013-07-17 23:46:44 +0000661void *fallback_map(const char *descr, uintptr_t phys_addr, size_t len);
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +0000662void fallback_unmap(void *virt_addr, size_t len);
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +0000663void noop_chip_writeb(const struct flashctx *flash, uint8_t val, chipaddr addr);
664void fallback_chip_writew(const struct flashctx *flash, uint16_t val, chipaddr addr);
665void fallback_chip_writel(const struct flashctx *flash, uint32_t val, chipaddr addr);
Mark Marshallf20b7be2014-05-09 21:16:21 +0000666void fallback_chip_writen(const struct flashctx *flash, const uint8_t *buf, chipaddr addr, size_t len);
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +0000667uint16_t fallback_chip_readw(const struct flashctx *flash, const chipaddr addr);
668uint32_t fallback_chip_readl(const struct flashctx *flash, const chipaddr addr);
669void fallback_chip_readn(const struct flashctx *flash, uint8_t *buf, const chipaddr addr, size_t len);
Carl-Daniel Hailfingera5bcbce2014-07-19 22:03:29 +0000670struct par_master {
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +0000671 void (*chip_writeb) (const struct flashctx *flash, uint8_t val, chipaddr addr);
672 void (*chip_writew) (const struct flashctx *flash, uint16_t val, chipaddr addr);
673 void (*chip_writel) (const struct flashctx *flash, uint32_t val, chipaddr addr);
Mark Marshallf20b7be2014-05-09 21:16:21 +0000674 void (*chip_writen) (const struct flashctx *flash, const uint8_t *buf, chipaddr addr, size_t len);
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +0000675 uint8_t (*chip_readb) (const struct flashctx *flash, const chipaddr addr);
676 uint16_t (*chip_readw) (const struct flashctx *flash, const chipaddr addr);
677 uint32_t (*chip_readl) (const struct flashctx *flash, const chipaddr addr);
678 void (*chip_readn) (const struct flashctx *flash, uint8_t *buf, const chipaddr addr, size_t len);
Carl-Daniel Hailfingerc40cff72011-12-20 00:19:29 +0000679 const void *data;
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +0000680};
Carl-Daniel Hailfingera5bcbce2014-07-19 22:03:29 +0000681int register_par_master(const struct par_master *mst, const enum chipbustype buses);
682struct registered_master {
Carl-Daniel Hailfingerc40cff72011-12-20 00:19:29 +0000683 enum chipbustype buses_supported;
684 union {
Carl-Daniel Hailfingera5bcbce2014-07-19 22:03:29 +0000685 struct par_master par;
686 struct spi_master spi;
687 struct opaque_master opaque;
Carl-Daniel Hailfingerc40cff72011-12-20 00:19:29 +0000688 };
689};
Carl-Daniel Hailfingera5bcbce2014-07-19 22:03:29 +0000690extern struct registered_master registered_masters[];
691extern int registered_master_count;
Stefan Tauner5c316f92015-02-08 21:57:52 +0000692int register_master(const struct registered_master *mst);
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +0000693
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000694/* serprog.c */
Carl-Daniel Hailfingerc4224842011-06-09 20:06:34 +0000695#if CONFIG_SERPROG == 1
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000696int serprog_init(void);
Stefan Taunerf80419c2014-05-02 15:41:42 +0000697void serprog_delay(unsigned int usecs);
Carl-Daniel Hailfingerc4224842011-06-09 20:06:34 +0000698#endif
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000699
700/* serial.c */
Stefan Taunerb0eee9b2015-01-10 09:32:50 +0000701#if IS_WINDOWS
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000702typedef HANDLE fdtype;
Stefan Taunerbb4fed72012-09-01 21:47:19 +0000703#define SER_INV_FD INVALID_HANDLE_VALUE
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000704#else
705typedef int fdtype;
Stefan Taunerbb4fed72012-09-01 21:47:19 +0000706#define SER_INV_FD -1
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000707#endif
708
709void sp_flush_incoming(void);
710fdtype sp_openserport(char *dev, unsigned int baud);
Stefan Tauner184c52c2013-08-23 21:51:32 +0000711int serialport_config(fdtype fd, unsigned int baud);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000712extern fdtype sp_fd;
David Hendricks8bb20212011-06-14 01:35:36 +0000713/* expose serialport_shutdown as it's currently used by buspirate */
714int serialport_shutdown(void *data);
Mark Marshallf20b7be2014-05-09 21:16:21 +0000715int serialport_write(const unsigned char *buf, unsigned int writecnt);
716int 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 +0000717int serialport_read(unsigned char *buf, unsigned int readcnt);
Stefan Tauner00e16082013-04-01 00:45:38 +0000718int serialport_read_nonblock(unsigned char *c, unsigned int readcnt, unsigned int timeout, unsigned int *really_read);
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000719
Virgil-Adrian Teacada7c5452012-04-30 23:11:06 +0000720/* Serial port/pin mapping:
721
722 1 CD <-
723 2 RXD <-
724 3 TXD ->
725 4 DTR ->
726 5 GND --
727 6 DSR <-
728 7 RTS ->
729 8 CTS <-
730 9 RI <-
731*/
732enum SP_PIN {
733 PIN_CD = 1,
734 PIN_RXD,
735 PIN_TXD,
736 PIN_DTR,
737 PIN_GND,
738 PIN_DSR,
739 PIN_RTS,
740 PIN_CTS,
741 PIN_RI,
742};
743
744void sp_set_pin(enum SP_PIN pin, int val);
745int sp_get_pin(enum SP_PIN pin);
746
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +0000747#endif /* !__PROGRAMMER_H__ */