Carl-Daniel Hailfinger | 5d5c072 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the flashrom project. |
| 3 | * |
| 4 | * Copyright (C) 2009 Carl-Daniel Hailfinger |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | * |
| 19 | * |
| 20 | * Header file for flash chip drivers. Included from flash.h. |
| 21 | * As a general rule, every function listed here should take a pointer to |
Carl-Daniel Hailfinger | 63fd902 | 2011-12-14 22:25:15 +0000 | [diff] [blame] | 22 | * struct flashctx as first parameter. |
Carl-Daniel Hailfinger | 5d5c072 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 23 | */ |
| 24 | |
| 25 | #ifndef __CHIPDRIVERS_H__ |
| 26 | #define __CHIPDRIVERS_H__ 1 |
| 27 | |
Carl-Daniel Hailfinger | 63fd902 | 2011-12-14 22:25:15 +0000 | [diff] [blame] | 28 | #include "flash.h" /* for chipaddr and flashctx */ |
Stefan Tauner | a63c7c4 | 2011-08-16 12:08:22 +0000 | [diff] [blame] | 29 | |
Carl-Daniel Hailfinger | 5d5c072 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 30 | /* spi.c, should probably be in spi_chip.c */ |
Carl-Daniel Hailfinger | 63fd902 | 2011-12-14 22:25:15 +0000 | [diff] [blame] | 31 | int probe_spi_rdid(struct flashctx *flash); |
| 32 | int probe_spi_rdid4(struct flashctx *flash); |
| 33 | int probe_spi_rems(struct flashctx *flash); |
| 34 | int probe_spi_res1(struct flashctx *flash); |
| 35 | int probe_spi_res2(struct flashctx *flash); |
Carl-Daniel Hailfinger | 8a3c60c | 2011-12-18 15:01:24 +0000 | [diff] [blame] | 36 | int spi_write_enable(struct flashctx *flash); |
| 37 | int spi_write_disable(struct flashctx *flash); |
Carl-Daniel Hailfinger | 63fd902 | 2011-12-14 22:25:15 +0000 | [diff] [blame] | 38 | int spi_block_erase_20(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 39 | int spi_block_erase_52(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 40 | int spi_block_erase_d7(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 41 | int spi_block_erase_d8(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 42 | int spi_block_erase_60(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 43 | int spi_block_erase_c7(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
Stefan Tauner | ac1b4c8 | 2012-02-17 14:51:04 +0000 | [diff] [blame] | 44 | erasefunc_t *spi_get_erasefn_from_opcode(uint8_t opcode); |
Carl-Daniel Hailfinger | 63fd902 | 2011-12-14 22:25:15 +0000 | [diff] [blame] | 45 | int spi_chip_write_1(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len); |
| 46 | int spi_chip_write_256(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len); |
| 47 | int spi_chip_read(struct flashctx *flash, uint8_t *buf, unsigned int start, int unsigned len); |
Carl-Daniel Hailfinger | 8a3c60c | 2011-12-18 15:01:24 +0000 | [diff] [blame] | 48 | uint8_t spi_read_status_register(struct flashctx *flash); |
Carl-Daniel Hailfinger | 63fd902 | 2011-12-14 22:25:15 +0000 | [diff] [blame] | 49 | int spi_write_status_register(struct flashctx *flash, int status); |
Carl-Daniel Hailfinger | 7a3bd8f | 2011-05-19 00:06:06 +0000 | [diff] [blame] | 50 | void spi_prettyprint_status_register_bit(uint8_t status, int bit); |
| 51 | void spi_prettyprint_status_register_bp3210(uint8_t status, int bp); |
| 52 | void spi_prettyprint_status_register_welwip(uint8_t status); |
Carl-Daniel Hailfinger | 63fd902 | 2011-12-14 22:25:15 +0000 | [diff] [blame] | 53 | int spi_prettyprint_status_register(struct flashctx *flash); |
| 54 | int spi_disable_blockprotect(struct flashctx *flash); |
Carl-Daniel Hailfinger | 8a3c60c | 2011-12-18 15:01:24 +0000 | [diff] [blame] | 55 | int spi_byte_program(struct flashctx *flash, unsigned int addr, uint8_t databyte); |
| 56 | int spi_nbyte_program(struct flashctx *flash, unsigned int addr, uint8_t *bytes, unsigned int len); |
| 57 | int spi_nbyte_read(struct flashctx *flash, unsigned int addr, uint8_t *bytes, unsigned int len); |
Carl-Daniel Hailfinger | 63fd902 | 2011-12-14 22:25:15 +0000 | [diff] [blame] | 58 | int spi_read_chunked(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len, unsigned int chunksize); |
| 59 | int spi_write_chunked(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len, unsigned int chunksize); |
| 60 | int spi_aai_write(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len); |
Carl-Daniel Hailfinger | 5d5c072 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 61 | |
Stefan Tauner | ac1b4c8 | 2012-02-17 14:51:04 +0000 | [diff] [blame] | 62 | /* sfdp.c */ |
| 63 | int probe_spi_sfdp(struct flashctx *flash); |
| 64 | |
Carl-Daniel Hailfinger | 532c717 | 2011-11-04 21:35:26 +0000 | [diff] [blame] | 65 | /* opaque.c */ |
Carl-Daniel Hailfinger | 63fd902 | 2011-12-14 22:25:15 +0000 | [diff] [blame] | 66 | int probe_opaque(struct flashctx *flash); |
| 67 | int read_opaque(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len); |
| 68 | int write_opaque(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len); |
| 69 | int erase_opaque(struct flashctx *flash, unsigned int blockaddr, unsigned int blocklen); |
Carl-Daniel Hailfinger | 532c717 | 2011-11-04 21:35:26 +0000 | [diff] [blame] | 70 | |
Carl-Daniel Hailfinger | 7a3bd8f | 2011-05-19 00:06:06 +0000 | [diff] [blame] | 71 | /* a25.c */ |
Carl-Daniel Hailfinger | 63fd902 | 2011-12-14 22:25:15 +0000 | [diff] [blame] | 72 | int spi_prettyprint_status_register_amic_a25l05p(struct flashctx *flash); |
| 73 | int spi_prettyprint_status_register_amic_a25l40p(struct flashctx *flash); |
| 74 | int spi_prettyprint_status_register_amic_a25l032(struct flashctx *flash); |
| 75 | int spi_prettyprint_status_register_amic_a25lq032(struct flashctx *flash); |
Carl-Daniel Hailfinger | 7a3bd8f | 2011-05-19 00:06:06 +0000 | [diff] [blame] | 76 | |
| 77 | /* at25.c */ |
Carl-Daniel Hailfinger | 63fd902 | 2011-12-14 22:25:15 +0000 | [diff] [blame] | 78 | int spi_prettyprint_status_register_at25df(struct flashctx *flash); |
| 79 | int spi_prettyprint_status_register_at25df_sec(struct flashctx *flash); |
| 80 | int spi_prettyprint_status_register_at25f(struct flashctx *flash); |
| 81 | int spi_prettyprint_status_register_at25fs010(struct flashctx *flash); |
| 82 | int spi_prettyprint_status_register_at25fs040(struct flashctx *flash); |
| 83 | int spi_prettyprint_status_register_atmel_at26df081a(struct flashctx *flash); |
| 84 | int spi_disable_blockprotect_at25df(struct flashctx *flash); |
| 85 | int spi_disable_blockprotect_at25df_sec(struct flashctx *flash); |
| 86 | int spi_disable_blockprotect_at25f(struct flashctx *flash); |
| 87 | int spi_disable_blockprotect_at25fs010(struct flashctx *flash); |
| 88 | int spi_disable_blockprotect_at25fs040(struct flashctx *flash); |
Carl-Daniel Hailfinger | 7a3bd8f | 2011-05-19 00:06:06 +0000 | [diff] [blame] | 89 | |
Carl-Daniel Hailfinger | 5d5c072 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 90 | /* 82802ab.c */ |
Carl-Daniel Hailfinger | 63fd902 | 2011-12-14 22:25:15 +0000 | [diff] [blame] | 91 | uint8_t wait_82802ab(struct flashctx *flash); |
| 92 | int probe_82802ab(struct flashctx *flash); |
| 93 | int erase_block_82802ab(struct flashctx *flash, unsigned int page, unsigned int pagesize); |
| 94 | int write_82802ab(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len); |
Sean Nelson | 28accc2 | 2010-03-19 18:47:06 +0000 | [diff] [blame] | 95 | void print_status_82802ab(uint8_t status); |
Carl-Daniel Hailfinger | 63fd902 | 2011-12-14 22:25:15 +0000 | [diff] [blame] | 96 | int unlock_82802ab(struct flashctx *flash); |
| 97 | int unlock_28f004s5(struct flashctx *flash); |
| 98 | int unlock_lh28f008bjt(struct flashctx *flash); |
Carl-Daniel Hailfinger | 5d5c072 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 99 | |
Carl-Daniel Hailfinger | 5d5c072 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 100 | /* jedec.c */ |
| 101 | uint8_t oddparity(uint8_t val); |
Carl-Daniel Hailfinger | 8a3c60c | 2011-12-18 15:01:24 +0000 | [diff] [blame] | 102 | void toggle_ready_jedec(struct flashctx *flash, chipaddr dst); |
| 103 | void data_polling_jedec(struct flashctx *flash, chipaddr dst, uint8_t data); |
| 104 | int write_byte_program_jedec(struct flashctx *flash, chipaddr bios, uint8_t *src, |
Carl-Daniel Hailfinger | 5d5c072 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 105 | chipaddr dst); |
Carl-Daniel Hailfinger | 63fd902 | 2011-12-14 22:25:15 +0000 | [diff] [blame] | 106 | int probe_jedec(struct flashctx *flash); |
| 107 | int write_jedec(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len); |
| 108 | int write_jedec_1(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len); |
| 109 | int erase_sector_jedec(struct flashctx *flash, unsigned int page, unsigned int pagesize); |
| 110 | int erase_block_jedec(struct flashctx *flash, unsigned int page, unsigned int blocksize); |
| 111 | int erase_chip_block_jedec(struct flashctx *flash, unsigned int page, unsigned int blocksize); |
Carl-Daniel Hailfinger | 5d5c072 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 112 | |
Carl-Daniel Hailfinger | 5d5c072 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 113 | /* m29f400bt.c */ |
Carl-Daniel Hailfinger | 63fd902 | 2011-12-14 22:25:15 +0000 | [diff] [blame] | 114 | int probe_m29f400bt(struct flashctx *flash); |
| 115 | int block_erase_m29f400bt(struct flashctx *flash, unsigned int start, unsigned int len); |
| 116 | int block_erase_chip_m29f400bt(struct flashctx *flash, unsigned int start, unsigned int len); |
| 117 | int write_m29f400bt(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len); |
Carl-Daniel Hailfinger | 8a3c60c | 2011-12-18 15:01:24 +0000 | [diff] [blame] | 118 | void protect_m29f400bt(struct flashctx *flash, chipaddr bios); |
Carl-Daniel Hailfinger | 5d5c072 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 119 | |
Carl-Daniel Hailfinger | 5d5c072 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 120 | /* pm49fl00x.c */ |
Carl-Daniel Hailfinger | 63fd902 | 2011-12-14 22:25:15 +0000 | [diff] [blame] | 121 | int unlock_49fl00x(struct flashctx *flash); |
| 122 | int lock_49fl00x(struct flashctx *flash); |
Carl-Daniel Hailfinger | 5d5c072 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 123 | |
Carl-Daniel Hailfinger | 5d5c072 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 124 | /* sst28sf040.c */ |
Carl-Daniel Hailfinger | 63fd902 | 2011-12-14 22:25:15 +0000 | [diff] [blame] | 125 | int erase_chip_28sf040(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 126 | int erase_sector_28sf040(struct flashctx *flash, unsigned int address, unsigned int sector_size); |
| 127 | int write_28sf040(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len); |
| 128 | int unprotect_28sf040(struct flashctx *flash); |
| 129 | int protect_28sf040(struct flashctx *flash); |
Carl-Daniel Hailfinger | 5d5c072 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 130 | |
Carl-Daniel Hailfinger | 5d5c072 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 131 | /* sst49lfxxxc.c */ |
Carl-Daniel Hailfinger | 63fd902 | 2011-12-14 22:25:15 +0000 | [diff] [blame] | 132 | int erase_sector_49lfxxxc(struct flashctx *flash, unsigned int address, unsigned int sector_size); |
| 133 | int unlock_49lfxxxc(struct flashctx *flash); |
Carl-Daniel Hailfinger | 5d5c072 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 134 | |
| 135 | /* sst_fwhub.c */ |
Carl-Daniel Hailfinger | 63fd902 | 2011-12-14 22:25:15 +0000 | [diff] [blame] | 136 | int printlock_sst_fwhub(struct flashctx *flash); |
| 137 | int unlock_sst_fwhub(struct flashctx *flash); |
Carl-Daniel Hailfinger | 5d5c072 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 138 | |
Carl-Daniel Hailfinger | 9188240 | 2010-12-05 16:33:59 +0000 | [diff] [blame] | 139 | /* w39.c */ |
Carl-Daniel Hailfinger | 63fd902 | 2011-12-14 22:25:15 +0000 | [diff] [blame] | 140 | int printlock_w39l040(struct flashctx * flash); |
| 141 | int printlock_w39v040a(struct flashctx *flash); |
| 142 | int printlock_w39v040b(struct flashctx *flash); |
| 143 | int printlock_w39v040c(struct flashctx *flash); |
| 144 | int printlock_w39v040fa(struct flashctx *flash); |
| 145 | int printlock_w39v040fb(struct flashctx *flash); |
| 146 | int printlock_w39v040fc(struct flashctx *flash); |
| 147 | int printlock_w39v080a(struct flashctx *flash); |
| 148 | int printlock_w39v080fa(struct flashctx *flash); |
| 149 | int printlock_w39v080fa_dual(struct flashctx *flash); |
| 150 | int unlock_w39v040fb(struct flashctx *flash); |
| 151 | int unlock_w39v080fa(struct flashctx *flash); |
David Borg | f5a30f6 | 2012-04-15 13:16:32 +0000 | [diff] [blame] | 152 | int printlock_at49f(struct flashctx *flash); |
Carl-Daniel Hailfinger | 5d5c072 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 153 | |
| 154 | /* w29ee011.c */ |
Carl-Daniel Hailfinger | 63fd902 | 2011-12-14 22:25:15 +0000 | [diff] [blame] | 155 | int probe_w29ee011(struct flashctx *flash); |
Carl-Daniel Hailfinger | 5d5c072 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 156 | |
Carl-Daniel Hailfinger | 5d5c072 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 157 | /* stm50flw0x0x.c */ |
Carl-Daniel Hailfinger | 63fd902 | 2011-12-14 22:25:15 +0000 | [diff] [blame] | 158 | int erase_sector_stm50flw0x0x(struct flashctx *flash, unsigned int block, unsigned int blocksize); |
| 159 | int unlock_stm50flw0x0x(struct flashctx *flash); |
Carl-Daniel Hailfinger | 5d5c072 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 160 | |
Rudolf Marek | 47eff6b | 2012-04-14 22:51:40 +0000 | [diff] [blame] | 161 | /* en29lv640b.c */ |
| 162 | int probe_en29lv640b(struct flashctx *flash); |
| 163 | int block_erase_en29lv640b(struct flashctx *flash, unsigned int start, unsigned int len); |
| 164 | int block_erase_chip_en29lv640b(struct flashctx *flash, unsigned int start, unsigned int len); |
| 165 | int write_en29lv640b(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len); |
| 166 | |
Carl-Daniel Hailfinger | 5d5c072 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 167 | #endif /* !__CHIPDRIVERS_H__ */ |