Skip to content

Commit 4f5ed7f

Browse files
author
Paolo Abeni
committed
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.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2 parents d6dc62f + 7a74c12 commit 4f5ed7f

File tree

7 files changed

+173
-94
lines changed

7 files changed

+173
-94
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/net/marvell,dfx-server.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Marvell Prestera DFX server
8+
9+
maintainers:
10+
- Miquel Raynal <miquel.raynal@bootlin.com>
11+
12+
select:
13+
properties:
14+
compatible:
15+
contains:
16+
const: marvell,dfx-server
17+
required:
18+
- compatible
19+
20+
properties:
21+
compatible:
22+
items:
23+
- const: marvell,dfx-server
24+
- const: simple-bus
25+
26+
reg:
27+
maxItems: 1
28+
29+
ranges: true
30+
31+
'#address-cells':
32+
const: 1
33+
34+
'#size-cells':
35+
const: 1
36+
37+
required:
38+
- compatible
39+
- reg
40+
- ranges
41+
42+
# The DFX server may expose clocks described as subnodes
43+
additionalProperties:
44+
type: object
45+
46+
examples:
47+
- |
48+
49+
#define MBUS_ID(target,attributes) (((target) << 24) | ((attributes) << 16))
50+
bus@0 {
51+
reg = <0 0>;
52+
#address-cells = <2>;
53+
#size-cells = <1>;
54+
55+
dfx-bus@ac000000 {
56+
compatible = "marvell,dfx-server", "simple-bus";
57+
#address-cells = <1>;
58+
#size-cells = <1>;
59+
ranges = <0 MBUS_ID(0x08, 0x00) 0 0x100000>;
60+
reg = <MBUS_ID(0x08, 0x00) 0 0x100000>;
61+
};
62+
};

Documentation/devicetree/bindings/net/marvell,prestera.txt

Lines changed: 0 additions & 81 deletions
This file was deleted.
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/net/marvell,prestera.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Marvell Prestera switch family
8+
9+
maintainers:
10+
- Miquel Raynal <miquel.raynal@bootlin.com>
11+
12+
properties:
13+
compatible:
14+
oneOf:
15+
- items:
16+
- enum:
17+
- marvell,prestera-98dx3236
18+
- marvell,prestera-98dx3336
19+
- marvell,prestera-98dx4251
20+
- const: marvell,prestera
21+
- enum:
22+
- pci11ab,c804
23+
- pci11ab,c80c
24+
- pci11ab,cc1e
25+
26+
reg:
27+
maxItems: 1
28+
29+
interrupts:
30+
maxItems: 3
31+
32+
dfx:
33+
description: Reference to the DFX Server bus node.
34+
$ref: /schemas/types.yaml#/definitions/phandle
35+
36+
nvmem-cells: true
37+
38+
nvmem-cell-names: true
39+
40+
if:
41+
properties:
42+
compatible:
43+
contains:
44+
const: marvell,prestera
45+
46+
# Memory mapped AlleyCat3 family
47+
then:
48+
properties:
49+
nvmem-cells: false
50+
nvmem-cell-names: false
51+
required:
52+
- interrupts
53+
54+
# PCI Aldrin family
55+
else:
56+
properties:
57+
interrupts: false
58+
dfx: false
59+
60+
required:
61+
- compatible
62+
- reg
63+
64+
# Ports can also be described
65+
additionalProperties:
66+
type: object
67+
68+
examples:
69+
- |
70+
packet-processor@0 {
71+
compatible = "marvell,prestera-98dx3236", "marvell,prestera";
72+
reg = <0 0x4000000>;
73+
interrupts = <33>, <34>, <35>;
74+
dfx = <&dfx>;
75+
};
76+
77+
- |
78+
pcie@0 {
79+
#address-cells = <3>;
80+
#size-cells = <2>;
81+
ranges = <0x0 0x0 0x0 0x0 0x0 0x0>;
82+
reg = <0x0 0x0 0x0 0x0 0x0 0x0>;
83+
device_type = "pci";
84+
85+
switch@0,0 {
86+
reg = <0x0 0x0 0x0 0x0 0x0>;
87+
compatible = "pci11ab,c80c";
88+
nvmem-cells = <&mac_address 0>;
89+
nvmem-cell-names = "mac-address";
90+
};
91+
};

drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6104,6 +6104,13 @@ static void mvpp2_port_copy_mac_addr(struct net_device *dev, struct mvpp2 *priv,
61046104
}
61056105
}
61066106

6107+
/* Only valid on OF enabled platforms */
6108+
if (!of_get_mac_address_nvmem(to_of_node(fwnode), fw_mac_addr)) {
6109+
*mac_from = "nvmem cell";
6110+
eth_hw_addr_set(dev, fw_mac_addr);
6111+
return;
6112+
}
6113+
61076114
*mac_from = "random";
61086115
eth_hw_addr_random(dev);
61096116
}

drivers/net/ethernet/marvell/prestera/prestera_main.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -858,17 +858,10 @@ static void prestera_event_handlers_unregister(struct prestera_switch *sw)
858858

859859
static int prestera_switch_set_base_mac_addr(struct prestera_switch *sw)
860860
{
861-
struct device_node *base_mac_np;
862-
int ret = 0;
863-
864-
if (sw->np) {
865-
base_mac_np = of_parse_phandle(sw->np, "base-mac-provider", 0);
866-
if (base_mac_np) {
867-
ret = of_get_mac_address(base_mac_np, sw->base_mac);
868-
of_node_put(base_mac_np);
869-
}
870-
}
861+
int ret;
871862

863+
if (sw->np)
864+
ret = of_get_mac_address(sw->np, sw->base_mac);
872865
if (!is_valid_ether_addr(sw->base_mac) || ret) {
873866
eth_random_addr(sw->base_mac);
874867
dev_info(prestera_dev(sw), "using random base mac address\n");
@@ -1372,7 +1365,7 @@ static int prestera_switch_init(struct prestera_switch *sw)
13721365
{
13731366
int err;
13741367

1375-
sw->np = of_find_compatible_node(NULL, NULL, "marvell,prestera");
1368+
sw->np = sw->dev->dev->of_node;
13761369

13771370
err = prestera_hw_switch_init(sw);
13781371
if (err) {

include/linux/of_net.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
struct net_device;
1515
extern int of_get_phy_mode(struct device_node *np, phy_interface_t *interface);
1616
extern int of_get_mac_address(struct device_node *np, u8 *mac);
17+
extern int of_get_mac_address_nvmem(struct device_node *np, u8 *mac);
1718
int of_get_ethdev_address(struct device_node *np, struct net_device *dev);
1819
extern struct net_device *of_find_net_device_by_node(struct device_node *np);
1920
#else
@@ -28,6 +29,11 @@ static inline int of_get_mac_address(struct device_node *np, u8 *mac)
2829
return -ENODEV;
2930
}
3031

32+
static inline int of_get_mac_address_nvmem(struct device_node *np, u8 *mac)
33+
{
34+
return -ENODEV;
35+
}
36+
3137
static inline int of_get_ethdev_address(struct device_node *np, struct net_device *dev)
3238
{
3339
return -ENODEV;

net/core/of_net.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static int of_get_mac_addr(struct device_node *np, const char *name, u8 *addr)
5757
return -ENODEV;
5858
}
5959

60-
static int of_get_mac_addr_nvmem(struct device_node *np, u8 *addr)
60+
int of_get_mac_address_nvmem(struct device_node *np, u8 *addr)
6161
{
6262
struct platform_device *pdev = of_find_device_by_node(np);
6363
struct nvmem_cell *cell;
@@ -94,6 +94,7 @@ static int of_get_mac_addr_nvmem(struct device_node *np, u8 *addr)
9494

9595
return 0;
9696
}
97+
EXPORT_SYMBOL(of_get_mac_address_nvmem);
9798

9899
/**
99100
* of_get_mac_address()
@@ -140,7 +141,7 @@ int of_get_mac_address(struct device_node *np, u8 *addr)
140141
if (!ret)
141142
return 0;
142143

143-
return of_get_mac_addr_nvmem(np, addr);
144+
return of_get_mac_address_nvmem(np, addr);
144145
}
145146
EXPORT_SYMBOL(of_get_mac_address);
146147

0 commit comments

Comments
 (0)