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

ravb: Avoid unsupported internal delay mode for R-Car E3/D3

According to the R-Car Gen3 Hardware Manual Rev 1.50 of Nov 30, 2018, the
TX clock internal delay mode isn't supported on R-Car E3 (r8a77990) or D3
(r8a77995). And by extension it is also not supported by RZ/G2E (r9a774c0).

This matches all ES versions of the affected SoCs as it is
not clear if this problem will be resolved in newer chips.
This can be revisited, as necessary.

This patch does not error-out if PHY_INTERFACE_MODE_RGMII_ID or
PHY_INTERFACE_MODE_RGMII_TXID are used on SoCs where TX clock delay
mode is not supported as there is a risk of introducing a regression
when used in conjunction with older DT blobs present in the field.
Rather, a warning is logged in such cases.

Based on work by Kazuya Mizuguchi.

Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Simon Horman and committed by
David S. Miller
0a5d329f c98f4822

+13 -2
+13 -2
drivers/net/ethernet/renesas/ravb_main.c
··· 1969 1969 } 1970 1970 } 1971 1971 1972 + static const struct soc_device_attribute ravb_delay_mode_quirk_match[] = { 1973 + { .soc_id = "r8a774c0" }, 1974 + { .soc_id = "r8a77990" }, 1975 + { .soc_id = "r8a77995" }, 1976 + { /* sentinel */ } 1977 + }; 1978 + 1972 1979 /* Set tx and rx clock internal delay modes */ 1973 1980 static void ravb_set_delay_mode(struct net_device *ndev) 1974 1981 { ··· 1987 1980 set |= APSR_DM_RDM; 1988 1981 1989 1982 if (priv->phy_interface == PHY_INTERFACE_MODE_RGMII_ID || 1990 - priv->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID) 1991 - set |= APSR_DM_TDM; 1983 + priv->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID) { 1984 + if (!WARN(soc_device_match(ravb_delay_mode_quirk_match), 1985 + "phy-mode %s requires TX clock internal delay mode which is not supported by this hardware revision. Please update device tree", 1986 + phy_modes(priv->phy_interface))) 1987 + set |= APSR_DM_TDM; 1988 + } 1992 1989 1993 1990 ravb_modify(ndev, APSR, APSR_DM, set); 1994 1991 }