blob: 2d191d9a1b57a29db9e259a0605d82d2535638bb [file] [log] [blame]
Patrick Georgiac959032020-05-05 22:49:26 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Kyösti Mälkki96d92762014-11-11 15:04:38 +02002
Elyes HAOUAS361a9352019-12-18 21:26:33 +01003#include <commonlib/helpers.h>
Kyösti Mälkki96d92762014-11-11 15:04:38 +02004#include <spi_flash.h>
Furquan Shaikhc28984d2016-11-20 21:04:00 -08005#include <spi-generic.h>
Furquan Shaikh810e2cd2016-12-05 20:32:24 -08006
Kyösti Mälkki96d92762014-11-11 15:04:38 +02007#include "spi_flash_internal.h"
8
9/* M25Pxx-specific commands */
10#define CMD_AT25_WREN 0x06 /* Write Enable */
11#define CMD_AT25_WRDI 0x04 /* Write Disable */
12#define CMD_AT25_RDSR 0x05 /* Read Status Register */
13#define CMD_AT25_WRSR 0x01 /* Write Status Register */
14#define CMD_AT25_READ 0x03 /* Read Data Bytes */
15#define CMD_AT25_FAST_READ 0x0b /* Read Data Bytes at Higher Speed */
16#define CMD_AT25_PP 0x02 /* Page Program */
17#define CMD_AT25_SE 0x20 /* Sector (4K) Erase */
18#define CMD_AT25_BE 0xd8 /* Block (64K) Erase */
19#define CMD_AT25_CE 0xc7 /* Chip Erase */
20#define CMD_AT25_DP 0xb9 /* Deep Power-down */
21#define CMD_AT25_RES 0xab /* Release from DP, and Read Signature */
22
Aaron Durbina6c73c82020-01-11 23:18:51 -070023static const struct spi_flash_part_id flash_table[] = {
Kyösti Mälkki96d92762014-11-11 15:04:38 +020024 {
Aaron Durbinfc7b9532020-01-23 11:45:30 -070025 /* AT25X16 */
26 .id[0] = 0x3015,
Aaron Durbina6c73c82020-01-11 23:18:51 -070027 .nr_sectors_shift = 9,
Kyösti Mälkki96d92762014-11-11 15:04:38 +020028 },
29 {
Aaron Durbinfc7b9532020-01-23 11:45:30 -070030 /* AT25DF32 */
31 .id[0] = 0x47,
Aaron Durbina6c73c82020-01-11 23:18:51 -070032 .nr_sectors_shift = 10,
Kyösti Mälkki96d92762014-11-11 15:04:38 +020033 },
34 {
Aaron Durbinfc7b9532020-01-23 11:45:30 -070035 /* AT25X64 */
36 .id[0] = 0x3017,
Aaron Durbina6c73c82020-01-11 23:18:51 -070037 .nr_sectors_shift = 11,
Kyösti Mälkki96d92762014-11-11 15:04:38 +020038 },
39 {
Aaron Durbinfc7b9532020-01-23 11:45:30 -070040 /* AT25Q16 */
41 .id[0] = 0x4015,
Aaron Durbina6c73c82020-01-11 23:18:51 -070042 .nr_sectors_shift = 9,
Kyösti Mälkki96d92762014-11-11 15:04:38 +020043 },
44 {
Aaron Durbinfc7b9532020-01-23 11:45:30 -070045 /* AT25Q32 */
46 .id[0] = 0x4016,
Aaron Durbina6c73c82020-01-11 23:18:51 -070047 .nr_sectors_shift = 10,
Kyösti Mälkki96d92762014-11-11 15:04:38 +020048 },
49 {
Aaron Durbinfc7b9532020-01-23 11:45:30 -070050 /* AT25Q64 */
51 .id[0] = 0x4017,
Aaron Durbina6c73c82020-01-11 23:18:51 -070052 .nr_sectors_shift = 11,
Kyösti Mälkki96d92762014-11-11 15:04:38 +020053 },
54 {
Aaron Durbinfc7b9532020-01-23 11:45:30 -070055 /* AT25Q128 */
56 .id[0] = 0x4018,
Aaron Durbina6c73c82020-01-11 23:18:51 -070057 .nr_sectors_shift = 12,
Kyösti Mälkki96d92762014-11-11 15:04:38 +020058 },
59};
60
Aaron Durbin5abeb062020-01-12 15:12:18 -070061const struct spi_flash_vendor_info spi_flash_atmel_vi = {
62 .id = VENDOR_ID_ATMEL,
63 .page_size_shift = 8,
64 .sector_size_kib_shift = 2,
Aaron Durbinfc7b9532020-01-23 11:45:30 -070065 .match_id_mask[0] = 0xffff,
Aaron Durbin5abeb062020-01-12 15:12:18 -070066 .ids = flash_table,
67 .nr_part_ids = ARRAY_SIZE(flash_table),
68 .desc = &spi_flash_pp_0x20_sector_desc,
Furquan Shaikhe2fc5e22017-05-17 17:26:01 -070069};