Skip to content

Commit 970cb1c

Browse files
committed
Merge branch 'phy-package'
Christian Marangi says: ==================== net: phy: Introduce PHY Package concept Idea of this big series is to introduce the concept of PHY package in DT and give PHY drivers a way to derive the base address from DT. The concept of PHY package is nothing new and is already a thing in the kernel with the API phy_package_join/leave/read/write. What is currently lacking is describing this in DT and better reference a base address to calculate offset from. In the scenario of a PHY package where multiple address are used and there isn't a way to get the base address of the PHY package from some regs, getting the information from DT is the only way. A possible example to this problem is this: ethernet-phy-package@0 { compatible = "qcom,qca8075-package"; #address-cells = <1>; #size-cells = <0>; reg = <0>; qcom,package-mode = "qsgmii"; ethernet-phy@1 { reg = <1>; }; phy4: ethernet-phy@4 { reg = <4>; }; }; The mdio parse functions are changed to address for this additional special node, the function is changed to simply detect this node and search also in this. (we match the node name to be "ethernet-phy-package") PHY driver can then use introduced helper of_phy_package_join to join the PHY to the PHY package and derive the base address from DT. Changes v7: - Rebase on top of net-next - Add Reviewed-by tag for DT patch - Change tx-driver-strength to tx-drive-strength - Drop driver reference in DT Changes v6: - Back to absolute PHY implementation - Correctly drop refcount for node on error condition and on PHY leave - Drop DT include patch in favor for 3 boolean vendor property - Fix Documentation problem for compatible and missing type and description - Drop redundand gpio-controller dependency and description - Skip scanphy with invalid PHY Package node and make reg mandatory - Rework fiber read status to use more generic function - Split qca808x LED generalization patch to permit easier review - Correctly return -EINVAL with wrong data passed to vendor property - Drop removing LED ops for qca807x PHY driver with gpio-controller Changes v5: - Rebase on top of net-next - Change implementation to base addr + offset in subnode - Adapt to all the changes and cleanup done to at803x Changes v4: - Rework DT implementation - Drop of autojoin support and rework to simple helper - Rework PHY driver to the new implementation - Add compatible for qca807x package - Further cleanup patches Changes v3: - Add back compatible implementation - Detach patch that can be handled separately (phy_package_mmd, phy_package extended) - Rework code to new simplified implementation with base addr + offset - Improve documentation with additional info and description Changes v2: - Drop compatible "ethernet-phy-package", use node name prefix matching instead - Improve DT example - Add reg for ethernet-phy-package - Drop phy-mode for ethernet-phy-package - Drop patch for generalization of phy-mode - Drop global-phy property (handle internally to the PHY driver) - Rework OF phy package code and PHY driver to handle base address - Fix missing of_node_put - Add some missing docs for added variables in struct - Move some define from dt-bindings include to PHY driver - Handle qsgmii validation in PHY driver - Fix wrong include for gpiolib - Drop reduntant version.h include ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents b63cc73 + f508a22 commit 970cb1c

File tree

14 files changed

+1676
-375
lines changed

14 files changed

+1676
-375
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/net/ethernet-phy-package.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Ethernet PHY Package Common Properties
8+
9+
maintainers:
10+
- Christian Marangi <[email protected]>
11+
12+
description:
13+
PHY packages are multi-port Ethernet PHY of the same family
14+
and each Ethernet PHY is affected by the global configuration
15+
of the PHY package.
16+
17+
Each reg of the PHYs defined in the PHY package node is
18+
absolute and describe the real address of the Ethernet PHY on
19+
the MDIO bus.
20+
21+
properties:
22+
$nodename:
23+
pattern: "^ethernet-phy-package@[a-f0-9]+$"
24+
25+
reg:
26+
minimum: 0
27+
maximum: 31
28+
description:
29+
The base ID number for the PHY package.
30+
Commonly the ID of the first PHY in the PHY package.
31+
32+
Some PHY in the PHY package might be not defined but
33+
still occupy ID on the device (just not attached to
34+
anything) hence the PHY package reg might correspond
35+
to a not attached PHY (offset 0).
36+
37+
'#address-cells':
38+
const: 1
39+
40+
'#size-cells':
41+
const: 0
42+
43+
patternProperties:
44+
^ethernet-phy@[a-f0-9]+$:
45+
$ref: ethernet-phy.yaml#
46+
47+
required:
48+
- reg
49+
- '#address-cells'
50+
- '#size-cells'
51+
52+
additionalProperties: true
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/net/qcom,qca807x.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Qualcomm QCA807x Ethernet PHY
8+
9+
maintainers:
10+
- Christian Marangi <[email protected]>
11+
- Robert Marko <[email protected]>
12+
13+
description: |
14+
Qualcomm QCA8072/5 Ethernet PHY is PHY package of 2 or 5
15+
IEEE 802.3 clause 22 compliant 10BASE-Te, 100BASE-TX and
16+
1000BASE-T PHY-s.
17+
18+
They feature 2 SerDes, one for PSGMII or QSGMII connection with
19+
MAC, while second one is SGMII for connection to MAC or fiber.
20+
21+
Both models have a combo port that supports 1000BASE-X and
22+
100BASE-FX fiber.
23+
24+
Each PHY inside of QCA807x series has 4 digitally controlled
25+
output only pins that natively drive LED-s for up to 2 attached
26+
LEDs. Some vendor also use these 4 output for GPIO usage without
27+
attaching LEDs.
28+
29+
Note that output pins can be set to drive LEDs OR GPIO, mixed
30+
definition are not accepted.
31+
32+
$ref: ethernet-phy-package.yaml#
33+
34+
properties:
35+
compatible:
36+
enum:
37+
- qcom,qca8072-package
38+
- qcom,qca8075-package
39+
40+
qcom,package-mode:
41+
description: |
42+
PHY package can be configured in 3 mode following this table:
43+
44+
First Serdes mode Second Serdes mode
45+
Option 1 PSGMII for copper Disabled
46+
ports 0-4
47+
Option 2 PSGMII for copper 1000BASE-X / 100BASE-FX
48+
ports 0-4
49+
Option 3 QSGMII for copper SGMII for
50+
ports 0-3 copper port 4
51+
52+
PSGMII mode (option 1 or 2) is configured dynamically based on
53+
the presence of a connected SFP device.
54+
$ref: /schemas/types.yaml#/definitions/string
55+
enum:
56+
- qsgmii
57+
- psgmii
58+
default: psgmii
59+
60+
qcom,tx-drive-strength-milliwatt:
61+
description: set the TX Amplifier value in mv.
62+
$ref: /schemas/types.yaml#/definitions/uint32
63+
enum: [140, 160, 180, 200, 220,
64+
240, 260, 280, 300, 320,
65+
400, 500, 600]
66+
default: 600
67+
68+
patternProperties:
69+
^ethernet-phy@[a-f0-9]+$:
70+
$ref: ethernet-phy.yaml#
71+
72+
properties:
73+
qcom,dac-full-amplitude:
74+
description:
75+
Set Analog MDI driver amplitude to FULL.
76+
77+
With this not defined, amplitude is set to DSP.
78+
(amplitude is adjusted based on cable length)
79+
80+
With this enabled and qcom,dac-full-bias-current
81+
and qcom,dac-disable-bias-current-tweak disabled,
82+
bias current is half.
83+
type: boolean
84+
85+
qcom,dac-full-bias-current:
86+
description:
87+
Set Analog MDI driver bias current to FULL.
88+
89+
With this not defined, bias current is set to DSP.
90+
(bias current is adjusted based on cable length)
91+
92+
Actual bias current might be different with
93+
qcom,dac-disable-bias-current-tweak disabled.
94+
type: boolean
95+
96+
qcom,dac-disable-bias-current-tweak:
97+
description: |
98+
Set Analog MDI driver bias current to disable tweak
99+
to bias current.
100+
101+
With this not defined, bias current tweak are enabled
102+
by default.
103+
104+
With this enabled the following tweak are NOT applied:
105+
- With both FULL amplitude and FULL bias current: bias current
106+
is set to half.
107+
- With only DSP amplitude: bias current is set to half and
108+
is set to 1/4 with cable < 10m.
109+
- With DSP bias current (included both DSP amplitude and
110+
DSP bias current): bias current is half the detected current
111+
with cable < 10m.
112+
type: boolean
113+
114+
gpio-controller: true
115+
116+
'#gpio-cells':
117+
const: 2
118+
119+
if:
120+
required:
121+
- gpio-controller
122+
then:
123+
properties:
124+
leds: false
125+
126+
unevaluatedProperties: false
127+
128+
required:
129+
- compatible
130+
131+
unevaluatedProperties: false
132+
133+
examples:
134+
- |
135+
#include <dt-bindings/leds/common.h>
136+
137+
mdio {
138+
#address-cells = <1>;
139+
#size-cells = <0>;
140+
141+
ethernet-phy-package@0 {
142+
#address-cells = <1>;
143+
#size-cells = <0>;
144+
compatible = "qcom,qca8075-package";
145+
reg = <0>;
146+
147+
qcom,package-mode = "qsgmii";
148+
149+
ethernet-phy@0 {
150+
reg = <0>;
151+
152+
leds {
153+
#address-cells = <1>;
154+
#size-cells = <0>;
155+
156+
led@0 {
157+
reg = <0>;
158+
color = <LED_COLOR_ID_GREEN>;
159+
function = LED_FUNCTION_LAN;
160+
default-state = "keep";
161+
};
162+
};
163+
};
164+
165+
ethernet-phy@1 {
166+
reg = <1>;
167+
};
168+
169+
ethernet-phy@2 {
170+
reg = <2>;
171+
172+
gpio-controller;
173+
#gpio-cells = <2>;
174+
};
175+
176+
ethernet-phy@3 {
177+
reg = <3>;
178+
};
179+
180+
ethernet-phy@4 {
181+
reg = <4>;
182+
};
183+
};
184+
};

drivers/net/mdio/of_mdio.c

Lines changed: 56 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,53 @@ bool of_mdiobus_child_is_phy(struct device_node *child)
139139
}
140140
EXPORT_SYMBOL(of_mdiobus_child_is_phy);
141141

142+
static int __of_mdiobus_parse_phys(struct mii_bus *mdio, struct device_node *np,
143+
bool *scanphys)
144+
{
145+
struct device_node *child;
146+
int addr, rc = 0;
147+
148+
/* Loop over the child nodes and register a phy_device for each phy */
149+
for_each_available_child_of_node(np, child) {
150+
if (of_node_name_eq(child, "ethernet-phy-package")) {
151+
/* Ignore invalid ethernet-phy-package node */
152+
if (!of_property_present(child, "reg"))
153+
continue;
154+
155+
rc = __of_mdiobus_parse_phys(mdio, child, NULL);
156+
if (rc && rc != -ENODEV)
157+
goto exit;
158+
159+
continue;
160+
}
161+
162+
addr = of_mdio_parse_addr(&mdio->dev, child);
163+
if (addr < 0) {
164+
/* Skip scanning for invalid ethernet-phy-package node */
165+
if (scanphys)
166+
*scanphys = true;
167+
continue;
168+
}
169+
170+
if (of_mdiobus_child_is_phy(child))
171+
rc = of_mdiobus_register_phy(mdio, child, addr);
172+
else
173+
rc = of_mdiobus_register_device(mdio, child, addr);
174+
175+
if (rc == -ENODEV)
176+
dev_err(&mdio->dev,
177+
"MDIO device at address %d is missing.\n",
178+
addr);
179+
else if (rc)
180+
goto exit;
181+
}
182+
183+
return 0;
184+
exit:
185+
of_node_put(child);
186+
return rc;
187+
}
188+
142189
/**
143190
* __of_mdiobus_register - Register mii_bus and create PHYs from the device tree
144191
* @mdio: pointer to mii_bus structure
@@ -180,33 +227,18 @@ int __of_mdiobus_register(struct mii_bus *mdio, struct device_node *np,
180227
return rc;
181228

182229
/* Loop over the child nodes and register a phy_device for each phy */
183-
for_each_available_child_of_node(np, child) {
184-
addr = of_mdio_parse_addr(&mdio->dev, child);
185-
if (addr < 0) {
186-
scanphys = true;
187-
continue;
188-
}
189-
190-
if (of_mdiobus_child_is_phy(child))
191-
rc = of_mdiobus_register_phy(mdio, child, addr);
192-
else
193-
rc = of_mdiobus_register_device(mdio, child, addr);
194-
195-
if (rc == -ENODEV)
196-
dev_err(&mdio->dev,
197-
"MDIO device at address %d is missing.\n",
198-
addr);
199-
else if (rc)
200-
goto unregister;
201-
}
230+
rc = __of_mdiobus_parse_phys(mdio, np, &scanphys);
231+
if (rc)
232+
goto unregister;
202233

203234
if (!scanphys)
204235
return 0;
205236

206237
/* auto scan for PHYs with empty reg property */
207238
for_each_available_child_of_node(np, child) {
208-
/* Skip PHYs with reg property set */
209-
if (of_property_present(child, "reg"))
239+
/* Skip PHYs with reg property set or ethernet-phy-package node */
240+
if (of_property_present(child, "reg") ||
241+
of_node_name_eq(child, "ethernet-phy-package"))
210242
continue;
211243

212244
for (addr = 0; addr < PHY_MAX_ADDR; addr++) {
@@ -227,15 +259,16 @@ int __of_mdiobus_register(struct mii_bus *mdio, struct device_node *np,
227259
if (!rc)
228260
break;
229261
if (rc != -ENODEV)
230-
goto unregister;
262+
goto put_unregister;
231263
}
232264
}
233265
}
234266

235267
return 0;
236268

237-
unregister:
269+
put_unregister:
238270
of_node_put(child);
271+
unregister:
239272
mdiobus_unregister(mdio);
240273
return rc;
241274
}

drivers/net/phy/broadcom.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,10 +665,11 @@ static int bcm54616s_config_aneg(struct phy_device *phydev)
665665
static int bcm54616s_read_status(struct phy_device *phydev)
666666
{
667667
struct bcm54616s_phy_priv *priv = phydev->priv;
668+
bool changed;
668669
int err;
669670

670671
if (priv->mode_1000bx_en)
671-
err = genphy_c37_read_status(phydev);
672+
err = genphy_c37_read_status(phydev, &changed);
672673
else
673674
err = genphy_read_status(phydev);
674675

0 commit comments

Comments
 (0)