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