Commit 4f5ed7fb authored by Paolo Abeni's avatar Paolo Abeni

Merge branch 'marvell-nvmem-mac-addresses-support'

Miquel Raynal says:

====================
Marvell nvmem mac addresses support

Now that we are aligned on how to make information available from static
storage media to drivers like Ethernet controller drivers or switch
drivers by using nvmem cells and going through the whole nvmem
infrastructure, here are two driver updates to reflect these changes.

Prior to the driver updates, I propose:
* Reverting binding changes which should have never been accepted like
  that.
* A conversion of the (old) Prestera and DFX server bindings (optional,
  can be dropped if not considered necessary).
* A better description of the more recent Prestera PCI switch.

Please mind that this series cannot break anything since retrieving the
MAC address Prestera driver has never worked upstream, because the (ONIE
tlv) driver supposed to export the MAC address has not been accepted in
its original form and has been updated to the nvmem-layout
infrastructure (bindings have been merged, the code remains to be
applied).
====================

Link: https://lore.kernel.org/r/20221124111556.264647-1-miquel.raynal@bootlin.comSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parents d6dc62fc 7a74c126
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
%YAML 1.2
---
$id: http://devicetree.org/schemas/net/marvell,dfx-server.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: Marvell Prestera DFX server
maintainers:
- Miquel Raynal <miquel.raynal@bootlin.com>
select:
properties:
compatible:
contains:
const: marvell,dfx-server
required:
- compatible
properties:
compatible:
items:
- const: marvell,dfx-server
- const: simple-bus
reg:
maxItems: 1
ranges: true
'#address-cells':
const: 1
'#size-cells':
const: 1
required:
- compatible
- reg
- ranges
# The DFX server may expose clocks described as subnodes
additionalProperties:
type: object
examples:
- |
#define MBUS_ID(target,attributes) (((target) << 24) | ((attributes) << 16))
bus@0 {
reg = <0 0>;
#address-cells = <2>;
#size-cells = <1>;
dfx-bus@ac000000 {
compatible = "marvell,dfx-server", "simple-bus";
#address-cells = <1>;
#size-cells = <1>;
ranges = <0 MBUS_ID(0x08, 0x00) 0 0x100000>;
reg = <MBUS_ID(0x08, 0x00) 0 0x100000>;
};
};
Marvell Prestera Switch Chip bindings
-------------------------------------
Required properties:
- compatible: must be "marvell,prestera" and one of the following
"marvell,prestera-98dx3236",
"marvell,prestera-98dx3336",
"marvell,prestera-98dx4251",
- reg: address and length of the register set for the device.
- interrupts: interrupt for the device
Optional properties:
- dfx: phandle reference to the "DFX Server" node
Example:
switch {
compatible = "simple-bus";
#address-cells = <1>;
#size-cells = <1>;
ranges = <0 MBUS_ID(0x03, 0x00) 0 0x100000>;
packet-processor@0 {
compatible = "marvell,prestera-98dx3236", "marvell,prestera";
reg = <0 0x4000000>;
interrupts = <33>, <34>, <35>;
dfx = <&dfx>;
};
};
DFX Server bindings
-------------------
Required properties:
- compatible: must be "marvell,dfx-server", "simple-bus"
- ranges: describes the address mapping of a memory-mapped bus.
- reg: address and length of the register set for the device.
Example:
dfx-server {
compatible = "marvell,dfx-server", "simple-bus";
#address-cells = <1>;
#size-cells = <1>;
ranges = <0 MBUS_ID(0x08, 0x00) 0 0x100000>;
reg = <MBUS_ID(0x08, 0x00) 0 0x100000>;
};
Marvell Prestera SwitchDev bindings
-----------------------------------
Optional properties:
- compatible: must be "marvell,prestera"
- base-mac-provider: describes handle to node which provides base mac address,
might be a static base mac address or nvme cell provider.
Example:
eeprom_mac_addr: eeprom-mac-addr {
compatible = "eeprom,mac-addr-cell";
status = "okay";
nvmem = <&eeprom_at24>;
};
prestera {
compatible = "marvell,prestera";
status = "okay";
base-mac-provider = <&eeprom_mac_addr>;
};
The current implementation of Prestera Switchdev PCI interface driver requires
that BAR2 is assigned to 0xf6000000 as base address from the PCI IO range:
&cp0_pcie0 {
ranges = <0x81000000 0x0 0xfb000000 0x0 0xfb000000 0x0 0xf0000
0x82000000 0x0 0xf6000000 0x0 0xf6000000 0x0 0x2000000
0x82000000 0x0 0xf9000000 0x0 0xf9000000 0x0 0x100000>;
phys = <&cp0_comphy0 0>;
status = "okay";
};
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
%YAML 1.2
---
$id: http://devicetree.org/schemas/net/marvell,prestera.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: Marvell Prestera switch family
maintainers:
- Miquel Raynal <miquel.raynal@bootlin.com>
properties:
compatible:
oneOf:
- items:
- enum:
- marvell,prestera-98dx3236
- marvell,prestera-98dx3336
- marvell,prestera-98dx4251
- const: marvell,prestera
- enum:
- pci11ab,c804
- pci11ab,c80c
- pci11ab,cc1e
reg:
maxItems: 1
interrupts:
maxItems: 3
dfx:
description: Reference to the DFX Server bus node.
$ref: /schemas/types.yaml#/definitions/phandle
nvmem-cells: true
nvmem-cell-names: true
if:
properties:
compatible:
contains:
const: marvell,prestera
# Memory mapped AlleyCat3 family
then:
properties:
nvmem-cells: false
nvmem-cell-names: false
required:
- interrupts
# PCI Aldrin family
else:
properties:
interrupts: false
dfx: false
required:
- compatible
- reg
# Ports can also be described
additionalProperties:
type: object
examples:
- |
packet-processor@0 {
compatible = "marvell,prestera-98dx3236", "marvell,prestera";
reg = <0 0x4000000>;
interrupts = <33>, <34>, <35>;
dfx = <&dfx>;
};
- |
pcie@0 {
#address-cells = <3>;
#size-cells = <2>;
ranges = <0x0 0x0 0x0 0x0 0x0 0x0>;
reg = <0x0 0x0 0x0 0x0 0x0 0x0>;
device_type = "pci";
switch@0,0 {
reg = <0x0 0x0 0x0 0x0 0x0>;
compatible = "pci11ab,c80c";
nvmem-cells = <&mac_address 0>;
nvmem-cell-names = "mac-address";
};
};
......@@ -6104,6 +6104,13 @@ static void mvpp2_port_copy_mac_addr(struct net_device *dev, struct mvpp2 *priv,
}
}
/* Only valid on OF enabled platforms */
if (!of_get_mac_address_nvmem(to_of_node(fwnode), fw_mac_addr)) {
*mac_from = "nvmem cell";
eth_hw_addr_set(dev, fw_mac_addr);
return;
}
*mac_from = "random";
eth_hw_addr_random(dev);
}
......
......@@ -858,17 +858,10 @@ static void prestera_event_handlers_unregister(struct prestera_switch *sw)
static int prestera_switch_set_base_mac_addr(struct prestera_switch *sw)
{
struct device_node *base_mac_np;
int ret = 0;
if (sw->np) {
base_mac_np = of_parse_phandle(sw->np, "base-mac-provider", 0);
if (base_mac_np) {
ret = of_get_mac_address(base_mac_np, sw->base_mac);
of_node_put(base_mac_np);
}
}
int ret;
if (sw->np)
ret = of_get_mac_address(sw->np, sw->base_mac);
if (!is_valid_ether_addr(sw->base_mac) || ret) {
eth_random_addr(sw->base_mac);
dev_info(prestera_dev(sw), "using random base mac address\n");
......@@ -1372,7 +1365,7 @@ static int prestera_switch_init(struct prestera_switch *sw)
{
int err;
sw->np = of_find_compatible_node(NULL, NULL, "marvell,prestera");
sw->np = sw->dev->dev->of_node;
err = prestera_hw_switch_init(sw);
if (err) {
......
......@@ -14,6 +14,7 @@
struct net_device;
extern int of_get_phy_mode(struct device_node *np, phy_interface_t *interface);
extern int of_get_mac_address(struct device_node *np, u8 *mac);
extern int of_get_mac_address_nvmem(struct device_node *np, u8 *mac);
int of_get_ethdev_address(struct device_node *np, struct net_device *dev);
extern struct net_device *of_find_net_device_by_node(struct device_node *np);
#else
......@@ -28,6 +29,11 @@ static inline int of_get_mac_address(struct device_node *np, u8 *mac)
return -ENODEV;
}
static inline int of_get_mac_address_nvmem(struct device_node *np, u8 *mac)
{
return -ENODEV;
}
static inline int of_get_ethdev_address(struct device_node *np, struct net_device *dev)
{
return -ENODEV;
......
......@@ -57,7 +57,7 @@ static int of_get_mac_addr(struct device_node *np, const char *name, u8 *addr)
return -ENODEV;
}
static int of_get_mac_addr_nvmem(struct device_node *np, u8 *addr)
int of_get_mac_address_nvmem(struct device_node *np, u8 *addr)
{
struct platform_device *pdev = of_find_device_by_node(np);
struct nvmem_cell *cell;
......@@ -94,6 +94,7 @@ static int of_get_mac_addr_nvmem(struct device_node *np, u8 *addr)
return 0;
}
EXPORT_SYMBOL(of_get_mac_address_nvmem);
/**
* of_get_mac_address()
......@@ -140,7 +141,7 @@ int of_get_mac_address(struct device_node *np, u8 *addr)
if (!ret)
return 0;
return of_get_mac_addr_nvmem(np, addr);
return of_get_mac_address_nvmem(np, addr);
}
EXPORT_SYMBOL(of_get_mac_address);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment