NAND/DAVINCI: remove private "target" copy

Remove "target" form private data, and use
common one in struct nand_block.

Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
Antonio Borneo 2010-12-31 19:46:03 +08:00 committed by Øyvind Harboe
parent 2e1f2b50fd
commit 3db34f8447
1 changed files with 17 additions and 27 deletions

View File

@ -39,8 +39,6 @@ enum ecc {
}; };
struct davinci_nand { struct davinci_nand {
struct target *target;
uint8_t chipsel; /* chipselect 0..3 == CS2..CS5 */ uint8_t chipsel; /* chipselect 0..3 == CS2..CS5 */
uint8_t eccmode; uint8_t eccmode;
@ -82,7 +80,7 @@ static int halted(struct target *target, const char *label)
static int davinci_init(struct nand_device *nand) static int davinci_init(struct nand_device *nand)
{ {
struct davinci_nand *info = nand->controller_priv; struct davinci_nand *info = nand->controller_priv;
struct target *target = info->target; struct target *target = nand->target;
uint32_t nandfcr; uint32_t nandfcr;
if (!halted(target, "init")) if (!halted(target, "init"))
@ -112,7 +110,7 @@ static int davinci_reset(struct nand_device *nand)
static int davinci_nand_ready(struct nand_device *nand, int timeout) static int davinci_nand_ready(struct nand_device *nand, int timeout)
{ {
struct davinci_nand *info = nand->controller_priv; struct davinci_nand *info = nand->controller_priv;
struct target *target = info->target; struct target *target = nand->target;
uint32_t nandfsr; uint32_t nandfsr;
/* NOTE: return code is zero/error, else success; not ERROR_* */ /* NOTE: return code is zero/error, else success; not ERROR_* */
@ -135,7 +133,7 @@ static int davinci_nand_ready(struct nand_device *nand, int timeout)
static int davinci_command(struct nand_device *nand, uint8_t command) static int davinci_command(struct nand_device *nand, uint8_t command)
{ {
struct davinci_nand *info = nand->controller_priv; struct davinci_nand *info = nand->controller_priv;
struct target *target = info->target; struct target *target = nand->target;
if (!halted(target, "command")) if (!halted(target, "command"))
return ERROR_NAND_OPERATION_FAILED; return ERROR_NAND_OPERATION_FAILED;
@ -147,7 +145,7 @@ static int davinci_command(struct nand_device *nand, uint8_t command)
static int davinci_address(struct nand_device *nand, uint8_t address) static int davinci_address(struct nand_device *nand, uint8_t address)
{ {
struct davinci_nand *info = nand->controller_priv; struct davinci_nand *info = nand->controller_priv;
struct target *target = info->target; struct target *target = nand->target;
if (!halted(target, "address")) if (!halted(target, "address"))
return ERROR_NAND_OPERATION_FAILED; return ERROR_NAND_OPERATION_FAILED;
@ -159,7 +157,7 @@ static int davinci_address(struct nand_device *nand, uint8_t address)
static int davinci_write_data(struct nand_device *nand, uint16_t data) static int davinci_write_data(struct nand_device *nand, uint16_t data)
{ {
struct davinci_nand *info = nand->controller_priv; struct davinci_nand *info = nand->controller_priv;
struct target *target = info->target; struct target *target = nand->target;
if (!halted(target, "write_data")) if (!halted(target, "write_data"))
return ERROR_NAND_OPERATION_FAILED; return ERROR_NAND_OPERATION_FAILED;
@ -171,7 +169,7 @@ static int davinci_write_data(struct nand_device *nand, uint16_t data)
static int davinci_read_data(struct nand_device *nand, void *data) static int davinci_read_data(struct nand_device *nand, void *data)
{ {
struct davinci_nand *info = nand->controller_priv; struct davinci_nand *info = nand->controller_priv;
struct target *target = info->target; struct target *target = nand->target;
if (!halted(target, "read_data")) if (!halted(target, "read_data"))
return ERROR_NAND_OPERATION_FAILED; return ERROR_NAND_OPERATION_FAILED;
@ -186,7 +184,7 @@ static int davinci_read_block_data(struct nand_device *nand,
uint8_t *data, int data_size) uint8_t *data, int data_size)
{ {
struct davinci_nand *info = nand->controller_priv; struct davinci_nand *info = nand->controller_priv;
struct target *target = info->target; struct target *target = nand->target;
uint32_t nfdata = info->data; uint32_t nfdata = info->data;
uint32_t tmp; uint32_t tmp;
@ -219,7 +217,7 @@ static int davinci_write_block_data(struct nand_device *nand,
uint8_t *data, int data_size) uint8_t *data, int data_size)
{ {
struct davinci_nand *info = nand->controller_priv; struct davinci_nand *info = nand->controller_priv;
struct target *target = info->target; struct target *target = nand->target;
uint32_t nfdata = info->data; uint32_t nfdata = info->data;
uint32_t tmp; uint32_t tmp;
int status; int status;
@ -260,7 +258,7 @@ static int davinci_write_page(struct nand_device *nand, uint32_t page,
if (!nand->device) if (!nand->device)
return ERROR_NAND_DEVICE_NOT_PROBED; return ERROR_NAND_DEVICE_NOT_PROBED;
if (!halted(info->target, "write_page")) if (!halted(nand->target, "write_page"))
return ERROR_NAND_OPERATION_FAILED; return ERROR_NAND_OPERATION_FAILED;
/* Always write both data and OOB ... we are not "raw" I/O! */ /* Always write both data and OOB ... we are not "raw" I/O! */
@ -309,7 +307,7 @@ static int davinci_read_page(struct nand_device *nand, uint32_t page,
if (!nand->device) if (!nand->device)
return ERROR_NAND_DEVICE_NOT_PROBED; return ERROR_NAND_DEVICE_NOT_PROBED;
if (!halted(info->target, "read_page")) if (!halted(nand->target, "read_page"))
return ERROR_NAND_OPERATION_FAILED; return ERROR_NAND_OPERATION_FAILED;
return info->read_page(nand, page, data, data_size, oob, oob_size); return info->read_page(nand, page, data, data_size, oob, oob_size);
@ -318,7 +316,7 @@ static int davinci_read_page(struct nand_device *nand, uint32_t page,
static void davinci_write_pagecmd(struct nand_device *nand, uint8_t cmd, uint32_t page) static void davinci_write_pagecmd(struct nand_device *nand, uint8_t cmd, uint32_t page)
{ {
struct davinci_nand *info = nand->controller_priv; struct davinci_nand *info = nand->controller_priv;
struct target *target = info->target; struct target *target = nand->target;
int page3 = nand->address_cycles - (nand->page_size == 512); int page3 = nand->address_cycles - (nand->page_size == 512);
/* write command ({page,otp}x{read,program} */ /* write command ({page,otp}x{read,program} */
@ -341,7 +339,7 @@ static void davinci_write_pagecmd(struct nand_device *nand, uint8_t cmd, uint32_
static int davinci_seek_column(struct nand_device *nand, uint16_t column) static int davinci_seek_column(struct nand_device *nand, uint16_t column)
{ {
struct davinci_nand *info = nand->controller_priv; struct davinci_nand *info = nand->controller_priv;
struct target *target = info->target; struct target *target = nand->target;
/* Random read, we must have issued a page read already */ /* Random read, we must have issued a page read already */
target_write_u8(target, info->cmd, NAND_CMD_RNDOUT); target_write_u8(target, info->cmd, NAND_CMD_RNDOUT);
@ -363,7 +361,7 @@ static int davinci_writepage_tail(struct nand_device *nand,
uint8_t *oob, uint32_t oob_size) uint8_t *oob, uint32_t oob_size)
{ {
struct davinci_nand *info = nand->controller_priv; struct davinci_nand *info = nand->controller_priv;
struct target *target = info->target; struct target *target = nand->target;
uint8_t status; uint8_t status;
if (oob_size) if (oob_size)
@ -396,7 +394,7 @@ static int davinci_write_page_ecc1(struct nand_device *nand, uint32_t page,
{ {
unsigned oob_offset; unsigned oob_offset;
struct davinci_nand *info = nand->controller_priv; struct davinci_nand *info = nand->controller_priv;
struct target *target = info->target; struct target *target = nand->target;
const uint32_t fcr_addr = info->aemif + NANDFCR; const uint32_t fcr_addr = info->aemif + NANDFCR;
const uint32_t ecc1_addr = info->aemif + NANDFECC + (4 * info->chipsel); const uint32_t ecc1_addr = info->aemif + NANDFECC + (4 * info->chipsel);
uint32_t fcr, ecc1; uint32_t fcr, ecc1;
@ -484,7 +482,7 @@ static int davinci_write_page_ecc4(struct nand_device *nand, uint32_t page,
struct davinci_nand *info = nand->controller_priv; struct davinci_nand *info = nand->controller_priv;
const uint8_t *l; const uint8_t *l;
struct target *target = info->target; struct target *target = nand->target;
const uint32_t fcr_addr = info->aemif + NANDFCR; const uint32_t fcr_addr = info->aemif + NANDFCR;
const uint32_t ecc4_addr = info->aemif + NAND4BITECC; const uint32_t ecc4_addr = info->aemif + NAND4BITECC;
uint32_t fcr, ecc4; uint32_t fcr, ecc4;
@ -564,7 +562,7 @@ static int davinci_write_page_ecc4infix(struct nand_device *nand, uint32_t page,
uint8_t *data, uint32_t data_size, uint8_t *oob, uint32_t oob_size) uint8_t *data, uint32_t data_size, uint8_t *oob, uint32_t oob_size)
{ {
struct davinci_nand *info = nand->controller_priv; struct davinci_nand *info = nand->controller_priv;
struct target *target = info->target; struct target *target = nand->target;
const uint32_t fcr_addr = info->aemif + NANDFCR; const uint32_t fcr_addr = info->aemif + NANDFCR;
const uint32_t ecc4_addr = info->aemif + NAND4BITECC; const uint32_t ecc4_addr = info->aemif + NAND4BITECC;
uint32_t fcr, ecc4; uint32_t fcr, ecc4;
@ -678,7 +676,6 @@ static int davinci_read_page_ecc4infix(struct nand_device *nand, uint32_t page,
NAND_DEVICE_COMMAND_HANDLER(davinci_nand_device_command) NAND_DEVICE_COMMAND_HANDLER(davinci_nand_device_command)
{ {
struct davinci_nand *info; struct davinci_nand *info;
struct target *target;
unsigned long chip, aemif; unsigned long chip, aemif;
enum ecc eccmode; enum ecc eccmode;
int chipsel; int chipsel;
@ -698,12 +695,6 @@ NAND_DEVICE_COMMAND_HANDLER(davinci_nand_device_command)
goto fail; goto fail;
} }
target = get_target(CMD_ARGV[1]);
if (!target) {
LOG_ERROR("invalid target %s", CMD_ARGV[1]);
goto fail;
}
COMMAND_PARSE_NUMBER(ulong, CMD_ARGV[2], chip); COMMAND_PARSE_NUMBER(ulong, CMD_ARGV[2], chip);
if (chip == 0) { if (chip == 0) {
LOG_ERROR("Invalid NAND chip address %s", CMD_ARGV[2]); LOG_ERROR("Invalid NAND chip address %s", CMD_ARGV[2]);
@ -749,7 +740,6 @@ NAND_DEVICE_COMMAND_HANDLER(davinci_nand_device_command)
if (info == NULL) if (info == NULL)
goto fail; goto fail;
info->target = target;
info->eccmode = eccmode; info->eccmode = eccmode;
info->chipsel = chipsel; info->chipsel = chipsel;
info->aemif = aemif; info->aemif = aemif;
@ -759,7 +749,7 @@ NAND_DEVICE_COMMAND_HANDLER(davinci_nand_device_command)
nand->controller_priv = info; nand->controller_priv = info;
info->io.target = target; info->io.target = nand->target;
info->io.data = info->data; info->io.data = info->data;
info->io.op = ARM_NAND_NONE; info->io.op = ARM_NAND_NONE;