Boris Baykov | 50a5660 | 2016-06-11 18:28:59 +0200 | [diff] [blame^] | 1 | /* |
| 2 | * This file is part of the flashrom project. |
| 3 | * |
| 4 | * Copyright (C) 2014 Boris Baykov |
| 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; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | */ |
| 20 | |
| 21 | /* |
| 22 | * JEDEC flash chips instructions for 4-bytes addressing |
| 23 | * SPI chip driver functions for 4-bytes addressing |
| 24 | */ |
| 25 | |
| 26 | #ifndef __SPI_4BA_H__ |
| 27 | #define __SPI_4BA_H__ 1 |
| 28 | |
| 29 | /* Enter 4-byte Address Mode */ |
| 30 | #define JEDEC_ENTER_4_BYTE_ADDR_MODE 0xB7 |
| 31 | #define JEDEC_ENTER_4_BYTE_ADDR_MODE_OUTSIZE 0x01 |
| 32 | #define JEDEC_ENTER_4_BYTE_ADDR_MODE_INSIZE 0x00 |
| 33 | |
| 34 | /* Exit 4-byte Address Mode */ |
| 35 | #define JEDEC_EXIT_4_BYTE_ADDR_MODE 0xE9 |
| 36 | #define JEDEC_EXIT_4_BYTE_ADDR_MODE_OUTSIZE 0x01 |
| 37 | #define JEDEC_EXIT_4_BYTE_ADDR_MODE_INSIZE 0x00 |
| 38 | |
| 39 | /* enter 4-bytes addressing mode */ |
| 40 | int spi_enter_4ba_b7(struct flashctx *flash); |
| 41 | int spi_enter_4ba_b7_we(struct flashctx *flash); |
| 42 | |
| 43 | /* read/write flash bytes in 4-bytes addressing mode */ |
| 44 | int spi_byte_program_4ba(struct flashctx *flash, unsigned int addr, uint8_t databyte); |
| 45 | int spi_nbyte_program_4ba(struct flashctx *flash, unsigned int addr, const uint8_t *bytes, unsigned int len); |
| 46 | int spi_nbyte_read_4ba(struct flashctx *flash, unsigned int addr, uint8_t *bytes, unsigned int len); |
| 47 | |
| 48 | /* erase flash bytes in 4-bytes addressing mode */ |
| 49 | int spi_block_erase_20_4ba(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 50 | int spi_block_erase_52_4ba(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 51 | int spi_block_erase_d8_4ba(struct flashctx *flash, unsigned int addr, unsigned int blocklen); |
| 52 | |
| 53 | |
| 54 | #endif /* __SPI_4BA_H__ */ |