linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Calvin Johnson <calvin.johnson@nxp.com>
To: linux.cj@gmail.com, Jon Nettleton <jon@solid-run.com>,
	linux@armlinux.org.uk, Makarand Pawagi <makarand.pawagi@nxp.com>,
	cristian.sovaiala@nxp.com, laurentiu.tudor@nxp.com,
	ioana.ciornei@nxp.com, V.Sethi@nxp.com, pankaj.bansal@nxp.com,
	"Rajesh V . Bikkina" <rajesh.bikkina@nxp.com>
Cc: Calvin Johnson <calvin.johnson@oss.nxp.com>,
	"David S. Miller" <davem@davemloft.net>,
	Madalin Bucur <madalin.bucur@oss.nxp.com>,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Subject: [PATCH v1 3/7] net/fsl: add ACPI support for mdio bus
Date: Fri, 31 Jan 2020 21:04:36 +0530	[thread overview]
Message-ID: <20200131153440.20870-4-calvin.johnson@nxp.com> (raw)
In-Reply-To: <20200131153440.20870-1-calvin.johnson@nxp.com>

From: Calvin Johnson <calvin.johnson@oss.nxp.com>

Add ACPI support for MDIO bus registration while maintaining
the existing DT support.

Signed-off-by: Calvin Johnson <calvin.johnson@oss.nxp.com>
---

 drivers/net/ethernet/freescale/xgmac_mdio.c | 63 ++++++++++++++-------
 1 file changed, 42 insertions(+), 21 deletions(-)

diff --git a/drivers/net/ethernet/freescale/xgmac_mdio.c b/drivers/net/ethernet/freescale/xgmac_mdio.c
index c82c85ef5fb3..51db7482b3de 100644
--- a/drivers/net/ethernet/freescale/xgmac_mdio.c
+++ b/drivers/net/ethernet/freescale/xgmac_mdio.c
@@ -2,6 +2,7 @@
  * QorIQ 10G MDIO Controller
  *
  * Copyright 2012 Freescale Semiconductor, Inc.
+ * Copyright 2019 NXP
  *
  * Authors: Andy Fleming <afleming@freescale.com>
  *          Timur Tabi <timur@freescale.com>
@@ -11,6 +12,7 @@
  * kind, whether express or implied.
  */
 
+#include <linux/acpi.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/interrupt.h>
@@ -245,14 +247,14 @@ static int xgmac_mdio_probe(struct platform_device *pdev)
 {
 	struct device_node *np = pdev->dev.of_node;
 	struct mii_bus *bus;
-	struct resource res;
+	struct resource *res;
 	struct mdio_fsl_priv *priv;
 	int ret;
 
-	ret = of_address_to_resource(np, 0, &res);
-	if (ret) {
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res) {
 		dev_err(&pdev->dev, "could not obtain address\n");
-		return ret;
+		return -ENODEV;
 	}
 
 	bus = mdiobus_alloc_size(sizeof(struct mdio_fsl_priv));
@@ -263,25 +265,41 @@ static int xgmac_mdio_probe(struct platform_device *pdev)
 	bus->read = xgmac_mdio_read;
 	bus->write = xgmac_mdio_write;
 	bus->parent = &pdev->dev;
-	snprintf(bus->id, MII_BUS_ID_SIZE, "%llx", (unsigned long long)res.start);
+	snprintf(bus->id, MII_BUS_ID_SIZE, "%llx",
+		 (unsigned long long)res->start);
 
 	/* Set the PHY base address */
 	priv = bus->priv;
-	priv->mdio_base = of_iomap(np, 0);
+	priv->mdio_base = devm_ioremap_resource(&pdev->dev, res);
 	if (!priv->mdio_base) {
 		ret = -ENOMEM;
 		goto err_ioremap;
 	}
 
-	priv->is_little_endian = of_property_read_bool(pdev->dev.of_node,
-						       "little-endian");
-
-	priv->has_a011043 = of_property_read_bool(pdev->dev.of_node,
-						  "fsl,erratum-a011043");
-
-	ret = of_mdiobus_register(bus, np);
-	if (ret) {
-		dev_err(&pdev->dev, "cannot register MDIO bus\n");
+	if (is_of_node(pdev->dev.fwnode)) {
+		priv->is_little_endian = of_property_read_bool(pdev->dev.of_node,
+							       "little-endian");
+
+		priv->has_a011043 = of_property_read_bool(pdev->dev.of_node,
+							  "fsl,erratum-a011043");
+
+		ret = of_mdiobus_register(bus, np);
+		if (ret) {
+			dev_err(&pdev->dev, "cannot register MDIO bus\n");
+			goto err_registration;
+		}
+	} else if (is_acpi_node(pdev->dev.fwnode)) {
+		priv->is_little_endian =
+			fwnode_property_read_bool(pdev->dev.fwnode,
+						  "little-endian");
+		ret = fwnode_mdiobus_register(bus, pdev->dev.fwnode);
+		if (ret) {
+			dev_err(&pdev->dev, "cannot register MDIO bus\n");
+			goto err_registration;
+		}
+	} else {
+		dev_err(&pdev->dev, "Cannot get cfg data from DT or ACPI\n");
+		ret = -ENXIO;
 		goto err_registration;
 	}
 
@@ -290,8 +308,6 @@ static int xgmac_mdio_probe(struct platform_device *pdev)
 	return 0;
 
 err_registration:
-	iounmap(priv->mdio_base);
-
 err_ioremap:
 	mdiobus_free(bus);
 
@@ -303,13 +319,12 @@ static int xgmac_mdio_remove(struct platform_device *pdev)
 	struct mii_bus *bus = platform_get_drvdata(pdev);
 
 	mdiobus_unregister(bus);
-	iounmap(bus->priv);
 	mdiobus_free(bus);
 
 	return 0;
 }
 
-static const struct of_device_id xgmac_mdio_match[] = {
+static const struct of_device_id xgmac_mdio_of_match[] = {
 	{
 		.compatible = "fsl,fman-xmdio",
 	},
@@ -318,12 +333,18 @@ static const struct of_device_id xgmac_mdio_match[] = {
 	},
 	{},
 };
-MODULE_DEVICE_TABLE(of, xgmac_mdio_match);
+MODULE_DEVICE_TABLE(of, xgmac_mdio_of_match);
+
+static const struct acpi_device_id xgmac_mdio_acpi_match[] = {
+	{"NXP0006", 0}
+};
+MODULE_DEVICE_TABLE(acpi, xgmac_mdio_acpi_match);
 
 static struct platform_driver xgmac_mdio_driver = {
 	.driver = {
 		.name = "fsl-fman_xmdio",
-		.of_match_table = xgmac_mdio_match,
+		.of_match_table = xgmac_mdio_of_match,
+		.acpi_match_table = ACPI_PTR(xgmac_mdio_acpi_match),
 	},
 	.probe = xgmac_mdio_probe,
 	.remove = xgmac_mdio_remove,
-- 
2.17.1


  parent reply	other threads:[~2020-01-31 15:35 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-31 15:34 [PATCH v1 0/7] ACPI support for xgmac_mdio and dpaa2-mac drivers Calvin Johnson
2020-01-31 15:34 ` [PATCH v1 1/7] mdio_bus: Introduce fwnode MDIO helpers Calvin Johnson
2020-01-31 16:28   ` Andrew Lunn
2020-02-05  7:11     ` [EXT] " Calvin Johnson (OSS)
2020-02-03  9:49   ` kbuild test robot
2020-02-05 14:17   ` Jeremy Linton
2020-02-07  9:42     ` [EXT] " Calvin Johnson (OSS)
2020-03-17 11:36   ` Calvin Johnson
2020-03-17 14:04     ` Andrew Lunn
2020-03-18  6:03       ` Calvin Johnson
2020-01-31 15:34 ` [PATCH v1 2/7] mdio_bus: modify fwnode phy related functions Calvin Johnson
2020-01-31 15:34 ` Calvin Johnson [this message]
2020-01-31 16:08   ` [PATCH v1 3/7] net/fsl: add ACPI support for mdio bus Andy Shevchenko
2020-02-04  7:18     ` Calvin Johnson (OSS)
2020-02-04 11:17       ` Andy Shevchenko
2020-02-03  3:44   ` Florian Fainelli
2020-02-04 18:46     ` Calvin Johnson
2020-01-31 15:34 ` [PATCH v1 4/7] device property: fwnode_get_phy_mode: Change API to solve int/unit warnings Calvin Johnson
2020-01-31 15:55   ` Andy Shevchenko
2020-02-03  9:13     ` Calvin Johnson (OSS)
2020-02-03  9:22       ` Andy Shevchenko
2020-02-03  2:32   ` kbuild test robot
2020-02-03  8:41   ` kbuild test robot
2020-01-31 15:34 ` [PATCH v1 5/7] device property: Introduce fwnode_phy_is_fixed_link() Calvin Johnson
2020-01-31 15:57   ` Andy Shevchenko
2020-02-03  9:21     ` Calvin Johnson (OSS)
2020-01-31 15:34 ` [PATCH v1 6/7] net: phylink: Introduce phylink_fwnode_phy_connect() Calvin Johnson
2020-02-03 18:21   ` kbuild test robot
2020-02-03 18:41   ` Russell King - ARM Linux admin
2020-02-03 18:43     ` Russell King - ARM Linux admin
2020-02-05 11:33     ` [EXT] " Calvin Johnson (OSS)
2020-01-31 15:34 ` [PATCH v1 7/7] dpaa2-eth: Add ACPI support for DPAA2 MAC driver Calvin Johnson
2020-02-03 18:02 ` [PATCH v1 0/7] ACPI support for xgmac_mdio and dpaa2-mac drivers Florian Fainelli
2020-02-05  8:31   ` [EXT] " Calvin Johnson (OSS)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200131153440.20870-4-calvin.johnson@nxp.com \
    --to=calvin.johnson@nxp.com \
    --cc=V.Sethi@nxp.com \
    --cc=calvin.johnson@oss.nxp.com \
    --cc=cristian.sovaiala@nxp.com \
    --cc=davem@davemloft.net \
    --cc=ioana.ciornei@nxp.com \
    --cc=jon@solid-run.com \
    --cc=laurentiu.tudor@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux.cj@gmail.com \
    --cc=linux@armlinux.org.uk \
    --cc=madalin.bucur@oss.nxp.com \
    --cc=makarand.pawagi@nxp.com \
    --cc=netdev@vger.kernel.org \
    --cc=pankaj.bansal@nxp.com \
    --cc=rajesh.bikkina@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).