linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] of_net: Add NVMEM support to of_get_mac_address
@ 2019-04-26 23:06 Petr Štetiar
  2019-04-26 23:06 ` [PATCH 1/4] " Petr Štetiar
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Petr Štetiar @ 2019-04-26 23:06 UTC (permalink / raw)
  To: netdev, devicetree, linux-kernel, Matthias Brugger
  Cc: Andrew Lunn, Florian Fainelli, Heiner Kallweit, Rob Herring,
	Frank Rowand, Srinivas Kandagatla, Maxime Ripard, Alban Bedel,
	Petr Štetiar, linux-arm-kernel, linux-mediatek

Hi,

this patch series is a continuation of my previous attempt[1], where I've
tried to wire MTD layer into of_get_mac_address, so it would be possible to
load MAC addresses from various NVMEMs as EEPROMs etc.

Predecessor of this patch which used directly MTD layer has originated in
OpenWrt some time ago and supports already about 497 use cases in 357
device tree files.

During the review process of my 1st attempt I was told, that I shouldn't be
using MTD directly, but I should rather use new NVMEM subsystem, so this
patch series tries to accommodate that.

First patch is wiring NVMEM support directly into of_get_mac_address as
it's obvious, that adding support for NVMEM into every other driver would
mean adding a lot of repetitive code. This patch allows us to configure MAC
addresses in various devices like ethernet and wireless adapters directly
from of_get_mac_address, which is used by quite a lot of drivers in the
tree already.

Second patch is simply updating documentation with NVMEM bits, also adding
some missing bits like mac-address and local-mac-address properties, which
are currently supported by of_get_mac_address.

Third and fourth patches are simply removing duplicate NVMEM code which is
no longer needed as the first patch has added NVMEM support directly into
of_get_mac_address.

Just for a better picture, this patch series and one simple patch[2] on top
of it, allows me to configure 8Devices Carambola2 board's MAC addresses
with following DTS (simplified):

 &spi {
 	flash@0 {
 		partitions {
			art: partition@ff0000 {
				label = "art";
				reg = <0xff0000 0x010000>;
				read-only;

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

					eth0_addr: eth-mac-addr@0 {
						reg = <0x0 0x6>;
					};

					eth1_addr: eth-mac-addr@6 {
						reg = <0x6 0x6>;
					};

					wmac_addr: wifi-mac-addr@1002 {
						reg = <0x1002 0x6>;
					};
				};
			};
		};
	};
 };

 &eth0 {
	nvmem-cells = <&eth0_addr>;
	nvmem-cell-names = "mac-address";
 };

 &eth1 {
	nvmem-cells = <&eth1_addr>;
	nvmem-cell-names = "mac-address";
 };

 &wmac {
	nvmem-cells = <&wmac_addr>;
	nvmem-cell-names = "mac-address";
 };


1. https://patchwork.ozlabs.org/patch/1086628/
2. https://patchwork.ozlabs.org/patch/890738/

-- ynezz

Petr Štetiar (4):
  of_net: Add NVMEM support to of_get_mac_address
  dt-bindings: doc: Reflect new NVMEM of_get_mac_address behaviour
  net: macb: Drop nvmem_get_mac_address usage
  net: davinci_emac: Drop nvmem_get_mac_address usage

 .../devicetree/bindings/net/altera_tse.txt         |  3 ++
 Documentation/devicetree/bindings/net/arc_emac.txt |  4 ++
 .../devicetree/bindings/net/brcm,amac.txt          |  3 ++
 .../devicetree/bindings/net/brcm,bcmgenet.txt      |  5 +++
 .../devicetree/bindings/net/brcm,systemport.txt    |  4 ++
 .../devicetree/bindings/net/cavium-mix.txt         |  7 +++-
 .../devicetree/bindings/net/cavium-pip.txt         |  5 +++
 Documentation/devicetree/bindings/net/cpsw.txt     |  3 ++
 .../devicetree/bindings/net/davicom-dm9000.txt     |  4 ++
 .../devicetree/bindings/net/davinci_emac.txt       |  2 +
 Documentation/devicetree/bindings/net/dsa/dsa.txt  |  7 ++--
 .../devicetree/bindings/net/emac_rockchip.txt      |  4 ++
 Documentation/devicetree/bindings/net/ethernet.txt |  2 +
 .../devicetree/bindings/net/ezchip_enet.txt        |  6 +++
 Documentation/devicetree/bindings/net/fsl-fec.txt  |  4 ++
 .../devicetree/bindings/net/fsl-tsec-phy.txt       |  4 ++
 .../devicetree/bindings/net/hisilicon-femac.txt    |  3 ++
 .../bindings/net/hisilicon-hix5hd2-gmac.txt        |  3 ++
 .../devicetree/bindings/net/keystone-netcp.txt     |  9 ++--
 Documentation/devicetree/bindings/net/macb.txt     |  8 ++--
 .../devicetree/bindings/net/marvell-orion-net.txt  |  3 ++
 .../devicetree/bindings/net/marvell-pxa168.txt     |  3 ++
 .../devicetree/bindings/net/microchip,enc28j60.txt |  3 ++
 .../devicetree/bindings/net/microchip,lan78xx.txt  |  2 +
 .../devicetree/bindings/net/opencores-ethoc.txt    |  4 ++
 .../devicetree/bindings/net/oxnas-dwmac.txt        |  6 +++
 .../devicetree/bindings/net/qca,qca7000.txt        |  3 ++
 .../devicetree/bindings/net/samsung-sxgbe.txt      |  3 ++
 .../bindings/net/snps,dwc-qos-ethernet.txt         |  2 +
 .../devicetree/bindings/net/socfpga-dwmac.txt      |  4 ++
 .../bindings/net/socionext,uniphier-ave4.txt       |  3 ++
 .../devicetree/bindings/net/socionext-netsec.txt   |  2 +
 Documentation/devicetree/bindings/net/stmmac.txt   |  4 ++
 .../bindings/net/wireless/mediatek,mt76.txt        |  2 +
 .../devicetree/bindings/net/wireless/qca,ath9k.txt |  2 +
 .../devicetree/bindings/soc/fsl/cpm_qe/qe/ucc.txt  |  3 ++
 drivers/net/ethernet/cadence/macb_main.c           | 12 ++----
 drivers/net/ethernet/ti/davinci_emac.c             | 14 +++----
 drivers/of/of_net.c                                | 48 +++++++++++++++++++---
 39 files changed, 179 insertions(+), 34 deletions(-)

-- 
1.9.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/4] of_net: Add NVMEM support to of_get_mac_address
  2019-04-26 23:06 [PATCH 0/4] of_net: Add NVMEM support to of_get_mac_address Petr Štetiar
@ 2019-04-26 23:06 ` Petr Štetiar
  2019-04-27 16:28   ` Andrew Lunn
  2019-04-26 23:06 ` [PATCH 2/4] dt-bindings: doc: Reflect new NVMEM of_get_mac_address behaviour Petr Štetiar
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: Petr Štetiar @ 2019-04-26 23:06 UTC (permalink / raw)
  To: netdev, devicetree, linux-kernel, Andrew Lunn, Florian Fainelli,
	Heiner Kallweit, Rob Herring, Frank Rowand
  Cc: Srinivas Kandagatla, Maxime Ripard, Alban Bedel,
	Petr Štetiar, Felix Fietkau, John Crispin

Many embedded devices have information such as MAC addresses stored
inside NVMEMs like EEPROMs and so on. Currently there are only two
drivers in the tree which benefit from NVMEM bindings.

Adding support for NVMEM into every other driver would mean adding a lot
of repetitive code. This patch allows us to configure MAC addresses in
various devices like ethernet and wireless adapters directly from
of_get_mac_address, which is already used by almost every driver in the
tree.

Predecessor of this patch which used directly MTD layer has originated
in OpenWrt some time ago and supports already about 497 use cases in 357
device tree files.

Cc: Alban Bedel <albeu@free.fr>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: John Crispin <john@phrozen.org>
Signed-off-by: Petr Štetiar <ynezz@true.cz>
---
 drivers/of/of_net.c | 48 +++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 43 insertions(+), 5 deletions(-)

diff --git a/drivers/of/of_net.c b/drivers/of/of_net.c
index d820f3e..a3d6773 100644
--- a/drivers/of/of_net.c
+++ b/drivers/of/of_net.c
@@ -8,6 +8,7 @@
 #include <linux/etherdevice.h>
 #include <linux/kernel.h>
 #include <linux/of_net.h>
+#include <linux/of_platform.h>
 #include <linux/phy.h>
 #include <linux/export.h>
 
@@ -47,12 +48,45 @@ static const void *of_get_mac_addr(struct device_node *np, const char *name)
 	return NULL;
 }
 
+static const void *of_get_mac_addr_nvmem(struct device_node *np)
+{
+	int r;
+	u8 mac[ETH_ALEN];
+	struct property *pp;
+	struct platform_device *pdev = of_find_device_by_node(np);
+
+	if (!pdev)
+		return NULL;
+
+	r = nvmem_get_mac_address(&pdev->dev, &mac);
+	if (r < 0)
+		return NULL;
+
+	pp = kzalloc(sizeof(*pp), GFP_KERNEL);
+	if (!pp)
+		return NULL;
+
+	pp->name = "nvmem-mac-address";
+	pp->length = ETH_ALEN;
+	pp->value = kmemdup(mac, ETH_ALEN, GFP_KERNEL);
+	if (!pp->value || of_add_property(np, pp))
+		goto free;
+
+	return pp->value;
+free:
+	kfree(pp->value);
+	kfree(pp);
+
+	return NULL;
+}
+
 /**
- * Search the device tree for the best MAC address to use.  'mac-address' is
- * checked first, because that is supposed to contain to "most recent" MAC
- * address. If that isn't set, then 'local-mac-address' is checked next,
- * because that is the default address.  If that isn't set, then the obsolete
- * 'address' is checked, just in case we're using an old device tree.
+ * Search the device tree for the best MAC address to use. Check NVME first as
+ * it should contain the proper MAC address, then 'mac-address' is checked
+ * next, because that is supposed to contain to "most recent" MAC address. If
+ * that isn't set, then 'local-mac-address' is checked next, because that is
+ * the default address.  If that isn't set, then the obsolete 'address' is
+ * checked, just in case we're using an old device tree.
  *
  * Note that the 'address' property is supposed to contain a virtual address of
  * the register set, but some DTS files have redefined that property to be the
@@ -69,6 +103,10 @@ const void *of_get_mac_address(struct device_node *np)
 {
 	const void *addr;
 
+	addr = of_get_mac_addr_nvmem(np);
+	if (addr)
+		return addr;
+
 	addr = of_get_mac_addr(np, "mac-address");
 	if (addr)
 		return addr;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/4] dt-bindings: doc: Reflect new NVMEM of_get_mac_address behaviour
  2019-04-26 23:06 [PATCH 0/4] of_net: Add NVMEM support to of_get_mac_address Petr Štetiar
  2019-04-26 23:06 ` [PATCH 1/4] " Petr Štetiar
@ 2019-04-26 23:06 ` Petr Štetiar
  2019-04-27 16:31   ` Andrew Lunn
                     ` (2 more replies)
  2019-04-26 23:06 ` [PATCH 3/4] net: macb: Drop nvmem_get_mac_address usage Petr Štetiar
  2019-04-26 23:06 ` [PATCH 4/4] net: davinci_emac: " Petr Štetiar
  3 siblings, 3 replies; 11+ messages in thread
From: Petr Štetiar @ 2019-04-26 23:06 UTC (permalink / raw)
  To: netdev, devicetree, linux-kernel, David S. Miller, Rob Herring,
	Mark Rutland, Andrew Lunn, Vivien Didelot, Florian Fainelli,
	Heiko Stuebner, Fugang Duan, Claudiu Manoil, Yisen Zhuang,
	Salil Mehta, Woojung Huh, Microchip Linux Driver Support,
	Neil Armstrong, Kunihiko Hayashi, Masahiro Yamada, Jassi Brar,
	Maxime Coquelin, Alexandre Torgue, Kalle Valo, Matthias Brugger,
	Li Yang
  Cc: Heiner Kallweit, Frank Rowand, Srinivas Kandagatla,
	Maxime Ripard, Alban Bedel, Petr Štetiar, linux-arm-kernel,
	linux-rockchip, linux-oxnas, linux-stm32, linux-wireless,
	linux-mediatek, linuxppc-dev

As of_get_mac_address now supports NVMEM under the hood, we should
update the bindings documentation with the new nvmem-cell* properties.
While at it, fix also other missing properties supported by
of_get_mac_address.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
---
 Documentation/devicetree/bindings/net/altera_tse.txt             | 3 +++
 Documentation/devicetree/bindings/net/arc_emac.txt               | 4 ++++
 Documentation/devicetree/bindings/net/brcm,amac.txt              | 3 +++
 Documentation/devicetree/bindings/net/brcm,bcmgenet.txt          | 5 +++++
 Documentation/devicetree/bindings/net/brcm,systemport.txt        | 4 ++++
 Documentation/devicetree/bindings/net/cavium-mix.txt             | 7 ++++++-
 Documentation/devicetree/bindings/net/cavium-pip.txt             | 5 +++++
 Documentation/devicetree/bindings/net/cpsw.txt                   | 3 +++
 Documentation/devicetree/bindings/net/davicom-dm9000.txt         | 4 ++++
 Documentation/devicetree/bindings/net/davinci_emac.txt           | 2 ++
 Documentation/devicetree/bindings/net/dsa/dsa.txt                | 7 ++++---
 Documentation/devicetree/bindings/net/emac_rockchip.txt          | 4 ++++
 Documentation/devicetree/bindings/net/ethernet.txt               | 2 ++
 Documentation/devicetree/bindings/net/ezchip_enet.txt            | 6 ++++++
 Documentation/devicetree/bindings/net/fsl-fec.txt                | 4 ++++
 Documentation/devicetree/bindings/net/fsl-tsec-phy.txt           | 4 ++++
 Documentation/devicetree/bindings/net/hisilicon-femac.txt        | 3 +++
 Documentation/devicetree/bindings/net/hisilicon-hix5hd2-gmac.txt | 3 +++
 Documentation/devicetree/bindings/net/keystone-netcp.txt         | 9 ++++++---
 Documentation/devicetree/bindings/net/macb.txt                   | 8 ++++----
 Documentation/devicetree/bindings/net/marvell-orion-net.txt      | 3 +++
 Documentation/devicetree/bindings/net/marvell-pxa168.txt         | 3 +++
 Documentation/devicetree/bindings/net/microchip,enc28j60.txt     | 3 +++
 Documentation/devicetree/bindings/net/microchip,lan78xx.txt      | 2 ++
 Documentation/devicetree/bindings/net/opencores-ethoc.txt        | 4 ++++
 Documentation/devicetree/bindings/net/oxnas-dwmac.txt            | 6 ++++++
 Documentation/devicetree/bindings/net/qca,qca7000.txt            | 3 +++
 Documentation/devicetree/bindings/net/samsung-sxgbe.txt          | 3 +++
 Documentation/devicetree/bindings/net/snps,dwc-qos-ethernet.txt  | 2 ++
 Documentation/devicetree/bindings/net/socfpga-dwmac.txt          | 4 ++++
 .../devicetree/bindings/net/socionext,uniphier-ave4.txt          | 3 +++
 Documentation/devicetree/bindings/net/socionext-netsec.txt       | 2 ++
 Documentation/devicetree/bindings/net/stmmac.txt                 | 4 ++++
 Documentation/devicetree/bindings/net/wireless/mediatek,mt76.txt | 2 ++
 Documentation/devicetree/bindings/net/wireless/qca,ath9k.txt     | 2 ++
 Documentation/devicetree/bindings/soc/fsl/cpm_qe/qe/ucc.txt      | 3 +++
 36 files changed, 128 insertions(+), 11 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/altera_tse.txt b/Documentation/devicetree/bindings/net/altera_tse.txt
index 0e21df9..dbc2bb4 100644
--- a/Documentation/devicetree/bindings/net/altera_tse.txt
+++ b/Documentation/devicetree/bindings/net/altera_tse.txt
@@ -47,8 +47,11 @@ Required properties:
 	- device_type: Must be "ethernet-phy".
 
 Optional properties:
+- mac-address: See ethernet.txt in the same directory.
 - local-mac-address: See ethernet.txt in the same directory.
 - max-frame-size: See ethernet.txt in the same directory.
+- nvmem-cells: See ethernet.txt in the same directory.
+- nvmem-cell-names: See ethernet.txt in the same directory.
 
 Example:
 
diff --git a/Documentation/devicetree/bindings/net/arc_emac.txt b/Documentation/devicetree/bindings/net/arc_emac.txt
index c73a0e9..139204e 100644
--- a/Documentation/devicetree/bindings/net/arc_emac.txt
+++ b/Documentation/devicetree/bindings/net/arc_emac.txt
@@ -13,6 +13,10 @@ Optional properties:
   only if property "phy-reset-gpios" is available.  Missing the property
   will have the duration be 1 millisecond.  Numbers greater than 1000 are
   invalid and 1 millisecond will be used instead.
+- mac-address: See ethernet.txt in the same directory.
+- local-mac-address: See ethernet.txt in the same directory.
+- nvmem-cells: See ethernet.txt in the same directory.
+- nvmem-cell-names: See ethernet.txt in the same directory.
 
 Clock handling:
 The clock frequency is needed to calculate and set polling period of EMAC.
diff --git a/Documentation/devicetree/bindings/net/brcm,amac.txt b/Documentation/devicetree/bindings/net/brcm,amac.txt
index 0bfad65..a9b9514 100644
--- a/Documentation/devicetree/bindings/net/brcm,amac.txt
+++ b/Documentation/devicetree/bindings/net/brcm,amac.txt
@@ -18,6 +18,9 @@ Required properties:
 
 Optional properties:
 - mac-address:	See ethernet.txt file in the same directory
+- local-mac-address: See ethernet.txt in the same directory.
+- nvmem-cells: See ethernet.txt in the same directory.
+- nvmem-cell-names: See ethernet.txt in the same directory.
 
 Examples:
 
diff --git a/Documentation/devicetree/bindings/net/brcm,bcmgenet.txt b/Documentation/devicetree/bindings/net/brcm,bcmgenet.txt
index 3956af1..b7e2517 100644
--- a/Documentation/devicetree/bindings/net/brcm,bcmgenet.txt
+++ b/Documentation/devicetree/bindings/net/brcm,bcmgenet.txt
@@ -30,6 +30,11 @@ Optional properties:
   See Documentation/devicetree/bindings/net/fixed-link.txt for information on
   the property specifics
 
+- mac-address: See ethernet.txt in the same directory.
+- local-mac-address: See ethernet.txt in the same directory.
+- nvmem-cells: See ethernet.txt in the same directory.
+- nvmem-cell-names: See ethernet.txt in the same directory.
+
 Required child nodes:
 
 - mdio bus node: this node should always be present regardless of the PHY
diff --git a/Documentation/devicetree/bindings/net/brcm,systemport.txt b/Documentation/devicetree/bindings/net/brcm,systemport.txt
index 83f29e0..ce3c812 100644
--- a/Documentation/devicetree/bindings/net/brcm,systemport.txt
+++ b/Documentation/devicetree/bindings/net/brcm,systemport.txt
@@ -20,6 +20,10 @@ Optional properties:
 - systemport,num-tier1-arb: number of tier 1 arbiters, an integer
 - systemport,num-txq: number of HW transmit queues, an integer
 - systemport,num-rxq: number of HW receive queues, an integer
+- mac-address: See ethernet.txt in the same directory.
+- local-mac-address: See ethernet.txt in the same directory.
+- nvmem-cells: See ethernet.txt in the same directory.
+- nvmem-cell-names: See ethernet.txt in the same directory.
 
 Example:
 ethernet@f04a0000 {
diff --git a/Documentation/devicetree/bindings/net/cavium-mix.txt b/Documentation/devicetree/bindings/net/cavium-mix.txt
index 8d7c309..41bcc99 100644
--- a/Documentation/devicetree/bindings/net/cavium-mix.txt
+++ b/Documentation/devicetree/bindings/net/cavium-mix.txt
@@ -18,7 +18,12 @@ Properties:
 - interrupts: Two interrupt specifiers.  The first is the MIX
   interrupt routing and the second the routing for the AGL interrupts.
 
-- phy-handle: Optional, see ethernet.txt file in the same directory.
+Optional properties:
+- phy-handle: See ethernet.txt file in the same directory.
+- mac-address: See ethernet.txt in the same directory.
+- local-mac-address: See ethernet.txt in the same directory.
+- nvmem-cells: See ethernet.txt in the same directory.
+- nvmem-cell-names: See ethernet.txt in the same directory.
 
 Example:
 	ethernet@1070000100800 {
diff --git a/Documentation/devicetree/bindings/net/cavium-pip.txt b/Documentation/devicetree/bindings/net/cavium-pip.txt
index e3b8fe71..4b1c3d9 100644
--- a/Documentation/devicetree/bindings/net/cavium-pip.txt
+++ b/Documentation/devicetree/bindings/net/cavium-pip.txt
@@ -43,6 +43,11 @@ Properties for PIP port which is a child the PIP interface:
 - tx-delay: Delay value for RGMII transmit clock. Optional. Disabled if 0.
   Value range is 1-31, and mapping to the actual delay varies depending on HW.
 
+- mac-address: See ethernet.txt in the same directory.
+- local-mac-address: See ethernet.txt in the same directory.
+- nvmem-cells: See ethernet.txt in the same directory.
+- nvmem-cell-names: See ethernet.txt in the same directory.
+
 Example:
 
 	pip@11800a0000000 {
diff --git a/Documentation/devicetree/bindings/net/cpsw.txt b/Documentation/devicetree/bindings/net/cpsw.txt
index 3264e19..248f7df 100644
--- a/Documentation/devicetree/bindings/net/cpsw.txt
+++ b/Documentation/devicetree/bindings/net/cpsw.txt
@@ -50,6 +50,9 @@ Required properties:
 Optional properties:
 - dual_emac_res_vlan	: Specifies VID to be used to segregate the ports
 - mac-address		: See ethernet.txt file in the same directory
+- local-mac-address: See ethernet.txt in the same directory.
+- nvmem-cells: See ethernet.txt in the same directory.
+- nvmem-cell-names: See ethernet.txt in the same directory.
 - phy_id		: Specifies slave phy id (deprecated, use phy-handle)
 - phy-handle		: See ethernet.txt file in the same directory
 
diff --git a/Documentation/devicetree/bindings/net/davicom-dm9000.txt b/Documentation/devicetree/bindings/net/davicom-dm9000.txt
index 64c159e..ce60d35 100644
--- a/Documentation/devicetree/bindings/net/davicom-dm9000.txt
+++ b/Documentation/devicetree/bindings/net/davicom-dm9000.txt
@@ -12,6 +12,10 @@ Optional properties:
 - davicom,ext-phy : Use external PHY
 - reset-gpios : phandle of gpio that will be used to reset chip during probe
 - vcc-supply : phandle of regulator that will be used to enable power to chip
+- mac-address: See ethernet.txt in the same directory.
+- local-mac-address: See ethernet.txt in the same directory.
+- nvmem-cells: See ethernet.txt in the same directory.
+- nvmem-cell-names: See ethernet.txt in the same directory.
 
 Example:
 
diff --git a/Documentation/devicetree/bindings/net/davinci_emac.txt b/Documentation/devicetree/bindings/net/davinci_emac.txt
index ca83dcc..c953945 100644
--- a/Documentation/devicetree/bindings/net/davinci_emac.txt
+++ b/Documentation/devicetree/bindings/net/davinci_emac.txt
@@ -20,6 +20,8 @@ Required properties:
 Optional properties:
 - phy-handle: See ethernet.txt file in the same directory.
               If absent, davinci_emac driver defaults to 100/FULL.
+- mac-address: See ethernet.txt in the same directory.
+- local-mac-address: See ethernet.txt in the same directory.
 - nvmem-cells: phandle, reference to an nvmem node for the MAC address
 - nvmem-cell-names: string, should be "mac-address" if nvmem is to be used
 - ti,davinci-rmii-en: 1 byte, 1 means use RMII
diff --git a/Documentation/devicetree/bindings/net/dsa/dsa.txt b/Documentation/devicetree/bindings/net/dsa/dsa.txt
index d66a529..9e2f0fa 100644
--- a/Documentation/devicetree/bindings/net/dsa/dsa.txt
+++ b/Documentation/devicetree/bindings/net/dsa/dsa.txt
@@ -71,9 +71,10 @@ properties, described in binding documents:
 			  Documentation/devicetree/bindings/net/fixed-link.txt
 			  for details.
 
-- local-mac-address	: See
-			  Documentation/devicetree/bindings/net/ethernet.txt
-			  for details.
+- mac-address: See ethernet.txt in the same directory.
+- local-mac-address: See ethernet.txt in the same directory.
+- nvmem-cells: See ethernet.txt in the same directory.
+- nvmem-cell-names: See ethernet.txt in the same directory.
 
 Example
 
diff --git a/Documentation/devicetree/bindings/net/emac_rockchip.txt b/Documentation/devicetree/bindings/net/emac_rockchip.txt
index 05bd7da..a84944a 100644
--- a/Documentation/devicetree/bindings/net/emac_rockchip.txt
+++ b/Documentation/devicetree/bindings/net/emac_rockchip.txt
@@ -14,6 +14,10 @@ Required properties:
 
 Optional properties:
 - phy-supply: phandle to a regulator if the PHY needs one
+- mac-address: See ethernet.txt in the same directory.
+- local-mac-address: See ethernet.txt in the same directory.
+- nvmem-cells: See ethernet.txt in the same directory.
+- nvmem-cell-names: See ethernet.txt in the same directory.
 
 Clock handling:
 - clocks: Must contain an entry for each entry in clock-names.
diff --git a/Documentation/devicetree/bindings/net/ethernet.txt b/Documentation/devicetree/bindings/net/ethernet.txt
index 2974e63..1e2bc9a 100644
--- a/Documentation/devicetree/bindings/net/ethernet.txt
+++ b/Documentation/devicetree/bindings/net/ethernet.txt
@@ -10,6 +10,8 @@ Documentation/devicetree/bindings/phy/phy-bindings.txt.
   the boot program; should be used in cases where the MAC address assigned to
   the device by the boot program is different from the "local-mac-address"
   property;
+- nvmem-cells: phandle, reference to an nvmem node for the MAC address
+- nvmem-cell-names: string, should be "mac-address" if nvmem is to be used
 - max-speed: number, specifies maximum speed in Mbit/s supported by the device;
 - max-frame-size: number, maximum transfer unit (IEEE defined MTU), rather than
   the maximum frame size (there's contradiction in the Devicetree
diff --git a/Documentation/devicetree/bindings/net/ezchip_enet.txt b/Documentation/devicetree/bindings/net/ezchip_enet.txt
index 4e29b2b..f928b92 100644
--- a/Documentation/devicetree/bindings/net/ezchip_enet.txt
+++ b/Documentation/devicetree/bindings/net/ezchip_enet.txt
@@ -5,6 +5,12 @@ Required properties:
 - reg: Address and length of the register set for the device
 - interrupts: Should contain the ENET interrupt
 
+Optional properties:
+- mac-address: See ethernet.txt in the same directory.
+- local-mac-address: See ethernet.txt in the same directory.
+- nvmem-cells: See ethernet.txt in the same directory.
+- nvmem-cell-names: See ethernet.txt in the same directory.
+
 Examples:
 
 	ethernet@f0003000 {
diff --git a/Documentation/devicetree/bindings/net/fsl-fec.txt b/Documentation/devicetree/bindings/net/fsl-fec.txt
index 2d41fb9..f2099f0 100644
--- a/Documentation/devicetree/bindings/net/fsl-fec.txt
+++ b/Documentation/devicetree/bindings/net/fsl-fec.txt
@@ -46,6 +46,10 @@ Optional properties:
   tx/rx queues 1 and 2. "int0" will be used for queue 0 and ENET_MII interrupts.
   For imx6sx, "int0" handles all 3 queues and ENET_MII. "pps" is for the pulse
   per second interrupt associated with 1588 precision time protocol(PTP).
+- mac-address: See ethernet.txt in the same directory.
+- local-mac-address: See ethernet.txt in the same directory.
+- nvmem-cells: See ethernet.txt in the same directory.
+- nvmem-cell-names: See ethernet.txt in the same directory.
 
 
 Optional subnodes:
diff --git a/Documentation/devicetree/bindings/net/fsl-tsec-phy.txt b/Documentation/devicetree/bindings/net/fsl-tsec-phy.txt
index 047bdf7..6bc9a68 100644
--- a/Documentation/devicetree/bindings/net/fsl-tsec-phy.txt
+++ b/Documentation/devicetree/bindings/net/fsl-tsec-phy.txt
@@ -71,6 +71,10 @@ Properties:
     in the L2.
   - rx-stash-idx : Denotes the index of the first byte from the received
     buffer to stash in the L2.
+  - mac-address: See ethernet.txt in the same directory.
+  - local-mac-address: See ethernet.txt in the same directory.
+  - nvmem-cells: See ethernet.txt in the same directory.
+  - nvmem-cell-names: See ethernet.txt in the same directory.
 
 Example:
 	ethernet@24000 {
diff --git a/Documentation/devicetree/bindings/net/hisilicon-femac.txt b/Documentation/devicetree/bindings/net/hisilicon-femac.txt
index d11af5e..e28bb6e 100644
--- a/Documentation/devicetree/bindings/net/hisilicon-femac.txt
+++ b/Documentation/devicetree/bindings/net/hisilicon-femac.txt
@@ -15,6 +15,9 @@ Required properties:
 - reset-names: should contain the reset signal name "mac"(required)
 	and "phy"(optional).
 - mac-address: see ethernet.txt [1].
+- local-mac-address: see ethernet.txt [1].
+- nvmem-cells: see ethernet.txt [1].
+- nvmem-cell-names: see ethernet.txt [1].
 - phy-mode: see ethernet.txt [1].
 - phy-handle: see ethernet.txt [1].
 - hisilicon,phy-reset-delays-us: triplet of delays if PHY reset signal given.
diff --git a/Documentation/devicetree/bindings/net/hisilicon-hix5hd2-gmac.txt b/Documentation/devicetree/bindings/net/hisilicon-hix5hd2-gmac.txt
index eea73ad..dddd408 100644
--- a/Documentation/devicetree/bindings/net/hisilicon-hix5hd2-gmac.txt
+++ b/Documentation/devicetree/bindings/net/hisilicon-hix5hd2-gmac.txt
@@ -19,6 +19,9 @@ Required properties:
 - phy-mode: see ethernet.txt [1].
 - phy-handle: see ethernet.txt [1].
 - mac-address: see ethernet.txt [1].
+- local-mac-address: see ethernet.txt [1].
+- nvmem-cells: see ethernet.txt [1].
+- nvmem-cell-names: see ethernet.txt [1].
 - clocks: clock phandle and specifier pair.
 - clock-names: contain the clock name "mac_core"(required) and "mac_ifc"(optional).
 - resets: should contain the phandle to the MAC core reset signal(optional),
diff --git a/Documentation/devicetree/bindings/net/keystone-netcp.txt b/Documentation/devicetree/bindings/net/keystone-netcp.txt
index 04ba1dc..61e8019 100644
--- a/Documentation/devicetree/bindings/net/keystone-netcp.txt
+++ b/Documentation/devicetree/bindings/net/keystone-netcp.txt
@@ -137,9 +137,12 @@ Optional properties:
 		when it obtains the mac address from efuse.
 - local-mac-address:	the driver is designed to use the of_get_mac_address api
 			only if efuse-mac is 0. When efuse-mac is 0, the MAC
-			address is obtained from local-mac-address. If this
-			attribute is not present, then the driver will use a
-			random MAC address.
+			address is obtained from nvmem-cells, mac-address and
+			local-mac-address. If any of this attributes is not present,
+			then the driver will use a random MAC address.
+- mac-address: See ethernet.txt in the same directory.
+- nvmem-cells: See ethernet.txt in the same directory.
+- nvmem-cell-names: See ethernet.txt in the same directory.
 - "netcp-device label":	phandle to the device specification for each of NetCP
 			sub-module attached to this interface.
 
diff --git a/Documentation/devicetree/bindings/net/macb.txt b/Documentation/devicetree/bindings/net/macb.txt
index 8b80515..92c5642 100644
--- a/Documentation/devicetree/bindings/net/macb.txt
+++ b/Documentation/devicetree/bindings/net/macb.txt
@@ -26,15 +26,15 @@ Required properties:
 	Optional elements: 'tsu_clk'
 - clocks: Phandles to input clocks.
 
-Optional properties:
-- nvmem-cells: phandle, reference to an nvmem node for the MAC address
-- nvmem-cell-names: string, should be "mac-address" if nvmem is to be used
-
 Optional properties for PHY child node:
 - reset-gpios : Should specify the gpio for phy reset
 - magic-packet : If present, indicates that the hardware supports waking
   up via magic packet.
 - phy-handle : see ethernet.txt file in the same directory
+- mac-address: See ethernet.txt in the same directory.
+- local-mac-address: See ethernet.txt in the same directory.
+- nvmem-cells: See ethernet.txt in the same directory.
+- nvmem-cell-names: See ethernet.txt in the same directory.
 
 Examples:
 
diff --git a/Documentation/devicetree/bindings/net/marvell-orion-net.txt b/Documentation/devicetree/bindings/net/marvell-orion-net.txt
index 6fd988c..2e0c06f 100644
--- a/Documentation/devicetree/bindings/net/marvell-orion-net.txt
+++ b/Documentation/devicetree/bindings/net/marvell-orion-net.txt
@@ -37,6 +37,9 @@ Required port properties:
  - reg: port number relative to ethernet controller, shall be 0, 1, or 2.
  - interrupts: port interrupt.
  - local-mac-address: See ethernet.txt file in the same directory.
+ - mac-address: See ethernet.txt in the same directory.
+ - nvmem-cells: See ethernet.txt in the same directory.
+ - nvmem-cell-names: See ethernet.txt in the same directory.
 
 Optional port properties:
  - marvell,tx-queue-size: size of the transmit ring buffer.
diff --git a/Documentation/devicetree/bindings/net/marvell-pxa168.txt b/Documentation/devicetree/bindings/net/marvell-pxa168.txt
index 845a148..5eaafa2 100644
--- a/Documentation/devicetree/bindings/net/marvell-pxa168.txt
+++ b/Documentation/devicetree/bindings/net/marvell-pxa168.txt
@@ -12,6 +12,9 @@ Optional properties:
 - #size-cells: must be 0 when using sub-nodes.
 - phy-handle: see ethernet.txt file in the same directory.
 - local-mac-address: see ethernet.txt file in the same directory.
+- mac-address: See ethernet.txt in the same directory.
+- nvmem-cells: See ethernet.txt in the same directory.
+- nvmem-cell-names: See ethernet.txt in the same directory.
 
 Sub-nodes:
 Each PHY can be represented as a sub-node. This is not mandatory.
diff --git a/Documentation/devicetree/bindings/net/microchip,enc28j60.txt b/Documentation/devicetree/bindings/net/microchip,enc28j60.txt
index 24626e0..c06923d 100644
--- a/Documentation/devicetree/bindings/net/microchip,enc28j60.txt
+++ b/Documentation/devicetree/bindings/net/microchip,enc28j60.txt
@@ -22,6 +22,9 @@ Optional properties:
   According to the ENC28J80 datasheet, the chip allows a maximum of 20 MHz, however,
   board designs may need to limit this value.
 - local-mac-address: See ethernet.txt in the same directory.
+- mac-address: See ethernet.txt in the same directory.
+- nvmem-cells: See ethernet.txt in the same directory.
+- nvmem-cell-names: See ethernet.txt in the same directory.
 
 
 Example (for NXP i.MX28 with pin control stuff for GPIO irq):
diff --git a/Documentation/devicetree/bindings/net/microchip,lan78xx.txt b/Documentation/devicetree/bindings/net/microchip,lan78xx.txt
index 76786a0..a31c475 100644
--- a/Documentation/devicetree/bindings/net/microchip,lan78xx.txt
+++ b/Documentation/devicetree/bindings/net/microchip,lan78xx.txt
@@ -10,6 +10,8 @@ Required properties:
 Optional properties:
 - local-mac-address:   see ethernet.txt
 - mac-address:         see ethernet.txt
+- nvmem-cells: See ethernet.txt in the same directory.
+- nvmem-cell-names: See ethernet.txt in the same directory.
 
 Optional properties of the embedded PHY:
 - microchip,led-modes: a 0..4 element vector, with each element configuring
diff --git a/Documentation/devicetree/bindings/net/opencores-ethoc.txt b/Documentation/devicetree/bindings/net/opencores-ethoc.txt
index 2dc127c..e7969dc 100644
--- a/Documentation/devicetree/bindings/net/opencores-ethoc.txt
+++ b/Documentation/devicetree/bindings/net/opencores-ethoc.txt
@@ -10,6 +10,10 @@ Required properties:
 Optional properties:
 - clocks: phandle to refer to the clk used as per
   Documentation/devicetree/bindings/clock/clock-bindings.txt
+- mac-address: See ethernet.txt in the same directory.
+- local-mac-address: See ethernet.txt in the same directory.
+- nvmem-cells: See ethernet.txt in the same directory.
+- nvmem-cell-names: See ethernet.txt in the same directory.
 
 Examples:
 
diff --git a/Documentation/devicetree/bindings/net/oxnas-dwmac.txt b/Documentation/devicetree/bindings/net/oxnas-dwmac.txt
index d7117a2..7f43451 100644
--- a/Documentation/devicetree/bindings/net/oxnas-dwmac.txt
+++ b/Documentation/devicetree/bindings/net/oxnas-dwmac.txt
@@ -17,6 +17,12 @@ Required properties on all platforms:
 
 - oxsemi,sys-ctrl: a phandle to the system controller syscon node
 
+Optional properties:
+- mac-address: See ethernet.txt in the same directory.
+- local-mac-address: See ethernet.txt in the same directory.
+- nvmem-cells: See ethernet.txt in the same directory.
+- nvmem-cell-names: See ethernet.txt in the same directory.
+
 Example :
 
 etha: ethernet@40400000 {
diff --git a/Documentation/devicetree/bindings/net/qca,qca7000.txt b/Documentation/devicetree/bindings/net/qca,qca7000.txt
index e4a8a51..5a2627e 100644
--- a/Documentation/devicetree/bindings/net/qca,qca7000.txt
+++ b/Documentation/devicetree/bindings/net/qca,qca7000.txt
@@ -24,6 +24,9 @@ Optional properties:
 		      are invalid. Missing the property will set the SPI
 		      frequency to 8000000 Hertz.
 - local-mac-address : see ./ethernet.txt
+- mac-address: See ethernet.txt in the same directory.
+- nvmem-cells: See ethernet.txt in the same directory.
+- nvmem-cell-names: See ethernet.txt in the same directory.
 - qca,legacy-mode   : Set the SPI data transfer of the QCA7000 to legacy mode.
 		      In this mode the SPI master must toggle the chip select
 		      between each data word. In burst mode these gaps aren't
diff --git a/Documentation/devicetree/bindings/net/samsung-sxgbe.txt b/Documentation/devicetree/bindings/net/samsung-sxgbe.txt
index 46e5911..94c12b4 100644
--- a/Documentation/devicetree/bindings/net/samsung-sxgbe.txt
+++ b/Documentation/devicetree/bindings/net/samsung-sxgbe.txt
@@ -22,6 +22,9 @@ Required properties:
 
 Optional properties:
 - mac-address: 6 bytes, mac address
+- local-mac-address: See ethernet.txt in the same directory.
+- nvmem-cells: See ethernet.txt in the same directory.
+- nvmem-cell-names: See ethernet.txt in the same directory.
 - max-frame-size: Maximum Transfer Unit (IEEE defined MTU), rather
 		  than the maximum frame size.
 
diff --git a/Documentation/devicetree/bindings/net/snps,dwc-qos-ethernet.txt b/Documentation/devicetree/bindings/net/snps,dwc-qos-ethernet.txt
index 36f1aef..881848f 100644
--- a/Documentation/devicetree/bindings/net/snps,dwc-qos-ethernet.txt
+++ b/Documentation/devicetree/bindings/net/snps,dwc-qos-ethernet.txt
@@ -105,6 +105,8 @@ Optional properties:
 - dma-coherent: Present if dma operations are coherent
 - mac-address: See ethernet.txt in the same directory
 - local-mac-address: See ethernet.txt in the same directory
+- nvmem-cells: See ethernet.txt in the same directory.
+- nvmem-cell-names: See ethernet.txt in the same directory.
 - phy-reset-gpios: Phandle and specifier for any GPIO used to reset the PHY.
   See ../gpio/gpio.txt.
 - snps,en-lpi: If present it enables use of the AXI low-power interface
diff --git a/Documentation/devicetree/bindings/net/socfpga-dwmac.txt b/Documentation/devicetree/bindings/net/socfpga-dwmac.txt
index 17d6819..29ffd21 100644
--- a/Documentation/devicetree/bindings/net/socfpga-dwmac.txt
+++ b/Documentation/devicetree/bindings/net/socfpga-dwmac.txt
@@ -19,6 +19,10 @@ altr,emac-splitter: Should be the phandle to the emac splitter soft IP node if
 		DWMAC controller is connected emac splitter.
 phy-mode: The phy mode the ethernet operates in
 altr,sgmii-to-sgmii-converter: phandle to the TSE SGMII converter
+mac-address: See ethernet.txt in the same directory.
+local-mac-address: See ethernet.txt in the same directory.
+nvmem-cells: See ethernet.txt in the same directory.
+nvmem-cell-names: See ethernet.txt in the same directory.
 
 This device node has additional phandle dependency, the sgmii converter:
 
diff --git a/Documentation/devicetree/bindings/net/socionext,uniphier-ave4.txt b/Documentation/devicetree/bindings/net/socionext,uniphier-ave4.txt
index fc8f017..13daf31 100644
--- a/Documentation/devicetree/bindings/net/socionext,uniphier-ave4.txt
+++ b/Documentation/devicetree/bindings/net/socionext,uniphier-ave4.txt
@@ -33,6 +33,9 @@ Required properties:
 
 Optional properties:
  - local-mac-address: See ethernet.txt in the same directory.
+ - mac-address: See ethernet.txt in the same directory.
+ - nvmem-cells: See ethernet.txt in the same directory.
+ - nvmem-cell-names: See ethernet.txt in the same directory.
 
 Required subnode:
  - mdio: A container for child nodes representing phy nodes.
diff --git a/Documentation/devicetree/bindings/net/socionext-netsec.txt b/Documentation/devicetree/bindings/net/socionext-netsec.txt
index 0cff94f..c5ac7fc 100644
--- a/Documentation/devicetree/bindings/net/socionext-netsec.txt
+++ b/Documentation/devicetree/bindings/net/socionext-netsec.txt
@@ -28,6 +28,8 @@ Optional properties: (See ethernet.txt file in the same directory)
 	accesses performed by the device are cache coherent.
 - local-mac-address: See ethernet.txt in the same directory.
 - mac-address: See ethernet.txt in the same directory.
+- nvmem-cells: See ethernet.txt in the same directory.
+- nvmem-cell-names: See ethernet.txt in the same directory.
 - max-speed: See ethernet.txt in the same directory.
 - max-frame-size: See ethernet.txt in the same directory.
 
diff --git a/Documentation/devicetree/bindings/net/stmmac.txt b/Documentation/devicetree/bindings/net/stmmac.txt
index cb69406..0a0519a 100644
--- a/Documentation/devicetree/bindings/net/stmmac.txt
+++ b/Documentation/devicetree/bindings/net/stmmac.txt
@@ -21,6 +21,10 @@ Required properties:
 	The 3rd cell is reset post-delay in micro seconds.
 
 Optional properties:
+- mac-address: See ethernet.txt in the same directory.
+- local-mac-address: See ethernet.txt in the same directory.
+- nvmem-cells: See ethernet.txt in the same directory.
+- nvmem-cell-names: See ethernet.txt in the same directory.
 - resets: Should contain a phandle to the STMMAC reset signal, if any
 - reset-names: Should contain the reset signal name "stmmaceth", if a
 	reset phandle is given
diff --git a/Documentation/devicetree/bindings/net/wireless/mediatek,mt76.txt b/Documentation/devicetree/bindings/net/wireless/mediatek,mt76.txt
index 7b9a776..bd5cc92 100644
--- a/Documentation/devicetree/bindings/net/wireless/mediatek,mt76.txt
+++ b/Documentation/devicetree/bindings/net/wireless/mediatek,mt76.txt
@@ -15,6 +15,8 @@ Optional properties:
 
 - mac-address: See ethernet.txt in the parent directory
 - local-mac-address: See ethernet.txt in the parent directory
+- nvmem-cells: See ethernet.txt in the parent directory.
+- nvmem-cell-names: See ethernet.txt in the parent directory.
 - ieee80211-freq-limit: See ieee80211.txt
 - mediatek,mtd-eeprom: Specify a MTD partition + offset containing EEPROM data
 
diff --git a/Documentation/devicetree/bindings/net/wireless/qca,ath9k.txt b/Documentation/devicetree/bindings/net/wireless/qca,ath9k.txt
index b7396c8..77074a0 100644
--- a/Documentation/devicetree/bindings/net/wireless/qca,ath9k.txt
+++ b/Documentation/devicetree/bindings/net/wireless/qca,ath9k.txt
@@ -36,6 +36,8 @@ Optional properties:
 			kernel firmware loader).
 - mac-address: See ethernet.txt in the parent directory
 - local-mac-address: See ethernet.txt in the parent directory
+- nvmem-cells: See ethernet.txt in the parent directory.
+- nvmem-cell-names: See ethernet.txt in the parent directory.
 
 
 In this example, the node is defined as child node of the PCI controller:
diff --git a/Documentation/devicetree/bindings/soc/fsl/cpm_qe/qe/ucc.txt b/Documentation/devicetree/bindings/soc/fsl/cpm_qe/qe/ucc.txt
index 5efb7ac..7fee9d5 100644
--- a/Documentation/devicetree/bindings/soc/fsl/cpm_qe/qe/ucc.txt
+++ b/Documentation/devicetree/bindings/soc/fsl/cpm_qe/qe/ucc.txt
@@ -43,6 +43,9 @@ to check for the new properties first.
 
 Required properties for network device_type:
 - mac-address : list of bytes representing the ethernet address.
+- local-mac-address: See ethernet.txt in the same directory.
+- nvmem-cells: See ethernet.txt in the same directory.
+- nvmem-cell-names: See ethernet.txt in the same directory.
 - phy-handle : The phandle for the PHY connected to this controller.
 
 Recommended properties:
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/4] net: macb: Drop nvmem_get_mac_address usage
  2019-04-26 23:06 [PATCH 0/4] of_net: Add NVMEM support to of_get_mac_address Petr Štetiar
  2019-04-26 23:06 ` [PATCH 1/4] " Petr Štetiar
  2019-04-26 23:06 ` [PATCH 2/4] dt-bindings: doc: Reflect new NVMEM of_get_mac_address behaviour Petr Štetiar
@ 2019-04-26 23:06 ` Petr Štetiar
  2019-04-27 16:44   ` Andrew Lunn
  2019-04-26 23:06 ` [PATCH 4/4] net: davinci_emac: " Petr Štetiar
  3 siblings, 1 reply; 11+ messages in thread
From: Petr Štetiar @ 2019-04-26 23:06 UTC (permalink / raw)
  To: netdev, devicetree, linux-kernel, Nicolas Ferre, David S. Miller
  Cc: Andrew Lunn, Florian Fainelli, Heiner Kallweit, Rob Herring,
	Frank Rowand, Srinivas Kandagatla, Maxime Ripard, Alban Bedel,
	Petr Štetiar

of_get_mac_address now uses NVMEM under the hood, so it's not necessary
to call it manually anymore.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
---
 drivers/net/ethernet/cadence/macb_main.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 3da2795..1b98bc8 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -4172,16 +4172,10 @@ static int macb_probe(struct platform_device *pdev)
 		bp->rx_intr_mask |= MACB_BIT(RXUBR);
 
 	mac = of_get_mac_address(np);
-	if (mac) {
+	if (mac)
 		ether_addr_copy(bp->dev->dev_addr, mac);
-	} else {
-		err = nvmem_get_mac_address(&pdev->dev, bp->dev->dev_addr);
-		if (err) {
-			if (err == -EPROBE_DEFER)
-				goto err_out_free_netdev;
-			macb_get_hwaddr(bp);
-		}
-	}
+	else
+		macb_get_hwaddr(bp);
 
 	err = of_get_phy_mode(np);
 	if (err < 0) {
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 4/4] net: davinci_emac: Drop nvmem_get_mac_address usage
  2019-04-26 23:06 [PATCH 0/4] of_net: Add NVMEM support to of_get_mac_address Petr Štetiar
                   ` (2 preceding siblings ...)
  2019-04-26 23:06 ` [PATCH 3/4] net: macb: Drop nvmem_get_mac_address usage Petr Štetiar
@ 2019-04-26 23:06 ` Petr Štetiar
  2019-04-27 16:54   ` Andrew Lunn
  3 siblings, 1 reply; 11+ messages in thread
From: Petr Štetiar @ 2019-04-26 23:06 UTC (permalink / raw)
  To: netdev, devicetree, linux-kernel, Grygorii Strashko, David S. Miller
  Cc: Andrew Lunn, Florian Fainelli, Heiner Kallweit, Rob Herring,
	Frank Rowand, Srinivas Kandagatla, Maxime Ripard, Alban Bedel,
	Petr Štetiar, linux-omap

of_get_mac_address now uses NVMEM under the hood, so it's not necessary
to call it manually anymore.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
---
 drivers/net/ethernet/ti/davinci_emac.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
index 57450b1..c1a5526 100644
--- a/drivers/net/ethernet/ti/davinci_emac.c
+++ b/drivers/net/ethernet/ti/davinci_emac.c
@@ -1912,15 +1912,11 @@ static int davinci_emac_probe(struct platform_device *pdev)
 		ether_addr_copy(ndev->dev_addr, priv->mac_addr);
 
 	if (!is_valid_ether_addr(priv->mac_addr)) {
-		/* Try nvmem if MAC wasn't passed over pdata or DT. */
-		rc = nvmem_get_mac_address(&pdev->dev, priv->mac_addr);
-		if (rc) {
-			/* Use random MAC if still none obtained. */
-			eth_hw_addr_random(ndev);
-			memcpy(priv->mac_addr, ndev->dev_addr, ndev->addr_len);
-			dev_warn(&pdev->dev, "using random MAC addr: %pM\n",
-				 priv->mac_addr);
-		}
+		/* Use random MAC if still none obtained. */
+		eth_hw_addr_random(ndev);
+		memcpy(priv->mac_addr, ndev->dev_addr, ndev->addr_len);
+		dev_warn(&pdev->dev, "using random MAC addr: %pM\n",
+			 priv->mac_addr);
 	}
 
 	ndev->netdev_ops = &emac_netdev_ops;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/4] of_net: Add NVMEM support to of_get_mac_address
  2019-04-26 23:06 ` [PATCH 1/4] " Petr Štetiar
@ 2019-04-27 16:28   ` Andrew Lunn
  0 siblings, 0 replies; 11+ messages in thread
From: Andrew Lunn @ 2019-04-27 16:28 UTC (permalink / raw)
  To: Petr Štetiar
  Cc: netdev, devicetree, linux-kernel, Florian Fainelli,
	Heiner Kallweit, Rob Herring, Frank Rowand, Srinivas Kandagatla,
	Maxime Ripard, Alban Bedel, Felix Fietkau, John Crispin

>  /**
> - * Search the device tree for the best MAC address to use.  'mac-address' is
> - * checked first, because that is supposed to contain to "most recent" MAC
> - * address. If that isn't set, then 'local-mac-address' is checked next,
> - * because that is the default address.  If that isn't set, then the obsolete
> - * 'address' is checked, just in case we're using an old device tree.
> + * Search the device tree for the best MAC address to use. Check NVME first as
> + * it should contain the proper MAC address, then 'mac-address' is checked
> + * next, because that is supposed to contain to "most recent" MAC address. If
> + * that isn't set, then 'local-mac-address' is checked next, because that is
> + * the default address.  If that isn't set, then the obsolete 'address' is
> + * checked, just in case we're using an old device tree.

Hi Petr

I'm not sure this is the correct order. I would actually put NVMEM
after mac-address and local-mac-address. These are well established
and used. We don't want to break existing boards with a new
property. By putting NVMEM later, in order to make it used, any
existing mac-address and local-mac-address need to be removed, making
the developers actually think about what they are doing.

	Andrew

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/4] dt-bindings: doc: Reflect new NVMEM of_get_mac_address behaviour
  2019-04-26 23:06 ` [PATCH 2/4] dt-bindings: doc: Reflect new NVMEM of_get_mac_address behaviour Petr Štetiar
@ 2019-04-27 16:31   ` Andrew Lunn
  2019-04-27 16:39   ` Andrew Lunn
  2019-04-27 16:56   ` Florian Fainelli
  2 siblings, 0 replies; 11+ messages in thread
From: Andrew Lunn @ 2019-04-27 16:31 UTC (permalink / raw)
  To: Petr Štetiar
  Cc: netdev, devicetree, linux-kernel, David S. Miller, Rob Herring,
	Mark Rutland, Vivien Didelot, Florian Fainelli, Heiko Stuebner,
	Fugang Duan, Claudiu Manoil, Yisen Zhuang, Salil Mehta,
	Woojung Huh, Microchip Linux Driver Support, Neil Armstrong,
	Kunihiko Hayashi, Masahiro Yamada, Jassi Brar, Maxime Coquelin,
	Alexandre Torgue, Kalle Valo, Matthias Brugger, Li Yang,
	Heiner Kallweit, Frank Rowand, Srinivas Kandagatla,
	Maxime Ripard, Alban Bedel, linux-arm-kernel, linux-rockchip,
	linux-oxnas, linux-stm32, linux-wireless, linux-mediatek,
	linuxppc-dev

> diff --git a/Documentation/devicetree/bindings/net/ethernet.txt b/Documentation/devicetree/bindings/net/ethernet.txt
> index 2974e63..1e2bc9a 100644
> --- a/Documentation/devicetree/bindings/net/ethernet.txt
> +++ b/Documentation/devicetree/bindings/net/ethernet.txt
> @@ -10,6 +10,8 @@ Documentation/devicetree/bindings/phy/phy-bindings.txt.
>    the boot program; should be used in cases where the MAC address assigned to
>    the device by the boot program is different from the "local-mac-address"
>    property;
> +- nvmem-cells: phandle, reference to an nvmem node for the MAC address
> +- nvmem-cell-names: string, should be "mac-address" if nvmem is to be used

You put the new values after local-mac-address and mac-address. That
suggests they are of lower priority. That conflicts with the current
patch. If you think NVMEM should take priority, please put the
properties first.

	   Andrew

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/4] dt-bindings: doc: Reflect new NVMEM of_get_mac_address behaviour
  2019-04-26 23:06 ` [PATCH 2/4] dt-bindings: doc: Reflect new NVMEM of_get_mac_address behaviour Petr Štetiar
  2019-04-27 16:31   ` Andrew Lunn
@ 2019-04-27 16:39   ` Andrew Lunn
  2019-04-27 16:56   ` Florian Fainelli
  2 siblings, 0 replies; 11+ messages in thread
From: Andrew Lunn @ 2019-04-27 16:39 UTC (permalink / raw)
  To: Petr Štetiar
  Cc: netdev, devicetree, linux-kernel, David S. Miller, Rob Herring,
	Mark Rutland, Vivien Didelot, Florian Fainelli, Heiko Stuebner,
	Fugang Duan, Claudiu Manoil, Yisen Zhuang, Salil Mehta,
	Woojung Huh, Microchip Linux Driver Support, Neil Armstrong,
	Kunihiko Hayashi, Masahiro Yamada, Jassi Brar, Maxime Coquelin,
	Alexandre Torgue, Kalle Valo, Matthias Brugger, Li Yang,
	Heiner Kallweit, Frank Rowand, Srinivas Kandagatla,
	Maxime Ripard, Alban Bedel, linux-arm-kernel, linux-rockchip,
	linux-oxnas, linux-stm32, linux-wireless, linux-mediatek,
	linuxppc-dev

> diff --git a/Documentation/devicetree/bindings/net/macb.txt b/Documentation/devicetree/bindings/net/macb.txt
> index 8b80515..92c5642 100644
> --- a/Documentation/devicetree/bindings/net/macb.txt
> +++ b/Documentation/devicetree/bindings/net/macb.txt
> @@ -26,15 +26,15 @@ Required properties:
>  	Optional elements: 'tsu_clk'
>  - clocks: Phandles to input clocks.
>  
> -Optional properties:
> -- nvmem-cells: phandle, reference to an nvmem node for the MAC address
> -- nvmem-cell-names: string, should be "mac-address" if nvmem is to be used
> -
>  Optional properties for PHY child node:
>  - reset-gpios : Should specify the gpio for phy reset
>  - magic-packet : If present, indicates that the hardware supports waking
>    up via magic packet.
>  - phy-handle : see ethernet.txt file in the same directory
> +- mac-address: See ethernet.txt in the same directory.
> +- local-mac-address: See ethernet.txt in the same directory.
> +- nvmem-cells: See ethernet.txt in the same directory.
> +- nvmem-cell-names: See ethernet.txt in the same directory.

This looks wrong. The MAC address is not a PHY property, so should not
be inside the PHY child node.

phy-handle is in the wrong place, but that is a separate problem.

	   Andrew

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/4] net: macb: Drop nvmem_get_mac_address usage
  2019-04-26 23:06 ` [PATCH 3/4] net: macb: Drop nvmem_get_mac_address usage Petr Štetiar
@ 2019-04-27 16:44   ` Andrew Lunn
  0 siblings, 0 replies; 11+ messages in thread
From: Andrew Lunn @ 2019-04-27 16:44 UTC (permalink / raw)
  To: Petr Štetiar
  Cc: netdev, devicetree, linux-kernel, Nicolas Ferre, David S. Miller,
	Florian Fainelli, Heiner Kallweit, Rob Herring, Frank Rowand,
	Srinivas Kandagatla, Maxime Ripard, Alban Bedel

On Sat, Apr 27, 2019 at 01:06:41AM +0200, Petr Štetiar wrote:
> of_get_mac_address now uses NVMEM under the hood, so it's not necessary
> to call it manually anymore.
> 
> Signed-off-by: Petr Štetiar <ynezz@true.cz>
> ---
>  drivers/net/ethernet/cadence/macb_main.c | 12 +++---------
>  1 file changed, 3 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
> index 3da2795..1b98bc8 100644
> --- a/drivers/net/ethernet/cadence/macb_main.c
> +++ b/drivers/net/ethernet/cadence/macb_main.c
> @@ -4172,16 +4172,10 @@ static int macb_probe(struct platform_device *pdev)
>  		bp->rx_intr_mask |= MACB_BIT(RXUBR);
>  
>  	mac = of_get_mac_address(np);
> -	if (mac) {
> +	if (mac)
>  		ether_addr_copy(bp->dev->dev_addr, mac);
> -	} else {
> -		err = nvmem_get_mac_address(&pdev->dev, bp->dev->dev_addr);
> -		if (err) {
> -			if (err == -EPROBE_DEFER)
> -				goto err_out_free_netdev;
> -			macb_get_hwaddr(bp);
> -		}
> -	}

Here we have an ordering problem. The current code looks for NVMEM
after local-mac-address and mac-address. You change will make it look
for NVMEM first.

    Andrew

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 4/4] net: davinci_emac: Drop nvmem_get_mac_address usage
  2019-04-26 23:06 ` [PATCH 4/4] net: davinci_emac: " Petr Štetiar
@ 2019-04-27 16:54   ` Andrew Lunn
  0 siblings, 0 replies; 11+ messages in thread
From: Andrew Lunn @ 2019-04-27 16:54 UTC (permalink / raw)
  To: Petr Štetiar
  Cc: netdev, devicetree, linux-kernel, Grygorii Strashko,
	David S. Miller, Florian Fainelli, Heiner Kallweit, Rob Herring,
	Frank Rowand, Srinivas Kandagatla, Maxime Ripard, Alban Bedel,
	linux-omap

On Sat, Apr 27, 2019 at 01:06:42AM +0200, Petr Štetiar wrote:
> of_get_mac_address now uses NVMEM under the hood, so it's not necessary
> to call it manually anymore.
> 
> Signed-off-by: Petr Štetiar <ynezz@true.cz>
> ---
>  drivers/net/ethernet/ti/davinci_emac.c | 14 +++++---------
>  1 file changed, 5 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
> index 57450b1..c1a5526 100644
> --- a/drivers/net/ethernet/ti/davinci_emac.c
> +++ b/drivers/net/ethernet/ti/davinci_emac.c
> @@ -1912,15 +1912,11 @@ static int davinci_emac_probe(struct platform_device *pdev)
>  		ether_addr_copy(ndev->dev_addr, priv->mac_addr);
>  
>  	if (!is_valid_ether_addr(priv->mac_addr)) {
> -		/* Try nvmem if MAC wasn't passed over pdata or DT. */
> -		rc = nvmem_get_mac_address(&pdev->dev, priv->mac_addr);
> -		if (rc) {
> -			/* Use random MAC if still none obtained. */
> -			eth_hw_addr_random(ndev);
> -			memcpy(priv->mac_addr, ndev->dev_addr, ndev->addr_len);
> -			dev_warn(&pdev->dev, "using random MAC addr: %pM\n",
> -				 priv->mac_addr);
> -		}
> +		/* Use random MAC if still none obtained. */
> +		eth_hw_addr_random(ndev);
> +		memcpy(priv->mac_addr, ndev->dev_addr, ndev->addr_len);
> +		dev_warn(&pdev->dev, "using random MAC addr: %pM\n",
> +			 priv->mac_addr);

Hi Petr

There is the same ordering issue here as with the previous patch.

      Andrew

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/4] dt-bindings: doc: Reflect new NVMEM of_get_mac_address behaviour
  2019-04-26 23:06 ` [PATCH 2/4] dt-bindings: doc: Reflect new NVMEM of_get_mac_address behaviour Petr Štetiar
  2019-04-27 16:31   ` Andrew Lunn
  2019-04-27 16:39   ` Andrew Lunn
@ 2019-04-27 16:56   ` Florian Fainelli
  2 siblings, 0 replies; 11+ messages in thread
From: Florian Fainelli @ 2019-04-27 16:56 UTC (permalink / raw)
  To: Petr Štetiar, netdev, devicetree, linux-kernel,
	David S. Miller, Rob Herring, Mark Rutland, Andrew Lunn,
	Vivien Didelot, Heiko Stuebner, Fugang Duan, Claudiu Manoil,
	Yisen Zhuang, Salil Mehta, Woojung Huh,
	Microchip Linux Driver Support, Neil Armstrong, Kunihiko Hayashi,
	Masahiro Yamada, Jassi Brar, Maxime Coquelin, Alexandre Torgue,
	Kalle Valo, Matthias Brugger, Li Yang
  Cc: Heiner Kallweit, Frank Rowand, Srinivas Kandagatla,
	Maxime Ripard, Alban Bedel, linux-arm-kernel, linux-rockchip,
	linux-oxnas, linux-stm32, linux-wireless, linux-mediatek,
	linuxppc-dev



On 4/26/2019 4:06 PM, Petr Štetiar wrote:
> As of_get_mac_address now supports NVMEM under the hood, we should
> update the bindings documentation with the new nvmem-cell* properties.
> While at it, fix also other missing properties supported by
> of_get_mac_address.
> 
> Signed-off-by: Petr Štetiar <ynezz@true.cz>

While I appreciate your effort in making the bindings up to date and
consistent, this does really scale well and is an error prone exercise,
how about consolidating all MAC address related properties into the
ethernet.txt document like you just did and update all bindings to
indicate something along the lines of:

For all other standard Ethernet related properties, please refer to
ethernet.txt or something like that?
-- 
Florian

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2019-04-27 16:56 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-26 23:06 [PATCH 0/4] of_net: Add NVMEM support to of_get_mac_address Petr Štetiar
2019-04-26 23:06 ` [PATCH 1/4] " Petr Štetiar
2019-04-27 16:28   ` Andrew Lunn
2019-04-26 23:06 ` [PATCH 2/4] dt-bindings: doc: Reflect new NVMEM of_get_mac_address behaviour Petr Štetiar
2019-04-27 16:31   ` Andrew Lunn
2019-04-27 16:39   ` Andrew Lunn
2019-04-27 16:56   ` Florian Fainelli
2019-04-26 23:06 ` [PATCH 3/4] net: macb: Drop nvmem_get_mac_address usage Petr Štetiar
2019-04-27 16:44   ` Andrew Lunn
2019-04-26 23:06 ` [PATCH 4/4] net: davinci_emac: " Petr Štetiar
2019-04-27 16:54   ` Andrew Lunn

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).