Skip to contentSkip to conversation

powerpc/85xx: Add support for Integrated Flash Controller (IFC)

PATCH New Dipen Dudhat 2 participants 3 messages Jan 20, 2011 1 message not in the archive PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/85xx: Add support for Integrated Flash Controller (IFC)

The Integrated Flash Controller (IFC) is used to access the external NAND Flash, NOR Flash, EPROM, SRAM and Generic ASIC memories.Four chip selects are provided in IFC so that maximum of four Flash devices can be hooked, but only one can be accessed at a given time.

Features supported by IFC are,
- Functional muxing of pins between NAND, NOR and GPCM
- Support memory banks of size 64KByte to 4 GBytes
- Write protection capability (only for NAND and NOR)
- Provision of Software Reset
- Flexible Timing programmability for every chip select
- NAND Machine
- x8/ x16 NAND Flash Interface
- SLC and MLC NAND Flash devices support with configurable
page sizes of upto 4KB
- Internal SRAM of 9KB which is directly mapped and availble at
boot time for NAND Boot
- Configurable block size
- Boot chip select (CS0) available at system reset
- NOR Machine
- Data bus width of 8/16/32
- Compatible with asynchronous NOR Flash
- Directly memory mapped
- Supports address data multiplexed (ADM) NOR device
- Boot chip select (CS0) available at system reset
- GPCM Machine (NORMAL GPCM Mode)
- Support for x8/16/32 bit device
- Compatible with general purpose addressable device e.g. SRAM, ROM
- External clock is supported with programmable division ratio
- GPCM Machine (Generic ASIC Mode)
- Support for x8/16/32 bit device
- Address and Data are shared on I/O bus
- Following Address and Data sequences can be supported on I/O bus
??? 32 bit I/O: AD
??? 16 bit I/O: AADD
??? 8 bit I/O : AAAADDDD
- Configurable Even/Odd Parity on Address/Data bus supported

---
 arch/powerpc/cpu/mpc85xx/cpu.c        |    7 +-
 arch/powerpc/cpu/mpc8xxx/Makefile     |    1 +
 arch/powerpc/cpu/mpc8xxx/fsl_ifc.c    |   84 +++
 arch/powerpc/include/asm/config.h     |    2 +
 arch/powerpc/include/asm/fsl_ifc.h    |  929 +++++++++++++++++++++++++++++++++
 arch/powerpc/include/asm/fsl_law.h    |    1 +
 arch/powerpc/include/asm/immap_85xx.h |    4 +
 7 files changed, 1027 insertions(+), 1 deletions(-)
 create mode 100644 arch/powerpc/cpu/mpc8xxx/fsl_ifc.c
 create mode 100644 arch/powerpc/include/asm/fsl_ifc.h
arch/powerpc/cpu/mpc85xx/cpu.c +6 -1
index 1aad2ba..49ea6cc 100644
@@ -33,6 +33,7 @@
 #include <asm/cache.h>
 #include <asm/io.h>
 #include <asm/mmu.h>
+#include <asm/fsl_ifc.h>
 #include <asm/fsl_law.h>
 #include <asm/fsl_lbc.h>
 #include <post.h>
@@ -280,7 +281,8 @@ int cpu_mmc_init(bd_t *bis)
 
 /*
  * Print out the state of various machine registers.
- * Currently prints out LAWs, BR0/OR0, and TLBs
+ * Currently prints out LAWs, BR0/OR0 for LBC, CSPR/CSOR/Timing
+ * parameters for IFC and TLBs
  */
 void mpc85xx_reginfo(void)
 {
@@ -289,6 +291,9 @@ void mpc85xx_reginfo(void)
 #if defined(CONFIG_FSL_LBC)
 	print_lbc_regs();
 #endif
+#ifdef CONFIG_FSL_IFC
+	print_ifc_regs();
+#endif
 
 }
 
arch/powerpc/cpu/mpc8xxx/Makefile +1 -0
index 5dfd65b..4ae26e4 100644
@@ -15,6 +15,7 @@ COBJS-y	+= cpu.o
 endif
 
 COBJS-$(CONFIG_OF_LIBFDT) += fdt.o
+COBJS-$(CONFIG_FSL_IFC) += fsl_ifc.o
 COBJS-$(CONFIG_FSL_LBC) += fsl_lbc.o
 COBJS-$(CONFIG_SYS_SRIO) += srio.o
 
arch/powerpc/cpu/mpc8xxx/fsl_ifc.c new file +84 -0

84 lines not on this page · raw message

arch/powerpc/include/asm/config.h +2 -0
index 2b6b233..536f142 100644
@@ -75,8 +75,10 @@
 /* Since so many PPC SOCs have a semi-common LBC, define this here */
 #if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx) || \
 	defined(CONFIG_MPC83xx)
+#if !defined(CONFIG_FSL_IFC)
 #define CONFIG_FSL_LBC
 #endif
+#endif
 
 /* All PPC boards must swap IDE bytes */
 #define CONFIG_IDE_SWAP_IO
arch/powerpc/include/asm/fsl_ifc.h new file +929 -0

929 lines not on this page · raw message

arch/powerpc/include/asm/fsl_law.h +1 -0
index 6a4279c..e308b15 100644
@@ -91,6 +91,7 @@ enum law_trgt_if {
 #define LAW_TRGT_IF_PCIX	LAW_TRGT_IF_PCI
 #define LAW_TRGT_IF_PCIE_2	LAW_TRGT_IF_PCI_2
 #define LAW_TRGT_IF_RIO_1	LAW_TRGT_IF_RIO
+#define LAW_TRGT_IF_IFC		LAW_TRGT_IF_LBC
 
 #ifdef CONFIG_MPC8641
 #define LAW_TRGT_IF_PCIE_1	LAW_TRGT_IF_PCI
arch/powerpc/include/asm/immap_85xx.h +4 -0
index 6bd83ba..a30a58c 100644
@@ -31,6 +31,7 @@
 #include <asm/types.h>
 #include <asm/fsl_dma.h>
 #include <asm/fsl_i2c.h>
+#include <asm/fsl_ifc.h>
 #include <asm/fsl_lbc.h>
 #include <asm/fsl_fman.h>
 
@@ -2227,6 +2228,7 @@ typedef struct ccsr_pme {
 #define CONFIG_SYS_MPC85xx_GPIO_OFFSET		0xF000
 #define CONFIG_SYS_MPC85xx_SATA1_OFFSET		0x18000
 #define CONFIG_SYS_MPC85xx_SATA2_OFFSET		0x19000
+#define CONFIG_SYS_MPC85xx_IFC_OFFSET		0x1e000
 #define CONFIG_SYS_MPC85xx_L2_OFFSET		0x20000
 #define CONFIG_SYS_MPC85xx_DMA_OFFSET		0x21000
 #define CONFIG_SYS_MPC85xx_USB_OFFSET		0x22000
@@ -2269,6 +2271,8 @@ typedef struct ccsr_pme {
 	(CONFIG_SYS_IMMR + CONFIG_SYS_MPC85xx_DDR2_OFFSET)
 #define CONFIG_SYS_LBC_ADDR \
 	(CONFIG_SYS_IMMR + CONFIG_SYS_MPC85xx_LBC_OFFSET)
+#define CONFIG_SYS_IFC_ADDR \
+	(CONFIG_SYS_IMMR + CONFIG_SYS_MPC85xx_IFC_OFFSET)
 #define CONFIG_SYS_MPC85xx_ESPI_ADDR \
 	(CONFIG_SYS_IMMR + CONFIG_SYS_MPC85xx_ESPI_OFFSET)
 #define CONFIG_SYS_MPC85xx_PCIX_ADDR \
Signature · 1 line
1.5.6.5
#1 lore raw

PATCH 1/1 powerpc/85xx: Add support for Integrated Flash Controller (IFC)

Dear Dipen Dudhat,

Quoted 5 lines · In message <[email protected]> you…

The Integrated Flash Controller (IFC) is used to access the external NAND Flash, NOR Flash, EPROM, SRAM and Generic ASIC memories.Four chip selects are provided in IFC so that maximum of four Flash devices can be hooked, but only one can be accessed at a given time.

...

Quoted 8 lines

- GPCM Machine (Generic ASIC Mode)
- Support for x8/16/32 bit device
- Address and Data are shared on I/O bus
- Following Address and Data sequences can be supported on I/O bus
??? 32 bit I/O: AD
??? 16 bit I/O: AADD
??? 8 bit I/O : AAAADDDD

Please use plain ASCII characters.

Checkpatch says:

ERROR: do not modify files in include/asm, change architecture specific files in include/asm-<architecture> #307: +++ b/arch/powerpc/include/asm/config.h

ERROR: do not modify files in include/asm, change architecture specific files in include/asm-<architecture> #323: +++ b/arch/powerpc/include/asm/fsl_ifc.h

ERROR: do not modify files in include/asm, change architecture specific files in include/asm-<architecture> #1257: +++ b/arch/powerpc/include/asm/fsl_law.h

ERROR: do not modify files in include/asm, change architecture specific files in include/asm-<architecture> #1269: +++ b/arch/powerpc/include/asm/immap_85xx.h

total: 4 errors, 0 warnings, 1084 lines checked

Please fix.

arch/powerpc/cpu/mpc8xxx/fsl_ifc.c line 36

Quoted 13 lines
arch/powerpc/cpu/mpc8xxx/fsl_ifc.c new file +13 -0
+void print_ifc_regs(void)
+{
+	int i, j;
+
+	printf("\nIFC Controller Registers\n");
+	for (i = 0; i < FSL_IFC_BANK_COUNT; i++) {
+		printf("\nCSPR%d\t0x%08X\tAMASK%d\t0x%08X\tCSOR%d\t0x%08X\n",
+			i, get_ifc_cspr(i), i, get_ifc_amask(i),
+			i, get_ifc_csor(i));
+		for (j = 0; j < 4; j++)
+			printf("IFC_FTIM%d:0x%08X ", j, get_ifc_ftim(i, j));
+	}
+}

Please note that printf formats starting with "\n..." are almost always wrong or inappropriate. "\n" _terminates_ a line of text, it does not start one.

Don't print useless blank lines.

Quoted 28 lines
arch/powerpc/include/asm/fsl_ifc.h new file +28 -0
+/*
+ * Instruction opcodes to be programmed
+ * in FIR registers- 6bits
+ */
+#define IFC_FIR_OP_NOP			0x00
+#define IFC_FIR_OP_CA0			0x01
+#define IFC_FIR_OP_CA1			0x02
+#define IFC_FIR_OP_CA2			0x03
+#define IFC_FIR_OP_CA3			0x04
+#define IFC_FIR_OP_RA0			0x05
+#define IFC_FIR_OP_RA1			0x06
+#define IFC_FIR_OP_RA2			0x07
+#define IFC_FIR_OP_RA3			0x08
+#define IFC_FIR_OP_CMD0			0x09
+#define IFC_FIR_OP_CMD1			0x0A
+#define IFC_FIR_OP_CMD2			0x0B
+#define IFC_FIR_OP_CMD3			0x0C
+#define IFC_FIR_OP_CMD4			0x0D
+#define IFC_FIR_OP_CMD5			0x0E
+#define IFC_FIR_OP_CMD6			0x0F
+#define IFC_FIR_OP_CMD7			0x10
+#define IFC_FIR_OP_CW0			0x11
+#define IFC_FIR_OP_CW1			0x12
+#define IFC_FIR_OP_CW2			0x13
+#define IFC_FIR_OP_CW3			0x14
+#define IFC_FIR_OP_CW4			0x15
+#define IFC_FIR_OP_CW5			0x16
+#define IFC_FIR_OP_CW6			0x17

arch/powerpc/include/asm/fsl_ifc.h line 484

Quoted 10 lines
arch/powerpc/include/asm/fsl_ifc.h new file +10 -0
+#define IFC_FIR_OP_CW7			0x18
+#define IFC_FIR_OP_WBCD			0x19
+#define IFC_FIR_OP_RBCD			0x1A
+#define IFC_FIR_OP_BTRD			0x1B
+#define IFC_FIR_OP_RDSTAT		0x1C
+#define IFC_FIR_OP_NWAIT		0x1D
+#define IFC_FIR_OP_WFR			0x1E
+#define IFC_FIR_OP_SBRD			0x1F
+#define IFC_FIR_OP_UA			0x20
+#define IFC_FIR_OP_RB			0x21

Make this an enum.

Quoted 10 lines
arch/powerpc/include/asm/fsl_ifc.h new file +10 -0
+/*
+ * ECC Error Status Registers (ECCSTAT0-ECCSTAT3)
+ */
+/* Number of ECC errors on sector n (n = 0-15) */
+#define IFC_NAND_ECCSTAT0_NUMBER0	0x0F000000
+#define IFC_NAND_ECCSTAT0_NUMBER1	0x000F0000
+#define IFC_NAND_ECCSTAT0_NUMBER2	0x00000F00
+#define IFC_NAND_ECCSTAT0_NUMBER3	0x0000000F
+#define IFC_NAND_ECCSTAT1_NUMBER4	0x0F000000
+#define IFC_NAND_ECCSTAT1_NUMBER5	0x000F0000

arch/powerpc/include/asm/fsl_ifc.h line 599

Quoted 10 lines
arch/powerpc/include/asm/fsl_ifc.h new file +10 -0
+#define IFC_NAND_ECCSTAT1_NUMBER6	0x00000F00
+#define IFC_NAND_ECCSTAT1_NUMBER7	0x0000000F
+#define IFC_NAND_ECCSTAT2_NUMBER8	0x0F000000
+#define IFC_NAND_ECCSTAT2_NUMBER9	0x000F0000
+#define IFC_NAND_ECCSTAT2_NUMBER10	0x00000F00
+#define IFC_NAND_ECCSTAT2_NUMBER11	0x0000000F
+#define IFC_NAND_ECCSTAT3_NUMBER12	0x0F000000
+#define IFC_NAND_ECCSTAT3_NUMBER13	0x000F0000
+#define IFC_NAND_ECCSTAT3_NUMBER14	0x00000F00
+#define IFC_NAND_ECCSTAT3_NUMBER15	0x0000000F

Do you think these macros are really useful? If I understand your intention, then the name is at least misleading - these appear to be masks, not numbers. To get a number, you rpobably need both a mask and a shift operation for most of these?

Quoted 50 lines
arch/powerpc/include/asm/fsl_ifc.h new file +50 -0
+/*
+ * IFC Controller NAND Machine registers
+ */
+struct fsl_ifc_nand {
+	u32 ncfgr;
+	u8 res17[0x10];
+	u32 nand_fcr0;
+	u32 nand_fcr1;
+	u8 res18[0x20];
+	u32 row0;
+	u8 res19[0x4];
+	u32 col0;
+	u8 res20[0x4];
+	u32 row1;
+	u8 res21[0x4];
+	u32 col1;
+	u8 res22[0x4];
+	u32 row2;
+	u8 res23[0x4];
+	u32 col2;
+	u8 res24[0x4];
+	u32 row3;
+	u8 res25[0x4];
+	u32 col3;
+	u8 res26[0x90];
+	u32 nand_fbcr;
+	u8 res27[0x4];
+	u32 nand_fir0;
+	u32 nand_fir1;
+	u32 nand_fir2;
+	u8 res28[0x40];
+	u32 nand_csel;
+	u8 res29[0x4];
+	u32 nandseq_strt;
+	u8 res30[0x4];
+	u32 nand_evter_stat;
+	u8 res31[0x4];
+	u32 pgrdcmpl_evt_stat;
+	u8 res32[0x8];
+	u32 nand_evter_en;
+	u8 res33[0x8];
+	u32 nand_evter_intr_en;
+	u8 res34[0x8];
+	u32 nand_erattr0;
+	u32 nand_erattr1;
+	u8 res35[0x40];
+	u32 nand_fsr;
+	u8 res36[0x4];
+	u32 nand_eccstat0;
+	u32 nand_eccstat1;

arch/powerpc/include/asm/fsl_ifc.h line 843

Quoted 10 lines
arch/powerpc/include/asm/fsl_ifc.h new file +10 -0
+	u32 nand_eccstat2;
+	u32 nand_eccstat3;
+	u8 res37[0x80];
+	u32 nanndcr;
+	u8 res38[0x8];
+	u32 nand_autoboot_trgr;
+	u8 res39[0x4];
+	u32 nand_mdr;
+	u8 res40[0x170];
+};

Why do you use u8 for all the served entries when the existing entries are all u32?

Ditto for the following structs.

Also note that code would be better readable if the variable names were vertically aligned (which comes for free when you convert the reserved entries to u32).

Best regards,

Wolfgang Denk

Signature · 5 lines
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: wd at denx.de
Every living thing wants to survive.
	-- Spock, "The Ultimate Computer", stardate 4731.3

A message that is not in the archive (sent off-list or not yet received): 57D3AB35EFB0E542A4326DBD78E17E950A532D@039-SN1MPN1-005.039d.mgd.msft.net

#3 lore raw

PATCH 1/1 powerpc/85xx: Add support for Integrated Flash Controller (IFC)

Dear Dudhat Dipen-B09055,

Quoted 2 lines · In message <57D3AB35EFB0E542A4326DBD78E17E950A532D@039-SN1MPN1-005.039d.mgd.msf…

Please find my comment inline with your comment.

Please do not full quote.

Quoted 4 lines

Checkpatch says:

[Dudhat Dipen-B09055] Now all the architecture related header files are moved to arch/powerpc/include/asm/
Isn't this correct??

Good point.

As it turns out, I was running a pretty old version of checkpatch. Please ignore the checkpatch related comments.

Thanks for pointing out!

Best regards,

Wolfgang Denk

Signature · 6 lines
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: wd at denx.de
Einstein argued that there must be simplified explanations of nature,
because God is not capricious or arbitrary. No  such  faith  comforts
the software engineer.                             - Fred Brooks, Jr.