blob: 3f5b503e32d23bf2cca95480f57a8da0465a9db4 [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
22 * struct flashchip as first parameter.
23 */
24
25#ifndef __CHIPDRIVERS_H__
26#define __CHIPDRIVERS_H__ 1
27
Stefan Taunera63c7c42011-08-16 12:08:22 +000028#include "flash.h" /* for chipaddr and flashchip */
29
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +000030/* spi.c, should probably be in spi_chip.c */
31int probe_spi_rdid(struct flashchip *flash);
32int probe_spi_rdid4(struct flashchip *flash);
33int probe_spi_rems(struct flashchip *flash);
Carl-Daniel Hailfingerdc1cda12010-05-28 17:07:57 +000034int probe_spi_res1(struct flashchip *flash);
35int probe_spi_res2(struct flashchip *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +000036int spi_write_enable(void);
37int spi_write_disable(void);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +000038int spi_block_erase_20(struct flashchip *flash, unsigned int addr, unsigned int blocklen);
39int spi_block_erase_52(struct flashchip *flash, unsigned int addr, unsigned int blocklen);
Sean Nelson5643c072010-01-19 03:23:07 +000040int spi_block_erase_d7(struct flashchip *flash, unsigned int addr, unsigned int blocklen);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +000041int spi_block_erase_d8(struct flashchip *flash, unsigned int addr, unsigned int blocklen);
42int spi_block_erase_60(struct flashchip *flash, unsigned int addr, unsigned int blocklen);
43int spi_block_erase_c7(struct flashchip *flash, unsigned int addr, unsigned int blocklen);
Carl-Daniel Hailfinger75a58f92010-10-13 22:26:56 +000044int spi_chip_write_1(struct flashchip *flash, uint8_t *buf, int start, int len);
45int spi_chip_write_256(struct flashchip *flash, uint8_t *buf, int start, int len);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +000046int spi_chip_read(struct flashchip *flash, uint8_t *buf, int start, int len);
47uint8_t spi_read_status_register(void);
Carl-Daniel Hailfinger7a3bd8f2011-05-19 00:06:06 +000048int spi_write_status_register(struct flashchip *flash, int status);
49void 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);
52int spi_prettyprint_status_register(struct flashchip *flash);
Carl-Daniel Hailfinger29a1c662010-07-14 20:21:22 +000053int spi_disable_blockprotect(struct flashchip *flash);
Michael Karcher4e2fb0e2010-01-12 23:29:26 +000054int spi_byte_program(int addr, uint8_t databyte);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +000055int spi_nbyte_program(int addr, uint8_t *bytes, int len);
56int spi_nbyte_read(int addr, uint8_t *bytes, int len);
57int spi_read_chunked(struct flashchip *flash, uint8_t *buf, int start, int len, int chunksize);
Carl-Daniel Hailfinger5824fbf2010-05-21 23:09:42 +000058int spi_write_chunked(struct flashchip *flash, uint8_t *buf, int start, int len, int chunksize);
Carl-Daniel Hailfinger75a58f92010-10-13 22:26:56 +000059int spi_aai_write(struct flashchip *flash, uint8_t *buf, int start, int len);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +000060
Carl-Daniel Hailfinger7a3bd8f2011-05-19 00:06:06 +000061/* a25.c */
62int spi_prettyprint_status_register_amic_a25l05p(struct flashchip *flash);
63int spi_prettyprint_status_register_amic_a25l40p(struct flashchip *flash);
64int spi_prettyprint_status_register_amic_a25l032(struct flashchip *flash);
65int spi_prettyprint_status_register_amic_a25lq032(struct flashchip *flash);
66
67/* at25.c */
68int spi_prettyprint_status_register_at25df(struct flashchip *flash);
69int spi_prettyprint_status_register_at25df_sec(struct flashchip *flash);
70int spi_prettyprint_status_register_at25f(struct flashchip *flash);
71int spi_prettyprint_status_register_at25fs010(struct flashchip *flash);
72int spi_prettyprint_status_register_at25fs040(struct flashchip *flash);
73int spi_prettyprint_status_register_atmel_at26df081a(struct flashchip *flash);
74int spi_disable_blockprotect_at25df(struct flashchip *flash);
75int spi_disable_blockprotect_at25df_sec(struct flashchip *flash);
76int spi_disable_blockprotect_at25f(struct flashchip *flash);
77int spi_disable_blockprotect_at25fs010(struct flashchip *flash);
78int spi_disable_blockprotect_at25fs040(struct flashchip *flash);
79
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +000080/* 82802ab.c */
Carl-Daniel Hailfingerb30a5ed2010-10-10 14:02:27 +000081uint8_t wait_82802ab(struct flashchip *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +000082int probe_82802ab(struct flashchip *flash);
Sean Nelson28accc22010-03-19 18:47:06 +000083int erase_block_82802ab(struct flashchip *flash, unsigned int page, unsigned int pagesize);
Carl-Daniel Hailfinger75a58f92010-10-13 22:26:56 +000084int write_82802ab(struct flashchip *flash, uint8_t *buf, int start, int len);
Sean Nelson28accc22010-03-19 18:47:06 +000085void print_status_82802ab(uint8_t status);
Sean Nelson28accc22010-03-19 18:47:06 +000086int unlock_82802ab(struct flashchip *flash);
Sean Nelson88647102010-03-22 06:57:02 +000087int unlock_28f004s5(struct flashchip *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +000088
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +000089/* jedec.c */
90uint8_t oddparity(uint8_t val);
91void toggle_ready_jedec(chipaddr dst);
92void data_polling_jedec(chipaddr dst, uint8_t data);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +000093int write_byte_program_jedec(chipaddr bios, uint8_t *src,
94 chipaddr dst);
95int probe_jedec(struct flashchip *flash);
Carl-Daniel Hailfinger75a58f92010-10-13 22:26:56 +000096int write_jedec(struct flashchip *flash, uint8_t *buf, int start, int len);
97int write_jedec_1(struct flashchip *flash, uint8_t *buf, int start, int len);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +000098int erase_sector_jedec(struct flashchip *flash, unsigned int page, unsigned int pagesize);
99int erase_block_jedec(struct flashchip *flash, unsigned int page, unsigned int blocksize);
Sean Nelson72a9a022009-12-22 22:15:33 +0000100int erase_chip_block_jedec(struct flashchip *flash, unsigned int page, unsigned int blocksize);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000101
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000102/* m29f400bt.c */
103int probe_m29f400bt(struct flashchip *flash);
Sean Nelson6b11ad22009-12-23 17:05:59 +0000104int block_erase_m29f400bt(struct flashchip *flash, unsigned int start, unsigned int len);
105int block_erase_chip_m29f400bt(struct flashchip *flash, unsigned int start, unsigned int len);
Carl-Daniel Hailfinger75a58f92010-10-13 22:26:56 +0000106int write_m29f400bt(struct flashchip *flash, uint8_t *buf, int start, int len);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000107void protect_m29f400bt(chipaddr bios);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000108
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000109/* pm49fl00x.c */
Sean Nelson6e0b9122010-02-19 00:52:10 +0000110int unlock_49fl00x(struct flashchip *flash);
Sean Nelson36172342010-02-27 18:01:15 +0000111int lock_49fl00x(struct flashchip *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000112
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000113/* sst28sf040.c */
Sean Nelson51c83fb2010-01-20 20:55:53 +0000114int erase_chip_28sf040(struct flashchip *flash, unsigned int addr, unsigned int blocklen);
115int erase_sector_28sf040(struct flashchip *flash, unsigned int address, unsigned int sector_size);
Carl-Daniel Hailfinger75a58f92010-10-13 22:26:56 +0000116int write_28sf040(struct flashchip *flash, uint8_t *buf, int start, int len);
Carl-Daniel Hailfinger79e67572010-10-13 21:49:30 +0000117int unprotect_28sf040(struct flashchip *flash);
118int protect_28sf040(struct flashchip *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000119
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000120/* sst49lfxxxc.c */
Sean Nelson51c83fb2010-01-20 20:55:53 +0000121int erase_sector_49lfxxxc(struct flashchip *flash, unsigned int address, unsigned int sector_size);
Sean Nelson6e0b9122010-02-19 00:52:10 +0000122int unlock_49lfxxxc(struct flashchip *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000123
124/* sst_fwhub.c */
Carl-Daniel Hailfinger81449a22010-03-15 03:48:42 +0000125int printlock_sst_fwhub(struct flashchip *flash);
Sean Nelsonccf7a2a2010-03-16 03:09:10 +0000126int unlock_sst_fwhub(struct flashchip *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000127
Carl-Daniel Hailfinger91882402010-12-05 16:33:59 +0000128/* w39.c */
Michael Karcher19e0aac2011-03-06 17:58:05 +0000129int printlock_w39l040(struct flashchip * flash);
Carl-Daniel Hailfinger91882402010-12-05 16:33:59 +0000130int printlock_w39v040a(struct flashchip *flash);
131int printlock_w39v040b(struct flashchip *flash);
Sean Nelson6e0b9122010-02-19 00:52:10 +0000132int printlock_w39v040c(struct flashchip *flash);
Carl-Daniel Hailfinger91882402010-12-05 16:33:59 +0000133int printlock_w39v040fa(struct flashchip *flash);
134int printlock_w39v040fb(struct flashchip *flash);
135int printlock_w39v040fc(struct flashchip *flash);
136int printlock_w39v080a(struct flashchip *flash);
137int printlock_w39v080fa(struct flashchip *flash);
138int printlock_w39v080fa_dual(struct flashchip *flash);
Idwer Volleringecc67072010-12-26 23:55:12 +0000139int unlock_w39v040fb(struct flashchip *flash);
Carl-Daniel Hailfinger91882402010-12-05 16:33:59 +0000140int unlock_w39v080fa(struct flashchip *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000141
142/* w29ee011.c */
143int probe_w29ee011(struct flashchip *flash);
144
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000145/* stm50flw0x0x.c */
Sean Nelson56358aa2010-01-19 16:08:51 +0000146int erase_sector_stm50flw0x0x(struct flashchip *flash, unsigned int block, unsigned int blocksize);
Sean Nelson28accc22010-03-19 18:47:06 +0000147int unlock_stm50flw0x0x(struct flashchip *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000148
149#endif /* !__CHIPDRIVERS_H__ */