blob: 1569bf3af4406c5d282d46fda1e40cbcf9b44642 [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
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +000030/* spi.c, should probably be in spi_chip.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +000031int probe_spi_rdid(struct flashctx *flash);
32int probe_spi_rdid4(struct flashctx *flash);
33int probe_spi_rems(struct flashctx *flash);
34int probe_spi_res1(struct flashctx *flash);
35int probe_spi_res2(struct flashctx *flash);
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +000036int spi_write_enable(struct flashctx *flash);
37int spi_write_disable(struct flashctx *flash);
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +000038int spi_block_erase_20(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
39int spi_block_erase_52(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
40int spi_block_erase_d7(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
41int spi_block_erase_d8(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
42int spi_block_erase_60(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
43int spi_block_erase_c7(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
Stefan Taunerac1b4c82012-02-17 14:51:04 +000044erasefunc_t *spi_get_erasefn_from_opcode(uint8_t opcode);
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +000045int spi_chip_write_1(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
46int spi_chip_write_256(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
47int spi_chip_read(struct flashctx *flash, uint8_t *buf, unsigned int start, int unsigned len);
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +000048uint8_t spi_read_status_register(struct flashctx *flash);
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +000049int spi_write_status_register(struct flashctx *flash, int status);
Carl-Daniel Hailfinger7a3bd8f2011-05-19 00:06:06 +000050void spi_prettyprint_status_register_bit(uint8_t status, int bit);
51void spi_prettyprint_status_register_bp3210(uint8_t status, int bp);
52void spi_prettyprint_status_register_welwip(uint8_t status);
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +000053int spi_prettyprint_status_register(struct flashctx *flash);
54int spi_disable_blockprotect(struct flashctx *flash);
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);
60int spi_aai_write(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +000061
Stefan Taunerac1b4c82012-02-17 14:51:04 +000062/* sfdp.c */
63int probe_spi_sfdp(struct flashctx *flash);
64
Carl-Daniel Hailfinger532c7172011-11-04 21:35:26 +000065/* opaque.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +000066int probe_opaque(struct flashctx *flash);
67int read_opaque(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
68int write_opaque(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
69int erase_opaque(struct flashctx *flash, unsigned int blockaddr, unsigned int blocklen);
Carl-Daniel Hailfinger532c7172011-11-04 21:35:26 +000070
Carl-Daniel Hailfinger7a3bd8f2011-05-19 00:06:06 +000071/* a25.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +000072int spi_prettyprint_status_register_amic_a25l05p(struct flashctx *flash);
73int spi_prettyprint_status_register_amic_a25l40p(struct flashctx *flash);
74int spi_prettyprint_status_register_amic_a25l032(struct flashctx *flash);
75int spi_prettyprint_status_register_amic_a25lq032(struct flashctx *flash);
Carl-Daniel Hailfinger7a3bd8f2011-05-19 00:06:06 +000076
77/* at25.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +000078int spi_prettyprint_status_register_at25df(struct flashctx *flash);
79int spi_prettyprint_status_register_at25df_sec(struct flashctx *flash);
80int spi_prettyprint_status_register_at25f(struct flashctx *flash);
81int spi_prettyprint_status_register_at25fs010(struct flashctx *flash);
82int spi_prettyprint_status_register_at25fs040(struct flashctx *flash);
83int spi_prettyprint_status_register_atmel_at26df081a(struct flashctx *flash);
84int spi_disable_blockprotect_at25df(struct flashctx *flash);
85int spi_disable_blockprotect_at25df_sec(struct flashctx *flash);
86int spi_disable_blockprotect_at25f(struct flashctx *flash);
87int spi_disable_blockprotect_at25fs010(struct flashctx *flash);
88int spi_disable_blockprotect_at25fs040(struct flashctx *flash);
Carl-Daniel Hailfinger7a3bd8f2011-05-19 00:06:06 +000089
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +000090/* 82802ab.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +000091uint8_t wait_82802ab(struct flashctx *flash);
92int probe_82802ab(struct flashctx *flash);
93int erase_block_82802ab(struct flashctx *flash, unsigned int page, unsigned int pagesize);
94int write_82802ab(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
Sean Nelson28accc22010-03-19 18:47:06 +000095void print_status_82802ab(uint8_t status);
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +000096int unlock_82802ab(struct flashctx *flash);
97int unlock_28f004s5(struct flashctx *flash);
98int unlock_lh28f008bjt(struct flashctx *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +000099
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000100/* jedec.c */
101uint8_t oddparity(uint8_t val);
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +0000102void toggle_ready_jedec(struct flashctx *flash, chipaddr dst);
103void data_polling_jedec(struct flashctx *flash, chipaddr dst, uint8_t data);
104int write_byte_program_jedec(struct flashctx *flash, chipaddr bios, uint8_t *src,
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000105 chipaddr dst);
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000106int probe_jedec(struct flashctx *flash);
107int write_jedec(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
108int write_jedec_1(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
109int erase_sector_jedec(struct flashctx *flash, unsigned int page, unsigned int pagesize);
110int erase_block_jedec(struct flashctx *flash, unsigned int page, unsigned int blocksize);
111int erase_chip_block_jedec(struct flashctx *flash, unsigned int page, unsigned int blocksize);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000112
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000113/* m29f400bt.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000114int probe_m29f400bt(struct flashctx *flash);
115int block_erase_m29f400bt(struct flashctx *flash, unsigned int start, unsigned int len);
116int block_erase_chip_m29f400bt(struct flashctx *flash, unsigned int start, unsigned int len);
117int write_m29f400bt(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
Carl-Daniel Hailfinger8a3c60c2011-12-18 15:01:24 +0000118void protect_m29f400bt(struct flashctx *flash, chipaddr bios);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000119
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000120/* pm49fl00x.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000121int unlock_49fl00x(struct flashctx *flash);
122int lock_49fl00x(struct flashctx *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000123
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000124/* sst28sf040.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000125int erase_chip_28sf040(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
126int erase_sector_28sf040(struct flashctx *flash, unsigned int address, unsigned int sector_size);
127int write_28sf040(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
128int unprotect_28sf040(struct flashctx *flash);
129int protect_28sf040(struct flashctx *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000130
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000131/* sst49lfxxxc.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000132int erase_sector_49lfxxxc(struct flashctx *flash, unsigned int address, unsigned int sector_size);
133int unlock_49lfxxxc(struct flashctx *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000134
135/* sst_fwhub.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000136int printlock_sst_fwhub(struct flashctx *flash);
137int unlock_sst_fwhub(struct flashctx *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000138
Carl-Daniel Hailfinger91882402010-12-05 16:33:59 +0000139/* w39.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000140int printlock_w39l040(struct flashctx * flash);
141int printlock_w39v040a(struct flashctx *flash);
142int printlock_w39v040b(struct flashctx *flash);
143int printlock_w39v040c(struct flashctx *flash);
144int printlock_w39v040fa(struct flashctx *flash);
145int printlock_w39v040fb(struct flashctx *flash);
146int printlock_w39v040fc(struct flashctx *flash);
147int printlock_w39v080a(struct flashctx *flash);
148int printlock_w39v080fa(struct flashctx *flash);
149int printlock_w39v080fa_dual(struct flashctx *flash);
150int unlock_w39v040fb(struct flashctx *flash);
151int unlock_w39v080fa(struct flashctx *flash);
David Borgf5a30f62012-04-15 13:16:32 +0000152int printlock_at49f(struct flashctx *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000153
154/* w29ee011.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000155int probe_w29ee011(struct flashctx *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000156
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000157/* stm50flw0x0x.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000158int erase_sector_stm50flw0x0x(struct flashctx *flash, unsigned int block, unsigned int blocksize);
159int unlock_stm50flw0x0x(struct flashctx *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000160
Rudolf Marek47eff6b2012-04-14 22:51:40 +0000161/* en29lv640b.c */
162int probe_en29lv640b(struct flashctx *flash);
163int block_erase_en29lv640b(struct flashctx *flash, unsigned int start, unsigned int len);
164int block_erase_chip_en29lv640b(struct flashctx *flash, unsigned int start, unsigned int len);
165int write_en29lv640b(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
166
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000167#endif /* !__CHIPDRIVERS_H__ */