blob: 02794eebab0a30124fd5e9a7f0a811dfa414ba32 [file] [log] [blame]
Nico Huber10337f72026-03-04 19:57:27 +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_MEMORY_BUS_H__
17#define __CHIPDRIVERS_MEMORY_BUS_H__ 1
18
19#include <stdint.h>
20
21struct flashprog_flashctx;
Nico Huber3a2a4d52026-03-01 12:15:23 +010022struct master_common;
23struct bus_probe;
24struct flashchip;
Nico Huber10337f72026-03-04 19:57:27 +010025
26/* 82802ab.c */
Nico Huber3a2a4d52026-03-01 12:15:23 +010027struct found_id *probe_82802ab(const struct bus_probe *, const struct master_common *, const struct flashchip *);
Nico Huber10337f72026-03-04 19:57:27 +010028uint8_t wait_82802ab(struct flashprog_flashctx *);
Nico Huber10337f72026-03-04 19:57:27 +010029int erase_block_82802ab(struct flashprog_flashctx *, unsigned int page, unsigned int pagesize);
30int write_82802ab(struct flashprog_flashctx *, const uint8_t *buf, unsigned int start, unsigned int len);
31void print_status_82802ab(uint8_t status);
32int unlock_28f004s5(struct flashprog_flashctx *);
33int unlock_lh28f008bjt(struct flashprog_flashctx *);
34
35/* jedec.c */
36uint8_t oddparity(uint8_t val);
37void toggle_ready_jedec(const struct flashprog_flashctx *, chipaddr dst);
38void data_polling_jedec(const struct flashprog_flashctx *, chipaddr dst, uint8_t data);
39int probe_jedec(struct flashprog_flashctx *);
40int probe_jedec_29gl(struct flashprog_flashctx *);
41int write_jedec(struct flashprog_flashctx *, const uint8_t *buf, unsigned int start, unsigned int len);
42int write_jedec_1(struct flashprog_flashctx *, const uint8_t *buf, unsigned int start, unsigned int len);
43int erase_sector_jedec(struct flashprog_flashctx *, unsigned int page, unsigned int pagesize);
44int erase_block_jedec(struct flashprog_flashctx *, unsigned int page, unsigned int blocksize);
45int erase_chip_block_jedec(struct flashprog_flashctx *, unsigned int page, unsigned int blocksize);
46
47int unlock_regspace2_uniform_32k(struct flashprog_flashctx *);
48int unlock_regspace2_uniform_64k(struct flashprog_flashctx *);
49int unlock_regspace2_block_eraser_0(struct flashprog_flashctx *);
50int unlock_regspace2_block_eraser_1(struct flashprog_flashctx *);
51int printlock_regspace2_uniform_64k(struct flashprog_flashctx *);
52int printlock_regspace2_block_eraser_0(struct flashprog_flashctx *);
53int printlock_regspace2_block_eraser_1(struct flashprog_flashctx *);
54
55/* sst28sf040.c */
56int erase_chip_28sf040(struct flashprog_flashctx *, unsigned int addr, unsigned int blocklen);
57int erase_sector_28sf040(struct flashprog_flashctx *, unsigned int address, unsigned int sector_size);
58int write_28sf040(struct flashprog_flashctx *, const uint8_t *buf, unsigned int start, unsigned int len);
59int unprotect_28sf040(struct flashprog_flashctx *);
60int protect_28sf040(struct flashprog_flashctx *);
61
62/* sst49lfxxxc.c */
63int erase_sector_49lfxxxc(struct flashprog_flashctx *, unsigned int address, unsigned int sector_size);
64
65/* sst_fwhub.c */
66int printlock_sst_fwhub(struct flashprog_flashctx *);
67int unlock_sst_fwhub(struct flashprog_flashctx *);
68
69/* w39.c */
70int printlock_w39f010(struct flashprog_flashctx *);
71int printlock_w39l010(struct flashprog_flashctx *);
72int printlock_w39l020(struct flashprog_flashctx *);
73int printlock_w39l040(struct flashprog_flashctx *);
74int printlock_w39v040a(struct flashprog_flashctx *);
75int printlock_w39v040b(struct flashprog_flashctx *);
76int printlock_w39v040c(struct flashprog_flashctx *);
77int printlock_w39v040fa(struct flashprog_flashctx *);
78int printlock_w39v040fb(struct flashprog_flashctx *);
79int printlock_w39v040fc(struct flashprog_flashctx *);
80int printlock_w39v080a(struct flashprog_flashctx *);
81int printlock_w39v080fa(struct flashprog_flashctx *);
82int printlock_w39v080fa_dual(struct flashprog_flashctx *);
83int printlock_at49f(struct flashprog_flashctx *);
84
85/* w29ee011.c */
Nico Huber2cadbe32026-03-05 18:34:57 +010086struct found_id *probe_w29ee011(const struct bus_probe *, const struct master_common *, const struct flashchip *);
Nico Huber10337f72026-03-04 19:57:27 +010087
88/* stm50.c */
89int erase_sector_stm50(struct flashprog_flashctx *, unsigned int block, unsigned int blocksize);
90
91/* en29lv640b.c */
92int probe_en29lv640b(struct flashprog_flashctx *);
93int write_en29lv640b(struct flashprog_flashctx *, const uint8_t *buf, unsigned int start, unsigned int len);
94
95/* memory_bus.c */
Nico Huber2ae63012026-03-04 21:06:45 +010096struct memory_chip_info {
97 chipsize_t chip_size;
98 feature_bits_t chip_features;
99};
100
101struct memory_found_id {
102 struct found_id generic;
103 struct memory_chip_info memory_info;
104};
105
106struct memory_found_id *alloc_memory_found_id(void);
107
Nico Huber3d6bd5a2026-02-21 15:47:21 +0100108struct par_master;
109void *programmer_map_flash_data(const struct par_master *, chipsize_t, const char *descr);
110void programmer_unmap_flash_region(const struct par_master *, void *, chipsize_t);
111
Nico Huber10337f72026-03-04 19:57:27 +0100112enum preparation_steps;
113int prepare_memory_access(struct flashprog_flashctx *, enum preparation_steps);
114int prepare_memory_register_access(struct flashprog_flashctx *, enum preparation_steps);
115void finish_memory_access(struct flashprog_flashctx *);
116
117#endif /* !__CHIPDRIVERS_MEMORY_BUS_H__ */