@@ -99,6 +99,15 @@
#define PTP_TIMESTAMP_EN_PDREQ_ BIT(2)
#define PTP_TIMESTAMP_EN_PDRES_ BIT(3)
+#define PTP_RX_LATENCY_1000 0x0224
+#define PTP_TX_LATENCY_1000 0x0225
+
+#define PTP_RX_LATENCY_100 0x0222
+#define PTP_TX_LATENCY_100 0x0223
+
+#define PTP_RX_LATENCY_10 0x0220
+#define PTP_TX_LATENCY_10 0x0221
+
#define PTP_TX_PARSE_L2_ADDR_EN 0x0284
#define PTP_RX_PARSE_L2_ADDR_EN 0x0244
@@ -2591,6 +2600,88 @@ static int lan8814_ptp_probe_once(struct phy_device *phydev)
return 0;
}
+static void lan8814_get_latency(struct phy_device *phydev, u32 id, s32 *latency)
+{
+ switch (id) {
+ case ETHTOOL_PHY_LATENCY_RX_10MBIT:
+ *latency = lanphy_read_page_reg(phydev, 5, PTP_RX_LATENCY_10);
+ break;
+ case ETHTOOL_PHY_LATENCY_TX_10MBIT:
+ *latency = lanphy_read_page_reg(phydev, 5, PTP_TX_LATENCY_10);
+ break;
+ case ETHTOOL_PHY_LATENCY_RX_100MBIT:
+ *latency = lanphy_read_page_reg(phydev, 5, PTP_RX_LATENCY_100);
+ break;
+ case ETHTOOL_PHY_LATENCY_TX_100MBIT:
+ *latency = lanphy_read_page_reg(phydev, 5, PTP_TX_LATENCY_100);
+ break;
+ case ETHTOOL_PHY_LATENCY_RX_1000MBIT:
+ *latency = lanphy_read_page_reg(phydev, 5, PTP_RX_LATENCY_1000);
+ break;
+ case ETHTOOL_PHY_LATENCY_TX_1000MBIT:
+ *latency = lanphy_read_page_reg(phydev, 5, PTP_TX_LATENCY_1000);
+ break;
+ }
+}
+
+static int lan8814_get_tunable(struct phy_device *phydev,
+ struct ethtool_tunable *tuna, void *data)
+{
+ switch (tuna->id) {
+ case ETHTOOL_PHY_LATENCY_RX_10MBIT:
+ case ETHTOOL_PHY_LATENCY_TX_10MBIT:
+ case ETHTOOL_PHY_LATENCY_RX_100MBIT:
+ case ETHTOOL_PHY_LATENCY_TX_100MBIT:
+ case ETHTOOL_PHY_LATENCY_RX_1000MBIT:
+ case ETHTOOL_PHY_LATENCY_TX_1000MBIT:
+ lan8814_get_latency(phydev, tuna->id, data);
+ return 0;
+ default:
+ return -EOPNOTSUPP;
+ }
+}
+
+static void lan8814_set_latency(struct phy_device *phydev, u32 id, s32 latency)
+{
+ switch (id) {
+ case ETHTOOL_PHY_LATENCY_RX_10MBIT:
+ lanphy_write_page_reg(phydev, 5, PTP_RX_LATENCY_10, latency);
+ break;
+ case ETHTOOL_PHY_LATENCY_TX_10MBIT:
+ lanphy_write_page_reg(phydev, 5, PTP_TX_LATENCY_10, latency);
+ break;
+ case ETHTOOL_PHY_LATENCY_RX_100MBIT:
+ lanphy_write_page_reg(phydev, 5, PTP_RX_LATENCY_100, latency);
+ break;
+ case ETHTOOL_PHY_LATENCY_TX_100MBIT:
+ lanphy_write_page_reg(phydev, 5, PTP_TX_LATENCY_100, latency);
+ break;
+ case ETHTOOL_PHY_LATENCY_RX_1000MBIT:
+ lanphy_write_page_reg(phydev, 5, PTP_RX_LATENCY_1000, latency);
+ break;
+ case ETHTOOL_PHY_LATENCY_TX_1000MBIT:
+ lanphy_write_page_reg(phydev, 5, PTP_TX_LATENCY_1000, latency);
+ break;
+ }
+}
+
+static int lan8814_set_tunable(struct phy_device *phydev,
+ struct ethtool_tunable *tuna, const void *data)
+{
+ switch (tuna->id) {
+ case ETHTOOL_PHY_LATENCY_RX_10MBIT:
+ case ETHTOOL_PHY_LATENCY_TX_10MBIT:
+ case ETHTOOL_PHY_LATENCY_RX_100MBIT:
+ case ETHTOOL_PHY_LATENCY_TX_100MBIT:
+ case ETHTOOL_PHY_LATENCY_RX_1000MBIT:
+ case ETHTOOL_PHY_LATENCY_TX_1000MBIT:
+ lan8814_set_latency(phydev, tuna->id, *(const s32 *)data);
+ return 0;
+ default:
+ return -EOPNOTSUPP;
+ }
+}
+
static int lan8814_config_init(struct phy_device *phydev)
{
int val;
@@ -2827,6 +2918,8 @@ static struct phy_driver ksphy_driver[] = {
.probe = lan8814_probe,
.soft_reset = genphy_soft_reset,
.read_status = ksz9031_read_status,
+ .get_tunable = lan8814_get_tunable,
+ .set_tunable = lan8814_set_tunable,
.get_sset_count = kszphy_get_sset_count,
.get_strings = kszphy_get_strings,
.get_stats = kszphy_get_stats,
Implement set/get_tunable to set/get the PHY latencies. Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com> --- drivers/net/phy/micrel.c | 93 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+)