Skip to content
Permalink
Browse files
net: mdio: mscc-miim: add MFD functionality through ocelot-core
In the MFD case we need to request a regmap from the parent device instead
of using mmio. This allows for the driver to be used in either case.

Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
  • Loading branch information
colin-foster-in-advantage authored and intel-lab-lkp committed Dec 18, 2021
1 parent 5d19d14 commit 769a8d735c3e2adee712e81ce5045b31fa096101
Showing 1 changed file with 16 additions and 6 deletions.
@@ -11,11 +11,13 @@
#include <linux/iopoll.h>
#include <linux/kernel.h>
#include <linux/mdio/mdio-mscc-miim.h>
#include <linux/mfd/core.h>
#include <linux/module.h>
#include <linux/of_mdio.h>
#include <linux/phy.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <soc/mscc/ocelot.h>

#define MSCC_MIIM_REG_STATUS 0x0
#define MSCC_MIIM_STATUS_STAT_PENDING BIT(2)
@@ -230,13 +232,21 @@ static int mscc_miim_probe(struct platform_device *pdev)
struct mii_bus *bus;
int ret;

regs = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
if (IS_ERR(regs)) {
dev_err(dev, "Unable to map MIIM registers\n");
return PTR_ERR(regs);
}
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);

if (!device_is_mfd(pdev)) {
regs = devm_ioremap_resource(dev, res);
if (IS_ERR(regs)) {
dev_err(dev, "Unable to map MIIM registers\n");
return PTR_ERR(regs);
}

mii_regmap = devm_regmap_init_mmio(dev, regs, &mscc_miim_regmap_config);
mii_regmap = devm_regmap_init_mmio(dev, regs,
&mscc_miim_regmap_config);
} else {
mii_regmap = ocelot_mfd_get_regmap_from_resource(dev->parent,
res);
}

if (IS_ERR(mii_regmap)) {
dev_err(dev, "Unable to create MIIM regmap\n");

0 comments on commit 769a8d7

Please sign in to comment.