Skip to contentSkip to conversation

basic pxa3 nand controller support

PATCH New Sergey Podstavin 1 participant 1 message Jan 11, 2008

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 basic pxa3 nand controller support

This is a fixed version for pxa3 nand controller,
working on pxa300 Zylonite

Best wishes,
Sergey Podstavin.

Quoted 9 lines
Quoted 1 line · eric miao <eric.y.miao <at> gmail.com> writes:

Early feedback is welcome, thanks!

Hi Eric

Overall the patch looks good, just a few comments.

The patch does not apply cleanly unless I remove the spurious newline

before

Quoted 4 lines

line 1284 resulting in the following error:
patch: **** malformed patch at line 1284: pm_message_t state)

The DRCMR97 register is not defined anywhere, at lest not in

2.6.24-rc6:

Quoted 1 line

drivers/mtd/nand/pxa3xx_nand.c:542: error: ‘DRCMR97’ undeclared (first

use in

Quoted 5 lines

this function)

The registers and bit definitions should be moved to pxa-regs.h, not?

I had my troubles getting it to work on a custom PXA320 board. I kinda

figured

Quoted 1 line

out what platform data it needs, but still can't seem to get it to work

properly:

Quoted 3 lines

pxa3xx-nand pxa3xx-nand: failed to detect flash

What kernel does your patch apply to? What CPUs/boards did you try it

on? Can

Quoted 6 lines

you provide an example platform integration required to make it work?

Cheers

Marcel
From 8e078f4fa24f5d3d8e7ee887f135f040dce0580f Mon Sep 17 00:00:00 2001

From: Sergey Podstavin <[email protected]>
Date: Fri, 11 Jan 2008 09:46:30 +0300
Subject: [PATCH] fixed basic pxa3 nand controller support

---
 arch/arm/kernel/head.S                 |    6 +-
 arch/arm/mach-pxa/generic.c            |    6 +
 arch/arm/mach-pxa/pxa3xx.c             |    1 +
 arch/arm/mach-pxa/zylonite.c           |   21 +
 drivers/mtd/nand/Kconfig               |    6 +
 drivers/mtd/nand/Makefile              |    1 +
 drivers/mtd/nand/pxa3xx_nand.c         | 1419 ++++++++++++++++++++++++++++++++
 include/asm-arm/arch-pxa/hardware.h    |   30 +-
 include/asm-arm/arch-pxa/pxa-regs.h    |   19 +
 include/asm-arm/arch-pxa/pxa3xx_nand.h |   18 +
 include/asm-arm/arch-pxa/zylonite.h    |  710 ++++++++++++++++
 11 files changed, 2212 insertions(+), 25 deletions(-)
 create mode 100644 drivers/mtd/nand/pxa3xx_nand.c
 create mode 100644 include/asm-arm/arch-pxa/pxa3xx_nand.h
arch/arm/kernel/head.S +3 -3
index 7898cbc..a89c0f2 100644
@@ -86,9 +86,9 @@ ENTRY(stext)
 	bl	__lookup_processor_type		@ r5=procinfo r9=cpuid
 	movs	r10, r5				@ invalid processor (r5=0)?
 	beq	__error_p			@ yes, error 'p'
-	bl	__lookup_machine_type		@ r5=machinfo
-	movs	r8, r5				@ invalid machine (r5=0)?
-	beq	__error_a			@ yes, error 'a'
+//	bl	__lookup_machine_type		@ r5=machinfo
+//	movs	r8, r5				@ invalid machine (r5=0)?
+//	beq	__error_a			@ yes, error 'a'
 	bl	__vet_atags
 	bl	__create_page_tables
 
arch/arm/mach-pxa/generic.c +6 -0
index 1c34946..4b0f6ea 100644
@@ -195,6 +195,11 @@ static struct map_desc standard_io_desc[] __initdata = {
 		.pfn		= __phys_to_pfn(0x40000000),
 		.length		= 0x02000000,
 		.type		= MT_DEVICE
+	}, {	/* nand               */
+		.virtual	= 0xf8300000,
+		.pfn		= __phys_to_pfn(0x43100000),
+		.length		= 0x00100000,
+		.type		= MT_DEVICE
 	}, {	/* LCD */
 		.virtual	=  0xf4000000,
 		.pfn		= __phys_to_pfn(0x44000000),
@@ -471,6 +476,7 @@ void __init pxa_set_ficp_info(struct pxaficp_platform_data *info)
 	pxa_device_ficp.dev.platform_data = info;
 }
 
+
 struct platform_device pxa_device_rtc = {
 	.name		= "sa1100-rtc",
 	.id		= -1,
arch/arm/mach-pxa/pxa3xx.c +1 -0
index 61d9c9d..4d800c6 100644
@@ -183,6 +183,7 @@ static struct clk pxa3xx_clks[] = {
 	PXA3xx_CK("LCDCLK", LCD,    &clk_pxa3xx_hsio_ops, &pxa_device_fb.dev),
 	PXA3xx_CK("CAMCLK", CAMERA, &clk_pxa3xx_hsio_ops, NULL),
 
+	PXA3xx_CK("NANDCLK", NAND, &clk_pxa3xx_hsio_ops, NULL),
 	PXA3xx_CKEN("UARTCLK", FFUART, 14857000, 1, &pxa_device_ffuart.dev),
 	PXA3xx_CKEN("UARTCLK", BTUART, 14857000, 1, &pxa_device_btuart.dev),
 	PXA3xx_CKEN("UARTCLK", STUART, 14857000, 1, NULL),
arch/arm/mach-pxa/zylonite.c +21 -0
index 743a87b..dc761bd 100644
@@ -156,6 +156,26 @@ static void __init zylonite_init_lcd(void)
 static inline void zylonite_init_lcd(void) {}
 #endif
 
+static struct resource nand_resources[] = {
+	[0] = {
+		.start	= 0x43100000,
+		.end	= 0x431000ff,
+		.flags	= IORESOURCE_MEM,
+	},
+	[1] = {
+		.start	= -1,	/* for run-time assignment */
+		.end	= -1,
+		.flags	= IORESOURCE_IRQ,
+	}
+};
+
+static struct platform_device nand_device = {
+	.name		= "pxa3xx-nand",
+	.id		= 0,
+	.num_resources	= ARRAY_SIZE(nand_resources),
+	.resource	= nand_resources,
+};
+
 static void __init zylonite_init(void)
 {
 	/* board-processor specific initialization */
@@ -171,6 +191,7 @@ static void __init zylonite_init(void)
 	platform_device_register(&smc91x_device);
 
 	zylonite_init_lcd();
+	platform_device_register(&nand_device);
 }
 
 MACHINE_START(ZYLONITE, "PXA3xx Platform Development Kit (aka Zylonite)")
drivers/mtd/nand/Kconfig +6 -0
index 246d451..2be073f 100644
@@ -84,6 +84,12 @@ config MTD_NAND_TS7250
 config MTD_NAND_IDS
 	tristate
 
+config MTD_NAND_PXA3xx
+	tristate "NAND flash support for PXA3xx"
+	depends on MTD_NAND && PXA3xx
+	help
+	  This enables the driver for the NAND flash device on Zylonite board
+
 config MTD_NAND_AU1550
 	tristate "Au1550/1200 NAND support"
 	depends on SOC_AU1200 || SOC_AU1550
drivers/mtd/nand/Makefile +1 -0
index 3ad6c01..ecb7968 100644
@@ -17,6 +17,7 @@ obj-$(CONFIG_MTD_NAND_BF5XX)		+= bf5xx_nand.o
 obj-$(CONFIG_MTD_NAND_PPCHAMELEONEVB)	+= ppchameleonevb.o
 obj-$(CONFIG_MTD_NAND_S3C2410)		+= s3c2410.o
 obj-$(CONFIG_MTD_NAND_DISKONCHIP)	+= diskonchip.o
+obj-$(CONFIG_MTD_NAND_PXA3xx)		+= pxa3xx_nand.o
 obj-$(CONFIG_MTD_NAND_H1900)		+= h1910.o
 obj-$(CONFIG_MTD_NAND_RTC_FROM4)	+= rtc_from4.o
 obj-$(CONFIG_MTD_NAND_SHARPSL)		+= sharpsl.o
drivers/mtd/nand/pxa3xx_nand.c new file +1419 -0

1,419 lines not on this page · raw message

include/asm-arm/arch-pxa/hardware.h +8 -22
index ab2d963..6e8b6b5 100644
@@ -41,10 +41,12 @@
  */
 #define io_p2v(x) (0xf2000000 + ((x) & 0x01ffffff) + (((x) & 0x1c000000) >> 1))
 #define io_v2p(x) (0x3c000000 + ((x) & 0x01ffffff) + (((x) & 0x0e000000) << 1))
-
+#define io_p2v_2(x)	(((((x) - 0x42000000) & 0xff000000) >> 3) + 0xf8000000\
+ 			+ ((x) & 0x001fffff))
 #ifndef __ASSEMBLY__
 
 # define __REG(x)	(*((volatile u32 *)io_p2v(x)))
+#define __REG_2(x)	(*((volatile u32 *)io_p2v_2(x)))
 
 /* With indexed regs we don't want to feed the index through io_p2v()
    especially if it is a variable, otherwise horrible code will result. */
@@ -90,31 +92,19 @@
 #endif
 
 #ifdef CONFIG_CPU_PXA300
-#define __cpu_is_pxa300(id)				\
-	({						\
-		unsigned int _id = (id) >> 4 & 0xfff;	\
-		_id == 0x688;				\
-	 })
+#define __cpu_is_pxa300(id)	(1)
 #else
 #define __cpu_is_pxa300(id)	(0)
 #endif
 
 #ifdef CONFIG_CPU_PXA310
-#define __cpu_is_pxa310(id)				\
-	({						\
-		unsigned int _id = (id) >> 4 & 0xfff;	\
-		_id == 0x689;				\
-	 })
+#define __cpu_is_pxa310(id)	(0)
 #else
 #define __cpu_is_pxa310(id)	(0)
 #endif
 
-#ifdef CONFIG_CPU_PXA320
-#define __cpu_is_pxa320(id)				\
-	({						\
-		unsigned int _id = (id) >> 4 & 0xfff;	\
-		_id == 0x603 || _id == 0x682;		\
-	 })
+#ifdef CONFIG_CPU_PXA320	
+#define __cpu_is_pxa320(id)	(0)
 #else
 #define __cpu_is_pxa320(id)	(0)
 #endif
@@ -166,11 +156,7 @@
 		_id <= 0x2;				\
 	 })
 
-#define __cpu_is_pxa3xx(id)				\
-	({						\
-		unsigned int _id = (id) >> 13 & 0x7;	\
-		_id == 0x3;				\
-	 })
+#define __cpu_is_pxa3xx(id)	(1)
 
 #define cpu_is_pxa2xx()					\
 	({						\
include/asm-arm/arch-pxa/pxa-regs.h +19 -0
index 6b33df6..9f1a32b 100644
@@ -159,6 +159,21 @@
 #define DRCMR68		__REG(0x40001110)  /* Request to Channel Map Register for Camera FIFO 0 Request */
 #define DRCMR69		__REG(0x40001114)  /* Request to Channel Map Register for Camera FIFO 1 Request */
 #define DRCMR70		__REG(0x40001118)  /* Request to Channel Map Register for Camera FIFO 2 Request */
+#define DRCMR71		__REG(0x4000111C)  /* Request to Channel Map Register for TPM Receive Request */
+#define DRCMR72		__REG(0x40001120)  /* Request to Channel Map Register for TPM Transmit Request 1 */
+#define DRCMR73		__REG(0x40001124)  /* Request to Channel Map Register for TPM Transmit Request 2 */
+#define DRCMR74		__REG(0x40001128)  /* Request to Channel Map Register for DREQ<2> */
+#define DRCMR91		__REG(0x4000116C)  /* Request to Channel Map Register for USIM 2 Receive Request */
+#define DRCMR92		__REG(0x40001170)  /* Request to Channel Map Register for USIM 2 Transmit Request */
+#define DRCMR93		__REG(0x40001174)  /* Request to Channel Map Register for MMC Controller 1 Request */
+#define DRCMR94		__REG(0x40001178)  /* Request to Channel Map Register for MMC Controller 2 Request */
+#define DRCMR95		__REG(0x4000117C)  /* Request to Channel Map Register for AC97 Surround Transmit Request */
+#define DRCMR96		__REG(0x40001180)  /* Request to Channel Map Register for AC97 centre/LFE Transmit Request */
+#define DRCMR97		__REG(0x40001184)  /* Request to Channel Map Register for NAND interface data transmit & receive Request */
+#define DRCMR98		__REG(0x40001188)  /* Reserved */
+#define DRCMR99		__REG(0x4000118C)  /* Request to Channel Map Register for NAND interface command transmit Request */
+#define DRCMR100	__REG(0x40001190)  /* Request to Channel Map Register for MMC Controller 3 Request */
+#define DRCMR101	__REG(0x40001194)  /* Request to Channel Map Register for MMC Controller 3 Request */
 
 #define DRCMRRXSADR	DRCMR2
 #define DRCMRTXSADR	DRCMR3
@@ -1780,6 +1795,8 @@
 #define OSCC		__REG(0x41300008)  /* Oscillator Configuration Register */
 #define CCSR		__REG(0x4130000C)  /* Core Clock Status Register */
 
+#define	CKEN_NAND	4	/* < NAND Flash Controller Clock Enable */
+
 #define CCCR_N_MASK	0x0380		/* Run Mode Frequency to Turbo Mode Frequency Multiplier */
 #define CCCR_M_MASK	0x0060		/* Memory Frequency to Run Mode Frequency Multiplier */
 #define CCCR_L_MASK	0x001f		/* Crystal Frequency to Memory Frequency Multiplier */
@@ -2035,6 +2052,8 @@
 #define MDMRS		__REG(0x48000040)  /* MRS value to be written to SDRAM */
 #define BOOT_DEF	__REG(0x48000044)  /* Read-Only Boot-Time Register. Contains BOOT_SEL and PKG_SEL */
 
+#define MECR_CIT	(1 << 1)	/* Card Is There: 0 -> no card, 1 -> card inserted */
+
 /*
  * More handy macros for PCMCIA
  *
include/asm-arm/arch-pxa/pxa3xx_nand.h new file +18 -0
new file mode 100644
index 0000000..81a8937
@@ -0,0 +1,18 @@
+#ifndef __ASM_ARCH_PXA3XX_NAND_H
+#define __ASM_ARCH_PXA3XX_NAND_H
+
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
+
+struct pxa3xx_nand_platform_data {
+
+	/* the data flash bus is shared between the Static Memory
+	 * Controller and the Data Flash Controller,  the arbiter
+	 * controls the ownership of the bus
+	 */
+	int	enable_arbiter;
+
+	struct mtd_partition *parts;
+	unsigned int	nr_parts;
+};
+#endif /* __ASM_ARCH_PXA3XX_NAND_H */
include/asm-arm/arch-pxa/zylonite.h +710 -0

715 lines not on this page · raw message

Signature · 1 line
1.5.3.7