summaryrefslogtreecommitdiff
path: root/src/flash/nand
diff options
context:
space:
mode:
Diffstat (limited to 'src/flash/nand')
-rw-r--r--src/flash/nand/lpc3180.c39
-rw-r--r--src/flash/nand/lpc3180.h1
2 files changed, 16 insertions, 24 deletions
diff --git a/src/flash/nand/lpc3180.c b/src/flash/nand/lpc3180.c
index 3285c42f..4cd4c6f3 100644
--- a/src/flash/nand/lpc3180.c
+++ b/src/flash/nand/lpc3180.c
@@ -49,13 +49,6 @@ 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);
@@ -63,7 +56,6 @@ NAND_DEVICE_COMMAND_HANDLER(lpc3180_nand_device_command)
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))
@@ -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;
@@ -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;
@@ -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);
@@ -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;
@@ -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)
{
@@ -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)
{
@@ -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)
{
@@ -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)
{
@@ -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)
{
@@ -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;
@@ -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)
@@ -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)
{
@@ -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)
{
@@ -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)
{
diff --git a/src/flash/nand/lpc3180.h b/src/flash/nand/lpc3180.h
index 88280f32..d524cfee 100644
--- a/src/flash/nand/lpc3180.h
+++ b/src/flash/nand/lpc3180.h
@@ -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;