1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 #include <commonlib/helpers.h>
5 #include <spi-generic.h>
7 #include "spi_flash_internal.h"
9 /* GD25Pxx-specific commands */
10 #define CMD_GD25_WREN 0x06 /* Write Enable */
11 #define CMD_GD25_WRDI 0x04 /* Write Disable */
12 #define CMD_GD25_RDSR 0x05 /* Read Status Register */
13 #define CMD_GD25_WRSR 0x01 /* Write Status Register */
14 #define CMD_GD25_READ 0x03 /* Read Data Bytes */
15 #define CMD_GD25_FAST_READ 0x0b /* Read Data Bytes at Higher Speed */
16 #define CMD_GD25_PP 0x02 /* Page Program */
17 #define CMD_GD25_SE 0x20 /* Sector (4K) Erase */
18 #define CMD_GD25_BE 0xd8 /* Block (64K) Erase */
19 #define CMD_GD25_CE 0xc7 /* Chip Erase */
20 #define CMD_GD25_DP 0xb9 /* Deep Power-down */
21 #define CMD_GD25_RES 0xab /* Release from DP, and Read Signature */
23 static const struct spi_flash_part_id flash_table
[] = {
27 .nr_sectors_shift
= 8,
32 .nr_sectors_shift
= 8,
33 .fast_read_dual_output_support
= 1,
34 .fast_read_dual_io_support
= 1,
35 }, /* also GD25Q80B */
39 .nr_sectors_shift
= 9,
40 .fast_read_dual_output_support
= 1,
41 .fast_read_dual_io_support
= 1,
42 }, /* also GD25Q16B */
46 .nr_sectors_shift
= 10,
47 .fast_read_dual_output_support
= 1,
48 .fast_read_dual_io_support
= 1,
49 }, /* also GD25Q32B */
53 .nr_sectors_shift
= 11,
54 .fast_read_dual_output_support
= 1,
55 .fast_read_dual_io_support
= 1,
56 }, /* also GD25Q64B, GD25B64C */
60 .nr_sectors_shift
= 12,
61 .fast_read_dual_output_support
= 1,
62 .fast_read_dual_io_support
= 1,
63 }, /* also GD25Q128B */
67 .nr_sectors_shift
= 8,
68 .fast_read_dual_output_support
= 1,
69 .fast_read_dual_io_support
= 1,
74 .nr_sectors_shift
= 9,
75 .fast_read_dual_output_support
= 1,
76 .fast_read_dual_io_support
= 1,
81 .nr_sectors_shift
= 8,
82 .fast_read_dual_output_support
= 1,
83 .fast_read_dual_io_support
= 1,
88 .nr_sectors_shift
= 9,
89 .fast_read_dual_output_support
= 1,
90 .fast_read_dual_io_support
= 1,
95 .nr_sectors_shift
= 10,
96 .fast_read_dual_output_support
= 1,
97 .fast_read_dual_io_support
= 1,
102 .nr_sectors_shift
= 11,
103 .fast_read_dual_output_support
= 1,
104 .fast_read_dual_io_support
= 1,
105 }, /* also GD25LB64C */
109 .nr_sectors_shift
= 12,
110 .fast_read_dual_output_support
= 1,
111 .fast_read_dual_io_support
= 1,
116 .nr_sectors_shift
= 13,
117 .fast_read_dual_output_support
= 1,
118 .fast_read_dual_io_support
= 1,
123 .nr_sectors_shift
= 13,
124 .fast_read_dual_output_support
= 1,
125 .fast_read_dual_io_support
= 1,
128 /* GD25LR512ME - 64MiB */
130 .nr_sectors_shift
= 14,
131 .fast_read_dual_output_support
= 1,
132 .fast_read_dual_io_support
= 1,
136 const struct spi_flash_vendor_info spi_flash_gigadevice_vi
= {
137 .id
= VENDOR_ID_GIGADEVICE
,
138 .page_size_shift
= 8,
139 .sector_size_kib_shift
= 2,
140 .match_id_mask
[0] = 0xffff,
142 .nr_part_ids
= ARRAY_SIZE(flash_table
),
143 .desc
= &spi_flash_pp_0x20_sector_desc
,