blob: 9b1434214c23a29836d1be5544f993f273224b24 [file] [log] [blame]
Nico Huberfbc41d22026-02-22 23:04:01 +01001/*
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
16#ifndef __CHIPDRIVERS_SPI_H__
17#define __CHIPDRIVERS_SPI_H__ 1
18
19#include <stdint.h>
20
21struct flashprog_flashctx;
Nico Huber43125762023-05-01 15:56:16 +020022struct master_common;
23struct bus_probe;
Nico Huberfbc41d22026-02-22 23:04:01 +010024
25/* spi.c */
26int spi_aai_write(struct flashprog_flashctx *, const uint8_t *buf, unsigned int start, unsigned int len);
27int spi_chip_write_256(struct flashprog_flashctx *, const uint8_t *buf, unsigned int start, unsigned int len);
28int spi_chip_read(struct flashprog_flashctx *, uint8_t *buf, unsigned int start, int unsigned len);
29
30/* spi25.c */
Nico Huber43125762023-05-01 15:56:16 +020031struct found_id *probe_spi_rdid(const struct bus_probe *, const struct master_common *);
32
Nico Huberfbc41d22026-02-22 23:04:01 +010033int spi_simple_write_cmd(struct flashprog_flashctx *, uint8_t op, unsigned int poll_delay);
Nico Huberfbc41d22026-02-22 23:04:01 +010034int probe_spi_rems(struct flashprog_flashctx *);
35int probe_spi_res1(struct flashprog_flashctx *);
36int probe_spi_res2(struct flashprog_flashctx *);
37int probe_spi_res3(struct flashprog_flashctx *);
38int probe_spi_at25f(struct flashprog_flashctx *);
39int spi_write_enable(struct flashprog_flashctx *);
40int spi_write_disable(struct flashprog_flashctx *);
41int spi_block_erase_20(struct flashprog_flashctx *, unsigned int addr, unsigned int blocklen);
42int spi_block_erase_21(struct flashprog_flashctx *, unsigned int addr, unsigned int blocklen);
43int spi_block_erase_50(struct flashprog_flashctx *, unsigned int addr, unsigned int blocklen);
44int spi_block_erase_52(struct flashprog_flashctx *, unsigned int addr, unsigned int blocklen);
45int spi_block_erase_53(struct flashprog_flashctx *, unsigned int addr, unsigned int blocklen);
46int spi_block_erase_5c(struct flashprog_flashctx *, unsigned int addr, unsigned int blocklen);
47int spi_block_erase_60(struct flashprog_flashctx *, unsigned int addr, unsigned int blocklen);
48int spi_block_erase_62(struct flashprog_flashctx *, unsigned int addr, unsigned int blocklen);
49int spi_block_erase_81(struct flashprog_flashctx *, unsigned int addr, unsigned int blocklen);
50int spi_block_erase_c4(struct flashprog_flashctx *, unsigned int addr, unsigned int blocklen);
51int spi_block_erase_c7(struct flashprog_flashctx *, unsigned int addr, unsigned int blocklen);
52int spi_block_erase_d7(struct flashprog_flashctx *, unsigned int addr, unsigned int blocklen);
53int spi_block_erase_d8(struct flashprog_flashctx *, unsigned int addr, unsigned int blocklen);
54int spi_block_erase_db(struct flashprog_flashctx *, unsigned int addr, unsigned int blocklen);
55int spi_block_erase_dc(struct flashprog_flashctx *, unsigned int addr, unsigned int blocklen);
56int spi_chip_write_1(struct flashprog_flashctx *, const uint8_t *buf, unsigned int start, unsigned int len);
57int spi_nbyte_read(struct flashprog_flashctx *, uint8_t *dst, unsigned int addr, unsigned int len);
58int spi_write_chunked(struct flashprog_flashctx *, const uint8_t *buf, unsigned int start, unsigned int len, unsigned int chunksize);
59int spi_set_extended_address(struct flashprog_flashctx *, uint8_t addr_high);
60
61enum preparation_steps;
62int spi_prepare_io(struct flashprog_flashctx *, enum preparation_steps);
63void spi_finish_io(struct flashprog_flashctx *);
64
65enum flash_reg;
66enum wrsr_target;
67int spi_read_register(const struct flashprog_flashctx *, enum flash_reg reg, uint8_t *value);
68int spi_write_register(const struct flashprog_flashctx *, enum flash_reg reg, uint8_t value, enum wrsr_target);
69void spi_prettyprint_status_register_bit(uint8_t status, int bit);
70int spi_prettyprint_status_register_plain(struct flashprog_flashctx *);
71int spi_prettyprint_status_register_default_welwip(struct flashprog_flashctx *);
72int spi_prettyprint_status_register_bp1_srwd(struct flashprog_flashctx *);
73int spi_prettyprint_status_register_bp2_srwd(struct flashprog_flashctx *);
74int spi_prettyprint_status_register_bp3_srwd(struct flashprog_flashctx *);
75int spi_prettyprint_status_register_bp4_srwd(struct flashprog_flashctx *);
76int spi_prettyprint_status_register_bp2_bpl(struct flashprog_flashctx *);
77int spi_prettyprint_status_register_bp2_tb_bpl(struct flashprog_flashctx *);
78int spi_disable_blockprotect(struct flashprog_flashctx *);
79int spi_disable_blockprotect_bp1_srwd(struct flashprog_flashctx *);
80int spi_disable_blockprotect_bp2_srwd(struct flashprog_flashctx *);
81int spi_disable_blockprotect_bp3_srwd(struct flashprog_flashctx *);
82int spi_disable_blockprotect_bp4_srwd(struct flashprog_flashctx *);
83int spi_prettyprint_status_register_amic_a25l032(struct flashprog_flashctx *);
84int spi_prettyprint_status_register_at25df(struct flashprog_flashctx *);
85int spi_prettyprint_status_register_at25df_sec(struct flashprog_flashctx *);
86int spi_prettyprint_status_register_at25f(struct flashprog_flashctx *);
87int spi_prettyprint_status_register_at25f512a(struct flashprog_flashctx *);
88int spi_prettyprint_status_register_at25f512b(struct flashprog_flashctx *);
89int spi_prettyprint_status_register_at25f4096(struct flashprog_flashctx *);
90int spi_prettyprint_status_register_at25fs010(struct flashprog_flashctx *);
91int spi_prettyprint_status_register_at25fs040(struct flashprog_flashctx *);
92int spi_prettyprint_status_register_at26df081a(struct flashprog_flashctx *);
93int spi_disable_blockprotect_at2x_global_unprotect(struct flashprog_flashctx *);
94int spi_disable_blockprotect_at2x_global_unprotect_sec(struct flashprog_flashctx *);
95int spi_disable_blockprotect_at25f(struct flashprog_flashctx *);
96int spi_disable_blockprotect_at25f512a(struct flashprog_flashctx *);
97int spi_disable_blockprotect_at25f512b(struct flashprog_flashctx *);
98int spi_disable_blockprotect_at25fs010(struct flashprog_flashctx *);
99int spi_disable_blockprotect_at25fs040(struct flashprog_flashctx *);
100int spi_prettyprint_status_register_en25s_wp(struct flashprog_flashctx *);
101int spi_prettyprint_status_register_n25q(struct flashprog_flashctx *);
102int spi_disable_blockprotect_n25q(struct flashprog_flashctx *);
103int spi_prettyprint_status_register_bp2_ep_srwd(struct flashprog_flashctx *);
104int spi_disable_blockprotect_bp2_ep_srwd(struct flashprog_flashctx *);
105int spi_prettyprint_status_register_sst25(struct flashprog_flashctx *);
106int spi_prettyprint_status_register_sst25vf016(struct flashprog_flashctx *);
107int spi_prettyprint_status_register_sst25vf040b(struct flashprog_flashctx *);
108int spi_disable_blockprotect_sst26_global_unprotect(struct flashprog_flashctx *);
109
110/* at45db.c */
111int spi_prepare_at45db(struct flashprog_flashctx *, enum preparation_steps);
112int spi_prettyprint_status_register_at45db(struct flashprog_flashctx *);
113int spi_disable_blockprotect_at45db(struct flashprog_flashctx *);
114int spi_read_at45db(struct flashprog_flashctx *, uint8_t *buf, unsigned int start, unsigned int len);
115int spi_read_at45db_e8(struct flashprog_flashctx *, uint8_t *buf, unsigned int start, unsigned int len);
116int spi_write_at45db(struct flashprog_flashctx *, const uint8_t *buf, unsigned int start, unsigned int len);
117int spi_erase_at45db_page(struct flashprog_flashctx *, unsigned int addr, unsigned int blocklen);
118int spi_erase_at45db_block(struct flashprog_flashctx *, unsigned int addr, unsigned int blocklen);
119int spi_erase_at45db_sector(struct flashprog_flashctx *, unsigned int addr, unsigned int blocklen);
120int spi_erase_at45db_chip(struct flashprog_flashctx *, unsigned int addr, unsigned int blocklen);
121int spi_erase_at45cs_sector(struct flashprog_flashctx *, unsigned int addr, unsigned int blocklen);
122
123/* spi95.c */
124int probe_spi_st95(struct flashprog_flashctx *);
125int spi_block_erase_emulation(struct flashprog_flashctx *, unsigned int addr, unsigned int blocklen);
126
127/* writeprotect_ranges.c */
128struct wp_bits;
129void decode_range_spi25(size_t *start, size_t *len, const struct wp_bits *, size_t chip_len);
130void decode_range_spi25_64k_block(size_t *start, size_t *len, const struct wp_bits *, size_t chip_len);
131void decode_range_spi25_bit_cmp(size_t *start, size_t *len, const struct wp_bits *, size_t chip_len);
132void decode_range_spi25_2x_block(size_t *start, size_t *len, const struct wp_bits *, size_t chip_len);
133
134/* sfdp.c */
135int probe_spi_sfdp(struct flashprog_flashctx *);
136
137#endif /* !__CHIPDRIVERS_SPI_H__ */