Freescale NFC NAND driver
Subsystems (2)
PATCH v2 1/1 Freescale NFC NAND driver
Reworked MPC5121 NAND driver.
Attempted to address all the problems listed by Scott Wood. Driver is now board independent. Will still need more work to be SOC independent.
Driver for the NAND controller on MPC5121.
This driver has been tested on ADS5121 rev4 / MPC5121e rev2 only which has the following configuration:
2K page size
8 bit device width
This should work on other boards with MPC5121 rev2 silicon with little or no change to the driver.
Various vintages of this controller exist on some iMX parts. Getting it to work on an iMX with the same controller version should be fairly easy. More work if it is an iMX with a different version on the controller.
This controller treats 2K pages as 4 512 byte pages and the hw ecc is over the combined 512 byte main area and the first 7 bytes of the spare area.
The hw ecc is stored in the last 9 bytes of the
spare area.
This all means the the spare area can not be written separately from the main. This means unmodified JFFS2 will not work.
--- board/ads5121/ads5121.c | 16 + drivers/mtd/nand/Makefile | 1 + drivers/mtd/nand/fsl_nfc_nand.c | 1105 +++++++++++++++++++++++++++++++++++++++ include/configs/ads5121.h | 38 ++ 4 files changed, 1160 insertions(+), 0 deletions(-) create mode 100644 drivers/mtd/nand/fsl_nfc_nand.c
board/ads5121/ads5121.c +16 -0
@@ -24,6 +24,7 @@#include <common.h> #include <mpc512x.h> #include <asm/bitops.h> +#include <asm/io.h> #include <command.h> #include <asm/processor.h> #include <fdt_support.h>
@@ -34,6 +35,7 @@/* Clocks in use */ #define SCCR1_CLOCKS_EN (CLOCK_SCCR1_CFG_EN | \ CLOCK_SCCR1_LPC_EN | \ + CLOCK_SCCR1_NFC_EN | \ CLOCK_SCCR1_PSC_EN(CONFIG_PSC_CONSOLE) | \ CLOCK_SCCR1_PSCFIFO_EN | \ CLOCK_SCCR1_DDR_EN | \
@@ -312,3 +314,17 @@ void ft_board_setup(void *blob, bd_t *bd) fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize); }#endif /* defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) */ + +#if defined(CONFIG_NAND_FSL_NFC ) +void ads5121_fsl_nfc_board_cs (int chip) +{ +unsigned char *csreg = (unsigned char *)CFG_CPLD_BASE +0x09 ; +u8 v; + + v =in_8 (csreg); + v |=0xf ; + v &= ~(1 <<chip); + +out_8 (csreg, v); +} +#endif
drivers/mtd/nand/Makefile +1 -0
@@ -38,6 +38,7 @@ endif COBJS-$(CONFIG_NAND_FSL_ELBC) += fsl_elbc_nand.o COBJS-$(CONFIG_NAND_FSL_UPM) += fsl_upm.o COBJS-$(CONFIG_NAND_S3C64XX) += s3c64xx.o +COBJS-$(CONFIG_NAND_FSL_NFC) += fsl_nfc_nand.o endif COBJS := $(COBJS-y)
drivers/mtd/nand/fsl_nfc_nand.c new file +1105 -0
1,105 lines not on this page · raw message
include/configs/ads5121.h +38 -0
@@ -33,6 +33,7 @@* * 0x0000_0000 - 0x0FFF_FFFF DDR RAM (256 MB) * 0x3000_0000 - 0x3001_FFFF SRAM (128 KB) +* 0x4000_0000 - 0x400F_FFFF NFC (1 MB) * 0x8000_0000 - 0x803F_FFFF IMMR (4 MB) * 0x8200_0000 - 0x8200_001F CPLD (32 B) * 0x8400_0000 - 0x82FF_FFFF PCI I/O space (16 MB)
@@ -199,6 +200,43 @@#undef CONFIG_SYS_FLASH_CHECKSUM/* +* NAND FLASH +* drivers/mtd/nand/mpc5121_mpc.c (rev 2 silicon/rev 4 boards only) +*/ +#define CONFIG_NAND_FSL_NFC +#ifdef CONFIG_NAND_FSL_NFC +#ifdef CONFIG_NAND_SPL +#define CONFIG_SYS_NAND_BASE 0xFFF00000 +#else +#define CONFIG_SYS_NAND_BASE 0x40000000 +#endif +#define CONFIG_CMD_NAND 1 +/* +* The flash on ADS5121 board is two flash chips in one package +*/ +#define CONFIG_SYS_MAX_NAND_DEVICE 2 +#define NAND_MAX_CHIPS CONFIG_SYS_MAX_NAND_DEVICE +#define CONFIG_SYS_NAND_SELECT_DEVICE 1 +#define CONFIG_NAND_MPC5121 +/* +* Configuration parameters for MPC5121 NAND driver +*/ +#define CONFIG_FSL_NFC_WIDTH 1 +#define CONFIG_FSL_NFC_WRITE_SIZE 2048 +#define CONFIG_FSL_NFC_SPARE_SIZE 64 +#define CONFIG_FSL_NFC_CHIPS 2 + +#ifndef __ASSEMBLY__ +/* +* ADS board as a custom chip select +*/ +extern void ads5121_fsl_nfc_board_cs (int ); +#define CONFIG_FSL_NFC_BOARD_CS_FUNC ads5121_fsl_nfc_board_cs +#endif /* __ASSEMBLY__ */ +#endif /* CONFIG_NAND_FSL_NFC */ + + +/* * CPLD registers area is really only 32 bytes in size, but the smallest possible LP * window is 64KB */
Signature · 1 line
1.5.6.2.255.gbed62
PATCH v2 1/1 Freescale NFC NAND driver
Hi
2008/11/5 John Rigby <[email protected]>:
Quoted 12 lines
Reworked MPC5121 NAND driver.
Attempted to address all the problems listed by Scott Wood. Driver is now board independent. Will still need more work to be SOC independent.Driver for the NAND controller on MPC5121.
This driver has been tested on ADS5121 rev4 / MPC5121e rev2 only which has the following configuration:
2K page size
8 bit device width
Quoted 7 lines
This should work on other boards with MPC5121 rev2 silicon with little or no change to the driver.
Various vintages of this controller exist on some iMX parts. Getting it to work on an iMX with the same controller version should be fairly easy. More work if it is an iMX with a different version on the controller.
The i.MX31 seems to have NFC v1 while i.MX32 has v2, would that mean that your driver is likely to work with i.MX32?
Regards, Magnus
PATCH v2 1/1 Freescale NFC NAND driver
Quoted 19 lines · Magnus Lilja
Hi
2008/11/5 John Rigby <[email protected]>:
Quoted 15 lines
Reworked MPC5121 NAND driver.
Attempted to address all the problems listed by Scott Wood. Driver is now board independent. Will still need more work to be SOC independent.Driver for the NAND controller on MPC5121.
This driver has been tested on ADS5121 rev4 / MPC5121e rev2 only which has the following configuration:
2K page size
8 bit device widthThis should work on other boards with MPC5121 rev2 silicon with little or no change to the driver.
Quoted 9 lines
Quoted 5 lines
Various vintages of this controller exist on some iMX parts. Getting it to work on an iMX with the same controller version should be fairly easy. More work if it is an iMX with a different version on the controller.
The i.MX31 seems to have NFC v1 while i.MX32 has v2, would that mean that your driver is likely to work with i.MX32?
I have a hard time keep track of the versions. If the register set has the SPAS register then it is close.
Quoted 3 lines
Regards, Magnus