Merge git://git.denx.de/u-boot-sh
[oweals/u-boot.git] / drivers / net / ravb.c
index 749562db960e59a8e7df3a0c8c7a6372b9b21e68..393ee9bb816a94283b5d3833bacbf59af5b05b31 100644 (file)
 
 #include <common.h>
 #include <clk.h>
+#include <cpu_func.h>
 #include <dm.h>
 #include <errno.h>
+#include <log.h>
 #include <miiphy.h>
 #include <malloc.h>
+#include <asm/cache.h>
+#include <linux/bitops.h>
+#include <linux/delay.h>
 #include <linux/mii.h>
 #include <wait_bit.h>
 #include <asm/io.h>
@@ -46,6 +51,8 @@
 #define CSR_OPS                        0x0000000F
 #define CSR_OPS_CONFIG         BIT(1)
 
+#define APSR_TDM               BIT(14)
+
 #define TCCR_TSRQ0             BIT(0)
 
 #define RFLR_RFL_MIN           0x05EE
@@ -389,9 +396,14 @@ static int ravb_dmac_init(struct udevice *dev)
        /* FIFO size set */
        writel(0x00222210, eth->iobase + RAVB_REG_TGC);
 
-       /* Delay CLK: 2ns */
-       if (pdata->max_speed == 1000)
-               writel(BIT(14), eth->iobase + RAVB_REG_APSR);
+       /* Delay CLK: 2ns (not applicable on R-Car E3/D3) */
+       if ((rmobile_get_cpu_type() == RMOBILE_CPU_TYPE_R8A77990) ||
+           (rmobile_get_cpu_type() == RMOBILE_CPU_TYPE_R8A77995))
+               return 0;
+
+       if ((pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_ID) ||
+           (pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID))
+               writel(APSR_TDM, eth->iobase + RAVB_REG_APSR);
 
        return 0;
 }