ARM: mxs: use CHIPID hardware to detect SoC
Subsystems (3)
cover ARM: mxs: use CHIPID hardware to detect SoC
As suggested by Wolfram, the first patch changes cpu_is_xxx and __arch_decomp_setup to use the 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.
The second one is a rebase of patch [1] on above patch.
Regards,
Shawn
[1] [PATCH v4] ARM: mxs: Add initial support for Bluegiga APX4 Development Kit
---
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/mxs.h | 28 ++-- arch/arm/mach-mxs/include/mach/uncompress.h | 11 +- arch/arm/mach-mxs/mach-apx4devkit.c | 245 +++++++++++++++++++++++++++ 5 files changed, 283 insertions(+), 18 deletions(-)
PATCH 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/mxs.h | 28 ++++++++++++++------------ arch/arm/mach-mxs/include/mach/uncompress.h | 11 +++++---- 2 files changed, 21 insertions(+), 18 deletions(-)
arch/arm/mach-mxs/include/mach/mxs.h +15 -13
@@ -26,19 +26,6 @@#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 +96,21 @@ static inline void __mxs_togl(u32 mask, void __iomem *reg) {__raw_writel (mask, reg +MXS_TOG_ADDR ); } + +/* +* MXS CPU types +*/ +#define CHIPID (MXS_IO_ADDRESS(MXS_DIGCTL_BASE_ADDR) + 0x310) + +static inline int cpu_is_mx23 (void ) +{ +return ((__raw_readl (CHIPID ) >>16 ) ==0x3780 ); +} + +static inline int cpu_is_mx28 (void ) +{ +return ((__raw_readl (CHIPID ) >>16 ) ==0x2800 ); +}#endif #endif /* __MACH_MXS_H__ */
arch/arm/mach-mxs/include/mach/uncompress.h +6 -5
@@ -55,16 +55,17 @@ static inline void flush(void)#define MX23_DUART_BASE_ADDR 0x80070000#define MX28_DUART_BASE_ADDR 0x80074000 +#define MXS_DIGCTL_CHIPID 0x8001c310static 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
PATCH 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 changescpu_is_xxxand__arch_decomp_setupto 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.Suggested-by Wolfram Sang <[email protected]>Signed-off-by Shawn Guo <[email protected]>
[...]
arch/arm/mach-mxs/include/mach/mxs.h static inline void __mxs_togl(u32 mask, void __iomem *reg) · line 103
Quoted 5 lines
arch/arm/mach-mxs/include/mach/mxs.h +5
-0+ +/* +* MXS CPU types +*/ +#define CHIPID (MXS_IO_ADDRESS(MXS_DIGCTL_BASE_ADDR) + 0x310)
Hmm, in general I don't like accessing single registers this way. Since we only read, it might work for now, but I think it will turn ugly the more we use from DIGCTL (which is annoying to abstract, yes).
0x310 should not be hardcoded. CHIPID could be MXS_CHIPID.
Quoted 5 lines
arch/arm/mach-mxs/include/mach/uncompress.h +0
-0
arch/arm/mach-mxs/include/mach/uncompress.h static inline void flush(void) · line 62
Quoted 10 lines
arch/arm/mach-mxs/include/mach/uncompress.h +2
-2@@ -55,16 +55,17 @@ static inline void flush(void)#define MX23_DUART_BASE_ADDR 0x80070000#define MX28_DUART_BASE_ADDR 0x80074000 +#define MXS_DIGCTL_CHIPID 0x8001c310static 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 ;
Can't we use the cpu_is-functions here?
Regards,
Wolfram
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/20120106/a5c81ef0/attachment.sig>
PATCH 1/2 ARM: mxs: detect SoC by checking CHIPID register
Quoted 12 lines · Wolfram Sang
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 changescpu_is_xxxand__arch_decomp_setupto 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.Suggested-by Wolfram Sang <[email protected]>Signed-off-by Shawn Guo <[email protected]>[...]
Quoted 10 lines
arch/arm/mach-mxs/include/mach/mxs.h static inline void __mxs_togl(u32 mask, void __iomem *reg) · line 103
Quoted 5 lines
arch/arm/mach-mxs/include/mach/mxs.h +5
-0+ +/* +* MXS CPU types +*/ +#define CHIPID (MXS_IO_ADDRESS(MXS_DIGCTL_BASE_ADDR) + 0x310)Hmm, in general I don't like accessing single registers this way. Since we only read, it might work for now, but I think it will turn ugly the more we use from DIGCTL (which is annoying to abstract, yes).
I agree with you. But I do not really want to start writing a digctl.c just from this patch series.
Quoted 2 lines
0x310should not be hardcoded. CHIPID could beMXS_CHIPID.
I thought about those when I wrote the code, and decided not to bother, since they are very really limited in mxs.h. But now I think I should bother, because your comments are here.
Quoted 10 lines
Quoted 10 lines
arch/arm/mach-mxs/include/mach/uncompress.h +1
-0@@ -55,16 +55,17 @@ static inline void flush(void)#define MX23_DUART_BASE_ADDR 0x80070000#define MX28_DUART_BASE_ADDR 0x80074000 +#define MXS_DIGCTL_CHIPID 0x8001c310
Quoted 8 lines
arch/arm/mach-mxs/include/mach/uncompress.h static inline void flush(void) · line 62
Quoted 5 lines
arch/arm/mach-mxs/include/mach/uncompress.h +1
-2static 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 ;Can't we use the cpu_is-functions here?
No. We are running with MMU off here.
Signature · 2 lines
Regards, Shawn
PATCH 1/2 ARM: mxs: detect SoC by checking CHIPID register
Quoted 6 lines
Quoted 3 lines
0x310should not be hardcoded. CHIPID could beMXS_CHIPID.I thought about those when I wrote the code, and decided not to bother, since they are very really limited in
mxs.h. But now I think I should bother, because your comments are here.
:) I think 0x310 should be defined in digctl.h (which was introduced by Aisheng IIRC). Then, we at least know which functionality from DIGCTL is used currently.
Quoted 3 lines
Quoted 2 lines
Can't we use the cpu_is-functions here?
No. We are running with MMU off here.
Right, thanks, missed that.
Thanks,
Wolfram
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/20120106/c17eb839/attachment.sig>
PATCH 2/2 ARM: mxs: Add initial support for Bluegiga APX4 Development Kit
In reply to Shawn GuoFrom: 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
@@ -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
@@ -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
cover ARM: mxs: use CHIPID hardware to detect SoC
In reply to Shawn GuoI'm not able to test patches until Monday. I'll test these when I'm back to office. Anyway patches looks good for me. Thanks!
Lauri
Quoted 26 lines · Shawn Guo
As suggested by Wolfram, the first patch changes
cpu_is_xxxand__arch_decomp_setupto use the 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.The second one is a rebase of patch [1] on above patch.
Regards,
Shawn[1] [PATCH v4] ARM: mxs: Add initial support for Bluegiga APX4 Development Kit
---
Lauri Hintsala (1):
ARM: mxs: Add initial support for Bluegiga APX4 Development KitShawn Guo (1):
ARM: mxs: detect SoC by checking CHIPID registerarch/arm/mach-mxs/Kconfig | 16 ++ arch/arm/mach-mxs/Makefile | 1 + arch/arm/mach-mxs/include/mach/mxs.h | 28 ++-- arch/arm/mach-mxs/include/mach/uncompress.h | 11 +- arch/arm/mach-mxs/mach-apx4devkit.c | 245 +++++++++++++++++++++++++++ 5 files changed, 283 insertions(+), 18 deletions(-)