net: phy: Fix the register offsets in Broadcom iProc mdio mux driver
authorArun Parameswaran <arun.parameswaran@broadcom.com>
Thu, 2 Aug 2018 00:53:47 +0000 (17:53 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 Sep 2018 20:43:39 +0000 (22:43 +0200)
[ Upstream commit 77fefa93bfebe4df44f154f2aa5938e32630d0bf ]

Modify the register offsets in the Broadcom iProc mdio mux to start
from the top of the register address space.

Earlier, the base address pointed to the end of the block's register
space. The base address will now point to the start of the mdio's
address space. The offsets have been fixed to match this.

Signed-off-by: Arun Parameswaran <arun.parameswaran@broadcom.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/phy/mdio-mux-bcm-iproc.c

index 0c5b68e..9b31670 100644 (file)
@@ -22,7 +22,7 @@
 #include <linux/mdio-mux.h>
 #include <linux/delay.h>
 
-#define MDIO_PARAM_OFFSET              0x00
+#define MDIO_PARAM_OFFSET              0x23c
 #define MDIO_PARAM_MIIM_CYCLE          29
 #define MDIO_PARAM_INTERNAL_SEL                25
 #define MDIO_PARAM_BUS_ID              22
 #define MDIO_PARAM_PHY_ID              16
 #define MDIO_PARAM_PHY_DATA            0
 
-#define MDIO_READ_OFFSET               0x04
+#define MDIO_READ_OFFSET               0x240
 #define MDIO_READ_DATA_MASK            0xffff
-#define MDIO_ADDR_OFFSET               0x08
+#define MDIO_ADDR_OFFSET               0x244
 
-#define MDIO_CTRL_OFFSET               0x0C
+#define MDIO_CTRL_OFFSET               0x248
 #define MDIO_CTRL_WRITE_OP             0x1
 #define MDIO_CTRL_READ_OP              0x2
 
-#define MDIO_STAT_OFFSET               0x10
+#define MDIO_STAT_OFFSET               0x24c
 #define MDIO_STAT_DONE                 1
 
 #define BUS_MAX_ADDR                   32
 #define EXT_BUS_START_ADDR             16
 
+#define MDIO_REG_ADDR_SPACE_SIZE       0x250
+
 struct iproc_mdiomux_desc {
        void *mux_handle;
        void __iomem *base;
@@ -169,6 +171,14 @@ static int mdio_mux_iproc_probe(struct platform_device *pdev)
        md->dev = &pdev->dev;
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       if (res->start & 0xfff) {
+               /* For backward compatibility in case the
+                * base address is specified with an offset.
+                */
+               dev_info(&pdev->dev, "fix base address in dt-blob\n");
+               res->start &= ~0xfff;
+               res->end = res->start + MDIO_REG_ADDR_SPACE_SIZE - 1;
+       }
        md->base = devm_ioremap_resource(&pdev->dev, res);
        if (IS_ERR(md->base)) {
                dev_err(&pdev->dev, "failed to ioremap register\n");