blob: d8a5bccb18b8a9a0da401053e7236c0c328d4603 [file] [log] [blame]
hailfinger088dc812009-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);
32int probe_spi_res(struct flashchip *flash);
33int spi_write_enable(void);
34int spi_write_disable(void);
35int spi_chip_erase_60(struct flashchip *flash);
36int spi_chip_erase_c7(struct flashchip *flash);
37int spi_chip_erase_60_c7(struct flashchip *flash);
38int spi_chip_erase_d8(struct flashchip *flash);
39int spi_block_erase_20(struct flashchip *flash, unsigned int addr, unsigned int blocklen);
40int spi_block_erase_52(struct flashchip *flash, unsigned int addr, unsigned int blocklen);
snelson4d31f0d2010-01-19 03:23:07 +000041int spi_block_erase_d7(struct flashchip *flash, unsigned int addr, unsigned int blocklen);
hailfinger088dc812009-12-14 03:32:24 +000042int spi_block_erase_d8(struct flashchip *flash, unsigned int addr, unsigned int blocklen);
43int spi_block_erase_60(struct flashchip *flash, unsigned int addr, unsigned int blocklen);
44int spi_block_erase_c7(struct flashchip *flash, unsigned int addr, unsigned int blocklen);
45int spi_chip_write_1(struct flashchip *flash, uint8_t *buf);
46int spi_chip_write_256(struct flashchip *flash, uint8_t *buf);
47int spi_chip_read(struct flashchip *flash, uint8_t *buf, int start, int len);
48uint8_t spi_read_status_register(void);
49int spi_disable_blockprotect(void);
mkarcher850a4972010-01-12 23:29:26 +000050int spi_byte_program(int addr, uint8_t databyte);
hailfinger088dc812009-12-14 03:32:24 +000051int spi_nbyte_program(int addr, uint8_t *bytes, int len);
52int spi_nbyte_read(int addr, uint8_t *bytes, int len);
53int spi_read_chunked(struct flashchip *flash, uint8_t *buf, int start, int len, int chunksize);
54int spi_aai_write(struct flashchip *flash, uint8_t *buf);
55
56/* 82802ab.c */
hailfinger4481d9d2010-01-07 21:23:45 +000057uint8_t wait_82802ab(chipaddr bios);
hailfinger088dc812009-12-14 03:32:24 +000058int probe_82802ab(struct flashchip *flash);
59int erase_82802ab(struct flashchip *flash);
snelsonc0acbeb2010-03-19 18:47:06 +000060int erase_block_82802ab(struct flashchip *flash, unsigned int page, unsigned int pagesize);
hailfinger088dc812009-12-14 03:32:24 +000061int write_82802ab(struct flashchip *flash, uint8_t *buf);
snelsonc0acbeb2010-03-19 18:47:06 +000062void print_status_82802ab(uint8_t status);
snelson51ce8902010-03-16 00:51:31 +000063void write_page_82802ab(chipaddr bios, uint8_t *src, chipaddr dst, int page_size);
snelsonc0acbeb2010-03-19 18:47:06 +000064int unlock_82802ab(struct flashchip *flash);
hailfinger088dc812009-12-14 03:32:24 +000065
hailfinger088dc812009-12-14 03:32:24 +000066/* jedec.c */
67uint8_t oddparity(uint8_t val);
68void toggle_ready_jedec(chipaddr dst);
69void data_polling_jedec(chipaddr dst, uint8_t data);
hailfinger088dc812009-12-14 03:32:24 +000070int write_byte_program_jedec(chipaddr bios, uint8_t *src,
71 chipaddr dst);
72int probe_jedec(struct flashchip *flash);
73int erase_chip_jedec(struct flashchip *flash);
74int write_jedec(struct flashchip *flash, uint8_t *buf);
75int write_jedec_1(struct flashchip *flash, uint8_t *buf);
76int erase_sector_jedec(struct flashchip *flash, unsigned int page, unsigned int pagesize);
77int erase_block_jedec(struct flashchip *flash, unsigned int page, unsigned int blocksize);
hailfingerc43afc92009-12-22 22:15:33 +000078int erase_chip_block_jedec(struct flashchip *flash, unsigned int page, unsigned int blocksize);
snelson63133f92010-01-04 17:15:23 +000079int write_sector_jedec_common(struct flashchip *flash, uint8_t *src, chipaddr dst, unsigned int page_size, unsigned int mask);
hailfinger088dc812009-12-14 03:32:24 +000080
hailfinger088dc812009-12-14 03:32:24 +000081/* m29f400bt.c */
82int probe_m29f400bt(struct flashchip *flash);
83int erase_m29f400bt(struct flashchip *flash);
snelson1c03aa12009-12-23 17:05:59 +000084int block_erase_m29f400bt(struct flashchip *flash, unsigned int start, unsigned int len);
85int block_erase_chip_m29f400bt(struct flashchip *flash, unsigned int start, unsigned int len);
hailfinger088dc812009-12-14 03:32:24 +000086int write_m29f400bt(struct flashchip *flash, uint8_t *buf);
87int write_coreboot_m29f400bt(struct flashchip *flash, uint8_t *buf);
hailfinger088dc812009-12-14 03:32:24 +000088void protect_m29f400bt(chipaddr bios);
89void write_page_m29f400bt(chipaddr bios, uint8_t *src,
90 chipaddr dst, int page_size);
91
hailfinger088dc812009-12-14 03:32:24 +000092/* pm49fl00x.c */
snelson1ee293c2010-02-19 00:52:10 +000093int unlock_49fl00x(struct flashchip *flash);
snelson59c83d22010-02-27 18:01:15 +000094int lock_49fl00x(struct flashchip *flash);
hailfinger088dc812009-12-14 03:32:24 +000095
hailfinger088dc812009-12-14 03:32:24 +000096/* sst28sf040.c */
snelson264e57c2010-01-20 20:55:53 +000097int erase_chip_28sf040(struct flashchip *flash, unsigned int addr, unsigned int blocklen);
98int erase_sector_28sf040(struct flashchip *flash, unsigned int address, unsigned int sector_size);
hailfinger088dc812009-12-14 03:32:24 +000099int write_28sf040(struct flashchip *flash, uint8_t *buf);
100
hailfinger088dc812009-12-14 03:32:24 +0000101/* sst49lfxxxc.c */
102int probe_49lfxxxc(struct flashchip *flash);
103int erase_49lfxxxc(struct flashchip *flash);
snelson264e57c2010-01-20 20:55:53 +0000104int erase_sector_49lfxxxc(struct flashchip *flash, unsigned int address, unsigned int sector_size);
105int erase_block_49lfxxxc(struct flashchip *flash, unsigned int address, unsigned int sector_size);
106int erase_chip_49lfxxxc(struct flashchip *flash, unsigned int addr, unsigned int blocksize);
hailfinger088dc812009-12-14 03:32:24 +0000107int write_49lfxxxc(struct flashchip *flash, uint8_t *buf);
snelson1ee293c2010-02-19 00:52:10 +0000108int unlock_49lfxxxc(struct flashchip *flash);
hailfinger088dc812009-12-14 03:32:24 +0000109
110/* sst_fwhub.c */
hailfingerb8e4e212010-03-15 03:48:42 +0000111int printlock_sst_fwhub(struct flashchip *flash);
snelson712e72d2010-03-16 03:09:10 +0000112int unlock_sst_fwhub(struct flashchip *flash);
hailfinger088dc812009-12-14 03:32:24 +0000113
114/* w39v040c.c */
snelson1ee293c2010-02-19 00:52:10 +0000115int printlock_w39v040c(struct flashchip *flash);
hailfinger088dc812009-12-14 03:32:24 +0000116
117/* w39V080fa.c */
snelson1ee293c2010-02-19 00:52:10 +0000118int unlock_winbond_fwhub(struct flashchip *flash);
hailfinger088dc812009-12-14 03:32:24 +0000119
120/* w29ee011.c */
121int probe_w29ee011(struct flashchip *flash);
122
hailfinger088dc812009-12-14 03:32:24 +0000123/* stm50flw0x0x.c */
snelsone0c56352010-01-19 16:08:51 +0000124int erase_sector_stm50flw0x0x(struct flashchip *flash, unsigned int block, unsigned int blocksize);
125int erase_chip_stm50flw0x0x(struct flashchip *flash, unsigned int addr, unsigned int blocklen);
snelsonc0acbeb2010-03-19 18:47:06 +0000126int unlock_stm50flw0x0x(struct flashchip *flash);
hailfinger088dc812009-12-14 03:32:24 +0000127
128#endif /* !__CHIPDRIVERS_H__ */