treewide: replace GPLv2 long form headers with SPDX header
[coreboot.git] / src / drivers / spi / eon.c
blobf2f16271ade9624b26d1def95582ea613dd0f3b2
1 /* This file is part of the coreboot project. */
2 /* SPDX-License-Identifier: GPL-2.0-or-later */
4 #include <console/console.h>
5 #include <commonlib/helpers.h>
6 #include <spi_flash.h>
7 #include <spi-generic.h>
8 #include <string.h>
10 #include "spi_flash_internal.h"
12 /* EN25*-specific commands */
13 #define CMD_EN25_WREN 0x06 /* Write Enable */
14 #define CMD_EN25_WRDI 0x04 /* Write Disable */
15 #define CMD_EN25_RDSR 0x05 /* Read Status Register */
16 #define CMD_EN25_WRSR 0x01 /* Write Status Register */
17 #define CMD_EN25_READ 0x03 /* Read Data Bytes */
18 #define CMD_EN25_FAST_READ 0x0b /* Read Data Bytes at Higher Speed */
19 #define CMD_EN25_PP 0x02 /* Page Program */
20 #define CMD_EN25_SE 0x20 /* Sector Erase */
21 #define CMD_EN25_BE 0xd8 /* Block Erase */
22 #define CMD_EN25_DP 0xb9 /* Deep Power-down */
23 #define CMD_EN25_RES 0xab /* Release from DP, and Read Signature */
25 #define EON_ID_EN25B80 0x2014
26 #define EON_ID_EN25B16 0x2015
27 #define EON_ID_EN25B32 0x2016
28 #define EON_ID_EN25B64 0x2017
29 #define EON_ID_EN25F80 0x3114
30 #define EON_ID_EN25F16 0x3115
31 #define EON_ID_EN25F32 0x3116
32 #define EON_ID_EN25F64 0x3117
33 #define EON_ID_EN25Q80 0x3014
34 #define EON_ID_EN25Q16 0x3015 /* Same as EN25D16 */
35 #define EON_ID_EN25Q32 0x3016 /* Same as EN25Q32A and EN25Q32B */
36 #define EON_ID_EN25Q64 0x3017
37 #define EON_ID_EN25Q128 0x3018
38 #define EON_ID_EN25QH16 0x7015
39 #define EON_ID_EN25QH32 0x7016
40 #define EON_ID_EN25QH64 0x7017
41 #define EON_ID_EN25QH128 0x7018
42 #define EON_ID_EN25S80 0x3814
43 #define EON_ID_EN25S16 0x3815
44 #define EON_ID_EN25S32 0x3816
45 #define EON_ID_EN25S64 0x3817
47 static const struct spi_flash_part_id flash_table[] = {
49 /* EN25B80 */
50 .id[0] = EON_ID_EN25B80,
51 .nr_sectors_shift = 8,
54 /* EN25B16 */
55 .id[0] = EON_ID_EN25B16,
56 .nr_sectors_shift = 9,
59 /* EN25B32 */
60 .id[0] = EON_ID_EN25B32,
61 .nr_sectors_shift = 10,
64 /* EN25B64 */
65 .id[0] = EON_ID_EN25B64,
66 .nr_sectors_shift = 11,
69 /* EN25F80 */
70 .id[0] = EON_ID_EN25F80,
71 .nr_sectors_shift = 8,
74 /* EN25F16 */
75 .id[0] = EON_ID_EN25F16,
76 .nr_sectors_shift = 9,
79 /* EN25F32 */
80 .id[0] = EON_ID_EN25F32,
81 .nr_sectors_shift = 10,
84 /* EN25F64 */
85 .id[0] = EON_ID_EN25F64,
86 .nr_sectors_shift = 11,
89 /* EN25Q80(A) */
90 .id[0] = EON_ID_EN25Q80,
91 .nr_sectors_shift = 8,
94 /* EN25Q16(D16) */
95 .id[0] = EON_ID_EN25Q16,
96 .nr_sectors_shift = 9,
99 /* EN25Q32(A/B) */
100 .id[0] = EON_ID_EN25Q32,
101 .nr_sectors_shift = 10,
104 /* EN25Q64 */
105 .id[0] = EON_ID_EN25Q64,
106 .nr_sectors_shift = 11,
109 /* EN25Q128 */
110 .id[0] = EON_ID_EN25Q128,
111 .nr_sectors_shift = 12,
114 /* EN25QH16 */
115 .id[0] = EON_ID_EN25QH16,
116 .nr_sectors_shift = 9,
119 /* EN25QH32 */
120 .id[0] = EON_ID_EN25QH32,
121 .nr_sectors_shift = 10,
124 /* EN25QH64 */
125 .id[0] = EON_ID_EN25QH64,
126 .nr_sectors_shift = 11,
129 /* EN25QH128 */
130 .id[0] = EON_ID_EN25QH128,
131 .nr_sectors_shift = 12,
134 /* EN25S80 */
135 .id[0] = EON_ID_EN25S80,
136 .nr_sectors_shift = 8,
139 /* EN25S16 */
140 .id[0] = EON_ID_EN25S16,
141 .nr_sectors_shift = 9,
144 /* EN25S32 */
145 .id[0] = EON_ID_EN25S32,
146 .nr_sectors_shift = 10,
149 /* EN25S64 */
150 .id[0] = EON_ID_EN25S64,
151 .nr_sectors_shift = 11,
155 const struct spi_flash_vendor_info spi_flash_eon_vi = {
156 .id = VENDOR_ID_EON,
157 .page_size_shift = 8,
158 .sector_size_kib_shift = 2,
159 .match_id_mask[0] = 0xffff,
160 .ids = flash_table,
161 .nr_part_ids = ARRAY_SIZE(flash_table),
162 .desc = &spi_flash_pp_0x20_sector_desc,