[PATCH] staging: octeon-ethernet: fix incorrect PHY mode

Andrew Lunn andrew at lunn.ch
Tue Mar 26 09:01:50 UTC 2019


> -static void cvm_set_rgmii_delay(struct device_node *np, int iface, int port)
> +static void cvm_set_rgmii_delay(struct octeon_ethernet *priv, int iface,
> +				int port)
>  {
> +	struct device_node *np = priv->of_node;
>  	u32 delay_value;
> +	bool rx_delay;
> +	bool tx_delay;
>  
> -	if (!of_property_read_u32(np, "rx-delay", &delay_value))
> +	/* By default, both RX/TX delay is enabled in
> +	 * __cvmx_helper_rgmii_enable().
> +	 */
> +	rx_delay = true;
> +	tx_delay = true;
> +
> +	if (!of_property_read_u32(np, "rx-delay", &delay_value)) {
>  		cvmx_write_csr(CVMX_ASXX_RX_CLK_SETX(port, iface), delay_value);
> -	if (!of_property_read_u32(np, "tx-delay", &delay_value))
> +		rx_delay = delay_value > 0;
> +	}
> +	if (!of_property_read_u32(np, "tx-delay", &delay_value)) {
>  		cvmx_write_csr(CVMX_ASXX_TX_CLK_SETX(port, iface), delay_value);
> +		tx_delay = delay_value > 0;
> +	}
> +
> +	if (!rx_delay && !tx_delay)
> +		priv->phy_mode = PHY_INTERFACE_MODE_RGMII_ID;
> +	else if (!rx_delay)
> +		priv->phy_mode = PHY_INTERFACE_MODE_RGMII_RXID;
> +	else if (!tx_delay)
> +		priv->phy_mode = PHY_INTERFACE_MODE_RGMII_TXID;
> +	else
> +		priv->phy_mode = PHY_INTERFACE_MODE_RGMII;

Humm, that is unique, as far as i know. Every other MAC driver uses
of_get_phy_mode() to get the value out of device tree. The proprietary
delay values can then be used to fine tune the basic delay setting
read from DT.

	Andrew


More information about the devel mailing list