Skip to content

Commit b5713da

Browse files
Ansuelgregkh
authored andcommitted
net: mdio: ipq8064: add regmap config to disable REGCACHE
[ Upstream commit b097bea ] mdio drivers should not use REGCHACHE. Also disable locking since it's handled by the mdio users and regmap is always accessed atomically. Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent c0dd36b commit b5713da

1 file changed

Lines changed: 24 additions & 9 deletions

File tree

‎drivers/net/mdio/mdio-ipq8064.c‎

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <linux/module.h>
1111
#include <linux/regmap.h>
1212
#include <linux/of_mdio.h>
13-
#include <linux/phy.h>
13+
#include <linux/of_address.h>
1414
#include <linux/platform_device.h>
1515
#include <linux/mfd/syscon.h>
1616

@@ -96,14 +96,34 @@ ipq8064_mdio_write(struct mii_bus *bus, int phy_addr, int reg_offset, u16 data)
9696
return ipq8064_mdio_wait_busy(priv);
9797
}
9898

99+
static const struct regmap_config ipq8064_mdio_regmap_config = {
100+
.reg_bits = 32,
101+
.reg_stride = 4,
102+
.val_bits = 32,
103+
.can_multi_write = false,
104+
/* the mdio lock is used by any user of this mdio driver */
105+
.disable_locking = true,
106+
107+
.cache_type = REGCACHE_NONE,
108+
};
109+
99110
static int
100111
ipq8064_mdio_probe(struct platform_device *pdev)
101112
{
102113
struct device_node *np = pdev->dev.of_node;
103114
struct ipq8064_mdio *priv;
115+
struct resource res;
104116
struct mii_bus *bus;
117+
void __iomem *base;
105118
int ret;
106119

120+
if (of_address_to_resource(np, 0, &res))
121+
return -ENOMEM;
122+
123+
base = ioremap(res.start, resource_size(&res));
124+
if (!base)
125+
return -ENOMEM;
126+
107127
bus = devm_mdiobus_alloc_size(&pdev->dev, sizeof(*priv));
108128
if (!bus)
109129
return -ENOMEM;
@@ -115,15 +135,10 @@ ipq8064_mdio_probe(struct platform_device *pdev)
115135
bus->parent = &pdev->dev;
116136

117137
priv = bus->priv;
118-
priv->base = device_node_to_regmap(np);
119-
if (IS_ERR(priv->base)) {
120-
if (priv->base == ERR_PTR(-EPROBE_DEFER))
121-
return -EPROBE_DEFER;
122-
123-
dev_err(&pdev->dev, "error getting device regmap, error=%pe\n",
124-
priv->base);
138+
priv->base = devm_regmap_init_mmio(&pdev->dev, base,
139+
&ipq8064_mdio_regmap_config);
140+
if (IS_ERR(priv->base))
125141
return PTR_ERR(priv->base);
126-
}
127142

128143
ret = of_mdiobus_register(bus, np);
129144
if (ret)

0 commit comments

Comments
 (0)