* [PATCH RESEND net-next v3 0/3] net: enetc: remove bootloader dependency
@ 2020-07-01 21:34 Michael Walle
2020-07-01 21:34 ` [PATCH RESEND net-next v3 1/3] net: dsa: felix: move USXGMII defines to common place Michael Walle
` (3 more replies)
0 siblings, 4 replies; 11+ messages in thread
From: Michael Walle @ 2020-07-01 21:34 UTC (permalink / raw)
To: netdev, linux-kernel
Cc: David S . Miller, Jakub Kicinski, Andrew Lunn, Michael Walle,
Vladimir Oltean, Alex Marginean, Claudiu Manoil, Heiko Thiery,
Russell King - ARM Linux admin
This is a resend of the series because the conversion to the phylink
interface will likely take longer:
https://lore.kernel.org/netdev/CA+h21hpBodyY8CtNH2ktRdc2FqPi=Fjp94=VVZvzSVbnvnfKVg@mail.gmail.com/
Unfortunately, we have boards in the wild with a bootloader which doesn't
set the PCS up correctly. Thus I'd really see this patches picked up as an
intermediate step until the phylink conversion is ready. Vladimir Oltean
already offered to convert enetc to phylink when he converts the felix to
phylink. After this series the PCS setup of the enetc looks almost the same
as the current felix setup. Thus conversion should be easy.
These patches were picked from the following series:
https://lore.kernel.org/netdev/1567779344-30965-1-git-send-email-claudiu.manoil@nxp.com/
They have never been resent. I've picked them up, addressed Andrews
comments, fixed some more bugs and asked Claudiu if I can keep their SOB
tags; he agreed. I've tested this on our board which happens to have a
bootloader which doesn't do the enetc setup in all cases. Though, only
SGMII mode was tested.
changes since v2:
- removed SOBs from "net: enetc: Initialize SerDes for SGMII and USXGMII
protocols" because almost everything has changed.
- get a phy_device for the internal PCS PHY so we can use the phy_
functions instead of raw mdiobus writes
- reuse macros already defined in fsl_mdio.h, move missing bits from
felix to fsl_mdio.h, because they share the same PCS PHY building
block
- added 2500BaseX mode (based on felix init routine)
- changed xgmii mode to usxgmii mode, because it is actually USXGMII and
felix does the same.
- fixed devad, which is 0x1f (MMD_VEND2)
changes since v1:
- mdiobus id is '"imdio-%s", dev_name(dev)' because the plain dev_name()
is used by the emdio.
- use mdiobus_write() instead of imdio->write(imdio, ..), since this is
already a full featured mdiobus
- set phy_mask to ~0 to avoid scanning the bus
- use phy_interface_mode_is_rgmii(phy_mode) to also include the RGMII
modes with pad delays.
- move enetc_imdio_init() to enetc_pf.c, there shouldn't be any other
users, should it?
- renamed serdes to SerDes
- printing the error code of mdiobus_register() in the error path
- call mdiobus_unregister() on _remove()
- call devm_mdiobus_free() if mdiobus_register() fails, since an
error is not fatal
Alex Marginean (1):
net: enetc: Use DT protocol information to set up the ports
Michael Walle (2):
net: dsa: felix: move USXGMII defines to common place
net: enetc: Initialize SerDes for SGMII and USXGMII protocols
drivers/net/dsa/ocelot/felix_vsc9959.c | 21 --
.../net/ethernet/freescale/enetc/enetc_hw.h | 3 +
.../net/ethernet/freescale/enetc/enetc_pf.c | 191 +++++++++++++++---
.../net/ethernet/freescale/enetc/enetc_pf.h | 5 +
include/linux/fsl/enetc_mdio.h | 19 ++
5 files changed, 194 insertions(+), 45 deletions(-)
--
2.20.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH RESEND net-next v3 1/3] net: dsa: felix: move USXGMII defines to common place
2020-07-01 21:34 [PATCH RESEND net-next v3 0/3] net: enetc: remove bootloader dependency Michael Walle
@ 2020-07-01 21:34 ` Michael Walle
2020-07-01 21:34 ` [PATCH RESEND net-next v3 2/3] net: enetc: Initialize SerDes for SGMII and USXGMII protocols Michael Walle
` (2 subsequent siblings)
3 siblings, 0 replies; 11+ messages in thread
From: Michael Walle @ 2020-07-01 21:34 UTC (permalink / raw)
To: netdev, linux-kernel
Cc: David S . Miller, Jakub Kicinski, Andrew Lunn, Michael Walle,
Vladimir Oltean, Alex Marginean, Claudiu Manoil, Heiko Thiery,
Russell King - ARM Linux admin
The ENETC has the same PCS PHY and thus needs the same definitions. Move
them into the common enetc_mdio.h header which has already the macros
for the SGMII PCS.
Signed-off-by: Michael Walle <michael@walle.cc>
---
drivers/net/dsa/ocelot/felix_vsc9959.c | 21 ---------------------
include/linux/fsl/enetc_mdio.h | 19 +++++++++++++++++++
2 files changed, 19 insertions(+), 21 deletions(-)
diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c
index 1dd9e348152d..986d4d26aa3c 100644
--- a/drivers/net/dsa/ocelot/felix_vsc9959.c
+++ b/drivers/net/dsa/ocelot/felix_vsc9959.c
@@ -16,29 +16,8 @@
#define VSC9959_VCAP_IS2_CNT 1024
#define VSC9959_VCAP_IS2_ENTRY_WIDTH 376
#define VSC9959_VCAP_PORT_CNT 6
-
-/* TODO: should find a better place for these */
-#define USXGMII_BMCR_RESET BIT(15)
-#define USXGMII_BMCR_AN_EN BIT(12)
-#define USXGMII_BMCR_RST_AN BIT(9)
-#define USXGMII_BMSR_LNKS(status) (((status) & GENMASK(2, 2)) >> 2)
-#define USXGMII_BMSR_AN_CMPL(status) (((status) & GENMASK(5, 5)) >> 5)
-#define USXGMII_ADVERTISE_LNKS(x) (((x) << 15) & BIT(15))
-#define USXGMII_ADVERTISE_FDX BIT(12)
-#define USXGMII_ADVERTISE_SPEED(x) (((x) << 9) & GENMASK(11, 9))
-#define USXGMII_LPA_LNKS(lpa) ((lpa) >> 15)
-#define USXGMII_LPA_DUPLEX(lpa) (((lpa) & GENMASK(12, 12)) >> 12)
-#define USXGMII_LPA_SPEED(lpa) (((lpa) & GENMASK(11, 9)) >> 9)
-
#define VSC9959_TAS_GCL_ENTRY_MAX 63
-enum usxgmii_speed {
- USXGMII_SPEED_10 = 0,
- USXGMII_SPEED_100 = 1,
- USXGMII_SPEED_1000 = 2,
- USXGMII_SPEED_2500 = 4,
-};
-
static const u32 vsc9959_ana_regmap[] = {
REG(ANA_ADVLEARN, 0x0089a0),
REG(ANA_VLANMASK, 0x0089a4),
diff --git a/include/linux/fsl/enetc_mdio.h b/include/linux/fsl/enetc_mdio.h
index 4875dd38af7e..0129366fa47a 100644
--- a/include/linux/fsl/enetc_mdio.h
+++ b/include/linux/fsl/enetc_mdio.h
@@ -27,6 +27,25 @@ enum enetc_pcs_speed {
ENETC_PCS_SPEED_2500 = 2,
};
+#define USXGMII_BMCR_RESET BIT(15)
+#define USXGMII_BMCR_AN_EN BIT(12)
+#define USXGMII_BMCR_RST_AN BIT(9)
+#define USXGMII_BMSR_LNKS(status) (((status) & GENMASK(2, 2)) >> 2)
+#define USXGMII_BMSR_AN_CMPL(status) (((status) & GENMASK(5, 5)) >> 5)
+#define USXGMII_ADVERTISE_LNKS(x) (((x) << 15) & BIT(15))
+#define USXGMII_ADVERTISE_FDX BIT(12)
+#define USXGMII_ADVERTISE_SPEED(x) (((x) << 9) & GENMASK(11, 9))
+#define USXGMII_LPA_LNKS(lpa) ((lpa) >> 15)
+#define USXGMII_LPA_DUPLEX(lpa) (((lpa) & GENMASK(12, 12)) >> 12)
+#define USXGMII_LPA_SPEED(lpa) (((lpa) & GENMASK(11, 9)) >> 9)
+
+enum usxgmii_speed {
+ USXGMII_SPEED_10 = 0,
+ USXGMII_SPEED_100 = 1,
+ USXGMII_SPEED_1000 = 2,
+ USXGMII_SPEED_2500 = 4,
+};
+
struct enetc_hw;
struct enetc_mdio_priv {
--
2.20.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH RESEND net-next v3 2/3] net: enetc: Initialize SerDes for SGMII and USXGMII protocols
2020-07-01 21:34 [PATCH RESEND net-next v3 0/3] net: enetc: remove bootloader dependency Michael Walle
2020-07-01 21:34 ` [PATCH RESEND net-next v3 1/3] net: dsa: felix: move USXGMII defines to common place Michael Walle
@ 2020-07-01 21:34 ` Michael Walle
2020-07-02 0:39 ` Jakub Kicinski
2020-07-02 3:16 ` kernel test robot
2020-07-01 21:34 ` [PATCH RESEND net-next v3 3/3] net: enetc: Use DT protocol information to set up the ports Michael Walle
2020-07-01 21:53 ` [PATCH RESEND net-next v3 0/3] net: enetc: remove bootloader dependency Russell King - ARM Linux admin
3 siblings, 2 replies; 11+ messages in thread
From: Michael Walle @ 2020-07-01 21:34 UTC (permalink / raw)
To: netdev, linux-kernel
Cc: David S . Miller, Jakub Kicinski, Andrew Lunn, Michael Walle,
Vladimir Oltean, Alex Marginean, Claudiu Manoil, Heiko Thiery,
Russell King - ARM Linux admin
ENETC has ethernet MACs capable of SGMII, 2500BaseX and USXGMII. But in
order to use these protocols some SerDes configurations need to be
performed. The SerDes is configurable via an internal PCS PHY which is
connected to an internal MDIO bus at address 0.
This patch basically removes the dependency on bootloader regarding
SerDes initialization.
Signed-off-by: Michael Walle <michael@walle.cc>
---
.../net/ethernet/freescale/enetc/enetc_hw.h | 3 +
.../net/ethernet/freescale/enetc/enetc_pf.c | 135 ++++++++++++++++++
.../net/ethernet/freescale/enetc/enetc_pf.h | 2 +
3 files changed, 140 insertions(+)
diff --git a/drivers/net/ethernet/freescale/enetc/enetc_hw.h b/drivers/net/ethernet/freescale/enetc/enetc_hw.h
index 6314051bc6c1..e80c2c36dbe9 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc_hw.h
+++ b/drivers/net/ethernet/freescale/enetc/enetc_hw.h
@@ -224,6 +224,9 @@ enum enetc_bdr_type {TX, RX};
#define ENETC_PM0_MAXFRM 0x8014
#define ENETC_SET_TX_MTU(val) ((val) << 16)
#define ENETC_SET_MAXFRM(val) ((val) & 0xffff)
+
+#define ENETC_PM_IMDIO_BASE 0x8030
+
#define ENETC_PM0_IF_MODE 0x8300
#define ENETC_PMO_IFM_RG BIT(2)
#define ENETC_PM0_IFM_RLP (BIT(5) | BIT(11))
diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c
index 824d211ec00f..79499a81c77b 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c
@@ -841,6 +841,136 @@ static void enetc_of_put_phy(struct enetc_ndev_priv *priv)
of_node_put(priv->phy_node);
}
+static int enetc_imdio_init(struct enetc_pf *pf, bool is_c45)
+{
+ struct device *dev = &pf->si->pdev->dev;
+ struct enetc_mdio_priv *mdio_priv;
+ struct phy_device *pcs;
+ struct mii_bus *bus;
+ int err;
+
+ bus = devm_mdiobus_alloc_size(dev, sizeof(*mdio_priv));
+ if (!bus)
+ return -ENOMEM;
+
+ bus->name = "Freescale ENETC internal MDIO Bus";
+ bus->read = enetc_mdio_read;
+ bus->write = enetc_mdio_write;
+ bus->parent = dev;
+ bus->phy_mask = ~0;
+ mdio_priv = bus->priv;
+ mdio_priv->hw = &pf->si->hw;
+ mdio_priv->mdio_base = ENETC_PM_IMDIO_BASE;
+ snprintf(bus->id, MII_BUS_ID_SIZE, "%s-imdio", dev_name(dev));
+
+ err = mdiobus_register(bus);
+ if (err) {
+ dev_err(dev, "cannot register internal MDIO bus (%d)\n", err);
+ goto free_mdio_bus;
+ }
+
+ pcs = get_phy_device(bus, 0, is_c45);
+ if (IS_ERR(pcs)) {
+ err = PTR_ERR(pcs);
+ dev_err(dev, "cannot get internal PCS PHY (%d)\n", err);
+ goto unregister_mdiobus;
+ }
+
+ pf->imdio = bus;
+ pf->pcs = pcs;
+
+ return 0;
+
+unregister_mdiobus:
+ mdiobus_unregister(bus);
+free_mdio_bus:
+ devm_mdiobus_free(dev, bus);
+ return err;
+}
+
+static void enetc_imdio_remove(struct enetc_pf *pf)
+{
+ if (pf->pcs)
+ put_device(&pf->pcs->mdio.dev);
+ if (pf->imdio)
+ mdiobus_unregister(pf->imdio);
+}
+
+static void enetc_configure_sgmii(struct phy_device *pcs)
+{
+ /* SGMII spec requires tx_config_Reg[15:0] to be exactly 0x4001
+ * for the MAC PCS in order to acknowledge the AN.
+ */
+ phy_write(pcs, MII_ADVERTISE, ADVERTISE_SGMII | ADVERTISE_LPACK);
+
+ phy_write(pcs, ENETC_PCS_IF_MODE,
+ ENETC_PCS_IF_MODE_SGMII_EN |
+ ENETC_PCS_IF_MODE_USE_SGMII_AN);
+
+ /* Adjust link timer for SGMII */
+ phy_write(pcs, ENETC_PCS_LINK_TIMER1, ENETC_PCS_LINK_TIMER1_VAL);
+ phy_write(pcs, ENETC_PCS_LINK_TIMER2, ENETC_PCS_LINK_TIMER2_VAL);
+
+ phy_write(pcs, MII_BMCR, BMCR_ANRESTART | BMCR_ANENABLE);
+}
+
+static void enetc_configure_2500basex(struct phy_device *pcs)
+{
+ phy_write(pcs, ENETC_PCS_IF_MODE,
+ ENETC_PCS_IF_MODE_SGMII_EN |
+ ENETC_PCS_IF_MODE_SGMII_SPEED(ENETC_PCS_SPEED_2500));
+
+ phy_write(pcs, MII_BMCR, BMCR_SPEED1000 | BMCR_FULLDPLX | BMCR_RESET);
+}
+
+static void enetc_configure_usxgmii(struct phy_device *pcs)
+{
+ /* Configure device ability for the USXGMII Replicator */
+ phy_write_mmd(pcs, MDIO_MMD_VEND2, MII_ADVERTISE,
+ ADVERTISE_SGMII |
+ ADVERTISE_LPACK |
+ USXGMII_ADVERTISE_FDX);
+
+ /* Restart PCS AN */
+ phy_write_mmd(pcs, MDIO_MMD_VEND2, MII_BMCR,
+ USXGMII_BMCR_RESET |
+ USXGMII_BMCR_AN_EN |
+ USXGMII_BMCR_RST_AN);
+}
+
+static int enetc_configure_serdes(struct enetc_ndev_priv *priv)
+{
+ bool is_c45 = priv->if_mode == PHY_INTERFACE_MODE_USXGMII;
+ struct enetc_pf *pf = enetc_si_priv(priv->si);
+ int err;
+
+ if (priv->if_mode != PHY_INTERFACE_MODE_SGMII &&
+ priv->if_mode != PHY_INTERFACE_MODE_2500BASEX &&
+ priv->if_mode != PHY_INTERFACE_MODE_USXGMII)
+ return 0;
+
+ err = enetc_imdio_init(pf, is_c45);
+ if (err)
+ return err;
+
+ switch (priv->if_mode) {
+ case PHY_INTERFACE_MODE_SGMII:
+ enetc_configure_sgmii(pf->pcs);
+ break;
+ case PHY_INTERFACE_MODE_2500BASEX:
+ enetc_configure_2500basex(pf->pcs);
+ break;
+ case PHY_INTERFACE_MODE_USXGMII:
+ enetc_configure_usxgmii(pf->pcs);
+ break;
+ default:
+ dev_err(&pf->si->pdev->dev, "Unsupported link mode %s\n",
+ phy_modes(priv->if_mode));
+ }
+
+ return 0;
+}
+
static int enetc_pf_probe(struct pci_dev *pdev,
const struct pci_device_id *ent)
{
@@ -905,6 +1035,10 @@ static int enetc_pf_probe(struct pci_dev *pdev,
if (err)
dev_warn(&pdev->dev, "Fallback to PHY-less operation\n");
+ err = enetc_configure_serdes(priv);
+ if (err)
+ dev_warn(&pdev->dev, "Attempted SerDes config but failed\n");
+
err = register_netdev(ndev);
if (err)
goto err_reg_netdev;
@@ -940,6 +1074,7 @@ static void enetc_pf_remove(struct pci_dev *pdev)
priv = netdev_priv(si->ndev);
unregister_netdev(si->ndev);
+ enetc_imdio_remove(pf);
enetc_mdio_remove(pf);
enetc_of_put_phy(priv);
diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.h b/drivers/net/ethernet/freescale/enetc/enetc_pf.h
index 59e65a6f6c3e..2cb922b59f46 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc_pf.h
+++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.h
@@ -44,6 +44,8 @@ struct enetc_pf {
DECLARE_BITMAP(active_vlans, VLAN_N_VID);
struct mii_bus *mdio; /* saved for cleanup */
+ struct mii_bus *imdio;
+ struct phy_device *pcs;
};
int enetc_msg_psi_init(struct enetc_pf *pf);
--
2.20.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH RESEND net-next v3 3/3] net: enetc: Use DT protocol information to set up the ports
2020-07-01 21:34 [PATCH RESEND net-next v3 0/3] net: enetc: remove bootloader dependency Michael Walle
2020-07-01 21:34 ` [PATCH RESEND net-next v3 1/3] net: dsa: felix: move USXGMII defines to common place Michael Walle
2020-07-01 21:34 ` [PATCH RESEND net-next v3 2/3] net: enetc: Initialize SerDes for SGMII and USXGMII protocols Michael Walle
@ 2020-07-01 21:34 ` Michael Walle
2020-07-01 21:53 ` [PATCH RESEND net-next v3 0/3] net: enetc: remove bootloader dependency Russell King - ARM Linux admin
3 siblings, 0 replies; 11+ messages in thread
From: Michael Walle @ 2020-07-01 21:34 UTC (permalink / raw)
To: netdev, linux-kernel
Cc: David S . Miller, Jakub Kicinski, Andrew Lunn, Michael Walle,
Vladimir Oltean, Alex Marginean, Claudiu Manoil, Heiko Thiery,
Russell King - ARM Linux admin
From: Alex Marginean <alexandru.marginean@nxp.com>
Use DT information rather than in-band information from bootloader to
set up MAC for XGMII. For RGMII use the DT indication in addition to
RGMII defaults in hardware.
However, this implies that PHY connection information needs to be
extracted before netdevice creation, when the ENETC Port MAC is
being configured.
Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com>
Signed-off-by: Claudiu Manoil <claudiu.manoil@nxp.com>
Signed-off-by: Michael Walle <michael@walle.cc>
---
.../net/ethernet/freescale/enetc/enetc_pf.c | 57 ++++++++++---------
.../net/ethernet/freescale/enetc/enetc_pf.h | 3 +
2 files changed, 34 insertions(+), 26 deletions(-)
diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c
index 79499a81c77b..414a9b1b2813 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c
@@ -481,7 +481,8 @@ static void enetc_port_si_configure(struct enetc_si *si)
enetc_port_wr(hw, ENETC_PSIVLANFMR, ENETC_PSIVLANFMR_VS);
}
-static void enetc_configure_port_mac(struct enetc_hw *hw)
+static void enetc_configure_port_mac(struct enetc_hw *hw,
+ phy_interface_t phy_mode)
{
enetc_port_wr(hw, ENETC_PM0_MAXFRM,
ENETC_SET_MAXFRM(ENETC_RX_MAXFRM_SIZE));
@@ -497,9 +498,11 @@ static void enetc_configure_port_mac(struct enetc_hw *hw)
ENETC_PM0_CMD_TXP | ENETC_PM0_PROMISC |
ENETC_PM0_TX_EN | ENETC_PM0_RX_EN);
/* set auto-speed for RGMII */
- if (enetc_port_rd(hw, ENETC_PM0_IF_MODE) & ENETC_PMO_IFM_RG)
+ if (enetc_port_rd(hw, ENETC_PM0_IF_MODE) & ENETC_PMO_IFM_RG ||
+ phy_interface_mode_is_rgmii(phy_mode))
enetc_port_wr(hw, ENETC_PM0_IF_MODE, ENETC_PM0_IFM_RGAUTO);
- if (enetc_global_rd(hw, ENETC_G_EPFBLPR(1)) == ENETC_G_EPFBLPR1_XGMII)
+
+ if (phy_mode == PHY_INTERFACE_MODE_USXGMII)
enetc_port_wr(hw, ENETC_PM0_IF_MODE, ENETC_PM0_IFM_XGMII);
}
@@ -523,7 +526,7 @@ static void enetc_configure_port(struct enetc_pf *pf)
enetc_configure_port_pmac(hw);
- enetc_configure_port_mac(hw);
+ enetc_configure_port_mac(hw, pf->if_mode);
enetc_port_si_configure(pf->si);
@@ -783,27 +786,27 @@ static void enetc_mdio_remove(struct enetc_pf *pf)
mdiobus_unregister(pf->mdio);
}
-static int enetc_of_get_phy(struct enetc_ndev_priv *priv)
+static int enetc_of_get_phy(struct enetc_pf *pf)
{
- struct enetc_pf *pf = enetc_si_priv(priv->si);
- struct device_node *np = priv->dev->of_node;
+ struct device *dev = &pf->si->pdev->dev;
+ struct device_node *np = dev->of_node;
struct device_node *mdio_np;
int err;
- priv->phy_node = of_parse_phandle(np, "phy-handle", 0);
- if (!priv->phy_node) {
+ pf->phy_node = of_parse_phandle(np, "phy-handle", 0);
+ if (!pf->phy_node) {
if (!of_phy_is_fixed_link(np)) {
- dev_err(priv->dev, "PHY not specified\n");
+ dev_err(dev, "PHY not specified\n");
return -ENODEV;
}
err = of_phy_register_fixed_link(np);
if (err < 0) {
- dev_err(priv->dev, "fixed link registration failed\n");
+ dev_err(dev, "fixed link registration failed\n");
return err;
}
- priv->phy_node = of_node_get(np);
+ pf->phy_node = of_node_get(np);
}
mdio_np = of_get_child_by_name(np, "mdio");
@@ -811,15 +814,15 @@ static int enetc_of_get_phy(struct enetc_ndev_priv *priv)
of_node_put(mdio_np);
err = enetc_mdio_probe(pf);
if (err) {
- of_node_put(priv->phy_node);
+ of_node_put(pf->phy_node);
return err;
}
}
- err = of_get_phy_mode(np, &priv->if_mode);
+ err = of_get_phy_mode(np, &pf->if_mode);
if (err) {
- dev_err(priv->dev, "missing phy type\n");
- of_node_put(priv->phy_node);
+ dev_err(dev, "missing phy type\n");
+ of_node_put(pf->phy_node);
if (of_phy_is_fixed_link(np))
of_phy_deregister_fixed_link(np);
else
@@ -831,14 +834,14 @@ static int enetc_of_get_phy(struct enetc_ndev_priv *priv)
return 0;
}
-static void enetc_of_put_phy(struct enetc_ndev_priv *priv)
+static void enetc_of_put_phy(struct enetc_pf *pf)
{
- struct device_node *np = priv->dev->of_node;
+ struct device_node *np = pf->si->pdev->dev.of_node;
if (np && of_phy_is_fixed_link(np))
of_phy_deregister_fixed_link(np);
- if (priv->phy_node)
- of_node_put(priv->phy_node);
+ if (pf->phy_node)
+ of_node_put(pf->phy_node);
}
static int enetc_imdio_init(struct enetc_pf *pf, bool is_c45)
@@ -1002,6 +1005,10 @@ static int enetc_pf_probe(struct pci_dev *pdev,
pf->si = si;
pf->total_vfs = pci_sriov_get_totalvfs(pdev);
+ err = enetc_of_get_phy(pf);
+ if (err)
+ dev_warn(&pdev->dev, "Fallback to PHY-less operation\n");
+
enetc_configure_port(pf);
enetc_get_si_caps(si);
@@ -1016,6 +1023,8 @@ static int enetc_pf_probe(struct pci_dev *pdev,
enetc_pf_netdev_setup(si, ndev, &enetc_ndev_ops);
priv = netdev_priv(ndev);
+ priv->phy_node = pf->phy_node;
+ priv->if_mode = pf->if_mode;
enetc_init_si_rings_params(priv);
@@ -1031,10 +1040,6 @@ static int enetc_pf_probe(struct pci_dev *pdev,
goto err_alloc_msix;
}
- err = enetc_of_get_phy(priv);
- if (err)
- dev_warn(&pdev->dev, "Fallback to PHY-less operation\n");
-
err = enetc_configure_serdes(priv);
if (err)
dev_warn(&pdev->dev, "Attempted SerDes config but failed\n");
@@ -1048,7 +1053,6 @@ static int enetc_pf_probe(struct pci_dev *pdev,
return 0;
err_reg_netdev:
- enetc_of_put_phy(priv);
enetc_free_msix(priv);
err_alloc_msix:
enetc_free_si_resources(priv);
@@ -1056,6 +1060,7 @@ static int enetc_pf_probe(struct pci_dev *pdev,
si->ndev = NULL;
free_netdev(ndev);
err_alloc_netdev:
+ enetc_of_put_phy(pf);
err_map_pf_space:
enetc_pci_remove(pdev);
@@ -1076,7 +1081,7 @@ static void enetc_pf_remove(struct pci_dev *pdev)
enetc_imdio_remove(pf);
enetc_mdio_remove(pf);
- enetc_of_put_phy(priv);
+ enetc_of_put_phy(pf);
enetc_free_msix(priv);
diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.h b/drivers/net/ethernet/freescale/enetc/enetc_pf.h
index 2cb922b59f46..0d0ee91282a5 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc_pf.h
+++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.h
@@ -46,6 +46,9 @@ struct enetc_pf {
struct mii_bus *mdio; /* saved for cleanup */
struct mii_bus *imdio;
struct phy_device *pcs;
+
+ struct device_node *phy_node;
+ phy_interface_t if_mode;
};
int enetc_msg_psi_init(struct enetc_pf *pf);
--
2.20.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH RESEND net-next v3 0/3] net: enetc: remove bootloader dependency
2020-07-01 21:34 [PATCH RESEND net-next v3 0/3] net: enetc: remove bootloader dependency Michael Walle
` (2 preceding siblings ...)
2020-07-01 21:34 ` [PATCH RESEND net-next v3 3/3] net: enetc: Use DT protocol information to set up the ports Michael Walle
@ 2020-07-01 21:53 ` Russell King - ARM Linux admin
2020-07-01 22:04 ` Vladimir Oltean
3 siblings, 1 reply; 11+ messages in thread
From: Russell King - ARM Linux admin @ 2020-07-01 21:53 UTC (permalink / raw)
To: Michael Walle
Cc: netdev, linux-kernel, David S . Miller, Jakub Kicinski,
Andrew Lunn, Vladimir Oltean, Alex Marginean, Claudiu Manoil,
Heiko Thiery
On Wed, Jul 01, 2020 at 11:34:30PM +0200, Michael Walle wrote:
> This is a resend of the series because the conversion to the phylink
> interface will likely take longer:
> https://lore.kernel.org/netdev/CA+h21hpBodyY8CtNH2ktRdc2FqPi=Fjp94=VVZvzSVbnvnfKVg@mail.gmail.com/
I don't think it will; I've given people notice of potential changes
back in February, and as Florian has pointed out, that's ample enough
time that it's now no problem if I push my series and it causes
breakage to drivers that haven't updated. I've also gone way beyond
what would normally be done, fixing up almost every driver the best
I can with the exception of two - felix DSA and Mediatek.
Some of the patches have been reviewed already, Ioana at NXP is happy
with them. There's a bit of tweaking of a couple of patches and
adding some documentation, and then they're good to go.
I'm not going to wait for Felix or Mediatek. As I say, I've given
plenty of warning, and it's only a _suspicion_ of breakage on my
side.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH RESEND net-next v3 0/3] net: enetc: remove bootloader dependency
2020-07-01 21:53 ` [PATCH RESEND net-next v3 0/3] net: enetc: remove bootloader dependency Russell King - ARM Linux admin
@ 2020-07-01 22:04 ` Vladimir Oltean
2020-07-02 8:41 ` Russell King - ARM Linux admin
0 siblings, 1 reply; 11+ messages in thread
From: Vladimir Oltean @ 2020-07-01 22:04 UTC (permalink / raw)
To: Russell King - ARM Linux admin
Cc: Michael Walle, netdev, lkml, David S . Miller, Jakub Kicinski,
Andrew Lunn, Alex Marginean, Claudiu Manoil, Heiko Thiery
On Thu, 2 Jul 2020 at 00:53, Russell King - ARM Linux admin
<linux@armlinux.org.uk> wrote:
>
> fixing up almost every driver the best I can with the exception of two -
> felix DSA and Mediatek.
>
> I'm not going to wait for Felix or Mediatek. As I say, I've given
> plenty of warning, and it's only a _suspicion_ of breakage on my
> side.
>
What do you mean "I'm not going to wait for Felix"?
https://patchwork.ozlabs.org/project/netdev/patch/20200625152331.3784018-5-olteanv@gmail.com/
We left it at:
> I'm not going to review patch 7
> tonight because of this fiasco. To pissed off to do a decent job, so
> you're just going to have to wait.
So, I was actively waiting for you to review it ever since, just like
you said, so I could send a v2. Were you waiting for anything?
Thank you,
-Vladimir
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH RESEND net-next v3 2/3] net: enetc: Initialize SerDes for SGMII and USXGMII protocols
2020-07-01 21:34 ` [PATCH RESEND net-next v3 2/3] net: enetc: Initialize SerDes for SGMII and USXGMII protocols Michael Walle
@ 2020-07-02 0:39 ` Jakub Kicinski
2020-07-02 3:16 ` kernel test robot
1 sibling, 0 replies; 11+ messages in thread
From: Jakub Kicinski @ 2020-07-02 0:39 UTC (permalink / raw)
To: Michael Walle
Cc: netdev, linux-kernel, David S . Miller, Andrew Lunn,
Vladimir Oltean, Alex Marginean, Claudiu Manoil, Heiko Thiery,
Russell King - ARM Linux admin
On Wed, 1 Jul 2020 23:34:32 +0200 Michael Walle wrote:
> ENETC has ethernet MACs capable of SGMII, 2500BaseX and USXGMII. But in
> order to use these protocols some SerDes configurations need to be
> performed. The SerDes is configurable via an internal PCS PHY which is
> connected to an internal MDIO bus at address 0.
>
> This patch basically removes the dependency on bootloader regarding
> SerDes initialization.
>
> Signed-off-by: Michael Walle <michael@walle.cc>
This does not build
../drivers/net/ethernet/freescale/enetc/enetc_pf.c:879:2: error: implicit declaration of function `devm_mdiobus_free`; did you mean `devm_mdiobus_alloc`? [-Werror=implicit-function-declaration]
879 | devm_mdiobus_free(dev, bus);
| ^~~~~~~~~~~~~~~~~
| devm_mdiobus_alloc
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH RESEND net-next v3 2/3] net: enetc: Initialize SerDes for SGMII and USXGMII protocols
2020-07-01 21:34 ` [PATCH RESEND net-next v3 2/3] net: enetc: Initialize SerDes for SGMII and USXGMII protocols Michael Walle
2020-07-02 0:39 ` Jakub Kicinski
@ 2020-07-02 3:16 ` kernel test robot
1 sibling, 0 replies; 11+ messages in thread
From: kernel test robot @ 2020-07-02 3:16 UTC (permalink / raw)
To: Michael Walle, netdev, linux-kernel
Cc: kbuild-all, clang-built-linux, David S . Miller, Jakub Kicinski,
Andrew Lunn, Michael Walle, Vladimir Oltean, Alex Marginean,
Claudiu Manoil, Heiko Thiery
[-- Attachment #1: Type: text/plain, Size: 2898 bytes --]
Hi Michael,
I love your patch! Yet something to improve:
[auto build test ERROR on net-next/master]
url: https://github.com/0day-ci/linux/commits/Michael-Walle/net-enetc-remove-bootloader-dependency/20200702-053650
base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 2b04a66156159592156a97553057e8c36de2ee70
config: x86_64-allyesconfig (attached as .config)
compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project c8f1d442d0858f66fd4128fde6f67eb5202fa2b1)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
>> drivers/net/ethernet/freescale/enetc/enetc_pf.c:879:2: error: implicit declaration of function 'devm_mdiobus_free' [-Werror,-Wimplicit-function-declaration]
devm_mdiobus_free(dev, bus);
^
1 error generated.
vim +/devm_mdiobus_free +879 drivers/net/ethernet/freescale/enetc/enetc_pf.c
835
836 static int enetc_imdio_init(struct enetc_pf *pf, bool is_c45)
837 {
838 struct device *dev = &pf->si->pdev->dev;
839 struct enetc_mdio_priv *mdio_priv;
840 struct phy_device *pcs;
841 struct mii_bus *bus;
842 int err;
843
844 bus = devm_mdiobus_alloc_size(dev, sizeof(*mdio_priv));
845 if (!bus)
846 return -ENOMEM;
847
848 bus->name = "Freescale ENETC internal MDIO Bus";
849 bus->read = enetc_mdio_read;
850 bus->write = enetc_mdio_write;
851 bus->parent = dev;
852 bus->phy_mask = ~0;
853 mdio_priv = bus->priv;
854 mdio_priv->hw = &pf->si->hw;
855 mdio_priv->mdio_base = ENETC_PM_IMDIO_BASE;
856 snprintf(bus->id, MII_BUS_ID_SIZE, "%s-imdio", dev_name(dev));
857
858 err = mdiobus_register(bus);
859 if (err) {
860 dev_err(dev, "cannot register internal MDIO bus (%d)\n", err);
861 goto free_mdio_bus;
862 }
863
864 pcs = get_phy_device(bus, 0, is_c45);
865 if (IS_ERR(pcs)) {
866 err = PTR_ERR(pcs);
867 dev_err(dev, "cannot get internal PCS PHY (%d)\n", err);
868 goto unregister_mdiobus;
869 }
870
871 pf->imdio = bus;
872 pf->pcs = pcs;
873
874 return 0;
875
876 unregister_mdiobus:
877 mdiobus_unregister(bus);
878 free_mdio_bus:
> 879 devm_mdiobus_free(dev, bus);
880 return err;
881 }
882
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 75293 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH RESEND net-next v3 0/3] net: enetc: remove bootloader dependency
2020-07-01 22:04 ` Vladimir Oltean
@ 2020-07-02 8:41 ` Russell King - ARM Linux admin
2020-07-02 9:41 ` Vladimir Oltean
0 siblings, 1 reply; 11+ messages in thread
From: Russell King - ARM Linux admin @ 2020-07-02 8:41 UTC (permalink / raw)
To: Vladimir Oltean
Cc: Michael Walle, netdev, lkml, David S . Miller, Jakub Kicinski,
Andrew Lunn, Alex Marginean, Claudiu Manoil, Heiko Thiery
On Thu, Jul 02, 2020 at 01:04:02AM +0300, Vladimir Oltean wrote:
> On Thu, 2 Jul 2020 at 00:53, Russell King - ARM Linux admin
> <linux@armlinux.org.uk> wrote:
> >
> > fixing up almost every driver the best I can with the exception of two -
> > felix DSA and Mediatek.
> >
> > I'm not going to wait for Felix or Mediatek. As I say, I've given
> > plenty of warning, and it's only a _suspicion_ of breakage on my
> > side.
> >
>
> What do you mean "I'm not going to wait for Felix"?
> https://patchwork.ozlabs.org/project/netdev/patch/20200625152331.3784018-5-olteanv@gmail.com/
> We left it at:
>
> > I'm not going to review patch 7
> > tonight because of this fiasco. To pissed off to do a decent job, so
> > you're just going to have to wait.
>
> So, I was actively waiting for you to review it ever since, just like
> you said, so I could send a v2. Were you waiting for anything?
I stopped being interested in your series with the patch 5 commit
description issue; what happened there is really demotivating.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH RESEND net-next v3 0/3] net: enetc: remove bootloader dependency
2020-07-02 8:41 ` Russell King - ARM Linux admin
@ 2020-07-02 9:41 ` Vladimir Oltean
2020-07-04 10:00 ` Russell King - ARM Linux admin
0 siblings, 1 reply; 11+ messages in thread
From: Vladimir Oltean @ 2020-07-02 9:41 UTC (permalink / raw)
To: Russell King - ARM Linux admin
Cc: Michael Walle, netdev, lkml, David S . Miller, Jakub Kicinski,
Andrew Lunn, Alex Marginean, Claudiu Manoil, Heiko Thiery
On Thu, 2 Jul 2020 at 11:41, Russell King - ARM Linux admin
<linux@armlinux.org.uk> wrote:
>
> On Thu, Jul 02, 2020 at 01:04:02AM +0300, Vladimir Oltean wrote:
> > On Thu, 2 Jul 2020 at 00:53, Russell King - ARM Linux admin
> > <linux@armlinux.org.uk> wrote:
> > >
> > > fixing up almost every driver the best I can with the exception of two -
> > > felix DSA and Mediatek.
> > >
> > > I'm not going to wait for Felix or Mediatek. As I say, I've given
> > > plenty of warning, and it's only a _suspicion_ of breakage on my
> > > side.
> > >
> >
> > What do you mean "I'm not going to wait for Felix"?
> > https://patchwork.ozlabs.org/project/netdev/patch/20200625152331.3784018-5-olteanv@gmail.com/
> > We left it at:
> >
> > > I'm not going to review patch 7
> > > tonight because of this fiasco. To pissed off to do a decent job, so
> > > you're just going to have to wait.
> >
> > So, I was actively waiting for you to review it ever since, just like
> > you said, so I could send a v2. Were you waiting for anything?
>
> I stopped being interested in your series with the patch 5 commit
> description issue; what happened there is really demotivating.
>
> --
> RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
> FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
Yes, but I mean, the fact that reviewing felix is "demotivating" can
only have 2 courses of action as far as I can see:
- I do resubmit the series with feedback that you've given so far, but
it's likely going to take a few more iterations because you haven't
reviewed the current series in its entirety, and you haven't in fact
reviewed the part which you consider as a dependency for your work yet
(the mac_link_up conversion). But this goes against your argument that
the lynx pcs will land quickly, so Michael should just wait a little
bit more.
- As per your "I'm not going to wait for Felix or Mediatek" phrase,
you might decide you just don't deal with DSA any longer, and you
proceed with the PCS patches by essentially breaking the dependency.
In this case, I'm not sure why Michael would need to wait either,
since _you_ are deciding to not wait for DSA, neither is he.
I'm fine either way, but one thing is not going to change, and that's
the ordering of my patches in the "PHYLINK integration improvements
for Felix DSA driver" series. As you know, most NXP users are not
using David's net-next directly (and that is at their! request), but a
"vendor" kernel which we try to keep as close to David's tree as
humanly possible, and which goes through a lot of testing. But if
there are going to be treewide changes in the phylink API (and there
_are_ already, that mac_link_up thing, which we haven't backported),
then there needs to be a strict ordering relationship between the
cleanup commits, which we can cherry-pick, and the adaptation to an
API which we haven't (nor we intend to) backport to 5.4, because it's
too much for little practical benefit. You seem to be hung up on that,
and we won't be making much progress if that continues, I'm afraid.
There are a lot of things to be done that depend on the lynx-pcs
thing, and there are multiple groups of people who are all waiting.
The new seville DSA driver, which _almost_ got into the previous
release cycle but missed the train due to a dependency with Mark
Brown's tree, also has a Lynx PCS integrated in it. I would like to
reuse the lynx-pcs module, but from what I can see, the bottleneck for
everybody seems to be reviewing the mac_link_up conversion of felix.
Thank you,
-Vladimir
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH RESEND net-next v3 0/3] net: enetc: remove bootloader dependency
2020-07-02 9:41 ` Vladimir Oltean
@ 2020-07-04 10:00 ` Russell King - ARM Linux admin
0 siblings, 0 replies; 11+ messages in thread
From: Russell King - ARM Linux admin @ 2020-07-04 10:00 UTC (permalink / raw)
To: Vladimir Oltean
Cc: Michael Walle, netdev, lkml, David S . Miller, Jakub Kicinski,
Andrew Lunn, Alex Marginean, Claudiu Manoil, Heiko Thiery
On Thu, Jul 02, 2020 at 12:41:39PM +0300, Vladimir Oltean wrote:
> On Thu, 2 Jul 2020 at 11:41, Russell King - ARM Linux admin
> <linux@armlinux.org.uk> wrote:
> >
> > On Thu, Jul 02, 2020 at 01:04:02AM +0300, Vladimir Oltean wrote:
> > > On Thu, 2 Jul 2020 at 00:53, Russell King - ARM Linux admin
> > > <linux@armlinux.org.uk> wrote:
> > > >
> > > > fixing up almost every driver the best I can with the exception of two -
> > > > felix DSA and Mediatek.
> > > >
> > > > I'm not going to wait for Felix or Mediatek. As I say, I've given
> > > > plenty of warning, and it's only a _suspicion_ of breakage on my
> > > > side.
> > > >
> > >
> > > What do you mean "I'm not going to wait for Felix"?
> > > https://patchwork.ozlabs.org/project/netdev/patch/20200625152331.3784018-5-olteanv@gmail.com/
> > > We left it at:
> > >
> > > > I'm not going to review patch 7
> > > > tonight because of this fiasco. To pissed off to do a decent job, so
> > > > you're just going to have to wait.
> > >
> > > So, I was actively waiting for you to review it ever since, just like
> > > you said, so I could send a v2. Were you waiting for anything?
> >
> > I stopped being interested in your series with the patch 5 commit
> > description issue; what happened there is really demotivating.
> >
> > --
> > RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
> > FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
>
> Yes, but I mean, the fact that reviewing felix is "demotivating" can
> only have 2 courses of action as far as I can see:
Sigh. I give up with you.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2020-07-04 10:01 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-01 21:34 [PATCH RESEND net-next v3 0/3] net: enetc: remove bootloader dependency Michael Walle
2020-07-01 21:34 ` [PATCH RESEND net-next v3 1/3] net: dsa: felix: move USXGMII defines to common place Michael Walle
2020-07-01 21:34 ` [PATCH RESEND net-next v3 2/3] net: enetc: Initialize SerDes for SGMII and USXGMII protocols Michael Walle
2020-07-02 0:39 ` Jakub Kicinski
2020-07-02 3:16 ` kernel test robot
2020-07-01 21:34 ` [PATCH RESEND net-next v3 3/3] net: enetc: Use DT protocol information to set up the ports Michael Walle
2020-07-01 21:53 ` [PATCH RESEND net-next v3 0/3] net: enetc: remove bootloader dependency Russell King - ARM Linux admin
2020-07-01 22:04 ` Vladimir Oltean
2020-07-02 8:41 ` Russell King - ARM Linux admin
2020-07-02 9:41 ` Vladimir Oltean
2020-07-04 10:00 ` Russell King - ARM Linux admin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).