devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij@linaro.org>
To: Andrew Lunn <andrew+netdev@lunn.ch>,
	 "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	 Jakub Kicinski <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,  Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	 Conor Dooley <conor+dt@kernel.org>, Andrew Lunn <andrew@lunn.ch>,
	 Heiner Kallweit <hkallweit1@gmail.com>,
	 Russell King <linux@armlinux.org.uk>,
	Simon Horman <horms@kernel.org>
Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org,
	 linux-kernel@vger.kernel.org,
	Linus Walleij <linus.walleij@linaro.org>
Subject: [PATCH 0/2] net: of: Support minor nvmem MAC offset
Date: Fri, 20 Dec 2024 20:17:05 +0100	[thread overview]
Message-ID: <20241220-net-mac-nvmem-offset-v1-0-e9d1da2c1681@linaro.org> (raw)

In practice (as found in the OpenWrt project) many devices
with multiple ethernet interfaces just store a base MAC
address in NVMEM and increase the lowermost byte with one for
each interface, so as to occupy less NVMEM.

Here is an example patch from the Linksys WRT300N router that
was used before we had device tree:

f = ioremap(IXP4XX_EXP_BUS_BASE(0), 0x60000);
if (f) {
    for (i = 0; i < 6; i++) {
        wrt300nv2_plat_eth[0].hwaddr[i] = readb(f + 0x5FFA0 + i);
        if (i == 5)
            offset = 1;
        wrt300nv2_plat_eth[1].hwaddr[i] =
	    (wrt300nv2_plat_eth[0].hwaddr[i] + offset);
    }
}
iounmap(f);

In order to support this scheme directly from device tree
we need some way to encode the same into device tree, this
patchset provides that.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
Linus Walleij (2):
      dt-bindings: net: ethernet-controller: Add mac offset option
      net: of: Support adding offset to nvmem MAC addresses

 .../devicetree/bindings/net/ethernet-controller.yaml         | 12 ++++++++++++
 net/core/of_net.c                                            | 10 ++++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)
---
base-commit: 40384c840ea1944d7c5a392e8975ed088ecf0b37
change-id: 20241219-net-mac-nvmem-offset-22b6218a4b0f

Best regards,
-- 
Linus Walleij <linus.walleij@linaro.org>


             reply	other threads:[~2024-12-20 19:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-20 19:17 Linus Walleij [this message]
2024-12-20 19:17 ` [PATCH 1/2] dt-bindings: net: ethernet-controller: Add mac offset option Linus Walleij
2024-12-31 13:35   ` Rob Herring
2025-01-13 14:59     ` Linus Walleij
2025-01-14 19:47       ` Rob Herring
2024-12-20 19:17 ` [PATCH 2/2] net: of: Support adding offset to nvmem MAC addresses Linus Walleij

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=20241220-net-mac-nvmem-offset-v1-0-e9d1da2c1681@linaro.org \
    --to=linus.walleij@linaro.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=andrew@lunn.ch \
    --cc=conor+dt@kernel.org \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=horms@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=robh@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).