coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
winbond.c File Reference
#include <console/console.h>
#include <commonlib/helpers.h>
#include <spi_flash.h>
#include <spi-generic.h>
#include <delay.h>
#include <lib.h>
#include "spi_flash_internal.h"
#include "spi_winbond.h"
Include dependency graph for winbond.c:

Go to the source code of this file.

Data Structures

union  status_reg1
 
union  status_reg2
 
struct  status_regs
 

Functions

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_get_write_protection (const struct spi_flash *flash, const struct region *region)
 
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. More...
 
static int winbond_set_write_protection (const struct spi_flash *flash, const struct region *region, const enum spi_flash_status_reg_lockdown mode)
 

Variables

static const struct spi_flash_part_id flash_table []
 
static const struct spi_flash_protection_ops spi_flash_protection_ops
 
const struct spi_flash_vendor_info spi_flash_winbond_vi
 

Function Documentation

◆ winbond_bpbits_to_region()

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

Definition at line 238 of file winbond.c.

References MIN, region::offset, and region::size.

Referenced by winbond_get_write_protection().

Here is the caller graph for this function:

◆ winbond_flash_cmd_status()

static int winbond_flash_cmd_status ( const struct spi_flash flash,
const u16  mask,
const u16  val,
const bool  non_volatile 
)
static

Common method to write some bit of the status register 1 & 2 at the same time.

Only change bits that are one in @mask. Compare the final result to make sure that the register isn't locked.

Parameters
maskThe bits that are affected by @val
valThe bits to write
non_volatileMake setting permanent
Returns
0 on success

Definition at line 337 of file winbond.c.

References BIOS_DEBUG, BIOS_ERR, CMD_VOLATILE_SREG_WREN, CMD_W25_RDSR, CMD_W25_RDSR2, CMD_W25_WREN, CMD_W25_WRSR, mask, NULL, printk, spi_flash::spi, spi_flash_cmd(), spi_flash_cmd_wait_ready(), spi_flash_cmd_write(), udelay(), val, and WINBOND_FLASH_TIMEOUT.

Here is the call graph for this function:

◆ winbond_get_write_protection()

static int winbond_get_write_protection ( const struct spi_flash flash,
const struct region region 
)
static

◆ winbond_set_write_protection()

static int winbond_set_write_protection ( const struct spi_flash flash,
const struct region region,
const enum spi_flash_status_reg_lockdown  mode 
)
static

Definition at line 438 of file winbond.c.

Variable Documentation

◆ flash_table

const struct spi_flash_part_id flash_table[]
static

Definition at line 1 of file winbond.c.

◆ spi_flash_protection_ops

Initial value:
= {
}
static int winbond_get_write_protection(const struct spi_flash *flash, const struct region *region)
Definition: winbond.c:267
static int winbond_set_write_protection(const struct spi_flash *flash, const struct region *region, const enum spi_flash_status_reg_lockdown mode)
Definition: winbond.c:438

Definition at line 438 of file winbond.c.

◆ spi_flash_winbond_vi

const struct spi_flash_vendor_info spi_flash_winbond_vi
Initial value:
= {
.page_size_shift = 8,
.sector_size_kib_shift = 2,
.match_id_mask[0] = 0xffff,
.ids = flash_table,
.nr_part_ids = ARRAY_SIZE(flash_table),
}
#define ARRAY_SIZE(a)
Definition: helpers.h:12
#define VENDOR_ID_WINBOND
Definition: spi-generic.h:27
const struct spi_flash_ops_descriptor spi_flash_pp_0x20_sector_desc
Definition: spi_flash.c:793
static const struct spi_flash_part_id flash_table[]
Definition: winbond.c:59
static const struct spi_flash_protection_ops spi_flash_protection_ops
Definition: winbond.c:552

Definition at line 438 of file winbond.c.