Skip to content

Commit 9fc3d6f

Browse files
Divya-Kopperakuba-moo
authored andcommitted
net: phy: microchip_t1 : Add initialization of ptp for lan887x
Add initialization of ptp for lan887x. Reviewed-by: Andrew Lunn <[email protected]> Signed-off-by: Divya Koppera <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 85b39f7 commit 9fc3d6f

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

drivers/net/phy/microchip_t1.c

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@
1010
#include <linux/ethtool.h>
1111
#include <linux/ethtool_netlink.h>
1212
#include <linux/bitfield.h>
13+
#include "microchip_rds_ptp.h"
1314

1415
#define PHY_ID_LAN87XX 0x0007c150
1516
#define PHY_ID_LAN937X 0x0007c180
1617
#define PHY_ID_LAN887X 0x0007c1f0
1718

19+
#define MCHP_RDS_PTP_LTC_BASE_ADDR 0xe000
20+
#define MCHP_RDS_PTP_PORT_BASE_ADDR (MCHP_RDS_PTP_LTC_BASE_ADDR + 0x800)
21+
1822
/* External Register Control Register */
1923
#define LAN87XX_EXT_REG_CTL (0x14)
2024
#define LAN87XX_EXT_REG_CTL_RD_CTL (0x1000)
@@ -229,6 +233,7 @@
229233

230234
#define LAN887X_INT_STS 0xf000
231235
#define LAN887X_INT_MSK 0xf001
236+
#define LAN887X_INT_MSK_P1588_MOD_INT_MSK BIT(3)
232237
#define LAN887X_INT_MSK_T1_PHY_INT_MSK BIT(2)
233238
#define LAN887X_INT_MSK_LINK_UP_MSK BIT(1)
234239
#define LAN887X_INT_MSK_LINK_DOWN_MSK BIT(0)
@@ -319,6 +324,8 @@ struct lan887x_regwr_map {
319324

320325
struct lan887x_priv {
321326
u64 stats[ARRAY_SIZE(lan887x_hw_stats)];
327+
struct mchp_rds_ptp_clock *clock;
328+
bool init_done;
322329
};
323330

324331
static int lan937x_dsp_workaround(struct phy_device *phydev, u16 ereg, u8 bank)
@@ -1269,8 +1276,19 @@ static int lan887x_get_features(struct phy_device *phydev)
12691276

12701277
static int lan887x_phy_init(struct phy_device *phydev)
12711278
{
1279+
struct lan887x_priv *priv = phydev->priv;
12721280
int ret;
12731281

1282+
if (!priv->init_done && phy_interrupt_is_valid(phydev)) {
1283+
priv->clock = mchp_rds_ptp_probe(phydev, MDIO_MMD_VEND1,
1284+
MCHP_RDS_PTP_LTC_BASE_ADDR,
1285+
MCHP_RDS_PTP_PORT_BASE_ADDR);
1286+
if (IS_ERR(priv->clock))
1287+
return PTR_ERR(priv->clock);
1288+
1289+
priv->init_done = true;
1290+
}
1291+
12741292
/* Clear loopback */
12751293
ret = phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1,
12761294
LAN887X_MIS_CFG_REG2,
@@ -1470,6 +1488,7 @@ static int lan887x_probe(struct phy_device *phydev)
14701488
if (!priv)
14711489
return -ENOMEM;
14721490

1491+
priv->init_done = false;
14731492
phydev->priv = priv;
14741493

14751494
return lan887x_phy_setup(phydev);
@@ -1518,6 +1537,7 @@ static void lan887x_get_strings(struct phy_device *phydev, u8 *data)
15181537

15191538
static int lan887x_config_intr(struct phy_device *phydev)
15201539
{
1540+
struct lan887x_priv *priv = phydev->priv;
15211541
int rc;
15221542

15231543
if (phydev->interrupts == PHY_INTERRUPT_ENABLED) {
@@ -1537,12 +1557,24 @@ static int lan887x_config_intr(struct phy_device *phydev)
15371557

15381558
rc = phy_read_mmd(phydev, MDIO_MMD_VEND1, LAN887X_INT_STS);
15391559
}
1560+
if (rc < 0)
1561+
return rc;
15401562

1541-
return rc < 0 ? rc : 0;
1563+
if (phy_is_default_hwtstamp(phydev)) {
1564+
return mchp_rds_ptp_top_config_intr(priv->clock,
1565+
LAN887X_INT_MSK,
1566+
LAN887X_INT_MSK_P1588_MOD_INT_MSK,
1567+
(phydev->interrupts ==
1568+
PHY_INTERRUPT_ENABLED));
1569+
}
1570+
1571+
return 0;
15421572
}
15431573

15441574
static irqreturn_t lan887x_handle_interrupt(struct phy_device *phydev)
15451575
{
1576+
struct lan887x_priv *priv = phydev->priv;
1577+
int rc = IRQ_NONE;
15461578
int irq_status;
15471579

15481580
irq_status = phy_read_mmd(phydev, MDIO_MMD_VEND1, LAN887X_INT_STS);
@@ -1553,10 +1585,13 @@ static irqreturn_t lan887x_handle_interrupt(struct phy_device *phydev)
15531585

15541586
if (irq_status & LAN887X_MX_CHIP_TOP_LINK_MSK) {
15551587
phy_trigger_machine(phydev);
1556-
return IRQ_HANDLED;
1588+
rc = IRQ_HANDLED;
15571589
}
15581590

1559-
return IRQ_NONE;
1591+
if (irq_status & LAN887X_INT_MSK_P1588_MOD_INT_MSK)
1592+
rc = mchp_rds_ptp_handle_interrupt(priv->clock);
1593+
1594+
return rc;
15601595
}
15611596

15621597
static int lan887x_cd_reset(struct phy_device *phydev,

0 commit comments

Comments
 (0)