[PATCH net-next 08/11] net: dsa: rzn1-a5psw: Make DSA tag protocol configurable via OF data

Prabhakar
2025-11-21T11:36:14Z

From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

Update the RZN1 A5PSW driver to obtain the DSA tag protocol from
device-specific data instead of using a hard-coded value. Add a new
`tag_proto` field to `struct a5psw_of_data` and use it in
`a5psw_get_tag_protocol()` to return the appropriate protocol for
each SoC.

This allows future SoCs such as RZ/T2H and RZ/N2H, which use the
DSA_TAG_PROTO_RZT2H_ETHSW tag format, to share the same driver
infrastructure without code duplication.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
drivers/net/dsa/rzn1_a5psw.c | 5 ++++-
drivers/net/dsa/rzn1_a5psw.h | 2 ++
2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/dsa/rzn1_a5psw.c b/drivers/net/dsa/rzn1_a5psw.c
index d957b6d40f05..dc42a409eaef 100644
--- a/drivers/net/dsa/rzn1_a5psw.c
+++ b/drivers/net/dsa/rzn1_a5psw.c
@@ -97,7 +97,9 @@ static enum dsa_tag_protocol a5psw_get_tag_protocol(struct dsa_switch *ds,
int port,
enum dsa_tag_protocol mp)
{
- return DSA_TAG_PROTO_RZN1_A5PSW;
+ struct a5psw *a5psw = ds->priv;
+
+ return a5psw->of_data->tag_proto;
}

static void a5psw_port_pattern_set(struct a5psw *a5psw, int port, int pattern,
@@ -1316,6 +1318,7 @@ static void a5psw_shutdown(struct platform_device *pdev)
static const struct a5psw_of_data rzn1_of_data = {
.nports = 5,
.cpu_port = 4,
+ .tag_proto = DSA_TAG_PROTO_RZN1_A5PSW,
};

static const struct of_device_id a5psw_of_mtable[] = {
diff --git a/drivers/net/dsa/rzn1_a5psw.h b/drivers/net/dsa/rzn1_a5psw.h
index d1b2cc5b43e6..0fef32451e4f 100644
--- a/drivers/net/dsa/rzn1_a5psw.h
+++ b/drivers/net/dsa/rzn1_a5psw.h
@@ -234,10 +234,12 @@ union lk_data {
* struct a5psw_of_data - OF data structure
* @nports: Number of ports in the switch
* @cpu_port: CPU port number
+ * @tag_proto: DSA tag protocol used by the switch
*/
struct a5psw_of_data {
unsigned int nports;
unsigned int cpu_port;
+ enum dsa_tag_protocol tag_proto;
};

/**
--
2.52.0