lkml.org 
[lkml]   [2021]   [Jun]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 3/3] phy: mscc: Add support for VSC8531_02 with RGMII tuning
> @@ -535,15 +535,16 @@ static int vsc85xx_rgmii_set_skews(struct phy_device *phydev, u32 rgmii_cntl,
> u16 rgmii_tx_delay_pos = ffs(rgmii_tx_delay_mask) - 1;
> u16 reg_val = 0;
> int rc;
> + struct vsc8531_private *vsc8531 = phydev->priv;

reverse christmass tree.


> mutex_lock(&phydev->lock);
>
> if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID ||
> phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)
> - reg_val |= RGMII_CLK_DELAY_2_0_NS << rgmii_rx_delay_pos;
> + reg_val |= vsc8531->rx_delay << rgmii_rx_delay_pos;
> if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID ||
> phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)
> - reg_val |= RGMII_CLK_DELAY_2_0_NS << rgmii_tx_delay_pos;
> + reg_val |= vsc8531->tx_delay << rgmii_tx_delay_pos;
>
> rc = phy_modify_paged(phydev, MSCC_PHY_PAGE_EXTENDED_2,
> rgmii_cntl,
> @@ -1820,6 +1821,17 @@ static int vsc85xx_config_init(struct phy_device *phydev)
> {
> int rc, i, phy_id;
> struct vsc8531_private *vsc8531 = phydev->priv;
> + struct device_node *of_node = phydev->mdio.dev.of_node;
> +
> + rc = of_property_read_u32(of_node, "vsc8531,rx-delay",
> + &vsc8531->rx_delay);
> + if (rc < 0)
> + vsc8531->rx_delay = RGMII_CLK_DELAY_2_0_NS;

of_property_read_u32() is guaranteed not to touch the result value, if
it is not in device tree. So you can simplify this to:

vsc8531->rx_delay = RGMII_CLK_DELAY_2_0_NS;
of_property_read_u32(of_node, "vsc8531,rx-delay", &vsc8531->rx_delay);

\
 
 \ /
  Last update: 2021-06-29 16:13    [W:0.124 / U:0.496 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site