All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Antliff <d.antliff@unsw.edu.au>
To: Sean Anderson <seanga2@gmail.com>,
	"u-boot@lists.denx.de" <u-boot@lists.denx.de>
Subject: Re: Setting MAC address from I2C EEPROM - debug / commands? (Xilinx)
Date: Mon, 12 Jun 2023 04:16:10 +0000	[thread overview]
Message-ID: <SY4PR01MB6797F496503ACDF6574DC99BB154A@SY4PR01MB6797.ausprd01.prod.outlook.com> (raw)
In-Reply-To: <17482435-1690-7c0d-772e-09daf8417ca4@gmail.com>

Hi Sean, thanks for getting back to me.

On 6/11/23 Sean Anderson wrote:
> On 6/11/23 23:25, David Antliff wrote:
> > On 11/23/22 Sean Anderson wrote:
> >>   On 11/22/22 20:23, David Antliff wrote:

[snip]

> > So I took up your suggestion, enabled CONFIG_NVMEM & CONFIG_I2C_EEPROM, and
> > with some trial and error I have got as far as added the following to my device tree:
> > 
> >      axi {
> >          i2c@ff030000 {
> >              i2c-mux@74 {
> >                  i2c@0 {
> >                      eeprom@54 {
> >                          mac_address: mac-address@23 {
> >                              reg = <0x23 6>;
> >                          };
> >                      };
> >                  };
> >              };
> >          };
> > 
> >          ethernet@ff0e0000 {
> >              nvmem-cells = <&mac_address>;
> >              nvmem-cell-names = "mac-address";
> >          };
> >      };
> > 
> > (This is part of a user .dtsi so it's added by Yocto to the existing DT provided by the vendor's board
> > definition).
> > 
> > The tree builds OK and I can view the correct nodes from U-Boot / fdt command.
> > 
> >  From a little debugging, I see that the call in eth-uclass.c around line 515 returns a null pointer:
> > 
> >        p = dev_read_u8_array_ptr(dev, "mac-address", ARP_HLEN);
> 
> This is expected. If (local-)mac-address is defined then nvmem_cell_get_by_name/nvmem_cell_read will not be used.

Yeah, so, I think I shot myself in the foot when writing this email, because although I am using the U-Boot device tree
for my efforts (the one appended to the U-Boot binary, a la CONFIG_OF_SEPARATE), I actually used the Linux one in
my email, which was a mistake because the "local-mac-address" has been populated with a valid address by that point.
I'm actually not sure where that address comes from, because in the U-Boot device tree, I have:

        local-mac-address = [ff ff ff ff ff ff];

So to be clear, I do not have a valid local-mac-address in the U-Boot device tree at the time U-Boot is looking for the MAC address.

> > And this results in U-Boot assigning the FF:FF:FF:FF:FF:FF address instead.
> > 
> > Yet, if I boot Linux, this device now appears in sysfs as /sys/bus/nvmem/devices/6-00544/nvmem,
> > and I can read/write to it, so something is working. Linux ends up with the wrong MAC though
> > (76:1b:db:1f:78:12, and I'm not sure where that comes from).
> > 
> > I think I have the right Ethernet device, as U-Boot reports:
> > 
> >      ZYNQ GEM: ff0e0000, mdio bus ff0e0000, phyaddr 12, interface rgmii-id
> > 
> > Do you have any thoughts as to why U-Boot is not picking up the MAC address from the EEPROM,
> > in this case, please?
> > 
> > The full sections of the relevant parts of the DT now look like this:

[snip]

> >          ethernet@ff0e0000 {
> >                  power-domains = <0x11 0x20>;
> >                  iommus = <0x12 0x877>;
> >                  #address-cells = <0x01>;
> >                  phy-mode = "rgmii-id";
> >                  nvmem-cells = <0x15>;
> >                  clock-names = "pclk\0hclk\0tx_clk\0rx_clk\0tsu_clk";
> >                  local-mac-address = [76 1b db 1f 78 12];
> 
> This will prevent the nvmem-cells from being used. Is this your U-Boot device tree? Or is it from /sys/firmware?

Yes, this is from /sys/firmware - my mistake, as mentioned above. The U-Boot device tree looks like this:

ZynqMP> fdt print /axi/ethernet@ff0e0000
ethernet@ff0e0000 {
        compatible = "xlnx,zynqmp-gem", "cdns,gem";
        status = "okay";
        interrupt-parent = <0x00000005>;
        interrupts = <0x00000000 0x0000003f 0x00000004 0x00000000 0x0000003f 0x00000004>;
        reg = <0x00000000 0xff0e0000 0x00000000 0x00001000>;
        clock-names = "pclk", "hclk", "tx_clk", "rx_clk", "tsu_clk";
        #address-cells = <0x00000001>;
        #size-cells = <0x00000000>;
        iommus = <0x00000012 0x00000877>;
        power-domains = <0x00000011 0x00000020>;
        resets = <0x00000013 0x00000020>;
        reset-names = "gem3_rst";
        clocks = <0x00000004 0x0000001f 0x00000004 0x0000006b 0x00000004 0x00000030 0x00000004 0x00000034 0x00000004 0x0000002c>;
        phy-handle = <0x00000014>;
        phy-mode = "rgmii-id";
        xlnx,ptp-enet-clock = <0x00000000>;
        local-mac-address = [ff ff ff ff ff ff];
        nvmem-cells = <0x00000015>;
        nvmem-cell-names = "mac-address";
        phandle = <0x00000067>;
        mdio {
                #address-cells = <0x00000001>;
                #size-cells = <0x00000000>;
                phandle = <0x00000068>;
                ethernet-phy@c {
                        #phy-cells = <0x00000001>;
                        compatible = "ethernet-phy-id2000.a231";
                        reg = <0x0000000c>;
                        ti,rx-internal-delay = <0x00000008>;
                        ti,tx-internal-delay = <0x0000000a>;
                        ti,fifo-depth = <0x00000001>;
                        ti,dp83867-rxctrl-strap-quirk;
                        reset-gpios = <0x00000016 0x00000006 0x00000001>;
                        phandle = <0x00000014>;
                };
        };
};

I've noticed in some online examples that there's a compatible = "nvmem-cells" at the EEPROM level, so I tried:

ZynqMP> fdt print /axi/i2c@ff030000/i2c-mux@74/i2c@0
i2c@0 {
        #address-cells = <0x00000001>;
        #size-cells = <0x00000000>;
        reg = <0x00000000>;
        phandle = <0x0000006d>;
        eeprom@54 {
                compatible = "atmel,24c128", "nvmem-cells";
                reg = <0x00000054>;
                phandle = <0x00000036>;
                mac-address@23 {
                        reg = <0x00000023 0x00000006>;
                        phandle = <0x00000015>;
                };
        };
};

However this does not work either. Is this compatibility declaration required?

[snip]
 
> You can also #define DEBUG in drivers/misc/nvmem.c

Thank you, I will try that.
 
-- David.

  reply	other threads:[~2023-06-12  4:16 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-23  1:23 Setting MAC address from I2C EEPROM - debug / commands? (Xilinx) David Antliff
2022-11-23  3:14 ` Sean Anderson
2022-11-23  8:45   ` Michal Simek
2022-11-23 13:27     ` Michael Walle
2022-11-23 15:11       ` Michal Simek
2022-11-23 15:26         ` Sean Anderson
2022-11-23 22:14     ` David Antliff
2022-11-23 21:56   ` David Antliff
2023-06-12  3:25   ` David Antliff
2023-06-12  4:01     ` Sean Anderson
2023-06-12  4:16       ` David Antliff [this message]
2023-06-12  5:32         ` David Antliff

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=SY4PR01MB6797F496503ACDF6574DC99BB154A@SY4PR01MB6797.ausprd01.prod.outlook.com \
    --to=d.antliff@unsw.edu.au \
    --cc=seanga2@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.