blob: 12fc5a325a2e9f48a2d44d5dc6a4a748b47bf6d0 [file] [log] [blame]
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +00001/*
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 Hailfinger63fd9022011-12-14 22:25:15 +000022 * struct flashctx as first parameter.
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +000023 */
24
25#ifndef __CHIPDRIVERS_H__
26#define __CHIPDRIVERS_H__ 1
27
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +000028#include "flash.h" /* for chipaddr and flashctx */
Stefan Taunera63c7c42011-08-16 12:08:22 +000029
Stefan Taunereb582572012-09-21 12:52:50 +000030/* spi.c */
Mark Marshallf20b7be2014-05-09 21:16:21 +000031int spi_aai_write(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
32int spi_chip_write_256(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
Stefan Taunereb582572012-09-21 12:52:50 +000033int spi_chip_read(struct flashctx *flash, uint8_t *buf, unsigned int start, int unsigned len);
34
35/* spi25.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +000036int probe_spi_rdid(struct flashctx *flash);
37int probe_spi_rdid4(struct flashctx *flash);
38int probe_spi_rems(struct flashctx *flash);
39int probe_spi_res1(struct flashctx *flash);
40int probe_spi_res2(struct flashctx *flash);
Stefan Tauner3f5e35d2013-04-19 01:58:33 +000041int probe_spi_res3(struct flashctx *flash);
Stefan Tauner57794ac2012-12-29 15:04:20 +000042int probe_spi_at25f(struct flashctx *flash);
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +000043int spi_write_enable(struct flashctx *flash);
44int spi_write_disable(struct flashctx *flash);
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +000045int spi_block_erase_20(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
Stefan Tauner94b39b42012-10-27 00:06:02 +000046int spi_block_erase_50(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +000047int spi_block_erase_52(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +000048int spi_block_erase_60(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
Stefan Tauner3c0fcd02012-09-21 12:46:56 +000049int spi_block_erase_62(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
Stefan Tauner730e7e72013-05-01 14:04:19 +000050int spi_block_erase_81(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
Nikolay Nikolaev6f59b0b2013-06-28 21:29:51 +000051int spi_block_erase_c4(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +000052int spi_block_erase_c7(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
Stefan Tauner730e7e72013-05-01 14:04:19 +000053int spi_block_erase_d7(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
54int spi_block_erase_d8(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
Nikolay Nikolaev579f1e02013-06-28 21:28:37 +000055int spi_block_erase_db(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
Stefan Taunerac1b4c82012-02-17 14:51:04 +000056erasefunc_t *spi_get_erasefn_from_opcode(uint8_t opcode);
Mark Marshallf20b7be2014-05-09 21:16:21 +000057int spi_chip_write_1(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +000058int spi_nbyte_read(struct flashctx *flash, unsigned int addr, uint8_t *bytes, unsigned int len);
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +000059int spi_read_chunked(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len, unsigned int chunksize);
Mark Marshallf20b7be2014-05-09 21:16:21 +000060int spi_write_chunked(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len, unsigned int chunksize);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +000061
Stefan Tauner6ee37e22012-12-29 15:03:51 +000062/* spi25_statusreg.c */
63uint8_t spi_read_status_register(struct flashctx *flash);
64int spi_write_status_register(struct flashctx *flash, int status);
Aidan Thorntondb4e87d2013-08-27 18:01:53 +000065void spi_prettyprint_status_register_bit(uint8_t status, int bit);
Stefan Tauner6ee37e22012-12-29 15:03:51 +000066int spi_prettyprint_status_register_plain(struct flashctx *flash);
Stefan Tauner278ba6e2013-06-28 21:28:27 +000067int spi_prettyprint_status_register_default_welwip(struct flashctx *flash);
Stefan Tauner12f3d512014-05-27 21:27:27 +000068int spi_prettyprint_status_register_bp1_srwd(struct flashctx *flash);
69int spi_prettyprint_status_register_bp2_srwd(struct flashctx *flash);
70int spi_prettyprint_status_register_bp3_srwd(struct flashctx *flash);
71int spi_prettyprint_status_register_bp4_srwd(struct flashctx *flash);
Stefan Tauner85f09f72014-05-27 21:27:14 +000072int spi_prettyprint_status_register_bp2_bpl(struct flashctx *flash);
Ben Gardnerbcf61092015-11-22 02:23:31 +000073int spi_prettyprint_status_register_bp2_tb_bpl(struct flashctx *flash);
Stefan Tauner6ee37e22012-12-29 15:03:51 +000074int spi_disable_blockprotect(struct flashctx *flash);
Stefan Taunera60d4082014-06-04 16:17:03 +000075int spi_disable_blockprotect_bp1_srwd(struct flashctx *flash);
Stefan Tauner278ba6e2013-06-28 21:28:27 +000076int spi_disable_blockprotect_bp2_srwd(struct flashctx *flash);
77int spi_disable_blockprotect_bp3_srwd(struct flashctx *flash);
78int spi_disable_blockprotect_bp4_srwd(struct flashctx *flash);
Stefan Tauner6ee37e22012-12-29 15:03:51 +000079int spi_prettyprint_status_register_amic_a25l032(struct flashctx *flash);
80int spi_prettyprint_status_register_at25df(struct flashctx *flash);
81int spi_prettyprint_status_register_at25df_sec(struct flashctx *flash);
Stefan Tauner57794ac2012-12-29 15:04:20 +000082int spi_prettyprint_status_register_at25f(struct flashctx *flash);
83int spi_prettyprint_status_register_at25f512a(struct flashctx *flash);
Stefan Tauner6ee37e22012-12-29 15:03:51 +000084int spi_prettyprint_status_register_at25f512b(struct flashctx *flash);
Stefan Tauner57794ac2012-12-29 15:04:20 +000085int spi_prettyprint_status_register_at25f4096(struct flashctx *flash);
Stefan Tauner6ee37e22012-12-29 15:03:51 +000086int spi_prettyprint_status_register_at25fs010(struct flashctx *flash);
87int spi_prettyprint_status_register_at25fs040(struct flashctx *flash);
88int spi_prettyprint_status_register_at26df081a(struct flashctx *flash);
Stefan Taunercecb2c52013-06-20 22:55:41 +000089int spi_disable_blockprotect_at2x_global_unprotect(struct flashctx *flash);
90int spi_disable_blockprotect_at2x_global_unprotect_sec(struct flashctx *flash);
Stefan Tauner57794ac2012-12-29 15:04:20 +000091int spi_disable_blockprotect_at25f(struct flashctx *flash);
92int spi_disable_blockprotect_at25f512a(struct flashctx *flash);
Stefan Tauner6ee37e22012-12-29 15:03:51 +000093int spi_disable_blockprotect_at25f512b(struct flashctx *flash);
94int spi_disable_blockprotect_at25fs010(struct flashctx *flash);
95int spi_disable_blockprotect_at25fs040(struct flashctx *flash);
Nikolay Nikolaevd0e3ea12013-06-28 21:29:08 +000096int spi_prettyprint_status_register_en25s_wp(struct flashctx *flash);
Nikolay Nikolaev6f59b0b2013-06-28 21:29:51 +000097int spi_prettyprint_status_register_n25q(struct flashctx *flash);
98int spi_disable_blockprotect_n25q(struct flashctx *flash);
Nikolay Nikolaevc80c4a32013-06-28 21:29:44 +000099int spi_prettyprint_status_register_bp2_ep_srwd(struct flashctx *flash);
100int spi_disable_blockprotect_bp2_ep_srwd(struct flashctx *flash);
Stefan Tauner6ee37e22012-12-29 15:03:51 +0000101int spi_prettyprint_status_register_sst25(struct flashctx *flash);
102int spi_prettyprint_status_register_sst25vf016(struct flashctx *flash);
103int spi_prettyprint_status_register_sst25vf040b(struct flashctx *flash);
104
Stefan Taunerac1b4c82012-02-17 14:51:04 +0000105/* sfdp.c */
106int probe_spi_sfdp(struct flashctx *flash);
107
Carl-Daniel Hailfinger532c7172011-11-04 21:35:26 +0000108/* opaque.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000109int probe_opaque(struct flashctx *flash);
110int read_opaque(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
Mark Marshallf20b7be2014-05-09 21:16:21 +0000111int write_opaque(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000112int erase_opaque(struct flashctx *flash, unsigned int blockaddr, unsigned int blocklen);
Carl-Daniel Hailfinger532c7172011-11-04 21:35:26 +0000113
Aidan Thorntondb4e87d2013-08-27 18:01:53 +0000114/* at45db.c */
115int probe_spi_at45db(struct flashctx *flash);
116int spi_prettyprint_status_register_at45db(struct flashctx *flash);
117int spi_disable_blockprotect_at45db(struct flashctx *flash);
118int spi_read_at45db(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
Stefan Taunerfdc4f7e2013-08-27 18:02:12 +0000119int spi_read_at45db_e8(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
Mark Marshallf20b7be2014-05-09 21:16:21 +0000120int spi_write_at45db(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
Aidan Thorntondb4e87d2013-08-27 18:01:53 +0000121int spi_erase_at45db_page(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
122int spi_erase_at45db_block(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
123int spi_erase_at45db_sector(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
124int spi_erase_at45db_chip(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
Stefan Tauner1dd5d3a2013-08-27 18:02:19 +0000125int spi_erase_at45cs_sector(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
Aidan Thorntondb4e87d2013-08-27 18:01:53 +0000126
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000127/* 82802ab.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000128uint8_t wait_82802ab(struct flashctx *flash);
129int probe_82802ab(struct flashctx *flash);
130int erase_block_82802ab(struct flashctx *flash, unsigned int page, unsigned int pagesize);
Mark Marshallf20b7be2014-05-09 21:16:21 +0000131int write_82802ab(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
Sean Nelson28accc22010-03-19 18:47:06 +0000132void print_status_82802ab(uint8_t status);
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000133int unlock_28f004s5(struct flashctx *flash);
134int unlock_lh28f008bjt(struct flashctx *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000135
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000136/* jedec.c */
137uint8_t oddparity(uint8_t val);
Stefan Tauner0ab1e5d2014-05-29 11:51:24 +0000138void toggle_ready_jedec(const struct flashctx *flash, chipaddr dst);
139void data_polling_jedec(const struct flashctx *flash, chipaddr dst, uint8_t data);
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000140int probe_jedec(struct flashctx *flash);
Stefan Tauner03a9c3c2014-08-03 14:15:14 +0000141int probe_jedec_29gl(struct flashctx *flash);
Mark Marshallf20b7be2014-05-09 21:16:21 +0000142int write_jedec(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
143int write_jedec_1(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000144int erase_sector_jedec(struct flashctx *flash, unsigned int page, unsigned int pagesize);
145int erase_block_jedec(struct flashctx *flash, unsigned int page, unsigned int blocksize);
146int erase_chip_block_jedec(struct flashctx *flash, unsigned int page, unsigned int blocksize);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000147
Carl-Daniel Hailfingeref3ac8a2014-08-03 13:05:34 +0000148int unlock_regspace2_uniform_32k(struct flashctx *flash);
149int unlock_regspace2_uniform_64k(struct flashctx *flash);
150int unlock_regspace2_block_eraser_0(struct flashctx *flash);
151int unlock_regspace2_block_eraser_1(struct flashctx *flash);
Carl-Daniel Hailfingeref3ac8a2014-08-03 13:05:34 +0000152int printlock_regspace2_uniform_64k(struct flashctx *flash);
153int printlock_regspace2_block_eraser_0(struct flashctx *flash);
154int printlock_regspace2_block_eraser_1(struct flashctx *flash);
155
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000156/* sst28sf040.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000157int erase_chip_28sf040(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
158int erase_sector_28sf040(struct flashctx *flash, unsigned int address, unsigned int sector_size);
Mark Marshallf20b7be2014-05-09 21:16:21 +0000159int write_28sf040(struct flashctx *flash, const uint8_t *buf,unsigned int start, unsigned int len);
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000160int unprotect_28sf040(struct flashctx *flash);
161int protect_28sf040(struct flashctx *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000162
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000163/* sst49lfxxxc.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000164int erase_sector_49lfxxxc(struct flashctx *flash, unsigned int address, unsigned int sector_size);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000165
166/* sst_fwhub.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000167int printlock_sst_fwhub(struct flashctx *flash);
168int unlock_sst_fwhub(struct flashctx *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000169
Carl-Daniel Hailfinger91882402010-12-05 16:33:59 +0000170/* w39.c */
Kyösti Mälkkic31243e2012-10-28 01:50:08 +0000171int printlock_w39f010(struct flashctx * flash);
172int printlock_w39l010(struct flashctx * flash);
173int printlock_w39l020(struct flashctx * flash);
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000174int printlock_w39l040(struct flashctx * flash);
175int printlock_w39v040a(struct flashctx *flash);
176int printlock_w39v040b(struct flashctx *flash);
177int printlock_w39v040c(struct flashctx *flash);
178int printlock_w39v040fa(struct flashctx *flash);
179int printlock_w39v040fb(struct flashctx *flash);
180int printlock_w39v040fc(struct flashctx *flash);
181int printlock_w39v080a(struct flashctx *flash);
182int printlock_w39v080fa(struct flashctx *flash);
183int printlock_w39v080fa_dual(struct flashctx *flash);
David Borgf5a30f62012-04-15 13:16:32 +0000184int printlock_at49f(struct flashctx *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000185
186/* w29ee011.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000187int probe_w29ee011(struct flashctx *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000188
Stefan Tauner4404f732013-09-12 08:28:56 +0000189/* stm50.c */
190int erase_sector_stm50(struct flashctx *flash, unsigned int block, unsigned int blocksize);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000191
Rudolf Marek47eff6b2012-04-14 22:51:40 +0000192/* en29lv640b.c */
193int probe_en29lv640b(struct flashctx *flash);
Mark Marshallf20b7be2014-05-09 21:16:21 +0000194int write_en29lv640b(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
Rudolf Marek47eff6b2012-04-14 22:51:40 +0000195
Boris Baykov50a56602016-06-11 18:28:59 +0200196/* spi4ba.c */
197int spi_enter_4ba_b7(struct flashctx *flash);
198int spi_enter_4ba_b7_we(struct flashctx *flash);
Ed Swierkd94d2542017-07-03 13:02:18 -0700199int spi_exit_4ba_e9(struct flashctx *flash);
200int spi_exit_4ba_e9_we(struct flashctx *flash);
Boris Baykov50a56602016-06-11 18:28:59 +0200201int spi_byte_program_4ba(struct flashctx *flash, unsigned int addr, uint8_t databyte);
202int spi_nbyte_program_4ba(struct flashctx *flash, unsigned int addr, const uint8_t *bytes, unsigned int len);
203int spi_nbyte_read_4ba(struct flashctx *flash, unsigned int addr, uint8_t *bytes, unsigned int len);
204int spi_block_erase_20_4ba(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
205int spi_block_erase_52_4ba(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
206int spi_block_erase_d8_4ba(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
Boris Baykov5de3b9b2016-06-11 18:29:02 +0200207int spi_byte_program_4ba_ereg(struct flashctx *flash, unsigned int addr, uint8_t databyte);
208int spi_nbyte_program_4ba_ereg(struct flashctx *flash, unsigned int addr, const uint8_t *bytes, unsigned int len);
209int spi_nbyte_read_4ba_ereg(struct flashctx *flash, unsigned int addr, uint8_t *bytes, unsigned int len);
210int spi_block_erase_20_4ba_ereg(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
211int spi_block_erase_52_4ba_ereg(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
212int spi_block_erase_d8_4ba_ereg(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
Boris Baykov7fe85692016-06-11 18:29:03 +0200213int spi_byte_program_4ba_direct(struct flashctx *flash, unsigned int addr, uint8_t databyte);
214int spi_nbyte_program_4ba_direct(struct flashctx *flash, unsigned int addr, const uint8_t *bytes, unsigned int len);
215int spi_nbyte_read_4ba_direct(struct flashctx *flash, unsigned int addr, uint8_t *bytes, unsigned int len);
216int spi_block_erase_21_4ba_direct(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
217int spi_block_erase_5c_4ba_direct(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
218int spi_block_erase_dc_4ba_direct(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
Boris Baykov50a56602016-06-11 18:28:59 +0200219
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000220#endif /* !__CHIPDRIVERS_H__ */