diff mbox

[U-Boot,V2,17/21] mx6: soc: add get_cpu_type

Message ID 1348281558-19520-18-git-send-email-troy.kisky@boundarydevices.com
State Changes Requested
Headers show

Commit Message

Troy Kisky Sept. 22, 2012, 2:39 a.m. UTC
Add function to return the processor type.

i.e. MX6Q, MX6DL, MX6SOLO, MX6SOLOLITE

Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
---
 arch/arm/cpu/armv7/mx6/soc.c              |   26 ++++++++++++++++++++++++++
 arch/arm/include/asm/arch-mx6/sys_proto.h |    6 ++++++
 2 files changed, 32 insertions(+)

Comments

Fabio Estevam Sept. 22, 2012, 2:50 a.m. UTC | #1
Hi Troy,

On Fri, Sep 21, 2012 at 11:39 PM, Troy Kisky
<troy.kisky@boundarydevices.com> wrote:
> Add function to return the processor type.
>
> i.e. MX6Q, MX6DL, MX6SOLO, MX6SOLOLITE

On arch/arm/imx-common/cpu.c we have:

static const char *get_imx_type(u32 imxtype)
{
	switch (imxtype) {
	case 0x63:
		return "6Q";	/* Quad-core version of the mx6 */
	case 0x61:
		return "6DS";	/* Dual/Solo version of the mx6 */
	case 0x60:
		return "6SL";	/* Solo-Lite version of the mx6 */
	case 0x51:
		return "51";
	case 0x53:
		return "53";
	default:
		return "??";
	}
}

,which seems to serve the same purpose.

Regards,

Fabio Estevam
Troy Kisky Sept. 22, 2012, 5:07 p.m. UTC | #2
On 9/21/2012 7:50 PM, Fabio Estevam wrote:
> Hi Troy,
>
> On Fri, Sep 21, 2012 at 11:39 PM, Troy Kisky
> <troy.kisky@boundarydevices.com> wrote:
>> Add function to return the processor type.
>>
>> i.e. MX6Q, MX6DL, MX6SOLO, MX6SOLOLITE
> On arch/arm/imx-common/cpu.c we have:
>
> static const char *get_imx_type(u32 imxtype)
> {
> 	switch (imxtype) {
> 	case 0x63:
> 		return "6Q";	/* Quad-core version of the mx6 */
> 	case 0x61:
> 		return "6DS";	/* Dual/Solo version of the mx6 */
> 	case 0x60:
> 		return "6SL";	/* Solo-Lite version of the mx6 */
> 	case 0x51:
> 		return "51";
> 	case 0x53:
> 		return "53";
> 	default:
> 		return "??";
> 	}
> }
>
> ,which seems to serve the same purpose.
>
> Regards,
>
> Fabio Estevam
>

No, not similar to get_imx_type, but it is similar to get_cpu_rev.

I guess I should fix get_imx_type, and get_cpu_rev, instead of
adding a new one.

Thanks for the heads up!
Troy
Stefano Babic Sept. 23, 2012, 2:59 p.m. UTC | #3
On 22/09/2012 19:07, Troy Kisky wrote:
> On 9/21/2012 7:50 PM, Fabio Estevam wrote:
>> Hi Troy,
>>
>> On Fri, Sep 21, 2012 at 11:39 PM, Troy Kisky
>> <troy.kisky@boundarydevices.com> wrote:
>>> Add function to return the processor type.
>>>
>>> i.e. MX6Q, MX6DL, MX6SOLO, MX6SOLOLITE
>> On arch/arm/imx-common/cpu.c we have:
>>
>> static const char *get_imx_type(u32 imxtype)
>> {
>>     switch (imxtype) {
>>     case 0x63:
>>         return "6Q";    /* Quad-core version of the mx6 */
>>     case 0x61:
>>         return "6DS";    /* Dual/Solo version of the mx6 */
>>     case 0x60:
>>         return "6SL";    /* Solo-Lite version of the mx6 */
>>     case 0x51:
>>         return "51";
>>     case 0x53:
>>         return "53";
>>     default:
>>         return "??";
>>     }
>> }
>>
>> ,which seems to serve the same purpose.
>>
>> Regards,
>>
>> Fabio Estevam
>>
> 
> No, not similar to get_imx_type, but it is similar to get_cpu_rev.
> 
> I guess I should fix get_imx_type, and get_cpu_rev, instead of
> adding a new one.
> 

Indeed. Try to use as much as possible code in imx-common, avoiding to
duplicate code.

Best regards,
Stefano
diff mbox

Patch

diff --git a/arch/arm/cpu/armv7/mx6/soc.c b/arch/arm/cpu/armv7/mx6/soc.c
index 7380ffe..5fce682 100644
--- a/arch/arm/cpu/armv7/mx6/soc.c
+++ b/arch/arm/cpu/armv7/mx6/soc.c
@@ -44,6 +44,32 @@  u32 get_cpu_rev(void)
 	return system_rev;
 }
 
+struct scu_regs {
+	uint32_t	ctrl;
+	uint32_t	config;
+	uint32_t	status;
+	uint32_t	invalidate;
+	uint32_t	fpga_rev;
+};
+
+signed char cpu_type[] = {MXC_CPU_MX6SOLO, MXC_CPU_MX6DL, -1, MXC_CPU_MX6Q};
+
+int get_cpu_type(void)
+{
+	struct scu_regs *scu = (struct scu_regs *)SCU_BASE_ADDR;
+	uint32_t reg = readl(&scu->config) & 3;
+	int type = cpu_type[reg];
+
+	if (!reg) {
+		u32 cpu_type = readl(ANATOP_BASE_ADDR + 0x280);
+
+		cpu_type >>= 16;
+		if (cpu_type == 0x60)
+			type = MXC_CPU_MX6SL;       /* this is a soloLite */
+	}
+	return type;
+}
+
 void init_aips(void)
 {
 	struct aipstz_regs *aips1, *aips2;
diff --git a/arch/arm/include/asm/arch-mx6/sys_proto.h b/arch/arm/include/asm/arch-mx6/sys_proto.h
index 711b30d..997fc8e 100644
--- a/arch/arm/include/asm/arch-mx6/sys_proto.h
+++ b/arch/arm/include/asm/arch-mx6/sys_proto.h
@@ -28,6 +28,12 @@ 
 
 u32 get_cpu_rev(void);
 
+#define MXC_CPU_MX6SL		60
+#define MXC_CPU_MX6DL		61
+#define MXC_CPU_MX6SOLO		62
+#define MXC_CPU_MX6Q		63
+
+int get_cpu_type(void);
 void set_vddsoc(u32 mv);
 
 /*