diff mbox series

[U-Boot,V3,1/3] imx6: Define 'soc' env var for imx6 SoC

Message ID 20180411103850.13539-2-guillaume.gardet@free.fr
State Superseded
Delegated to: Stefano Babic
Headers show
Series Update sabrelite and nitrogen6x boards to use distro boot support | expand

Commit Message

Guillaume GARDET April 11, 2018, 10:38 a.m. UTC
Signed-off-by: Guillaume GARDET <guillaume.gardet@free.fr>
Cc: Troy Kisky <troy.kisky@boundarydevices.com>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
Cc: Gary Bisson <gary.bisson@boundarydevices.com>

---
 arch/arm/mach-imx/mx6/soc.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

Comments

Fabio Estevam April 11, 2018, 2:23 p.m. UTC | #1
Hi Guillaume,

On Wed, Apr 11, 2018 at 7:38 AM, Guillaume GARDET
<guillaume.gardet@free.fr> wrote:

Please explain in the commit log why this is needed. Thanks

> Signed-off-by: Guillaume GARDET <guillaume.gardet@free.fr>
> Cc: Troy Kisky <troy.kisky@boundarydevices.com>
> Cc: Stefano Babic <sbabic@denx.de>
> Cc: Fabio Estevam <fabio.estevam@nxp.com>
> Cc: Gary Bisson <gary.bisson@boundarydevices.com>
Guillaume GARDET April 11, 2018, 2:41 p.m. UTC | #2
Hi,


Le 11/04/2018 à 16:23, Fabio Estevam a écrit :
> Hi Guillaume,
>
> On Wed, Apr 11, 2018 at 7:38 AM, Guillaume GARDET
> <guillaume.gardet@free.fr> wrote:
>
> Please explain in the commit log why this is needed. Thanks

This is for efi fdtfile fallback definition for default distro config for nitrogen6x board.
Is it ok for you?

>
>> Signed-off-by: Guillaume GARDET <guillaume.gardet@free.fr>
>> Cc: Troy Kisky <troy.kisky@boundarydevices.com>
>> Cc: Stefano Babic <sbabic@denx.de>
>> Cc: Fabio Estevam <fabio.estevam@nxp.com>
>> Cc: Gary Bisson <gary.bisson@boundarydevices.com>
Fabio Estevam April 11, 2018, 3:41 p.m. UTC | #3
On Wed, Apr 11, 2018 at 11:41 AM, Guillaume Gardet
<guillaume.gardet@free.fr> wrote:

> This is for efi fdtfile fallback definition for default distro config for
> nitrogen6x board.
> Is it ok for you?

Yes, this is the explanation that I was looking for :-)

Please send a new version with this info added in the commit log.

Thanks
Gary Bisson April 11, 2018, 3:46 p.m. UTC | #4
Hi Guillaume,

On Wed, Apr 11, 2018 at 12:38:48PM +0200, Guillaume GARDET wrote:
> Signed-off-by: Guillaume GARDET <guillaume.gardet@free.fr>
> Cc: Troy Kisky <troy.kisky@boundarydevices.com>
> Cc: Stefano Babic <sbabic@denx.de>
> Cc: Fabio Estevam <fabio.estevam@nxp.com>
> Cc: Gary Bisson <gary.bisson@boundarydevices.com>
> 
> ---
>  arch/arm/mach-imx/mx6/soc.c | 34 ++++++++++++++++++++++++++++++++++
>  1 file changed, 34 insertions(+)
> 
> diff --git a/arch/arm/mach-imx/mx6/soc.c b/arch/arm/mach-imx/mx6/soc.c
> index 9b3d8f69b2..c4cb752c76 100644
> --- a/arch/arm/mach-imx/mx6/soc.c
> +++ b/arch/arm/mach-imx/mx6/soc.c
> @@ -446,6 +446,40 @@ int arch_cpu_init(void)
>  	return 0;
>  }
>  
> + #ifdef CONFIG_ARCH_MISC_INIT
> + int arch_misc_init(void)
> + {
> + #ifdef CONFIG_ENV_VARS_UBOOT_CONFIG
> +	if (is_cpu_type(MXC_CPU_MX6QP))
> +		env_set("soc", "imx6qp");
> +	else if (is_cpu_type(MXC_CPU_MX6Q))
> +		env_set("soc", "imx6q");
> +	else if (is_cpu_type(MXC_CPU_MX6DP))
> +		env_set("soc", "imx6dp");

If we want that soc variable to be used for dtb names, then the above
won't work. A i.MX6DP platform has its dtb named imx6qp-board.dtb.

> +	else if (is_cpu_type(MXC_CPU_MX6D))
> +		env_set("soc", "imx6d");

Same here, a Dual CPU actually uses a imx6q-board.dtb.

> +	else if (is_mx6dl( ))
> +		env_set("soc", "imx6dl");
> +	else if (is_mx6sx( ))
> +		env_set("soc", "imx6sx");
> +	else if (is_mx6sl( ))
> +		env_set("soc", "imx6sl");
> +	else if (is_mx6solo( ))
> +		env_set("soc", "imx6solo");

Same here, a Solo CPU uses a imx6dl-board.dtb.

> +	else if (is_mx6ul( ))
> +		env_set("soc", "imx6ul");
> +	else if (is_mx6ull( ))
> +		env_set("soc", "imx6ull");
> +	else if (is_mx6sll( ))
> +		env_set("soc", "imx6sll");
> +	else
> +		env_set("soc", "imx6");

In that case we most likely miss a CPU definition, maybe "unknown" would
be more explicit?

Regards,
Gary
Guillaume GARDET April 11, 2018, 3:52 p.m. UTC | #5
Le 11/04/2018 à 17:46, Gary Bisson a écrit :
> Hi Guillaume,
>
> On Wed, Apr 11, 2018 at 12:38:48PM +0200, Guillaume GARDET wrote:
>> Signed-off-by: Guillaume GARDET <guillaume.gardet@free.fr>
>> Cc: Troy Kisky <troy.kisky@boundarydevices.com>
>> Cc: Stefano Babic <sbabic@denx.de>
>> Cc: Fabio Estevam <fabio.estevam@nxp.com>
>> Cc: Gary Bisson <gary.bisson@boundarydevices.com>
>>
>> ---
>>   arch/arm/mach-imx/mx6/soc.c | 34 ++++++++++++++++++++++++++++++++++
>>   1 file changed, 34 insertions(+)
>>
>> diff --git a/arch/arm/mach-imx/mx6/soc.c b/arch/arm/mach-imx/mx6/soc.c
>> index 9b3d8f69b2..c4cb752c76 100644
>> --- a/arch/arm/mach-imx/mx6/soc.c
>> +++ b/arch/arm/mach-imx/mx6/soc.c
>> @@ -446,6 +446,40 @@ int arch_cpu_init(void)
>>   	return 0;
>>   }
>>   
>> + #ifdef CONFIG_ARCH_MISC_INIT
>> + int arch_misc_init(void)
>> + {
>> + #ifdef CONFIG_ENV_VARS_UBOOT_CONFIG
>> +	if (is_cpu_type(MXC_CPU_MX6QP))
>> +		env_set("soc", "imx6qp");
>> +	else if (is_cpu_type(MXC_CPU_MX6Q))
>> +		env_set("soc", "imx6q");
>> +	else if (is_cpu_type(MXC_CPU_MX6DP))
>> +		env_set("soc", "imx6dp");
> If we want that soc variable to be used for dtb names, then the above
> won't work. A i.MX6DP platform has its dtb named imx6qp-board.dtb.
>
>> +	else if (is_cpu_type(MXC_CPU_MX6D))
>> +		env_set("soc", "imx6d");
> Same here, a Dual CPU actually uses a imx6q-board.dtb.
>
>> +	else if (is_mx6dl( ))
>> +		env_set("soc", "imx6dl");
>> +	else if (is_mx6sx( ))
>> +		env_set("soc", "imx6sx");
>> +	else if (is_mx6sl( ))
>> +		env_set("soc", "imx6sl");
>> +	else if (is_mx6solo( ))
>> +		env_set("soc", "imx6solo");
> Same here, a Solo CPU uses a imx6dl-board.dtb.

So, how to handle dtb filenames? Update with wrong soc definition ? Or drop this patch and define a FDTFILE for each flavor?

>
>> +	else if (is_mx6ul( ))
>> +		env_set("soc", "imx6ul");
>> +	else if (is_mx6ull( ))
>> +		env_set("soc", "imx6ull");
>> +	else if (is_mx6sll( ))
>> +		env_set("soc", "imx6sll");
>> +	else
>> +		env_set("soc", "imx6");
> In that case we most likely miss a CPU definition, maybe "unknown" would
> be more explicit?

Currently soc is defined to imx6, so I think it is a good idea to keep imx6 definition.

Guillaume


>
> Regards,
> Gary
>
Fabio Estevam April 11, 2018, 4:06 p.m. UTC | #6
On Wed, Apr 11, 2018 at 12:52 PM, Guillaume Gardet
<guillaume.gardet@free.fr> wrote:

> So, how to handle dtb filenames? Update with wrong soc definition ? Or drop
> this patch and define a FDTFILE for each flavor?

You can take a look at how we handle this for wandboard, cuboxi,
sabresd, for example.

Taking mx6sabresd as an example you can look at board_late_init() in
board/freescale/mx6sabresd/mx6sabresd.c

Then inside  include/configs/mx6sabre_common.h check for the findfdt
script that picks the correct dtb.
Guillaume GARDET April 12, 2018, 8:13 a.m. UTC | #7
Le 11/04/2018 à 18:06, Fabio Estevam a écrit :
> On Wed, Apr 11, 2018 at 12:52 PM, Guillaume Gardet
> <guillaume.gardet@free.fr> wrote:
>
>> So, how to handle dtb filenames? Update with wrong soc definition ? Or drop
>> this patch and define a FDTFILE for each flavor?
> You can take a look at how we handle this for wandboard, cuboxi,
> sabresd, for example.
>
> Taking mx6sabresd as an example you can look at board_late_init() in
> board/freescale/mx6sabresd/mx6sabresd.c
>
> Then inside  include/configs/mx6sabre_common.h check for the findfdt
> script that picks the correct dtb.
>
Ok. So, how would you like to proceed?
Remove the generic mx6 'soc' definition and use a board sepcific 'board_rev' (or maybe a static definition if one configuration match a single dtb) to define the right dtb?

Could you tell me which DTB should work with the various nitrogen6x boards config?

Here are the one I could get from upstream kernel dts folder and possible config match:
* imx6q-nitrogen6x.dts     =>     nitrogen6q2g_defconfig nitrogen6q_defconfig
* imx6q-nitrogen6_max.dts     =>     none?
* imx6q-nitrogen6_som2.dts     =>     none?
* imx6qp-nitrogen6_max.dts     =>     none?
* imx6qp-nitrogen6_som2.dts     =>     none?
* imx6dl-nitrogen6x.dts     =>     nitrogen6dl2g_defconfig nitrogen6dl_defconfig
* imx6sx-nitrogen6sx.dts     =>     nitrogen6s1g_defconfig nitrogen6s_defconfig
* imx6q-sabrelite.dts     =>     mx6qsabrelite_defconfig
* imx6dl-sabrelite.dts     =>     none?


Guillaume
Fabio Estevam April 12, 2018, 11:14 a.m. UTC | #8
On Thu, Apr 12, 2018 at 5:13 AM, Guillaume Gardet
<guillaume.gardet@free.fr> wrote:
script that picks the correct dtb.
>>
> Ok. So, how would you like to proceed?
> Remove the generic mx6 'soc' definition and use a board sepcific 'board_rev'
> (or maybe a static definition if one configuration match a single dtb) to
> define the right dtb?

I prefer to keep the same solution as done in other boards sucn as
mx6sabresd, wandboard and cuboxi.

> Could you tell me which DTB should work with the various nitrogen6x boards
> config?

I will let Gary confirm this one, as I am not familiar with the board
variants from Boundary Devices.
Gary Bisson April 12, 2018, 12:36 p.m. UTC | #9
Hi Fabio, Guillaume

On Thu, Apr 12, 2018 at 08:14:51AM -0300, Fabio Estevam wrote:
> On Thu, Apr 12, 2018 at 5:13 AM, Guillaume Gardet
> <guillaume.gardet@free.fr> wrote:
> script that picks the correct dtb.
> >>
> > Ok. So, how would you like to proceed?
> > Remove the generic mx6 'soc' definition and use a board sepcific 'board_rev'
> > (or maybe a static definition if one configuration match a single dtb) to
> > define the right dtb?
> 
> I prefer to keep the same solution as done in other boards sucn as
> mx6sabresd, wandboard and cuboxi.

Ok. My suggestion was to have something generic so that it matches the
fdt name set in config_distro_bootcmd.h
(${soc}-${board}${boardver}.dtb).

I especially like the naming in that standard, don't think board_rev
should be the SOC name.

This would also avoid redundancy in each board_late_init functions since
only the board name would need to be setup (and boardver in some cases
like wandboard).

Guillaume, please forget that point for now and just set your fdtfile
name in the config file. I'll update the board file later on.

Regards,
Gary
Guillaume GARDET April 12, 2018, 12:48 p.m. UTC | #10
Le 12/04/2018 à 14:36, Gary Bisson a écrit :
> Hi Fabio, Guillaume
>
> On Thu, Apr 12, 2018 at 08:14:51AM -0300, Fabio Estevam wrote:
>> On Thu, Apr 12, 2018 at 5:13 AM, Guillaume Gardet
>> <guillaume.gardet@free.fr> wrote:
>> script that picks the correct dtb.
>>> Ok. So, how would you like to proceed?
>>> Remove the generic mx6 'soc' definition and use a board sepcific 'board_rev'
>>> (or maybe a static definition if one configuration match a single dtb) to
>>> define the right dtb?
>> I prefer to keep the same solution as done in other boards sucn as
>> mx6sabresd, wandboard and cuboxi.
> Ok. My suggestion was to have something generic so that it matches the
> fdt name set in config_distro_bootcmd.h
> (${soc}-${board}${boardver}.dtb).
>
> I especially like the naming in that standard, don't think board_rev
> should be the SOC name.
>
> This would also avoid redundancy in each board_late_init functions since
> only the board name would need to be setup (and boardver in some cases
> like wandboard).
>
> Guillaume, please forget that point for now and just set your fdtfile
> name in the config file. I'll update the board file later on.

Ok.

Could you just confirm which DTB should work with the various nitrogen6x boards config, please?
Are the following ok?
* imx6q-nitrogen6x.dts     =>     nitrogen6q2g_defconfig nitrogen6q_defconfig
* imx6dl-nitrogen6x.dts     =>     nitrogen6dl2g_defconfig nitrogen6dl_defconfig
* imx6sx-nitrogen6sx.dts     =>     nitrogen6s1g_defconfig nitrogen6s_defconfig
* imx6q-sabrelite.dts     =>     mx6qsabrelite_defconfig

Guillaume
Gary Bisson April 12, 2018, 12:58 p.m. UTC | #11
Hi Guillaume,

On Thu, Apr 12, 2018 at 02:48:07PM +0200, Guillaume Gardet wrote:
> 
> 
> Le 12/04/2018 à 14:36, Gary Bisson a écrit :
> > Hi Fabio, Guillaume
> > 
> > On Thu, Apr 12, 2018 at 08:14:51AM -0300, Fabio Estevam wrote:
> > > On Thu, Apr 12, 2018 at 5:13 AM, Guillaume Gardet
> > > <guillaume.gardet@free.fr> wrote:
> > > script that picks the correct dtb.
> > > > Ok. So, how would you like to proceed?
> > > > Remove the generic mx6 'soc' definition and use a board sepcific 'board_rev'
> > > > (or maybe a static definition if one configuration match a single dtb) to
> > > > define the right dtb?
> > > I prefer to keep the same solution as done in other boards sucn as
> > > mx6sabresd, wandboard and cuboxi.
> > Ok. My suggestion was to have something generic so that it matches the
> > fdt name set in config_distro_bootcmd.h
> > (${soc}-${board}${boardver}.dtb).
> > 
> > I especially like the naming in that standard, don't think board_rev
> > should be the SOC name.
> > 
> > This would also avoid redundancy in each board_late_init functions since
> > only the board name would need to be setup (and boardver in some cases
> > like wandboard).
> > 
> > Guillaume, please forget that point for now and just set your fdtfile
> > name in the config file. I'll update the board file later on.
> 
> Ok.
> 
> Could you just confirm which DTB should work with the various nitrogen6x boards config, please?
> Are the following ok?
> * imx6q-nitrogen6x.dts     =>     nitrogen6q2g_defconfig nitrogen6q_defconfig
> * imx6dl-nitrogen6x.dts     =>     nitrogen6dl2g_defconfig nitrogen6dl_defconfig
> * imx6sx-nitrogen6sx.dts     =>     nitrogen6s1g_defconfig nitrogen6s_defconfig

No, imx6sx is different than imx6s. Solo is the same as imx6dl as far as
the kernl is concerned.

Maybe just leave fdt_file blank for nitrogen6x for now, it's only necessary
for PXE which isn't enabled in nitrogen6*defconfig.

Regards,
Gary
Guillaume GARDET April 12, 2018, 1:07 p.m. UTC | #12
Le 12/04/2018 à 14:58, Gary Bisson a écrit :
> Hi Guillaume,
>
> On Thu, Apr 12, 2018 at 02:48:07PM +0200, Guillaume Gardet wrote:
>>
>> Le 12/04/2018 à 14:36, Gary Bisson a écrit :
>>> Hi Fabio, Guillaume
>>>
>>> On Thu, Apr 12, 2018 at 08:14:51AM -0300, Fabio Estevam wrote:
>>>> On Thu, Apr 12, 2018 at 5:13 AM, Guillaume Gardet
>>>> <guillaume.gardet@free.fr> wrote:
>>>> script that picks the correct dtb.
>>>>> Ok. So, how would you like to proceed?
>>>>> Remove the generic mx6 'soc' definition and use a board sepcific 'board_rev'
>>>>> (or maybe a static definition if one configuration match a single dtb) to
>>>>> define the right dtb?
>>>> I prefer to keep the same solution as done in other boards sucn as
>>>> mx6sabresd, wandboard and cuboxi.
>>> Ok. My suggestion was to have something generic so that it matches the
>>> fdt name set in config_distro_bootcmd.h
>>> (${soc}-${board}${boardver}.dtb).
>>>
>>> I especially like the naming in that standard, don't think board_rev
>>> should be the SOC name.
>>>
>>> This would also avoid redundancy in each board_late_init functions since
>>> only the board name would need to be setup (and boardver in some cases
>>> like wandboard).
>>>
>>> Guillaume, please forget that point for now and just set your fdtfile
>>> name in the config file. I'll update the board file later on.
>> Ok.
>>
>> Could you just confirm which DTB should work with the various nitrogen6x boards config, please?
>> Are the following ok?
>> * imx6q-nitrogen6x.dts     =>     nitrogen6q2g_defconfig nitrogen6q_defconfig
>> * imx6dl-nitrogen6x.dts     =>     nitrogen6dl2g_defconfig nitrogen6dl_defconfig
>> * imx6sx-nitrogen6sx.dts     =>     nitrogen6s1g_defconfig nitrogen6s_defconfig
> No, imx6sx is different than imx6s. Solo is the same as imx6dl as far as
> the kernl is concerned.
>
> Maybe just leave fdt_file blank for nitrogen6x for now, it's only necessary
> for PXE which isn't enabled in nitrogen6*defconfig.

Ok, I will leave it as is for now, but fdtfile must also be defined for EFI boot. Otherwise, you start your EFI payload without device tree.


Guillaume


>
> Regards,
> Gary
>
diff mbox series

Patch

diff --git a/arch/arm/mach-imx/mx6/soc.c b/arch/arm/mach-imx/mx6/soc.c
index 9b3d8f69b2..c4cb752c76 100644
--- a/arch/arm/mach-imx/mx6/soc.c
+++ b/arch/arm/mach-imx/mx6/soc.c
@@ -446,6 +446,40 @@  int arch_cpu_init(void)
 	return 0;
 }
 
+ #ifdef CONFIG_ARCH_MISC_INIT
+ int arch_misc_init(void)
+ {
+ #ifdef CONFIG_ENV_VARS_UBOOT_CONFIG
+	if (is_cpu_type(MXC_CPU_MX6QP))
+		env_set("soc", "imx6qp");
+	else if (is_cpu_type(MXC_CPU_MX6Q))
+		env_set("soc", "imx6q");
+	else if (is_cpu_type(MXC_CPU_MX6DP))
+		env_set("soc", "imx6dp");
+	else if (is_cpu_type(MXC_CPU_MX6D))
+		env_set("soc", "imx6d");
+	else if (is_mx6dl( ))
+		env_set("soc", "imx6dl");
+	else if (is_mx6sx( ))
+		env_set("soc", "imx6sx");
+	else if (is_mx6sl( ))
+		env_set("soc", "imx6sl");
+	else if (is_mx6solo( ))
+		env_set("soc", "imx6solo");
+	else if (is_mx6ul( ))
+		env_set("soc", "imx6ul");
+	else if (is_mx6ull( ))
+		env_set("soc", "imx6ull");
+	else if (is_mx6sll( ))
+		env_set("soc", "imx6sll");
+	else
+		env_set("soc", "imx6");
+ #endif
+
+	return 0;
+ }
+ #endif
+
 #ifdef CONFIG_ENV_IS_IN_MMC
 __weak int board_mmc_get_env_dev(int devno)
 {