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

Go to the source code of this file.

Macros

#define CMD_SST_WREN   0x06 /* Write Enable */
 
#define CMD_SST_WRDI   0x04 /* Write Disable */
 
#define CMD_SST_RDSR   0x05 /* Read Status Register */
 
#define CMD_SST_WRSR   0x01 /* Write Status Register */
 
#define CMD_SST_EWSR   0x50 /* Enable Write Status Register */
 
#define CMD_SST_READ   0x03 /* Read Data Bytes */
 
#define CMD_SST_FAST_READ   0x0b /* Read Data Bytes at Higher Speed */
 
#define CMD_SST_BP   0x02 /* Byte Program */
 
#define CMD_SST_PP   0x02 /* Page Program */
 
#define CMD_SST_AAI_WP   0xAD /* Auto Address Increment Word Program */
 
#define CMD_SST_SE   0x20 /* Sector Erase */
 
#define SST_SR_WIP   (1 << 0) /* Write-in-Progress */
 
#define SST_SR_WEL   (1 << 1) /* Write enable */
 
#define SST_SR_BP0   (1 << 2) /* Block Protection 0 */
 
#define SST_SR_BP1   (1 << 3) /* Block Protection 1 */
 
#define SST_SR_BP2   (1 << 4) /* Block Protection 2 */
 
#define SST_SR_AAI   (1 << 6) /* Addressing mode */
 
#define SST_SR_BPL   (1 << 7) /* BP bits lock */
 

Functions

static int sst_enable_writing (const struct spi_flash *flash)
 
static int sst_enable_writing_status (const struct spi_flash *flash)
 
static int sst_disable_writing (const struct spi_flash *flash)
 
static int sst_byte_write (const struct spi_flash *flash, u32 offset, const void *buf)
 
static int sst_write_ai (const struct spi_flash *flash, u32 offset, size_t len, const void *buf)
 
static int sst_unlock (const struct spi_flash *flash)
 

Variables

static const struct spi_flash_part_id flash_table_ai []
 
static const struct spi_flash_part_id flash_table_pp256 []
 
static const struct spi_flash_ops_descriptor descai
 
const struct spi_flash_vendor_info spi_flash_sst_ai_vi
 
const struct spi_flash_vendor_info spi_flash_sst_vi
 

Macro Definition Documentation

◆ CMD_SST_AAI_WP

#define CMD_SST_AAI_WP   0xAD /* Auto Address Increment Word Program */

Definition at line 23 of file sst.c.

◆ CMD_SST_BP

#define CMD_SST_BP   0x02 /* Byte Program */

Definition at line 21 of file sst.c.

◆ CMD_SST_EWSR

#define CMD_SST_EWSR   0x50 /* Enable Write Status Register */

Definition at line 18 of file sst.c.

◆ CMD_SST_FAST_READ

#define CMD_SST_FAST_READ   0x0b /* Read Data Bytes at Higher Speed */

Definition at line 20 of file sst.c.

◆ CMD_SST_PP

#define CMD_SST_PP   0x02 /* Page Program */

Definition at line 22 of file sst.c.

◆ CMD_SST_RDSR

#define CMD_SST_RDSR   0x05 /* Read Status Register */

Definition at line 16 of file sst.c.

◆ CMD_SST_READ

#define CMD_SST_READ   0x03 /* Read Data Bytes */

Definition at line 19 of file sst.c.

◆ CMD_SST_SE

#define CMD_SST_SE   0x20 /* Sector Erase */

Definition at line 24 of file sst.c.

◆ CMD_SST_WRDI

#define CMD_SST_WRDI   0x04 /* Write Disable */

Definition at line 15 of file sst.c.

◆ CMD_SST_WREN

#define CMD_SST_WREN   0x06 /* Write Enable */

Definition at line 14 of file sst.c.

◆ CMD_SST_WRSR

#define CMD_SST_WRSR   0x01 /* Write Status Register */

Definition at line 17 of file sst.c.

◆ SST_SR_AAI

#define SST_SR_AAI   (1 << 6) /* Addressing mode */

Definition at line 31 of file sst.c.

◆ SST_SR_BP0

#define SST_SR_BP0   (1 << 2) /* Block Protection 0 */

Definition at line 28 of file sst.c.

◆ SST_SR_BP1

#define SST_SR_BP1   (1 << 3) /* Block Protection 1 */

Definition at line 29 of file sst.c.

◆ SST_SR_BP2

#define SST_SR_BP2   (1 << 4) /* Block Protection 2 */

Definition at line 30 of file sst.c.

◆ SST_SR_BPL

#define SST_SR_BPL   (1 << 7) /* BP bits lock */

Definition at line 32 of file sst.c.

◆ SST_SR_WEL

#define SST_SR_WEL   (1 << 1) /* Write enable */

Definition at line 27 of file sst.c.

◆ SST_SR_WIP

#define SST_SR_WIP   (1 << 0) /* Write-in-Progress */

Definition at line 26 of file sst.c.

Function Documentation

◆ sst_byte_write()

static int sst_byte_write ( const struct spi_flash flash,
u32  offset,
const void buf 
)
static

Definition at line 118 of file sst.c.

References BIOS_SPEW, buf, CMD_SST_BP, CMD_SST_RDSR, offset, printk, spi_flash::spi, spi_flash_cmd_wait_ready(), spi_flash_cmd_write(), SPI_FLASH_PROG_TIMEOUT_MS, spi_w8r8(), and sst_enable_writing().

Referenced by sst_write_ai().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sst_disable_writing()

static int sst_disable_writing ( const struct spi_flash flash)
static

Definition at line 109 of file sst.c.

References BIOS_WARNING, CMD_SST_WRDI, NULL, printk, spi_flash::spi, and spi_flash_cmd().

Referenced by sst_write_ai().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sst_enable_writing()

static int sst_enable_writing ( const struct spi_flash flash)
static

Definition at line 91 of file sst.c.

References BIOS_WARNING, CMD_SST_WREN, NULL, printk, spi_flash::spi, and spi_flash_cmd().

Referenced by sst_byte_write(), and sst_write_ai().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sst_enable_writing_status()

static int sst_enable_writing_status ( const struct spi_flash flash)
static

Definition at line 100 of file sst.c.

References BIOS_WARNING, CMD_SST_EWSR, NULL, printk, spi_flash::spi, and spi_flash_cmd().

Here is the call graph for this function:

◆ sst_unlock()

static int sst_unlock ( const struct spi_flash flash)
static

Definition at line 209 of file sst.c.

◆ sst_write_ai()

static int sst_write_ai ( const struct spi_flash flash,
u32  offset,
size_t  len,
const void buf 
)
static

Variable Documentation

◆ descai

const struct spi_flash_ops_descriptor descai
static
Initial value:
= {
.erase_cmd = CMD_SST_SE,
.status_cmd = CMD_SST_RDSR,
.wren_cmd = CMD_SST_WREN,
.ops = {
.write = sst_write_ai,
},
}
int spi_flash_cmd_read(const struct spi_flash *flash, u32 offset, size_t len, void *buf)
Definition: spi_flash.c:142
int spi_flash_cmd_erase(const struct spi_flash *flash, u32 offset, size_t len)
Definition: spi_flash.c:228
int spi_flash_cmd_status(const struct spi_flash *flash, u8 *reg)
Definition: spi_flash.c:276
static int sst_write_ai(const struct spi_flash *flash, u32 offset, size_t len, const void *buf)
Definition: sst.c:144
#define CMD_SST_SE
Definition: sst.c:24
#define CMD_SST_RDSR
Definition: sst.c:16
#define CMD_SST_WREN
Definition: sst.c:14

Definition at line 209 of file sst.c.

◆ flash_table_ai

const struct spi_flash_part_id flash_table_ai[]
static

Definition at line 1 of file sst.c.

◆ flash_table_pp256

const struct spi_flash_part_id flash_table_pp256[]
static
Initial value:
= {
{
.id[0] = 0x4b,
.nr_sectors_shift = 11,
},
}

Definition at line 1 of file sst.c.

◆ spi_flash_sst_ai_vi

const struct spi_flash_vendor_info spi_flash_sst_ai_vi
Initial value:
= {
.sector_size_kib_shift = 2,
.match_id_mask[0] = 0xff,
.nr_part_ids = ARRAY_SIZE(flash_table_ai),
.desc = &descai,
.after_probe = sst_unlock,
}
#define ARRAY_SIZE(a)
Definition: helpers.h:12
#define VENDOR_ID_SST
Definition: spi-generic.h:25
static const struct spi_flash_ops_descriptor descai
Definition: sst.c:229
static const struct spi_flash_part_id flash_table_ai[]
Definition: sst.c:34
static int sst_unlock(const struct spi_flash *flash)
Definition: sst.c:209

Definition at line 209 of file sst.c.

◆ spi_flash_sst_vi

const struct spi_flash_vendor_info spi_flash_sst_vi
Initial value:
= {
.page_size_shift = 8,
.sector_size_kib_shift = 2,
.match_id_mask[0] = 0xff,
.nr_part_ids = ARRAY_SIZE(flash_table_pp256),
.after_probe = sst_unlock,
}
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_pp256[]
Definition: sst.c:82

Definition at line 209 of file sst.c.