[net-next: PATCH 10/12] net: dsa: add ACPI support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Although the recent switch to device_/fwnode_ API covers the most
of modifications required for supporting ACPI, minor additional
changes should be applied:

* Use different subnode names with ACPI for 'ports' and 'mdio':
  * Naming of the nodes in ACPI must conform the namespace
    constraints, with regards to the characters' type
    and ACPI_NAMESEG_SIZE [1]. Because of that, the 'ports'
    subnode name used in device tree case, is not appropriate
    in ACPI world. This patch updates the subnode name depending on
    the hardware description type in runtime.
* Obtain ports indexes from _ADR fields
  * Same as in the MDIO PHY case, use this standard field instead of
    parsing 'reg' property from _DSD object.
* For now cascade topology remains unsupported in ACPI world, so
  disable ports connected to other switch devices.

[1] https://uefi.org/specs/ACPI/6.4/05_ACPI_Software_Programming_Model/ACPI_Software_Programming_Model.html#acpi-namespace

Signed-off-by: Marcin Wojtas <mw@xxxxxxxxxxxx>
---
 net/dsa/dsa2.c | 35 +++++++++++++++++---
 1 file changed, 31 insertions(+), 4 deletions(-)

diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 5e11d66f9057..53837dad1cca 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -6,6 +6,8 @@
  * Copyright (c) 2016 Andrew Lunn <andrew@xxxxxxx>
  */
 
+#include <linux/acpi.h>
+#include <linux/acpi_mdio.h>
 #include <linux/device.h>
 #include <linux/etherdevice.h>
 #include <linux/err.h>
@@ -854,6 +856,7 @@ static int dsa_switch_setup_tag_protocol(struct dsa_switch *ds)
 static int dsa_switch_setup(struct dsa_switch *ds)
 {
 	struct dsa_devlink_priv *dl_priv;
+	char mdio_node_name[] = "mdio";
 	struct fwnode_handle *fwnode;
 	struct dsa_port *dp;
 	int err;
@@ -910,9 +913,16 @@ static int dsa_switch_setup(struct dsa_switch *ds)
 
 		dsa_slave_mii_bus_init(ds);
 
-		fwnode = fwnode_get_named_child_node(ds->dev->fwnode, "mdio");
+		/* Update subnode name if operating in the ACPI world. */
+		if (is_acpi_node(fwnode))
+			strncpy(mdio_node_name, "MDIO", ACPI_NAMESEG_SIZE);
 
-		err = of_mdiobus_register(ds->slave_mii_bus, to_of_node(fwnode));
+		fwnode = fwnode_get_named_child_node(ds->dev->fwnode, mdio_node_name);
+
+		if (is_acpi_node(fwnode))
+			err = acpi_mdiobus_register(ds->slave_mii_bus, fwnode);
+		else
+			err = of_mdiobus_register(ds->slave_mii_bus, to_of_node(fwnode));
 		fwnode_handle_put(fwnode);
 		if (err < 0)
 			goto free_slave_mii_bus;
@@ -1374,6 +1384,15 @@ static int dsa_port_parse_user(struct dsa_port *dp, const char *name)
 
 static int dsa_port_parse_dsa(struct dsa_port *dp)
 {
+	/* Cascade switch connection is not supported in ACPI world. */
+	if (is_acpi_node(dp->fwnode)) {
+		dev_warn(dp->ds->dev,
+			 "DSA type is not supported with ACPI, disable port #%d\n",
+			 dp->index);
+		dp->type = DSA_PORT_TYPE_UNUSED;
+		return 0;
+	}
+
 	dp->type = DSA_PORT_TYPE_DSA;
 
 	return 0;
@@ -1524,11 +1543,16 @@ static int dsa_switch_parse_ports_of(struct dsa_switch *ds,
 				     struct fwnode_handle *fwnode)
 {
 	struct fwnode_handle *ports, *port;
+	char ports_node_name[] = "ports";
 	struct dsa_port *dp;
 	int err = 0;
 	u32 reg;
 
-	ports = fwnode_get_named_child_node(fwnode, "ports");
+	/* Update subnode name if operating in the ACPI world. */
+	if (is_acpi_node(fwnode))
+		strncpy(ports_node_name, "PRTS", ACPI_NAMESEG_SIZE);
+
+	ports = fwnode_get_named_child_node(fwnode, ports_node_name);
 	if (!ports) {
 		/* The second possibility is "ethernet-ports" */
 		ports = fwnode_get_named_child_node(fwnode, "ethernet-ports");
@@ -1539,7 +1563,10 @@ static int dsa_switch_parse_ports_of(struct dsa_switch *ds,
 	}
 
 	fwnode_for_each_available_child_node(ports, port) {
-		err = fwnode_property_read_u32(port, "reg", &reg);
+		if (is_acpi_node(port))
+			err = acpi_get_local_address(ACPI_HANDLE_FWNODE(port), &reg);
+		else
+			err = fwnode_property_read_u32(port, "reg", &reg);
 		if (err) {
 			fwnode_handle_put(port);
 			goto out_put_node;
-- 
2.29.0




[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux