[RFC 1/2] misc: Add MAC address mapper "driver"

Sascha Hauer s.hauer at pengutronix.de
Mon Feb 1 02:10:07 PST 2016


On Sun, Jan 31, 2016 at 09:57:13PM -0800, Andrey Smirnov wrote:
> Add Barebox specific device tree provisions to allow specifying MAC
> addresses for network interfaces via device tree.
> 
> Signed-off-by: Andrey Smirnov <andrew.smirnov at gmail.com>
> ---
>  .../bindings/barebox/barebox,mac-address-map.rst   |  27 ++++
>  drivers/misc/Makefile                              |   1 +
>  drivers/misc/mac-address-map.c                     | 142 +++++++++++++++++++++
>  3 files changed, 170 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/barebox/barebox,mac-address-map.rst
>  create mode 100644 drivers/misc/mac-address-map.c
> 
> diff --git a/Documentation/devicetree/bindings/barebox/barebox,mac-address-map.rst b/Documentation/devicetree/bindings/barebox/barebox,mac-address-map.rst
> new file mode 100644
> index 0000000..1ac3062
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/barebox/barebox,mac-address-map.rst
> @@ -0,0 +1,27 @@
> +barebox MAC address map
> +=======================
> +
> +This driver allows to specify each network adapter's source of MAC address from the devicetree.
> +
> +Required properties:
> +
> +* ``compatible``: should be ``barebox,mac-address-map``
> +
> +Besides ``compatible`` property the node is expected to contain a
> +number of children nodes each specifing a single "MAC source ->
> +interface" mapping.
> +
> +Child node's required properties:
> +* ``network-interface``: phandle corresponding to network interface
> +* ``mac-location``: a pair of phandle to 'cdev' containing MAC address
> +  and offset withing that 'cdev'
> +
> +Example::
> +
> +  mac-address-map {
> +	compatible = "barebox,mac-address-map";
> +	nic at 0 {
> +		network-interface = <&fec>;
> +		mac-location = <&ocotp 0x88>;
> +	};
> +  };

I wonder if the correct way to do this wouldn't be nvmem, see
Documentation/devicetree/bindings/nvmem/nvmem.txt in the Kernel.
This would mandate a binding like:

	ocotp {
		mac1: mac at 88 {
			reg = <0x88 0x6>;
		};
	};

	&fec {
		nvmem-cells = <&mac1>;
		nvmem-cell-names = "mac-address";
	};

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list