[PATCH 1/2] arm: mvebu: Implement the mac command (Marvell hw_info)

Marek Behún kabel at kernel.org
Mon Oct 11 12:56:34 CEST 2021


On Mon, 11 Oct 2021 12:19:07 +0200
Luka Kovacic <luka.kovacic at sartura.hr> wrote:

> Hello Pali,
> 
> > Something like this? compatible = "marvell,hw-info"  
> 
> This compatible string looks good to me.
> We will send a new patch version, which implements the discussed DT
> functionality.
>
> > > I am sure Luka knows more about the format than me.  
> 
> The Marvell hw_info partition is very similar to the U-Boot
> environment. The only difference is in the separator between the
> "key=value" pairs, which is 0x20/space in the case of hw_info.
> This is also prevents us to hard-code the parameter addresses in the
> device tree, because they can move around.
>
> The checksum is stored before the hw_info environment - this would
> have to be investigated further to implement checksum verification.

These differences between Marvell's version and U-Boot's standard
environment version can be specified in device-tree (via compatible or
other properties) and handled by one driver.

A driver for nvmem provider of standard U-Boot env could have this
binding (with "denx,u-boot-env" as compatible, changing it to
"marvell,hw-info" would make it work with spaces instead of '=' as
separator):

  spi-flash {
    blah blah blah;

    partitions {
      compatible = "fixed-partitions";
      #address-cells = <1>;
      #size-cells = <1>;

      hw-info at 18000 {
        compatible = "denx,u-boot-env";
        reg = <0x18000 0x1000>;
        label = "hw-info";

        eth0_mac_addr: ethaddr {
          compatible = "mac-address-string";
          name = "ethaddr";
        };

        eth1_mac_addr: eth1addr {
          compatible = "mac-address-string";
          name = "eth1addr";
        };
      };
    };
  };

  ethernet at 30000 {
    nvmem-cells = <&eth0_mac_addr>;
    nvmem-cell-names = "mac-address";
  };


On Turris MOX, we have the MAC address of the device stored in
One-Time-Programmable memory accesible only by the secure coprocessor,
which Linux communicates with via the turris-mox-rwtm kernel driver.

Currently this driver does not register itself as a nvmem provider, and
so isn't use by the ethernet controller driver to get MAC addresses.
MAC addresses are currently read by U-Boot board code and the
controller keeps these to Linux.

But I plan to extend the turris-mox-rwtm driver to also provide MAC
addresses via nvmem API, and then specify in device-tree
  &eth1 {
    nvmem-cells = <&rwtm_eth1_mac>;
    nvmem-cell-names = "address";
  };

Maybe in the future you will also want to implement this in Linux.
It could be done simply by adding a new type of nvmem provider, with
compatible = "marvell,hw-info".

Luka, what do you think?

Marek 


More information about the U-Boot mailing list