From: Andrew Lunn <andrew@lunn.ch>
To: ciprian.regus@analog.com
Cc: Parthiban Veerasooran <parthiban.veerasooran@microchip.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>, Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>,
Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH net-next 4/5] net: ethernet: adi: Add a driver for the ADIN1140 MACPHY
Date: Sun, 3 May 2026 02:59:15 +0200 [thread overview]
Message-ID: <f477a03e-1d1f-4a38-af47-4cc16f5d87a5@lunn.ch> (raw)
In-Reply-To: <20260503-adin1140-driver-v1-4-dd043cdd88f0@analog.com>
> +static int adin1140_get_phy_c45_mms(int devnum)
> +{
> + switch (devnum) {
> + case MDIO_MMD_PCS:
> + return ADIN1140_PHY_C45_PCS_MMS2;
> + case MDIO_MMD_PMAPMD:
> + return ADIN1140_PHY_C45_PMA_PMD_MMS3;
> + case MDIO_MMD_VEND2:
> + return ADIN1140_PHY_C45_VS_PLCA_MMS4;
> + default:
> + return devnum;
> + }
> +}
> +
> +static int adin1140_mdiobus_read_c45(struct mii_bus *bus, int addr,
> + int devnum, int regnum)
> +{
> + struct oa_tc6 *tc6 = bus->priv;
> + u32 regval;
> + u32 mms;
> + int ret;
> +
> + mms = adin1140_get_phy_c45_mms(devnum);
> + ret = oa_tc6_read_register(tc6, ADIN1140_MMS_REG(mms, regnum),
> + ®val);
> + if (ret)
> + return ret;
> +
> + return regval;
> +}
> +
> +static int adin1140_mdiobus_write_c45(struct mii_bus *bus, int addr,
> + int devnum, int regnum, u16 val)
> +{
> + struct oa_tc6 *tc6 = bus->priv;
> + int ret;
> +
> + ret = adin1140_get_phy_c45_mms(devnum);
> + if (ret < 0)
> + return ret;
> +
> + return oa_tc6_write_register(tc6, ADIN1140_MMS_REG(ret, regnum), val);
> +}
At a quick look, these seem the same as oa_tc6_mdiobus_read_c45() and
oa_tc6_mdiobus_write_c45(). Please export them and use them.
> +static int adin1140_mdiobus_read(struct mii_bus *bus, int addr, int regnum)
> +{
> + struct oa_tc6 *tc6 = bus->priv;
> + u32 reg_val;
> + int ret;
> +
> + /* The ADIN1140's standard PHY C22 register map (OA TC6 0xFF00 -
> + * 0xFF1F), of which only 0xFF00 - 0xFF03 are implemented) cannot be
> + * accessed while frames are being received by the PHY. In case this
> + * happens the CONFIG0 and CONFIG2 register values will get corrupted,
> + * getting a random value. Both reads and writes cause the same
> + * behavior. This is a workaround that avoids MDIO accesses all
> + * together. Since this is a 10BASE-T1S PHY, only the loopback and
> + * reset (AN) bits in the control register (0x0) can be written.
> + * These functionalities have custom implementations in the PHY
> + * driver. Since the MAC and PHY are integrated in the same device, we
> + * can read the OA TC6 MACPHY ID register instead of the PHYID (0x2
> + * and 0x3) ones, as their value matches. C45 accesses do not cause
> + * this issue.
> + */
> +
> + switch (regnum) {
> + case MII_BMCR:
> + return ADIN1140_PHY_CTRL_DEFAULT;
> + case MII_BMSR:
> + return ADIN1140_PHY_STATUS_DEFAULT;
> + case MII_PHYSID1:
> + ret = oa_tc6_read_register(tc6, ADIN1140_MACPHY_ID_REG,
> + ®_val);
> + if (ret)
> + return ret;
> +
> + return FIELD_GET(GENMASK(31, 16), reg_val);
> + case MII_PHYSID2:
> + ret = oa_tc6_read_register(tc6, ADIN1140_MACPHY_ID_REG,
> + ®_val);
> + if (ret)
> + return ret;
Is it even worth reading this register? Why not hard code this as
well? Or do you expect a new version of the device which is less
FUBAR, and having a different PHY ID?
> +static int adin1140_mdiobus_write(struct mii_bus *bus, int addr, int regnum,
> + u16 val)
> +{
> + return 0;
-EIO. Since writes are not support, you want to know if something
actually does a write.
> +static int adin1140_mdio_register(struct adin1140_priv *priv)
> +{
> + priv->mdiobus = mdiobus_alloc();
> + if (!priv->mdiobus) {
> + netdev_err(priv->netdev, "MDIO bus alloc failed\n");
> + return -ENOMEM;
> + }
> +
> + priv->mdiobus->read = adin1140_mdiobus_read;
> + priv->mdiobus->write = adin1140_mdiobus_write;
> + priv->mdiobus->read_c45 = adin1140_mdiobus_read_c45;
> + priv->mdiobus->write_c45 = adin1140_mdiobus_write_c45;
Name? id?
Andrew
next prev parent reply other threads:[~2026-05-03 0:59 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-02 23:24 [PATCH net-next 0/5] net: Add ADIN1140 support Ciprian Regus via B4 Relay
2026-05-02 23:24 ` [PATCH net-next 1/5] net: ethernet: oa_tc6: Handle the OA TC6 SPI protected mode Ciprian Regus via B4 Relay
2026-05-02 23:24 ` [PATCH net-next 2/5] net: ethernet: oa_tc6: Allow custom mii_bus Ciprian Regus via B4 Relay
2026-05-03 3:50 ` Andrew Lunn
2026-05-03 17:34 ` Selvamani Rajagopal
2026-05-03 18:06 ` Andrew Lunn
2026-05-03 18:50 ` Selvamani Rajagopal
2026-05-02 23:24 ` [PATCH net-next 3/5] net: phy: Add support for the ADIN1140 PHY Ciprian Regus via B4 Relay
2026-05-03 0:40 ` Andrew Lunn
2026-05-02 23:24 ` [PATCH net-next 4/5] net: ethernet: adi: Add a driver for the ADIN1140 MACPHY Ciprian Regus via B4 Relay
2026-05-03 0:59 ` Andrew Lunn [this message]
2026-05-03 1:01 ` Andrew Lunn
2026-05-03 3:15 ` Andrew Lunn
2026-05-03 3:36 ` Andrew Lunn
2026-05-03 15:15 ` Andrew Lunn
2026-05-03 18:19 ` Regus, Ciprian
2026-05-02 23:24 ` [PATCH net-next 5/5] dt-bindings: net: Add bindings for the ADIN1140 Ciprian Regus via B4 Relay
2026-05-03 1:06 ` Andrew Lunn
2026-05-04 7:33 ` Regus, Ciprian
2026-05-04 12:11 ` Andrew Lunn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f477a03e-1d1f-4a38-af47-4cc16f5d87a5@lunn.ch \
--to=andrew@lunn.ch \
--cc=andrew+netdev@lunn.ch \
--cc=ciprian.regus@analog.com \
--cc=conor+dt@kernel.org \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=horms@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=parthiban.veerasooran@microchip.com \
--cc=robh@kernel.org \
--cc=skhan@linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox