2 * Copyright (C) 2015 Piotr Dymacz <piotr@dymacz.pl>
3 * Copyright (C) 2005 Wolfgang Denk, DENX Software Engineering, <wd@denx.de>
5 * SPDX-License-Identifier:GPL-2.0
14 * Struct for info about FLASH chip/bank, with:
15 * - manufacturer and model names
16 * - JEDEC ID (combined device & manufacturer code)
17 * - total bank size in bytes
18 * - size of erase unit in bytes
20 * - size of program page in bytes
21 * - number of erase units
23 * - physical sector start addresses
35 u32 start[CFG_MAX_FLASH_SECT];
38 extern flash_info_t flash_info[];
41 * Struct for info about supported SPI NOR FLASH chips, with:
43 * - JEDEC ID (combined device & manufacturer code)
44 * - total size in bytes
45 * - size of erase unit in bytes
46 * - size of program page in bytes
58 extern const spi_nor_ids_info_t spi_nor_ids[];
59 extern const u32 spi_nor_ids_count;
63 u32 flash_erase(flash_info_t *info, u32 s_first, u32 s_last);
64 const char *flash_manuf_name(u32 jedec_id);
66 extern int flash_sect_erase(ulong addr_first, ulong addr_last);
69 extern int flash_write(char *, ulong, ulong);
70 extern flash_info_t *addr2info(ulong);
71 extern u32 write_buff(flash_info_t *info, uchar *src, ulong addr, ulong cnt);
74 #define SIZE_4KiB 4 * 1024
75 #define SIZE_64KiB 64 * 1024
77 #define SIZE_4MiB 4 * 1024 * 1024
78 #define SIZE_8MiB 8 * 1024 * 1024
79 #define SIZE_16MiB 16 * 1024 * 1024
80 #define SIZE_32MiB 32 * 1024 * 1024
81 #define SIZE_64MiB 64 * 1024 * 1024
83 /* Return codes from flash_write(): */
86 #define ERR_NOT_ERASED 2
87 #define ERR_PROTECTED 4
90 #define ERR_UNKNOWN_FLASH_VENDOR 32
91 #define ERR_UNKNOWN_FLASH_TYPE 64
92 #define ERR_PROG_ERROR 128
94 /* FLASH vendors IDs */
95 #define FLASH_VENDOR_JEDEC_ATMEL 0x1F
96 #define FLASH_VENDOR_JEDEC_EON 0x1C
97 #define FLASH_VENDOR_JEDEC_MACRONIX 0xC2
98 #define FLASH_VENDOR_JEDEC_MICRON 0x20
99 #define FLASH_VENDOR_JEDEC_SPANSION 0x01
100 #define FLASH_VENDOR_JEDEC_WINBOND 0xEF
103 #define FLASH_UNKNOWN 0xFFFFFF
104 #define FLASH_CUSTOM 0x111111
106 /* Basic SPI FLASH commands */
107 #define SPI_FLASH_CMD_WRSR 0x01
108 #define SPI_FLASH_CMD_PP 0x02
109 #define SPI_FLASH_CMD_READ 0x03
110 #define SPI_FLASH_CMD_WRDI 0x04
111 #define SPI_FLASH_CMD_RDSR 0x05
112 #define SPI_FLASH_CMD_WREN 0x06
114 /* SPI FLASH erase related commands */
115 #define SPI_FLASH_CMD_ES_4KB 0x20
116 #define SPI_FLASH_CMD_ES_32KB 0x52
117 #define SPI_FLASH_CMD_ES_64KB 0xD8
118 #define SPI_FLASH_CMD_ES_ALL 0xC7
120 /* Other SPI FLASH commands */
121 #define SPI_FLASH_CMD_JEDEC 0x9F
122 #define SPI_FLASH_CMD_SFDP 0x5A
124 /* SFDP related defines */
125 #define SPI_FLASH_SFDP_SIGN 0x50444653
127 #endif /* !CFG_NO_FLASH */
129 #endif /* _FLASH_H_ */