OpenOCD
|
Driver for SPI NOR flash chips connected via DesignWare SPI Core. More...
Go to the source code of this file.
Data Structures | |
struct | dw_spi_driver |
Driver private state. More... | |
struct | dw_spi_regmap |
IP block placement map. More... | |
Macros | |
#define | DW_SPI_ARG_REG "r4" |
Register used to pass argument struct to helper functions. More... | |
#define | DW_SPI_IF_OWNER_WIDTH 2 |
IF owner register field width. More... | |
#define | DW_SPI_REG_BAUDR 0x14 |
Baud rate configuration register. More... | |
#define | DW_SPI_REG_BAUDR_SCKDV(x) ((x) & GENMASK(15, 0)) |
Clock divisor. More... | |
#define | DW_SPI_REG_CTRLR0 0x00 |
General configuration register. More... | |
#define | DW_SPI_REG_CTRLR0_DFS(x) ((x) & GENMASK(3, 0)) |
Data frame size. More... | |
#define | DW_SPI_REG_CTRLR0_FRF(x) (((x) << 4) & GENMASK(5, 4)) |
SI protocol. More... | |
#define | DW_SPI_REG_CTRLR0_SCPH(x) ((!!(x)) << 6) |
Probe position. More... | |
#define | DW_SPI_REG_CTRLR0_SCPOL(x) ((!!(x)) << 7) |
Probe polarity. More... | |
#define | DW_SPI_REG_CTRLR0_TMOD(x) (((x) << 8) & GENMASK(9, 8)) |
SI mode. More... | |
#define | DW_SPI_REG_DR 0x60 |
Data register. More... | |
#define | DW_SPI_REG_IMR 0x2c |
Interrupt configuration register. More... | |
#define | DW_SPI_REG_SER 0x10 |
Slave select register. More... | |
#define | DW_SPI_REG_SER_SER(x) ((x) & GENMASK(15, 0)) |
Slave select bitmask. More... | |
#define | DW_SPI_REG_SIMCEN 0x08 |
Master controller enable register. More... | |
#define | DW_SPI_REG_SIMCEN_SIMCEN(x) (!!(x)) |
Controller enable. More... | |
#define | DW_SPI_REG_SR 0x28 |
Status register. More... | |
#define | DW_SPI_TIMEOUT_DEFAULT (600 * 1000) |
Default timeout value in ms for flash transaction jobs. More... | |
#define | DW_SPI_TIMEOUT_TRANSACTION 1000 |
Timeout value in ms for short flash transactions, e.g. More... | |
Enumerations | |
enum | dw_spi_si_mode { DW_SPI_SI_MODE_BOOT = 1 , DW_SPI_SI_MODE_MASTER = 2 } |
Owner of the SI interface. More... | |
Functions | |
static int | dw_spi_assert_halted (const struct flash_bank *const bank) |
Assert target is halted. More... | |
static int | dw_spi_auto_probe (struct flash_bank *bank) |
Autoprobe driver. More... | |
static int | dw_spi_blank_check (struct flash_bank *bank, size_t sector_count, uint8_t pattern) |
Flash bank blank check. More... | |
static int | dw_spi_ctrl_check_sectors_fill (const struct flash_bank *const bank, uint32_t address, size_t sector_size, size_t sector_count, uint8_t pattern, uint8_t read_cmd, uint8_t *buffer) |
Check that selected region is filled with pattern. More... | |
static int | dw_spi_ctrl_configure_si (const struct flash_bank *const bank) |
Configure SI transfer mode. More... | |
static int | dw_spi_ctrl_configure_speed (const struct flash_bank *const bank) |
Configure SI transfer speed. More... | |
static int | dw_spi_ctrl_disable_interrupts (const struct flash_bank *const bank) |
Disable SI master controller interrupts. More... | |
static int | dw_spi_ctrl_erase_sectors (const struct flash_bank *const bank, uint32_t address, uint32_t sector_size, size_t sector_count, uint8_t stat_cmd, uint8_t we_cmd, uint8_t erase_sector_cmd, uint8_t we_mask, uint8_t busy_mask) |
Erase sectors. More... | |
static int | dw_spi_ctrl_mode (const struct flash_bank *const bank, enum dw_spi_si_mode mode) |
Select SI interface owner. More... | |
static int | dw_spi_ctrl_mode_configure (const struct flash_bank *const bank, enum dw_spi_si_mode mode) |
Select master controller as SI interface owner. More... | |
static int | dw_spi_ctrl_mode_restore (const struct flash_bank *const bank) |
Restore SI controller mode. More... | |
static int | dw_spi_ctrl_program (const struct flash_bank *const bank, uint32_t address, const uint8_t *const buffer, size_t buffer_size, uint32_t page_size, uint8_t stat_cmd, uint8_t we_cmd, uint8_t program_cmd, uint8_t we_mask, uint8_t busy_mask) |
Write flash region. More... | |
static int | dw_spi_ctrl_read (const struct flash_bank *const bank, uint32_t address, uint8_t *buffer, size_t buffer_size, uint8_t read_cmd) |
Read flash data. More... | |
static int | dw_spi_ctrl_transaction (const struct flash_bank *const bank, uint8_t *const buffer, size_t size, bool read) |
Do data transaction. More... | |
static int | dw_spi_erase (struct flash_bank *bank, unsigned int first, unsigned int last) |
Flash bank erase sectors. More... | |
static int | dw_spi_erase_check (struct flash_bank *bank) |
Flash bank erase check. More... | |
static int | dw_spi_erase_chip (const struct flash_bank *const bank) |
Erase Flash chip. More... | |
static int | dw_spi_erase_sectors (const struct flash_bank *const bank, unsigned int first, unsigned int last) |
Flash device erase sectors. More... | |
static int | dw_spi_info (struct flash_bank *bank, struct command_invocation *cmd) |
Flash bank info. More... | |
static int | dw_spi_master_ctrl_configure (struct flash_bank *bank) |
Prepare master controller for transaction. More... | |
static int | dw_spi_master_ctrl_enable (const struct flash_bank *const bank, bool value) |
Enable master controller. More... | |
static int | dw_spi_master_ctrl_restore (struct flash_bank *bank) |
Restore SI controller selection. More... | |
static int | dw_spi_probe (struct flash_bank *bank) |
Flash bank probe. More... | |
static int | dw_spi_read (struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count) |
Flash bank read data using master controller. More... | |
static int | dw_spi_read_id (const struct flash_bank *const bank) |
Read Flash device ID. More... | |
static int | dw_spi_read_status (const struct flash_bank *const bank, uint8_t *const status) |
Read Flash device status. More... | |
static int | dw_spi_spiflash_search (const struct flash_bank *const bank) |
Search for Flash chip info. More... | |
static int | dw_spi_wait_finish (const struct flash_bank *const bank, unsigned int timeout) |
Wait for Flash command to finish. More... | |
static int | dw_spi_write (struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count) |
Flash bank write data. More... | |
static int | dw_spi_write_buffer (const struct flash_bank *const bank, const uint8_t *buffer, uint32_t offset, uint32_t count) |
Write buffer to Flash. More... | |
static int | dw_spi_write_enable (const struct flash_bank *const bank) |
Flash device write enable. More... | |
FLASH_BANK_COMMAND_HANDLER (dw_spi_flash_bank_command) | |
Handle flash bank command. More... | |
Variables | |
const struct flash_driver | dw_spi_flash |
DW-SPI NOR flash functions. More... | |
static const struct dw_spi_regmap | jaguar2_regmap |
Register map for Jaguar2 switch devices. More... | |
static const struct dw_spi_regmap | ocelot_regmap |
Register map for Ocelot switch devices. More... | |
Driver for SPI NOR flash chips connected via DesignWare SPI Core.
Controller's Linux driver is located at drivers/spi/spi-dw-mmio.c. DW-SPI is used in a number of processors, including Microsemi Jaguar2 and Ocelot switch chips.
Serial interface (SI) nCS0 pin, which is usually connected to the external flash, cannot be controlled via GPIO controller: it is asserted only when TX FIFO is not empty. Since JTAG is not fast enough to fill TX FIFO and collect data from RX FIFO at the same time even on the slowest SPI clock speeds, driver can only operate using functions, loaded in target's memory. Therefore, it requires the user to set up DRAM controller and provide work-area.
In Microsemi devices, serial interface pins may be governed either by Boot or Master controller. For these devices, additional configuration of spi_mst address is required to switch between the two.
Currently supported devices typically have much more RAM then NOR Flash (Jaguar2 reference design has 256MB RAM and 32MB NOR Flash), so supporting work-area sizes smaller then transfer buffer seems like the unnecessary complication.
This code was tested on Jaguar2 VSC7448 connected to Macronix MX25L25635F.
Definition in file dw-spi.c.
#define DW_SPI_ARG_REG "r4" |
#define DW_SPI_IF_OWNER_WIDTH 2 |
#define DW_SPI_REG_BAUDR 0x14 |
#define DW_SPI_REG_BAUDR_SCKDV | ( | x | ) | ((x) & GENMASK(15, 0)) |
#define DW_SPI_REG_CTRLR0 0x00 |
#define DW_SPI_REG_CTRLR0_DFS | ( | x | ) | ((x) & GENMASK(3, 0)) |
#define DW_SPI_REG_CTRLR0_FRF | ( | x | ) | (((x) << 4) & GENMASK(5, 4)) |
#define DW_SPI_REG_CTRLR0_SCPH | ( | x | ) | ((!!(x)) << 6) |
#define DW_SPI_REG_CTRLR0_SCPOL | ( | x | ) | ((!!(x)) << 7) |
#define DW_SPI_REG_CTRLR0_TMOD | ( | x | ) | (((x) << 8) & GENMASK(9, 8)) |
#define DW_SPI_REG_IMR 0x2c |
#define DW_SPI_REG_SER_SER | ( | x | ) | ((x) & GENMASK(15, 0)) |
#define DW_SPI_REG_SIMCEN 0x08 |
#define DW_SPI_REG_SIMCEN_SIMCEN | ( | x | ) | (!!(x)) |
#define DW_SPI_TIMEOUT_DEFAULT (600 * 1000) |
#define DW_SPI_TIMEOUT_TRANSACTION 1000 |
enum dw_spi_si_mode |
|
static |
Assert target is halted.
[in] | bank | Flash bank handle. |
Definition at line 1325 of file dw-spi.c.
References bank, ERROR_OK, ERROR_TARGET_NOT_HALTED, LOG_ERROR, and TARGET_HALTED.
Referenced by dw_spi_master_ctrl_configure().
|
static |
Autoprobe driver.
[in] | bank | Flash bank handle. |
Definition at line 1583 of file dw-spi.c.
References bank, dw_spi_probe(), ERROR_FAIL, ERROR_OK, and dw_spi_driver::probed.
|
static |
Flash bank blank check.
Definition at line 1130 of file dw-spi.c.
References bank, dw_spi_ctrl_check_sectors_fill(), ERROR_FAIL, LOG_ERROR, pattern, flash_device::read_cmd, sector_count, and dw_spi_driver::spi_flash.
Referenced by dw_spi_erase_check().
|
static |
Check that selected region is filled with pattern.
This function is used for Flash erase checking.
[in] | bank | Flash bank. |
[in] | address | Starting address. Sector aligned. |
[in] | sector_size | Size of sector. |
[in] | sector_count | Number of sectors. |
[in] | pattern | Fill pattern. |
[in] | read_cmd | Flash read command. |
[out] | buffer | Filled flag array. Must hold sector_count number of entries. |
Definition at line 480 of file dw-spi.c.
References address, dw_spi_check_fill::address, working_area::address, bank, buf_set_u32(), buffer, mips32_algorithm::common_magic, dw_spi_check_fill::data_reg, destroy_mem_param(), destroy_reg_param(), DW_SPI_ARG_REG, DW_SPI_REG_DR, DW_SPI_REG_SR, dw_spi_check_fill::fill_status_array, dw_spi_check_fill::four_byte_mode, dw_spi_driver::four_byte_mode, init_mem_param(), init_reg_param(), LOG_ERROR, MIPS32_COMMON_MAGIC, MIPS32_ISA_MIPS32, PARAM_OUT, pattern, dw_spi_check_fill::pattern, read_cmd, dw_spi_check_fill::read_cmd, dw_spi_driver::regmap, sector_count, dw_spi_check_fill::sector_count, sector_size, dw_spi_check_fill::sector_size, dw_spi_regmap::simc, working_area::size, dw_spi_check_fill::status_reg, target_alloc_working_area(), target_buffer_set_u32(), target_free_working_area(), target_read_buffer(), target_run_algorithm(), target_write_buffer(), dw_spi_driver::timeout, mem_param::value, and reg_param::value.
Referenced by dw_spi_blank_check().
|
static |
Configure SI transfer mode.
[in] | bank | Flash bank. |
Definition at line 264 of file dw-spi.c.
References bank, dw_spi_driver::chip_select_bitmask, DW_SPI_REG_CTRLR0, DW_SPI_REG_CTRLR0_DFS, DW_SPI_REG_CTRLR0_FRF, DW_SPI_REG_CTRLR0_SCPH, DW_SPI_REG_CTRLR0_SCPOL, DW_SPI_REG_CTRLR0_TMOD, DW_SPI_REG_SER, DW_SPI_REG_SER_SER, LOG_ERROR, mode, dw_spi_driver::regmap, dw_spi_regmap::simc, and target_write_u32().
Referenced by dw_spi_master_ctrl_configure().
|
static |
Configure SI transfer speed.
[in] | bank | Flash bank. |
Definition at line 298 of file dw-spi.c.
References bank, DW_SPI_REG_BAUDR, DW_SPI_REG_BAUDR_SCKDV, dw_spi_regmap::freq, LOG_DEBUG, LOG_ERROR, MIN, dw_spi_driver::regmap, dw_spi_regmap::simc, dw_spi_driver::speed, and target_write_u32().
Referenced by dw_spi_master_ctrl_configure().
|
static |
Disable SI master controller interrupts.
[in] | bank | Flash bank. |
Definition at line 327 of file dw-spi.c.
References bank, DW_SPI_REG_IMR, LOG_ERROR, dw_spi_driver::regmap, dw_spi_regmap::simc, and target_write_u32().
Referenced by dw_spi_master_ctrl_configure().
|
static |
Erase sectors.
[in] | bank | Flash bank. |
[in] | address | Flash address. Must be sector aligned. |
[in] | sector_size | Size of flash sector. |
[in] | sector_count | Number of sectors to erase. |
[in] | stat_cmd | Flash command to read chip status. |
[in] | we_cmd | Flash command to set enable write. |
[in] | erase_sector_cmd | Flash command to set erase sector. |
[in] | we_mask | Status byte write enable mask. |
[in] | busy_mask | Status byte write busy mask. |
Definition at line 733 of file dw-spi.c.
References address, dw_spi_erase::address, working_area::address, bank, buf_set_u32(), busy_mask, dw_spi_erase::busy_mask, mips32_algorithm::common_magic, dw_spi_erase::data_reg, destroy_mem_param(), destroy_reg_param(), DW_SPI_ARG_REG, DW_SPI_REG_DR, DW_SPI_REG_SR, erase_sector_cmd, dw_spi_erase::erase_sector_cmd, dw_spi_erase::four_byte_mode, dw_spi_driver::four_byte_mode, init_mem_param(), init_reg_param(), LOG_ERROR, MIPS32_COMMON_MAGIC, MIPS32_ISA_MIPS32, PARAM_OUT, dw_spi_erase::read_status_cmd, dw_spi_driver::regmap, sector_count, dw_spi_erase::sector_count, sector_size, dw_spi_erase::sector_size, dw_spi_regmap::simc, working_area::size, dw_spi_erase::status_reg, target_alloc_working_area(), target_buffer_set_u32(), target_free_working_area(), target_run_algorithm(), target_write_buffer(), dw_spi_driver::timeout, mem_param::value, reg_param::value, dw_spi_erase::write_enable_cmd, and dw_spi_erase::write_enable_mask.
Referenced by dw_spi_erase_sectors().
|
static |
Select SI interface owner.
Mode selection is skipped if Boot controller not available on target (i.e. spi_mst command argument is not configured).
[in] | bank | Flash bank. |
[in] | mode | New controller mode. |
Definition at line 153 of file dw-spi.c.
References bank, ctrl, DW_SPI_IF_OWNER_WIDTH, ERROR_OK, GENMASK, LOG_ERROR, mode, dw_spi_driver::regmap, dw_spi_regmap::si_if_owner_offset, dw_spi_regmap::spi_mst, target_read_u32(), and target_write_u32().
Referenced by dw_spi_ctrl_mode_configure(), and dw_spi_ctrl_mode_restore().
|
static |
Select master controller as SI interface owner.
Previous interface owner is restored via dw_spi_ctrl_mode_restore() function. Mode selection is skipped if Boot controller not available on target (i.e. spi_mst command argument is not configured).
[in] | bank | Flash bank. |
[in] | mode | New controller mode. |
Definition at line 191 of file dw-spi.c.
References bank, ctrl, dw_spi_ctrl_mode(), DW_SPI_IF_OWNER_WIDTH, ERROR_OK, GENMASK, LOG_ERROR, mode, dw_spi_driver::regmap, dw_spi_driver::saved_ctrl_mode, dw_spi_regmap::si_if_owner_offset, dw_spi_regmap::spi_mst, and target_read_u32().
Referenced by dw_spi_master_ctrl_configure().
|
static |
Restore SI controller mode.
Restore initially configured SI controller mode. Undo configuration done by dw_spi_ctrl_mode_configure() function. Mode selection is skipped if Boot controller not available on target (i.e. spi_mst command argument is not configured).
[in] | bank | Flash bank. |
Definition at line 226 of file dw-spi.c.
References bank, dw_spi_ctrl_mode(), and dw_spi_driver::saved_ctrl_mode.
Referenced by dw_spi_master_ctrl_restore().
|
static |
Write flash region.
[in] | bank | Flash bank. |
[in] | address | First page address. Page aligned when write is crossing the page boundary. |
[in] | buffer | Data buffer. |
[in] | buffer_size | buffer size. |
[in] | page_size | Size of flash page. |
[in] | stat_cmd | Flash command to read chip status. |
[in] | we_cmd | Flash command to enable write. |
[in] | program_cmd | Flash command to program chip. |
[in] | we_mask | Status byte write enable mask. |
[in] | busy_mask | Status byte write busy mask. |
Definition at line 608 of file dw-spi.c.
References address, dw_spi_program::address, working_area::address, bank, buf_set_u32(), buffer, dw_spi_program::buffer, buffer_size, dw_spi_program::buffer_size, busy_mask, dw_spi_program::busy_mask, mips32_algorithm::common_magic, dw_spi_program::data_reg, destroy_mem_param(), destroy_reg_param(), DW_SPI_ARG_REG, DW_SPI_REG_DR, DW_SPI_REG_SR, dw_spi_program::four_byte_mode, dw_spi_driver::four_byte_mode, init_mem_param(), init_reg_param(), LOG_ERROR, MIPS32_COMMON_MAGIC, MIPS32_ISA_MIPS32, page_size, dw_spi_program::page_size, PARAM_OUT, program_cmd, dw_spi_program::program_cmd, dw_spi_program::read_status_cmd, dw_spi_driver::regmap, dw_spi_regmap::simc, working_area::size, dw_spi_program::status_reg, target_alloc_working_area(), target_buffer_set_u32(), target_free_working_area(), target_run_algorithm(), target_write_buffer(), dw_spi_driver::timeout, mem_param::value, reg_param::value, dw_spi_program::write_enable_cmd, and dw_spi_program::write_enable_mask.
Referenced by dw_spi_write_buffer().
|
static |
Read flash data.
[in] | bank | Flash bank. |
[in] | address | Flash address. |
[out] | buffer | Data buffer. |
[in] | buffer_size | buffer size. |
[in] | read_cmd | Flash command to read data from flash. |
Definition at line 836 of file dw-spi.c.
References address, dw_spi_read::address, working_area::address, bank, buf_set_u32(), buffer, dw_spi_read::buffer, buffer_size, dw_spi_read::buffer_size, mips32_algorithm::common_magic, dw_spi_read::data_reg, destroy_mem_param(), destroy_reg_param(), DW_SPI_ARG_REG, DW_SPI_REG_DR, DW_SPI_REG_SR, dw_spi_read::four_byte_mode, dw_spi_driver::four_byte_mode, init_mem_param(), init_reg_param(), LOG_ERROR, MIPS32_COMMON_MAGIC, MIPS32_ISA_MIPS32, PARAM_OUT, read_cmd, dw_spi_read::read_cmd, dw_spi_driver::regmap, dw_spi_regmap::simc, working_area::size, dw_spi_read::status_reg, target_alloc_working_area(), target_buffer_set_u32(), target_free_working_area(), target_read_buffer(), target_run_algorithm(), target_write_buffer(), dw_spi_driver::timeout, mem_param::value, and reg_param::value.
Referenced by dw_spi_read().
|
static |
Do data transaction.
Buffer data are sent and replaced with received data. Total buffer size is a sum of TX and RX messages. RX portion of the buffer is initially filled with dummy values, which get replaced by the message.
[in] | bank | Flash bank. |
[in,out] | buffer | Data buffer. If read flag is set, buffer is filled with received data. |
[in] | size | buffer size. |
[in] | read | The read flag. If set to true, read values will override buffer . |
Definition at line 356 of file dw-spi.c.
References working_area::address, bank, buf_set_u32(), buffer, dw_spi_transaction::buffer, mips32_algorithm::common_magic, dw_spi_transaction::data_reg, destroy_mem_param(), destroy_reg_param(), DW_SPI_ARG_REG, DW_SPI_REG_DR, DW_SPI_REG_SR, DW_SPI_TIMEOUT_TRANSACTION, init_mem_param(), init_reg_param(), LOG_ERROR, MIPS32_COMMON_MAGIC, MIPS32_ISA_MIPS32, PARAM_OUT, dw_spi_transaction::read_flag, dw_spi_driver::regmap, dw_spi_regmap::simc, size, dw_spi_transaction::size, working_area::size, dw_spi_transaction::status_reg, target_alloc_working_area(), target_buffer_set_u32(), target_free_working_area(), target_read_buffer(), target_run_algorithm(), target_write_buffer(), mem_param::value, and reg_param::value.
Referenced by dw_spi_erase_chip(), dw_spi_read_id(), dw_spi_read_status(), and dw_spi_write_enable().
|
static |
Flash bank erase sectors.
[in] | bank | Flash bank handle. |
[in] | first | The first sector to erase. |
[in] | last | The last sector to erase. |
Definition at line 1482 of file dw-spi.c.
References bank, dw_spi_erase_sectors(), dw_spi_master_ctrl_configure(), and dw_spi_master_ctrl_restore().
|
static |
Flash bank erase check.
[in] | bank | Flash bank handle. |
Definition at line 1547 of file dw-spi.c.
References bank, dw_spi_blank_check(), dw_spi_master_ctrl_configure(), and dw_spi_master_ctrl_restore().
|
static |
Erase Flash chip.
[in] | bank | Flash bank handle. |
Definition at line 1060 of file dw-spi.c.
References bank, buffer, buffer_size, flash_device::chip_erase_cmd, dw_spi_ctrl_transaction(), dw_spi_wait_finish(), dw_spi_write_enable(), ERROR_OK, LOG_ERROR, dw_spi_driver::spi_flash, and dw_spi_driver::timeout.
Referenced by dw_spi_erase_sectors().
|
static |
Flash device erase sectors.
[in] | bank | Flash bank handle. |
[in] | first | The first sector to erase. |
[in] | last | The last sector to erase. |
Definition at line 1098 of file dw-spi.c.
References bank, dw_spi_ctrl_erase_sectors(), dw_spi_erase_chip(), flash_device::erase_cmd, ERROR_OK, LOG_ERROR, flash_device::sectorsize, dw_spi_driver::spi_flash, SPIFLASH_BSY_BIT, SPIFLASH_READ_STATUS, SPIFLASH_WE_BIT, and SPIFLASH_WRITE_ENABLE.
Referenced by dw_spi_erase().
|
static |
Flash bank info.
[in] | bank | Flash bank handle. |
[in,out] | cmd | Command invocation. |
Definition at line 1567 of file dw-spi.c.
References bank, cmd, command_print(), command_print_sameline(), ERROR_OK, dw_spi_driver::id, flash_device::name, and dw_spi_driver::spi_flash.
|
static |
Prepare master controller for transaction.
[in] | bank | Flash bank handle. |
Definition at line 1341 of file dw-spi.c.
References bank, dw_spi_assert_halted(), dw_spi_ctrl_configure_si(), dw_spi_ctrl_configure_speed(), dw_spi_ctrl_disable_interrupts(), dw_spi_ctrl_mode_configure(), dw_spi_master_ctrl_enable(), DW_SPI_SI_MODE_MASTER, ERROR_OK, and LOG_ERROR.
Referenced by dw_spi_erase(), dw_spi_erase_check(), dw_spi_probe(), dw_spi_read(), and dw_spi_write().
|
static |
Enable master controller.
Configuration of the master controller must be done when it is disabled.
[in] | bank | Flash bank. |
[in] | value | New enable state. |
Definition at line 243 of file dw-spi.c.
References bank, DW_SPI_REG_SIMCEN, DW_SPI_REG_SIMCEN_SIMCEN, LOG_ERROR, dw_spi_driver::regmap, dw_spi_regmap::simc, and target_write_u32().
Referenced by dw_spi_master_ctrl_configure(), and dw_spi_master_ctrl_restore().
|
static |
Restore SI controller selection.
[in] | bank | Flash bank handle. |
Definition at line 1387 of file dw-spi.c.
References bank, dw_spi_ctrl_mode_restore(), dw_spi_master_ctrl_enable(), and LOG_ERROR.
Referenced by dw_spi_erase(), dw_spi_erase_check(), dw_spi_probe(), dw_spi_read(), and dw_spi_write().
|
static |
Flash bank probe.
[in] | bank | Flash bank handle. |
Definition at line 1410 of file dw-spi.c.
References alloc_block_array(), bank, dw_spi_master_ctrl_configure(), dw_spi_master_ctrl_restore(), dw_spi_spiflash_search(), ERROR_FAIL, ERROR_FLASH_BANK_INVALID, ERROR_TARGET_INVALID, LOG_ERROR, LOG_INFO, LOG_WARNING, mips_m4k_target, target_type::name, dw_spi_driver::probed, flash_device::sectorsize, size, flash_device::size_in_bytes, dw_spi_driver::spi_flash, and TARGET_LITTLE_ENDIAN.
Referenced by dw_spi_auto_probe().
|
static |
Flash bank read data using master controller.
[in] | bank | Flash bank handle. |
[out] | buffer | Data buffer. |
[in] | offset | Flash address offset. |
[in] | count | buffer size. |
Definition at line 1525 of file dw-spi.c.
References bank, buffer, count, dw_spi_ctrl_read(), dw_spi_master_ctrl_configure(), dw_spi_master_ctrl_restore(), offset, flash_device::read_cmd, and dw_spi_driver::spi_flash.
|
static |
Read Flash device ID.
[in] | bank | Flash bank handle. |
Definition at line 945 of file dw-spi.c.
References bank, buffer, buffer_size, dw_spi_ctrl_transaction(), ERROR_OK, dw_spi_driver::id, le_to_h_u32(), LOG_DEBUG, LOG_ERROR, and SPIFLASH_READ_ID.
Referenced by dw_spi_spiflash_search().
|
static |
Read Flash device status.
[in] | bank | Flash bank handle. |
[out] | status | The status byte. |
Definition at line 977 of file dw-spi.c.
References bank, buffer, buffer_size, dw_spi_ctrl_transaction(), ERROR_OK, LOG_ERROR, SPIFLASH_READ_STATUS, and status.
Referenced by dw_spi_wait_finish(), and dw_spi_write_enable().
|
static |
Search for Flash chip info.
[in] | bank | Flash bank handle. |
Definition at line 1225 of file dw-spi.c.
References bank, dw_spi_read_id(), ERROR_FAIL, ERROR_OK, flash_devices, dw_spi_driver::id, LOG_ERROR, name, and dw_spi_driver::spi_flash.
Referenced by dw_spi_probe().
|
static |
Wait for Flash command to finish.
[in] | bank | Flash bank handle. |
[in] | timeout | The timeout in ms. |
Definition at line 1004 of file dw-spi.c.
References alive_sleep(), bank, dw_spi_read_status(), ERROR_OK, ERROR_TIMEOUT_REACHED, LOG_ERROR, SPIFLASH_BSY_BIT, status, dw_spi_driver::timeout, and timeval_ms().
Referenced by dw_spi_erase_chip().
|
static |
Flash bank write data.
[in] | bank | Flash bank handle. |
[in] | buffer | Data buffer. |
[in] | offset | Flash address offset. |
[in] | count | buffer size. |
Definition at line 1503 of file dw-spi.c.
References bank, buffer, count, dw_spi_master_ctrl_configure(), dw_spi_master_ctrl_restore(), dw_spi_write_buffer(), and offset.
|
static |
Write buffer to Flash.
[in] | bank | Flash bank handle. |
[in] | buffer | Data buffer. |
[in] | offset | Flash address offset. |
[in] | count | buffer size. |
Definition at line 1173 of file dw-spi.c.
References address, ARRAY_SIZE, bank, buffer, count, dw_spi_ctrl_program(), ERROR_OK, LOG_ERROR, MIN, offset, page_size, flash_device::pagesize, flash_device::pprog_cmd, dw_spi_driver::spi_flash, SPIFLASH_BSY_BIT, SPIFLASH_READ_STATUS, SPIFLASH_WE_BIT, and SPIFLASH_WRITE_ENABLE.
Referenced by dw_spi_write().
|
static |
Flash device write enable.
[in] | bank | Flash bank handle. |
Definition at line 1031 of file dw-spi.c.
References bank, buffer, buffer_size, dw_spi_ctrl_transaction(), dw_spi_read_status(), ERROR_FAIL, ERROR_OK, LOG_ERROR, SPIFLASH_WE_BIT, SPIFLASH_WRITE_ENABLE, and status.
Referenced by dw_spi_erase_chip().
FLASH_BANK_COMMAND_HANDLER | ( | dw_spi_flash_bank_command | ) |
Handle flash bank command.
[in] | CMD_ARGC | Number of arguments. |
[in] | CMD_ARGV | Command arguments. |
Definition at line 1256 of file dw-spi.c.
References bank, BIT, dw_spi_driver::chip_select_bitmask, CMD_ARGC, CMD_ARGV, COMMAND_PARSE_NUMBER, DW_SPI_TIMEOUT_DEFAULT, ERROR_COMMAND_SYNTAX_ERROR, ERROR_FAIL, ERROR_OK, dw_spi_driver::four_byte_mode, dw_spi_regmap::freq, jaguar2_regmap, LOG_ERROR, LOG_WARNING, ocelot_regmap, dw_spi_driver::regmap, dw_spi_regmap::si_if_owner_offset, dw_spi_regmap::simc, dw_spi_driver::speed, dw_spi_regmap::spi_mst, and dw_spi_driver::timeout.
const struct flash_driver dw_spi_flash |
DW-SPI NOR flash functions.
|
static |
Register map for Jaguar2 switch devices.
Definition at line 1 of file dw-spi.c.
Referenced by FLASH_BANK_COMMAND_HANDLER().
|
static |
Register map for Ocelot switch devices.
Definition at line 1 of file dw-spi.c.
Referenced by FLASH_BANK_COMMAND_HANDLER().