From: Selvamani Rajagopal OPEN Alliance 10BASE-T1x Serial Interface specification, table 6 allows vendors to use any memory map select (MMS) value between 10 and 15. This new API interface enables vendor to map one of thes MMS values to MDIO_MMD_VEND1. Reviewed-by: Andrew Lunn Signed-off-by: Selvamani Rajagopal --- changes in v10 - Moved the API documentation to this patch changes in v9 - Added the missing vend1_mms initializer to where it belonged - Added Reviewed tag 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 | 7 +++++++ drivers/net/ethernet/oa_tc6/oa_tc6_main.c | 21 ++++++++++++++++++--- drivers/net/ethernet/oa_tc6/oa_tc6_std_def.h | 1 + include/linux/oa_tc6.h | 1 + 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/Documentation/networking/oa-tc6-framework.rst b/Documentation/networking/oa-tc6-framework.rst index 23856c4bfd69..3cfe8cb7cf75 100644 --- a/Documentation/networking/oa-tc6-framework.rst +++ b/Documentation/networking/oa-tc6-framework.rst @@ -537,6 +537,13 @@ Provides hardware timestamp related traffic statistics for ethtool. Helper to set hardware timestamp configuration. Part of net_device_ops callbacks. +.. c:function:: void oa_tc6_set_vend1_mms(struct oa_tc6 *tc6, int mms); + +Helper to map MDIO_MMD_VEND1 command to vendor specific Memory Map Select +(MMS) value. This function offers flexibility for vendors that may have +used any MMS value between 10 and 15 as allowed by the specification. +MDIO_MMD_VEND2 is already mapped to MMS4 in the OA TC6 frame work code. + .. c:function:: int oa_tc6_write_register_mms(struct oa_tc6 *tc6, \ u8 mms, u16 address, \ u32 value); diff --git a/drivers/net/ethernet/oa_tc6/oa_tc6_main.c b/drivers/net/ethernet/oa_tc6/oa_tc6_main.c index e793d7fb0635..5b2454b75974 100644 --- a/drivers/net/ethernet/oa_tc6/oa_tc6_main.c +++ b/drivers/net/ethernet/oa_tc6/oa_tc6_main.c @@ -266,6 +266,18 @@ static int oa_tc6_update_standard_capability(struct oa_tc6 *tc6) return 0; } +/** + * oa_tc6_set_vend1_mms - Add vendor specific MDIO_MMD to OA TC6 MMS + * mapper value. + * @tc6: oa_tc6 struct. + * @mms: vendor defined MMS value for VEND1 mdio device. + */ +void oa_tc6_set_vend1_mms(struct oa_tc6 *tc6, int mms) +{ + tc6->vend1_mms = mms; +} +EXPORT_SYMBOL_GPL(oa_tc6_set_vend1_mms); + static __be32 oa_tc6_prepare_ctrl_header(u32 addr, u8 length, enum oa_tc6_register_op reg_op) { @@ -593,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: @@ -606,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->vend1_mms; default: return -EOPNOTSUPP; } @@ -619,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; @@ -637,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; @@ -1658,6 +1672,7 @@ struct oa_tc6 *oa_tc6_init(struct spi_device *spi, struct net_device *netdev, SET_NETDEV_DEV(netdev, &spi->dev); mutex_init(&tc6->spi_ctrl_lock); spin_lock_init(&tc6->tx_skb_lock); + tc6->vend1_mms = -EOPNOTSUPP; tc6->ttsc_current_id = OA_TC6_TTSCA_REG_ID; INIT_LIST_HEAD(&tc6->tx_ts_skb_q); 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 a4d269cd685f..3bb41873773f 100644 --- a/drivers/net/ethernet/oa_tc6/oa_tc6_std_def.h +++ b/drivers/net/ethernet/oa_tc6/oa_tc6_std_def.h @@ -140,6 +140,7 @@ struct oa_tc6 { u64 tx_hwtstamp_err; u8 ts_ttsc_pending; u8 ttsc_current_id; + int vend1_mms; }; enum oa_tc6_header_type { diff --git a/include/linux/oa_tc6.h b/include/linux/oa_tc6.h index adfa83cd92ee..15d62e1b87a2 100644 --- a/include/linux/oa_tc6.h +++ b/include/linux/oa_tc6.h @@ -114,5 +114,6 @@ void oa_tc6_get_ts_stats(struct oa_tc6 *tc6, struct ethtool_ts_stats *stats); int oa_tc6_hwtstamp_set(struct oa_tc6 *tc6, struct kernel_hwtstamp_config *cfg); +void oa_tc6_set_vend1_mms(struct oa_tc6 *tc6, int mms); void oa_tc6_ptp_unregister(struct oa_tc6 *tc6); #endif /* _LINUX_OA_TC6_H */ -- 2.43.0