1 From 9d1bcb1f293f1391302a109c9819c3705c804700 Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
3 Date: Wed, 27 Jul 2022 13:35:23 +0200
4 Subject: [PATCH 14/14] net: dsa: qca8k: move read_switch_id function to common
7 The same function to read the switch id is used by drivers based on
8 qca8k family switch. Move them to common code to make them accessible
11 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
12 Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
13 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
15 drivers/net/dsa/qca/qca8k-8xxx.c | 29 -----------------------------
16 drivers/net/dsa/qca/qca8k-common.c | 29 +++++++++++++++++++++++++++++
17 drivers/net/dsa/qca/qca8k.h | 1 +
18 3 files changed, 30 insertions(+), 29 deletions(-)
20 --- a/drivers/net/dsa/qca/qca8k-8xxx.c
21 +++ b/drivers/net/dsa/qca/qca8k-8xxx.c
22 @@ -1822,35 +1822,6 @@ static const struct dsa_switch_ops qca8k
23 .connect_tag_protocol = qca8k_connect_tag_protocol,
26 -static int qca8k_read_switch_id(struct qca8k_priv *priv)
35 - ret = qca8k_read(priv, QCA8K_REG_MASK_CTRL, &val);
39 - id = QCA8K_MASK_CTRL_DEVICE_ID(val);
40 - if (id != priv->info->id) {
42 - "Switch id detected %x but expected %x",
43 - id, priv->info->id);
47 - priv->switch_id = id;
49 - /* Save revision to communicate to the internal PHY driver */
50 - priv->switch_revision = QCA8K_MASK_CTRL_REV_ID(val);
56 qca8k_sw_probe(struct mdio_device *mdiodev)
58 --- a/drivers/net/dsa/qca/qca8k-common.c
59 +++ b/drivers/net/dsa/qca/qca8k-common.c
60 @@ -1175,3 +1175,32 @@ int qca8k_port_lag_leave(struct dsa_swit
62 return qca8k_lag_refresh_portmap(ds, port, lag, true);
65 +int qca8k_read_switch_id(struct qca8k_priv *priv)
74 + ret = qca8k_read(priv, QCA8K_REG_MASK_CTRL, &val);
78 + id = QCA8K_MASK_CTRL_DEVICE_ID(val);
79 + if (id != priv->info->id) {
81 + "Switch id detected %x but expected %x",
82 + id, priv->info->id);
86 + priv->switch_id = id;
88 + /* Save revision to communicate to the internal PHY driver */
89 + priv->switch_revision = QCA8K_MASK_CTRL_REV_ID(val);
93 --- a/drivers/net/dsa/qca/qca8k.h
94 +++ b/drivers/net/dsa/qca/qca8k.h
95 @@ -424,6 +424,7 @@ extern const struct qca8k_mib_desc ar832
96 extern const struct regmap_access_table qca8k_readable_table;
97 int qca8k_mib_init(struct qca8k_priv *priv);
98 void qca8k_port_set_status(struct qca8k_priv *priv, int port, int enable);
99 +int qca8k_read_switch_id(struct qca8k_priv *priv);
101 /* Common read/write/rmw function */
102 int qca8k_read(struct qca8k_priv *priv, u32 reg, u32 *val);