4.18-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Arun Parameswaran <arun.parameswa...@broadcom.com>

[ 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.parameswa...@broadcom.com>
Reviewed-by: Andrew Lunn <and...@lunn.ch>
Reviewed-by: Florian Fainelli <f.faine...@gmail.com>
Signed-off-by: David S. Miller <da...@davemloft.net>
Signed-off-by: Sasha Levin <alexander.le...@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gre...@linuxfoundation.org>
---
 drivers/net/phy/mdio-mux-bcm-iproc.c |   20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

--- a/drivers/net/phy/mdio-mux-bcm-iproc.c
+++ b/drivers/net/phy/mdio-mux-bcm-iproc.c
@@ -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
@@ -30,20 +30,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 p
        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");


Reply via email to