Re: [U-Boot] [PATCH 04/10] mxc_nand: add nand driver for MX2/MX3
Ilya, On Wed, May 6, 2009 at 8:30 PM, Ilya Yanok ya...@emcraft.com wrote: Driver for NFC NAND controller found on Freescale's MX2 and MX3 processors. Ported from Linux. Tested only with i.MX27 but should works with other MX2 and MX3 processors too. [..] --- /dev/null +++ b/drivers/mtd/nand/mxc_nand.c @@ -0,0 +1,891 @@ [...] +/* This function polls the NANDFC to wait for the basic operation to + * complete by checking the INT bit of config2 register. + */ +static void wait_op_done(struct mxc_nand_host *host, int max_retries, + uint16_t param, int useirq) +{ + uint32_t tmp; + + while (max_retries-- 0) { + if (readw(host-regs + NFC_CONFIG2) NFC_INT) { + tmp = readw(host-regs + NFC_CONFIG2); + tmp = ~NFC_INT; + writew(tmp, host-regs + NFC_CONFIG2); + break; + } + udelay(1); + } + if (max_retries = 0) + MTDDEBUG(MTD_DEBUG_LEVEL0, %s(%d): INT not set\n, + __func__, param); +} As you don't have an interrupt handler (as opposed to the Linux driver), why keep the 'useirq' parameter ? [...] +static void send_cmd(struct mxc_nand_host *host, uint16_t cmd, int useirq) Same comment (also renders all 'islast' parameters obsolete). [...] +int board_nand_init(struct nand_chip *this) +{ [...] + + tmp = readw(host-regs + NFC_CONFIG1); + tmp |= NFC_INT_MSK; + writew(tmp, host-regs + NFC_CONFIG1); I don't think this is needed on i.MX27, since you don't have an interrupt handler. Setting NFC_INT_MSK on i.MX21 will cause NFC_INT in NFC_CONFIG2 to never get set (and wait_op_done() to always time out) You might want to have a look at u-boot-v2's MXC nand driver, that one works on both i.MX21 and i.MX27, without setting NFC_INT_MSK: http://git.denx.de/?p=u-boot/u-boot-v2.git;a=blob;f=drivers/nand/nand_imx.c;hb=HEAD Also, see my post on linux-arm-kernel, [RFC][PATCH] MXC NAND i.MX21 support: http://www.spinics.net/lists/arm-kernel/msg64970.html Best regards, Ivo. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 04/10] mxc_nand: add nand driver for MX2/MX3
Hi 2009/5/8 Ivo Clarysse ivo.clary...@gmail.com: Ilya, On Wed, May 6, 2009 at 8:30 PM, Ilya Yanok ya...@emcraft.com wrote: Driver for NFC NAND controller found on Freescale's MX2 and MX3 processors. Ported from Linux. Tested only with i.MX27 but should works with other MX2 and MX3 processors too. [..] --- /dev/null +++ b/drivers/mtd/nand/mxc_nand.c @@ -0,0 +1,891 @@ [...] +/* This function polls the NANDFC to wait for the basic operation to + * complete by checking the INT bit of config2 register. + */ +static void wait_op_done(struct mxc_nand_host *host, int max_retries, + uint16_t param, int useirq) +{ + uint32_t tmp; + + while (max_retries-- 0) { + if (readw(host-regs + NFC_CONFIG2) NFC_INT) { + tmp = readw(host-regs + NFC_CONFIG2); + tmp = ~NFC_INT; + writew(tmp, host-regs + NFC_CONFIG2); + break; + } + udelay(1); + } + if (max_retries = 0) + MTDDEBUG(MTD_DEBUG_LEVEL0, %s(%d): INT not set\n, + __func__, param); +} As you don't have an interrupt handler (as opposed to the Linux driver), why keep the 'useirq' parameter ? [...] +static void send_cmd(struct mxc_nand_host *host, uint16_t cmd, int useirq) Same comment (also renders all 'islast' parameters obsolete). I think it's a good idea to keep the code as close as possible to the original linux driver. That way it's easy to make a diff and update the U-boot driver with whatever changes are done in Linux. Regards, Magnus ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 04/10] mxc_nand: add nand driver for MX2/MX3
Hi 2009/5/6 Ilya Yanok ya...@emcraft.com: Driver for NFC NAND controller found on Freescale's MX2 and MX3 processors. Ported from Linux. Tested only with i.MX27 but should works with other MX2 and MX3 processors too. Signed-off-by: Ilya Yanok ya...@emcraft.com --- drivers/mtd/nand/Makefile | 1 + drivers/mtd/nand/mxc_nand.c | 891 +++ 2 files changed, 892 insertions(+), 0 deletions(-) create mode 100644 drivers/mtd/nand/mxc_nand.c diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile index 471cd6b..24de947 100644 --- a/drivers/mtd/nand/Makefile +++ b/drivers/mtd/nand/Makefile @@ -40,6 +40,7 @@ COBJS-$(CONFIG_DRIVER_NAND_BFIN) += bfin_nand.o COBJS-$(CONFIG_NAND_DAVINCI) += davinci_nand.o COBJS-$(CONFIG_NAND_FSL_ELBC) += fsl_elbc_nand.o COBJS-$(CONFIG_NAND_FSL_UPM) += fsl_upm.o +COBJS-$(CONFIG_NAND_MXC) += mxc_nand.o COBJS-$(CONFIG_NAND_NOMADIK) += nomadik.o COBJS-$(CONFIG_NAND_S3C2410) += s3c2410_nand.c COBJS-$(CONFIG_NAND_S3C64XX) += s3c64xx.o diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c new file mode 100644 index 000..48a6b7b --- /dev/null +++ b/drivers/mtd/nand/mxc_nand.c @@ -0,0 +1,891 @@ ... +#define NFC_SP_EN (1 2) +#define NFC_ECC_EN (1 3) +#define NFC_INT_MSK (1 4) +#define NFC_BIG (1 5) +#define NFC_RST (1 6) +#define NFC_CE (1 7) +#define NFC_ONE_CYCLE (1 8) + +typedef enum _bool{false,true} bool; Isn't there some include-file we can use instead of typdefing this locally? + Regards, Magnus ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 04/10] mxc_nand: add nand driver for MX2/MX3
Dear Ilya, In message 1241634633-13917-5-git-send-email-ya...@emcraft.com you wrote: Driver for NFC NAND controller found on Freescale's MX2 and MX3 processors. Ported from Linux. Tested only with i.MX27 but should works with other MX2 and MX3 processors too. ... +/* Set INT to 0, FCMD to 1, rest to 0 in NFC_CONFIG2 Register + * for Command operation */ Incorrect multiline comment style. Here and elsewhere. ... +static void send_prog_page(struct mxc_nand_host *host, uint8_t buf_id, + int spare_only) +{ + MTDDEBUG(MTD_DEBUG_LEVEL3, send_prog_page (%d)\n, spare_only); + + /* NANDFC buffer 0 is used for page read/write */ + writew(buf_id, host-regs + NFC_BUF_ADDR); + + /* Configure spare or page+spare access */ + if (!host-pagesize_2k) { + uint16_t config1 = readw(host-regs + NFC_CONFIG1); + if (spare_only) + config1 |= NFC_SP_EN; + else + config1 = ~(NFC_SP_EN); Use setbits*() / clrbits*() ? Here and elsewhere. Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de Q: Do you know what the death rate around here is? A: One per person. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot