OpenOCD
mxc.c File Reference
Include dependency graph for mxc.c:

Go to the source code of this file.

Macros

#define nfc_is_v1()
 
#define nfc_is_v2()
 
#define OOB_SIZE   64
 

Functions

static uint32_t align_address_v2 (struct nand_device *nand, uint32_t addr)
 
 COMMAND_HANDLER (handle_mxc_biswap_command)
 
static int do_data_output (struct nand_device *nand)
 
static int ecc_status_v1 (struct nand_device *nand)
 
static int ecc_status_v2 (struct nand_device *nand)
 
static int get_next_byte_from_sram_buffer (struct nand_device *nand, uint8_t *value)
 
static int get_next_halfword_from_sram_buffer (struct nand_device *nand, uint16_t *value)
 
static int initialize_nf_controller (struct nand_device *nand)
 
static int mxc_address (struct nand_device *nand, uint8_t address)
 
static int mxc_command (struct nand_device *nand, uint8_t command)
 
static int mxc_init (struct nand_device *nand)
 
static int mxc_nand_ready (struct nand_device *nand, int tout)
 
static int mxc_read_data (struct nand_device *nand, void *data)
 
static int mxc_read_page (struct nand_device *nand, uint32_t page, uint8_t *data, uint32_t data_size, uint8_t *oob, uint32_t oob_size)
 
static int mxc_reset (struct nand_device *nand)
 
static int mxc_write_data (struct nand_device *nand, uint16_t data)
 
static int mxc_write_page (struct nand_device *nand, uint32_t page, uint8_t *data, uint32_t data_size, uint8_t *oob, uint32_t oob_size)
 
 NAND_DEVICE_COMMAND_HANDLER (mxc_nand_device_command)
 
static int poll_for_complete_op (struct nand_device *nand, const char *text)
 
static int validate_target_state (struct nand_device *nand)
 

Variables

static const char data_block_size_err_msg []
 
static const char get_status_register_err_msg [] = "can't get NAND status"
 
static uint32_t in_sram_address
 
static const struct command_registration mxc_nand_command_handler []
 
struct nand_flash_controller mxc_nand_flash_controller
 
static const struct command_registration mxc_sub_command_handlers []
 
static unsigned char sign_of_sequental_byte_read
 
static const char sram_buffer_bounds_err_msg []
 
static const char target_not_halted_err_msg []
 

Macro Definition Documentation

◆ nfc_is_v1

#define nfc_is_v1 ( )
Value:
(mxc_nf_info->mxc_version == MXC_VERSION_MX27 || \
mxc_nf_info->mxc_version == MXC_VERSION_MX31)
@ MXC_VERSION_MX27
Definition: mxc.h:124
@ MXC_VERSION_MX31
Definition: mxc.h:125

Definition at line 41 of file mxc.c.

◆ nfc_is_v2

#define nfc_is_v2 ( )
Value:
(mxc_nf_info->mxc_version == MXC_VERSION_MX25 || \
mxc_nf_info->mxc_version == MXC_VERSION_MX35)
@ MXC_VERSION_MX25
Definition: mxc.h:123
@ MXC_VERSION_MX35
Definition: mxc.h:126

Definition at line 43 of file mxc.c.

◆ OOB_SIZE

#define OOB_SIZE   64

Definition at line 39 of file mxc.c.

Function Documentation

◆ align_address_v2()

◆ COMMAND_HANDLER()

◆ do_data_output()

◆ ecc_status_v1()

static int ecc_status_v1 ( struct nand_device nand)
static

◆ ecc_status_v2()

static int ecc_status_v2 ( struct nand_device nand)
static

◆ get_next_byte_from_sram_buffer()

◆ get_next_halfword_from_sram_buffer()

static int get_next_halfword_from_sram_buffer ( struct nand_device nand,
uint16_t *  value 
)
static

◆ initialize_nf_controller()

◆ mxc_address()

static int mxc_address ( struct nand_device nand,
uint8_t  address 
)
static

◆ mxc_command()

◆ mxc_init()

◆ mxc_nand_ready()

static int mxc_nand_ready ( struct nand_device nand,
int  tout 
)
static

◆ mxc_read_data()

static int mxc_read_data ( struct nand_device nand,
void *  data 
)
static

◆ mxc_read_page()

◆ mxc_reset()

static int mxc_reset ( struct nand_device nand)
static

Definition at line 314 of file mxc.c.

References ERROR_OK, initialize_nf_controller(), and validate_target_state().

◆ mxc_write_data()

static int mxc_write_data ( struct nand_device nand,
uint16_t  data 
)
static

Definition at line 308 of file mxc.c.

References ERROR_NAND_OPERATION_FAILED, and LOG_ERROR.

◆ mxc_write_page()

◆ NAND_DEVICE_COMMAND_HANDLER()

◆ poll_for_complete_op()

static int poll_for_complete_op ( struct nand_device nand,
const char *  text 
)
static

◆ validate_target_state()

Variable Documentation

◆ data_block_size_err_msg

const char data_block_size_err_msg[]
static
Initial value:
=
"minimal granularity is one half-word, %" PRIu32 " is incorrect"

Definition at line 56 of file mxc.c.

Referenced by mxc_read_page(), and mxc_write_page().

◆ get_status_register_err_msg

const char get_status_register_err_msg[] = "can't get NAND status"
static

Definition at line 60 of file mxc.c.

Referenced by mxc_init(), and mxc_write_page().

◆ in_sram_address

uint32_t in_sram_address
static

◆ mxc_nand_command_handler

const struct command_registration mxc_nand_command_handler[]
static
Initial value:
= {
{
.name = "mxc",
.mode = COMMAND_ANY,
.help = "MXC NAND flash controller commands",
.usage = "",
},
}
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
Definition: command.h:253
@ COMMAND_ANY
Definition: command.h:42
static const struct command_registration mxc_sub_command_handlers[]
Definition: mxc.c:168
const char * usage
a string listing the options and arguments, required or optional
Definition: command.h:241

Definition at line 139 of file mxc.c.

◆ mxc_nand_flash_controller

struct nand_flash_controller mxc_nand_flash_controller
Initial value:
= {
.name = "mxc",
.nand_device_command = &mxc_nand_device_command,
.init = &mxc_init,
.reset = &mxc_reset,
.command = &mxc_command,
.address = &mxc_address,
.write_data = &mxc_write_data,
.read_data = &mxc_read_data,
.write_page = &mxc_write_page,
.read_page = &mxc_read_page,
.nand_ready = &mxc_nand_ready,
}
static int mxc_write_page(struct nand_device *nand, uint32_t page, uint8_t *data, uint32_t data_size, uint8_t *oob, uint32_t oob_size)
Definition: mxc.c:448
static int mxc_nand_ready(struct nand_device *nand, int tout)
Definition: mxc.c:424
static int mxc_read_data(struct nand_device *nand, void *data)
Definition: mxc.c:279
static int mxc_reset(struct nand_device *nand)
Definition: mxc.c:314
static int mxc_command(struct nand_device *nand, uint8_t command)
Definition: mxc.c:327
static int mxc_write_data(struct nand_device *nand, uint16_t data)
Definition: mxc.c:308
static const struct command_registration mxc_nand_command_handler[]
Definition: mxc.c:180
static int mxc_read_page(struct nand_device *nand, uint32_t page, uint8_t *data, uint32_t data_size, uint8_t *oob, uint32_t oob_size)
Definition: mxc.c:577
static int mxc_init(struct nand_device *nand)
Definition: mxc.c:191
static int mxc_address(struct nand_device *nand, uint8_t address)
Definition: mxc.c:399

Definition at line 901 of file mxc.c.

◆ mxc_sub_command_handlers

const struct command_registration mxc_sub_command_handlers[]
static
Initial value:
= {
{
.name = "biswap",
.mode = COMMAND_EXEC,
.handler = handle_mxc_biswap_command,
.help = "Turns on/off bad block information swapping from main area, "
"without parameter query status.",
.usage = "bank_id ['enable'|'disable']",
},
}
@ COMMAND_EXEC
Definition: command.h:40

Definition at line 139 of file mxc.c.

◆ sign_of_sequental_byte_read

unsigned char sign_of_sequental_byte_read
static

◆ sram_buffer_bounds_err_msg

const char sram_buffer_bounds_err_msg[]
static
Initial value:
=
"trying to access out of SRAM buffer bound (addr=0x%" PRIx32 ")"

Definition at line 58 of file mxc.c.

Referenced by get_next_byte_from_sram_buffer(), and get_next_halfword_from_sram_buffer().

◆ target_not_halted_err_msg

const char target_not_halted_err_msg[]
static
Initial value:
=
"target must be halted to use mxc NAND flash controller"

Definition at line 54 of file mxc.c.

Referenced by validate_target_state().