blob: ce0f9acd68a1811b88d60d3ac85195f5f247cde7 [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 Hailfinger5d5c0722009-12-14 03:32:24 +000036int spi_write_enable(void);
37int spi_write_disable(void);
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);
44int spi_chip_write_1(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
45int spi_chip_write_256(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
46int spi_chip_read(struct flashctx *flash, uint8_t *buf, unsigned int start, int unsigned len);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +000047uint8_t spi_read_status_register(void);
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +000048int spi_write_status_register(struct flashctx *flash, int status);
Carl-Daniel Hailfinger7a3bd8f2011-05-19 00:06:06 +000049void spi_prettyprint_status_register_bit(uint8_t status, int bit);
50void spi_prettyprint_status_register_bp3210(uint8_t status, int bp);
51void spi_prettyprint_status_register_welwip(uint8_t status);
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +000052int spi_prettyprint_status_register(struct flashctx *flash);
53int spi_disable_blockprotect(struct flashctx *flash);
Stefan Taunerc69c9c82011-11-23 09:13:48 +000054int spi_byte_program(unsigned int addr, uint8_t databyte);
55int spi_nbyte_program(unsigned int addr, uint8_t *bytes, unsigned int len);
56int spi_nbyte_read(unsigned int addr, uint8_t *bytes, unsigned int len);
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +000057int spi_read_chunked(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len, unsigned int chunksize);
58int spi_write_chunked(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len, unsigned int chunksize);
59int spi_aai_write(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +000060
Carl-Daniel Hailfinger532c7172011-11-04 21:35:26 +000061/* opaque.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +000062int probe_opaque(struct flashctx *flash);
63int read_opaque(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
64int write_opaque(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
65int erase_opaque(struct flashctx *flash, unsigned int blockaddr, unsigned int blocklen);
Carl-Daniel Hailfinger532c7172011-11-04 21:35:26 +000066
Carl-Daniel Hailfinger7a3bd8f2011-05-19 00:06:06 +000067/* a25.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +000068int spi_prettyprint_status_register_amic_a25l05p(struct flashctx *flash);
69int spi_prettyprint_status_register_amic_a25l40p(struct flashctx *flash);
70int spi_prettyprint_status_register_amic_a25l032(struct flashctx *flash);
71int spi_prettyprint_status_register_amic_a25lq032(struct flashctx *flash);
Carl-Daniel Hailfinger7a3bd8f2011-05-19 00:06:06 +000072
73/* at25.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +000074int spi_prettyprint_status_register_at25df(struct flashctx *flash);
75int spi_prettyprint_status_register_at25df_sec(struct flashctx *flash);
76int spi_prettyprint_status_register_at25f(struct flashctx *flash);
77int spi_prettyprint_status_register_at25fs010(struct flashctx *flash);
78int spi_prettyprint_status_register_at25fs040(struct flashctx *flash);
79int spi_prettyprint_status_register_atmel_at26df081a(struct flashctx *flash);
80int spi_disable_blockprotect_at25df(struct flashctx *flash);
81int spi_disable_blockprotect_at25df_sec(struct flashctx *flash);
82int spi_disable_blockprotect_at25f(struct flashctx *flash);
83int spi_disable_blockprotect_at25fs010(struct flashctx *flash);
84int spi_disable_blockprotect_at25fs040(struct flashctx *flash);
Carl-Daniel Hailfinger7a3bd8f2011-05-19 00:06:06 +000085
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +000086/* 82802ab.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +000087uint8_t wait_82802ab(struct flashctx *flash);
88int probe_82802ab(struct flashctx *flash);
89int erase_block_82802ab(struct flashctx *flash, unsigned int page, unsigned int pagesize);
90int write_82802ab(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
Sean Nelson28accc22010-03-19 18:47:06 +000091void print_status_82802ab(uint8_t status);
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +000092int unlock_82802ab(struct flashctx *flash);
93int unlock_28f004s5(struct flashctx *flash);
94int unlock_lh28f008bjt(struct flashctx *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +000095
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +000096/* jedec.c */
97uint8_t oddparity(uint8_t val);
98void toggle_ready_jedec(chipaddr dst);
99void data_polling_jedec(chipaddr dst, uint8_t data);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000100int write_byte_program_jedec(chipaddr bios, uint8_t *src,
101 chipaddr dst);
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000102int probe_jedec(struct flashctx *flash);
103int write_jedec(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
104int write_jedec_1(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
105int erase_sector_jedec(struct flashctx *flash, unsigned int page, unsigned int pagesize);
106int erase_block_jedec(struct flashctx *flash, unsigned int page, unsigned int blocksize);
107int erase_chip_block_jedec(struct flashctx *flash, unsigned int page, unsigned int blocksize);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000108
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000109/* m29f400bt.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000110int probe_m29f400bt(struct flashctx *flash);
111int block_erase_m29f400bt(struct flashctx *flash, unsigned int start, unsigned int len);
112int block_erase_chip_m29f400bt(struct flashctx *flash, unsigned int start, unsigned int len);
113int write_m29f400bt(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000114void protect_m29f400bt(chipaddr bios);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000115
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000116/* pm49fl00x.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000117int unlock_49fl00x(struct flashctx *flash);
118int lock_49fl00x(struct flashctx *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000119
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000120/* sst28sf040.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000121int erase_chip_28sf040(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
122int erase_sector_28sf040(struct flashctx *flash, unsigned int address, unsigned int sector_size);
123int write_28sf040(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
124int unprotect_28sf040(struct flashctx *flash);
125int protect_28sf040(struct flashctx *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000126
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000127/* sst49lfxxxc.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000128int erase_sector_49lfxxxc(struct flashctx *flash, unsigned int address, unsigned int sector_size);
129int unlock_49lfxxxc(struct flashctx *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000130
131/* sst_fwhub.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000132int printlock_sst_fwhub(struct flashctx *flash);
133int unlock_sst_fwhub(struct flashctx *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000134
Carl-Daniel Hailfinger91882402010-12-05 16:33:59 +0000135/* w39.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000136int printlock_w39l040(struct flashctx * flash);
137int printlock_w39v040a(struct flashctx *flash);
138int printlock_w39v040b(struct flashctx *flash);
139int printlock_w39v040c(struct flashctx *flash);
140int printlock_w39v040fa(struct flashctx *flash);
141int printlock_w39v040fb(struct flashctx *flash);
142int printlock_w39v040fc(struct flashctx *flash);
143int printlock_w39v080a(struct flashctx *flash);
144int printlock_w39v080fa(struct flashctx *flash);
145int printlock_w39v080fa_dual(struct flashctx *flash);
146int unlock_w39v040fb(struct flashctx *flash);
147int unlock_w39v080fa(struct flashctx *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000148
149/* w29ee011.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000150int probe_w29ee011(struct flashctx *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000151
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000152/* stm50flw0x0x.c */
Carl-Daniel Hailfinger63fd9022011-12-14 22:25:15 +0000153int erase_sector_stm50flw0x0x(struct flashctx *flash, unsigned int block, unsigned int blocksize);
154int unlock_stm50flw0x0x(struct flashctx *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000155
156#endif /* !__CHIPDRIVERS_H__ */