Skip to contentSkip to conversation

ARM: mxs: use CHIPID register to detect SoC

PATCH New Shawn Guo 4 participants 9 messages Jan 6, 2012 – Jan 11, 2012

Subsystems (3)
lore
Share & tools
lore

Shawn Guo

author
#0 lore raw

v2 cover ARM: mxs: use CHIPID register to detect SoC

Changes since v1:
* Define CHIPID register offset in digctl.h
* Rename macro CHIPID to MXS_CHIPID
* Remove mach-types.h inclusion from uncompress.h

Lauri Hintsala (1):
ARM: mxs: Add initial support for Bluegiga APX4 Development Kit

Shawn Guo (1):
ARM: mxs: detect SoC by checking CHIPID register

 arch/arm/mach-mxs/Kconfig                   |   16 ++
 arch/arm/mach-mxs/Makefile                  |    1 +
 arch/arm/mach-mxs/include/mach/digctl.h     |    1 +
 arch/arm/mach-mxs/include/mach/mxs.h        |   29 ++--
 arch/arm/mach-mxs/include/mach/uncompress.h |   13 +-
 arch/arm/mach-mxs/mach-apx4devkit.c         |  245 +++++++++++++++++++++++++++
 6 files changed, 285 insertions(+), 20 deletions(-)
author
#1 lore raw

PATCH v2 1/2 ARM: mxs: detect SoC by checking CHIPID register

Both imx23 and imx28 have CHIPID register at address 0x8001c310, which can be used to identify the SoC. This patch changes cpu_is_xxx and __arch_decomp_setup to use this CHIPID register than machine type to detect the chip between imx23 and imx28, so that we do not need to change these functions whenever a new board/machine gets added.

---
 arch/arm/mach-mxs/include/mach/digctl.h     |    1 +
 arch/arm/mach-mxs/include/mach/mxs.h        |   29 ++++++++++++++------------
 arch/arm/mach-mxs/include/mach/uncompress.h |   13 +++++------
 3 files changed, 23 insertions(+), 20 deletions(-)
arch/arm/mach-mxs/include/mach/digctl.h +1 -0
index 49a888c..1796406 100644
@@ -18,4 +18,5 @@
 #define HW_DIGCTL_CTRL			0x0
 #define  BP_DIGCTL_CTRL_SAIF_CLKMUX	10
 #define  BM_DIGCTL_CTRL_SAIF_CLKMUX	(0x3 << 10)
+#define HW_DIGCTL_CHIPID		0x310
 #endif
arch/arm/mach-mxs/include/mach/mxs.h +16 -13
index bde5f66..7d4fb6d 100644
@@ -23,22 +23,10 @@
 #include <linux/io.h>
 #endif
 #include <asm/mach-types.h>
+#include <mach/digctl.h>
 #include <mach/hardware.h>
 
 /*
- * MXS CPU types
- */
-#define cpu_is_mx23()		(					\
-		machine_is_mx23evk() ||					\
-		machine_is_stmp378x() ||				\
-		0)
-#define cpu_is_mx28()		(					\
-		machine_is_mx28evk() ||					\
-		machine_is_m28evk() ||					\
-		machine_is_tx28() ||					\
-		0)
-
-/*
  * IO addresses common to MXS-based
  */
 #define MXS_IO_BASE_ADDR		0x80000000
@@ -109,6 +97,21 @@ static inline void __mxs_togl(u32 mask, void __iomem *reg)
 {
 	__raw_writel(mask, reg + MXS_TOG_ADDR);
 }
+
+/*
+ * MXS CPU types
+ */
+#define MXS_CHIPID (MXS_IO_ADDRESS(MXS_DIGCTL_BASE_ADDR) + HW_DIGCTL_CHIPID)
+
+static inline int cpu_is_mx23(void)
+{
+	return ((__raw_readl(MXS_CHIPID) >> 16) == 0x3780);
+}
+
+static inline int cpu_is_mx28(void)
+{
+	return ((__raw_readl(MXS_CHIPID) >> 16) == 0x2800);
+}
 #endif
 
 #endif /* __MACH_MXS_H__ */
arch/arm/mach-mxs/include/mach/uncompress.h +6 -7
index 6777674..ef28114 100644
@@ -18,8 +18,6 @@
 #ifndef __MACH_MXS_UNCOMPRESS_H__
 #define __MACH_MXS_UNCOMPRESS_H__
 
-#include <asm/mach-types.h>
-
 unsigned long mxs_duart_base;
 
 #define MXS_DUART(x)	(*(volatile unsigned long *)(mxs_duart_base + (x)))
@@ -55,16 +53,17 @@ static inline void flush(void)
 
 #define MX23_DUART_BASE_ADDR	0x80070000
 #define MX28_DUART_BASE_ADDR	0x80074000
+#define MXS_DIGCTL_CHIPID	0x8001c310
 
 static inline void __arch_decomp_setup(unsigned long arch_id)
 {
-	switch (arch_id) {
-	case MACH_TYPE_MX23EVK:
+	u16 chipid = (*(volatile unsigned long *) MXS_DIGCTL_CHIPID) >> 16;
+
+	switch (chipid) {
+	case 0x3780:
 		mxs_duart_base = MX23_DUART_BASE_ADDR;
 		break;
-	case MACH_TYPE_MX28EVK:
-	case MACH_TYPE_M28EVK:
-	case MACH_TYPE_TX28:
+	case 0x2800:
 		mxs_duart_base = MX28_DUART_BASE_ADDR;
 		break;
 	default:
Signature · 1 line
1.7.4.1
#2 lore raw

PATCH v2 1/2 ARM: mxs: detect SoC by checking CHIPID register

Quoted 8 lines · Shawn Guo

Both imx23 and imx28 have CHIPID register at address 0x8001c310, which can be used to identify the SoC. This patch changes cpu_is_xxx and __arch_decomp_setup to use this CHIPID register than machine type to detect the chip between imx23 and imx28, so that we do not need to change these functions whenever a new board/machine gets added.

Signature · 9 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120107/f7b599b1/attachment-0001.sig>
#3 lore raw

PATCH v2 1/2 ARM: mxs: detect SoC by checking CHIPID register

In reply to Shawn Guo
Quoted 9 lines

Both imx23 and imx28 have CHIPID register at address 0x8001c310, which can be used to identify the SoC. This patch changes cpu_is_xxx and __arch_decomp_setup to use this CHIPID register than machine type to detect the chip between imx23 and imx28, so that we do not need to change these functions whenever a new board/machine gets added.

---

Looks nice, please add my:

Also please keep me in Cc with mxs patches.

M

author
#4 lore raw

PATCH v2 1/2 ARM: mxs: detect SoC by checking CHIPID register

Quoted 6 lines · Marek Vasut
Quoted 6 lines

Both imx23 and imx28 have CHIPID register at address 0x8001c310, which can be used to identify the SoC. This patch changes cpu_is_xxx and __arch_decomp_setup to use this CHIPID register than machine type to detect the chip between imx23 and imx28, so that we do not need to change these functions whenever a new board/machine gets added.

Quoted 8 lines
Quoted 3 lines

---

Looks nice, please add my:

Sorry, the patch has been sent to arm-soc.

Quoted 2 lines

Also please keep me in Cc with mxs patches.

Ok, will do.

Signature · 2 lines
Regards,
Shawn
#5 lore raw

PATCH v2 1/2 ARM: mxs: detect SoC by checking CHIPID register

Quoted 11 lines · Marek Vasut
Quoted 10 lines
Quoted 9 lines

Both imx23 and imx28 have CHIPID register at address 0x8001c310, which can be used to identify the SoC. This patch changes cpu_is_xxx and __arch_decomp_setup to use this CHIPID register than machine type to detect the chip between imx23 and imx28, so that we do not need to change these functions whenever a new board/machine gets added.

---

Quoted 5 lines
Quoted 3 lines

Looks nice, please add my:

Sorry, the patch has been sent to arm-soc.

No problem

Quoted 4 lines
Quoted 2 lines

Also please keep me in Cc with mxs patches.

Ok, will do.

Thanks

author
#6 lore raw

PATCH v2 2/2 ARM: mxs: Add initial support for Bluegiga APX4 Development Kit

In reply to Shawn Guo

From: Lauri Hintsala <[email protected]>

Added initial support for APX4 Development Kit with RTC, LED, Ethernet, Audio, SDIO, I2C, DUART and AUART support.

---
 arch/arm/mach-mxs/Kconfig           |   16 +++
 arch/arm/mach-mxs/Makefile          |    1 +
 arch/arm/mach-mxs/mach-apx4devkit.c |  245 +++++++++++++++++++++++++++++++++++
 3 files changed, 262 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-mxs/mach-apx4devkit.c
arch/arm/mach-mxs/Kconfig +16 -0
index cf00b3e..c57f996 100644
@@ -83,6 +83,18 @@ config MODULE_M28
 	select MXS_HAVE_PLATFORM_MXSFB
 	select MXS_OCOTP
 
+config MODULE_APX4
+	bool
+	select SOC_IMX28
+	select LEDS_GPIO_REGISTER
+	select MXS_HAVE_AMBA_DUART
+	select MXS_HAVE_PLATFORM_AUART
+	select MXS_HAVE_PLATFORM_FEC
+	select MXS_HAVE_PLATFORM_MXS_I2C
+	select MXS_HAVE_PLATFORM_MXS_MMC
+	select MXS_HAVE_PLATFORM_MXS_SAIF
+	select MXS_OCOTP
+
 config MACH_TX28
 	bool "Ka-Ro TX28 module"
 	select MODULE_TX28
@@ -91,4 +103,8 @@ config MACH_M28EVK
 	bool "Support DENX M28EVK Platform"
 	select MODULE_M28
 
+config MACH_APX4DEVKIT
+	bool "Support Bluegiga APX4 Development Kit"
+	select MODULE_APX4
+
 endif
arch/arm/mach-mxs/Makefile +1 -0
index 8c93b24..908bf9a 100644
@@ -11,6 +11,7 @@ obj-$(CONFIG_MACH_STMP378X_DEVB) += mach-stmp378x_devb.o
 obj-$(CONFIG_MACH_MX23EVK) += mach-mx23evk.o
 obj-$(CONFIG_MACH_MX28EVK) += mach-mx28evk.o
 obj-$(CONFIG_MACH_M28EVK)    += mach-m28evk.o
+obj-$(CONFIG_MACH_APX4DEVKIT) += mach-apx4devkit.o
 obj-$(CONFIG_MODULE_TX28) += module-tx28.o
 obj-$(CONFIG_MACH_TX28)    += mach-tx28.o
 
arch/arm/mach-mxs/mach-apx4devkit.c new file +245 -0

245 lines not on this page · raw message

Signature · 1 line
1.7.4.1
#7 lore raw

PATCH 1/1 MXS: apx4devkit: add platform data for saif

In reply to Shawn Guo
cc shawn.guo at linaro.org

---

Hi Shawn,

My patch was based on mainline tree and saif patches broke it. This patch fixes compiling issue which was caused by saif patches. If you think so we can apply also this patch later when apx4devkit is pulled to mainline (hopefully to 3.3).

Lauri

 arch/arm/mach-mxs/mach-apx4devkit.c |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)
arch/arm/mach-mxs/mach-apx4devkit.c +16 -2
index 08693f1..013aae5 100644
@@ -33,6 +33,7 @@
 
 #include <mach/common.h>
 #include <mach/iomux-mx28.h>
+#include <mach/digctl.h>
 
 #include "devices-mx28.h"
 
@@ -192,6 +193,18 @@ static int apx4devkit_phy_fixup(struct phy_device *phy)
 	return 0;
 }
 
+static const struct mxs_saif_platform_data
+                       apx4devkit_mxs_saif_pdata[] __initconst = {
+       /* working on EXTMSTR0 mode (saif0 master, saif1 slave) */
+       {
+               .master_mode = 1,
+               .master_id = 0,
+       }, {
+               .master_mode = 0,
+               .master_id = 0,
+       },
+};
+
 static void __init apx4devkit_init(void)
 {
 	mxs_iomux_setup_multiple_pads(apx4devkit_pads,
@@ -216,8 +229,9 @@ static void __init apx4devkit_init(void)
 
 	gpio_led_register_device(0, &apx4devkit_led_data);
 
-	mx28_add_saif(0);
-	mx28_add_saif(1);
+	mxs_saif_clkmux_select(MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR0);
+	mx28_add_saif(0, &apx4devkit_mxs_saif_pdata[0]);
+	mx28_add_saif(1, &apx4devkit_mxs_saif_pdata[1]);
 
 	apx4devkit_add_regulators();
 
Signature · 1 line
1.7.4.1
author
#8 lore raw

PATCH 1/1 MXS: apx4devkit: add platform data for saif

Please make the patch subject like: 'ARM: mxs: apx4devkit: ...'

Quoted 10 lines · Lauri Hintsala
cc shawn.guo at linaro.org

---

Hi Shawn,

My patch was based on mainline tree and saif patches broke it. This patch fixes compiling issue which was caused by saif patches. If you think so we can apply also this patch later when apx4devkit is pulled to mainline (hopefully to 3.3).

I doubt that Arnd and Olof will send it for 3.3, since it's missed arm-soc 'next' branch. But we can send this patch as a fix to arm-soc anyway, when the board support gets pulled to arm-soc tree.

Quoted 12 lines

Lauri

 arch/arm/mach-mxs/mach-apx4devkit.c |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)
arch/arm/mach-mxs/mach-apx4devkit.c +0 -0
index 08693f1..013aae5 100644

arch/arm/mach-mxs/mach-apx4devkit.c line 36

Quoted 4 lines
arch/arm/mach-mxs/mach-apx4devkit.c +1 -0
@@ -33,6 +33,7 @@
 
 #include <mach/common.h>
 #include <mach/iomux-mx28.h>
+#include <mach/digctl.h>

Nit: I would suggest put the new line in the second row to have them alphabetically sorted as a group of <mach/*> inclusion.

Regards,
Shawn

Quoted 37 lines
arch/arm/mach-mxs/mach-apx4devkit.c +15 -2
 #include "devices-mx28.h"
 
@@ -192,6 +193,18 @@ static int apx4devkit_phy_fixup(struct phy_device *phy)
 	return 0;
 }
 
+static const struct mxs_saif_platform_data
+                       apx4devkit_mxs_saif_pdata[] __initconst = {
+       /* working on EXTMSTR0 mode (saif0 master, saif1 slave) */
+       {
+               .master_mode = 1,
+               .master_id = 0,
+       }, {
+               .master_mode = 0,
+               .master_id = 0,
+       },
+};
+
 static void __init apx4devkit_init(void)
 {
 	mxs_iomux_setup_multiple_pads(apx4devkit_pads,
@@ -216,8 +229,9 @@ static void __init apx4devkit_init(void)
 
 	gpio_led_register_device(0, &apx4devkit_led_data);
 
-	mx28_add_saif(0);
-	mx28_add_saif(1);
+	mxs_saif_clkmux_select(MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR0);
+	mx28_add_saif(0, &apx4devkit_mxs_saif_pdata[0]);
+	mx28_add_saif(1, &apx4devkit_mxs_saif_pdata[1]);
 
 	apx4devkit_add_regulators();
 
Signature · 1 line
1.7.4.1