[PATCH] add-gta02-pcb-revision-detect.patch

Andy Green andy at openmoko.com
Wed Apr 2 22:08:09 CEST 2008


Add function

int gta02_get_pcb_revision(void)

which returns state of GTA02 PCB revision pins.  It is also called
and logged during boot with KERN_INFO.  The results look like:

b9    b8        b2    b1    b0
 GPD4  GPD3     GPD0  GPC15 GPC13

 GTA02 A5 and before:  0x000
 GTA02 A6           :  0x001

Signed-off-by: Andy Green <andy at openmoko.com>
---

 arch/arm/mach-s3c2440/mach-gta02.c   |   55 ++++++++++++++++++++++++++++++++++
 include/asm-arm/arch-s3c2410/gta02.h |    9 ++++++
 2 files changed, 64 insertions(+), 0 deletions(-)


diff --git a/arch/arm/mach-s3c2440/mach-gta02.c b/arch/arm/mach-s3c2440/mach-gta02.c
index d28e976..3fc7398 100644
--- a/arch/arm/mach-s3c2440/mach-gta02.c
+++ b/arch/arm/mach-s3c2440/mach-gta02.c
@@ -317,6 +317,59 @@ FIQ_HANDLER_ENTRY(256, 512)
 FIQ_HANDLER_END()
 
 
+/**
+ * returns PCB revision information in b9,b8 and b2,b1,b0
+ * Pre-GTA02 A6 returns 0x000
+ *     GTA02 A6 returns 0x101
+ *     ...
+ */
+
+int gta02_get_pcb_revision(void)
+{
+	int n;
+	int u = 0;
+	static unsigned long pinlist[] = {
+		GTA02_PCB_ID1_0,
+		GTA02_PCB_ID1_1,
+		GTA02_PCB_ID1_2,
+		GTA02_PCB_ID2_0,
+		GTA02_PCB_ID2_1,
+	};
+	static int pin_offset[] = {
+		0, 1, 2, 8, 9
+	};
+
+	for (n = 0 ; n < ARRAY_SIZE(pinlist); n++) {
+		/*
+		 * set the PCB version GPIO to be pulled-down input
+		 * force low briefly first
+		 */
+		s3c2410_gpio_cfgpin(pinlist[n], S3C2410_GPIO_OUTPUT);
+		s3c2410_gpio_setpin(pinlist[n], 0);
+		/* misnomer: it is a pullDOWN in 2442 */
+		s3c2410_gpio_pullup(pinlist[n], 1);
+		s3c2410_gpio_cfgpin(pinlist[n], S3C2410_GPIO_INPUT);
+
+		udelay(10);
+
+		if (s3c2410_gpio_getpin(pinlist[n]))
+			u |= 1 << pin_offset[n];
+
+		/*
+		* when not being interrogated, all of the revision GPIO
+		* are set to output HIGH without pulldown so no current flows
+		* if they are NC or pulled up.
+		*/
+		s3c2410_gpio_setpin(pinlist[n], 1);
+		s3c2410_gpio_cfgpin(pinlist[n], S3C2410_GPIO_OUTPUT);
+		/* misnomer: it is a pullDOWN in 2442 */
+		s3c2410_gpio_pullup(pinlist[n], 0);
+	}
+
+	return u;
+}
+
+
 static struct map_desc gta02_iodesc[] __initdata = {
 	{
 		.virtual	= 0xe0000000,
@@ -1241,6 +1294,8 @@ static void __init gta02_machine_init(void)
 {
 	int rc;
 
+	printk(KERN_INFO"GTA02 PCB rev = 0x%03X\n", gta02_get_pcb_revision());
+
 	s3c_device_usb.dev.platform_data = &gta02_usb_info;
 	s3c_device_nand.dev.platform_data = &gta02_nand_info;
 	s3c_device_sdi.dev.platform_data = &gta02_mmc_cfg;
diff --git a/include/asm-arm/arch-s3c2410/gta02.h b/include/asm-arm/arch-s3c2410/gta02.h
index 2dd4fa4..6289d1e 100644
--- a/include/asm-arm/arch-s3c2410/gta02.h
+++ b/include/asm-arm/arch-s3c2410/gta02.h
@@ -96,4 +96,13 @@
 #define GTA02v3_IRQ_nUSB_FLT	IRQ_EINT18	/* v3 + v4 only */
 #define GTA02v3_IRQ_nGSM_OC	IRQ_EINT19	/* v3 + v4 only */
 
+/* returns 00 000 on GTA02 A5 and earlier, A6 returns 01 001 */
+#define GTA02_PCB_ID1_0		S3C2410_GPC13
+#define GTA02_PCB_ID1_1		S3C2410_GPC15
+#define GTA02_PCB_ID1_2		S3C2410_GPD0
+#define GTA02_PCB_ID2_0		S3C2410_GPD3
+#define GTA02_PCB_ID2_1		S3C2410_GPD4
+
+int gta02_get_pcb_revision(void);
+
 #endif /* _GTA02_H */





More information about the openmoko-kernel mailing list