]> git.sur5r.net Git - openocd/commitdiff
NAND/LPC3180: remove private "target" copy
authorAntonio Borneo <borneo.antonio@gmail.com>
Fri, 31 Dec 2010 11:46:04 +0000 (19:46 +0800)
committerØyvind Harboe <oyvind.harboe@zylin.com>
Sun, 2 Jan 2011 18:57:45 +0000 (19:57 +0100)
Remove "target" form private data, and use
common one in struct nand_block.

Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
src/flash/nand/lpc3180.c
src/flash/nand/lpc3180.h

index 3285c42f1ecc28905abfa6e2baad09e083c65b10..4cd4c6f390e04ceadadf4d456ac0842b993eba4b 100644 (file)
@@ -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)
        {
index 88280f3250ea2e8a7f1774c4141f64d012d9a104..d524cfeeba92d86391324ab0e8f9d28d4f35c1e5 100644 (file)
@@ -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;