Skip to content

Commit acd7aaf

Browse files
ardbiesheuvelkuba-moo
authored andcommitted
netsec: ignore 'phy-mode' device property on ACPI systems
Since commit bbc4d71 ("net: phy: realtek: fix rtl8211e rx/tx delay config"), the Realtek PHY driver will override any TX/RX delay set by hardware straps if the phy-mode device property does not match. This is causing problems on SynQuacer based platforms (the only SoC that incorporates the netsec hardware), since many were built with this Realtek PHY, and shipped with firmware that defines the phy-mode as 'rgmii', even though the PHY is configured for TX and RX delay using pull-ups. From the driver's perspective, we should not make any assumptions in the general case that the PHY hardware does not require any initial configuration. However, the situation is slightly different for ACPI boot, since it implies rich firmware with AML abstractions to handle hardware details that are not exposed to the OS. So in the ACPI case, it is reasonable to assume that the PHY comes up in the right mode, regardless of whether the mode is set by straps, by boot time firmware or by AML executed by the ACPI interpreter. So let's ignore the 'phy-mode' device property when probing the netsec driver in ACPI mode, and hardcode the mode to PHY_INTERFACE_MODE_NA, which should work with any PHY provided that it is configured by the time the driver attaches to it. While at it, document that omitting the mode is permitted for DT probing as well, by setting the phy-mode DT property to the empty string. Fixes: 533dd11 ("net: socionext: Add Synquacer NetSec driver") Signed-off-by: Ard Biesheuvel <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 618355c commit acd7aaf

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

Documentation/devicetree/bindings/net/socionext-netsec.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ Optional properties: (See ethernet.txt file in the same directory)
3030
- max-frame-size: See ethernet.txt in the same directory.
3131

3232
The MAC address will be determined using the optional properties
33-
defined in ethernet.txt.
33+
defined in ethernet.txt. The 'phy-mode' property is required, but may
34+
be set to the empty string if the PHY configuration is programmed by
35+
the firmware or set by hardware straps, and needs to be preserved.
3436

3537
Example:
3638
eth0: ethernet@522d0000 {

drivers/net/ethernet/socionext/netsec.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <linux/pm_runtime.h>
77
#include <linux/acpi.h>
88
#include <linux/of_mdio.h>
9+
#include <linux/of_net.h>
910
#include <linux/etherdevice.h>
1011
#include <linux/interrupt.h>
1112
#include <linux/io.h>
@@ -1833,6 +1834,14 @@ static const struct net_device_ops netsec_netdev_ops = {
18331834
static int netsec_of_probe(struct platform_device *pdev,
18341835
struct netsec_priv *priv, u32 *phy_addr)
18351836
{
1837+
int err;
1838+
1839+
err = of_get_phy_mode(pdev->dev.of_node, &priv->phy_interface);
1840+
if (err) {
1841+
dev_err(&pdev->dev, "missing required property 'phy-mode'\n");
1842+
return err;
1843+
}
1844+
18361845
priv->phy_np = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0);
18371846
if (!priv->phy_np) {
18381847
dev_err(&pdev->dev, "missing required property 'phy-handle'\n");
@@ -1859,6 +1868,14 @@ static int netsec_acpi_probe(struct platform_device *pdev,
18591868
if (!IS_ENABLED(CONFIG_ACPI))
18601869
return -ENODEV;
18611870

1871+
/* ACPI systems are assumed to configure the PHY in firmware, so
1872+
* there is really no need to discover the PHY mode from the DSDT.
1873+
* Since firmware is known to exist in the field that configures the
1874+
* PHY correctly but passes the wrong mode string in the phy-mode
1875+
* device property, we have no choice but to ignore it.
1876+
*/
1877+
priv->phy_interface = PHY_INTERFACE_MODE_NA;
1878+
18621879
ret = device_property_read_u32(&pdev->dev, "phy-channel", phy_addr);
18631880
if (ret) {
18641881
dev_err(&pdev->dev,
@@ -1995,13 +2012,6 @@ static int netsec_probe(struct platform_device *pdev)
19952012
priv->msg_enable = NETIF_MSG_TX_ERR | NETIF_MSG_HW | NETIF_MSG_DRV |
19962013
NETIF_MSG_LINK | NETIF_MSG_PROBE;
19972014

1998-
priv->phy_interface = device_get_phy_mode(&pdev->dev);
1999-
if ((int)priv->phy_interface < 0) {
2000-
dev_err(&pdev->dev, "missing required property 'phy-mode'\n");
2001-
ret = -ENODEV;
2002-
goto free_ndev;
2003-
}
2004-
20052015
priv->ioaddr = devm_ioremap(&pdev->dev, mmio_res->start,
20062016
resource_size(mmio_res));
20072017
if (!priv->ioaddr) {

0 commit comments

Comments
 (0)