public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Christoph Niedermaier <cniedermaier@dh-electronics.com>
To: Marek Vasut <marex@denx.de>,
	"u-boot@lists.denx.de" <u-boot@lists.denx.de>
Cc: NXP i.MX U-Boot Team <uboot-imx@nxp.com>,
	Fabio Estevam <festevam@gmail.com>,
	Stefano Babic <sbabic@denx.de>, Tom Rini <trini@konsulko.com>,
	u-boot <u-boot@dh-electronics.com>
Subject: RE: [PATCH 2/2] arm64: imx8mp: Read item and serial number from EEPROM ID page on DH i.MX8MP DHCOM
Date: Thu, 17 Oct 2024 11:55:43 +0000	[thread overview]
Message-ID: <73ccb69b85094e24be2343d5cbc8879a@dh-electronics.com> (raw)
In-Reply-To: <74bd0a6b-fe12-4e2c-af79-c1f8ffb7d484@denx.de>

From: Marek Vasut <marex@denx.de>
Sent: Thursday, October 17, 2024 2:22 AM
> On 10/16/24 2:31 PM, Christoph Niedermaier wrote:
> 
> [...]
> 
>>>> diff --git a/board/dhelectronics/common/dh_common.h b/board/dhelectronics/common/dh_common.h
>>>> index 4c22ece435..1baa45e340 100644
>>>> --- a/board/dhelectronics/common/dh_common.h
>>>> +++ b/board/dhelectronics/common/dh_common.h
>>>> @@ -6,6 +6,8 @@
>>>>    enum eip_request_values {
>>>>        MAC0,
>>>>        MAC1,
>>>> +     ITEM_NUMBER,
>>>> +     SN,
>>>
>>> Why is this patch not squashed into 1/2 ? It seems to be changing the
>>> same code.
>>
>> The first patch add the reading for MAC address from the EEPROM ID
>> page and add the use of that addresses. The second extends the reading
>> to the serial number and the item number. So that the patch doesn't
>> get too big I found it useful to split it into two. Do you want me to
>> make one patch out of it?
> 
> Yes please. Once you cache the EEPROM content, the patch would likely
> get simpler anyway.

Will be done in v2.

> 
> [...]
> 
>>>> +     ret = dh_get_value_from_eeprom_id_page(ITEM_NUMBER, item_number, sizeof(item_number),
>>>> +                                            "eeprom0");
>>>> +     if (ret) {
>>>> +             /*
>>>> +              * The function only returns the value -ENOENT for SoM rev.100, because
>>>> +              * the EEPROM ID page isn't available there. Therefore the output makes
>>>> +              * no sense and will be suppressed here.
>>>> +              */
>>>> +             if (ret != -ENOENT)
>>>> +                     printf("%s: Unable to get item number form EEPROM ID page! ret = %d\n",
> 
> 'form' typo

Will be fixed in v2.

>>>> +                            __func__, ret);
>>>
>>> This will be printed on every device, even the ones without ID EEPROM,
>>> correct ? This should not be printed on devices without ID EEPROM. Also,
>>
>> This is suppressed by the -ENOENT check.
> 
> Does i2c_eeprom_read() in dh_get_value_from_eeprom_id_page() return
> -ENOENT in case the EEPROM is described in DT, but not populated on the
> board ? I suspect it returns some other error code, -ETIMEDOUT or
> -EINVAL maybe ?

It could only be possible if the DTO for hardware rev. 100 (which has no
EEPROM ID page) is not loaded. The return value then is -ENODEV.
I will included this in v2.

>>> if (ret && ret != -ENOENT) {}
>>>
>>> works equally well without the extra indent.
>>
>> I have an else to (ret) here not to (ret && ret != -ENOENT).
>> This would change the logic.
> 
> } else if (!ret) { or similar should fix that, right ?
> 
> Basically, the question is, can we avoid this two level deep indent ? I
> think yes ?

I want to try it in v2.

> [...]
> 
>>> Also, this shouldn't be repeatedly reading the EEPROM, the EEPROM read
>>> operation is the slow part, the EEPROM is 32 bytes, so the EEPROM should
>>> be read once and cached, and once the cache is populated all read
>>> accesses to the EEPROM should use the cache.
>>
>> This is already covered in function dh_get_value_from_eeprom_id_page().
> It seems that function always calls
> ret = i2c_eeprom_read(dev, 0x0, eipa, sizeof(eipa));
> ?

The 32 bytes are read into a static variable. If the ID (DHE) already exists
in it, the i2c_eeprom_read() function is no longer called.


Regards
Christoph

  reply	other threads:[~2024-10-17 11:55 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-10 13:23 [PATCH 1/2] arm64: imx8mp: Read MAC address from M24C32-D write-lockable page on DH i.MX8MP DHCOM if available Christoph Niedermaier
2024-10-10 13:23 ` [PATCH 2/2] arm64: imx8mp: Read item and serial number from EEPROM ID page on DH i.MX8MP DHCOM Christoph Niedermaier
2024-10-12 20:55   ` Marek Vasut
2024-10-16 12:31     ` Christoph Niedermaier
2024-10-17  0:22       ` Marek Vasut
2024-10-17 11:55         ` Christoph Niedermaier [this message]
2024-10-17 18:35           ` Marek Vasut
2024-10-21 15:38             ` Christoph Niedermaier
2024-10-21 23:00               ` Marek Vasut
2024-10-22  9:31                 ` Christoph Niedermaier
2024-10-22 11:57                   ` Marek Vasut
2024-10-23 12:18                     ` Christoph Niedermaier
2024-10-23 12:41                       ` Marek Vasut
2024-10-23 13:20                         ` Christoph Niedermaier
2024-10-23 14:04                           ` Marek Vasut
2024-10-25 15:36                             ` Christoph Niedermaier
2024-10-12 20:42 ` [PATCH 1/2] arm64: imx8mp: Read MAC address from M24C32-D write-lockable page on DH i.MX8MP DHCOM if available Marek Vasut
2024-10-16 11:57   ` Christoph Niedermaier
2024-10-16 12:15     ` Marek Vasut
2024-10-17 11:09       ` Christoph Niedermaier
2024-10-17 14:01         ` Marek Vasut
2024-10-21 15:08           ` 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=73ccb69b85094e24be2343d5cbc8879a@dh-electronics.com \
    --to=cniedermaier@dh-electronics.com \
    --cc=festevam@gmail.com \
    --cc=marex@denx.de \
    --cc=sbabic@denx.de \
    --cc=trini@konsulko.com \
    --cc=u-boot@dh-electronics.com \
    --cc=u-boot@lists.denx.de \
    --cc=uboot-imx@nxp.com \
    /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