Skip to content

Commit 96b7a9d

Browse files
author
Paolo Abeni
committed
Merge branch 'net-phy-mxl-gpy-broken-interrupt-fixes'
Michael Walle says: ==================== net: phy: mxl-gpy: broken interrupt fixes The GPY215 has a broken interrupt pin. This patch series tries to workaround that and because in general that is not possible, disables the interrupts by default and falls back to polling mode. There is an opt-in via the devicetree. ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents a3ae160 + 97a89ed commit 96b7a9d

File tree

5 files changed

+64
-0
lines changed

5 files changed

+64
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/net/maxlinear,gpy2xx.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: MaxLinear GPY2xx PHY
8+
9+
maintainers:
10+
- Andrew Lunn <[email protected]>
11+
- Michael Walle <[email protected]>
12+
13+
allOf:
14+
- $ref: ethernet-phy.yaml#
15+
16+
properties:
17+
maxlinear,use-broken-interrupts:
18+
description: |
19+
Interrupts are broken on some GPY2xx PHYs in that they keep the
20+
interrupt line asserted even after the interrupt status register is
21+
cleared. Thus it is blocking the interrupt line which is usually bad
22+
for shared lines. By default interrupts are disabled for this PHY and
23+
polling mode is used. If one can live with the consequences, this
24+
property can be used to enable interrupt handling.
25+
26+
Affected PHYs (as far as known) are GPY215B and GPY215C.
27+
type: boolean
28+
29+
dependencies:
30+
maxlinear,use-broken-interrupts: [ interrupts ]
31+
32+
unevaluatedProperties: false
33+
34+
examples:
35+
- |
36+
ethernet {
37+
#address-cells = <1>;
38+
#size-cells = <0>;
39+
40+
ethernet-phy@0 {
41+
reg = <0>;
42+
interrupts-extended = <&intc 0>;
43+
maxlinear,use-broken-interrupts;
44+
};
45+
};
46+
47+
...

Documentation/devicetree/bindings/vendor-prefixes.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,8 @@ patternProperties:
775775
description: MaxBotix Inc.
776776
"^maxim,.*":
777777
description: Maxim Integrated Products
778+
"^maxlinear,.*":
779+
description: MaxLinear Inc.
778780
"^mbvl,.*":
779781
description: Mobiveil Inc.
780782
"^mcube,.*":

drivers/net/phy/mxl-gpy.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/mutex.h>
1313
#include <linux/phy.h>
1414
#include <linux/polynomial.h>
15+
#include <linux/property.h>
1516
#include <linux/netdevice.h>
1617

1718
/* PHY ID */
@@ -292,6 +293,10 @@ static int gpy_probe(struct phy_device *phydev)
292293
phydev->priv = priv;
293294
mutex_init(&priv->mbox_lock);
294295

296+
if (gpy_has_broken_mdint(phydev) &&
297+
!device_property_present(dev, "maxlinear,use-broken-interrupts"))
298+
phydev->dev_flags |= PHY_F_NO_IRQ;
299+
295300
fw_version = phy_read(phydev, PHY_FWV);
296301
if (fw_version < 0)
297302
return fw_version;

drivers/net/phy/phy_device.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,6 +1487,13 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
14871487

14881488
phydev->interrupts = PHY_INTERRUPT_DISABLED;
14891489

1490+
/* PHYs can request to use poll mode even though they have an
1491+
* associated interrupt line. This could be the case if they
1492+
* detect a broken interrupt handling.
1493+
*/
1494+
if (phydev->dev_flags & PHY_F_NO_IRQ)
1495+
phydev->irq = PHY_POLL;
1496+
14901497
/* Port is set to PORT_TP by default and the actual PHY driver will set
14911498
* it to different value depending on the PHY configuration. If we have
14921499
* the generic PHY driver we can't figure it out, thus set the old

include/linux/phy.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,9 @@ struct phy_device {
739739
#endif
740740
};
741741

742+
/* Generic phy_device::dev_flags */
743+
#define PHY_F_NO_IRQ 0x80000000
744+
742745
static inline struct phy_device *to_phy_device(const struct device *dev)
743746
{
744747
return container_of(to_mdio_device(dev), struct phy_device, mdio);

0 commit comments

Comments
 (0)