lkml.org 
[lkml]   [2021]   [Dec]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC v5 net-next 10/13] net: mdio: mscc-miim: add MFD functionality through ocelot-core
Date
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>
---
drivers/net/mdio/mdio-mscc-miim.c | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/drivers/net/mdio/mdio-mscc-miim.c b/drivers/net/mdio/mdio-mscc-miim.c
index 00757e77fab0..d35cca4672b4 100644
--- a/drivers/net/mdio/mdio-mscc-miim.c
+++ b/drivers/net/mdio/mdio-mscc-miim.c
@@ -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");
--
2.25.1
\
 
 \ /
  Last update: 2021-12-18 22:51    [W:0.127 / U:3.520 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site