diff mbox series

[v3,17/22] net: tsec: Support <reg> property from the subnode "queue-group"

Message ID 20210314051510.26628-18-bmeng.cn@gmail.com
State Superseded
Delegated to: Priyanka Jain
Headers show
Series ppc: qemu: Add eTSEC support | expand

Commit Message

Bin Meng March 14, 2021, 5:15 a.m. UTC
At present the tsec driver uses a non-standard DT bindings to get
its <reg> base / size. The upstream Linux kernel seems to require
the <reg> base / size to be put under a subnode of the eTSEC node
with a name prefix "queue-group". This is not documented in the
kernel DT bindings, but it looks every dtsi file that contains the
eTSEC node was written like this.

This commit updates the tsec driver to handle this case.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>

---

Changes in v3:
- keep the variable definitions sorted
- invert the strncmp logic to reduce the indentation level
- add a comment to mention only the first "queue-group" is used
- call the same map_physmem() in the common code path

 drivers/net/tsec.c | 30 +++++++++++++++++++++++++++---
 1 file changed, 27 insertions(+), 3 deletions(-)

Comments

Vladimir Oltean March 14, 2021, 8:14 a.m. UTC | #1
On Sun, Mar 14, 2021 at 01:15:05PM +0800, Bin Meng wrote:
> At present the tsec driver uses a non-standard DT bindings to get
> its <reg> base / size. The upstream Linux kernel seems to require
> the <reg> base / size to be put under a subnode of the eTSEC node
> with a name prefix "queue-group". This is not documented in the
> kernel DT bindings, but it looks every dtsi file that contains the
> eTSEC node was written like this.
> 
> This commit updates the tsec driver to handle this case.
> 
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
> 
> ---

Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
diff mbox series

Patch

diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c
index 491d2ef1ae..c68e4b7fb5 100644
--- a/drivers/net/tsec.c
+++ b/drivers/net/tsec.c
@@ -826,15 +826,39 @@  int tsec_probe(struct udevice *dev)
 	u32 tbiaddr = CONFIG_SYS_TBIPA_VALUE;
 	struct tsec_data *data;
 	const char *phy_mode;
+	ofnode parent, child;
 	fdt_addr_t reg;
-	ofnode parent;
 	int ret;
 
 	data = (struct tsec_data *)dev_get_driver_data(dev);
 
 	pdata->iobase = (phys_addr_t)dev_read_addr(dev);
-	if (pdata->iobase == FDT_ADDR_T_NONE)
-		return -ENOENT;
+	if (pdata->iobase == FDT_ADDR_T_NONE) {
+		ofnode_for_each_subnode(child, dev_ofnode(dev)) {
+			if (strncmp(ofnode_get_name(child), "queue-group",
+				    strlen("queue-group")))
+				continue;
+
+			reg = ofnode_get_addr(child);
+			if (reg == FDT_ADDR_T_NONE) {
+				printf("No 'reg' property of <queue-group>\n");
+				return -ENOENT;
+			}
+			pdata->iobase = reg;
+
+			/*
+			 * if there are multiple queue groups,
+			 * only the first one is used.
+			 */
+			break;
+		}
+
+		if (!ofnode_valid(child)) {
+			printf("No child node for <queue-group>?\n");
+			return -ENOENT;
+		}
+	}
+
 	priv->regs = map_physmem(pdata->iobase, 0, MAP_NOCACHE);
 
 	ret = dev_read_phandle_with_args(dev, "tbi-handle", NULL, 0, 0,