hailfinger | 088dc81 | 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 |
Souvik Ghosh | d75cd67 | 2016-06-17 14:21:39 -0700 | [diff] [blame] | 22 | * struct flashctx as first parameter. |
hailfinger | 088dc81 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 23 | */ |
| 24 | |
| 25 | #ifndef __CHIPDRIVERS_H__ |
| 26 | #define __CHIPDRIVERS_H__ 1 |
| 27 | |
Souvik Ghosh | d75cd67 | 2016-06-17 14:21:39 -0700 | [diff] [blame] | 28 | #include "flash.h" /* for chipaddr and flashctx */ |
David Hendricks | 148a4bf | 2015-03-13 21:02:42 -0700 | [diff] [blame] | 29 | #include "writeprotect.h" /* for generic_modifier_bits */ |
stefanct | 8de303e | 2011-08-16 12:08:22 +0000 | [diff] [blame] | 30 | |
hailfinger | 088dc81 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 31 | /* spi.c, should probably be in spi_chip.c */ |
Souvik Ghosh | d75cd67 | 2016-06-17 14:21:39 -0700 | [diff] [blame] | 32 | int probe_spi_rdid(struct flashctx *flash); |
| 33 | int probe_spi_rdid4(struct flashctx *flash); |
| 34 | int probe_spi_rems(struct flashctx *flash); |
| 35 | int probe_spi_res1(struct flashctx *flash); |
| 36 | int probe_spi_res2(struct flashctx *flash); |
| 37 | int spi_write_enable(struct flashctx *flash); |
| 38 | int spi_write_disable(struct flashctx *flash); |
| 39 | int spi_block_erase_20(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 40 | int spi_block_erase_52(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
Souvik Ghosh | d75cd67 | 2016-06-17 14:21:39 -0700 | [diff] [blame] | 41 | int spi_block_erase_60(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 42 | int spi_block_erase_c7(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
Patrick Georgi | 860875a | 2017-02-03 18:44:55 +0100 | [diff] [blame] | 43 | int spi_block_erase_d7(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 44 | int spi_block_erase_d8(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
Patrick Georgi | ab8353e | 2017-02-03 18:32:01 +0100 | [diff] [blame] | 45 | int spi_chip_write_1(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); |
| 46 | int spi_chip_write_256(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); |
Souvik Ghosh | d75cd67 | 2016-06-17 14:21:39 -0700 | [diff] [blame] | 47 | int spi_chip_read(struct flashctx *flash, uint8_t *buf, unsigned int start, int unsigned len); |
| 48 | uint8_t spi_read_status_register(const struct flashctx *flash); |
| 49 | int spi_write_status_register(const struct flashctx *flash, int status); |
hailfinger | 7533bc8 | 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); |
Souvik Ghosh | d75cd67 | 2016-06-17 14:21:39 -0700 | [diff] [blame] | 53 | int spi_prettyprint_status_register(struct flashctx *flash); |
| 54 | int spi_disable_blockprotect(struct flashctx *flash); |
| 55 | int spi_byte_program(struct flashctx *flash, unsigned int addr, uint8_t databyte); |
Patrick Georgi | ab8353e | 2017-02-03 18:32:01 +0100 | [diff] [blame] | 56 | int spi_nbyte_program(struct flashctx *flash, unsigned int addr, const uint8_t *bytes, unsigned int len); |
Souvik Ghosh | d75cd67 | 2016-06-17 14:21:39 -0700 | [diff] [blame] | 57 | int spi_nbyte_read(struct flashctx *flash, unsigned int addr, uint8_t *bytes, unsigned int len); |
| 58 | int spi_read_chunked(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len, unsigned int chunksize); |
| 59 | int spi_read_unbound(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len, unsigned int chunksize); |
Patrick Georgi | ab8353e | 2017-02-03 18:32:01 +0100 | [diff] [blame] | 60 | int spi_write_chunked(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len, unsigned int chunksize); |
| 61 | int spi_aai_write(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); |
hailfinger | 088dc81 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 62 | |
hailfinger | fe7cd9e | 2011-11-04 21:35:26 +0000 | [diff] [blame] | 63 | /* opaque.c */ |
Souvik Ghosh | d75cd67 | 2016-06-17 14:21:39 -0700 | [diff] [blame] | 64 | int probe_opaque(struct flashctx *flash); |
| 65 | int read_opaque(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len); |
Patrick Georgi | ab8353e | 2017-02-03 18:32:01 +0100 | [diff] [blame] | 66 | int write_opaque(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); |
Souvik Ghosh | d75cd67 | 2016-06-17 14:21:39 -0700 | [diff] [blame] | 67 | int erase_opaque(struct flashctx *flash, unsigned int blockaddr, unsigned int blocklen); |
| 68 | uint8_t read_status_opaque(const struct flashctx *flash); |
| 69 | int write_status_opaque(const struct flashctx *flash, int status); |
hailfinger | fe7cd9e | 2011-11-04 21:35:26 +0000 | [diff] [blame] | 70 | |
hailfinger | 7533bc8 | 2011-05-19 00:06:06 +0000 | [diff] [blame] | 71 | /* a25.c */ |
Souvik Ghosh | d75cd67 | 2016-06-17 14:21:39 -0700 | [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); |
hailfinger | 7533bc8 | 2011-05-19 00:06:06 +0000 | [diff] [blame] | 76 | |
| 77 | /* at25.c */ |
Souvik Ghosh | d75cd67 | 2016-06-17 14:21:39 -0700 | [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); |
hailfinger | 7533bc8 | 2011-05-19 00:06:06 +0000 | [diff] [blame] | 89 | |
hailfinger | 088dc81 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 90 | /* 82802ab.c */ |
Souvik Ghosh | d75cd67 | 2016-06-17 14:21:39 -0700 | [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); |
Patrick Georgi | ab8353e | 2017-02-03 18:32:01 +0100 | [diff] [blame] | 94 | int write_82802ab(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); |
snelson | c0acbeb | 2010-03-19 18:47:06 +0000 | [diff] [blame] | 95 | void print_status_82802ab(uint8_t status); |
Souvik Ghosh | d75cd67 | 2016-06-17 14:21:39 -0700 | [diff] [blame] | 96 | int unlock_82802ab(struct flashctx *flash); |
| 97 | int unlock_28f004s5(struct flashctx *flash); |
| 98 | int unlock_lh28f008bjt(struct flashctx *flash); |
hailfinger | 088dc81 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 99 | |
David Hendricks | 07af3a4 | 2011-07-11 22:13:02 -0700 | [diff] [blame] | 100 | /* ichspi.c */ |
Souvik Ghosh | d75cd67 | 2016-06-17 14:21:39 -0700 | [diff] [blame] | 101 | int ich_hwseq_probe(struct flashctx *flash); |
| 102 | int ich_hwseq_read(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len); |
| 103 | int ich_hwseq_block_erase(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 104 | int ich_hwseq_write_256(struct flashctx *flash, uint8_t *buf, int start, int len); |
David Hendricks | 07af3a4 | 2011-07-11 22:13:02 -0700 | [diff] [blame] | 105 | |
hailfinger | 088dc81 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 106 | /* jedec.c */ |
| 107 | uint8_t oddparity(uint8_t val); |
Souvik Ghosh | d75cd67 | 2016-06-17 14:21:39 -0700 | [diff] [blame] | 108 | void toggle_ready_jedec(struct flashctx *flash, chipaddr dst); |
| 109 | void data_polling_jedec(struct flashctx *flash, chipaddr dst, uint8_t data); |
| 110 | int write_byte_program_jedec(struct flashctx *flash, chipaddr bios, uint8_t *src, |
hailfinger | 088dc81 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 111 | chipaddr dst); |
Souvik Ghosh | d75cd67 | 2016-06-17 14:21:39 -0700 | [diff] [blame] | 112 | int probe_jedec(struct flashctx *flash); |
Patrick Georgi | ab8353e | 2017-02-03 18:32:01 +0100 | [diff] [blame] | 113 | int write_jedec(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); |
| 114 | int write_jedec_1(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); |
Souvik Ghosh | d75cd67 | 2016-06-17 14:21:39 -0700 | [diff] [blame] | 115 | int erase_sector_jedec(struct flashctx *flash, unsigned int page, unsigned int pagesize); |
| 116 | int erase_block_jedec(struct flashctx *flash, unsigned int page, unsigned int blocksize); |
| 117 | int erase_chip_block_jedec(struct flashctx *flash, unsigned int page, unsigned int blocksize); |
hailfinger | 088dc81 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 118 | |
hailfinger | 088dc81 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 119 | /* m29f400bt.c */ |
Souvik Ghosh | d75cd67 | 2016-06-17 14:21:39 -0700 | [diff] [blame] | 120 | int probe_m29f400bt(struct flashctx *flash); |
| 121 | int block_erase_m29f400bt(struct flashctx *flash, unsigned int start, unsigned int len); |
| 122 | int block_erase_chip_m29f400bt(struct flashctx *flash, unsigned int start, unsigned int len); |
Patrick Georgi | ab8353e | 2017-02-03 18:32:01 +0100 | [diff] [blame] | 123 | int write_m29f400bt(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); |
Souvik Ghosh | d75cd67 | 2016-06-17 14:21:39 -0700 | [diff] [blame] | 124 | void protect_m29f400bt(struct flashctx *flash, chipaddr bios); |
hailfinger | 088dc81 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 125 | |
hailfinger | 088dc81 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 126 | /* pm49fl00x.c */ |
Souvik Ghosh | d75cd67 | 2016-06-17 14:21:39 -0700 | [diff] [blame] | 127 | int unlock_49fl00x(struct flashctx *flash); |
| 128 | int lock_49fl00x(struct flashctx *flash); |
hailfinger | 088dc81 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 129 | |
hailfinger | 088dc81 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 130 | /* sst28sf040.c */ |
Souvik Ghosh | d75cd67 | 2016-06-17 14:21:39 -0700 | [diff] [blame] | 131 | int erase_chip_28sf040(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 132 | int erase_sector_28sf040(struct flashctx *flash, unsigned int address, unsigned int sector_size); |
Patrick Georgi | ab8353e | 2017-02-03 18:32:01 +0100 | [diff] [blame] | 133 | int write_28sf040(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); |
Souvik Ghosh | d75cd67 | 2016-06-17 14:21:39 -0700 | [diff] [blame] | 134 | int unprotect_28sf040(struct flashctx *flash); |
| 135 | int protect_28sf040(struct flashctx *flash); |
hailfinger | 088dc81 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 136 | |
hailfinger | 088dc81 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 137 | /* sst49lfxxxc.c */ |
Souvik Ghosh | d75cd67 | 2016-06-17 14:21:39 -0700 | [diff] [blame] | 138 | int erase_sector_49lfxxxc(struct flashctx *flash, unsigned int address, unsigned int sector_size); |
| 139 | int unlock_49lfxxxc(struct flashctx *flash); |
hailfinger | 088dc81 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 140 | |
| 141 | /* sst_fwhub.c */ |
Souvik Ghosh | d75cd67 | 2016-06-17 14:21:39 -0700 | [diff] [blame] | 142 | int printlock_sst_fwhub(struct flashctx *flash); |
| 143 | int unlock_sst_fwhub(struct flashctx *flash); |
hailfinger | 088dc81 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 144 | |
Vadim Bendebury | 3a50116 | 2014-10-21 20:38:13 -0700 | [diff] [blame] | 145 | /* s25fl.c */ |
Souvik Ghosh | d75cd67 | 2016-06-17 14:21:39 -0700 | [diff] [blame] | 146 | int probe_spi_big_spansion(struct flashctx *flash); |
| 147 | int s25fl_block_erase(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
Vadim Bendebury | 3a50116 | 2014-10-21 20:38:13 -0700 | [diff] [blame] | 148 | |
David Hendricks | 148a4bf | 2015-03-13 21:02:42 -0700 | [diff] [blame] | 149 | /* s25f.c */ |
Souvik Ghosh | d75cd67 | 2016-06-17 14:21:39 -0700 | [diff] [blame] | 150 | int s25f_get_modifier_bits(const struct flashctx *flash, struct generic_modifier_bits *m); |
| 151 | int s25f_set_modifier_bits(const struct flashctx *flash, struct generic_modifier_bits *m); |
| 152 | int s25fs_block_erase_d8(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
David Hendricks | 398714f | 2014-07-03 17:49:41 -0700 | [diff] [blame] | 153 | |
hailfinger | f899301 | 2010-12-05 16:33:59 +0000 | [diff] [blame] | 154 | /* w39.c */ |
Souvik Ghosh | d75cd67 | 2016-06-17 14:21:39 -0700 | [diff] [blame] | 155 | int printlock_w39l040(struct flashctx * flash); |
| 156 | int printlock_w39v040a(struct flashctx *flash); |
| 157 | int printlock_w39v040b(struct flashctx *flash); |
| 158 | int printlock_w39v040c(struct flashctx *flash); |
| 159 | int printlock_w39v040fa(struct flashctx *flash); |
| 160 | int printlock_w39v040fb(struct flashctx *flash); |
| 161 | int printlock_w39v040fc(struct flashctx *flash); |
| 162 | int printlock_w39v080a(struct flashctx *flash); |
| 163 | int printlock_w39v080fa(struct flashctx *flash); |
| 164 | int printlock_w39v080fa_dual(struct flashctx *flash); |
| 165 | int unlock_w39v040fb(struct flashctx *flash); |
| 166 | int unlock_w39v080fa(struct flashctx *flash); |
hailfinger | 088dc81 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 167 | |
| 168 | /* w29ee011.c */ |
Souvik Ghosh | d75cd67 | 2016-06-17 14:21:39 -0700 | [diff] [blame] | 169 | int probe_w29ee011(struct flashctx *flash); |
hailfinger | 088dc81 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 170 | |
hailfinger | 088dc81 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 171 | /* stm50flw0x0x.c */ |
Souvik Ghosh | d75cd67 | 2016-06-17 14:21:39 -0700 | [diff] [blame] | 172 | int erase_sector_stm50flw0x0x(struct flashctx *flash, unsigned int block, unsigned int blocksize); |
| 173 | int unlock_stm50flw0x0x(struct flashctx *flash); |
hailfinger | 088dc81 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 174 | |
Louis Yung-Chieh Lo | e53fa0f | 2011-04-11 17:18:41 +0800 | [diff] [blame] | 175 | /* dummyflasher.c */ |
Souvik Ghosh | d75cd67 | 2016-06-17 14:21:39 -0700 | [diff] [blame] | 176 | int probe_variable_size(struct flashctx *flash); |
Louis Yung-Chieh Lo | e53fa0f | 2011-04-11 17:18:41 +0800 | [diff] [blame] | 177 | |
Boris Baykov | 64d00c7 | 2016-06-11 18:28:59 +0200 | [diff] [blame^] | 178 | /* spi4ba.c */ |
| 179 | int spi_enter_4ba_b7(struct flashctx *flash); |
| 180 | int spi_enter_4ba_b7_we(struct flashctx *flash); |
| 181 | int spi_byte_program_4ba(struct flashctx *flash, unsigned int addr, uint8_t databyte); |
| 182 | int spi_nbyte_program_4ba(struct flashctx *flash, unsigned int addr, const uint8_t *bytes, unsigned int len); |
| 183 | int spi_nbyte_read_4ba(struct flashctx *flash, unsigned int addr, uint8_t *bytes, unsigned int len); |
| 184 | int spi_block_erase_20_4ba(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 185 | int spi_block_erase_52_4ba(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 186 | int spi_block_erase_d8_4ba(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 187 | |
hailfinger | 088dc81 | 2009-12-14 03:32:24 +0000 | [diff] [blame] | 188 | #endif /* !__CHIPDRIVERS_H__ */ |