PebbleOS v4.44.0-46-gef116268a
Loading...
Searching...
No Matches
SPI NOR

Flash driver for a JEDEC NOR part on a SPI memory controller. More...

Data Structures

struct  pbl_flash_spi_nor
 NOR flash on a SPI memory controller. More...
 

Macros

#define PBL_FLASH_SPI_NOR_DEFINE(sym, _name, _bus, _part, _base, _otp_layout)
 Define a NOR flash on a SPI memory controller.
 

Detailed Description

Flash driver for a JEDEC NOR part on a SPI memory controller.

The part is described by its SFDP tables (JESD216): size, page size, erase types and times, read modes and 4-byte address opcodes. The part description fills in what SFDP does not cover (OTP organization, status register layout and latencies) and stands in for SFDP on parts without it. The widest read and program modes both the part and the controller support are used. Parts over 16 MiB are driven with 4-byte address opcodes when both support them, which leaves the part in its power-on 3-byte address mode; otherwise the part is put in 4-byte address mode, and taken out of it by pbl_flash_stop().

Reads go through the controller's memory-mapped window when it has one, and through operations beyond it. On a PBL_SPI_MEM_XIP controller the part is not reset, the state the boot code left is adopted, and programs and erases return once the part is readable again. Addresses start at the base the board gives, e.g. where the controller maps the part.

The user OTP area is made of the part's security registers. The board lays out its cells:

static const struct pbl_flash_otp_cell s_otp_cells[] = {
PBL_FLASH_OTP_CELL("serial-number", 0x20, 32),
};
static const struct pbl_flash_otp_layout s_otp_layout = {s_otp_cells, ARRAY_LENGTH(s_otp_cells)};
PBL_FLASH_SPI_NOR_DEFINE(s_flash, "flash", &s_qspi.mem, &pbl_flash_nor_gd25lq255e, 0U,
&s_otp_layout);
const struct pbl_flash_nor_part pbl_flash_nor_gd25lq255e
GigaDevice GD25LQ255E.
#define PBL_FLASH_SPI_NOR_DEFINE(sym, _name, _bus, _part, _base, _otp_layout)
Define a NOR flash on a SPI memory controller.
Definition spi_nor.h:89
Named ranges of the OTP area, as laid out by the board.
Definition flash.h:104
A named range of the OTP area.
Definition flash.h:94
#define PBL_FLASH_OTP_CELL(_name, _offset, _len)
Initializer for a struct pbl_flash_otp_cell.
Definition flash.h:112
#define ARRAY_LENGTH(array)
Calculate the length of an array, based on the size of the element type.
Definition size.h:18

Data Structure Documentation

◆ pbl_flash_spi_nor

struct pbl_flash_spi_nor

NOR flash on a SPI memory controller.

Data Fields
const struct pbl_spi_mem * bus Controller.
struct pbl_flash_spi_nor_data * data Driver state.
struct pbl_flash flash Flash.
const struct pbl_flash_nor_part * part Part.

Macro Definition Documentation

◆ PBL_FLASH_SPI_NOR_DEFINE

#define PBL_FLASH_SPI_NOR_DEFINE (   sym,
  _name,
  _bus,
  _part,
  _base,
  _otp_layout 
)
Value:
static struct pbl_flash_spi_nor_data sym##_data; \
const struct pbl_flash_spi_nor sym = { \
.flash = PBL_FLASH_INIT(sym, _name, &(_bus)->dev, nullptr, &pbl_flash_spi_nor_ops, (_base), \
&sym##_data.geometry, &(_part)->otp.info, _otp_layout), \
.data = &sym##_data, \
.bus = (_bus), \
.part = (_part), \
}; \
PBL_DEVICE_REGISTER(sym, &sym.flash.dev)
const struct pbl_spi_mem * bus
Controller.
Definition spi_nor.h:70
const struct pbl_flash_nor_part * part
Part.
Definition spi_nor.h:72
struct pbl_flash flash
Flash.
Definition spi_nor.h:66
NOR flash on a SPI memory controller.
Definition spi_nor.h:64
struct pbl_device dev
Device.
Definition flash.h:207
#define PBL_FLASH_INIT(sym, _name, _parent, _deps, _ops, _base, _geometry, _otp, _otp_layout)
Initializer for the struct pbl_flash of flash sym.
Definition flash.h:251
#define PBL_FLASH_STATE_DEFINE(sym)
Define the class state of flash sym, for the PBL_FLASH_*_DEFINE() macro of a driver.
Definition flash.h:231

Define a NOR flash on a SPI memory controller.

Parameters
symSymbol of the flash.
_nameName.
_busController, a struct pbl_spi_mem.
_partPart, a struct pbl_flash_nor_part.
_baseAddress of the first byte.
_otp_layoutOTP cells, a struct pbl_flash_otp_layout, or NULL.