Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] ARM: vf610: report soc info via soc device
@ 2020-03-26 17:42 Andrey Smirnov
  2020-03-27 17:04 ` Chris Healy
  2020-03-27 17:24 ` Fabio Estevam
  0 siblings, 2 replies; 3+ messages in thread
From: Andrey Smirnov @ 2020-03-26 17:42 UTC (permalink / raw)
  To: Shawn Guo
  Cc: Andrey Smirnov, linux-kernel, linux-imx, Chris Healy,
	linux-arm-kernel, Lucas Stach

The patch adds plumbing to soc device info code necessary to support
Vybrid devices. Use case in mind for this is CAAM driver, which
utilizes said API.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Chris Healy <cphealy@gmail.com>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-imx@nxp.com
---
 arch/arm/mach-imx/cpu.c        | 16 ++++++++++
 arch/arm/mach-imx/mach-vf610.c | 53 ++++++++++++++++++++++++++++++++++
 arch/arm/mach-imx/mxc.h        |  6 ++++
 3 files changed, 75 insertions(+)

diff --git a/arch/arm/mach-imx/cpu.c b/arch/arm/mach-imx/cpu.c
index 06f8d64b65af..e3d12b21d6f6 100644
--- a/arch/arm/mach-imx/cpu.c
+++ b/arch/arm/mach-imx/cpu.c
@@ -172,6 +172,22 @@ struct device * __init imx_soc_device_init(void)
 		ocotp_compat = "fsl,imx7ulp-ocotp";
 		soc_id = "i.MX7ULP";
 		break;
+	case MXC_CPU_VF500:
+		ocotp_compat = "fsl,vf610-ocotp";
+		soc_id = "VF500";
+		break;
+	case MXC_CPU_VF510:
+		ocotp_compat = "fsl,vf610-ocotp";
+		soc_id = "VF510";
+		break;
+	case MXC_CPU_VF600:
+		ocotp_compat = "fsl,vf610-ocotp";
+		soc_id = "VF600";
+		break;
+	case MXC_CPU_VF610:
+		ocotp_compat = "fsl,vf610-ocotp";
+		soc_id = "VF610";
+		break;
 	default:
 		soc_id = "Unknown";
 	}
diff --git a/arch/arm/mach-imx/mach-vf610.c b/arch/arm/mach-imx/mach-vf610.c
index 9c929b09310c..565dc08412a2 100644
--- a/arch/arm/mach-imx/mach-vf610.c
+++ b/arch/arm/mach-imx/mach-vf610.c
@@ -3,11 +3,63 @@
  * Copyright 2012-2013 Freescale Semiconductor, Inc.
  */

+#include <linux/of_address.h>
 #include <linux/of_platform.h>
+#include <linux/io.h>
+
 #include <linux/irqchip.h>
 #include <asm/mach/arch.h>
 #include <asm/hardware/cache-l2x0.h>

+#include "common.h"
+#include "hardware.h"
+
+#define MSCM_CPxCOUNT		0x00c
+#define MSCM_CPxCFG1		0x014
+
+static void __init vf610_detect_cpu(void)
+{
+	struct device_node *np;
+	u32 cpxcount, cpxcfg1;
+	unsigned int cpu_type;
+	void __iomem *mscm;
+
+	np = of_find_compatible_node(NULL, NULL, "fsl,vf610-mscm-cpucfg");
+	if (WARN_ON(!np))
+		return;
+
+	mscm = of_iomap(np, 0);
+	of_node_put(np);
+
+	if (WARN_ON(!mscm))
+		return;
+
+	cpxcount = readl_relaxed(mscm + MSCM_CPxCOUNT);
+	cpxcfg1  = readl_relaxed(mscm + MSCM_CPxCFG1);
+
+	iounmap(mscm);
+
+	cpu_type = cpxcount ? MXC_CPU_VF600 : MXC_CPU_VF500;
+
+	if (cpxcfg1)
+		cpu_type |= MXC_CPU_VFx10;
+
+	mxc_set_cpu_type(cpu_type);
+}
+
+static void __init vf610_init_machine(void)
+{
+	struct device *parent;
+
+	vf610_detect_cpu();
+
+	parent = imx_soc_device_init();
+	if (parent == NULL)
+		pr_warn("failed to initialize soc device\n");
+
+	of_platform_default_populate(NULL, NULL, parent);
+}
+
 static const char * const vf610_dt_compat[] __initconst = {
 	"fsl,vf500",
 	"fsl,vf510",
@@ -20,5 +72,6 @@ static const char * const vf610_dt_compat[] __initconst = {
 DT_MACHINE_START(VYBRID_VF610, "Freescale Vybrid VF5xx/VF6xx (Device Tree)")
 	.l2c_aux_val	= 0,
 	.l2c_aux_mask	= ~0,
+	.init_machine   = vf610_init_machine,
 	.dt_compat	= vf610_dt_compat,
 MACHINE_END
diff --git a/arch/arm/mach-imx/mxc.h b/arch/arm/mach-imx/mxc.h
index 2bfd2d59b4a6..48e6d781f15b 100644
--- a/arch/arm/mach-imx/mxc.h
+++ b/arch/arm/mach-imx/mxc.h
@@ -33,6 +33,12 @@
 #define MXC_CPU_IMX7D		0x72
 #define MXC_CPU_IMX7ULP		0xff

+#define MXC_CPU_VFx10		0x010
+#define MXC_CPU_VF500		0x500
+#define MXC_CPU_VF510		(MXC_CPU_VF500 | MXC_CPU_VFx10)
+#define MXC_CPU_VF600		0x600
+#define MXC_CPU_VF610		(MXC_CPU_VF600 | MXC_CPU_VFx10)
+
 #define IMX_DDR_TYPE_LPDDR2		1

 #ifndef __ASSEMBLY__
--
2.21.0

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] ARM: vf610: report soc info via soc device
  2020-03-26 17:42 [PATCH] ARM: vf610: report soc info via soc device Andrey Smirnov
@ 2020-03-27 17:04 ` Chris Healy
  2020-03-27 17:24 ` Fabio Estevam
  1 sibling, 0 replies; 3+ messages in thread
From: Chris Healy @ 2020-03-27 17:04 UTC (permalink / raw)
  To: Andrey Smirnov; +Cc: linux-imx, Shawn Guo, linux-kernel, linux ARM, Lucas Stach

On a VF610 Vybrid:

Tested-by: Chris Healy <cphealy@gmail.com>

On Thu, Mar 26, 2020 at 10:42 AM Andrey Smirnov
<andrew.smirnov@gmail.com> wrote:
>
> The patch adds plumbing to soc device info code necessary to support
> Vybrid devices. Use case in mind for this is CAAM driver, which
> utilizes said API.
>
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> Cc: Lucas Stach <l.stach@pengutronix.de>
> Cc: Chris Healy <cphealy@gmail.com>
> Cc: Shawn Guo <shawnguo@kernel.org>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-imx@nxp.com
> ---
>  arch/arm/mach-imx/cpu.c        | 16 ++++++++++
>  arch/arm/mach-imx/mach-vf610.c | 53 ++++++++++++++++++++++++++++++++++
>  arch/arm/mach-imx/mxc.h        |  6 ++++
>  3 files changed, 75 insertions(+)
>
> diff --git a/arch/arm/mach-imx/cpu.c b/arch/arm/mach-imx/cpu.c
> index 06f8d64b65af..e3d12b21d6f6 100644
> --- a/arch/arm/mach-imx/cpu.c
> +++ b/arch/arm/mach-imx/cpu.c
> @@ -172,6 +172,22 @@ struct device * __init imx_soc_device_init(void)
>                 ocotp_compat = "fsl,imx7ulp-ocotp";
>                 soc_id = "i.MX7ULP";
>                 break;
> +       case MXC_CPU_VF500:
> +               ocotp_compat = "fsl,vf610-ocotp";
> +               soc_id = "VF500";
> +               break;
> +       case MXC_CPU_VF510:
> +               ocotp_compat = "fsl,vf610-ocotp";
> +               soc_id = "VF510";
> +               break;
> +       case MXC_CPU_VF600:
> +               ocotp_compat = "fsl,vf610-ocotp";
> +               soc_id = "VF600";
> +               break;
> +       case MXC_CPU_VF610:
> +               ocotp_compat = "fsl,vf610-ocotp";
> +               soc_id = "VF610";
> +               break;
>         default:
>                 soc_id = "Unknown";
>         }
> diff --git a/arch/arm/mach-imx/mach-vf610.c b/arch/arm/mach-imx/mach-vf610.c
> index 9c929b09310c..565dc08412a2 100644
> --- a/arch/arm/mach-imx/mach-vf610.c
> +++ b/arch/arm/mach-imx/mach-vf610.c
> @@ -3,11 +3,63 @@
>   * Copyright 2012-2013 Freescale Semiconductor, Inc.
>   */
>
> +#include <linux/of_address.h>
>  #include <linux/of_platform.h>
> +#include <linux/io.h>
> +
>  #include <linux/irqchip.h>
>  #include <asm/mach/arch.h>
>  #include <asm/hardware/cache-l2x0.h>
>
> +#include "common.h"
> +#include "hardware.h"
> +
> +#define MSCM_CPxCOUNT          0x00c
> +#define MSCM_CPxCFG1           0x014
> +
> +static void __init vf610_detect_cpu(void)
> +{
> +       struct device_node *np;
> +       u32 cpxcount, cpxcfg1;
> +       unsigned int cpu_type;
> +       void __iomem *mscm;
> +
> +       np = of_find_compatible_node(NULL, NULL, "fsl,vf610-mscm-cpucfg");
> +       if (WARN_ON(!np))
> +               return;
> +
> +       mscm = of_iomap(np, 0);
> +       of_node_put(np);
> +
> +       if (WARN_ON(!mscm))
> +               return;
> +
> +       cpxcount = readl_relaxed(mscm + MSCM_CPxCOUNT);
> +       cpxcfg1  = readl_relaxed(mscm + MSCM_CPxCFG1);
> +
> +       iounmap(mscm);
> +
> +       cpu_type = cpxcount ? MXC_CPU_VF600 : MXC_CPU_VF500;
> +
> +       if (cpxcfg1)
> +               cpu_type |= MXC_CPU_VFx10;
> +
> +       mxc_set_cpu_type(cpu_type);
> +}
> +
> +static void __init vf610_init_machine(void)
> +{
> +       struct device *parent;
> +
> +       vf610_detect_cpu();
> +
> +       parent = imx_soc_device_init();
> +       if (parent == NULL)
> +               pr_warn("failed to initialize soc device\n");
> +
> +       of_platform_default_populate(NULL, NULL, parent);
> +}
> +
>  static const char * const vf610_dt_compat[] __initconst = {
>         "fsl,vf500",
>         "fsl,vf510",
> @@ -20,5 +72,6 @@ static const char * const vf610_dt_compat[] __initconst = {
>  DT_MACHINE_START(VYBRID_VF610, "Freescale Vybrid VF5xx/VF6xx (Device Tree)")
>         .l2c_aux_val    = 0,
>         .l2c_aux_mask   = ~0,
> +       .init_machine   = vf610_init_machine,
>         .dt_compat      = vf610_dt_compat,
>  MACHINE_END
> diff --git a/arch/arm/mach-imx/mxc.h b/arch/arm/mach-imx/mxc.h
> index 2bfd2d59b4a6..48e6d781f15b 100644
> --- a/arch/arm/mach-imx/mxc.h
> +++ b/arch/arm/mach-imx/mxc.h
> @@ -33,6 +33,12 @@
>  #define MXC_CPU_IMX7D          0x72
>  #define MXC_CPU_IMX7ULP                0xff
>
> +#define MXC_CPU_VFx10          0x010
> +#define MXC_CPU_VF500          0x500
> +#define MXC_CPU_VF510          (MXC_CPU_VF500 | MXC_CPU_VFx10)
> +#define MXC_CPU_VF600          0x600
> +#define MXC_CPU_VF610          (MXC_CPU_VF600 | MXC_CPU_VFx10)
> +
>  #define IMX_DDR_TYPE_LPDDR2            1
>
>  #ifndef __ASSEMBLY__
> --
> 2.21.0

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] ARM: vf610: report soc info via soc device
  2020-03-26 17:42 [PATCH] ARM: vf610: report soc info via soc device Andrey Smirnov
  2020-03-27 17:04 ` Chris Healy
@ 2020-03-27 17:24 ` Fabio Estevam
  1 sibling, 0 replies; 3+ messages in thread
From: Fabio Estevam @ 2020-03-27 17:24 UTC (permalink / raw)
  To: Andrey Smirnov
  Cc: linux-kernel, Chris Healy, NXP Linux Team, Shawn Guo,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
	Lucas Stach

Hi Andrey,

On Thu, Mar 26, 2020 at 2:42 PM Andrey Smirnov <andrew.smirnov@gmail.com> wrote:
>
> The patch adds plumbing to soc device info code necessary to support
> Vybrid devices. Use case in mind for this is CAAM driver, which
> utilizes said API.
>
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>

Reviewed-by: Fabio Estevam <festevam@gmail.com>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-26 17:42 [PATCH] ARM: vf610: report soc info via soc device Andrey Smirnov
2020-03-27 17:04 ` Chris Healy
2020-03-27 17:24 ` Fabio Estevam

Linux-ARM-Kernel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-arm-kernel/0 linux-arm-kernel/git/0.git
	git clone --mirror https://lore.kernel.org/linux-arm-kernel/1 linux-arm-kernel/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-arm-kernel linux-arm-kernel/ https://lore.kernel.org/linux-arm-kernel \
		linux-arm-kernel@lists.infradead.org
	public-inbox-index linux-arm-kernel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-arm-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git