diff mbox series

[U-Boot,08/10] ARM: mvebu: clearfog: run-time selection of DT file

Message ID a6587bc9749d31b079a226fae680fb178277d331.1574676560.git.baruch@tkos.co.il
State Superseded
Delegated to: Stefan Roese
Headers show
Series ARM: clearfog: add run-time board detect | expand

Commit Message

Baruch Siach Nov. 25, 2019, 10:30 a.m. UTC
Set the kernel device-tree file (fdtfile environment variable) based on
run-time detection of the platform.

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
 arch/arm/mach-mvebu/Kconfig        |  1 +
 board/solidrun/clearfog/clearfog.c | 14 ++++++++++++++
 2 files changed, 15 insertions(+)

Comments

Stefan Roese Jan. 13, 2020, 7:27 a.m. UTC | #1
On 25.11.19 11:30, Baruch Siach wrote:
> Set the kernel device-tree file (fdtfile environment variable) based on
> run-time detection of the platform.
> 
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> ---
>   arch/arm/mach-mvebu/Kconfig        |  1 +
>   board/solidrun/clearfog/clearfog.c | 14 ++++++++++++++
>   2 files changed, 15 insertions(+)
> 
> diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig
> index fdd39685b75d..bc5eaa5a7679 100644
> --- a/arch/arm/mach-mvebu/Kconfig
> +++ b/arch/arm/mach-mvebu/Kconfig
> @@ -91,6 +91,7 @@ choice
>   config TARGET_CLEARFOG
>   	bool "Support ClearFog"
>   	select 88F6820
> +	select BOARD_LATE_INIT
>   
>   config TARGET_HELIOS4
>   	bool "Support Helios4"
> diff --git a/board/solidrun/clearfog/clearfog.c b/board/solidrun/clearfog/clearfog.c
> index 852b1ad71bb2..00c1306e9c80 100644
> --- a/board/solidrun/clearfog/clearfog.c
> +++ b/board/solidrun/clearfog/clearfog.c
> @@ -265,3 +265,17 @@ int board_eth_init(bd_t *bis)
>   	cpu_eth_init(bis); /* Built in controller(s) come first */
>   	return pci_eth_init(bis);
>   }
> +
> +int board_late_init(void)
> +{
> +	read_tlv_data();
> +
> +	if (sr_product_is("Clearfog Base"))
> +		 env_set("fdtfile", "armada-388-clearfog-base.dtb");
> +	else if (sr_product_is("Clearfog GTR S4"))
> +		 env_set("fdtfile", "armada-385-clearfog-gtr-s4.dtb");
> +	else if (sr_product_is("Clearfog GTR L8"))
> +		 env_set("fdtfile", "armada-385-clearfog-gtr-l8.dtb");
> +
> +	return 0;
> +}
> 

Where does this sr_product_is() function come from? I might have missed
it in a previous patch - please point me to it, thanks.

Does it make sense to match string values here or wouldn't it be better
to match board ID's (enum)?

Thanks,
Stefan
Baruch Siach Jan. 14, 2020, 10:26 a.m. UTC | #2
Hi Stefan,

On Mon, Jan 13, 2020 at 08:27:31AM +0100, Stefan Roese wrote:
> On 25.11.19 11:30, Baruch Siach wrote:
> > Set the kernel device-tree file (fdtfile environment variable) based on
> > run-time detection of the platform.
> > 
> > Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> > ---
> >   arch/arm/mach-mvebu/Kconfig        |  1 +
> >   board/solidrun/clearfog/clearfog.c | 14 ++++++++++++++
> >   2 files changed, 15 insertions(+)
> > 
> > diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig
> > index fdd39685b75d..bc5eaa5a7679 100644
> > --- a/arch/arm/mach-mvebu/Kconfig
> > +++ b/arch/arm/mach-mvebu/Kconfig
> > @@ -91,6 +91,7 @@ choice
> >   config TARGET_CLEARFOG
> >   	bool "Support ClearFog"
> >   	select 88F6820
> > +	select BOARD_LATE_INIT
> >   config TARGET_HELIOS4
> >   	bool "Support Helios4"
> > diff --git a/board/solidrun/clearfog/clearfog.c b/board/solidrun/clearfog/clearfog.c
> > index 852b1ad71bb2..00c1306e9c80 100644
> > --- a/board/solidrun/clearfog/clearfog.c
> > +++ b/board/solidrun/clearfog/clearfog.c
> > @@ -265,3 +265,17 @@ int board_eth_init(bd_t *bis)
> >   	cpu_eth_init(bis); /* Built in controller(s) come first */
> >   	return pci_eth_init(bis);
> >   }
> > +
> > +int board_late_init(void)
> > +{
> > +	read_tlv_data();
> > +
> > +	if (sr_product_is("Clearfog Base"))
> > +		 env_set("fdtfile", "armada-388-clearfog-base.dtb");
> > +	else if (sr_product_is("Clearfog GTR S4"))
> > +		 env_set("fdtfile", "armada-385-clearfog-gtr-s4.dtb");
> > +	else if (sr_product_is("Clearfog GTR L8"))
> > +		 env_set("fdtfile", "armada-385-clearfog-gtr-l8.dtb");
> > +
> > +	return 0;
> > +}
> > 
> 
> Where does this sr_product_is() function come from? I might have missed
> it in a previous patch - please point me to it, thanks.

sr_product_is() is added in patch #6 of this series. Match is tested against 
TLV stored product name string.

> Does it make sense to match string values here or wouldn't it be better
> to match board ID's (enum)?

sr_product_is() matches also string prefixes. I use this feature in patch #9 
to set Clearfog GTR S4/L8 serdes configuration.

baruch
Stefan Roese Jan. 14, 2020, 11:28 a.m. UTC | #3
Hi Baruch,

On 14.01.20 11:26, Baruch Siach wrote:
> Hi Stefan,
> 
> On Mon, Jan 13, 2020 at 08:27:31AM +0100, Stefan Roese wrote:
>> On 25.11.19 11:30, Baruch Siach wrote:
>>> Set the kernel device-tree file (fdtfile environment variable) based on
>>> run-time detection of the platform.
>>>
>>> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
>>> ---
>>>    arch/arm/mach-mvebu/Kconfig        |  1 +
>>>    board/solidrun/clearfog/clearfog.c | 14 ++++++++++++++
>>>    2 files changed, 15 insertions(+)
>>>
>>> diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig
>>> index fdd39685b75d..bc5eaa5a7679 100644
>>> --- a/arch/arm/mach-mvebu/Kconfig
>>> +++ b/arch/arm/mach-mvebu/Kconfig
>>> @@ -91,6 +91,7 @@ choice
>>>    config TARGET_CLEARFOG
>>>    	bool "Support ClearFog"
>>>    	select 88F6820
>>> +	select BOARD_LATE_INIT
>>>    config TARGET_HELIOS4
>>>    	bool "Support Helios4"
>>> diff --git a/board/solidrun/clearfog/clearfog.c b/board/solidrun/clearfog/clearfog.c
>>> index 852b1ad71bb2..00c1306e9c80 100644
>>> --- a/board/solidrun/clearfog/clearfog.c
>>> +++ b/board/solidrun/clearfog/clearfog.c
>>> @@ -265,3 +265,17 @@ int board_eth_init(bd_t *bis)
>>>    	cpu_eth_init(bis); /* Built in controller(s) come first */
>>>    	return pci_eth_init(bis);
>>>    }
>>> +
>>> +int board_late_init(void)
>>> +{
>>> +	read_tlv_data();
>>> +
>>> +	if (sr_product_is("Clearfog Base"))
>>> +		 env_set("fdtfile", "armada-388-clearfog-base.dtb");
>>> +	else if (sr_product_is("Clearfog GTR S4"))
>>> +		 env_set("fdtfile", "armada-385-clearfog-gtr-s4.dtb");
>>> +	else if (sr_product_is("Clearfog GTR L8"))
>>> +		 env_set("fdtfile", "armada-385-clearfog-gtr-l8.dtb");
>>> +
>>> +	return 0;
>>> +}
>>>
>>
>> Where does this sr_product_is() function come from? I might have missed
>> it in a previous patch - please point me to it, thanks.
> 
> sr_product_is() is added in patch #6 of this series. Match is tested against
> TLV stored product name string.

Ah, I missed it. Thanks.
  
>> Does it make sense to match string values here or wouldn't it be better
>> to match board ID's (enum)?
> 
> sr_product_is() matches also string prefixes. I use this feature in patch #9
> to set Clearfog GTR S4/L8 serdes configuration.

If you prefer to continue this was with string comparison, then feel free
to add my:

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan
diff mbox series

Patch

diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig
index fdd39685b75d..bc5eaa5a7679 100644
--- a/arch/arm/mach-mvebu/Kconfig
+++ b/arch/arm/mach-mvebu/Kconfig
@@ -91,6 +91,7 @@  choice
 config TARGET_CLEARFOG
 	bool "Support ClearFog"
 	select 88F6820
+	select BOARD_LATE_INIT
 
 config TARGET_HELIOS4
 	bool "Support Helios4"
diff --git a/board/solidrun/clearfog/clearfog.c b/board/solidrun/clearfog/clearfog.c
index 852b1ad71bb2..00c1306e9c80 100644
--- a/board/solidrun/clearfog/clearfog.c
+++ b/board/solidrun/clearfog/clearfog.c
@@ -265,3 +265,17 @@  int board_eth_init(bd_t *bis)
 	cpu_eth_init(bis); /* Built in controller(s) come first */
 	return pci_eth_init(bis);
 }
+
+int board_late_init(void)
+{
+	read_tlv_data();
+
+	if (sr_product_is("Clearfog Base"))
+		 env_set("fdtfile", "armada-388-clearfog-base.dtb");
+	else if (sr_product_is("Clearfog GTR S4"))
+		 env_set("fdtfile", "armada-385-clearfog-gtr-s4.dtb");
+	else if (sr_product_is("Clearfog GTR L8"))
+		 env_set("fdtfile", "armada-385-clearfog-gtr-l8.dtb");
+
+	return 0;
+}