Skip to contentSkip to conversation

Revision boot params to kernel for ARM and mx35 3 stack fixes

PATCH In review Marc Reilly 2 participants 5 messages May 8, 2010 – May 11, 2010

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

The mx35 3 stack relies the cpu rev and board rev to be passed via the bootloader.
The first two patches make this happen.
The third patch fixes the pad selection for the CONTRAST pin. previously it had been set to GPIO1_1 and would trigger endless spurios interrupts on the rev2 board.

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#1 lore raw

PATCH 1/3 Add passing of revision tag when booting the kernel on ARM platforms.

From: Marc Reilly <[email protected]>

---
 arch/arm/include/asm/armlinux.h |    6 ++++++
 arch/arm/lib/armlinux.c         |   23 +++++++++++++++++++++++
 2 files changed, 29 insertions(+), 0 deletions(-)
arch/arm/include/asm/armlinux.h +6 -0
index cfe57f4..f4104fb 100644
@@ -6,6 +6,7 @@
 void armlinux_set_bootparams(void *params);
 void armlinux_set_architecture(int architecture);
 void armlinux_add_dram(struct device_d *dev);
+void armlinux_set_revision(unsigned int);
 #else
 static inline void armlinux_set_bootparams(void *params)
 {
@@ -18,6 +19,11 @@ static inline void armlinux_set_architecture(int architecture)
 static inline void armlinux_add_dram(struct device_d *dev)
 {
 }
+
+static inline void armlinux_set_revision(unsigned int)
+{
+}
+
 #endif
 
 #endif /* __ARCH_ARMLINUX_H */
arch/arm/lib/armlinux.c +23 -0
index 019c030..1c39045 100644
@@ -44,6 +44,8 @@ static struct tag *params;
 static int armlinux_architecture = 0;
 static void *armlinux_bootparams = NULL;
 
+static unsigned int system_rev;
+
 static void setup_start_tag(void)
 {
 	params = (struct tag *)armlinux_bootparams;
@@ -106,6 +108,18 @@ static void setup_commandline_tag(const char *commandline)
 	params = tag_next(params);
 }
 
+static void setup_revision_tag(void)
+{
+	if( system_rev) {
+		params->hdr.tag = ATAG_REVISION;
+		params->hdr.size = tag_size(tag_revision);
+		
+		params->u.revision.rev = system_rev;
+		
+		params = tag_next(params);
+	}
+}
+
 #if 0
 static void setup_initrd_tag(ulong initrd_start, ulong initrd_end)
 {
@@ -147,6 +161,12 @@ void armlinux_add_dram(struct device_d *dev)
 	list_add_tail(&mem->list, &memory_list);
 }
 
+void armlinux_set_revision(unsigned int rev)
+{
+	system_rev = rev;
+}
+
+
 #ifdef CONFIG_CMD_BOOTM
 int do_bootm_linux(struct image_data *data)
 {
@@ -184,6 +204,7 @@ int do_bootm_linux(struct image_data *data)
 	if (initrd_start && initrd_end)
 		setup_initrd_tag (initrd_start, initrd_end);
 #endif
+	setup_revision_tag();
 	setup_end_tag();
 
 	if (relocate_image(data->os, (void *)ntohl(os_header->ih_load)))
@@ -281,6 +302,7 @@ static int do_bootz(struct command *cmdtp, int argc, char *argv[])
 	if (initrd_start && initrd_end)
 		setup_initrd_tag (initrd_start, initrd_end);
 #endif
+	setup_revision_tag();
 	setup_end_tag();
 
 	shutdown_barebox();
@@ -323,6 +345,7 @@ static int do_bootu(struct command *cmdtp, int argc, char *argv[])
 	setup_start_tag();
 	setup_memory_tags();
 	setup_commandline_tag(commandline);
+	setup_revision_tag();
 	setup_end_tag();
 
 	shutdown_barebox();
Signature · 7 lines
1.6.4.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

PATCH 2/3 Detect CPU and board revision for freescale-mx35-3-stack and add to boot parameters

From: Marc Reilly <[email protected]>

---
 arch/arm/mach-imx/include/mach/generic.h    |    5 ++
 arch/arm/mach-imx/include/mach/imx35-regs.h |   18 +++++++
 board/freescale-mx35-3-stack/3stack.c       |   71 +++++++++++++++++++++++++--
 3 files changed, 90 insertions(+), 4 deletions(-)
arch/arm/mach-imx/include/mach/generic.h +5 -0
index 99a53a4..926e553 100644
@@ -3,6 +3,11 @@ int imx_silicon_revision(void);
 #define IMX27_CHIP_REVISION_1_0   0
 #define IMX27_CHIP_REVISION_2_0   1
 
+#define IMX35_CHIP_REVISION_1_0		0x10
+#define IMX35_CHIP_REVISION_2_0		0x20
+
+
+
 #ifdef CONFIG_ARCH_IMX1
 #define cpu_is_mx1()	(1)
 #else
arch/arm/mach-imx/include/mach/imx35-regs.h +18 -0
index c394a2a..899e57b 100644
@@ -76,6 +76,24 @@
 #define PDR0_AUTO_CON		(1 << 0)
 #define PDR0_PER_SEL		(1 << 26)
 
+
+#define IIM_STAT	0x0000
+#define IIM_STATM	0x0004
+#define IIM_ERR		0x0008
+#define IIM_EMASK	0x000C
+#define IIM_FCTL	0x0010
+#define IIM_UA		0x0014
+#define IIM_LA		0x0018
+#define IIM_SDAT	0x001C
+#define IIM_PREV	0x0020
+#define IIM_SREV	0x0024
+#define IIM_PREG_P	0x0028
+#define IIM_SCS0	0x002C
+#define IIM_SCS1	0x0030
+#define IIM_SCS2	0x0034
+#define IIM_SCS3	0x0038
+
+
 /*
  * Adresses and ranges of the external chip select lines
  */
board/freescale-mx35-3-stack/3stack.c +67 -4

120 lines not on this page · raw message

Signature · 7 lines
1.6.4.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw

PATCH 3/3 mx35-3stack: fix Pad selection for CONTRAST pin.

From: Marc Reilly <[email protected]>

On the Rev2 board the GPIO1_1 triggers an interrupt signal for one of the external devices (can't remember which one off the top of my head). This change stops the endless interrupts.

---
 board/freescale-mx35-3-stack/3stack.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
board/freescale-mx35-3-stack/3stack.c +2 -1
index cee0e75..74baae0 100644
@@ -325,10 +325,11 @@ static struct pad_desc f3s_pads[] = {
 	MX35_PAD_D3_HSYNC__IPU_DISPB_D3_HSYNC,
 	MX35_PAD_D3_FPSHIFT__IPU_DISPB_D3_CLK,
 	MX35_PAD_D3_DRDY__IPU_DISPB_D3_DRDY,
-	MX35_PAD_CONTRAST__GPIO1_1,
+	MX35_PAD_CONTRAST__IPU_DISPB_CONTR,
 	MX35_PAD_D3_VSYNC__IPU_DISPB_D3_VSYNC,
 	MX35_PAD_D3_REV__IPU_DISPB_D3_REV,
 	MX35_PAD_D3_CLS__IPU_DISPB_D3_CLS,
+	
 };
 
 static int f3s_console_init(void)
Signature · 7 lines
1.6.4.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
maintainer
#4 lore raw

Re: [PATCH 2/3] Detect CPU and board revision for freescale-mx35-3-stack and add to boot parameters

In reply to Marc Reilly

Hi Marc,

Your patch has some coding style issues. We write function calls like x(y), not x( y ). Also there are several trailing whitespaces in the patch.
Some other comments inline.

Quoted 84 lines · Marc Reilly

From: Marc Reilly <[email protected]>

---
 arch/arm/mach-imx/include/mach/generic.h    |    5 ++
 arch/arm/mach-imx/include/mach/imx35-regs.h |   18 +++++++
 board/freescale-mx35-3-stack/3stack.c       |   71 +++++++++++++++++++++++++--
 3 files changed, 90 insertions(+), 4 deletions(-)
arch/arm/mach-imx/include/mach/generic.h +5 -0
index 99a53a4..926e553 100644
@@ -3,6 +3,11 @@ int imx_silicon_revision(void);
 #define IMX27_CHIP_REVISION_1_0   0
 #define IMX27_CHIP_REVISION_2_0   1
 
+#define IMX35_CHIP_REVISION_1_0		0x10
+#define IMX35_CHIP_REVISION_2_0		0x20
+
+
+
 #ifdef CONFIG_ARCH_IMX1
 #define cpu_is_mx1()	(1)
 #else
arch/arm/mach-imx/include/mach/imx35-regs.h +18 -0
index c394a2a..899e57b 100644
@@ -76,6 +76,24 @@
 #define PDR0_AUTO_CON		(1 << 0)
 #define PDR0_PER_SEL		(1 << 26)
 
+
+#define IIM_STAT	0x0000
+#define IIM_STATM	0x0004
+#define IIM_ERR		0x0008
+#define IIM_EMASK	0x000C
+#define IIM_FCTL	0x0010
+#define IIM_UA		0x0014
+#define IIM_LA		0x0018
+#define IIM_SDAT	0x001C
+#define IIM_PREV	0x0020
+#define IIM_SREV	0x0024
+#define IIM_PREG_P	0x0028
+#define IIM_SCS0	0x002C
+#define IIM_SCS1	0x0030
+#define IIM_SCS2	0x0034
+#define IIM_SCS3	0x0038
+
+
 /*
  * Adresses and ranges of the external chip select lines
  */
board/freescale-mx35-3-stack/3stack.c +16 -0
index fcb87cf..cee0e75 100644
@@ -47,6 +47,7 @@
 #include <mach/iomux-v3.h>
 #include <mach/pmic.h>
 #include <mach/imx-ipu-fb.h>
+#include <mach/generic.h>
 
 #include <i2c/i2c.h>
 #include <i2c/mc13892.h>
@@ -144,6 +145,58 @@ static struct device_d imxfb_dev = {
 	.platform_data	= &ipu_fb_data,
 };
 
+
+/* Board rev for the PDK 3stack */
+#define MX35PDK_BOARD_REV_1	0
+#define MX35PDK_BOARD_REV_2	1
+
+
+/*
+ * Revision to be passed to kernel. The kernel provided
+ * by freescale relies on this.
+ *
+ * C --> CPU type
+ * S --> Silicon revision
+ * B --> Board rev
+ *
+ * 31    20     16     12    8      4     0

board/freescale-mx35-3-stack/3stack.c static struct device_d imxfb_dev = { · line 172

Quoted 10 lines
board/freescale-mx35-3-stack/3stack.c +10 -0
+ *        | Cmaj | Cmin | B  | Smaj | Smin|
+ *
+ * e.g 0x00035120 --> i.MX35, Cpu silicon rev 2.0, Board rev 2
+*/
+static unsigned int system_rev;
+
+unsigned int get_board_rev(void)
+{
+	return system_rev;
+}

This shouldn't be exported, at least not with such a generic name and without a declaration in a header file.

Quoted 5 lines
board/freescale-mx35-3-stack/3stack.c +5 -0
+
+/*
+ * Setup system_rev with the MX35 cpu and the silicon revision
+ * Doesn't set up the board.
+ *

board/freescale-mx35-3-stack/3stack.c static struct device_d imxfb_dev = { · line 187

Quoted 10 lines
board/freescale-mx35-3-stack/3stack.c +10 -0
+ * TODO: look up the rompatch
+ */
+static inline void setup_soc_rev(void)
+{
+	uint32_t reg;
+	reg = readl(IMX_IIM_BASE + IIM_SREV);
+	reg += IMX35_CHIP_REVISION_1_0;
+	
+	system_rev = 0x35000 + (reg & 0xFF);
+}

This function could be useful elsewhere. We already have a imx_silicon_revision() for i.MX27. Can you use the same for i.MX35 please?

Quoted 16 lines
board/freescale-mx35-3-stack/3stack.c +12 -0
+
+static inline void set_board_rev(int rev)
+{
+	system_rev =  (system_rev & ~(0xF << 8)) | (rev & 0xF) << 8;
+}
+
+int is_soc_rev(int rev)
+{
+	return (system_rev & 0xFF) - rev;
+}
+
+
 static int f3s_devices_init(void)
 {
 	uint32_t reg;

board/freescale-mx35-3-stack/3stack.c static int f3s_devices_init(void) · line 237

Quoted 4 lines
board/freescale-mx35-3-stack/3stack.c +1 -0
@@ -181,6 +234,8 @@ static int f3s_devices_init(void)
 		break;
 	}
 
+	setup_soc_rev();

I think it's easier to read just to do a

system_rev = 0x35000 | imx_silicon_revision();

here, and a

Quoted 30 lines
board/freescale-mx35-3-stack/3stack.c +6 -3
+
 	i2c_register_board_info(0, i2c_devices, ARRAY_SIZE(i2c_devices));
 	register_device(&i2c_dev);
 
@@ -374,13 +429,16 @@ static int f3s_get_rev(struct mc13892 *mc13892)
 	if (rev == 0x00ffffff)
 		return -ENODEV;
 
-	return ((rev >> 6) & 0x7) ? 20 : 10;
+	return ((rev >> 6) & 0x7) ? MX35PDK_BOARD_REV_2 : MX35PDK_BOARD_REV_1;
 }
 
 static int f3s_pmic_init_v2(struct mc13892 *mc13892)
 {
 	int err = 0;
 
+	/* COMPARE pin (GPIO1_5) as output and set high */
+	gpio_direction_output( 32*0 + 5 , 1);
+	
 	err |= mc13892_set_bits(mc13892, MC13892_REG_SETTING_0, 0x03, 0x03);
 	err |= mc13892_set_bits(mc13892, MC13892_REG_MODE_0, 0x01, 0x01);
 	if (err)
@@ -421,16 +479,18 @@ static int f3s_pmic_init(void)
 
 	rev = f3s_get_rev(mc13892);
 	switch (rev) {
-	case 10:
+	case MX35PDK_BOARD_REV_1:
 		break;
-	case 20:

board/freescale-mx35-3-stack/3stack.c static int f3s_pmic_init(void) · line 492

Quoted 10 lines
board/freescale-mx35-3-stack/3stack.c +3 -1
+	case MX35PDK_BOARD_REV_2:
 		f3s_pmic_init_v2(mc13892);
 		break;
 	default:
 		printf("FAILED to identify board revision!\n");
 		return 0;
 	}
-	printf("i.MX35 PDK CPU board version %d.%d\n", rev / 10, rev % 10);
+	
+	set_board_rev( rev );

system_rev |= rev << 8

here.

Also, imx35_3ds_system_rev might be a better name to prevent confusion with other system_rev variables.

Sascha

Quoted 23 lines
board/freescale-mx35-3-stack/3stack.c +4 -0
+	printf("i.MX35 PDK CPU board version %d.\n", rev );
 
 	mc9sdz60 = mc9sdz60_get();
 	if (!mc9sdz60) {
@@ -439,6 +499,9 @@ static int f3s_pmic_init(void)
 	}
 
 	f3s_pmic_init_all(mc9sdz60);
+	
+	printf("system_rev is 0x%08x.\n", system_rev );
+	armlinux_set_revision( system_rev );
 
 	return 0;
 }
Signature · 7 lines
1.6.4.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox