public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mips: pistachio: Determine SoC revision during boot
@ 2016-04-18 14:24 James Hartley
  2016-04-18 16:59 ` Sergei Shtylyov
  0 siblings, 1 reply; 3+ messages in thread
From: James Hartley @ 2016-04-18 14:24 UTC (permalink / raw)
  To: Ralf Baechle, Andrew Bresticker, Jonas Gorski, James Hogan
  Cc: linux-mips, linux-kernel, Ionela Voinescu, James Hartley

Now that there are different revisions of the Pistachio SoC
in circulation, add this information to the boot log to make
it easier for users to determine which hardware they have.

Signed-off-by: James Hartley <james.hartley@imgtec.com>
Signed-off-by: Ionela Voinescu <ionela.voinescu@imgtec.com>

diff --git a/arch/mips/pistachio/init.c b/arch/mips/pistachio/init.c
index 96ba2cc..48f8755 100644
--- a/arch/mips/pistachio/init.c
+++ b/arch/mips/pistachio/init.c
@@ -2,6 +2,7 @@
  * Pistachio platform setup
  *
  * Copyright (C) 2014 Google, Inc.
+ * Copyright (C) 2016 Imagination Technologies
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
@@ -9,6 +10,7 @@
  */
 
 #include <linux/init.h>
+#include <linux/io.h>
 #include <linux/kernel.h>
 #include <linux/of_address.h>
 #include <linux/of_fdt.h>
@@ -24,9 +26,28 @@
 #include <asm/smp-ops.h>
 #include <asm/traps.h>
 
+/*
+ * Core revision register decoding
+ * Bits 23 to 20: Major rev
+ * Bits 15 to 8: Minor rev
+ * Bits 7 to 0: Maintenance rev
+ */
+#define PISTACHIO_CORE_REV_REG	0xB81483D0
+#define PISTACHIO_CORE_REV_A1	0x00100006
+#define PISTACHIO_CORE_REV_B0	0x00100106
+
 const char *get_system_type(void)
 {
-	return "IMG Pistachio SoC";
+	u32 core_rev;
+
+	core_rev = __raw_readl((const void *)PISTACHIO_CORE_REV_REG);
+
+	if (core_rev == PISTACHIO_CORE_REV_B0)
+		return "IMG Pistachio SoC (B0)";
+	else if (core_rev == PISTACHIO_CORE_REV_A1)
+		return "IMG_Pistachio SoC (A1)";
+	else
+		return "IMG_Pistachio SoC";
 }
 
 static void __init plat_setup_iocoherency(void)
@@ -109,6 +130,8 @@ void __init prom_init(void)
 	mips_cm_probe();
 	mips_cpc_probe();
 	register_cps_smp_ops();
+
+	pr_info("SoC Type: %s\n", get_system_type());
 }
 
 void __init prom_free_prom_memory(void)
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mips: pistachio: Determine SoC revision during boot
  2016-04-18 14:24 [PATCH] mips: pistachio: Determine SoC revision during boot James Hartley
@ 2016-04-18 16:59 ` Sergei Shtylyov
  2016-04-19 10:27   ` James Hartley
  0 siblings, 1 reply; 3+ messages in thread
From: Sergei Shtylyov @ 2016-04-18 16:59 UTC (permalink / raw)
  To: James Hartley, Ralf Baechle, Andrew Bresticker, Jonas Gorski,
	James Hogan
  Cc: linux-mips, linux-kernel, Ionela Voinescu

Hello.

On 04/18/2016 05:24 PM, James Hartley wrote:

> Now that there are different revisions of the Pistachio SoC
> in circulation, add this information to the boot log to make
> it easier for users to determine which hardware they have.
>
> Signed-off-by: James Hartley <james.hartley@imgtec.com>
> Signed-off-by: Ionela Voinescu <ionela.voinescu@imgtec.com>
>
> diff --git a/arch/mips/pistachio/init.c b/arch/mips/pistachio/init.c
> index 96ba2cc..48f8755 100644
> --- a/arch/mips/pistachio/init.c
> +++ b/arch/mips/pistachio/init.c
[...]
> @@ -24,9 +26,28 @@
>   #include <asm/smp-ops.h>
>   #include <asm/traps.h>
>
> +/*
> + * Core revision register decoding
> + * Bits 23 to 20: Major rev
> + * Bits 15 to 8: Minor rev
> + * Bits 7 to 0: Maintenance rev
> + */
> +#define PISTACHIO_CORE_REV_REG	0xB81483D0
> +#define PISTACHIO_CORE_REV_A1	0x00100006
> +#define PISTACHIO_CORE_REV_B0	0x00100106
> +
>   const char *get_system_type(void)
>   {
> -	return "IMG Pistachio SoC";
> +	u32 core_rev;
> +
> +	core_rev = __raw_readl((const void *)PISTACHIO_CORE_REV_REG);
> +
> +	if (core_rev == PISTACHIO_CORE_REV_B0)
> +		return "IMG Pistachio SoC (B0)";
> +	else if (core_rev == PISTACHIO_CORE_REV_A1)
> +		return "IMG_Pistachio SoC (A1)";
> +	else
> +		return "IMG_Pistachio SoC";

    How about the *switch* instead?

[...]

MBR, Sergei

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mips: pistachio: Determine SoC revision during boot
  2016-04-18 16:59 ` Sergei Shtylyov
@ 2016-04-19 10:27   ` James Hartley
  0 siblings, 0 replies; 3+ messages in thread
From: James Hartley @ 2016-04-19 10:27 UTC (permalink / raw)
  To: Sergei Shtylyov, Ralf Baechle, Andrew Bresticker, Jonas Gorski,
	James Hogan
  Cc: linux-mips, linux-kernel, Ionela Voinescu

Hi Sergei

On 18/04/16 17:59, Sergei Shtylyov wrote:
> Hello.
>
> On 04/18/2016 05:24 PM, James Hartley wrote:
>
>> Now that there are different revisions of the Pistachio SoC
>> in circulation, add this information to the boot log to make
>> it easier for users to determine which hardware they have.
>>
>> Signed-off-by: James Hartley <james.hartley@imgtec.com>
>> Signed-off-by: Ionela Voinescu <ionela.voinescu@imgtec.com>
>>
>> diff --git a/arch/mips/pistachio/init.c b/arch/mips/pistachio/init.c
>> index 96ba2cc..48f8755 100644
>> --- a/arch/mips/pistachio/init.c
>> +++ b/arch/mips/pistachio/init.c
> [...]
>> @@ -24,9 +26,28 @@
>>   #include <asm/smp-ops.h>
>>   #include <asm/traps.h>
>>
>> +/*
>> + * Core revision register decoding
>> + * Bits 23 to 20: Major rev
>> + * Bits 15 to 8: Minor rev
>> + * Bits 7 to 0: Maintenance rev
>> + */
>> +#define PISTACHIO_CORE_REV_REG    0xB81483D0
>> +#define PISTACHIO_CORE_REV_A1    0x00100006
>> +#define PISTACHIO_CORE_REV_B0    0x00100106
>> +
>>   const char *get_system_type(void)
>>   {
>> -    return "IMG Pistachio SoC";
>> +    u32 core_rev;
>> +
>> +    core_rev = __raw_readl((const void *)PISTACHIO_CORE_REV_REG);
>> +
>> +    if (core_rev == PISTACHIO_CORE_REV_B0)
>> +        return "IMG Pistachio SoC (B0)";
>> +    else if (core_rev == PISTACHIO_CORE_REV_A1)
>> +        return "IMG_Pistachio SoC (A1)";
>> +    else
>> +        return "IMG_Pistachio SoC";
>
>    How about the *switch* instead?
Yes, that would be slightly more readable - I'll do that in V2.

Thanks for the review! 

James.
>
> [...]
>
> MBR, Sergei
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-04-19 10:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-18 14:24 [PATCH] mips: pistachio: Determine SoC revision during boot James Hartley
2016-04-18 16:59 ` Sergei Shtylyov
2016-04-19 10:27   ` James Hartley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox