public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Christoph Niedermaier <cniedermaier@dh-electronics.com>
To: Marek Vasut <marex@nabladev.com>,
	"u-boot@lists.denx.de" <u-boot@lists.denx.de>
Cc: Patrice Chotard <patrice.chotard@foss.st.com>,
	Peng Fan <peng.fan@nxp.com>,
	Sam Protsenko <semen.protsenko@linaro.org>,
	Tom Rini <trini@konsulko.com>, u-boot <u-boot@dh-electronics.com>
Subject: RE: [PATCH] board: dhelectronics: imx: Use second Ethernet MAC also from fuse
Date: Mon, 23 Mar 2026 10:07:02 +0000	[thread overview]
Message-ID: <2eebac26eff54f9da7e2d01dbca71569@dh-electronics.com> (raw)
In-Reply-To: <941708e9-a2e6-4f8d-a15d-d1da8a91ae91@nabladev.com>

From: Marek Vasut <marex@nabladev.com>
Sent: Sunday, March 22, 2026 12:41 AM
> On 3/21/26 9:55 PM, Christoph Niedermaier wrote:
>> From: Marek Vasut <marex@nabladev.com>
>> Sent: Friday, March 20, 2026 7:22 PM
>>> On 3/20/26 11:29 AM, Christoph Niedermaier wrote:
>>>
>>> [...]
>>>
>>>> +++ b/board/dhelectronics/dh_imx8mp/imx8mp_dhcom_pdk2.c
>>>> @@ -50,7 +50,7 @@ static int dh_imx8_setup_ethaddr(struct eeprom_id_page *eip)
>>>>        if (dh_get_mac_is_enabled("ethernet0"))
>>>>                return 0;
>>>>
>>>> -     if (!dh_imx_get_mac_from_fuse(enetaddr))
>>>> +     if (!dh_imx_get_mac_from_fuse(0, enetaddr))
>>>>                goto out;
>>>>
>>>>        if (!dh_get_value_from_eeprom_buffer(DH_MAC0, enetaddr, sizeof(enetaddr), eip))
>>>> @@ -75,8 +75,8 @@ static int dh_imx8_setup_eth1addr(struct eeprom_id_page *eip)
>>>>        if (dh_get_mac_is_enabled("ethernet1"))
>>>>                return 0;
>>>>
>>>> -     if (!dh_imx_get_mac_from_fuse(enetaddr))
>>>> -             goto increment_out;
>>>> +     if (!dh_imx_get_mac_from_fuse(1, enetaddr))
>>>> +             goto out;
>>>
>>> The ordering in this and next hunk seems bogus.
>>>
>>> If read from the (new/second) fuse slot 1 fails, the code should attempt
>>> to use fuse slot 0 content incremented by 1, just like it did before ...
>>>
>>> "
>>> if (!dh_imx_get_mac_from_fuse(1, enetaddr))
>>>     goto out;
>>> if (!dh_imx_get_mac_from_fuse(0, enetaddr))
>>>     goto increment_out;
>>> "
>>>
>>>>        if (!dh_get_value_from_eeprom_buffer(DH_MAC1, enetaddr, sizeof(enetaddr), eip))
>>>>                goto out;
>>>> @@ -92,6 +92,13 @@ static int dh_imx8_setup_eth1addr(struct eeprom_id_page *eip)
>>>>        if (!dh_get_mac_from_eeprom(enetaddr, "eeprom0"))
>>>>                goto increment_out;
>>>>
>>>> +     /*
>>>> +      * If only the first MAC address is fused but not the second, use the
>>>> +      * fused MAC address incremented by one, for the second MAC address.
>>>> +      */
>>>> +     if (!dh_imx_get_mac_from_fuse(0, enetaddr))
>>>> +             goto increment_out;
>>> ... this part would then be unnecessary.
>>
>> That's how it's supposed to be. The two MAC addresses should be assigned the same
>> priority order and be as independent of each other as possible to avoid confusion.
>> Sources associated with the second MAC address therefore have a higher priority
>> than those associated with the first MAC address in the fuses. Using the fuse of
>> the first MAC address incremented by one as a fallback is the last resort if no
>> address is found for the second MAC address after the priority order has been
>> checked.
> The priority is this:
> - ENV -- because user can override the content, and user override is
> highest prio
> - Device not enabled in DT, do nothing
> - Fuses, (newly first fuse block 1 , then) fuse block 0 -- because
> in-SoC fuses always have to take precedence over the external EEPROM
> - EEPROM, first block 1, then block 0 -- because this is what is usually
> programmed out of factory, anything higher priority is up to the user

The SoM is delivered with both MAC addresses coming from DH electronics provided
by EEPROMs. If a customer wants his own MAC, they can fuse the MAC address to
override it permanently, but referring to your suggestion if the customer only
fuse one MAC address the behavior depends on which MAC address is fused.

Fuse only the first MAC address:
- 1. Ethernet: MAC is taken from FUSE 0
- 2. Ethernet: MAC is taken from FUSE 0 + incremented by one

Fuse only the second MAC address:
- 1. Ethernet: MAC is taken from EEPROM
- 2. Ethernet: MAC is taken from FUSE 1

The problem is that we have a customer with SoMs where only the first MAC address
was sequentially fused from a MAC address pool. That means the second MAC address
of the SoM is the same MAC address as the MAC address from the next SoM's first
MAC address. This patch prevents this by setting the MAC addresses independently
of one another. Then for the second MAC address the DH electronics MAC from the
EEPROM is used. In this patch the fallback where the first MAC address incremented
by one is used should not occur on the customer side, as the SoMs are shipped with
MAC addresses in the EEPROMs. If this does occur, however due to an EEPROM read
error or whatever this patch could be improved by a warning message.

Regards
Christoph

  reply	other threads:[~2026-03-23 10:07 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-20 10:29 [PATCH] board: dhelectronics: imx: Use second Ethernet MAC also from fuse Christoph Niedermaier
2026-03-20 13:41 ` Peng Fan (OSS)
2026-03-20 14:41   ` Christoph Niedermaier
2026-03-20 15:00 ` Peng Fan
2026-03-20 18:22 ` Marek Vasut
2026-03-21 20:55   ` Christoph Niedermaier
2026-03-21 23:40     ` Marek Vasut
2026-03-23 10:07       ` Christoph Niedermaier [this message]
2026-03-23 14:58         ` Marek Vasut
2026-03-23 16:49           ` Christoph Niedermaier
2026-03-23 17:20             ` Marek Vasut
2026-03-27 22:02               ` Christoph Niedermaier
2026-03-27 23:11                 ` Marek Vasut
2026-03-31  9:19                   ` Christoph Niedermaier
2026-03-23 17:34 ` Marek Vasut
2026-03-26 13:34   ` Christoph Niedermaier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2eebac26eff54f9da7e2d01dbca71569@dh-electronics.com \
    --to=cniedermaier@dh-electronics.com \
    --cc=marex@nabladev.com \
    --cc=patrice.chotard@foss.st.com \
    --cc=peng.fan@nxp.com \
    --cc=semen.protsenko@linaro.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@dh-electronics.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox