blob: f0223ae5da8f32098efe967f16dfce0a5d472d6e [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 */
31int spi_aai_write(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
32int spi_chip_write_256(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
33int 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 Tauner57794ac2012-12-29 15:04:20 +000041int probe_spi_at25f(struct flashctx *flash);
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +000042int spi_write_enable(struct flashctx *flash);
43int spi_write_disable(struct flashctx *flash);
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +000044int spi_block_erase_20(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
Stefan Tauner94b39b42012-10-27 00:06:02 +000045int spi_block_erase_50(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +000046int spi_block_erase_52(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
Stefan Tauner94b39b42012-10-27 00:06:02 +000047int spi_block_erase_81(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +000048int spi_block_erase_d7(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
49int spi_block_erase_d8(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
50int spi_block_erase_60(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
Stefan Tauner3c0fcd02012-09-21 12:46:56 +000051int spi_block_erase_62(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 Taunerac1b4c82012-02-17 14:51:04 +000053erasefunc_t *spi_get_erasefn_from_opcode(uint8_t opcode);
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +000054int spi_chip_write_1(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +000055int spi_byte_program(struct flashctx *flash, unsigned int addr, uint8_t databyte);
56int spi_nbyte_program(struct flashctx *flash, unsigned int addr, uint8_t *bytes, unsigned int len);
57int spi_nbyte_read(struct flashctx *flash, unsigned int addr, uint8_t *bytes, unsigned int len);
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +000058int spi_read_chunked(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len, unsigned int chunksize);
59int spi_write_chunked(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len, unsigned int chunksize);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +000060
Stefan Tauner6ee37e22012-12-29 15:03:51 +000061/* spi25_statusreg.c */
62uint8_t spi_read_status_register(struct flashctx *flash);
63int spi_write_status_register(struct flashctx *flash, int status);
64int spi_prettyprint_status_register_plain(struct flashctx *flash);
65int spi_prettyprint_status_register_default_bp1(struct flashctx *flash);
66int spi_prettyprint_status_register_default_bp2(struct flashctx *flash);
67int spi_prettyprint_status_register_default_bp3(struct flashctx *flash);
68int spi_disable_blockprotect(struct flashctx *flash);
69int spi_prettyprint_status_register_amic_a25l032(struct flashctx *flash);
70int spi_prettyprint_status_register_at25df(struct flashctx *flash);
71int spi_prettyprint_status_register_at25df_sec(struct flashctx *flash);
Stefan Tauner57794ac2012-12-29 15:04:20 +000072int spi_prettyprint_status_register_at25f(struct flashctx *flash);
73int spi_prettyprint_status_register_at25f512a(struct flashctx *flash);
Stefan Tauner6ee37e22012-12-29 15:03:51 +000074int spi_prettyprint_status_register_at25f512b(struct flashctx *flash);
Stefan Tauner57794ac2012-12-29 15:04:20 +000075int spi_prettyprint_status_register_at25f4096(struct flashctx *flash);
Stefan Tauner6ee37e22012-12-29 15:03:51 +000076int spi_prettyprint_status_register_at25fs010(struct flashctx *flash);
77int spi_prettyprint_status_register_at25fs040(struct flashctx *flash);
78int spi_prettyprint_status_register_at26df081a(struct flashctx *flash);
79int spi_disable_blockprotect_at25df(struct flashctx *flash);
80int spi_disable_blockprotect_at25df_sec(struct flashctx *flash);
Stefan Tauner57794ac2012-12-29 15:04:20 +000081int spi_disable_blockprotect_at25f(struct flashctx *flash);
82int spi_disable_blockprotect_at25f512a(struct flashctx *flash);
Stefan Tauner6ee37e22012-12-29 15:03:51 +000083int spi_disable_blockprotect_at25f512b(struct flashctx *flash);
Stefan Tauner57794ac2012-12-29 15:04:20 +000084int spi_disable_blockprotect_at25f4096(struct flashctx *flash);
Stefan Tauner6ee37e22012-12-29 15:03:51 +000085int spi_disable_blockprotect_at25fs010(struct flashctx *flash);
86int spi_disable_blockprotect_at25fs040(struct flashctx *flash);
Stefan Tauner54aaa4a2012-12-29 15:04:12 +000087int spi_prettyprint_status_register_s33(struct flashctx *flash);
88int spi_disable_blockprotect_s33(struct flashctx *flash);
Stefan Tauner6ee37e22012-12-29 15:03:51 +000089int spi_prettyprint_status_register_sst25(struct flashctx *flash);
90int spi_prettyprint_status_register_sst25vf016(struct flashctx *flash);
91int spi_prettyprint_status_register_sst25vf040b(struct flashctx *flash);
92
Stefan Taunerac1b4c82012-02-17 14:51:04 +000093/* sfdp.c */
94int probe_spi_sfdp(struct flashctx *flash);
95
Carl-Daniel Hailfinger532c7172011-11-04 21:35:26 +000096/* opaque.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +000097int probe_opaque(struct flashctx *flash);
98int read_opaque(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
99int write_opaque(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
100int erase_opaque(struct flashctx *flash, unsigned int blockaddr, unsigned int blocklen);
Carl-Daniel Hailfinger532c7172011-11-04 21:35:26 +0000101
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000102/* 82802ab.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000103uint8_t wait_82802ab(struct flashctx *flash);
104int probe_82802ab(struct flashctx *flash);
105int erase_block_82802ab(struct flashctx *flash, unsigned int page, unsigned int pagesize);
106int write_82802ab(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
Sean Nelson28accc22010-03-19 18:47:06 +0000107void print_status_82802ab(uint8_t status);
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000108int unlock_82802ab(struct flashctx *flash);
109int unlock_28f004s5(struct flashctx *flash);
110int unlock_lh28f008bjt(struct flashctx *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000111
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000112/* jedec.c */
113uint8_t oddparity(uint8_t val);
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +0000114void toggle_ready_jedec(struct flashctx *flash, chipaddr dst);
115void data_polling_jedec(struct flashctx *flash, chipaddr dst, uint8_t data);
116int write_byte_program_jedec(struct flashctx *flash, chipaddr bios, uint8_t *src,
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000117 chipaddr dst);
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000118int probe_jedec(struct flashctx *flash);
119int write_jedec(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
120int write_jedec_1(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
121int erase_sector_jedec(struct flashctx *flash, unsigned int page, unsigned int pagesize);
122int erase_block_jedec(struct flashctx *flash, unsigned int page, unsigned int blocksize);
123int erase_chip_block_jedec(struct flashctx *flash, unsigned int page, unsigned int blocksize);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000124
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000125/* m29f400bt.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000126int probe_m29f400bt(struct flashctx *flash);
127int block_erase_m29f400bt(struct flashctx *flash, unsigned int start, unsigned int len);
128int block_erase_chip_m29f400bt(struct flashctx *flash, unsigned int start, unsigned int len);
129int write_m29f400bt(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +0000130void protect_m29f400bt(struct flashctx *flash, chipaddr bios);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000131
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000132/* pm49fl00x.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000133int unlock_49fl00x(struct flashctx *flash);
134int lock_49fl00x(struct flashctx *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000135
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000136/* sst28sf040.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000137int erase_chip_28sf040(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
138int erase_sector_28sf040(struct flashctx *flash, unsigned int address, unsigned int sector_size);
139int write_28sf040(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
140int unprotect_28sf040(struct flashctx *flash);
141int protect_28sf040(struct flashctx *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000142
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000143/* sst49lfxxxc.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000144int erase_sector_49lfxxxc(struct flashctx *flash, unsigned int address, unsigned int sector_size);
145int unlock_49lfxxxc(struct flashctx *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000146
147/* sst_fwhub.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000148int printlock_sst_fwhub(struct flashctx *flash);
149int unlock_sst_fwhub(struct flashctx *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000150
Carl-Daniel Hailfinger91882402010-12-05 16:33:59 +0000151/* w39.c */
Kyösti Mälkkic31243e2012-10-28 01:50:08 +0000152int printlock_w39f010(struct flashctx * flash);
153int printlock_w39l010(struct flashctx * flash);
154int printlock_w39l020(struct flashctx * flash);
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000155int printlock_w39l040(struct flashctx * flash);
156int printlock_w39v040a(struct flashctx *flash);
157int printlock_w39v040b(struct flashctx *flash);
158int printlock_w39v040c(struct flashctx *flash);
159int printlock_w39v040fa(struct flashctx *flash);
160int printlock_w39v040fb(struct flashctx *flash);
161int printlock_w39v040fc(struct flashctx *flash);
162int printlock_w39v080a(struct flashctx *flash);
163int printlock_w39v080fa(struct flashctx *flash);
164int printlock_w39v080fa_dual(struct flashctx *flash);
165int unlock_w39v040fb(struct flashctx *flash);
166int unlock_w39v080fa(struct flashctx *flash);
David Borgf5a30f62012-04-15 13:16:32 +0000167int printlock_at49f(struct flashctx *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000168
169/* w29ee011.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000170int probe_w29ee011(struct flashctx *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000171
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000172/* stm50flw0x0x.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000173int erase_sector_stm50flw0x0x(struct flashctx *flash, unsigned int block, unsigned int blocksize);
174int unlock_stm50flw0x0x(struct flashctx *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000175
Rudolf Marek47eff6b2012-04-14 22:51:40 +0000176/* en29lv640b.c */
177int probe_en29lv640b(struct flashctx *flash);
178int block_erase_en29lv640b(struct flashctx *flash, unsigned int start, unsigned int len);
179int block_erase_chip_en29lv640b(struct flashctx *flash, unsigned int start, unsigned int len);
180int write_en29lv640b(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
181
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000182#endif /* !__CHIPDRIVERS_H__ */