coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
spansion.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #include <commonlib/helpers.h>
4 #include <spi_flash.h>
5 #include <spi-generic.h>
6 
7 #include "spi_flash_internal.h"
8 
9 /* S25FLxx-specific commands */
10 #define CMD_S25FLXX_READ 0x03 /* Read Data Bytes */
11 #define CMD_S25FLXX_FAST_READ 0x0b /* Read Data Bytes at Higher Speed */
12 #define CMD_S25FLXX_READID 0x90 /* Read Manufacture ID and Device ID */
13 #define CMD_S25FLXX_WREN 0x06 /* Write Enable */
14 #define CMD_S25FLXX_WRDI 0x04 /* Write Disable */
15 #define CMD_S25FLXX_RDSR 0x05 /* Read Status Register */
16 #define CMD_S25FLXX_WRSR 0x01 /* Write Status Register */
17 #define CMD_S25FLXX_PP 0x02 /* Page Program */
18 #define CMD_S25FLXX_SE 0xd8 /* Sector Erase */
19 #define CMD_S25FLXX_BE 0xc7 /* Bulk Erase */
20 #define CMD_S25FLXX_DP 0xb9 /* Deep Power-down */
21 #define CMD_S25FLXX_RES 0xab /* Release from DP, and Read Signature */
22 
23 #define SPSN_ID_S25FL008A 0x0213
24 #define SPSN_ID_S25FL016A 0x0214
25 #define SPSN_ID_S25FL032A 0x0215
26 #define SPSN_ID_S25FL064A 0x0216
27 #define SPSN_ID_S25FL128S 0x0219
28 #define SPSN_ID_S25FL128P 0x2018
29 #define SPSN_ID_S25FL208K 0x4014
30 #define SPSN_ID_S25FL116K 0x4015
31 #define SPSN_ID_S25FL132K 0x4016
32 #define SPSN_ID_S25FL164K 0x4017
33 #define SPSN_EXT_ID_S25FL128P_256KB 0x0300
34 #define SPSN_EXT_ID_S25FL128P_64KB 0x0301
35 #define SPSN_EXT_ID_S25FL032P 0x4d00
36 #define SPSN_EXT_ID_S25FLXXS_64KB 0x4d01
37 
38 static const struct spi_flash_part_id flash_table_ext[] = {
39  {
40  /* S25FL008A */
41  .id[0] = SPSN_ID_S25FL008A,
42  .nr_sectors_shift = 4,
43  },
44  {
45  /* S25FL016A */
46  .id[0] = SPSN_ID_S25FL016A,
47  .nr_sectors_shift = 5,
48  },
49  {
50  /* S25FL032A */
51  .id[0] = SPSN_ID_S25FL032A,
52  .nr_sectors_shift = 6,
53  },
54  {
55  /* S25FL064A */
56  .id[0] = SPSN_ID_S25FL064A,
57  .nr_sectors_shift = 7,
58  },
59  {
60  /* S25FL128P_64K */
61  .id[0] = SPSN_ID_S25FL128P,
63  .nr_sectors_shift = 8,
64  },
65  {
66  /* S25FL128S_256K */
67  .id[0] = SPSN_ID_S25FL128S,
69  .nr_sectors_shift = 9,
70  },
71  {
72  /* S25FL032P */
73  .id[0] = SPSN_ID_S25FL032A,
74  .id[1] = SPSN_EXT_ID_S25FL032P,
75  .nr_sectors_shift = 6,
76  },
77  {
78  /* S25FS128S */
79  .id[0] = SPSN_ID_S25FL128P,
81  .nr_sectors_shift = 8,
82  },
83 };
84 
85 static const struct spi_flash_part_id flash_table_256k_sector[] = {
86  {
87  /* S25FL128P_256K */
88  .id[0] = SPSN_ID_S25FL128P,
90  .nr_sectors_shift = 6,
91  },
92 };
93 
94 static const struct spi_flash_part_id flash_table[] = {
95  {
96  /* S25FL208K */
97  .id[0] = SPSN_ID_S25FL208K,
98  .nr_sectors_shift = 4,
99  },
100  {
101  /* S25FL116K_16M */
102  .id[0] = SPSN_ID_S25FL116K,
103  .nr_sectors_shift = 5,
104  },
105  {
106  /* S25FL132K */
107  .id[0] = SPSN_ID_S25FL132K,
108  .nr_sectors_shift = 6,
109  },
110  {
111  /* S25FL164K */
112  .id[0] = SPSN_ID_S25FL164K,
113  .nr_sectors_shift = 7,
114  },
115 };
116 
119  .page_size_shift = 8,
120  .sector_size_kib_shift = 6,
121  .match_id_mask[0] = 0xffff,
122  .match_id_mask[1] = 0xffff,
123  .ids = flash_table_ext,
124  .nr_part_ids = ARRAY_SIZE(flash_table_ext),
126 };
127 
130  .page_size_shift = 8,
131  .sector_size_kib_shift = 8,
132  .match_id_mask[0] = 0xffff,
133  .match_id_mask[1] = 0xffff,
135  .nr_part_ids = ARRAY_SIZE(flash_table_256k_sector),
137 };
138 
141  .page_size_shift = 8,
142  .sector_size_kib_shift = 6,
143  .match_id_mask[0] = 0xffff,
144  .ids = flash_table,
145  .nr_part_ids = ARRAY_SIZE(flash_table),
147 };
#define ARRAY_SIZE(a)
Definition: helpers.h:12
#define SPSN_EXT_ID_S25FL128P_64KB
Definition: spansion.c:34
#define SPSN_ID_S25FL128P
Definition: spansion.c:28
#define SPSN_ID_S25FL164K
Definition: spansion.c:32
#define SPSN_ID_S25FL032A
Definition: spansion.c:25
static const struct spi_flash_part_id flash_table[]
Definition: spansion.c:94
#define SPSN_EXT_ID_S25FL128P_256KB
Definition: spansion.c:33
#define SPSN_EXT_ID_S25FL032P
Definition: spansion.c:35
#define SPSN_ID_S25FL116K
Definition: spansion.c:30
const struct spi_flash_vendor_info spi_flash_spansion_ext2_vi
Definition: spansion.c:128
#define SPSN_ID_S25FL132K
Definition: spansion.c:31
static const struct spi_flash_part_id flash_table_256k_sector[]
Definition: spansion.c:85
#define SPSN_ID_S25FL208K
Definition: spansion.c:29
static const struct spi_flash_part_id flash_table_ext[]
Definition: spansion.c:38
#define SPSN_ID_S25FL128S
Definition: spansion.c:27
const struct spi_flash_vendor_info spi_flash_spansion_vi
Definition: spansion.c:139
#define SPSN_ID_S25FL064A
Definition: spansion.c:26
#define SPSN_ID_S25FL016A
Definition: spansion.c:24
#define SPSN_ID_S25FL008A
Definition: spansion.c:23
const struct spi_flash_vendor_info spi_flash_spansion_ext1_vi
Definition: spansion.c:117
#define SPSN_EXT_ID_S25FLXXS_64KB
Definition: spansion.c:36
#define VENDOR_ID_SPANSION
Definition: spi-generic.h:24
const struct spi_flash_ops_descriptor spi_flash_pp_0xd8_sector_desc
Definition: spi_flash.c:806