blob: 119ea7002784f895f1e03f260dfc320178464045 [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
28/* spi.c, should probably be in spi_chip.c */
29int probe_spi_rdid(struct flashchip *flash);
30int probe_spi_rdid4(struct flashchip *flash);
31int probe_spi_rems(struct flashchip *flash);
Carl-Daniel Hailfingerdc1cda12010-05-28 17:07:57 +000032int probe_spi_res1(struct flashchip *flash);
33int probe_spi_res2(struct flashchip *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +000034int spi_write_enable(void);
35int spi_write_disable(void);
36int spi_chip_erase_60(struct flashchip *flash);
37int spi_chip_erase_c7(struct flashchip *flash);
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);
44int spi_chip_write_1(struct flashchip *flash, uint8_t *buf);
45int spi_chip_write_256(struct flashchip *flash, uint8_t *buf);
Carl-Daniel Hailfinger9a795d82010-07-14 16:19:05 +000046int spi_chip_write_1_new(struct flashchip *flash, uint8_t *buf, int start, int len);
47int spi_chip_write_256_new(struct flashchip *flash, uint8_t *buf, int start, int len);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +000048int spi_chip_read(struct flashchip *flash, uint8_t *buf, int start, int len);
49uint8_t spi_read_status_register(void);
Carl-Daniel Hailfingerfd7075a2010-07-29 13:09:18 +000050int spi_prettyprint_status_register_at25df(struct flashchip *flash);
51int spi_prettyprint_status_register_at25df_sec(struct flashchip *flash);
52int spi_prettyprint_status_register_at25f(struct flashchip *flash);
53int spi_prettyprint_status_register_at25fs010(struct flashchip *flash);
54int spi_prettyprint_status_register_at25fs040(struct flashchip *flash);
Carl-Daniel Hailfinger29a1c662010-07-14 20:21:22 +000055int spi_disable_blockprotect(struct flashchip *flash);
Carl-Daniel Hailfingerfd7075a2010-07-29 13:09:18 +000056int spi_disable_blockprotect_at25df(struct flashchip *flash);
57int spi_disable_blockprotect_at25df_sec(struct flashchip *flash);
58int spi_disable_blockprotect_at25f(struct flashchip *flash);
59int spi_disable_blockprotect_at25fs010(struct flashchip *flash);
60int spi_disable_blockprotect_at25fs040(struct flashchip *flash);
Michael Karcher4e2fb0e2010-01-12 23:29:26 +000061int spi_byte_program(int addr, uint8_t databyte);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +000062int spi_nbyte_program(int addr, uint8_t *bytes, int len);
63int spi_nbyte_read(int addr, uint8_t *bytes, int len);
64int spi_read_chunked(struct flashchip *flash, uint8_t *buf, int start, int len, int chunksize);
Carl-Daniel Hailfinger5824fbf2010-05-21 23:09:42 +000065int spi_write_chunked(struct flashchip *flash, uint8_t *buf, int start, int len, int chunksize);
Carl-Daniel Hailfinger9a795d82010-07-14 16:19:05 +000066int spi_aai_write(struct flashchip *flash, uint8_t *buf, int start, int len);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +000067
68/* 82802ab.c */
Carl-Daniel Hailfingeraca1dce2010-01-07 21:23:45 +000069uint8_t wait_82802ab(chipaddr bios);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +000070int probe_82802ab(struct flashchip *flash);
71int erase_82802ab(struct flashchip *flash);
Sean Nelson28accc22010-03-19 18:47:06 +000072int erase_block_82802ab(struct flashchip *flash, unsigned int page, unsigned int pagesize);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +000073int write_82802ab(struct flashchip *flash, uint8_t *buf);
Sean Nelson28accc22010-03-19 18:47:06 +000074void print_status_82802ab(uint8_t status);
Sean Nelsone4446e42010-03-16 00:51:31 +000075void write_page_82802ab(chipaddr bios, uint8_t *src, chipaddr dst, int page_size);
Sean Nelson28accc22010-03-19 18:47:06 +000076int unlock_82802ab(struct flashchip *flash);
Sean Nelson88647102010-03-22 06:57:02 +000077int unlock_28f004s5(struct flashchip *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +000078
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +000079/* jedec.c */
80uint8_t oddparity(uint8_t val);
81void toggle_ready_jedec(chipaddr dst);
82void data_polling_jedec(chipaddr dst, uint8_t data);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +000083int write_byte_program_jedec(chipaddr bios, uint8_t *src,
84 chipaddr dst);
85int probe_jedec(struct flashchip *flash);
86int erase_chip_jedec(struct flashchip *flash);
87int write_jedec(struct flashchip *flash, uint8_t *buf);
88int write_jedec_1(struct flashchip *flash, uint8_t *buf);
89int erase_sector_jedec(struct flashchip *flash, unsigned int page, unsigned int pagesize);
90int erase_block_jedec(struct flashchip *flash, unsigned int page, unsigned int blocksize);
Sean Nelson72a9a022009-12-22 22:15:33 +000091int erase_chip_block_jedec(struct flashchip *flash, unsigned int page, unsigned int blocksize);
Sean Nelsonc57a9202010-01-04 17:15:23 +000092int write_sector_jedec_common(struct flashchip *flash, uint8_t *src, chipaddr dst, unsigned int page_size, unsigned int mask);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +000093
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +000094/* m29f400bt.c */
95int probe_m29f400bt(struct flashchip *flash);
96int erase_m29f400bt(struct flashchip *flash);
Sean Nelson6b11ad22009-12-23 17:05:59 +000097int block_erase_m29f400bt(struct flashchip *flash, unsigned int start, unsigned int len);
98int block_erase_chip_m29f400bt(struct flashchip *flash, unsigned int start, unsigned int len);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +000099int write_m29f400bt(struct flashchip *flash, uint8_t *buf);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000100void protect_m29f400bt(chipaddr bios);
101void write_page_m29f400bt(chipaddr bios, uint8_t *src,
102 chipaddr dst, int page_size);
103
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000104/* pm49fl00x.c */
Sean Nelson6e0b9122010-02-19 00:52:10 +0000105int unlock_49fl00x(struct flashchip *flash);
Sean Nelson36172342010-02-27 18:01:15 +0000106int lock_49fl00x(struct flashchip *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000107
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000108/* sst28sf040.c */
Sean Nelson51c83fb2010-01-20 20:55:53 +0000109int erase_chip_28sf040(struct flashchip *flash, unsigned int addr, unsigned int blocklen);
110int erase_sector_28sf040(struct flashchip *flash, unsigned int address, unsigned int sector_size);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000111int write_28sf040(struct flashchip *flash, uint8_t *buf);
112
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000113/* sst49lfxxxc.c */
Sean Nelson51c83fb2010-01-20 20:55:53 +0000114int erase_sector_49lfxxxc(struct flashchip *flash, unsigned int address, unsigned int sector_size);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000115int write_49lfxxxc(struct flashchip *flash, uint8_t *buf);
Sean Nelson6e0b9122010-02-19 00:52:10 +0000116int unlock_49lfxxxc(struct flashchip *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000117
118/* sst_fwhub.c */
Carl-Daniel Hailfinger81449a22010-03-15 03:48:42 +0000119int printlock_sst_fwhub(struct flashchip *flash);
Sean Nelsonccf7a2a2010-03-16 03:09:10 +0000120int unlock_sst_fwhub(struct flashchip *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000121
122/* w39v040c.c */
Sean Nelson6e0b9122010-02-19 00:52:10 +0000123int printlock_w39v040c(struct flashchip *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000124
125/* w39V080fa.c */
Sean Nelson6e0b9122010-02-19 00:52:10 +0000126int unlock_winbond_fwhub(struct flashchip *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000127
128/* w29ee011.c */
129int probe_w29ee011(struct flashchip *flash);
130
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000131/* stm50flw0x0x.c */
Sean Nelson56358aa2010-01-19 16:08:51 +0000132int erase_sector_stm50flw0x0x(struct flashchip *flash, unsigned int block, unsigned int blocksize);
133int erase_chip_stm50flw0x0x(struct flashchip *flash, unsigned int addr, unsigned int blocklen);
Sean Nelson28accc22010-03-19 18:47:06 +0000134int unlock_stm50flw0x0x(struct flashchip *flash);
Carl-Daniel Hailfinger5d5c0722009-12-14 03:32:24 +0000135
136#endif /* !__CHIPDRIVERS_H__ */