Skip to content

Commit

Permalink
NAND/LPC3180: remove private "target" copy
Browse files Browse the repository at this point in the history
Remove "target" form private data, and use
common one in struct nand_block.

Signed-off-by: Antonio Borneo <[email protected]>
  • Loading branch information
borneoa authored and oharboe committed Jan 2, 2011
1 parent 3db34f8 commit 35c30e9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 24 deletions.
39 changes: 16 additions & 23 deletions src/flash/nand/lpc3180.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,13 @@ NAND_DEVICE_COMMAND_HANDLER(lpc3180_nand_device_command)
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);

struct lpc3180_nand_controller *lpc3180_info;
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))
Expand Down Expand Up @@ -106,9 +98,10 @@ static int lpc3180_pll(int fclkin, uint32_t pll_ctrl)
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;
Expand Down Expand Up @@ -159,7 +152,7 @@ static float lpc3180_cycle_time(struct lpc3180_nand_controller *lpc3180_info)
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;
Expand Down Expand Up @@ -234,7 +227,7 @@ static int lpc3180_init(struct nand_device *nand)
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);
Expand Down Expand Up @@ -280,7 +273,7 @@ static int lpc3180_init(struct nand_device *nand)


/* 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;
Expand All @@ -301,7 +294,7 @@ static int lpc3180_init(struct nand_device *nand)
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)
{
Expand Down Expand Up @@ -343,7 +336,7 @@ static int lpc3180_reset(struct nand_device *nand)
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)
{
Expand Down Expand Up @@ -373,7 +366,7 @@ static int lpc3180_command(struct nand_device *nand, uint8_t command)
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)
{
Expand Down Expand Up @@ -403,7 +396,7 @@ static int lpc3180_address(struct nand_device *nand, uint8_t address)
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)
{
Expand Down Expand Up @@ -433,7 +426,7 @@ static int lpc3180_write_data(struct nand_device *nand, uint16_t data)
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)
{
Expand Down Expand Up @@ -495,7 +488,7 @@ static int lpc3180_read_data(struct nand_device *nand, void *data)
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;
Expand Down Expand Up @@ -831,7 +824,7 @@ static int lpc3180_write_page(struct nand_device *nand, uint32_t page, uint8_t *
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)
Expand Down Expand Up @@ -1146,7 +1139,7 @@ static int lpc3180_read_page(struct nand_device *nand, uint32_t page, uint8_t *d
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)
{
Expand Down Expand Up @@ -1194,7 +1187,7 @@ static int lpc3180_controller_ready(struct nand_device *nand, int timeout)
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)
{
Expand Down Expand Up @@ -1242,7 +1235,7 @@ static int lpc3180_nand_ready(struct nand_device *nand, int timeout)
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)
{
Expand Down
1 change: 0 additions & 1 deletion src/flash/nand/lpc3180.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ enum lpc3180_selected_controller

struct lpc3180_nand_controller
{
struct target *target;
int osc_freq;
enum lpc3180_selected_controller selected_controller;
int is_bulk;
Expand Down

0 comments on commit 35c30e9

Please sign in to comment.