]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
net: tsec: Access eTSEC registers using virtual address
authorHou Zhiqiang <Zhiqiang.Hou@nxp.com>
Sun, 3 May 2020 14:48:42 +0000 (22:48 +0800)
committerPriyanka Jain <priyanka.jain@nxp.com>
Thu, 4 Jun 2020 13:23:20 +0000 (18:53 +0530)
The current code accesses eTSEC registers using physical
address directly, it's not correct, though no problem on
current platforms. It won't work on platforms, which does
not support 1:1 virtual-physical address map.

Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
drivers/net/tsec.c

index c2e755f2b1e343de5817e207e9dfabe9979df8ac..611cb040dc534d84f3cf29b28c41387ff0a8bc4c 100644 (file)
@@ -800,7 +800,7 @@ int tsec_probe(struct udevice *dev)
        int ret;
 
        pdata->iobase = (phys_addr_t)dev_read_addr(dev);
-       priv->regs = (struct tsec *)pdata->iobase;
+       priv->regs = dev_remap_addr(dev);
 
        if (dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0,
                                       &phandle_args)) {
@@ -819,8 +819,13 @@ int tsec_probe(struct udevice *dev)
        }
 
        reg = ofnode_get_addr_index(parent, 0);
-       priv->phyregs_sgmii = (struct tsec_mii_mng *)
-                       (reg + TSEC_MDIO_REGS_OFFSET);
+       if (reg == FDT_ADDR_T_NONE) {
+               printf("No 'reg' property of MII for external PHY\n");
+               return -ENOENT;
+       }
+
+       priv->phyregs_sgmii = map_physmem(reg + TSEC_MDIO_REGS_OFFSET, 0,
+                                         MAP_NOCACHE);
 
        ret = dev_read_phandle_with_args(dev, "tbi-handle", NULL, 0, 0,
                                         &phandle_args);