diff mbox series

[U-Boot,V3,24/27] imx8m: soc: probe clock device in arch_cpu_init_dm

Message ID 20190827064033.28973-25-peng.fan@nxp.com
State Accepted
Commit e663c703b16b515ce0038f971c5d10d33884869b
Delegated to: Stefano Babic
Headers show
Series i.MX8MM support | expand

Commit Message

Peng Fan Aug. 27, 2019, 6:25 a.m. UTC
Because we need to get cpu freq in print_cpuinfo at very early stage,
so we need to make sure the ccm be probed.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 arch/arm/mach-imx/imx8m/soc.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

Comments

Frieder Schrempf Aug. 28, 2019, 3:20 p.m. UTC | #1
Hi Peng,

On 27.08.19 08:25, Peng Fan wrote:
> Because we need to get cpu freq in print_cpuinfo at very early stage,
> so we need to make sure the ccm be probed.
> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>   arch/arm/mach-imx/imx8m/soc.c | 17 +++++++++++++++++
>   1 file changed, 17 insertions(+)
> 
> diff --git a/arch/arm/mach-imx/imx8m/soc.c b/arch/arm/mach-imx/imx8m/soc.c
> index 3a54db4898..f904049120 100644
> --- a/arch/arm/mach-imx/imx8m/soc.c
> +++ b/arch/arm/mach-imx/imx8m/soc.c
> @@ -14,6 +14,7 @@
>   #include <asm/mach-imx/boot_mode.h>
>   #include <asm/mach-imx/syscounter.h>
>   #include <asm/armv8/mmu.h>
> +#include <dm/uclass.h>
>   #include <errno.h>
>   #include <fdt_support.h>
>   #include <fsl_wdog.h>
> @@ -228,6 +229,22 @@ static void imx_set_wdog_powerdown(bool enable)
>   	writew(enable, &wdog3->wmcr);
>   }
>   
> +int arch_cpu_init_dm(void)
> +{
> +	struct udevice *dev;
> +	int ret;
> +
> +	ret = uclass_get_device_by_name(UCLASS_CLK,
> +					"clock-controller@30380000",
> +					&dev);

I just upgraded my working tree to v2019.10-rc3 + your v3 MX8MM patches. 
This somehow breaks things for me. The U-Boot proper hangs when calling 
uclass_get_device_by_name(). Removing this call makes the boot work again.
Do you have any idea what could be wrong? Do I miss something?

Thanks,
Frieder

> +	if (ret < 0) {
> +		printf("Failed to find clock node. Check device tree\n");
> +		return ret;
> +	}
> +
> +	return 0;
> +}
> +
>   int arch_cpu_init(void)
>   {
>   	struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR;
>
Peng Fan Aug. 29, 2019, 1:21 a.m. UTC | #2
Hi Frieder,

> Subject: Re: [PATCH V3 24/27] imx8m: soc: probe clock device in
> arch_cpu_init_dm
> 
> Hi Peng,
> 
> On 27.08.19 08:25, Peng Fan wrote:
> > Because we need to get cpu freq in print_cpuinfo at very early stage,
> > so we need to make sure the ccm be probed.
> >
> > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > ---
> >   arch/arm/mach-imx/imx8m/soc.c | 17 +++++++++++++++++
> >   1 file changed, 17 insertions(+)
> >
> > diff --git a/arch/arm/mach-imx/imx8m/soc.c
> > b/arch/arm/mach-imx/imx8m/soc.c index 3a54db4898..f904049120
> 100644
> > --- a/arch/arm/mach-imx/imx8m/soc.c
> > +++ b/arch/arm/mach-imx/imx8m/soc.c
> > @@ -14,6 +14,7 @@
> >   #include <asm/mach-imx/boot_mode.h>
> >   #include <asm/mach-imx/syscounter.h>
> >   #include <asm/armv8/mmu.h>
> > +#include <dm/uclass.h>
> >   #include <errno.h>
> >   #include <fdt_support.h>
> >   #include <fsl_wdog.h>
> > @@ -228,6 +229,22 @@ static void imx_set_wdog_powerdown(bool
> enable)
> >   	writew(enable, &wdog3->wmcr);
> >   }
> >
> > +int arch_cpu_init_dm(void)
> > +{
> > +	struct udevice *dev;
> > +	int ret;
> > +
> > +	ret = uclass_get_device_by_name(UCLASS_CLK,
> > +					"clock-controller@30380000",
> > +					&dev);
> 
> I just upgraded my working tree to v2019.10-rc3 + your v3 MX8MM patches.
> This somehow breaks things for me. The U-Boot proper hangs when calling
> uclass_get_device_by_name(). Removing this call makes the boot work again.
> Do you have any idea what could be wrong? Do I miss something?

Please enlarge CONFIG_SYS_MALLOC_F_LEN to 0x10000 and have a try.

Regards,
Peng.

> 
> Thanks,
> Frieder
> 
> > +	if (ret < 0) {
> > +		printf("Failed to find clock node. Check device tree\n");
> > +		return ret;
> > +	}
> > +
> > +	return 0;
> > +}
> > +
> >   int arch_cpu_init(void)
> >   {
> >   	struct ocotp_regs *ocotp = (struct ocotp_regs
> *)OCOTP_BASE_ADDR;
> >
Frieder Schrempf Aug. 29, 2019, 5:47 a.m. UTC | #3
On 29.08.19 03:21, Peng Fan wrote:
> Hi Frieder,
> 
>> Subject: Re: [PATCH V3 24/27] imx8m: soc: probe clock device in
>> arch_cpu_init_dm
>>
>> Hi Peng,
>>
>> On 27.08.19 08:25, Peng Fan wrote:
>>> Because we need to get cpu freq in print_cpuinfo at very early stage,
>>> so we need to make sure the ccm be probed.
>>>
>>> Signed-off-by: Peng Fan <peng.fan@nxp.com>
>>> ---
>>>    arch/arm/mach-imx/imx8m/soc.c | 17 +++++++++++++++++
>>>    1 file changed, 17 insertions(+)
>>>
>>> diff --git a/arch/arm/mach-imx/imx8m/soc.c
>>> b/arch/arm/mach-imx/imx8m/soc.c index 3a54db4898..f904049120
>> 100644
>>> --- a/arch/arm/mach-imx/imx8m/soc.c
>>> +++ b/arch/arm/mach-imx/imx8m/soc.c
>>> @@ -14,6 +14,7 @@
>>>    #include <asm/mach-imx/boot_mode.h>
>>>    #include <asm/mach-imx/syscounter.h>
>>>    #include <asm/armv8/mmu.h>
>>> +#include <dm/uclass.h>
>>>    #include <errno.h>
>>>    #include <fdt_support.h>
>>>    #include <fsl_wdog.h>
>>> @@ -228,6 +229,22 @@ static void imx_set_wdog_powerdown(bool
>> enable)
>>>    	writew(enable, &wdog3->wmcr);
>>>    }
>>>
>>> +int arch_cpu_init_dm(void)
>>> +{
>>> +	struct udevice *dev;
>>> +	int ret;
>>> +
>>> +	ret = uclass_get_device_by_name(UCLASS_CLK,
>>> +					"clock-controller@30380000",
>>> +					&dev);
>>
>> I just upgraded my working tree to v2019.10-rc3 + your v3 MX8MM patches.
>> This somehow breaks things for me. The U-Boot proper hangs when calling
>> uclass_get_device_by_name(). Removing this call makes the boot work again.
>> Do you have any idea what could be wrong? Do I miss something?
> 
> Please enlarge CONFIG_SYS_MALLOC_F_LEN to 0x10000 and have a try.

That did the trick. Thanks a lot!

> 
> Regards,
> Peng.
> 
>>
>> Thanks,
>> Frieder
>>
>>> +	if (ret < 0) {
>>> +		printf("Failed to find clock node. Check device tree\n");
>>> +		return ret;
>>> +	}
>>> +
>>> +	return 0;
>>> +}
>>> +
>>>    int arch_cpu_init(void)
>>>    {
>>>    	struct ocotp_regs *ocotp = (struct ocotp_regs
>> *)OCOTP_BASE_ADDR;
>>>
Patrick Wildt Oct. 10, 2019, 10:35 p.m. UTC | #4
On Tue, Aug 27, 2019 at 06:25:58AM +0000, Peng Fan wrote:
> Because we need to get cpu freq in print_cpuinfo at very early stage,
> so we need to make sure the ccm be probed.
> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  arch/arm/mach-imx/imx8m/soc.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/arch/arm/mach-imx/imx8m/soc.c b/arch/arm/mach-imx/imx8m/soc.c
> index 3a54db4898..f904049120 100644
> --- a/arch/arm/mach-imx/imx8m/soc.c
> +++ b/arch/arm/mach-imx/imx8m/soc.c
> @@ -14,6 +14,7 @@
>  #include <asm/mach-imx/boot_mode.h>
>  #include <asm/mach-imx/syscounter.h>
>  #include <asm/armv8/mmu.h>
> +#include <dm/uclass.h>
>  #include <errno.h>
>  #include <fdt_support.h>
>  #include <fsl_wdog.h>
> @@ -228,6 +229,22 @@ static void imx_set_wdog_powerdown(bool enable)
>  	writew(enable, &wdog3->wmcr);
>  }
>  
> +int arch_cpu_init_dm(void)
> +{
> +	struct udevice *dev;
> +	int ret;
> +
> +	ret = uclass_get_device_by_name(UCLASS_CLK,
> +					"clock-controller@30380000",
> +					&dev);
> +	if (ret < 0) {
> +		printf("Failed to find clock node. Check device tree\n");
> +		return ret;
> +	}
> +
> +	return 0;
> +}
> +
>  int arch_cpu_init(void)
>  {
>  	struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR;
> -- 
> 2.16.4
> 
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot

This commit broke my i.MX8MQ board.  This is because the i.MX8MQ does
not yet have a DM-based clock driver like i.MX8MM, so requiring the
existence of such uclass device breaks i.MX8MQ.  I would propse the
following commit, which make the whole function only available for
i.MX8MQ.

---

From 644bf63ed0b33c499631be757de077f2059144e7 Mon Sep 17 00:00:00 2001
From: Patrick Wildt <patrick@blueri.se>
Date: Fri, 11 Oct 2019 00:28:38 +0200
Subject: [PATCH] imx: require CCM driver only on i.MX8MM

Since there is no clock driver like that for i.MX8MQ, we cannot
require it on that platform, so make sure it is only built for
i.MX8MM.

Signed-off-by: Patrick Wildt <patrick@blueri.se>
---
 arch/arm/mach-imx/imx8m/soc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/mach-imx/imx8m/soc.c b/arch/arm/mach-imx/imx8m/soc.c
index aeca82cdbf..11ca8c86b3 100644
--- a/arch/arm/mach-imx/imx8m/soc.c
+++ b/arch/arm/mach-imx/imx8m/soc.c
@@ -229,6 +229,7 @@ static void imx_set_wdog_powerdown(bool enable)
 	writew(enable, &wdog3->wmcr);
 }
 
+#ifdef CONFIG_ARCH_IMX8MM
 int arch_cpu_init_dm(void)
 {
 	struct udevice *dev;
@@ -244,6 +245,7 @@ int arch_cpu_init_dm(void)
 
 	return 0;
 }
+#endif
 
 int arch_cpu_init(void)
 {
diff mbox series

Patch

diff --git a/arch/arm/mach-imx/imx8m/soc.c b/arch/arm/mach-imx/imx8m/soc.c
index 3a54db4898..f904049120 100644
--- a/arch/arm/mach-imx/imx8m/soc.c
+++ b/arch/arm/mach-imx/imx8m/soc.c
@@ -14,6 +14,7 @@ 
 #include <asm/mach-imx/boot_mode.h>
 #include <asm/mach-imx/syscounter.h>
 #include <asm/armv8/mmu.h>
+#include <dm/uclass.h>
 #include <errno.h>
 #include <fdt_support.h>
 #include <fsl_wdog.h>
@@ -228,6 +229,22 @@  static void imx_set_wdog_powerdown(bool enable)
 	writew(enable, &wdog3->wmcr);
 }
 
+int arch_cpu_init_dm(void)
+{
+	struct udevice *dev;
+	int ret;
+
+	ret = uclass_get_device_by_name(UCLASS_CLK,
+					"clock-controller@30380000",
+					&dev);
+	if (ret < 0) {
+		printf("Failed to find clock node. Check device tree\n");
+		return ret;
+	}
+
+	return 0;
+}
+
 int arch_cpu_init(void)
 {
 	struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR;