programmer.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719
  1. /*
  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. #ifndef __PROGRAMMER_H__
  24. #define __PROGRAMMER_H__ 1
  25. #include "flash.h" /* for chipaddr and flashctx */
  26. enum programmer {
  27. #if CONFIG_INTERNAL == 1
  28. PROGRAMMER_INTERNAL,
  29. #endif
  30. #if CONFIG_DUMMY == 1
  31. PROGRAMMER_DUMMY,
  32. #endif
  33. #if CONFIG_NIC3COM == 1
  34. PROGRAMMER_NIC3COM,
  35. #endif
  36. #if CONFIG_NICREALTEK == 1
  37. PROGRAMMER_NICREALTEK,
  38. #endif
  39. #if CONFIG_NICNATSEMI == 1
  40. PROGRAMMER_NICNATSEMI,
  41. #endif
  42. #if CONFIG_GFXNVIDIA == 1
  43. PROGRAMMER_GFXNVIDIA,
  44. #endif
  45. #if CONFIG_DRKAISER == 1
  46. PROGRAMMER_DRKAISER,
  47. #endif
  48. #if CONFIG_SATASII == 1
  49. PROGRAMMER_SATASII,
  50. #endif
  51. #if CONFIG_ATAHPT == 1
  52. PROGRAMMER_ATAHPT,
  53. #endif
  54. #if CONFIG_FT2232_SPI == 1
  55. PROGRAMMER_FT2232_SPI,
  56. #endif
  57. #if CONFIG_SERPROG == 1
  58. PROGRAMMER_SERPROG,
  59. #endif
  60. #if CONFIG_BUSPIRATE_SPI == 1
  61. PROGRAMMER_BUSPIRATE_SPI,
  62. #endif
  63. #if CONFIG_RAIDEN_DEBUG_SPI == 1
  64. PROGRAMMER_RAIDEN_DEBUG_SPI,
  65. #endif
  66. #if CONFIG_DEDIPROG == 1
  67. PROGRAMMER_DEDIPROG,
  68. #endif
  69. #if CONFIG_RAYER_SPI == 1
  70. PROGRAMMER_RAYER_SPI,
  71. #endif
  72. #if CONFIG_NICINTEL == 1
  73. PROGRAMMER_NICINTEL,
  74. #endif
  75. #if CONFIG_NICINTEL_SPI == 1
  76. PROGRAMMER_NICINTEL_SPI,
  77. #endif
  78. #if CONFIG_OGP_SPI == 1
  79. PROGRAMMER_OGP_SPI,
  80. #endif
  81. #if CONFIG_SATAMV == 1
  82. PROGRAMMER_SATAMV,
  83. #endif
  84. #if CONFIG_LINUX_MTD == 1
  85. PROGRAMMER_LINUX_MTD,
  86. #endif
  87. #if CONFIG_LINUX_SPI == 1
  88. PROGRAMMER_LINUX_SPI,
  89. #endif
  90. PROGRAMMER_INVALID /* This must always be the last entry. */
  91. };
  92. enum alias_type {
  93. ALIAS_NONE = 0, /* no alias (default) */
  94. ALIAS_EC, /* embedded controller */
  95. ALIAS_HOST, /* chipset / PCH / SoC / etc. */
  96. };
  97. struct programmer_alias {
  98. const char *name;
  99. enum alias_type type;
  100. };
  101. extern struct programmer_alias *alias;
  102. extern struct programmer_alias aliases[];
  103. struct programmer_entry {
  104. const char *vendor;
  105. const char *name;
  106. int (*init) (void);
  107. void *(*map_flash_region) (const char *descr, unsigned long phys_addr,
  108. size_t len);
  109. void (*unmap_flash_region) (void *virt_addr, size_t len);
  110. void (*delay) (int usecs);
  111. /*
  112. * If set, use extra precautions such as erasing with small block sizes
  113. * and verifying more rigorously. This will incur a performance penalty
  114. * but is good for programming the ROM in-system on a live machine.
  115. */
  116. int paranoid;
  117. };
  118. extern const struct programmer_entry programmer_table[];
  119. int programmer_init(enum programmer prog, char *param);
  120. int programmer_shutdown(void);
  121. enum bitbang_spi_master_type {
  122. BITBANG_SPI_INVALID = 0, /* This must always be the first entry. */
  123. #if CONFIG_RAYER_SPI == 1
  124. BITBANG_SPI_MASTER_RAYER,
  125. #endif
  126. #if CONFIG_NICINTEL_SPI == 1
  127. BITBANG_SPI_MASTER_NICINTEL,
  128. #endif
  129. #if CONFIG_INTERNAL == 1
  130. #if defined(__i386__) || defined(__x86_64__)
  131. BITBANG_SPI_MASTER_MCP,
  132. #endif
  133. #endif
  134. #if CONFIG_OGP_SPI == 1
  135. BITBANG_SPI_MASTER_OGP,
  136. #endif
  137. };
  138. struct bitbang_spi_master {
  139. enum bitbang_spi_master_type type;
  140. /* Note that CS# is active low, so val=0 means the chip is active. */
  141. void (*set_cs) (int val);
  142. void (*set_sck) (int val);
  143. void (*set_mosi) (int val);
  144. int (*get_miso) (void);
  145. void (*request_bus) (void);
  146. void (*release_bus) (void);
  147. };
  148. #if CONFIG_INTERNAL == 1
  149. struct penable {
  150. uint16_t vendor_id;
  151. uint16_t device_id;
  152. int status; /* OK=0 and NT=1 are defines only. Beware! */
  153. const char *vendor_name;
  154. const char *device_name;
  155. int (*doit) (struct pci_dev *dev, const char *name);
  156. };
  157. extern const struct penable chipset_enables[];
  158. enum board_match_phase {
  159. P1,
  160. P2,
  161. P3
  162. };
  163. struct board_match {
  164. /* Any device, but make it sensible, like the ISA bridge. */
  165. uint16_t first_vendor;
  166. uint16_t first_device;
  167. uint16_t first_card_vendor;
  168. uint16_t first_card_device;
  169. /* Any device, but make it sensible, like
  170. * the host bridge. May be NULL.
  171. */
  172. uint16_t second_vendor;
  173. uint16_t second_device;
  174. uint16_t second_card_vendor;
  175. uint16_t second_card_device;
  176. /* Pattern to match DMI entries. May be NULL. */
  177. const char *dmi_pattern;
  178. /* The vendor / part name from the coreboot table. May be NULL. */
  179. const char *lb_vendor;
  180. const char *lb_part;
  181. enum board_match_phase phase;
  182. const char *vendor_name;
  183. const char *board_name;
  184. int max_rom_decode_parallel;
  185. int status;
  186. int (*enable) (void); /* May be NULL. */
  187. };
  188. extern const struct board_match board_matches[];
  189. struct board_info {
  190. const char *vendor;
  191. const char *name;
  192. const int working;
  193. #ifdef CONFIG_PRINT_WIKI
  194. const char *url;
  195. const char *note;
  196. #endif
  197. };
  198. extern const struct board_info boards_known[];
  199. extern const struct board_info laptops_known[];
  200. #endif
  201. /* udelay.c */
  202. void myusec_delay(int usecs);
  203. void myusec_calibrate_delay(void);
  204. void internal_delay(int usecs);
  205. #if NEED_PCI == 1
  206. /* pcidev.c */
  207. extern uint32_t io_base_addr;
  208. extern struct pci_access *pacc;
  209. extern struct pci_dev *pcidev_dev;
  210. struct pcidev_status {
  211. uint16_t vendor_id;
  212. uint16_t device_id;
  213. int status;
  214. const char *vendor_name;
  215. const char *device_name;
  216. };
  217. uintptr_t pcidev_validate(struct pci_dev *dev, int bar, const struct pcidev_status *devs);
  218. uintptr_t pcidev_init(int bar, const struct pcidev_status *devs);
  219. /* rpci_write_* are reversible writes. The original PCI config space register
  220. * contents will be restored on shutdown.
  221. */
  222. int rpci_write_byte(struct pci_dev *dev, int reg, uint8_t data);
  223. int rpci_write_word(struct pci_dev *dev, int reg, uint16_t data);
  224. int rpci_write_long(struct pci_dev *dev, int reg, uint32_t data);
  225. #endif
  226. /* print.c */
  227. #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
  228. void print_supported_pcidevs(const struct pcidev_status *devs);
  229. #endif
  230. #if CONFIG_INTERNAL == 1
  231. /* board_enable.c */
  232. void w836xx_ext_enter(uint16_t port);
  233. void w836xx_ext_leave(uint16_t port);
  234. int it8705f_write_enable(uint8_t port);
  235. uint8_t sio_read(uint16_t port, uint8_t reg);
  236. void sio_write(uint16_t port, uint8_t reg, uint8_t data);
  237. void sio_mask(uint16_t port, uint8_t reg, uint8_t data, uint8_t mask);
  238. void board_handle_before_superio(void);
  239. void board_handle_before_laptop(void);
  240. int board_flash_enable(const char *vendor, const char *part);
  241. /* chipset_enable.c */
  242. int chipset_flash_enable(void);
  243. int get_target_bus_from_chipset(enum chipbustype *target_bus);
  244. enum ich_chipset ich_generation;
  245. /* processor_enable.c */
  246. int processor_flash_enable(void);
  247. #endif
  248. /* physmap.c */
  249. void *physmap(const char *descr, unsigned long phys_addr, size_t len);
  250. void *physmap_try_ro(const char *descr, unsigned long phys_addr, size_t len);
  251. void physunmap(void *virt_addr, size_t len);
  252. #if CONFIG_INTERNAL == 1
  253. int setup_cpu_msr(int cpu);
  254. void cleanup_cpu_msr(void);
  255. /* cbtable.c */
  256. void lb_vendor_dev_from_string(const char *boardstring);
  257. int coreboot_init(void);
  258. extern char *lb_part, *lb_vendor;
  259. extern int partvendor_from_cbtable;
  260. /* dmi.c */
  261. extern int has_dmi_support;
  262. void dmi_init(void);
  263. int dmi_match(const char *pattern);
  264. /* internal.c */
  265. struct superio {
  266. uint16_t vendor;
  267. uint16_t port;
  268. uint16_t model;
  269. };
  270. extern struct superio superios[];
  271. extern int superio_count;
  272. #define SUPERIO_VENDOR_NONE 0x0
  273. #define SUPERIO_VENDOR_ITE 0x1
  274. #endif
  275. #if NEED_PCI == 1
  276. struct pci_dev *pci_dev_find_filter(struct pci_filter filter);
  277. struct pci_dev *pci_dev_find_vendorclass(uint16_t vendor, uint16_t devclass);
  278. struct pci_dev *pci_dev_find(uint16_t vendor, uint16_t device);
  279. struct pci_dev *pci_card_find(uint16_t vendor, uint16_t device,
  280. uint16_t card_vendor, uint16_t card_device);
  281. #endif
  282. void get_io_perms(void);
  283. void release_io_perms(void);
  284. #if CONFIG_INTERNAL == 1
  285. extern int is_laptop;
  286. extern int laptop_ok;
  287. extern int force_boardenable;
  288. extern int force_boardmismatch;
  289. void probe_superio(void);
  290. int register_superio(struct superio s);
  291. extern enum chipbustype internal_buses_supported;
  292. int internal_init(void);
  293. #endif
  294. /* hwaccess.c */
  295. void mmio_writeb(uint8_t val, void *addr);
  296. void mmio_writew(uint16_t val, void *addr);
  297. void mmio_writel(uint32_t val, void *addr);
  298. uint8_t mmio_readb(void *addr);
  299. uint16_t mmio_readw(void *addr);
  300. uint32_t mmio_readl(void *addr);
  301. void mmio_le_writeb(uint8_t val, void *addr);
  302. void mmio_le_writew(uint16_t val, void *addr);
  303. void mmio_le_writel(uint32_t val, void *addr);
  304. uint8_t mmio_le_readb(void *addr);
  305. uint16_t mmio_le_readw(void *addr);
  306. uint32_t mmio_le_readl(void *addr);
  307. #define pci_mmio_writeb mmio_le_writeb
  308. #define pci_mmio_writew mmio_le_writew
  309. #define pci_mmio_writel mmio_le_writel
  310. #define pci_mmio_readb mmio_le_readb
  311. #define pci_mmio_readw mmio_le_readw
  312. #define pci_mmio_readl mmio_le_readl
  313. void rmmio_writeb(uint8_t val, void *addr);
  314. void rmmio_writew(uint16_t val, void *addr);
  315. void rmmio_writel(uint32_t val, void *addr);
  316. void rmmio_le_writeb(uint8_t val, void *addr);
  317. void rmmio_le_writew(uint16_t val, void *addr);
  318. void rmmio_le_writel(uint32_t val, void *addr);
  319. #define pci_rmmio_writeb rmmio_le_writeb
  320. #define pci_rmmio_writew rmmio_le_writew
  321. #define pci_rmmio_writel rmmio_le_writel
  322. void rmmio_valb(void *addr);
  323. void rmmio_valw(void *addr);
  324. void rmmio_vall(void *addr);
  325. /* dummyflasher.c */
  326. #if CONFIG_DUMMY == 1
  327. int dummy_init(void);
  328. void *dummy_map(const char *descr, unsigned long phys_addr, size_t len);
  329. void dummy_unmap(void *virt_addr, size_t len);
  330. #endif
  331. /* nic3com.c */
  332. #if CONFIG_NIC3COM == 1
  333. int nic3com_init(void);
  334. extern const struct pcidev_status nics_3com[];
  335. #endif
  336. /* gfxnvidia.c */
  337. #if CONFIG_GFXNVIDIA == 1
  338. int gfxnvidia_init(void);
  339. extern const struct pcidev_status gfx_nvidia[];
  340. #endif
  341. /* drkaiser.c */
  342. #if CONFIG_DRKAISER == 1
  343. int drkaiser_init(void);
  344. extern const struct pcidev_status drkaiser_pcidev[];
  345. #endif
  346. /* nicrealtek.c */
  347. #if CONFIG_NICREALTEK == 1
  348. int nicrealtek_init(void);
  349. extern const struct pcidev_status nics_realtek[];
  350. #endif
  351. /* nicnatsemi.c */
  352. #if CONFIG_NICNATSEMI == 1
  353. int nicnatsemi_init(void);
  354. extern const struct pcidev_status nics_natsemi[];
  355. #endif
  356. /* nicintel.c */
  357. #if CONFIG_NICINTEL == 1
  358. int nicintel_init(void);
  359. extern const struct pcidev_status nics_intel[];
  360. #endif
  361. /* nicintel_spi.c */
  362. #if CONFIG_NICINTEL_SPI == 1
  363. int nicintel_spi_init(void);
  364. extern const struct pcidev_status nics_intel_spi[];
  365. #endif
  366. /* ogp_spi.c */
  367. #if CONFIG_OGP_SPI == 1
  368. int ogp_spi_init(void);
  369. extern const struct pcidev_status ogp_spi[];
  370. #endif
  371. /* satamv.c */
  372. #if CONFIG_SATAMV == 1
  373. int satamv_init(void);
  374. extern const struct pcidev_status satas_mv[];
  375. #endif
  376. /* satasii.c */
  377. #if CONFIG_SATASII == 1
  378. int satasii_init(void);
  379. extern const struct pcidev_status satas_sii[];
  380. #endif
  381. /* atahpt.c */
  382. #if CONFIG_ATAHPT == 1
  383. int atahpt_init(void);
  384. extern const struct pcidev_status ata_hpt[];
  385. #endif
  386. /* ft2232_spi.c */
  387. #if CONFIG_FT2232_SPI == 1
  388. struct usbdev_status {
  389. uint16_t vendor_id;
  390. uint16_t device_id;
  391. int status;
  392. const char *vendor_name;
  393. const char *device_name;
  394. };
  395. int ft2232_spi_init(void);
  396. extern const struct usbdev_status devs_ft2232spi[];
  397. void print_supported_usbdevs(const struct usbdev_status *devs);
  398. #endif
  399. /* rayer_spi.c */
  400. #if CONFIG_RAYER_SPI == 1
  401. int rayer_spi_init(void);
  402. #endif
  403. /* bitbang_spi.c */
  404. int bitbang_spi_init(const struct bitbang_spi_master *master, int halfperiod);
  405. int bitbang_spi_shutdown(const struct bitbang_spi_master *master);
  406. /* buspirate_spi.c */
  407. #if CONFIG_BUSPIRATE_SPI == 1
  408. int buspirate_spi_init(void);
  409. #endif
  410. /* raiden_debug_spi.c */
  411. #if CONFIG_RAIDEN_DEBUG_SPI == 1
  412. int raiden_debug_spi_init(void);
  413. #endif
  414. /* linux_i2c.c */
  415. #if CONFIG_LINUX_I2C == 1
  416. int linux_i2c_shutdown(void *data);
  417. int linux_i2c_init(void);
  418. int linux_i2c_open(int bus, int addr, int force);
  419. void linux_i2c_close(void);
  420. int linux_i2c_xfer(int bus, int addr, const void *inbuf,
  421. int insize, const void *outbuf, int outsize);
  422. #endif
  423. /* linux_mtd.c */
  424. #if CONFIG_LINUX_MTD == 1
  425. int linux_mtd_init(void);
  426. #endif
  427. /* linux_spi.c */
  428. #if CONFIG_LINUX_SPI == 1
  429. int linux_spi_init(void);
  430. #endif
  431. /* dediprog.c */
  432. #if CONFIG_DEDIPROG == 1
  433. int dediprog_init(void);
  434. #endif
  435. /* flashrom.c */
  436. struct decode_sizes {
  437. uint32_t parallel;
  438. uint32_t lpc;
  439. uint32_t fwh;
  440. uint32_t spi;
  441. };
  442. extern struct decode_sizes max_rom_decode;
  443. extern int programmer_may_write;
  444. extern unsigned long flashbase;
  445. void check_chip_supported(const struct flashctx *flash);
  446. int check_max_decode(enum chipbustype buses, uint32_t size);
  447. char *extract_programmer_param(const char *param_name);
  448. /* layout.c */
  449. int show_id(uint8_t *bios, int size, int force);
  450. /* spi.c */
  451. enum spi_controller {
  452. SPI_CONTROLLER_NONE,
  453. #if CONFIG_INTERNAL == 1
  454. #if defined(__i386__) || defined(__x86_64__)
  455. SPI_CONTROLLER_ICH7,
  456. SPI_CONTROLLER_ICH9,
  457. SPI_CONTROLLER_ICH_HWSEQ,
  458. SPI_CONTROLLER_IT85XX,
  459. SPI_CONTROLLER_IT87XX,
  460. SPI_CONTROLLER_MEC1308,
  461. SPI_CONTROLLER_SB600,
  462. SPI_CONTROLLER_VIA,
  463. SPI_CONTROLLER_WBSIO,
  464. SPI_CONTROLLER_WPCE775X,
  465. SPI_CONTROLLER_ENE,
  466. #endif
  467. #if defined(__arm__)
  468. SPI_CONTROLLER_TEGRA2,
  469. #endif
  470. #endif
  471. #if CONFIG_FT2232_SPI == 1
  472. SPI_CONTROLLER_FT2232,
  473. #endif
  474. #if CONFIG_DUMMY == 1
  475. SPI_CONTROLLER_DUMMY,
  476. #endif
  477. #if CONFIG_BUSPIRATE_SPI == 1
  478. SPI_CONTROLLER_BUSPIRATE,
  479. #endif
  480. #if CONFIG_RAIDEN_DEBUG_SPI == 1
  481. SPI_CONTROLLER_RAIDEN_DEBUG,
  482. #endif
  483. #if CONFIG_DEDIPROG == 1
  484. SPI_CONTROLLER_DEDIPROG,
  485. #endif
  486. #if CONFIG_OGP_SPI == 1 || CONFIG_NICINTEL_SPI == 1 || CONFIG_RAYER_SPI == 1 || (CONFIG_INTERNAL == 1 && (defined(__i386__) || defined(__x86_64__) || defined(__arm__)))
  487. SPI_CONTROLLER_BITBANG,
  488. #endif
  489. #if CONFIG_LINUX_SPI == 1
  490. SPI_CONTROLLER_LINUX,
  491. #endif
  492. #if CONFIG_SERPROG == 1
  493. SPI_CONTROLLER_SERPROG,
  494. #endif
  495. };
  496. extern const int spi_programmer_count;
  497. #define MAX_DATA_UNSPECIFIED 0
  498. #define MAX_DATA_READ_UNLIMITED 64 * 1024
  499. #define MAX_DATA_WRITE_UNLIMITED 256
  500. struct spi_programmer {
  501. enum spi_controller type;
  502. unsigned int max_data_read;
  503. unsigned int max_data_write;
  504. int (*command)(const struct flashctx *flash, unsigned int writecnt, unsigned int readcnt,
  505. const unsigned char *writearr, unsigned char *readarr);
  506. int (*multicommand)(const struct flashctx *flash, struct spi_command *cmds);
  507. /* Optimized functions for this programmer */
  508. int (*read)(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
  509. int (*write_256)(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
  510. };
  511. extern const struct spi_programmer *spi_programmer;
  512. int default_spi_send_command(const struct flashctx *flash, unsigned int writecnt, unsigned int readcnt,
  513. const unsigned char *writearr, unsigned char *readarr);
  514. int default_spi_send_multicommand(const struct flashctx *flash, struct spi_command *cmds);
  515. int default_spi_read(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
  516. int default_spi_write_256(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
  517. void register_spi_programmer(const struct spi_programmer *programmer);
  518. /* ichspi.c */
  519. enum ich_chipset {
  520. CHIPSET_ICH_UNKNOWN,
  521. CHIPSET_ICH7 = 7,
  522. CHIPSET_ICH8,
  523. CHIPSET_ICH9,
  524. CHIPSET_ICH10,
  525. CHIPSET_5_SERIES_IBEX_PEAK,
  526. CHIPSET_6_SERIES_COUGAR_POINT,
  527. CHIPSET_7_SERIES_PANTHER_POINT,
  528. CHIPSET_8_SERIES_LYNX_POINT,
  529. CHIPSET_8_SERIES_LYNX_POINT_LP,
  530. CHIPSET_9_SERIES_WILDCAT_POINT,
  531. CHIPSET_100_SERIES_SUNRISE_POINT,
  532. CHIPSET_BAYTRAIL,
  533. CHIPSET_APL,
  534. };
  535. #if CONFIG_INTERNAL == 1
  536. extern uint32_t ichspi_bbar;
  537. int ich_init_spi(struct pci_dev *dev, uint32_t base, void *rcrb,
  538. enum ich_chipset ich_generation);
  539. int via_init_spi(struct pci_dev *dev);
  540. /* ene_lpc.c */
  541. int ene_probe_spi_flash(const char *name);
  542. /* it85spi.c */
  543. int it85xx_spi_init(struct superio s);
  544. int it8518_spi_init(struct superio s);
  545. /* it87spi.c */
  546. void enter_conf_mode_ite(uint16_t port);
  547. void exit_conf_mode_ite(uint16_t port);
  548. void probe_superio_ite(void);
  549. int init_superio_ite(void);
  550. /* mcp6x_spi.c */
  551. int mcp6x_spi_init(int want_spi);
  552. /* mec1308.c */
  553. int mec1308_probe_spi_flash(const char *name);
  554. /* sb600spi.c */
  555. int sb600_probe_spi(struct pci_dev *dev);
  556. /* wbsio_spi.c */
  557. int wbsio_check_for_spi(void);
  558. #endif
  559. /* opaque.c */
  560. struct opaque_programmer {
  561. int max_data_read;
  562. int max_data_write;
  563. /* Specific functions for this programmer */
  564. int (*probe) (struct flashctx *flash);
  565. int (*read) (struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
  566. int (*write) (struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
  567. int (*erase) (struct flashctx *flash, unsigned int blockaddr, unsigned int blocklen);
  568. uint8_t (*read_status) (const struct flashctx *flash);
  569. int (*write_status) (const struct flashctx *flash, int status);
  570. const void *data;
  571. };
  572. extern struct opaque_programmer *opaque_programmer;
  573. void register_opaque_programmer(struct opaque_programmer *pgm);
  574. /* programmer.c */
  575. int noop_shutdown(void);
  576. void *fallback_map(const char *descr, unsigned long phys_addr, size_t len);
  577. void fallback_unmap(void *virt_addr, size_t len);
  578. uint8_t noop_chip_readb(const struct flashctx *flash, const chipaddr addr);
  579. void noop_chip_writeb(const struct flashctx *flash, uint8_t val, chipaddr addr);
  580. void fallback_chip_writew(const struct flashctx *flash, uint16_t val, chipaddr addr);
  581. void fallback_chip_writel(const struct flashctx *flash, uint32_t val, chipaddr addr);
  582. void fallback_chip_writen(const struct flashctx *flash, uint8_t *buf, chipaddr addr, size_t len);
  583. uint16_t fallback_chip_readw(const struct flashctx *flash, const chipaddr addr);
  584. uint32_t fallback_chip_readl(const struct flashctx *flash, const chipaddr addr);
  585. void fallback_chip_readn(const struct flashctx *flash, uint8_t *buf, const chipaddr addr, size_t len);
  586. struct par_programmer {
  587. void (*chip_writeb) (const struct flashctx *flash, uint8_t val, chipaddr addr);
  588. void (*chip_writew) (const struct flashctx *flash, uint16_t val, chipaddr addr);
  589. void (*chip_writel) (const struct flashctx *flash, uint32_t val, chipaddr addr);
  590. void (*chip_writen) (const struct flashctx *flash, uint8_t *buf, chipaddr addr, size_t len);
  591. uint8_t (*chip_readb) (const struct flashctx *flash, const chipaddr addr);
  592. uint16_t (*chip_readw) (const struct flashctx *flash, const chipaddr addr);
  593. uint32_t (*chip_readl) (const struct flashctx *flash, const chipaddr addr);
  594. void (*chip_readn) (const struct flashctx *flash, uint8_t *buf, const chipaddr addr, size_t len);
  595. };
  596. extern const struct par_programmer *par_programmer;
  597. void register_par_programmer(const struct par_programmer *pgm, const enum chipbustype buses);
  598. /* serprog.c */
  599. #if CONFIG_SERPROG == 1
  600. int serprog_init(void);
  601. void serprog_delay(int usecs);
  602. #endif
  603. /* serial.c */
  604. #if _WIN32
  605. typedef HANDLE fdtype;
  606. #else
  607. typedef int fdtype;
  608. #endif
  609. /* wpce775x.c */
  610. int wpce775x_probe_spi_flash(const char *name);
  611. /* cros_ec.c */
  612. int cros_ec_probe_i2c(const char *name);
  613. /**
  614. * Probe the Google Chrome OS EC device
  615. *
  616. * @return 0 if found correct, non-zero if not found or error
  617. */
  618. int cros_ec_probe_dev(void);
  619. int cros_ec_probe_lpc(const char *name);
  620. int cros_ec_need_2nd_pass(void);
  621. int cros_ec_finish(void);
  622. int cros_ec_prepare(uint8_t *image, int size);
  623. void sp_flush_incoming(void);
  624. fdtype sp_openserport(char *dev, unsigned int baud);
  625. void __attribute__((noreturn)) sp_die(char *msg);
  626. extern fdtype sp_fd;
  627. /* expose serialport_shutdown as it's currently used by buspirate */
  628. int serialport_shutdown(void *data);
  629. int serialport_write(unsigned char *buf, unsigned int writecnt);
  630. int serialport_read(unsigned char *buf, unsigned int readcnt);
  631. #endif /* !__PROGRAMMER_H__ */