Activate proper support for EN29F002(A)(N)[BT].
[coreboot.git] / util / flashrom / flash.h
index 5d7b64508c38742aac08d487250e918a66239b0d..1dcdbfbdb54309d817ac662e06a2ef67d4d67c49 100644 (file)
 #include <stdint.h>
 #include <stdio.h>
 
+#ifdef __FreeBSD__
+  #include <machine/cpufunc.h>
+  #define off64_t off_t
+  #define lseek64 lseek
+  #define OUTB(x, y) do { u_int tmp = (y); outb(tmp, (x)); } while (0)
+  #define OUTW(x, y) do { u_int tmp = (y); outw(tmp, (x)); } while (0)
+  #define OUTL(x, y) do { u_int tmp = (y); outl(tmp, (x)); } while (0)
+  #define INB(x) __extension__ ({ u_int tmp = (x); inb(tmp); })
+  #define INW(x) __extension__ ({ u_int tmp = (x); inw(tmp); })
+  #define INL(x) __extension__ ({ u_int tmp = (x); inl(tmp); })
+#else
+  #define OUTB outb
+  #define OUTW outw
+  #define OUTL outl
+  #define INB  inb
+  #define INW  inw
+  #define INL  inl
+#endif
+
 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
 
 struct flashchip {
@@ -66,6 +85,7 @@ struct flashchip {
 #define TEST_OK_READ   (1<<1)
 #define TEST_OK_ERASE  (1<<2)
 #define TEST_OK_WRITE  (1<<3)
+#define TEST_OK_PR     (TEST_OK_PROBE|TEST_OK_READ)
 #define TEST_OK_PREW   (TEST_OK_PROBE|TEST_OK_READ|TEST_OK_ERASE|TEST_OK_WRITE)
 #define TEST_OK_MASK   0x0f
 
@@ -98,6 +118,11 @@ extern struct flashchip flashchips[];
 
 #define AMIC_ID                        0x7F37  /* AMIC */
 #define AMIC_ID_NOPREFIX       0x37    /* AMIC */
+#define AMIC_A25L40P           0x2013
+#define AMIC_A29002B           0x0d
+#define AMIC_A29002T           0x8c
+#define AMIC_A29040B           0x86
+#define AMIC_A49LF040A         0x9d
 
 #define ASD_ID                 0x25    /* ASD, not listed in JEP106W */
 #define ASD_AE49F2008          0x52
@@ -169,11 +194,6 @@ extern struct flashchip flashchips[];
 
 #define ISSI_ID                        0xD5    /* ISSI Integrated Silicon Solutions */
 
-#define MSYSTEMS_ID            0x156F  /* M-Systems, not listed in JEP106W */
-#define MSYSTEMS_MD2200                0xDB
-#define MSYSTEMS_MD2800                0x30    /* hmm -- both 0x30 */
-#define MSYSTEMS_MD2802                0x30    /* hmm -- both 0x30 */
-
 /*
  * MX25 chips are SPI, first byte of device ID is memory type,
  * second byte of device ID is log(bitsize)-9.
@@ -237,8 +257,21 @@ extern struct flashchip flashchips[];
 #define SST_25VF032B           0x254A
 #define SST_25VF040B           0x258D
 #define SST_25VF080B           0x258E
-#define SST_29EE020A           0x10
+#define SST_27SF512            0xA4
+#define SST_27SF010            0xA5
+#define SST_27SF020            0xA6
+#define SST_27VF010            0xA9
+#define SST_27VF020            0xAA
 #define SST_28SF040            0x04
+#define SST_29EE512            0x5D
+#define SST_29EE010            0x07
+#define SST_29LE010            0x08    /* also SST29VE010 */
+#define SST_29EE020A           0x10
+#define SST_29LE020            0x12    /* also SST29VE020 */
+#define SST_29SF020            0x24
+#define SST_29VF020            0x25
+#define SST_29SF040            0x13
+#define SST_29VF040            0x14
 #define SST_39SF010            0xB5
 #define SST_39SF020            0xB6
 #define SST_39SF040            0xB7
@@ -339,8 +372,17 @@ void print_supported_boards(void);
 /* chipset_enable.c */
 int chipset_flash_enable(void);
 void print_supported_chipsets(void);
-extern int ich9_detected;
-extern void *ich_spibar;
+
+typedef enum {
+       BUS_TYPE_LPC,
+       BUS_TYPE_ICH7_SPI,
+       BUS_TYPE_ICH9_SPI,
+       BUS_TYPE_IT87XX_SPI,
+       BUS_TYPE_VIA_SPI
+} flashbus_t;
+
+extern flashbus_t flashbus;
+extern void *spibar;
 
 /* Physical memory mapping device */
 #if defined (__sun) && (defined(__i386) || defined(__amd64))
@@ -359,7 +401,7 @@ extern int verbose;
 int map_flash_registers(struct flashchip *flash);
 
 /* layout.c */
-int show_id(uint8_t *bios, int size);
+int show_id(uint8_t *bios, int size, int force);
 int read_romlayout(char *name);
 int find_romentry(char *name);
 int handle_romentries(uint8_t *buffer, uint8_t *content);
@@ -370,8 +412,8 @@ extern char *lb_part, *lb_vendor;
 
 /* spi.c */
 int probe_spi_rdid(struct flashchip *flash);
+int probe_spi_rdid4(struct flashchip *flash);
 int probe_spi_res(struct flashchip *flash);
-int it87xx_probe_spi_flash(const char *name);
 int spi_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr);
 void spi_write_enable();
 void spi_write_disable();
@@ -381,7 +423,6 @@ int spi_chip_read(struct flashchip *flash, uint8_t *buf);
 uint8_t spi_read_status_register();
 void spi_disable_blockprotect(void);
 void spi_byte_program(int address, uint8_t byte);
-void spi_page_program(int block, uint8_t *buf, uint8_t *bios);
 void spi_nbyte_read(int address, uint8_t *bytes, int len);
 
 /* 82802ab.c */
@@ -394,12 +435,22 @@ int probe_29f040b(struct flashchip *flash);
 int erase_29f040b(struct flashchip *flash);
 int write_29f040b(struct flashchip *flash, uint8_t *buf);
 
+/* en29f002a.c */
+int probe_en29f002a(struct flashchip *flash);
+int erase_en29f002a(struct flashchip *flash);
+int write_en29f002a(struct flashchip *flash, uint8_t *buf);
+
+/* ichspi.c */
+int ich_spi_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr);
+int ich_spi_read(struct flashchip *flash, uint8_t * buf);
+int ich_spi_write(struct flashchip *flash, uint8_t * buf);
+
 /* it87spi.c */
 extern uint16_t it8716f_flashport;
+int it87xx_probe_spi_flash(const char *name);
 int it8716f_spi_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr);
 int it8716f_spi_chip_read(struct flashchip *flash, uint8_t *buf);
 int it8716f_spi_chip_write(struct flashchip *flash, uint8_t *buf);
-void it8716f_spi_page_program(int block, uint8_t *buf, uint8_t *bios);
 
 /* jedec.c */
 uint8_t oddparity(uint8_t val);
@@ -435,10 +486,10 @@ 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);
+/* pm49fl00x.c */
+int probe_49fl00x(struct flashchip *flash);
+int erase_49fl00x(struct flashchip *flash);
+int write_49fl00x(struct flashchip *flash, uint8_t *buf);
 
 /* sharplhf00l04.c */
 int probe_lhf00l04(struct flashchip *flash);
@@ -471,6 +522,11 @@ int probe_sst_fwhub(struct flashchip *flash);
 int erase_sst_fwhub(struct flashchip *flash);
 int write_sst_fwhub(struct flashchip *flash, uint8_t *buf);
 
+/* w39v040c.c */
+int probe_w39v040c(struct flashchip *flash);
+int erase_w39v040c(struct flashchip *flash);
+int write_w39v040c(struct flashchip *flash, uint8_t *buf);
+
 /* w39V080fa.c */
 int probe_winbond_fwhub(struct flashchip *flash);
 int erase_winbond_fwhub(struct flashchip *flash);
@@ -486,4 +542,5 @@ int write_49f002(struct flashchip *flash, uint8_t *buf);
 int probe_stm50flw0x0x(struct flashchip *flash);
 int erase_stm50flw0x0x(struct flashchip *flash);
 int write_stm50flw0x0x(struct flashchip *flash, uint8_t *buf);
+
 #endif                         /* !__FLASH_H__ */