SyterKit 0.4.0.x
SyterKit is a bare-metal framework
Loading...
Searching...
No Matches
Enumerations | Functions | Variables
sys-spi-nand.c File Reference
#include <io.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <types.h>
#include <timer.h>
#include <common.h>
#include <log.h>
#include <sys-clk.h>
#include <sys-dma.h>
#include <sys-gpio.h>
#include "sys-spi-nand.h"
#include "sys-spi.h"
Include dependency graph for sys-spi-nand.c:

Enumerations

enum  {
  OPCODE_READ_ID = 0x9f , OPCODE_READ_STATUS = 0x0f , OPCODE_WRITE_STATUS = 0x1f , OPCODE_READ_PAGE = 0x13 ,
  OPCODE_READ = 0x03 , OPCODE_FAST_READ = 0x0b , OPCODE_FAST_READ_DUAL_O = 0x3b , OPCODE_FAST_READ_QUAD_O = 0x6b ,
  OPCODE_FAST_READ_DUAL_IO = 0xbb , OPCODE_FAST_READ_QUAD_IO = 0xeb , OPCODE_WRITE_ENABLE = 0x06 , OPCODE_BLOCK_ERASE = 0xd8 ,
  OPCODE_PROGRAM_LOAD = 0x02 , OPCODE_PROGRAM_EXEC = 0x10 , OPCODE_RESET = 0xff
}
 
enum  { CONFIG_ADDR_PROTECT = 0xa0 , CONFIG_ADDR_OTP = 0xb0 , CONFIG_ADDR_STATUS = 0xc0 , CONFIG_POS_BUF = 0x08 }
 
enum  spi_mfr_id {
  SPI_NAND_MFR_WINBOND = 0xef , SPI_NAND_MFR_GIGADEVICE = 0xc8 , SPI_NAND_MFR_MACRONIX = 0xc2 , SPI_NAND_MFR_MICRON = 0x2c ,
  SPI_NAND_MFR_FORESEE = 0xcd , SPI_NAND_MFR_ETRON = 0xd5 , SPI_NAND_MFR_XTX = 0x0b
}
 

Functions

static int spi_nand_info (sunxi_spi_t *spi)
 Retrieve SPI NAND information.
 
 __attribute__ ((unused))
 Perform a reset operation on the SPI NAND.
 
static int spi_nand_get_config (sunxi_spi_t *spi, uint8_t addr, uint8_t *val)
 Get configuration value from SPI NAND at specified address.
 
static int spi_nand_set_config (sunxi_spi_t *spi, uint8_t addr, uint8_t val)
 Set configuration value to SPI NAND at specified address.
 
static bool spi_nand_wait_while_busy (sunxi_spi_t *spi)
 Wait until SPI NAND is not busy.
 
int spi_nand_detect (sunxi_spi_t *spi)
 Detect and initialize SPI NAND flash.
 
static int spi_nand_load_page (sunxi_spi_t *spi, uint32_t offset)
 Load a page from SPI NAND flash at the specified offset.
 
uint32_t spi_nand_read (sunxi_spi_t *spi, uint8_t *buf, uint32_t addr, uint32_t rxlen)
 Read data from SPI NAND flash.
 

Variables

static const spi_nand_info_t spi_nand_infos []
 
static spi_nand_info_t info
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
OPCODE_READ_ID 
OPCODE_READ_STATUS 
OPCODE_WRITE_STATUS 
OPCODE_READ_PAGE 
OPCODE_READ 
OPCODE_FAST_READ 
OPCODE_FAST_READ_DUAL_O 
OPCODE_FAST_READ_QUAD_O 
OPCODE_FAST_READ_DUAL_IO 
OPCODE_FAST_READ_QUAD_IO 
OPCODE_WRITE_ENABLE 
OPCODE_BLOCK_ERASE 
OPCODE_PROGRAM_LOAD 
OPCODE_PROGRAM_EXEC 
OPCODE_RESET 

◆ anonymous enum

anonymous enum
Enumerator
CONFIG_ADDR_PROTECT 
CONFIG_ADDR_OTP 
CONFIG_ADDR_STATUS 
CONFIG_POS_BUF 

◆ spi_mfr_id

enum spi_mfr_id
Enumerator
SPI_NAND_MFR_WINBOND 
SPI_NAND_MFR_GIGADEVICE 
SPI_NAND_MFR_MACRONIX 
SPI_NAND_MFR_MICRON 
SPI_NAND_MFR_FORESEE 
SPI_NAND_MFR_ETRON 
SPI_NAND_MFR_XTX 

Function Documentation

◆ __attribute__()

__attribute__ ( (unused )

Perform a reset operation on the SPI NAND.

Parameters
spiPointer to the sunxi_spi_t structure.
Returns
0 on success, -1 on failure.

◆ spi_nand_detect()

int spi_nand_detect ( sunxi_spi_t spi)

Detect and initialize SPI NAND flash.

Parameters
spiPointer to the sunxi_spi_t structure.
Returns
0 on success, -1 on failure.

◆ spi_nand_get_config()

static int spi_nand_get_config ( sunxi_spi_t spi,
uint8_t  addr,
uint8_t val 
)
static

Get configuration value from SPI NAND at specified address.

Parameters
spiPointer to the sunxi_spi_t structure.
addrAddress to read from.
valPointer to store the configuration value.
Returns
0 on success, -1 on failure.

◆ spi_nand_info()

static int spi_nand_info ( sunxi_spi_t spi)
static

Retrieve SPI NAND information.

Parameters
spiPointer to the sunxi_spi_t structure.
Returns
0 on success, -1 on failure.

◆ spi_nand_load_page()

static int spi_nand_load_page ( sunxi_spi_t spi,
uint32_t  offset 
)
static

Load a page from SPI NAND flash at the specified offset.

Parameters
spiPointer to the sunxi_spi_t structure.
offsetOffset of the page to load.
Returns
0 on success, -1 on failure.

◆ spi_nand_read()

uint32_t spi_nand_read ( sunxi_spi_t spi,
uint8_t buf,
uint32_t  addr,
uint32_t  rxlen 
)

Read data from SPI NAND flash.

Parameters
spiPointer to the sunxi_spi_t structure.
bufPointer to the buffer to store the read data.
addrStarting address to read from.
rxlenNumber of bytes to read.
Returns
Number of bytes read on success, -1 on failure.

◆ spi_nand_set_config()

static int spi_nand_set_config ( sunxi_spi_t spi,
uint8_t  addr,
uint8_t  val 
)
static

Set configuration value to SPI NAND at specified address.

Parameters
spiPointer to the sunxi_spi_t structure.
addrAddress to write to.
valValue to be written.
Returns
0 on success, -1 on failure.

◆ spi_nand_wait_while_busy()

static bool spi_nand_wait_while_busy ( sunxi_spi_t spi)
static

Wait until SPI NAND is not busy.

Parameters
spiPointer to the sunxi_spi_t structure.

Variable Documentation

◆ info

spi_nand_info_t info
static

◆ spi_nand_infos

const spi_nand_info_t spi_nand_infos[]
static