Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: phy: micrel: Add support for non PTP SKUs for lan8814

The lan8814 has 4 different SKUs and for 2 of these SKUs the PTP is
disabled. All these SKUs have the same value in the register 2 and 3.
Meaning that we can't differentiate them based on device id, therefore
check the SKU register and based on this allow or not to create a PTP
device.

Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/20251021070726.3690685-1-horatiu.vultur@microchip.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Horatiu Vultur and committed by
Paolo Abeni
61b7ade9 e0665df8

+38
+38
drivers/net/phy/micrel.c
··· 101 101 #define LAN8814_CABLE_DIAG_VCT_DATA_MASK GENMASK(7, 0) 102 102 #define LAN8814_PAIR_BIT_SHIFT 12 103 103 104 + #define LAN8814_SKUS 0xB 105 + 104 106 #define LAN8814_WIRE_PAIR_MASK 0xF 105 107 106 108 /* Lan8814 general Interrupt control/status reg in GPHY specific block. */ ··· 369 367 370 368 #define LAN8842_REV_8832 0x8832 371 369 370 + #define LAN8814_REV_LAN8814 0x8814 371 + #define LAN8814_REV_LAN8818 0x8818 372 + 372 373 struct kszphy_hw_stat { 373 374 const char *string; 374 375 u8 reg; ··· 454 449 bool rmii_ref_clk_sel; 455 450 bool rmii_ref_clk_sel_val; 456 451 bool clk_enable; 452 + bool is_ptp_available; 457 453 u64 stats[ARRAY_SIZE(kszphy_hw_stats)]; 458 454 struct kszphy_phy_stats phy_stats; 459 455 }; ··· 4132 4126 return 0; 4133 4127 } 4134 4128 4129 + /* Check if the PHY has 1588 support. There are multiple skus of the PHY and 4130 + * some of them support PTP while others don't support it. This function will 4131 + * return true is the sku supports it, otherwise will return false. 4132 + */ 4133 + static bool lan8814_has_ptp(struct phy_device *phydev) 4134 + { 4135 + struct kszphy_priv *priv = phydev->priv; 4136 + 4137 + return priv->is_ptp_available; 4138 + } 4139 + 4135 4140 static irqreturn_t lan8814_handle_interrupt(struct phy_device *phydev) 4136 4141 { 4137 4142 int ret = IRQ_NONE; ··· 4158 4141 phy_trigger_machine(phydev); 4159 4142 ret = IRQ_HANDLED; 4160 4143 } 4144 + 4145 + if (!lan8814_has_ptp(phydev)) 4146 + return ret; 4161 4147 4162 4148 while (true) { 4163 4149 irq_status = lanphy_read_page_reg(phydev, LAN8814_PAGE_PORT_REGS, ··· 4221 4201 4222 4202 if (!IS_ENABLED(CONFIG_PTP_1588_CLOCK) || 4223 4203 !IS_ENABLED(CONFIG_NETWORK_PHY_TIMESTAMPING)) 4204 + return; 4205 + 4206 + if (!lan8814_has_ptp(phydev)) 4224 4207 return; 4225 4208 4226 4209 lanphy_write_page_reg(phydev, LAN8814_PAGE_PORT_REGS, ··· 4355 4332 4356 4333 static int lan8814_ptp_probe_once(struct phy_device *phydev) 4357 4334 { 4335 + if (!lan8814_has_ptp(phydev)) 4336 + return 0; 4337 + 4358 4338 return __lan8814_ptp_probe_once(phydev, "lan8814_ptp_pin", 4359 4339 LAN8814_PTP_GPIO_NUM); 4360 4340 } ··· 4471 4445 addr = lanphy_read_page_reg(phydev, LAN8814_PAGE_COMMON_REGS, 0) & 0x1F; 4472 4446 devm_phy_package_join(&phydev->mdio.dev, phydev, 4473 4447 addr, sizeof(struct lan8814_shared_priv)); 4448 + 4449 + /* There are lan8814 SKUs that don't support PTP. Make sure that for 4450 + * those skus no PTP device is created. Here we check if the SKU 4451 + * supports PTP. 4452 + */ 4453 + err = lanphy_read_page_reg(phydev, LAN8814_PAGE_COMMON_REGS, 4454 + LAN8814_SKUS); 4455 + if (err < 0) 4456 + return err; 4457 + 4458 + priv->is_ptp_available = err == LAN8814_REV_LAN8814 || 4459 + err == LAN8814_REV_LAN8818; 4474 4460 4475 4461 if (phy_package_init_once(phydev)) { 4476 4462 err = lan8814_release_coma_mode(phydev);