From: Arun Ramadoss <arun.ramadoss@microchip.com>
To: <linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>
Cc: Woojung Huh <woojung.huh@microchip.com>,
<UNGLinuxDriver@microchip.com>, Andrew Lunn <andrew@lunn.ch>,
Vivien Didelot <vivien.didelot@gmail.com>,
Florian Fainelli <f.fainelli@gmail.com>,
Vladimir Oltean <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
"Russell King" <linux@armlinux.org.uk>
Subject: [Patch net-next 7/7] net: dsa: microchip: move remaining register offset to ksz_chip_reg
Date: Tue, 28 Jun 2022 22:43:29 +0530 [thread overview]
Message-ID: <20220628171329.25503-8-arun.ramadoss@microchip.com> (raw)
In-Reply-To: <20220628171329.25503-1-arun.ramadoss@microchip.com>
This patch moves the broadcast ctrl, multicast ctrl and start control
registers from ksz_chip_dat to ksz_chip_reg.
Signed-off-by: Arun Ramadoss <arun.ramadoss@microchip.com>
---
drivers/net/dsa/microchip/ksz_common.c | 57 +++++++-------------------
drivers/net/dsa/microchip/ksz_common.h | 3 ++
2 files changed, 18 insertions(+), 42 deletions(-)
diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index 2f336b991d5a..1354804171a1 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -217,6 +217,9 @@ static const u16 ksz8795_regs[] = {
[P_SPEED_STATUS] = 0x09,
[S_TAIL_TAG_CTRL] = 0x0C,
[P_STP_CTRL] = 0x02,
+ [S_START_CTRL] = 0x01,
+ [S_BROADCAST_CTRL] = 0x06,
+ [S_MULTICAST_CTRL] = 0x04,
};
static const u32 ksz8795_masks[] = {
@@ -268,6 +271,9 @@ static const u16 ksz8863_regs[] = {
[P_SPEED_STATUS] = 0x0F,
[S_TAIL_TAG_CTRL] = 0x03,
[P_STP_CTRL] = 0x02,
+ [S_START_CTRL] = 0x01,
+ [S_BROADCAST_CTRL] = 0x06,
+ [S_MULTICAST_CTRL] = 0x04,
};
static const u32 ksz8863_masks[] = {
@@ -305,6 +311,9 @@ static u8 ksz8863_shifts[] = {
static const u16 ksz9477_regs[] = {
[P_STP_CTRL] = 0x0B04,
+ [S_START_CTRL] = 0x0300,
+ [S_BROADCAST_CTRL] = 0x0332,
+ [S_MULTICAST_CTRL] = 0x0331,
};
@@ -325,9 +334,6 @@ const struct ksz_chip_data ksz_switch_chips[] = {
.regs = ksz8795_regs,
.masks = ksz8795_masks,
.shifts = ksz8795_shifts,
- .broadcast_ctrl_reg = 0x06,
- .multicast_ctrl_reg = 0x04,
- .start_ctrl_reg = 0x01,
.supports_mii = {false, false, false, false, true},
.supports_rmii = {false, false, false, false, true},
.supports_rgmii = {false, false, false, false, true},
@@ -364,9 +370,6 @@ const struct ksz_chip_data ksz_switch_chips[] = {
.regs = ksz8795_regs,
.masks = ksz8795_masks,
.shifts = ksz8795_shifts,
- .broadcast_ctrl_reg = 0x06,
- .multicast_ctrl_reg = 0x04,
- .start_ctrl_reg = 0x01,
.supports_mii = {false, false, false, false, true},
.supports_rmii = {false, false, false, false, true},
.supports_rgmii = {false, false, false, false, true},
@@ -389,9 +392,6 @@ const struct ksz_chip_data ksz_switch_chips[] = {
.regs = ksz8795_regs,
.masks = ksz8795_masks,
.shifts = ksz8795_shifts,
- .broadcast_ctrl_reg = 0x06,
- .multicast_ctrl_reg = 0x04,
- .start_ctrl_reg = 0x01,
.supports_mii = {false, false, false, false, true},
.supports_rmii = {false, false, false, false, true},
.supports_rgmii = {false, false, false, false, true},
@@ -413,9 +413,6 @@ const struct ksz_chip_data ksz_switch_chips[] = {
.regs = ksz8863_regs,
.masks = ksz8863_masks,
.shifts = ksz8863_shifts,
- .broadcast_ctrl_reg = 0x06,
- .multicast_ctrl_reg = 0x04,
- .start_ctrl_reg = 0x01,
.supports_mii = {false, false, true},
.supports_rmii = {false, false, true},
.internal_phy = {true, true, false},
@@ -435,9 +432,6 @@ const struct ksz_chip_data ksz_switch_chips[] = {
.mib_cnt = ARRAY_SIZE(ksz9477_mib_names),
.reg_mib_cnt = MIB_COUNTER_NUM,
.regs = ksz9477_regs,
- .broadcast_ctrl_reg = 0x0332,
- .multicast_ctrl_reg = 0x0331,
- .start_ctrl_reg = 0x0300,
.supports_mii = {false, false, false, false,
false, true, false},
.supports_rmii = {false, false, false, false,
@@ -462,9 +456,6 @@ const struct ksz_chip_data ksz_switch_chips[] = {
.mib_cnt = ARRAY_SIZE(ksz9477_mib_names),
.reg_mib_cnt = MIB_COUNTER_NUM,
.regs = ksz9477_regs,
- .broadcast_ctrl_reg = 0x0332,
- .multicast_ctrl_reg = 0x0331,
- .start_ctrl_reg = 0x0300,
.supports_mii = {false, false, false, false,
false, true, true},
.supports_rmii = {false, false, false, false,
@@ -488,9 +479,6 @@ const struct ksz_chip_data ksz_switch_chips[] = {
.mib_cnt = ARRAY_SIZE(ksz9477_mib_names),
.reg_mib_cnt = MIB_COUNTER_NUM,
.regs = ksz9477_regs,
- .broadcast_ctrl_reg = 0x0332,
- .multicast_ctrl_reg = 0x0331,
- .start_ctrl_reg = 0x0300,
.supports_mii = {false, false, true},
.supports_rmii = {false, false, true},
.supports_rgmii = {false, false, true},
@@ -511,9 +499,6 @@ const struct ksz_chip_data ksz_switch_chips[] = {
.mib_cnt = ARRAY_SIZE(ksz9477_mib_names),
.reg_mib_cnt = MIB_COUNTER_NUM,
.regs = ksz9477_regs,
- .broadcast_ctrl_reg = 0x0332,
- .multicast_ctrl_reg = 0x0331,
- .start_ctrl_reg = 0x0300,
.supports_mii = {false, false, false, false,
false, true, true},
.supports_rmii = {false, false, false, false,
@@ -536,9 +521,6 @@ const struct ksz_chip_data ksz_switch_chips[] = {
.mib_cnt = ARRAY_SIZE(ksz9477_mib_names),
.reg_mib_cnt = MIB_COUNTER_NUM,
.regs = ksz9477_regs,
- .broadcast_ctrl_reg = 0x0332,
- .multicast_ctrl_reg = 0x0331,
- .start_ctrl_reg = 0x0300,
.supports_mii = {false, false, false, false, true},
.supports_rmii = {false, false, false, false, true},
.supports_rgmii = {false, false, false, false, true},
@@ -557,9 +539,6 @@ const struct ksz_chip_data ksz_switch_chips[] = {
.mib_cnt = ARRAY_SIZE(ksz9477_mib_names),
.reg_mib_cnt = MIB_COUNTER_NUM,
.regs = ksz9477_regs,
- .broadcast_ctrl_reg = 0x0332,
- .multicast_ctrl_reg = 0x0331,
- .start_ctrl_reg = 0x0300,
.supports_mii = {false, false, false, false, true, true},
.supports_rmii = {false, false, false, false, true, true},
.supports_rgmii = {false, false, false, false, true, true},
@@ -578,9 +557,6 @@ const struct ksz_chip_data ksz_switch_chips[] = {
.mib_cnt = ARRAY_SIZE(ksz9477_mib_names),
.reg_mib_cnt = MIB_COUNTER_NUM,
.regs = ksz9477_regs,
- .broadcast_ctrl_reg = 0x0332,
- .multicast_ctrl_reg = 0x0331,
- .start_ctrl_reg = 0x0300,
.supports_mii = {false, false, false, false,
true, true, false, false},
.supports_rmii = {false, false, false, false,
@@ -603,9 +579,6 @@ const struct ksz_chip_data ksz_switch_chips[] = {
.mib_cnt = ARRAY_SIZE(ksz9477_mib_names),
.reg_mib_cnt = MIB_COUNTER_NUM,
.regs = ksz9477_regs,
- .broadcast_ctrl_reg = 0x0332,
- .multicast_ctrl_reg = 0x0331,
- .start_ctrl_reg = 0x0300,
.supports_mii = {false, false, false, false,
true, true, false, false},
.supports_rmii = {false, false, false, false,
@@ -628,9 +601,6 @@ const struct ksz_chip_data ksz_switch_chips[] = {
.mib_cnt = ARRAY_SIZE(ksz9477_mib_names),
.reg_mib_cnt = MIB_COUNTER_NUM,
.regs = ksz9477_regs,
- .broadcast_ctrl_reg = 0x0332,
- .multicast_ctrl_reg = 0x0331,
- .start_ctrl_reg = 0x0300,
.supports_mii = {false, false, false, false,
true, true, false, false},
.supports_rmii = {false, false, false, false,
@@ -830,8 +800,11 @@ static void ksz_update_port_member(struct ksz_device *dev, int port)
static int ksz_setup(struct dsa_switch *ds)
{
struct ksz_device *dev = ds->priv;
+ const u16 *regs;
int ret;
+ regs = dev->info->regs;
+
dev->vlan_cache = devm_kcalloc(dev->dev, sizeof(struct vlan_table),
dev->info->num_vlans, GFP_KERNEL);
if (!dev->vlan_cache)
@@ -844,7 +817,7 @@ static int ksz_setup(struct dsa_switch *ds)
}
/* set broadcast storm protection 10% rate */
- regmap_update_bits(dev->regmap[1], dev->info->broadcast_ctrl_reg,
+ regmap_update_bits(dev->regmap[1], regs[S_BROADCAST_CTRL],
BROADCAST_STORM_RATE,
(BROADCAST_STORM_VALUE *
BROADCAST_STORM_PROT_RATE) / 100);
@@ -853,7 +826,7 @@ static int ksz_setup(struct dsa_switch *ds)
dev->dev_ops->enable_stp_addr(dev);
- regmap_update_bits(dev->regmap[0], dev->info->multicast_ctrl_reg,
+ regmap_update_bits(dev->regmap[0], regs[S_MULTICAST_CTRL],
MULTICAST_STORM_DISABLE, MULTICAST_STORM_DISABLE);
ksz_init_mib_timer(dev);
@@ -867,7 +840,7 @@ static int ksz_setup(struct dsa_switch *ds)
}
/* start switch */
- regmap_update_bits(dev->regmap[0], dev->info->start_ctrl_reg,
+ regmap_update_bits(dev->regmap[0], regs[S_START_CTRL],
SW_START, SW_START);
return 0;
diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
index 2a9b2b59fa79..91fbb3b62536 100644
--- a/drivers/net/dsa/microchip/ksz_common.h
+++ b/drivers/net/dsa/microchip/ksz_common.h
@@ -165,6 +165,9 @@ enum ksz_regs {
P_SPEED_STATUS,
S_TAIL_TAG_CTRL,
P_STP_CTRL,
+ S_START_CTRL,
+ S_BROADCAST_CTRL,
+ S_MULTICAST_CTRL,
};
enum ksz_masks {
--
2.36.1
next prev parent reply other threads:[~2022-06-28 17:15 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-28 17:13 [Patch net-next 0/7] net: dsa: microchip: use ksz_chip_reg for Arun Ramadoss
2022-06-28 17:13 ` [Patch net-next 1/7] net: dsa: microchip: move ksz8->regs to ksz_common Arun Ramadoss
2022-06-28 17:13 ` [Patch net-next 2/7] net: dsa: microchip: move ksz8->masks " Arun Ramadoss
2022-06-28 17:13 ` [Patch net-next 3/7] net: dsa: microchip: move ksz8->shifts " Arun Ramadoss
2022-06-28 17:13 ` [Patch net-next 4/7] net: dsa: microchip: remove the struct ksz8 Arun Ramadoss
2022-06-28 17:13 ` [Patch net-next 5/7] net: dsa: microchip: change the size of reg from u8 to u16 Arun Ramadoss
2022-06-28 17:13 ` [Patch net-next 6/7] net: dsa: microchip: add P_STP_CTRL to ksz_chip_reg Arun Ramadoss
2022-06-28 17:13 ` Arun Ramadoss [this message]
2022-06-29 13:00 ` [Patch net-next 0/7] net: dsa: microchip: use ksz_chip_reg for patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220628171329.25503-8-arun.ramadoss@microchip.com \
--to=arun.ramadoss@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=vivien.didelot@gmail.com \
--cc=woojung.huh@microchip.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®