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: pcs: pcs-lynx: use phylink_get_link_timer_ns() helper

Use the phylink_get_link_timer_ns() helper to get the period for the
link timer.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Link: https://lore.kernel.org/r/E1pFyhW-0067jq-Fh@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Russell King (Oracle) and committed by
Jakub Kicinski
e2a95750 28dbf774

+8 -12
+8 -12
drivers/net/pcs/pcs-lynx.c
··· 10 10 #define SGMII_CLOCK_PERIOD_NS 8 /* PCS is clocked at 125 MHz */ 11 11 #define LINK_TIMER_VAL(ns) ((u32)((ns) / SGMII_CLOCK_PERIOD_NS)) 12 12 13 - #define SGMII_AN_LINK_TIMER_NS 1600000 /* defined by SGMII spec */ 14 - #define IEEE8023_LINK_TIMER_NS 10000000 15 - 16 13 #define LINK_TIMER_LO 0x12 17 14 #define LINK_TIMER_HI 0x13 18 15 #define IF_MODE 0x14 ··· 123 126 phy_interface_t interface, 124 127 const unsigned long *advertising) 125 128 { 129 + int link_timer_ns; 126 130 u32 link_timer; 127 131 u16 if_mode; 128 132 int err; 129 133 130 - if (interface == PHY_INTERFACE_MODE_1000BASEX) { 131 - link_timer = LINK_TIMER_VAL(IEEE8023_LINK_TIMER_NS); 134 + link_timer_ns = phylink_get_link_timer_ns(interface); 135 + if (link_timer_ns > 0) { 136 + link_timer = LINK_TIMER_VAL(link_timer_ns); 137 + 132 138 mdiodev_write(pcs, LINK_TIMER_LO, link_timer & 0xffff); 133 139 mdiodev_write(pcs, LINK_TIMER_HI, link_timer >> 16); 140 + } 134 141 142 + if (interface == PHY_INTERFACE_MODE_1000BASEX) { 135 143 if_mode = 0; 136 144 } else { 137 145 if_mode = IF_MODE_SGMII_EN; 138 - if (mode == MLO_AN_INBAND) { 146 + if (mode == MLO_AN_INBAND) 139 147 if_mode |= IF_MODE_USE_SGMII_AN; 140 - 141 - /* Adjust link timer for SGMII */ 142 - link_timer = LINK_TIMER_VAL(SGMII_AN_LINK_TIMER_NS); 143 - mdiodev_write(pcs, LINK_TIMER_LO, link_timer & 0xffff); 144 - mdiodev_write(pcs, LINK_TIMER_HI, link_timer >> 16); 145 - } 146 148 } 147 149 148 150 err = mdiodev_modify(pcs, IF_MODE,