47 #if defined(__BIG_ENDIAN)
63 .nr_sectors_shift = 8,
68 .nr_sectors_shift = 9,
73 .nr_sectors_shift = 10,
78 .nr_sectors_shift = 8,
79 .fast_read_dual_output_support = 1,
84 .nr_sectors_shift = 9,
85 .fast_read_dual_output_support = 1,
90 .nr_sectors_shift = 10,
91 .fast_read_dual_output_support = 1,
96 .nr_sectors_shift = 11,
97 .fast_read_dual_output_support = 1,
102 .nr_sectors_shift = 8,
103 .fast_read_dual_output_support = 1,
104 .fast_read_dual_io_support = 1,
109 .nr_sectors_shift = 9,
110 .fast_read_dual_output_support = 1,
111 .fast_read_dual_io_support = 1,
112 .protection_granularity_shift = 16,
118 .nr_sectors_shift = 9,
119 .fast_read_dual_output_support = 1,
120 .fast_read_dual_io_support = 1,
121 .protection_granularity_shift = 16,
127 .nr_sectors_shift = 10,
128 .fast_read_dual_output_support = 1,
129 .fast_read_dual_io_support = 1,
130 .protection_granularity_shift = 16,
136 .nr_sectors_shift = 10,
137 .fast_read_dual_output_support = 1,
138 .fast_read_dual_io_support = 1,
139 .protection_granularity_shift = 16,
145 .nr_sectors_shift = 11,
146 .fast_read_dual_output_support = 1,
147 .fast_read_dual_io_support = 1,
148 .protection_granularity_shift = 17,
154 .nr_sectors_shift = 11,
155 .fast_read_dual_output_support = 1,
156 .fast_read_dual_io_support = 1,
157 .protection_granularity_shift = 17,
163 .nr_sectors_shift = 11,
164 .fast_read_dual_output_support = 1,
165 .fast_read_dual_io_support = 1,
166 .protection_granularity_shift = 17,
172 .nr_sectors_shift = 12,
173 .fast_read_dual_output_support = 1,
174 .fast_read_dual_io_support = 1,
175 .protection_granularity_shift = 18,
181 .nr_sectors_shift = 12,
182 .fast_read_dual_output_support = 1,
183 .fast_read_dual_io_support = 1,
184 .protection_granularity_shift = 18,
190 .nr_sectors_shift = 12,
191 .fast_read_dual_output_support = 1,
192 .fast_read_dual_io_support = 1,
193 .protection_granularity_shift = 18,
199 .nr_sectors_shift = 12,
200 .fast_read_dual_output_support = 1,
201 .fast_read_dual_io_support = 1,
202 .protection_granularity_shift = 18,
208 .nr_sectors_shift = 14,
209 .fast_read_dual_output_support = 1,
210 .fast_read_dual_io_support = 1,
211 .protection_granularity_shift = 16,
217 .nr_sectors_shift = 13,
218 .fast_read_dual_output_support = 1,
219 .fast_read_dual_io_support = 1,
220 .protection_granularity_shift = 16,
226 .nr_sectors_shift = 13,
227 .fast_read_dual_output_support = 1,
228 .fast_read_dual_io_support = 1,
229 .protection_granularity_shift = 16,
242 const size_t flash_size,
245 size_t protected_size =
246 MIN(bp ? granularity << (bp - 1) : 0, flash_size);
249 protected_size = flash_size - protected_size;
253 out->
offset = tb ? 0 : flash_size - protected_size;
254 out->
size = protected_size;
281 const size_t granularity = (1 <<
params->protection_granularity_shift);
290 if (
params->bp_bits == 3) {
298 }
else if (
params->bp_bits == 4) {
340 const bool non_volatile)
362 cmdbuf.sreg |= reg8 << 8;
376 cmdbuf.sreg &= ~
mask;
407 cmdbuf.sreg |= reg8 << 8;
482 (1 <<
params->protection_granularity_shift))) {
484 params->protection_granularity_shift + 1;
492 if (
params->bp_bits == 3) {
494 .bp3 = { .bp =
bp, .tb =
tb, .sec = 0 }
497 .bp3 = { .bp = ~0, .tb = 1, .sec = 1 }
501 .bp4 = { .bp =
bp, .tb =
tb }
504 .bp4 = { .bp = ~0, .tb = 1 }
530 if (
params->bp_bits == 3) {
531 val.reg1.bp3.srp0 = !!(srp & 1);
532 mask.reg1.bp3.srp0 = 1;
534 val.reg1.bp4.srp0 = !!(srp & 1);
535 mask.reg1.bp4.srp0 = 1;
538 val.reg2.srp1 = !!(srp & 2);
559 .page_size_shift = 8,
560 .sector_size_kib_shift = 2,
561 .match_id_mask[0] = 0xffff,
static struct sdram_info params
#define printk(level,...)
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
static size_t region_sz(const struct region *r)
int region_is_subregion(const struct region *p, const struct region *c)
static size_t region_end(const struct region *r)
static size_t region_offset(const struct region *r)
#define VENDOR_ID_WINBOND
const struct spi_flash_ops_descriptor spi_flash_pp_0x20_sector_desc
int spi_flash_cmd_wait_ready(const struct spi_flash *flash, unsigned long timeout)
int spi_flash_cmd(const struct spi_slave *spi, u8 cmd, void *response, size_t len)
int spi_flash_cmd_write(const struct spi_slave *spi, const u8 *cmd, size_t cmd_len, const void *data, size_t data_len)
spi_flash_status_reg_lockdown
@ SPI_WRITE_PROTECTION_PERMANENT
@ SPI_WRITE_PROTECTION_PIN
@ SPI_WRITE_PROTECTION_PRESERVE
@ SPI_WRITE_PROTECTION_NONE
@ SPI_WRITE_PROTECTION_REBOOT
#define WINBOND_FLASH_TIMEOUT
#define CMD_VOLATILE_SREG_WREN
int(* get_write)(const struct spi_flash *flash, const struct region *region)
const struct spi_flash_part_id * part
struct status_reg1::@89 bp3
struct status_reg1::@90 bp4
const struct spi_flash_vendor_info spi_flash_winbond_vi
static int winbond_get_write_protection(const struct spi_flash *flash, const struct region *region)
static const struct spi_flash_part_id flash_table[]
static int winbond_flash_cmd_status(const struct spi_flash *flash, const u16 mask, const u16 val, const bool non_volatile)
Common method to write some bit of the status register 1 & 2 at the same time.
static void winbond_bpbits_to_region(const size_t granularity, const u8 bp, bool tb, const bool cmp, const size_t flash_size, struct region *out)
static int winbond_set_write_protection(const struct spi_flash *flash, const struct region *region, const enum spi_flash_status_reg_lockdown mode)
static const struct spi_flash_protection_ops spi_flash_protection_ops