Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c8f8207c authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'of_net-Add-NVMEM-support-to-of_get_mac_address'

Petr Štetiar says:

====================
of_net: Add NVMEM support to of_get_mac_address

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 that I should rather use new NVMEM subsystem and
during the review process of v2 I was told, that I should handle
EPROBE_DEFFER error as well, during the review process of v3 I was told,
that returning pointer/NULL/ERR_PTR is considered as wrong API design, so
this v4 patch series tries to accommodate all this previous remarks.

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, and cleaning
up all current binding documentation referencing any of the MAC address
related properties.

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

Patches 5-10 are converting all current users of of_get_mac_address to the
new ERR_PTR encoded error value, as of_get_mac_address could now return
valid pointer, NULL and ERR_PTR.

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/


====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 8ef5cc4f ea168cdf
Loading
Loading
Loading
Loading
+2 −3
Original line number Original line Diff line number Diff line
@@ -46,9 +46,8 @@ Required properties:
	- reg: phy id used to communicate to phy.
	- reg: phy id used to communicate to phy.
	- device_type: Must be "ethernet-phy".
	- device_type: Must be "ethernet-phy".


Optional properties:
The MAC address will be determined using the optional properties defined in
- local-mac-address: See ethernet.txt in the same directory.
ethernet.txt.
- max-frame-size: See ethernet.txt in the same directory.


Example:
Example:


+3 −2
Original line number Original line Diff line number Diff line
@@ -24,8 +24,6 @@ Required properties:
- phy-mode: See ethernet.txt file in the same directory
- phy-mode: See ethernet.txt file in the same directory


Optional properties:
Optional properties:
- mac-address: mac address to be assigned to the device. Can be overridden
  by UEFI.
- dma-coherent: Present if dma operations are coherent
- dma-coherent: Present if dma operations are coherent
- amd,per-channel-interrupt: Indicates that Rx and Tx complete will generate
- amd,per-channel-interrupt: Indicates that Rx and Tx complete will generate
  a unique interrupt for each DMA channel - this requires an additional
  a unique interrupt for each DMA channel - this requires an additional
@@ -34,6 +32,9 @@ Optional properties:
    0 - 1GbE and 10GbE (default)
    0 - 1GbE and 10GbE (default)
    1 - 2.5GbE and 10GbE
    1 - 2.5GbE and 10GbE


The MAC address will be determined using the optional properties defined in
ethernet.txt.

The following optional properties are represented by an array with each
The following optional properties are represented by an array with each
value corresponding to a particular speed. The first array value represents
value corresponding to a particular speed. The first array value represents
the setting for the 1GbE speed, the second value for the 2.5GbE speed and
the setting for the 1GbE speed, the second value for the 2.5GbE speed and
+2 −2
Original line number Original line Diff line number Diff line
@@ -16,8 +16,8 @@ Required properties:
				registers (required for Northstar2)
				registers (required for Northstar2)
 - interrupts:	Interrupt number
 - interrupts:	Interrupt number


Optional properties:
The MAC address will be determined using the optional properties
- mac-address:	See ethernet.txt file in the same directory
defined in ethernet.txt.


Examples:
Examples:


+3 −1
Original line number Original line Diff line number Diff line
@@ -49,10 +49,12 @@ Required properties:


Optional properties:
Optional properties:
- dual_emac_res_vlan	: Specifies VID to be used to segregate the ports
- dual_emac_res_vlan	: Specifies VID to be used to segregate the ports
- mac-address		: See ethernet.txt file in the same directory
- phy_id		: Specifies slave phy id (deprecated, use phy-handle)
- phy_id		: Specifies slave phy id (deprecated, use phy-handle)
- phy-handle		: See ethernet.txt file in the same directory
- phy-handle		: See ethernet.txt file in the same directory


The MAC address will be determined using the optional properties
defined in ethernet.txt.

Slave sub-nodes:
Slave sub-nodes:
- fixed-link		: See fixed-link.txt file in the same directory
- fixed-link		: See fixed-link.txt file in the same directory


+3 −2
Original line number Original line Diff line number Diff line
@@ -20,11 +20,12 @@ Required properties:
Optional properties:
Optional properties:
- phy-handle: See ethernet.txt file in the same directory.
- phy-handle: See ethernet.txt file in the same directory.
              If absent, davinci_emac driver defaults to 100/FULL.
              If absent, davinci_emac driver defaults to 100/FULL.
- 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
- ti,davinci-rmii-en: 1 byte, 1 means use RMII
- ti,davinci-no-bd-ram: boolean, does EMAC have BD RAM?
- ti,davinci-no-bd-ram: boolean, does EMAC have BD RAM?


The MAC address will be determined using the optional properties
defined in ethernet.txt.

Example (enbw_cmc board):
Example (enbw_cmc board):
	eth0: emac@1e20000 {
	eth0: emac@1e20000 {
		compatible = "ti,davinci-dm6467-emac";
		compatible = "ti,davinci-dm6467-emac";
Loading