return ERROR_FLASH_BANK_INVALID;
}
- struct target *target = get_target(CMD_ARGV[1]);
- if (NULL == target)
- {
- LOG_ERROR("target '%s' not defined", CMD_ARGV[1]);
- return ERROR_NAND_DEVICE_INVALID;
- }
-
uint32_t osc_freq;
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], osc_freq);
lpc3180_info = malloc(sizeof(struct lpc3180_nand_controller));
nand->controller_priv = lpc3180_info;
- lpc3180_info->target = target;
lpc3180_info->osc_freq = osc_freq;
if ((lpc3180_info->osc_freq < 1000) || (lpc3180_info->osc_freq > 20000))
return (m / (2 * p)) * (fclkin / n);
}
-static float lpc3180_cycle_time(struct lpc3180_nand_controller *lpc3180_info)
+static float lpc3180_cycle_time(struct nand_device *nand)
{
- struct target *target = lpc3180_info->target;
+ struct lpc3180_nand_controller *lpc3180_info = nand->controller_priv;
+ struct target *target = nand->target;
uint32_t sysclk_ctrl, pwr_ctrl, hclkdiv_ctrl, hclkpll_ctrl;
int sysclk;
int hclk;
static int lpc3180_init(struct nand_device *nand)
{
struct lpc3180_nand_controller *lpc3180_info = nand->controller_priv;
- struct target *target = lpc3180_info->target;
+ struct target *target = nand->target;
int bus_width = nand->bus_width ? : 8;
int address_cycles = nand->address_cycles ? : 3;
int page_size = nand->page_size ? : 512;
target_write_u32(target, 0x200b8030, mlc_icr_value);
/* calculate NAND controller timings */
- cycle = lpc3180_cycle_time(lpc3180_info);
+ cycle = lpc3180_cycle_time(nand);
twp = ((40 / cycle) + 1);
twh = ((20 / cycle) + 1);
/* calculate NAND controller timings */
- cycle = lpc3180_cycle_time(lpc3180_info);
+ cycle = lpc3180_cycle_time(nand);
r_setup = w_setup = 0;
r_hold = w_hold = 10 / cycle;
static int lpc3180_reset(struct nand_device *nand)
{
struct lpc3180_nand_controller *lpc3180_info = nand->controller_priv;
- struct target *target = lpc3180_info->target;
+ struct target *target = nand->target;
if (target->state != TARGET_HALTED)
{
static int lpc3180_command(struct nand_device *nand, uint8_t command)
{
struct lpc3180_nand_controller *lpc3180_info = nand->controller_priv;
- struct target *target = lpc3180_info->target;
+ struct target *target = nand->target;
if (target->state != TARGET_HALTED)
{
static int lpc3180_address(struct nand_device *nand, uint8_t address)
{
struct lpc3180_nand_controller *lpc3180_info = nand->controller_priv;
- struct target *target = lpc3180_info->target;
+ struct target *target = nand->target;
if (target->state != TARGET_HALTED)
{
static int lpc3180_write_data(struct nand_device *nand, uint16_t data)
{
struct lpc3180_nand_controller *lpc3180_info = nand->controller_priv;
- struct target *target = lpc3180_info->target;
+ struct target *target = nand->target;
if (target->state != TARGET_HALTED)
{
static int lpc3180_read_data(struct nand_device *nand, void *data)
{
struct lpc3180_nand_controller *lpc3180_info = nand->controller_priv;
- struct target *target = lpc3180_info->target;
+ struct target *target = nand->target;
if (target->state != TARGET_HALTED)
{
static int lpc3180_write_page(struct nand_device *nand, uint32_t page, uint8_t *data, uint32_t data_size, uint8_t *oob, uint32_t oob_size)
{
struct lpc3180_nand_controller *lpc3180_info = nand->controller_priv;
- struct target *target = lpc3180_info->target;
+ struct target *target = nand->target;
int retval;
uint8_t status;
uint8_t *page_buffer;
static int lpc3180_read_page(struct nand_device *nand, uint32_t page, uint8_t *data, uint32_t data_size, uint8_t *oob, uint32_t oob_size)
{
struct lpc3180_nand_controller *lpc3180_info = nand->controller_priv;
- struct target *target = lpc3180_info->target;
+ struct target *target = nand->target;
uint8_t *page_buffer;
if (target->state != TARGET_HALTED)
static int lpc3180_controller_ready(struct nand_device *nand, int timeout)
{
struct lpc3180_nand_controller *lpc3180_info = nand->controller_priv;
- struct target *target = lpc3180_info->target;
+ struct target *target = nand->target;
if (target->state != TARGET_HALTED)
{
static int lpc3180_nand_ready(struct nand_device *nand, int timeout)
{
struct lpc3180_nand_controller *lpc3180_info = nand->controller_priv;
- struct target *target = lpc3180_info->target;
+ struct target *target = nand->target;
if (target->state != TARGET_HALTED)
{
static int lpc3180_tc_ready(struct nand_device *nand, int timeout)
{
struct lpc3180_nand_controller *lpc3180_info = nand->controller_priv;
- struct target *target = lpc3180_info->target;
+ struct target *target = nand->target;
if (target->state != TARGET_HALTED)
{