blob: 6ffa367f8b4b03787cd8932d7e38379d227a0b5b [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 */
Nico Huber2e947462026-03-07 17:04:59 +010036struct found_id *probe_jedec(const struct bus_probe *, const struct master_common *, const struct flashchip *);
37struct found_id *probe_jedec_29gl(const struct bus_probe *, const struct master_common *, const struct flashchip *);
38
Nico Huber10337f72026-03-04 19:57:27 +010039uint8_t oddparity(uint8_t val);
40void toggle_ready_jedec(const struct flashprog_flashctx *, chipaddr dst);
41void data_polling_jedec(const struct flashprog_flashctx *, chipaddr dst, uint8_t data);
Nico Huber10337f72026-03-04 19:57:27 +010042int write_jedec(struct flashprog_flashctx *, const uint8_t *buf, unsigned int start, unsigned int len);
43int write_jedec_1(struct flashprog_flashctx *, const uint8_t *buf, unsigned int start, unsigned int len);
44int erase_sector_jedec(struct flashprog_flashctx *, unsigned int page, unsigned int pagesize);
45int erase_block_jedec(struct flashprog_flashctx *, unsigned int page, unsigned int blocksize);
46int erase_chip_block_jedec(struct flashprog_flashctx *, unsigned int page, unsigned int blocksize);
47
48int unlock_regspace2_uniform_32k(struct flashprog_flashctx *);
49int unlock_regspace2_uniform_64k(struct flashprog_flashctx *);
50int unlock_regspace2_block_eraser_0(struct flashprog_flashctx *);
51int unlock_regspace2_block_eraser_1(struct flashprog_flashctx *);
52int printlock_regspace2_uniform_64k(struct flashprog_flashctx *);
53int printlock_regspace2_block_eraser_0(struct flashprog_flashctx *);
54int printlock_regspace2_block_eraser_1(struct flashprog_flashctx *);
55
56/* sst28sf040.c */
57int erase_chip_28sf040(struct flashprog_flashctx *, unsigned int addr, unsigned int blocklen);
58int erase_sector_28sf040(struct flashprog_flashctx *, unsigned int address, unsigned int sector_size);
59int write_28sf040(struct flashprog_flashctx *, const uint8_t *buf, unsigned int start, unsigned int len);
60int unprotect_28sf040(struct flashprog_flashctx *);
61int protect_28sf040(struct flashprog_flashctx *);
62
63/* sst49lfxxxc.c */
64int erase_sector_49lfxxxc(struct flashprog_flashctx *, unsigned int address, unsigned int sector_size);
65
66/* sst_fwhub.c */
67int printlock_sst_fwhub(struct flashprog_flashctx *);
68int unlock_sst_fwhub(struct flashprog_flashctx *);
69
70/* w39.c */
71int printlock_w39f010(struct flashprog_flashctx *);
72int printlock_w39l010(struct flashprog_flashctx *);
73int printlock_w39l020(struct flashprog_flashctx *);
74int printlock_w39l040(struct flashprog_flashctx *);
75int printlock_w39v040a(struct flashprog_flashctx *);
76int printlock_w39v040b(struct flashprog_flashctx *);
77int printlock_w39v040c(struct flashprog_flashctx *);
78int printlock_w39v040fa(struct flashprog_flashctx *);
79int printlock_w39v040fb(struct flashprog_flashctx *);
80int printlock_w39v040fc(struct flashprog_flashctx *);
81int printlock_w39v080a(struct flashprog_flashctx *);
82int printlock_w39v080fa(struct flashprog_flashctx *);
83int printlock_w39v080fa_dual(struct flashprog_flashctx *);
84int printlock_at49f(struct flashprog_flashctx *);
85
86/* w29ee011.c */
Nico Huber2cadbe32026-03-05 18:34:57 +010087struct found_id *probe_w29ee011(const struct bus_probe *, const struct master_common *, const struct flashchip *);
Nico Huber10337f72026-03-04 19:57:27 +010088
89/* stm50.c */
90int erase_sector_stm50(struct flashprog_flashctx *, unsigned int block, unsigned int blocksize);
91
92/* en29lv640b.c */
93int probe_en29lv640b(struct flashprog_flashctx *);
94int write_en29lv640b(struct flashprog_flashctx *, const uint8_t *buf, unsigned int start, unsigned int len);
95
96/* memory_bus.c */
Nico Huber2ae63012026-03-04 21:06:45 +010097struct memory_chip_info {
98 chipsize_t chip_size;
99 feature_bits_t chip_features;
Nico Huber2e947462026-03-07 17:04:59 +0100100 signed int probe_timing;
Nico Huber2ae63012026-03-04 21:06:45 +0100101};
102
103struct memory_found_id {
104 struct found_id generic;
105 struct memory_chip_info memory_info;
106};
107
108struct memory_found_id *alloc_memory_found_id(void);
109
Nico Huber3d6bd5a2026-02-21 15:47:21 +0100110struct par_master;
111void *programmer_map_flash_data(const struct par_master *, chipsize_t, const char *descr);
112void programmer_unmap_flash_region(const struct par_master *, void *, chipsize_t);
113
Nico Huber10337f72026-03-04 19:57:27 +0100114enum preparation_steps;
115int prepare_memory_access(struct flashprog_flashctx *, enum preparation_steps);
116int prepare_memory_register_access(struct flashprog_flashctx *, enum preparation_steps);
117void finish_memory_access(struct flashprog_flashctx *);
118
119#endif /* !__CHIPDRIVERS_MEMORY_BUS_H__ */