Move SPI code out of board_enable.c where it started its life. The SPI
[coreboot.git] / util / flashrom / flash.h
index 62d3f40a956cbd2aa4d4f5e379f8935361bbf49f..6029828773d6a5f07b4668a68b7d45457ea11f1d 100644 (file)
@@ -1,24 +1,23 @@
 /*
- * flash.h: flash programming utility - central include file
+ * This file is part of the flashrom project.
  *
- * Copyright 2000 Silicon Integrated System Corporation
- * Copyright 2000 Ronald G. Minnich <rminnich@gmail.com>
- * Copyright 2005-2007 coresystems GmbH <stepan@coresystems.de>
- * 
- *     This program is free software; you can redistribute it and/or modify
- *     it under the terms of the GNU General Public License as published by
- *     the Free Software Foundation; either version 2 of the License, or
- *     (at your option) any later version.
+ * Copyright (C) 2000 Silicon Integrated System Corporation
+ * Copyright (C) 2000 Ronald G. Minnich <rminnich@gmail.com>
+ * Copyright (C) 2005-2007 coresystems GmbH <stepan@coresystems.de>
  *
- *     This program is distributed in the hope that it will be useful,
- *     but WITHOUT ANY WARRANTY; without even the implied warranty of
- *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *     GNU General Public License for more details.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
  *
- *     You should have received a copy of the GNU General Public License
- *     along with this program; if not, write to the Free Software
- *     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
 #ifndef __FLASH_H__
@@ -27,9 +26,9 @@
 #if defined(__GLIBC__)
 #include <sys/io.h>
 #endif
-
 #include <unistd.h>
 #include <stdint.h>
+#include <stdio.h>
 
 struct flashchip {
        char *name;
@@ -56,6 +55,8 @@ extern struct flashchip flashchips[];
 /* Please keep this list sorted alphabetically by manufacturer. The first
  * entry of each section should be the manufacturer ID, followed by the
  * list of devices from that manufacturer (sorted by device IDs).
+ * All LPC/FWH parts (parallel flash) have 8-bit device IDs.
+ * All SPI parts have 16-bit device IDs.
  */
 
 #define AMD_ID                 0x01    /* AMD */
@@ -69,8 +70,31 @@ extern struct flashchip flashchips[];
 #define AT_29C040A             0xA4
 #define AT_29C020              0xDA
 
+#define EON_ID                 0x1C
+/* EN25 chips are SPI, first byte of device id is memory type,
+   second byte of device id is log(bitsize)-9 */
+#define EN_25B05               0x2010  /* 2^19 kbit or 2^16 kByte */
+#define EN_25B10               0x2011
+#define EN_25B20               0x2012
+#define EN_25B40               0x2013
+#define EN_25B80               0x2014
+#define EN_25B16               0x2015
+#define EN_25B32               0x2016
+
 #define MX_ID                  0xC2    /* Macronix (MX) */
 #define MX_29F002              0xB0
+/* MX25L chips are SPI, first byte of device id is memory type,
+   second byte of device id is log(bitsize)-9 */
+#define MX_25L512              0x2010  /* 2^19 kbit or 2^16 kByte */
+#define MX_25L1005             0x2011
+#define MX_25L2005             0x2012
+#define MX_25L4005             0x2013  /* MX25L4005{,A} */
+#define MX_25L8005             0x2014
+#define MX_25L1605             0x2015  /* MX25L1605{,A,D} */
+#define MX_25L3205             0x2016  /* MX25L3205{,A} */
+#define MX_25L6405             0x2017  /* MX25L3205{,D} */
+#define MX_25L1635D            0x2415
+#define MX_25L3235D            0x2416
 
 #define SHARP_ID               0xB0    /* Sharp */
 #define SHARP_LHF00L04         0xCF
@@ -102,6 +126,8 @@ extern struct flashchip flashchips[];
 #define WINBOND_ID             0xDA    /* Winbond */
 #define W_29C011               0xC1
 #define W_29C020C              0x45
+#define W_29C040P              0x46
+#define W_29EE011              0xC1
 #define W_39V040FA             0x34
 #define W_39V040A              0x3D
 #define W_39V040B              0x54
@@ -164,6 +190,110 @@ int chipset_flash_enable(void);   /* chipset_enable.c */
 
 extern int fd_mem;
 
-int map_flash_registers(struct flashchip *flash); /* flashrom.c */
+/* debug.c */
+extern int verbose;
+#define printf_debug(x...) { if (verbose) printf(x); }
+
+/* flashrom.c */
+int map_flash_registers(struct flashchip *flash);
+
+/* layout.c */
+int show_id(uint8_t *bios, int size);
+int read_romlayout(char *name);
+int find_romentry(char *name);
+int handle_romentries(uint8_t *buffer, uint8_t *content);
+
+/* lbtable.c */
+int linuxbios_init(void);
+extern char *lb_part, *lb_vendor;
+
+/* spi.c */
+int probe_spi(struct flashchip *flash);
+int it87xx_probe_serial_flash(const char *name);
+
+/* 82802ab.c */
+int probe_82802ab(struct flashchip *flash);
+int erase_82802ab(struct flashchip *flash);
+int write_82802ab(struct flashchip *flash, uint8_t *buf);
+
+/* am29f040b.c */
+int probe_29f040b(struct flashchip *flash);
+int erase_29f040b(struct flashchip *flash);
+int write_29f040b(struct flashchip *flash, uint8_t *buf);
+
+/* jedec.c */
+void toggle_ready_jedec(volatile uint8_t *dst);
+void data_polling_jedec(volatile uint8_t *dst, uint8_t data);
+void unprotect_jedec(volatile uint8_t *bios);
+void protect_jedec(volatile uint8_t *bios);
+int write_byte_program_jedec(volatile uint8_t *bios, uint8_t *src,
+                            volatile uint8_t *dst);
+int probe_jedec(struct flashchip *flash);
+int erase_chip_jedec(struct flashchip *flash);
+int write_jedec(struct flashchip *flash, uint8_t *buf);
+int erase_sector_jedec(volatile uint8_t *bios, unsigned int page);
+int erase_block_jedec(volatile uint8_t *bios, unsigned int page);
+int write_sector_jedec(volatile uint8_t *bios, uint8_t *src,
+                      volatile uint8_t *dst, unsigned int page_size);
+
+/* m29f400bt.c */
+int probe_m29f400bt(struct flashchip *flash);
+int erase_m29f400bt(struct flashchip *flash);
+int block_erase_m29f400bt(volatile uint8_t *bios,
+                                volatile uint8_t *dst);
+int write_m29f400bt(struct flashchip *flash, uint8_t *buf);
+int write_linuxbios_m29f400bt(struct flashchip *flash, uint8_t *buf);
+void toggle_ready_m29f400bt(volatile uint8_t *dst);
+void data_polling_m29f400bt(volatile uint8_t *dst, uint8_t data);
+void protect_m29f400bt(volatile uint8_t *bios);
+void write_page_m29f400bt(volatile uint8_t *bios, uint8_t *src,
+                         volatile uint8_t *dst, int page_size);
+
+/* mx29f002.c */
+int probe_29f002(struct flashchip *flash);
+int erase_29f002(struct flashchip *flash);
+int write_29f002(struct flashchip *flash, uint8_t *buf);
+
+/* pm49fl004.c */
+int probe_49fl004(struct flashchip *flash);
+int erase_49fl004(struct flashchip *flash);
+int write_49fl004(struct flashchip *flash, uint8_t *buf);
+
+/* sharplhf00l04.c */
+int probe_lhf00l04(struct flashchip *flash);
+int erase_lhf00l04(struct flashchip *flash);
+int write_lhf00l04(struct flashchip *flash, uint8_t *buf);
+void toggle_ready_lhf00l04(volatile uint8_t *dst);
+void data_polling_lhf00l04(volatile uint8_t *dst, uint8_t data);
+void protect_lhf00l04(volatile uint8_t *bios);
+
+/* sst28sf040.c */
+int probe_28sf040(struct flashchip *flash);
+int erase_28sf040(struct flashchip *flash);
+int write_28sf040(struct flashchip *flash, uint8_t *buf);
+
+/* sst39sf020.c */
+int probe_39sf020(struct flashchip *flash);
+int write_39sf020(struct flashchip *flash, uint8_t *buf);
+
+/* sst49lf040.c */
+int erase_49lf040(struct flashchip *flash);
+int write_49lf040(struct flashchip *flash, uint8_t *buf);
+
+/* sst49lfxxxc.c */
+int probe_49lfxxxc(struct flashchip *flash);
+int erase_49lfxxxc(struct flashchip *flash);
+int write_49lfxxxc(struct flashchip *flash, uint8_t *buf);
+
+/* sst_fwhub.c */
+int probe_sst_fwhub(struct flashchip *flash);
+int erase_sst_fwhub(struct flashchip *flash);
+int write_sst_fwhub(struct flashchip *flash, uint8_t *buf);
+
+/* w29ee011.c */
+int probe_w29ee011(struct flashchip *flash);
+
+/* w49f002u.c */
+int write_49f002(struct flashchip *flash, uint8_t *buf);
 
 #endif                         /* !__FLASH_H__ */