From: Selvamani Rajagopal <Selv…@onsemi.com> Add vend1_mms to struct oa_tc6_quirks to let a vendor driver map MDIO_MMD_VEND1 to one of the vendor specific MMS values, 10 to 15, in table 6 of the OPEN Alliance 10BASE-T1x MAC-PHY Serial Interface specification. The mapping must be known when oa_tc6_init() scans for the PHY, which can access MMD VEND1. A zero vend1_mms keeps the current behavior. A value outside 10 to 15 makes oa_tc6_init() fail with -EINVAL. Signed-off-by: Selvamani Rajagopal <Selv…@onsemi.com> --- changes in v13 - No change changes in v12 - Dropped Reviewed-by from Andrew Lunn as the code has changed. - MMD VEND1 mapping is now part of the quirks, not an API. changes in v11 - Accidentally patch got removed changes in v10 - No change changes in v9 - No change changes in v8 - No change changes in v7 - No change changes in v6 - No change changes in v5 - no change changes in v4 - no change changes in v3 - no change changes in v2 - Moved the handling of vendor specific MMS mapping to separate patch - new patch --- Documentation/networking/oa-tc6-framework.rst | 12 +++++++++++- drivers/net/ethernet/oa_tc6/oa_tc6_main.c | 22 ++++++++++++++++------ drivers/net/ethernet/oa_tc6/oa_tc6_std_def.h | 6 +++++- include/linux/oa_tc6.h | 1 + 4 files changed, 33 insertions(+), 8 deletions(-) diff --git a/Documentation/networking/oa-tc6-framework.rst b/Documentation/networking/oa-tc6-framework.rst index 390529419133..558dc25038d3 100644 --- a/Documentation/networking/oa-tc6-framework.rst +++ b/Documentation/networking/oa-tc6-framework.rst @@ -469,7 +469,17 @@ The include/linux/oa_tc6.h defines the following functions: struct net_device *netdev, \ struct oa_tc6_quirks *quirks) -Initialize OA TC6 lib. +Initialize the OA TC6 lib. Pass ``NULL`` for quirks if no device-specific +settings are needed. + +The quirk_flags field supports: + +- OA_TC6_BROKEN_PHY: Leave MDIO bus registration and PHY connection to the + vendor driver instead of the framework. + +A zero value for vend1_mms means no Clause 45 ``MDIO_MMD_VEND1`` +mapping is requested; it does not select MMS 0. For any nonzero value +outside the range 10 through 15, ``oa_tc6_init()`` fails with ``-EINVAL``. .. c:function:: void oa_tc6_exit(struct oa_tc6 *tc6) diff --git a/drivers/net/ethernet/oa_tc6/oa_tc6_main.c b/drivers/net/ethernet/oa_tc6/oa_tc6_main.c index 1740b9d00a3c..e9e7b4ad3b2c 100644 --- a/drivers/net/ethernet/oa_tc6/oa_tc6_main.c +++ b/drivers/net/ethernet/oa_tc6/oa_tc6_main.c @@ -605,7 +605,7 @@ static int oa_tc6_mdiobus_write(struct mii_bus *bus, int addr, int regnum, val); } -static int oa_tc6_get_phy_c45_mms(int devnum) +static int oa_tc6_get_phy_c45_mms(struct oa_tc6 *tc6, int devnum) { switch (devnum) { case MDIO_MMD_PCS: @@ -618,6 +618,8 @@ static int oa_tc6_get_phy_c45_mms(int devnum) return OA_TC6_PHY_C45_AUTO_NEG_MMS5; case MDIO_MMD_POWER_UNIT: return OA_TC6_PHY_C45_POWER_UNIT_MMS6; + case MDIO_MMD_VEND1: + return tc6->quirks.vend1_mms; default: return -EOPNOTSUPP; } @@ -631,7 +633,7 @@ int oa_tc6_mdiobus_read_c45(struct mii_bus *bus, int addr, int devnum, int mms; int ret; - mms = oa_tc6_get_phy_c45_mms(devnum); + mms = oa_tc6_get_phy_c45_mms(tc6, devnum); if (mms < 0) return mms; @@ -649,7 +651,7 @@ int oa_tc6_mdiobus_write_c45(struct mii_bus *bus, int addr, int devnum, struct oa_tc6 *tc6 = bus->priv; int mms; - mms = oa_tc6_get_phy_c45_mms(devnum); + mms = oa_tc6_get_phy_c45_mms(tc6, devnum); if (mms < 0) return mms; @@ -708,7 +710,7 @@ static int oa_tc6_phy_init(struct oa_tc6 *tc6) { int ret; - if (tc6->quirk_flags & OA_TC6_BROKEN_PHY) + if (tc6->quirks.quirk_flags & OA_TC6_BROKEN_PHY) return 0; ret = oa_tc6_check_phy_reg_direct_access_capability(tc6); @@ -747,7 +749,7 @@ static int oa_tc6_phy_init(struct oa_tc6 *tc6) static void oa_tc6_phy_exit(struct oa_tc6 *tc6) { - if (tc6->quirk_flags & OA_TC6_BROKEN_PHY) + if (tc6->quirks.quirk_flags & OA_TC6_BROKEN_PHY) return; phy_disconnect(tc6->phydev); @@ -1711,7 +1713,15 @@ struct oa_tc6 *oa_tc6_init(struct spi_device *spi, struct net_device *netdev, init_completion(&tc6->ts_cfg_done); if (quirks) - tc6->quirk_flags = quirks->quirk_flags; + tc6->quirks = *quirks; + + if (!tc6->quirks.vend1_mms) + tc6->quirks.vend1_mms = -EOPNOTSUPP; + else if (tc6->quirks.vend1_mms < OA_TC6_VENDOR_MMS_MIN || + tc6->quirks.vend1_mms > OA_TC6_VENDOR_MMS_MAX) + return ERR_PTR(dev_err_probe(&spi->dev, -EINVAL, + "Invalid VEND1 MMS: %d\n", + tc6->quirks.vend1_mms)); /* Set the SPI controller to pump at realtime priority */ tc6->spi->rt = true; diff --git a/drivers/net/ethernet/oa_tc6/oa_tc6_std_def.h b/drivers/net/ethernet/oa_tc6/oa_tc6_std_def.h index ec9a9bb03c0d..cbc4fd661113 100644 --- a/drivers/net/ethernet/oa_tc6/oa_tc6_std_def.h +++ b/drivers/net/ethernet/oa_tc6/oa_tc6_std_def.h @@ -32,6 +32,10 @@ #define OA_TC6_CTRL_HEADER_LENGTH GENMASK(7, 1) #define OA_TC6_CTRL_HEADER_PARITY BIT(0) +/* Vendor-specific MMS range from Table 6 of OA TC6 specification. */ +#define OA_TC6_VENDOR_MMS_MIN 10 +#define OA_TC6_VENDOR_MMS_MAX 15 + /* Data header */ #define OA_TC6_DATA_HEADER_DATA_NOT_CTRL BIT(31) #define OA_TC6_DATA_HEADER_DATA_VALID BIT(21) @@ -131,7 +135,7 @@ struct oa_tc6 { bool int_flag; bool disable_traffic; bool prot_ctrl; - enum oa_tc6_quirk_flag quirk_flags; + struct oa_tc6_quirks quirks; struct gpio_desc *reset_gpio; struct list_head ttsc_skb_list; struct ptp_clock *ptp_clock; diff --git a/include/linux/oa_tc6.h b/include/linux/oa_tc6.h index 32c25b5e2aa3..f34ed8218a7c 100644 --- a/include/linux/oa_tc6.h +++ b/include/linux/oa_tc6.h @@ -86,6 +86,7 @@ enum oa_tc6_quirk_flag { struct oa_tc6_quirks { enum oa_tc6_quirk_flag quirk_flags; + int vend1_mms; }; struct oa_tc6 *oa_tc6_init(struct spi_device *spi, struct net_device *netdev,
-- 2.43.0