| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
#ifndef __SPI_FLASH_INTERNAL_H_ |
| 12 |
#define __SPI_FLASH_INTERNAL_H_ |
| 13 |
|
| 14 |
#include <comdef.h> |
| 15 |
|
| 16 |
#define CONFIG_SYS_HZ 12000000 |
| 17 |
#define SPI_FLASH_PROG_TIMEOUT (2 * CONFIG_SYS_HZ) |
| 18 |
#define SPI_FLASH_PAGE_ERASE_TIMEOUT (5 * CONFIG_SYS_HZ) |
| 19 |
#define SPI_FLASH_SECTOR_ERASE_TIMEOUT (10 * CONFIG_SYS_HZ) |
| 20 |
|
| 21 |
|
| 22 |
#define CMD_READ_ARRAY_SLOW 0x03 |
| 23 |
#define CMD_READ_ARRAY_FAST 0x0B |
| 24 |
#define CMD_READ_ARRAY_DUAL 0x3B |
| 25 |
#define CMD_READ_ARRAY_QUAD 0X6B |
| 26 |
#define CMD_READ_ARRAY_LEGACY 0xEB |
| 27 |
|
| 28 |
#define CMD_WRITE_STATUS 0x01 |
| 29 |
|
| 30 |
#define CMD_WRITE_STATUS_1 0x01 |
| 31 |
#define CMD_WRITE_STATUS_2 0x31 |
| 32 |
#define CMD_WRITE_STATUS_3 0x11 |
| 33 |
#define CMD_READ_STATUS_1 0x05 |
| 34 |
#define CMD_READ_STATUS_2 0x35 |
| 35 |
#define CMD_READ_STATUS_3 0x15 |
| 36 |
|
| 37 |
#define CMD_PAGE_PROGRAM 0x02 |
| 38 |
#define CMD_PAGE_PROGRAM_QUAD 0x32 |
| 39 |
#define CMD_WRITE_DISABLE 0x04 |
| 40 |
#define CMD_READ_STATUS 0x05 |
| 41 |
#define CMD_READ_STATUS1 0x35 |
| 42 |
#define CMD_WRITE_ENABLE 0x06 |
| 43 |
#define CMD_W25_FAST_READ 0x0b |
| 44 |
#define CMD_W25_SE 0x20 |
| 45 |
#define CMD_W25_BE 0xd8 |
| 46 |
#define CMD_W25_CE 0xc7 |
| 47 |
#define CMD_W25_DP 0xb9 |
| 48 |
#define CMD_W25_RES 0xab |
| 49 |
#define CMD_W25_BE_32 0x52 |
| 50 |
#define CMD_STATUS_ENABLE 0x50 |
| 51 |
|
| 52 |
|
| 53 |
#define STATUS_WIP 0x01 |
| 54 |
#define FLASH_ENABLE 0x02 |
| 55 |
#define STATUS_QE (0x01 << 1) |
| 56 |
|
| 57 |
|
| 58 |
int spi_flash_cmd(struct spi_slave *spi, u8 cmd, void *response, u32 len); |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
int spi_flash_cmd_read(struct spi_slave *spi, u8 *cmd,u32 cmd_len, |
| 65 |
void *data, u32 data_len); |
| 66 |
|
| 67 |
int spi_flash_cmd_read_fast(struct spi_flash *flash, u32 offset, |
| 68 |
u32 len, void *data, u32 mode); |
| 69 |
|
| 70 |
int spi_flash_read_mode(struct spi_flash *flash, u32 offset, |
| 71 |
u32 len, void *data, u32 mode); |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
int spi_flash_cmd_write(struct spi_slave *spi, u8 *cmd, u32 cmd_len, |
| 78 |
void *data, u32 data_len); |
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
int spi_flash_cmd_write_mode(struct spi_flash *flash, u32 offset, |
| 85 |
u32 len, void *buf, u32 mode); |
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
int spi_flash_cmd_write_enable(struct spi_flash *flash); |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
int spi_flash_cmd_write_disable(struct spi_slave *spi); |
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
int spi_flash_read_common(struct spi_flash *flash, u8 *cmd, |
| 102 |
u32 cmd_len, void *data, u32 data_len); |
| 103 |
|
| 104 |
|
| 105 |
int spi_flash_cmd_poll_bit(struct spi_flash *flash, unsigned long timeout, |
| 106 |
u8 cmd, u8 poll_bit); |
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
int spi_flash_cmd_wait_ready(struct spi_flash *flash, unsigned long timeout); |
| 113 |
|
| 114 |
|
| 115 |
int spi_flash_cmd_erase(struct spi_flash *flash, u8 erase_cmd, u32 offset, u32 len); |
| 116 |
int spi_flash_erase_mode(struct spi_flash *flash, u32 offset, u32 len, u32 mode); |
| 117 |
|
| 118 |
|
| 119 |
struct spi_flash *spi_flash_probe_spansion(struct spi_slave *spi, u8 *idcode); |
| 120 |
struct spi_flash *spi_flash_probe_atmel(struct spi_slave *spi, u8 *idcode); |
| 121 |
struct spi_flash *spi_flash_probe_eon(struct spi_slave *spi, u8 *idcode); |
| 122 |
struct spi_flash *spi_flash_probe_macronix(struct spi_slave *spi, u8 *idcode); |
| 123 |
struct spi_flash *spi_flash_probe_sst(struct spi_slave *spi, u8 *idcode); |
| 124 |
struct spi_flash *spi_flash_probe_stmicro(struct spi_slave *spi, u8 *idcode); |
| 125 |
struct spi_flash *spi_flash_probe_winbond(struct spi_slave *spi, u8 *idcode); |
| 126 |
struct spi_flash *spi_fram_probe_ramtron(struct spi_slave *spi, u8 *idcode); |
| 127 |
struct spi_flash *spi_flash_probe_gigadevice(struct spi_slave *spi, u8 *idcode); |
| 128 |
struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs, |
| 129 |
unsigned int max_hz, u32 mode, u32 fifo_width); |
| 130 |
|
| 131 |
|
| 132 |
#endif |
| 133 |
|