Scott Wood skrev: > On Sun, Nov 08, 2009 at 11:55:39AM +0100, Magnus Lilja wrote: >> Alternative solution for supporting 16 bit NAND detection for the >> i.MX27 and i.MX31 SoCs. This moves the SoC specific code to the SoC header >> file leaving mxc_nand.c free from #ifdef's (in this respect). > > OTOH, it moves more NAND stuff out of the NAND driver. > > I guess it depends on how many more such alternatives you think will be > added in the future.
I'll figure something out that keeps the NAND stuff in mxc_nand.c and repost. > >> diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c >> index 3e4254a..45d0024 100644 >> --- a/drivers/mtd/nand/mxc_nand.c >> +++ b/drivers/mtd/nand/mxc_nand.c >> @@ -808,8 +808,6 @@ static void mxc_nand_command(struct mtd_info *mtd, >> unsigned command, >> >> int board_nand_init(struct nand_chip *this) >> { >> - struct system_control_regs *sc_regs = >> - (struct system_control_regs *)IMX_SYSTEM_CTL_BASE; >> struct mtd_info *mtd; >> uint16_t tmp; >> int err = 0; >> @@ -871,15 +869,9 @@ int board_nand_init(struct nand_chip *this) >> writew(0x4, &host->regs->nfc_wrprot); >> >> /* NAND bus width determines access funtions used by upper layer */ >> -#ifdef CONFIG_MX27 >> - if (readl(&sc_regs->fmcr) & NF_16BIT_SEL) >> - this->options |= NAND_BUSWIDTH_16; >> -#elif defined(CONFIG_MX31) >> - if (readl(&sc_regs->rcsr) & CCM_RCSR_NF16B) >> + if (mxc_nand_is_16bit()) >> this->options |= NAND_BUSWIDTH_16; >> -#else >> -#warning "No autodetection of 8/16 bit NAND" >> -#endif >> + >> host->pagesize_2k = 0; >> >> return err; >> diff --git a/include/asm-arm/arch-mx27/imx-regs.h >> b/include/asm-arm/arch-mx27/imx-regs.h >> index d36a6da..b88fe51 100644 >> --- a/include/asm-arm/arch-mx27/imx-regs.h >> +++ b/include/asm-arm/arch-mx27/imx-regs.h >> @@ -516,4 +516,17 @@ struct iim_regs { >> #define IIM0_SCC_KEY 11 >> #define IIM1_SUID 1 >> >> +#ifndef __ASSEMBLY__ >> +static inline int mxc_nand_is_16bit(void) >> +{ >> + struct system_control_regs *sc_regs = >> + (struct system_control_regs *)IMX_SYSTEM_CTL_BASE; >> + >> + if (readl(&sc_regs->rcsr) & CCM_RCSR_NF16B) >> + return 1; >> + else >> + return 0; >> +} >> +#endif >> + >> #endif /* _IMX_REGS_H */ >> diff --git a/include/asm-arm/arch-mx31/mx31-regs.h >> b/include/asm-arm/arch-mx31/mx31-regs.h >> index 86c9975..613c632 100644 >> --- a/include/asm-arm/arch-mx31/mx31-regs.h >> +++ b/include/asm-arm/arch-mx31/mx31-regs.h >> @@ -63,6 +63,19 @@ struct system_control_regs { >> #define CCM_RCSR_NF16B (1 << 31) >> #define CCM_RCSR_NFMS (1 << 30) >> >> +#include <asm/io.h> >> + >> +static inline int mxc_nand_is_16bit(void) >> +{ >> + struct system_control_regs *sc_regs = >> + (struct system_control_regs *)IMX_SYSTEM_CTL_BASE; >> + >> + if (readl(&sc_regs->rcsr) & CCM_RCSR_NF16B) >> + return 1; >> + else >> + return 0; >> +} >> + >> #endif > > It looks like you put the MX31 version in the MX27 file as well... Heh, thanks. Will take of that. Thanks for the feedback /Magnus _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot