diff mbox series

[v4,2/6] arm64: dts: ti: k3-j784s4: Add alias to MCU CPSW2G

Message ID 20240131101441.1362409-3-c-vankar@ti.com (mailing list archive)
State New, archived
Headers show
Series Add CPSW2G and CPSW9G nodes for J784S4 | expand

Commit Message

Chintan Vankar Jan. 31, 2024, 10:14 a.m. UTC
Add alias for the MCU CPSW2G port to enable Linux to fetch MAC Address
for the port directly from U-Boot.
---
 arch/arm64/boot/dts/ti/k3-j784s4-evm.dts | 1 +
 1 file changed, 1 insertion(+)

Comments

Andrew Davis Jan. 31, 2024, 3:36 p.m. UTC | #1
On 1/31/24 4:14 AM, Chintan Vankar wrote:
> Add alias for the MCU CPSW2G port to enable Linux to fetch MAC Address
> for the port directly from U-Boot.

Could you explain *how* this alias allows Linux to fetch a MAC
address from U-Boot? Sounds like we are doing something hacky here..

Why can't Linux fetch the MAC from efuses the same way U-Boot does,
what happens if I don't use U-Boot to boot?

Andrew

> ---
>   arch/arm64/boot/dts/ti/k3-j784s4-evm.dts | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/arch/arm64/boot/dts/ti/k3-j784s4-evm.dts b/arch/arm64/boot/dts/ti/k3-j784s4-evm.dts
> index f34b92acc56d..b74f7d3025de 100644
> --- a/arch/arm64/boot/dts/ti/k3-j784s4-evm.dts
> +++ b/arch/arm64/boot/dts/ti/k3-j784s4-evm.dts
> @@ -27,6 +27,7 @@ aliases {
>   		mmc1 = &main_sdhci1;
>   		i2c0 = &wkup_i2c0;
>   		i2c3 = &main_i2c0;
> +		ethernet0 = &mcu_cpsw_port1;
>   	};
>   
>   	memory@80000000 {
Chintan Vankar March 11, 2024, 10:44 a.m. UTC | #2
On 31/01/24 21:06, Andrew Davis wrote:
> On 1/31/24 4:14 AM, Chintan Vankar wrote:
>> Add alias for the MCU CPSW2G port to enable Linux to fetch MAC Address
>> for the port directly from U-Boot.
> 
> Could you explain *how* this alias allows Linux to fetch a MAC
> address from U-Boot? Sounds like we are doing something hacky here..
> 
Using "probe_daughtercards()" function U-Boot parses MAC addresses from
EEPROM, then it internally calls "eth_env_set_enetaddr_by_index()"
function which stores these MAC addresses into environment variables
ethaddr, eth1addr, eth2addr and so on based on number of ports.

U-Boot loads DTB during boot process, and it calls
"fdt_fixup_ethernet()" function, which uses environment variables to
update MAC addresses of ethernet ports as specified in the aliases
section.

> Why can't Linux fetch the MAC from efuses the same way U-Boot does,

Linux can fetch the MAC address from efuses if "ti,syscon-efuse"
property is enabled.

> what happens if I don't use U-Boot to boot?

If you don't use U-Boot to boot then the equivalent of
"probe_daughtercards()" has to be implemented which is currently
missing.

> 
> Andrew
> 
>> ---
>>   arch/arm64/boot/dts/ti/k3-j784s4-evm.dts | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/arch/arm64/boot/dts/ti/k3-j784s4-evm.dts 
>> b/arch/arm64/boot/dts/ti/k3-j784s4-evm.dts
>> index f34b92acc56d..b74f7d3025de 100644
>> --- a/arch/arm64/boot/dts/ti/k3-j784s4-evm.dts
>> +++ b/arch/arm64/boot/dts/ti/k3-j784s4-evm.dts
>> @@ -27,6 +27,7 @@ aliases {
>>           mmc1 = &main_sdhci1;
>>           i2c0 = &wkup_i2c0;
>>           i2c3 = &main_i2c0;
>> +        ethernet0 = &mcu_cpsw_port1;
>>       };
>>       memory@80000000 {
Andrew Davis March 19, 2024, 3:35 p.m. UTC | #3
On 3/11/24 5:44 AM, Chintan Vankar wrote:
> 
> 
> On 31/01/24 21:06, Andrew Davis wrote:
>> On 1/31/24 4:14 AM, Chintan Vankar wrote:
>>> Add alias for the MCU CPSW2G port to enable Linux to fetch MAC Address
>>> for the port directly from U-Boot.
>>
>> Could you explain *how* this alias allows Linux to fetch a MAC
>> address from U-Boot? Sounds like we are doing something hacky here..
>>
> Using "probe_daughtercards()" function U-Boot parses MAC addresses from
> EEPROM, then it internally calls "eth_env_set_enetaddr_by_index()"
> function which stores these MAC addresses into environment variables
> ethaddr, eth1addr, eth2addr and so on based on number of ports.
> 
> U-Boot loads DTB during boot process, and it calls
> "fdt_fixup_ethernet()" function, which uses environment variables to
> update MAC addresses of ethernet ports as specified in the aliases
> section.
> 

So maybe a better question would by why does it need to use aliases
for this?

>> Why can't Linux fetch the MAC from efuses the same way U-Boot does,
> 
> Linux can fetch the MAC address from efuses if "ti,syscon-efuse"
> property is enabled.
> 

Then let's do it this way always.

>> what happens if I don't use U-Boot to boot?
> 
> If you don't use U-Boot to boot then the equivalent of
> "probe_daughtercards()" has to be implemented which is currently
> missing.
> 

Or we just let Linux fetch it instead of implementing that function
in all the possible bootloaders. This would also remove a DTB fixup.
Those fixups should be avoided if at all possible.

Andrew

>>
>> Andrew
>>
>>> ---
>>>   arch/arm64/boot/dts/ti/k3-j784s4-evm.dts | 1 +
>>>   1 file changed, 1 insertion(+)
>>>
>>> diff --git a/arch/arm64/boot/dts/ti/k3-j784s4-evm.dts b/arch/arm64/boot/dts/ti/k3-j784s4-evm.dts
>>> index f34b92acc56d..b74f7d3025de 100644
>>> --- a/arch/arm64/boot/dts/ti/k3-j784s4-evm.dts
>>> +++ b/arch/arm64/boot/dts/ti/k3-j784s4-evm.dts
>>> @@ -27,6 +27,7 @@ aliases {
>>>           mmc1 = &main_sdhci1;
>>>           i2c0 = &wkup_i2c0;
>>>           i2c3 = &main_i2c0;
>>> +        ethernet0 = &mcu_cpsw_port1;
>>>       };
>>>       memory@80000000 {
Chintan Vankar March 21, 2024, 7:01 a.m. UTC | #4
On 19/03/24 21:05, Andrew Davis wrote:
> On 3/11/24 5:44 AM, Chintan Vankar wrote:
>>
>>
>> On 31/01/24 21:06, Andrew Davis wrote:
>>> On 1/31/24 4:14 AM, Chintan Vankar wrote:
>>>> Add alias for the MCU CPSW2G port to enable Linux to fetch MAC Address
>>>> for the port directly from U-Boot.
>>>
>>> Could you explain *how* this alias allows Linux to fetch a MAC
>>> address from U-Boot? Sounds like we are doing something hacky here..
>>>
>> Using "probe_daughtercards()" function U-Boot parses MAC addresses from
>> EEPROM, then it internally calls "eth_env_set_enetaddr_by_index()"
>> function which stores these MAC addresses into environment variables
>> ethaddr, eth1addr, eth2addr and so on based on number of ports.
>>
>> U-Boot loads DTB during boot process, and it calls
>> "fdt_fixup_ethernet()" function, which uses environment variables to
>> update MAC addresses of ethernet ports as specified in the aliases
>> section.
>>
> 
> So maybe a better question would by why does it need to use aliases
> for this?
> 

Since "probe_daughtercards()" in U-Boot is implemented in a way that
it gets the MAC addresses fromm EEPROM and "fdt_fixup_ethernet()"
function configures MAC addresses for the ethernet ports as specified
in aliases section.

>>> Why can't Linux fetch the MAC from efuses the same way U-Boot does,
>>
>> Linux can fetch the MAC address from efuses if "ti,syscon-efuse"
>> property is enabled.
>>
> 
> Then let's do it this way always.
> 
Yes, Linux reads MAC addresses from efuse this way only, but the
functionality of Linux getting the MAC addresses from EEPROM is
not implemented.

>>> what happens if I don't use U-Boot to boot?
>>
>> If you don't use U-Boot to boot then the equivalent of
>> "probe_daughtercards()" has to be implemented which is currently
>> missing.
>>
> 
> Or we just let Linux fetch it instead of implementing that function
> in all the possible bootloaders. This would also remove a DTB fixup.
> Those fixups should be avoided if at all possible.
> 

Yes, we can let Linux fetch MAC addresses, but right now the Ethernet
driver in Linux can only fetch MAC addresses from "EFUSE" and not from
"EEPROM", and since the functionality to fetch MAC addresses from
"EEPROM" is implemented in U-Boot we are utilizing it.

> Andrew
> 
>>>
>>> Andrew
>>>
>>>> ---
>>>>   arch/arm64/boot/dts/ti/k3-j784s4-evm.dts | 1 +
>>>>   1 file changed, 1 insertion(+)
>>>>
>>>> diff --git a/arch/arm64/boot/dts/ti/k3-j784s4-evm.dts 
>>>> b/arch/arm64/boot/dts/ti/k3-j784s4-evm.dts
>>>> index f34b92acc56d..b74f7d3025de 100644
>>>> --- a/arch/arm64/boot/dts/ti/k3-j784s4-evm.dts
>>>> +++ b/arch/arm64/boot/dts/ti/k3-j784s4-evm.dts
>>>> @@ -27,6 +27,7 @@ aliases {
>>>>           mmc1 = &main_sdhci1;
>>>>           i2c0 = &wkup_i2c0;
>>>>           i2c3 = &main_i2c0;
>>>> +        ethernet0 = &mcu_cpsw_port1;
>>>>       };
>>>>       memory@80000000 {
diff mbox series

Patch

diff --git a/arch/arm64/boot/dts/ti/k3-j784s4-evm.dts b/arch/arm64/boot/dts/ti/k3-j784s4-evm.dts
index f34b92acc56d..b74f7d3025de 100644
--- a/arch/arm64/boot/dts/ti/k3-j784s4-evm.dts
+++ b/arch/arm64/boot/dts/ti/k3-j784s4-evm.dts
@@ -27,6 +27,7 @@  aliases {
 		mmc1 = &main_sdhci1;
 		i2c0 = &wkup_i2c0;
 		i2c3 = &main_i2c0;
+		ethernet0 = &mcu_cpsw_port1;
 	};
 
 	memory@80000000 {