diff mbox series

[net-next:,v3,4/6] net: mvmdio: add ACPI support

Message ID 20210621173028.3541424-5-mw@semihalf.com (mailing list archive)
State Accepted
Delegated to: Netdev Maintainers
Headers show
Series ACPI MDIO support for Marvell controllers | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers success CCed 4 of 4 maintainers
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 46 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link

Commit Message

Marcin Wojtas June 21, 2021, 5:30 p.m. UTC
This patch introducing ACPI support for the mvmdio driver by adding
acpi_match_table with two entries:

* "MRVL0100" for the SMI operation
* "MRVL0101" for the XSMI mode

Signed-off-by: Marcin Wojtas <mw@semihalf.com>
---
 drivers/net/ethernet/marvell/mvmdio.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

Comments

Andrew Lunn June 23, 2021, 8:28 p.m. UTC | #1
On Mon, Jun 21, 2021 at 07:30:26PM +0200, Marcin Wojtas wrote:
> This patch introducing ACPI support for the mvmdio driver by adding
> acpi_match_table with two entries:
> 
> * "MRVL0100" for the SMI operation
> * "MRVL0101" for the XSMI mode

Same as the freescale MDIO bus driver, you should add

depends on FWNODE_MDIO

Otherwise you might find randconfig builds end up with it disabled,
and then linker errors.

       Andrew
Marcin Wojtas June 23, 2021, 9:58 p.m. UTC | #2
śr., 23 cze 2021 o 22:28 Andrew Lunn <andrew@lunn.ch> napisał(a):
>
> On Mon, Jun 21, 2021 at 07:30:26PM +0200, Marcin Wojtas wrote:
> > This patch introducing ACPI support for the mvmdio driver by adding
> > acpi_match_table with two entries:
> >
> > * "MRVL0100" for the SMI operation
> > * "MRVL0101" for the XSMI mode
>
> Same as the freescale MDIO bus driver, you should add
>
> depends on FWNODE_MDIO
>
> Otherwise you might find randconfig builds end up with it disabled,
> and then linker errors.
>

The CONFIG_MVMDIO is selected by CONFIG_MV643XX_ETH and actually there
is a real example of the previously discussed fallback to the
mdiobus_register() (without DT/ACPI and now FWNODE_MDIO). I just
checked and successfully built the kernel out of the dove_defconfig. I
only needed below fix, that will be submitted in v4:

--- a/include/linux/fwnode_mdio.h
+++ b/include/linux/fwnode_mdio.h
@@ -40,7 +40,7 @@ static inline int fwnode_mdiobus_register(struct mii_bus *bus,
         * This way, we don't have to keep compat bits around in drivers.
         */

-       return mdiobus_register(mdio);
+       return mdiobus_register(bus);
 }
 #endif

In order to leave dove_defconfig intact, I'd keep the current Kconfig
shape for this driver.

Thanks,
Marcin
Andrew Lunn June 24, 2021, 1:24 a.m. UTC | #3
On Wed, Jun 23, 2021 at 11:58:14PM +0200, Marcin Wojtas wrote:
> śr., 23 cze 2021 o 22:28 Andrew Lunn <andrew@lunn.ch> napisał(a):
> >
> > On Mon, Jun 21, 2021 at 07:30:26PM +0200, Marcin Wojtas wrote:
> > > This patch introducing ACPI support for the mvmdio driver by adding
> > > acpi_match_table with two entries:
> > >
> > > * "MRVL0100" for the SMI operation
> > > * "MRVL0101" for the XSMI mode
> >
> > Same as the freescale MDIO bus driver, you should add
> >
> > depends on FWNODE_MDIO
> >
> > Otherwise you might find randconfig builds end up with it disabled,
> > and then linker errors.
> >
> 
> The CONFIG_MVMDIO is selected by CONFIG_MV643XX_ETH and actually there
> is a real example of the previously discussed fallback to the
> mdiobus_register() (without DT/ACPI and now FWNODE_MDIO). I just
> checked and successfully built the kernel out of the dove_defconfig. I
> only needed below fix, that will be submitted in v4:

You could be correct, but i've seen randconfig builds find issues. So
i tend to add dependencies to avoid possible problems.  Such problem
reports tend to come weeks later, when Arnd does such builds.

	Andrew
diff mbox series

Patch

diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c
index d14762d93640..7537ee3f6622 100644
--- a/drivers/net/ethernet/marvell/mvmdio.c
+++ b/drivers/net/ethernet/marvell/mvmdio.c
@@ -17,8 +17,10 @@ 
  * warranty of any kind, whether express or implied.
  */
 
+#include <linux/acpi.h>
 #include <linux/clk.h>
 #include <linux/delay.h>
+#include <linux/fwnode_mdio.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/kernel.h>
@@ -281,7 +283,7 @@  static int orion_mdio_probe(struct platform_device *pdev)
 	struct orion_mdio_dev *dev;
 	int i, ret;
 
-	type = (enum orion_mdio_bus_type)of_device_get_match_data(&pdev->dev);
+	type = (enum orion_mdio_bus_type)device_get_match_data(&pdev->dev);
 
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!r) {
@@ -369,7 +371,7 @@  static int orion_mdio_probe(struct platform_device *pdev)
 		goto out_mdio;
 	}
 
-	ret = of_mdiobus_register(bus, pdev->dev.of_node);
+	ret = fwnode_mdiobus_register(bus, pdev->dev.fwnode);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "Cannot register MDIO bus (%d)\n", ret);
 		goto out_mdio;
@@ -421,12 +423,20 @@  static const struct of_device_id orion_mdio_match[] = {
 };
 MODULE_DEVICE_TABLE(of, orion_mdio_match);
 
+static const struct acpi_device_id orion_mdio_acpi_match[] = {
+	{ "MRVL0100", BUS_TYPE_SMI },
+	{ "MRVL0101", BUS_TYPE_XSMI },
+	{ },
+};
+MODULE_DEVICE_TABLE(acpi, orion_mdio_acpi_match);
+
 static struct platform_driver orion_mdio_driver = {
 	.probe = orion_mdio_probe,
 	.remove = orion_mdio_remove,
 	.driver = {
 		.name = "orion-mdio",
 		.of_match_table = orion_mdio_match,
+		.acpi_match_table = ACPI_PTR(orion_mdio_acpi_match),
 	},
 };