mxc nand: cosmectic: Light cleanup

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
Cc: Scott Wood <scottwood@freescale.com>
Cc: Stefano Babic <sbabic@denx.de>
Signed-off-by: Scott Wood <scottwood@freescale.com>
This commit is contained in:
Benoît Thébaudeau 2012-08-13 22:48:26 +02:00 committed by Scott Wood
parent 80c8ab7b25
commit 365b2c0761
3 changed files with 11 additions and 13 deletions

View File

@ -123,8 +123,7 @@ static int is_16bit_nand(void)
#elif defined(CONFIG_MX25) || defined(CONFIG_MX35) #elif defined(CONFIG_MX25) || defined(CONFIG_MX35)
static int is_16bit_nand(void) static int is_16bit_nand(void)
{ {
struct ccm_regs *ccm = struct ccm_regs *ccm = (struct ccm_regs *)IMX_CCM_BASE;
(struct ccm_regs *)IMX_CCM_BASE;
if (readl(&ccm->rcsr) & CCM_RCSR_NF_16BIT_SEL) if (readl(&ccm->rcsr) & CCM_RCSR_NF_16BIT_SEL)
return 1; return 1;
@ -238,7 +237,7 @@ static void send_prog_page(struct mxc_nand_host *host, uint8_t buf_id,
if (spare_only) if (spare_only)
config1 |= NFC_SP_EN; config1 |= NFC_SP_EN;
else else
config1 &= ~(NFC_SP_EN); config1 &= ~NFC_SP_EN;
writew(config1, &host->regs->config1); writew(config1, &host->regs->config1);
} }
@ -687,7 +686,6 @@ static int mxc_nand_correct_data(struct mtd_info *mtd, u_char *dat,
#define mxc_nand_write_page_syndrome NULL #define mxc_nand_write_page_syndrome NULL
#define mxc_nand_write_page_raw_syndrome NULL #define mxc_nand_write_page_raw_syndrome NULL
#define mxc_nand_write_oob_syndrome NULL #define mxc_nand_write_oob_syndrome NULL
#define mxc_nfc_11_nand_correct_data NULL
static int mxc_nand_correct_data(struct mtd_info *mtd, u_char *dat, static int mxc_nand_correct_data(struct mtd_info *mtd, u_char *dat,
u_char *read_ecc, u_char *calc_ecc) u_char *read_ecc, u_char *calc_ecc)
@ -1188,7 +1186,6 @@ int board_nand_init(struct nand_chip *this)
{ {
struct mtd_info *mtd; struct mtd_info *mtd;
uint16_t tmp; uint16_t tmp;
int err = 0;
#ifdef CONFIG_SYS_NAND_USE_FLASH_BBT #ifdef CONFIG_SYS_NAND_USE_FLASH_BBT
this->options |= NAND_USE_FLASH_BBT; this->options |= NAND_USE_FLASH_BBT;
@ -1287,5 +1284,5 @@ int board_nand_init(struct nand_chip *this)
this->ecc.layout = &nand_hw_eccoob; this->ecc.layout = &nand_hw_eccoob;
#endif #endif
mxc_setup_config1(); mxc_setup_config1();
return err; return 0;
} }

View File

@ -166,5 +166,6 @@ struct fsl_nfc_regs {
#define NFC_RST (1 << 6) #define NFC_RST (1 << 6)
#define NFC_CE (1 << 7) #define NFC_CE (1 << 7)
#define NFC_ONE_CYCLE (1 << 8) #define NFC_ONE_CYCLE (1 << 8)
#define NFC_FP_INT (1 << 11)
#endif /* __FSL_NFC_H */ #endif /* __FSL_NFC_H */

View File

@ -45,10 +45,10 @@ static void nfc_wait_ready(void)
writew(tmp, &nfc->config2); writew(tmp, &nfc->config2);
} }
void nfc_nand_init(void) static void nfc_nand_init(void)
{ {
#if defined(MXC_NFC_V1_1) #if defined(MXC_NFC_V1_1)
int ecc_per_page = CONFIG_SYS_NAND_PAGE_SIZE / 512; int ecc_per_page = CONFIG_SYS_NAND_PAGE_SIZE / 512;
int config1; int config1;
writew(CONFIG_SYS_NAND_SPARE_SIZE / 2, &nfc->spare_area_size); writew(CONFIG_SYS_NAND_SPARE_SIZE / 2, &nfc->spare_area_size);
@ -57,12 +57,12 @@ void nfc_nand_init(void)
writew(0x2, &nfc->config); writew(0x2, &nfc->config);
/* hardware ECC checking and correct */ /* hardware ECC checking and correct */
config1 = readw(&nfc->config1) | NFC_ECC_EN | 0x800; config1 = readw(&nfc->config1) | NFC_ECC_EN | NFC_FP_INT;
/* /*
* if spare size is larger that 16 bytes per 512 byte hunk * if spare size is larger that 16 bytes per 512 byte hunk
* then use 8 symbol correction instead of 4 * then use 8 symbol correction instead of 4
*/ */
if ((CONFIG_SYS_NAND_SPARE_SIZE / ecc_per_page) > 16) if (CONFIG_SYS_NAND_SPARE_SIZE / ecc_per_page > 16)
config1 &= ~NFC_4_8N_ECC; config1 &= ~NFC_4_8N_ECC;
else else
config1 |= NFC_4_8N_ECC; config1 |= NFC_4_8N_ECC;
@ -133,7 +133,7 @@ static void nfc_nand_data_output(void)
* This NAND controller requires multiple input commands * This NAND controller requires multiple input commands
* for pages larger than 512 bytes. * for pages larger than 512 bytes.
*/ */
for (i = 1; i < (CONFIG_SYS_NAND_PAGE_SIZE / 512); i++) { for (i = 1; i < CONFIG_SYS_NAND_PAGE_SIZE / 512; i++) {
config1 = readw(&nfc->config1); config1 = readw(&nfc->config1);
config1 |= NFC_ECC_EN | NFC_INT_MSK; config1 |= NFC_ECC_EN | NFC_INT_MSK;
writew(config1, &nfc->config1); writew(config1, &nfc->config1);
@ -171,7 +171,7 @@ static int nfc_read_page(unsigned int page_address, unsigned char *buf)
dst = (u32 *)buf; dst = (u32 *)buf;
/* main copy loop from NAND-buffer to SDRAM memory */ /* main copy loop from NAND-buffer to SDRAM memory */
for (i = 0; i < (CONFIG_SYS_NAND_PAGE_SIZE / 4); i++) { for (i = 0; i < CONFIG_SYS_NAND_PAGE_SIZE / 4; i++) {
writel(readl(src), dst); writel(readl(src), dst);
src++; src++;
dst++; dst++;
@ -230,7 +230,7 @@ static int nand_load(unsigned int from, unsigned int size, unsigned char *buf)
page = from / CONFIG_SYS_NAND_PAGE_SIZE; page = from / CONFIG_SYS_NAND_PAGE_SIZE;
i = 0; i = 0;
while (i < (size / CONFIG_SYS_NAND_PAGE_SIZE)) { while (i < size / CONFIG_SYS_NAND_PAGE_SIZE) {
if (nfc_read_page(page, buf) < 0) if (nfc_read_page(page, buf) < 0)
return -1; return -1;