blob: 86a82a00c008c52a1ceec0b87340f0dcda85f68c [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
Nico Hubere7598392026-06-23 22:29:15 +020056/* m28f.c */
57int write_m28f(struct flashprog_flashctx *, const uint8_t *src, unsigned int pos, unsigned int len);
58int erase_m28f(struct flashprog_flashctx *, unsigned int addr, unsigned int blocksize);
59
Nico Huber10337f72026-03-04 19:57:27 +010060/* sst28sf040.c */
61int erase_chip_28sf040(struct flashprog_flashctx *, unsigned int addr, unsigned int blocklen);
62int erase_sector_28sf040(struct flashprog_flashctx *, unsigned int address, unsigned int sector_size);
63int write_28sf040(struct flashprog_flashctx *, const uint8_t *buf, unsigned int start, unsigned int len);
64int unprotect_28sf040(struct flashprog_flashctx *);
65int protect_28sf040(struct flashprog_flashctx *);
66
67/* sst49lfxxxc.c */
68int erase_sector_49lfxxxc(struct flashprog_flashctx *, unsigned int address, unsigned int sector_size);
69
70/* sst_fwhub.c */
71int printlock_sst_fwhub(struct flashprog_flashctx *);
72int unlock_sst_fwhub(struct flashprog_flashctx *);
73
74/* w39.c */
75int printlock_w39f010(struct flashprog_flashctx *);
76int printlock_w39l010(struct flashprog_flashctx *);
77int printlock_w39l020(struct flashprog_flashctx *);
78int printlock_w39l040(struct flashprog_flashctx *);
79int printlock_w39v040a(struct flashprog_flashctx *);
80int printlock_w39v040b(struct flashprog_flashctx *);
81int printlock_w39v040c(struct flashprog_flashctx *);
82int printlock_w39v040fa(struct flashprog_flashctx *);
83int printlock_w39v040fb(struct flashprog_flashctx *);
84int printlock_w39v040fc(struct flashprog_flashctx *);
85int printlock_w39v080a(struct flashprog_flashctx *);
86int printlock_w39v080fa(struct flashprog_flashctx *);
87int printlock_w39v080fa_dual(struct flashprog_flashctx *);
88int printlock_at49f(struct flashprog_flashctx *);
89
90/* w29ee011.c */
Nico Huber2cadbe32026-03-05 18:34:57 +010091struct found_id *probe_w29ee011(const struct bus_probe *, const struct master_common *, const struct flashchip *);
Nico Huber10337f72026-03-04 19:57:27 +010092
93/* stm50.c */
94int erase_sector_stm50(struct flashprog_flashctx *, unsigned int block, unsigned int blocksize);
95
96/* en29lv640b.c */
97int probe_en29lv640b(struct flashprog_flashctx *);
98int write_en29lv640b(struct flashprog_flashctx *, const uint8_t *buf, unsigned int start, unsigned int len);
99
100/* memory_bus.c */
Nico Huber2ae63012026-03-04 21:06:45 +0100101struct memory_chip_info {
102 chipsize_t chip_size;
103 feature_bits_t chip_features;
Nico Huber2e947462026-03-07 17:04:59 +0100104 signed int probe_timing;
Nico Huber2ae63012026-03-04 21:06:45 +0100105};
106
107struct memory_found_id {
108 struct found_id generic;
109 struct memory_chip_info memory_info;
110};
111
112struct memory_found_id *alloc_memory_found_id(void);
113
Nico Huber3d6bd5a2026-02-21 15:47:21 +0100114struct par_master;
115void *programmer_map_flash_data(const struct par_master *, chipsize_t, const char *descr);
116void programmer_unmap_flash_region(const struct par_master *, void *, chipsize_t);
117
Nico Huber517d9372026-03-14 21:48:36 +0100118int prepare_memory_access(struct flashprog_flashctx *);
119int prepare_memory_register_access(struct flashprog_flashctx *);
Nico Huber10337f72026-03-04 19:57:27 +0100120void finish_memory_access(struct flashprog_flashctx *);
121
122#endif /* !__CHIPDRIVERS_MEMORY_BUS_H__ */