| 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 |
* Header file for flash chip drivers. Included from flash.h. |
| 16 |
* As a general rule, every function listed here should take a pointer to |
| 17 |
* struct flashctx as first parameter. |
| 18 |
*/ |
| 19 |
|
| 20 |
#ifndef __CHIPDRIVERS_H__ |
| 21 |
#define __CHIPDRIVERS_H__ 1 |
| 22 |
|
| 23 |
#include "flash.h" /* for chipaddr and flashctx */ |
| 24 |
|
| 25 |
/* spi.c */ |
| 26 |
int spi_aai_write(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); |
| 27 |
int spi_chip_write_256(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); |
| 28 |
int spi_chip_read(struct flashctx *flash, uint8_t *buf, unsigned int start, int unsigned len); |
| 29 |
bool spi_probe_opcode(const struct flashctx *flash, uint8_t opcode); |
| 30 |
|
| 31 |
/* spi25.c */ |
| 32 |
int probe_spi_rdid(struct flashctx *flash); |
| 33 |
int probe_spi_rdid4(struct flashctx *flash); |
| 34 |
int probe_spi_rems(struct flashctx *flash); |
| 35 |
int probe_spi_res1(struct flashctx *flash); |
| 36 |
int probe_spi_res2(struct flashctx *flash); |
| 37 |
int probe_spi_res3(struct flashctx *flash); |
| 38 |
int probe_spi_at25f(struct flashctx *flash); |
| 39 |
int spi_write_enable(struct flashctx *flash); |
| 40 |
int spi_write_disable(struct flashctx *flash); |
| 41 |
int spi_block_erase_20(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 42 |
int spi_block_erase_21(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 43 |
int spi_block_erase_50(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 44 |
int spi_block_erase_52(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 45 |
int spi_block_erase_53(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 46 |
int spi_block_erase_5c(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 47 |
int spi_block_erase_60(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 48 |
int spi_block_erase_62(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 49 |
int spi_block_erase_81(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 50 |
int spi_block_erase_c4(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 51 |
int spi_block_erase_c7(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 52 |
int spi_block_erase_d7(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 53 |
int spi_block_erase_d8(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 54 |
int spi_block_erase_db(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 55 |
int spi_block_erase_dc(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 56 |
enum block_erase_func spi25_get_erasefn_from_opcode(uint8_t opcode); |
| 57 |
const uint8_t *spi_get_opcode_from_erasefn(enum block_erase_func func); |
| 58 |
int spi_chip_write_1(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); |
| 59 |
int spi_nbyte_read(struct flashctx *flash, unsigned int addr, uint8_t *bytes, unsigned int len); |
| 60 |
int spi_read_chunked(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len, unsigned int chunksize); |
| 61 |
int spi_write_chunked(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len, unsigned int chunksize); |
| 62 |
int spi_enter_4ba(struct flashctx *flash); |
| 63 |
int spi_exit_4ba(struct flashctx *flash); |
| 64 |
int spi_set_extended_address(struct flashctx *, uint8_t addr_high); |
| 65 |
|
| 66 |
|
| 67 |
/* spi25_statusreg.c */ |
| 68 |
int spi_read_register(const struct flashctx *flash, enum flash_reg reg, uint8_t *value); |
| 69 |
int spi_write_register(const struct flashctx *flash, enum flash_reg reg, uint8_t value); |
| 70 |
void spi_prettyprint_status_register_bit(uint8_t status, int bit); |
| 71 |
|
| 72 |
/* sfdp.c */ |
| 73 |
int probe_spi_sfdp(struct flashctx *flash); |
| 74 |
|
| 75 |
/* opaque.c */ |
| 76 |
int probe_opaque(struct flashctx *flash); |
| 77 |
int read_opaque(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len); |
| 78 |
int write_opaque(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); |
| 79 |
int erase_opaque(struct flashctx *flash, unsigned int blockaddr, unsigned int blocklen); |
| 80 |
|
| 81 |
/* at45db.c */ |
| 82 |
int probe_spi_at45db(struct flashctx *flash); |
| 83 |
int spi_prettyprint_status_register_at45db(struct flashctx *flash); |
| 84 |
int spi_disable_blockprotect_at45db(struct flashctx *flash); |
| 85 |
int spi_read_at45db(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len); |
| 86 |
int spi_read_at45db_e8(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len); |
| 87 |
int spi_write_at45db(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); |
| 88 |
int spi_erase_at45db_page(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 89 |
int spi_erase_at45db_block(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 90 |
int spi_erase_at45db_sector(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 91 |
int spi_erase_at45db_chip(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 92 |
int spi_erase_at45cs_sector(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 93 |
|
| 94 |
/* 82802ab.c */ |
| 95 |
uint8_t wait_82802ab(struct flashctx *flash); |
| 96 |
int probe_82802ab(struct flashctx *flash); |
| 97 |
int erase_block_82802ab(struct flashctx *flash, unsigned int page, unsigned int pagesize); |
| 98 |
int write_82802ab(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); |
| 99 |
void print_status_82802ab(uint8_t status); |
| 100 |
blockprotect_func_t *lookup_82802ab_blockprotect_func_ptr(const struct flashchip *const chip); |
| 101 |
|
| 102 |
/* jedec.c */ |
| 103 |
uint8_t oddparity(uint8_t val); |
| 104 |
void toggle_ready_jedec(const struct flashctx *flash, chipaddr dst); |
| 105 |
void data_polling_jedec(const struct flashctx *flash, chipaddr dst, uint8_t data); |
| 106 |
int probe_jedec(struct flashctx *flash); |
| 107 |
int probe_jedec_29gl(struct flashctx *flash); |
| 108 |
int write_jedec(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); |
| 109 |
int write_jedec_1(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); |
| 110 |
int erase_sector_jedec(struct flashctx *flash, unsigned int page, unsigned int pagesize); |
| 111 |
int erase_block_jedec(struct flashctx *flash, unsigned int page, unsigned int blocksize); |
| 112 |
int erase_chip_block_jedec(struct flashctx *flash, unsigned int page, unsigned int blocksize); |
| 113 |
|
| 114 |
blockprotect_func_t *lookup_jedec_blockprotect_func_ptr(const struct flashchip *const chip); |
| 115 |
int printlock_regspace2_uniform_64k(struct flashctx *flash); |
| 116 |
int printlock_regspace2_block_eraser_0(struct flashctx *flash); |
| 117 |
int printlock_regspace2_block_eraser_1(struct flashctx *flash); |
| 118 |
|
| 119 |
/* sst28sf040.c */ |
| 120 |
int erase_chip_28sf040(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 121 |
int erase_sector_28sf040(struct flashctx *flash, unsigned int address, unsigned int sector_size); |
| 122 |
int write_28sf040(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); |
| 123 |
int unprotect_28sf040(struct flashctx *flash); |
| 124 |
int protect_28sf040(struct flashctx *flash); |
| 125 |
|
| 126 |
/* sst49lfxxxc.c */ |
| 127 |
int erase_sector_49lfxxxc(struct flashctx *flash, unsigned int address, unsigned int sector_size); |
| 128 |
|
| 129 |
/* sst_fwhub.c */ |
| 130 |
int printlock_sst_fwhub(struct flashctx *flash); |
| 131 |
int unlock_sst_fwhub(struct flashctx *flash); |
| 132 |
|
| 133 |
/* s25f.c */ |
| 134 |
int probe_spi_big_spansion(struct flashctx *flash); |
| 135 |
int s25fl_block_erase(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 136 |
int s25fs_block_erase_d8(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 137 |
|
| 138 |
/* w39.c */ |
| 139 |
int printlock_w39f010(struct flashctx * flash); |
| 140 |
int printlock_w39l010(struct flashctx * flash); |
| 141 |
int printlock_w39l020(struct flashctx * flash); |
| 142 |
int printlock_w39l040(struct flashctx * flash); |
| 143 |
int printlock_w39v040a(struct flashctx *flash); |
| 144 |
int printlock_w39v040b(struct flashctx *flash); |
| 145 |
int printlock_w39v040c(struct flashctx *flash); |
| 146 |
int printlock_w39v040fa(struct flashctx *flash); |
| 147 |
int printlock_w39v040fb(struct flashctx *flash); |
| 148 |
int printlock_w39v040fc(struct flashctx *flash); |
| 149 |
int printlock_w39v080a(struct flashctx *flash); |
| 150 |
int printlock_w39v080fa(struct flashctx *flash); |
| 151 |
int printlock_w39v080fa_dual(struct flashctx *flash); |
| 152 |
int printlock_at49f(struct flashctx *flash); |
| 153 |
|
| 154 |
/* w29ee011.c */ |
| 155 |
int probe_w29ee011(struct flashctx *flash); |
| 156 |
bool w29ee011_can_override(const char *const chip_name, const char *const override_chip); |
| 157 |
|
| 158 |
/* stm50.c */ |
| 159 |
int erase_sector_stm50(struct flashctx *flash, unsigned int block, unsigned int blocksize); |
| 160 |
|
| 161 |
/* en29lv640b.c */ |
| 162 |
int probe_en29lv640b(struct flashctx *flash); |
| 163 |
int write_en29lv640b(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); |
| 164 |
|
| 165 |
/* edi.c */ |
| 166 |
int edi_chip_block_erase(struct flashctx *flash, unsigned int page, unsigned int size); |
| 167 |
int edi_chip_write(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); |
| 168 |
int edi_chip_read(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len); |
| 169 |
int edi_probe_kb9012(struct flashctx *flash); |
| 170 |
|
| 171 |
/* spi95.c */ |
| 172 |
int probe_spi_st95(struct flashctx *flash); |
| 173 |
int spi_block_erase_emulation(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 174 |
|
| 175 |
/* writeprotect_ranges.c */ |
| 176 |
void decode_range_spi25(size_t *start, size_t *len, const struct wp_bits *, size_t chip_len); |
| 177 |
void decode_range_spi25_64k_block(size_t *start, size_t *len, const struct wp_bits *, size_t chip_len); |
| 178 |
void decode_range_spi25_bit_cmp(size_t *start, size_t *len, const struct wp_bits *, size_t chip_len); |
| 179 |
void decode_range_spi25_2x_block(size_t *start, size_t *len, const struct wp_bits *, size_t chip_len); |
| 180 |
|
| 181 |
#endif /* !__CHIPDRIVERS_H__ */ |