Skip to content

Commit 61fccb2

Browse files
KAZUMIZUdavem330
authored andcommitted
ravb: Add tx and rx clock internal delays mode of APSR
This patch enables tx and rx clock internal delay modes (TDM and RDM). This is to address a failure in the case of 1Gbps communication using the by salvator-x board with the KSZ9031RNX phy. This has been reported to occur with both the r8a7795 (H3) and r8a7796 (M3-W) SoCs. With this change APSR internal delay modes are enabled for "rgmii-id", "rgmii-rxid" and "rgmii-txid" phy modes as follows: phy mode | ASPR delay mode -----------+---------------- rgmii-id | TDM and RDM rgmii-rxid | RDM rgmii-txid | TDM Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi.ks@renesas.com> Signed-off-by: Simon Horman <horms+renesas@verge.net.au> Acked-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 1a28242 commit 61fccb2

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

drivers/net/ethernet/renesas/ravb.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ enum ravb_reg {
7676
CDAR20 = 0x0060,
7777
CDAR21 = 0x0064,
7878
ESR = 0x0088,
79+
APSR = 0x008C, /* R-Car Gen3 only */
7980
RCR = 0x0090,
8081
RQC0 = 0x0094,
8182
RQC1 = 0x0098,
@@ -248,6 +249,15 @@ enum ESR_BIT {
248249
ESR_EIL = 0x00001000,
249250
};
250251

252+
/* APSR */
253+
enum APSR_BIT {
254+
APSR_MEMS = 0x00000002,
255+
APSR_CMSW = 0x00000010,
256+
APSR_DM = 0x00006000, /* Undocumented? */
257+
APSR_DM_RDM = 0x00002000,
258+
APSR_DM_TDM = 0x00004000,
259+
};
260+
251261
/* RCR */
252262
enum RCR_BIT {
253263
RCR_EFFS = 0x00000001,

drivers/net/ethernet/renesas/ravb_main.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1920,6 +1920,23 @@ static void ravb_set_config_mode(struct net_device *ndev)
19201920
}
19211921
}
19221922

1923+
/* Set tx and rx clock internal delay modes */
1924+
static void ravb_set_delay_mode(struct net_device *ndev)
1925+
{
1926+
struct ravb_private *priv = netdev_priv(ndev);
1927+
int set = 0;
1928+
1929+
if (priv->phy_interface == PHY_INTERFACE_MODE_RGMII_ID ||
1930+
priv->phy_interface == PHY_INTERFACE_MODE_RGMII_RXID)
1931+
set |= APSR_DM_RDM;
1932+
1933+
if (priv->phy_interface == PHY_INTERFACE_MODE_RGMII_ID ||
1934+
priv->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID)
1935+
set |= APSR_DM_TDM;
1936+
1937+
ravb_modify(ndev, APSR, APSR_DM, set);
1938+
}
1939+
19231940
static int ravb_probe(struct platform_device *pdev)
19241941
{
19251942
struct device_node *np = pdev->dev.of_node;
@@ -2032,6 +2049,9 @@ static int ravb_probe(struct platform_device *pdev)
20322049
/* Request GTI loading */
20332050
ravb_modify(ndev, GCCR, GCCR_LTI, GCCR_LTI);
20342051

2052+
if (priv->chip_id != RCAR_GEN2)
2053+
ravb_set_delay_mode(ndev);
2054+
20352055
/* Allocate descriptor base address table */
20362056
priv->desc_bat_size = sizeof(struct ravb_desc) * DBAT_ENTRY_NUM;
20372057
priv->desc_bat = dma_alloc_coherent(ndev->dev.parent, priv->desc_bat_size,
@@ -2168,6 +2188,9 @@ static int __maybe_unused ravb_resume(struct device *dev)
21682188
/* Request GTI loading */
21692189
ravb_modify(ndev, GCCR, GCCR_LTI, GCCR_LTI);
21702190

2191+
if (priv->chip_id != RCAR_GEN2)
2192+
ravb_set_delay_mode(ndev);
2193+
21712194
/* Restore descriptor base address table */
21722195
ravb_write(ndev, priv->desc_bat_dma, DBAT);
21732196

0 commit comments

Comments
 (0)