net: dsa: microchip: use ksz_chip_reg for
cover net: dsa: microchip: use ksz_chip_reg for
This patch series tries to use the same approach as struct ksz8 for register which has different address for different switch family. It moves the struct ksz8 from ksz8.h to struct ksz_chip_reg. Based on the switch detect, the corresponding mask, reg and shifts are assigned.
Arun Ramadoss (7):
net: dsa: microchip: move ksz8->regs to ksz_common
net: dsa: microchip: move ksz8->masks to ksz_common
net: dsa: microchip: move ksz8->shifts to ksz_common
net: dsa: microchip: remove the struct ksz8
net: dsa: microchip: change the size of reg from u8 to u16
net: dsa: microchip: add P_STP_CTRL to ksz_chip_reg
net: dsa: microchip: move remaining register offset to ksz_chip_reg
drivers/net/dsa/microchip/ksz8.h | 58 ------- drivers/net/dsa/microchip/ksz8795.c | 221 ++++++------------------ drivers/net/dsa/microchip/ksz8795_reg.h | 1 - drivers/net/dsa/microchip/ksz8863_smi.c | 17 +- drivers/net/dsa/microchip/ksz9477.c | 7 +- drivers/net/dsa/microchip/ksz9477_reg.h | 6 - drivers/net/dsa/microchip/ksz_common.c | 206 +++++++++++++++------- drivers/net/dsa/microchip/ksz_common.h | 58 +++++++ drivers/net/dsa/microchip/ksz_spi.c | 10 +- 9 files changed, 267 insertions(+), 317 deletions(-)
base-commit: d521bc0a0f7cdd56b646e6283d5f7296eb16793d
Signature · 1 line
2.36.1
PATCH 1/7 net: dsa: microchip: move ksz8->regs to ksz_common
This patch moves the ksz8->regs from ksz8795.c to the ksz_common.c. And the regs is dereferrenced using dev->info->regs.
--- drivers/net/dsa/microchip/ksz8.h | 18 ------ drivers/net/dsa/microchip/ksz8795.c | 76 ++++++++----------------- drivers/net/dsa/microchip/ksz9477_reg.h | 3 - drivers/net/dsa/microchip/ksz_common.c | 37 ++++++++++++ drivers/net/dsa/microchip/ksz_common.h | 18 ++++++ 5 files changed, 79 insertions(+), 73 deletions(-)
drivers/net/dsa/microchip/ksz8.h +0 -18
@@ -12,23 +12,6 @@#include <net/dsa.h> #include "ksz_common.h" -enum ksz_regs { -REG_IND_CTRL_0 , -REG_IND_DATA_8 , -REG_IND_DATA_CHECK , -REG_IND_DATA_HI , -REG_IND_DATA_LO , -REG_IND_MIB_CHECK , -REG_IND_BYTE , -P_FORCE_CTRL , -P_LINK_STATUS , -P_LOCAL_CTRL , -P_NEG_RESTART_CTRL , -P_REMOTE_STATUS , -P_SPEED_STATUS , -S_TAIL_TAG_CTRL , -}; -enum ksz_masks {PORT_802_1P_REMAPPING ,SW_TAIL_TAG_ENABLE ,
@@ -64,7 +47,6 @@ enum ksz_shifts { };struct ksz8 { -const u8 *regs;const u32 *masks;const u8 *shifts;void *priv;
drivers/net/dsa/microchip/ksz8795.c +24 -52
190 lines not on this page · raw message
drivers/net/dsa/microchip/ksz9477_reg.h +0 -3
@@ -1624,9 +1624,6 @@#define P_MIRROR_CTRL REG_PORT_MRI_MIRROR_CTRL#define P_STP_CTRL REG_PORT_LUE_MSTP_STATE#define P_PHY_CTRL REG_PORT_PHY_CTRL -#define P_NEG_RESTART_CTRL REG_PORT_PHY_CTRL -#define P_LINK_STATUS REG_PORT_PHY_STATUS -#define P_SPEED_STATUS REG_PORT_PHY_PHY_CTRL#define P_RATE_LIMIT_CTRL REG_PORT_MAC_IN_RATE_LIMIT#define S_LINK_AGING_CTRL REG_SW_LUE_CTRL_1
drivers/net/dsa/microchip/ksz_common.c +37 -0
@@ -201,6 +201,39 @@ static const struct ksz_dev_ops ksz9477_dev_ops = { .exit = ksz9477_switch_exit, }; +static const u8 ksz8795_regs[] = { + [REG_IND_CTRL_0 ] =0x6E , + [REG_IND_DATA_8 ] =0x70 , + [REG_IND_DATA_CHECK ] =0x72 , + [REG_IND_DATA_HI ] =0x71 , + [REG_IND_DATA_LO ] =0x75 , + [REG_IND_MIB_CHECK ] =0x74 , + [REG_IND_BYTE ] =0xA0 , + [P_FORCE_CTRL ] =0x0C , + [P_LINK_STATUS ] =0x0E , + [P_LOCAL_CTRL ] =0x07 , + [P_NEG_RESTART_CTRL ] =0x0D , + [P_REMOTE_STATUS ] =0x08 , + [P_SPEED_STATUS ] =0x09 , + [S_TAIL_TAG_CTRL ] =0x0C , +}; + +static const u8 ksz8863_regs[] = { + [REG_IND_CTRL_0 ] =0x79 , + [REG_IND_DATA_8 ] =0x7B , + [REG_IND_DATA_CHECK ] =0x7B , + [REG_IND_DATA_HI ] =0x7C , + [REG_IND_DATA_LO ] =0x80 , + [REG_IND_MIB_CHECK ] =0x80 , + [P_FORCE_CTRL ] =0x0C , + [P_LINK_STATUS ] =0x0E , + [P_LOCAL_CTRL ] =0x0C , + [P_NEG_RESTART_CTRL ] =0x0D , + [P_REMOTE_STATUS ] =0x0E , + [P_SPEED_STATUS ] =0x0F , + [S_TAIL_TAG_CTRL ] =0x03 , +}; +const struct ksz_chip_data ksz_switch_chips[] = { [KSZ8795 ] = { .chip_id =KSZ8795_CHIP_ID ,
@@ -215,6 +248,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_names = ksz9477_mib_names, .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, + .regs = ksz8795_regs, .stp_ctrl_reg = 0x02, .broadcast_ctrl_reg = 0x06, .multicast_ctrl_reg = 0x04,
@@ -252,6 +286,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_names = ksz9477_mib_names, .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, + .regs = ksz8795_regs, .stp_ctrl_reg = 0x02, .broadcast_ctrl_reg = 0x06, .multicast_ctrl_reg = 0x04,
@@ -275,6 +310,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_names = ksz9477_mib_names, .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, + .regs = ksz8795_regs, .stp_ctrl_reg = 0x02, .broadcast_ctrl_reg = 0x06, .multicast_ctrl_reg = 0x04,
@@ -297,6 +333,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_names = ksz88xx_mib_names, .mib_cnt = ARRAY_SIZE(ksz88xx_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, + .regs = ksz8863_regs, .stp_ctrl_reg = 0x02, .broadcast_ctrl_reg = 0x06, .multicast_ctrl_reg = 0x04,
drivers/net/dsa/microchip/ksz_common.h +18 -0
@@ -47,6 +47,7 @@ struct ksz_chip_data {const struct ksz_mib_names *mib_names;int mib_cnt;u8 reg_mib_cnt; +const u8 *regs;int stp_ctrl_reg;int broadcast_ctrl_reg;int multicast_ctrl_reg;
@@ -146,6 +147,23 @@ enum ksz_chip_id { LAN9374_CHIP_ID = 0x00937400, }; +enum ksz_regs { +REG_IND_CTRL_0 , +REG_IND_DATA_8 , +REG_IND_DATA_CHECK , +REG_IND_DATA_HI , +REG_IND_DATA_LO , +REG_IND_MIB_CHECK , +REG_IND_BYTE , +P_FORCE_CTRL , +P_LINK_STATUS , +P_LOCAL_CTRL , +P_NEG_RESTART_CTRL , +P_REMOTE_STATUS , +P_SPEED_STATUS , +S_TAIL_TAG_CTRL , +}; +struct alu_struct {/* entry 1 */ u8 is_static:1 ;
Signature · 1 line
2.36.1
PATCH 2/7 net: dsa: microchip: move ksz8->masks to ksz_common
In reply to Arun RamadossThis patch moves the ksz8->masks from ksz8795.c to ksz_common.c. The mask will be dereferenced using dev->info->masks.
--- drivers/net/dsa/microchip/ksz8.h | 23 -------- drivers/net/dsa/microchip/ksz8795.c | 71 ++++--------------------- drivers/net/dsa/microchip/ksz9477_reg.h | 2 - drivers/net/dsa/microchip/ksz_common.c | 48 +++++++++++++++++ drivers/net/dsa/microchip/ksz_common.h | 23 ++++++++ 5 files changed, 81 insertions(+), 86 deletions(-)
drivers/net/dsa/microchip/ksz8.h +0 -23
@@ -12,28 +12,6 @@#include <net/dsa.h> #include "ksz_common.h" -enum ksz_masks { -PORT_802_1P_REMAPPING , -SW_TAIL_TAG_ENABLE , -MIB_COUNTER_OVERFLOW , -MIB_COUNTER_VALID , -VLAN_TABLE_FID , -VLAN_TABLE_MEMBERSHIP , -VLAN_TABLE_VALID , -STATIC_MAC_TABLE_VALID , -STATIC_MAC_TABLE_USE_FID , -STATIC_MAC_TABLE_FID , -STATIC_MAC_TABLE_OVERRIDE , -STATIC_MAC_TABLE_FWD_PORTS , -DYNAMIC_MAC_TABLE_ENTRIES_H , -DYNAMIC_MAC_TABLE_MAC_EMPTY , -DYNAMIC_MAC_TABLE_NOT_READY , -DYNAMIC_MAC_TABLE_ENTRIES , -DYNAMIC_MAC_TABLE_FID , -DYNAMIC_MAC_TABLE_SRC_PORT , -DYNAMIC_MAC_TABLE_TIMESTAMP , -}; -enum ksz_shifts {VLAN_TABLE_MEMBERSHIP_S ,VLAN_TABLE ,
@@ -47,7 +25,6 @@ enum ksz_shifts { };struct ksz8 { -const u32 *masks;const u8 *shifts;void *priv; };
drivers/net/dsa/microchip/ksz8795.c +10 -61
176 lines not on this page · raw message
drivers/net/dsa/microchip/ksz9477_reg.h +0 -2
@@ -1262,8 +1262,6 @@/* 5 - MIB Counters */ #define REG_PORT_MIB_CTRL_STAT__4 0x0500 -#define MIB_COUNTER_OVERFLOW BIT(31) -#define MIB_COUNTER_VALID BIT(30)#define MIB_COUNTER_READ BIT(25)#define MIB_COUNTER_FLUSH_FREEZE BIT(24)#define MIB_COUNTER_INDEX_M (BIT(8) - 1)
drivers/net/dsa/microchip/ksz_common.c +48 -0
84 lines not on this page · raw message
drivers/net/dsa/microchip/ksz_common.h +23 -0
@@ -48,6 +48,7 @@ struct ksz_chip_data {int mib_cnt;u8 reg_mib_cnt;const u8 *regs; +const u32 *masks;int stp_ctrl_reg;int broadcast_ctrl_reg;int multicast_ctrl_reg;
@@ -164,6 +165,28 @@ enum ksz_regs { S_TAIL_TAG_CTRL, }; +enum ksz_masks { +PORT_802_1P_REMAPPING , +SW_TAIL_TAG_ENABLE , +MIB_COUNTER_OVERFLOW , +MIB_COUNTER_VALID , +VLAN_TABLE_FID , +VLAN_TABLE_MEMBERSHIP , +VLAN_TABLE_VALID , +STATIC_MAC_TABLE_VALID , +STATIC_MAC_TABLE_USE_FID , +STATIC_MAC_TABLE_FID , +STATIC_MAC_TABLE_OVERRIDE , +STATIC_MAC_TABLE_FWD_PORTS , +DYNAMIC_MAC_TABLE_ENTRIES_H , +DYNAMIC_MAC_TABLE_MAC_EMPTY , +DYNAMIC_MAC_TABLE_NOT_READY , +DYNAMIC_MAC_TABLE_ENTRIES , +DYNAMIC_MAC_TABLE_FID , +DYNAMIC_MAC_TABLE_SRC_PORT , +DYNAMIC_MAC_TABLE_TIMESTAMP , +}; +struct alu_struct {/* entry 1 */ u8 is_static:1 ;
Signature · 1 line
2.36.1
PATCH 3/7 net: dsa: microchip: move ksz8->shifts to ksz_common
In reply to Arun RamadossThis patch moves ksz8->shifts from ksz8795.c to ksz_common.c. The shifts are dereferenced using dev->info->shifts.
--- drivers/net/dsa/microchip/ksz8.h | 13 ------- drivers/net/dsa/microchip/ksz8795.c | 49 ++++---------------------- drivers/net/dsa/microchip/ksz_common.c | 27 ++++++++++++++ drivers/net/dsa/microchip/ksz_common.h | 13 +++++++ 4 files changed, 46 insertions(+), 56 deletions(-)
drivers/net/dsa/microchip/ksz8.h +0 -13
@@ -12,20 +12,7 @@#include <net/dsa.h> #include "ksz_common.h" -enum ksz_shifts { -VLAN_TABLE_MEMBERSHIP_S , -VLAN_TABLE , -STATIC_MAC_FWD_PORTS , -STATIC_MAC_FID , -DYNAMIC_MAC_ENTRIES_H , -DYNAMIC_MAC_ENTRIES , -DYNAMIC_MAC_FID , -DYNAMIC_MAC_TIMESTAMP , -DYNAMIC_MAC_SRC_PORT , -}; -struct ksz8 { -const u8 *shifts;void *priv; };
drivers/net/dsa/microchip/ksz8795.c +6 -43
127 lines not on this page · raw message
drivers/net/dsa/microchip/ksz_common.c +27 -0
@@ -240,6 +240,18 @@ static const u32 ksz8795_masks[] = { [DYNAMIC_MAC_TABLE_TIMESTAMP] = GENMASK(28, 27), }; +static const u8 ksz8795_shifts[] = { + [VLAN_TABLE_MEMBERSHIP_S ] =7 , + [VLAN_TABLE ] =16 , + [STATIC_MAC_FWD_PORTS ] =16 , + [STATIC_MAC_FID ] =24 , + [DYNAMIC_MAC_ENTRIES_H ] =3 , + [DYNAMIC_MAC_ENTRIES ] =29 , + [DYNAMIC_MAC_FID ] =16 , + [DYNAMIC_MAC_TIMESTAMP ] =27 , + [DYNAMIC_MAC_SRC_PORT ] =24 , +}; +static const u8 ksz8863_regs[] = { [REG_IND_CTRL_0 ] =0x79 , [REG_IND_DATA_8 ] =0x7B ,
@@ -278,6 +290,17 @@ static const u32 ksz8863_masks[] = { [DYNAMIC_MAC_TABLE_TIMESTAMP] = GENMASK(23, 22), }; +static u8 ksz8863_shifts[] = { + [VLAN_TABLE_MEMBERSHIP_S ] =16 , + [STATIC_MAC_FWD_PORTS ] =16 , + [STATIC_MAC_FID ] =22 , + [DYNAMIC_MAC_ENTRIES_H ] =3 , + [DYNAMIC_MAC_ENTRIES ] =24 , + [DYNAMIC_MAC_FID ] =16 , + [DYNAMIC_MAC_TIMESTAMP ] =24 , + [DYNAMIC_MAC_SRC_PORT ] =20 , +}; +const struct ksz_chip_data ksz_switch_chips[] = { [KSZ8795 ] = { .chip_id =KSZ8795_CHIP_ID ,
@@ -294,6 +317,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .reg_mib_cnt = MIB_COUNTER_NUM, .regs = ksz8795_regs, .masks = ksz8795_masks, + .shifts = ksz8795_shifts, .stp_ctrl_reg = 0x02, .broadcast_ctrl_reg = 0x06, .multicast_ctrl_reg = 0x04,
@@ -333,6 +357,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .reg_mib_cnt = MIB_COUNTER_NUM, .regs = ksz8795_regs, .masks = ksz8795_masks, + .shifts = ksz8795_shifts, .stp_ctrl_reg = 0x02, .broadcast_ctrl_reg = 0x06, .multicast_ctrl_reg = 0x04,
@@ -358,6 +383,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .reg_mib_cnt = MIB_COUNTER_NUM, .regs = ksz8795_regs, .masks = ksz8795_masks, + .shifts = ksz8795_shifts, .stp_ctrl_reg = 0x02, .broadcast_ctrl_reg = 0x06, .multicast_ctrl_reg = 0x04,
@@ -382,6 +408,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .reg_mib_cnt = MIB_COUNTER_NUM, .regs = ksz8863_regs, .masks = ksz8863_masks, + .shifts = ksz8863_shifts, .stp_ctrl_reg = 0x02, .broadcast_ctrl_reg = 0x06, .multicast_ctrl_reg = 0x04,
drivers/net/dsa/microchip/ksz_common.h +13 -0
@@ -49,6 +49,7 @@ struct ksz_chip_data {u8 reg_mib_cnt;const u8 *regs;const u32 *masks; +const u8 *shifts;int stp_ctrl_reg;int broadcast_ctrl_reg;int multicast_ctrl_reg;
@@ -187,6 +188,18 @@ enum ksz_masks { DYNAMIC_MAC_TABLE_TIMESTAMP, }; +enum ksz_shifts { +VLAN_TABLE_MEMBERSHIP_S , +VLAN_TABLE , +STATIC_MAC_FWD_PORTS , +STATIC_MAC_FID , +DYNAMIC_MAC_ENTRIES_H , +DYNAMIC_MAC_ENTRIES , +DYNAMIC_MAC_FID , +DYNAMIC_MAC_TIMESTAMP , +DYNAMIC_MAC_SRC_PORT , +}; +struct alu_struct {/* entry 1 */ u8 is_static:1 ;
Signature · 1 line
2.36.1
PATCH 4/7 net: dsa: microchip: remove the struct ksz8
In reply to Arun RamadossThis patch removes the struct ksz8 from ksz8.h which is no longer needed. The platform bus specific details are now deferenced through dev->priv.
--- drivers/net/dsa/microchip/ksz8.h | 4 ---- drivers/net/dsa/microchip/ksz8863_smi.c | 17 +++-------------- drivers/net/dsa/microchip/ksz_spi.c | 10 +--------- 3 files changed, 4 insertions(+), 27 deletions(-)
drivers/net/dsa/microchip/ksz8.h +0 -4
@@ -12,10 +12,6 @@#include <net/dsa.h> #include "ksz_common.h" -struct ksz8 { -void *priv; -}; -int ksz8_setup (struct dsa_switch *ds);u32 ksz8_get_port_addr (int port,int offset);void ksz8_cfg_port_member (struct ksz_device *dev,int port,u8 member);
drivers/net/dsa/microchip/ksz8863_smi.c +3 -14
@@ -26,11 +26,9 @@ static int ksz8863_mdio_read(void *ctx, const void *reg_buf, size_t reg_len,struct mdio_device *mdev;u8 reg = *(u8 *)reg_buf;u8 *val = val_buf; -struct ksz8 *ksz8;int i, ret =0 ; - ksz8 = dev->priv; - mdev = ksz8->priv; + mdev = dev->priv;mutex_lock_nested (&mdev->bus->mdio_lock,MDIO_MUTEX_NESTED );for (i =0 ; i < val_len; i++) {
@@ -55,13 +53,11 @@ static int ksz8863_mdio_write(void *ctx, const void *data, size_t count) {struct ksz_device *dev = ctx;struct mdio_device *mdev; -struct ksz8 *ksz8;int i, ret =0 ;u32 reg;u8 *val; - ksz8 = dev->priv; - mdev = ksz8->priv; + mdev = dev->priv; val = (u8 *)(data +4 ); reg = *(u32 *)data;
@@ -142,17 +138,10 @@ static int ksz8863_smi_probe(struct mdio_device *mdiodev) {struct regmap_config rc;struct ksz_device *dev; -struct ksz8 *ksz8;int ret;int i; - ksz8 =devm_kzalloc (&mdiodev->dev,sizeof (struct ksz8 ),GFP_KERNEL ); -if (!ksz8) -return -ENOMEM ; - - ksz8->priv = mdiodev; - - dev =ksz_switch_alloc (&mdiodev->dev, ksz8); + dev =ksz_switch_alloc (&mdiodev->dev, mdiodev);if (!dev)return -ENOMEM ;
drivers/net/dsa/microchip/ksz_spi.c +1 -9
@@ -14,7 +14,6 @@#include <linux/regmap.h> #include <linux/spi/spi.h> -#include "ksz8.h" #include "ksz_common.h" #define KSZ8795_SPI_ADDR_SHIFT 12
@@ -45,16 +44,9 @@ static int ksz_spi_probe(struct spi_device *spi)struct device *ddev = &spi->dev;struct regmap_config rc;struct ksz_device *dev; -struct ksz8 *ksz8;int i, ret =0 ; - ksz8 =devm_kzalloc (&spi->dev,sizeof (struct ksz8 ),GFP_KERNEL ); -if (!ksz8) -return -ENOMEM ; - - ksz8->priv = spi; - - dev =ksz_switch_alloc (&spi->dev, ksz8); + dev =ksz_switch_alloc (&spi->dev, spi);if (!dev)return -ENOMEM ;
Signature · 1 line
2.36.1
PATCH 5/7 net: dsa: microchip: change the size of reg from u8 to u16
In reply to Arun RamadossThe register size for the ksz8 switches is u8 and for ksz9477 series is u16. To have common struct for ksz series switches the size of reg is increased from u8 to u16.
--- drivers/net/dsa/microchip/ksz8795.c | 22 +++++++++++----------- drivers/net/dsa/microchip/ksz_common.c | 4 ++-- drivers/net/dsa/microchip/ksz_common.h | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-)
drivers/net/dsa/microchip/ksz8795.c +11 -11
@@ -45,7 +45,7 @@ static void ksz_port_cfg(struct ksz_device *dev, int port, int offset, u8 bits,static int ksz8_ind_write8 (struct ksz_device *dev,u8 table,u16 addr,u8 data) { -const u8 *regs; +const u16 *regs;u16 ctrl_addr;int ret =0 ;
@@ -117,7 +117,7 @@ static void ksz8795_set_prio_queue(struct ksz_device *dev, int port, int queue)void ksz8_r_mib_cnt (struct ksz_device *dev,int port,u16 addr,u64 *cnt) {const u32 *masks; -const u8 *regs; +const u16 *regs;u16 ctrl_addr;u32 data;u8 check;
@@ -153,7 +153,7 @@ static void ksz8795_r_mib_pkt(struct ksz_device *dev, int port, u16 addr, u64 *dropped, u64 *cnt) {const u32 *masks; -const u8 *regs; +const u16 *regs;u16 ctrl_addr;u32 data;u8 check;
@@ -205,7 +205,7 @@ static void ksz8863_r_mib_pkt(struct ksz_device *dev, int port, u16 addr, u64 *dropped, u64 *cnt) {u32 *last = (u32 *)dropped; -const u8 *regs; +const u16 *regs;u16 ctrl_addr;u32 data;u32 cur;
@@ -292,7 +292,7 @@ void ksz8_port_init_cnt(struct ksz_device *dev, int port)static void ksz8_r_table (struct ksz_device *dev,int table,u16 addr,u64 *data) { -const u8 *regs; +const u16 *regs;u16 ctrl_addr; regs = dev->info->regs;
@@ -307,7 +307,7 @@ static void ksz8_r_table(struct ksz_device *dev, int table, u16 addr, u64 *data)static void ksz8_w_table (struct ksz_device *dev,int table,u16 addr,u64 data) { -const u8 *regs; +const u16 *regs;u16 ctrl_addr; regs = dev->info->regs;
@@ -324,7 +324,7 @@ static int ksz8_valid_dyn_entry(struct ksz_device *dev, u8 *data) {int timeout =100 ;const u32 *masks; -const u8 *regs; +const u16 *regs; masks = dev->info->masks; regs = dev->info->regs;
@@ -354,7 +354,7 @@ int ksz8_r_dyn_mac_table(struct ksz_device *dev, u16 addr, u8 *mac_addr,u32 data_hi, data_lo;const u8 *shifts;const u32 *masks; -const u8 *regs; +const u16 *regs;u16 ctrl_addr;u8 data;int rc;
@@ -561,7 +561,7 @@ void ksz8_r_phy(struct ksz_device *dev, u16 phy, u16 reg, u16 *val) {u8 restart, speed, ctrl, link;int processed = true; -const u8 *regs; +const u16 *regs;u8 val1, val2;u16 data =0 ;u8 p = phy;
@@ -684,7 +684,7 @@ void ksz8_r_phy(struct ksz_device *dev, u16 phy, u16 reg, u16 *val)void ksz8_w_phy (struct ksz_device *dev,u16 phy,u16 reg,u16 val) {u8 restart, speed, ctrl, data; -const u8 *regs; +const u16 *regs;u8 p = phy; regs = dev->info->regs;
@@ -1199,7 +1199,7 @@ void ksz8_config_cpu_port(struct dsa_switch *ds)struct ksz_device *dev = ds->priv;struct ksz_port *p;const u32 *masks; -const u8 *regs; +const u16 *regs;u8 remote;int i;
drivers/net/dsa/microchip/ksz_common.c +2 -2
@@ -201,7 +201,7 @@ static const struct ksz_dev_ops ksz9477_dev_ops = { .exit = ksz9477_switch_exit, }; -static const u8 ksz8795_regs[] = { +static const u16 ksz8795_regs[] = { [REG_IND_CTRL_0 ] =0x6E , [REG_IND_DATA_8 ] =0x70 , [REG_IND_DATA_CHECK ] =0x72 ,
@@ -252,7 +252,7 @@ static const u8 ksz8795_shifts[] = { [DYNAMIC_MAC_SRC_PORT] = 24, }; -static const u8 ksz8863_regs[] = { +static const u16 ksz8863_regs[] = { [REG_IND_CTRL_0 ] =0x79 , [REG_IND_DATA_8 ] =0x7B , [REG_IND_DATA_CHECK ] =0x7B ,
drivers/net/dsa/microchip/ksz_common.h +1 -1
@@ -47,7 +47,7 @@ struct ksz_chip_data {const struct ksz_mib_names *mib_names;int mib_cnt;u8 reg_mib_cnt; -const u8 *regs; +const u16 *regs;const u32 *masks;const u8 *shifts;int stp_ctrl_reg;
Signature · 1 line
2.36.1
PATCH 6/7 net: dsa: microchip: add P_STP_CTRL to ksz_chip_reg
In reply to Arun RamadossThis patch moves the stp_ctrl_reg from the ksz_chip_data to ksz_chip_reg structure.
--- drivers/net/dsa/microchip/ksz8795.c | 17 +++++++----- drivers/net/dsa/microchip/ksz8795_reg.h | 1 - drivers/net/dsa/microchip/ksz9477.c | 7 +++-- drivers/net/dsa/microchip/ksz9477_reg.h | 1 - drivers/net/dsa/microchip/ksz_common.c | 37 +++++++++++++------------ drivers/net/dsa/microchip/ksz_common.h | 1 + 6 files changed, 35 insertions(+), 29 deletions(-)
drivers/net/dsa/microchip/ksz8795.c +10 -7
@@ -809,6 +809,9 @@ void ksz8_flush_dyn_mac_table(struct ksz_device *dev, int port)u8 learn[DSA_MAX_PORTS ];int first, index, cnt;struct ksz_port *p; +const u16 *regs; + + regs = dev->info->regs;if ((uint )port < dev->info->port_cnt) { first = port;
@@ -822,9 +825,9 @@ void ksz8_flush_dyn_mac_table(struct ksz_device *dev, int port) p = &dev->ports[index];if (!p->on)continue ; -ksz_pread8 (dev, index,P_STP_CTRL , &learn[index]); +ksz_pread8 (dev, index, regs[P_STP_CTRL ], &learn[index]);if (!(learn[index] &PORT_LEARN_DISABLE )) -ksz_pwrite8 (dev, index,P_STP_CTRL , +ksz_pwrite8 (dev, index, regs[P_STP_CTRL ], learn[index] |PORT_LEARN_DISABLE ); }ksz_cfg (dev,S_FLUSH_TABLE_CTRL ,SW_FLUSH_DYN_MAC_TABLE , true);
@@ -833,7 +836,7 @@ void ksz8_flush_dyn_mac_table(struct ksz_device *dev, int port)if (!p->on)continue ;if (!(learn[index] &PORT_LEARN_DISABLE )) -ksz_pwrite8 (dev, index,P_STP_CTRL , learn[index]); +ksz_pwrite8 (dev, index, regs[P_STP_CTRL ], learn[index]); } }
@@ -1236,11 +1239,11 @@ void ksz8_config_cpu_port(struct dsa_switch *ds) p->fiber =1 ; }if (p->fiber) -ksz_port_cfg (dev, i,P_STP_CTRL ,PORT_FORCE_FLOW_CTRL , - true); +ksz_port_cfg (dev, i, regs[P_STP_CTRL ], +PORT_FORCE_FLOW_CTRL , true);else -ksz_port_cfg (dev, i,P_STP_CTRL ,PORT_FORCE_FLOW_CTRL , - false); +ksz_port_cfg (dev, i, regs[P_STP_CTRL ], +PORT_FORCE_FLOW_CTRL , false); } }
drivers/net/dsa/microchip/ksz8795_reg.h +0 -1
@@ -766,7 +766,6 @@#define P_TAG_CTRL REG_PORT_CTRL_0#define P_MIRROR_CTRL REG_PORT_CTRL_1#define P_802_1P_CTRL REG_PORT_CTRL_2 -#define P_STP_CTRL REG_PORT_CTRL_2#define P_PASS_ALL_CTRL REG_PORT_CTRL_12#define P_INS_SRC_PVID_CTRL REG_PORT_CTRL_12#define P_DROP_TAG_CTRL REG_PORT_CTRL_13
drivers/net/dsa/microchip/ksz9477.c +4 -3
@@ -338,6 +338,7 @@ void ksz9477_cfg_port_member(struct ksz_device *dev, int port, u8 member)void ksz9477_flush_dyn_mac_table (struct ksz_device *dev,int port) { +const u16 *regs = dev->info->regs;u8 data; regmap_update_bits(dev->regmap[0], REG_SW_LUE_CTRL_2,
@@ -346,12 +347,12 @@ void ksz9477_flush_dyn_mac_table(struct ksz_device *dev, int port)if (port < dev->info->port_cnt) {/* flush individual port */ -ksz_pread8 (dev, port,P_STP_CTRL , &data); +ksz_pread8 (dev, port, regs[P_STP_CTRL ], &data);if (!(data &PORT_LEARN_DISABLE )) -ksz_pwrite8 (dev, port,P_STP_CTRL , +ksz_pwrite8 (dev, port, regs[P_STP_CTRL ], data |PORT_LEARN_DISABLE );ksz_cfg (dev,S_FLUSH_TABLE_CTRL ,SW_FLUSH_DYN_MAC_TABLE , true); -ksz_pwrite8 (dev, port,P_STP_CTRL , data); +ksz_pwrite8 (dev, port, regs[P_STP_CTRL ], data); }else {/* flush all */ ksz_cfg (dev,S_FLUSH_TABLE_CTRL ,SW_FLUSH_STP_TABLE , true);
drivers/net/dsa/microchip/ksz9477_reg.h +0 -1
@@ -1620,7 +1620,6 @@#define P_BCAST_STORM_CTRL REG_PORT_MAC_CTRL_0#define P_PRIO_CTRL REG_PORT_MRI_PRIO_CTRL#define P_MIRROR_CTRL REG_PORT_MRI_MIRROR_CTRL -#define P_STP_CTRL REG_PORT_LUE_MSTP_STATE#define P_PHY_CTRL REG_PORT_PHY_CTRL#define P_RATE_LIMIT_CTRL REG_PORT_MAC_IN_RATE_LIMIT
drivers/net/dsa/microchip/ksz_common.c +20 -17
@@ -216,6 +216,7 @@ static const u16 ksz8795_regs[] = { [P_REMOTE_STATUS] = 0x08, [P_SPEED_STATUS] = 0x09, [S_TAIL_TAG_CTRL] = 0x0C, + [P_STP_CTRL] = 0x02, };static const u32 ksz8795_masks[] = {
@@ -266,6 +267,7 @@ static const u16 ksz8863_regs[] = { [P_REMOTE_STATUS] = 0x0E, [P_SPEED_STATUS] = 0x0F, [S_TAIL_TAG_CTRL] = 0x03, + [P_STP_CTRL] = 0x02, };static const u32 ksz8863_masks[] = {
@@ -301,6 +303,11 @@ static u8 ksz8863_shifts[] = { [DYNAMIC_MAC_SRC_PORT] = 20, }; +static const u16 ksz9477_regs[] = { + [P_STP_CTRL ] =0x0B04 , + +}; +const struct ksz_chip_data ksz_switch_chips[] = { [KSZ8795 ] = { .chip_id =KSZ8795_CHIP_ID ,
@@ -318,7 +325,6 @@ const struct ksz_chip_data ksz_switch_chips[] = { .regs = ksz8795_regs, .masks = ksz8795_masks, .shifts = ksz8795_shifts, - .stp_ctrl_reg = 0x02, .broadcast_ctrl_reg = 0x06, .multicast_ctrl_reg = 0x04, .start_ctrl_reg = 0x01,
@@ -358,7 +364,6 @@ const struct ksz_chip_data ksz_switch_chips[] = { .regs = ksz8795_regs, .masks = ksz8795_masks, .shifts = ksz8795_shifts, - .stp_ctrl_reg = 0x02, .broadcast_ctrl_reg = 0x06, .multicast_ctrl_reg = 0x04, .start_ctrl_reg = 0x01,
@@ -384,7 +389,6 @@ const struct ksz_chip_data ksz_switch_chips[] = { .regs = ksz8795_regs, .masks = ksz8795_masks, .shifts = ksz8795_shifts, - .stp_ctrl_reg = 0x02, .broadcast_ctrl_reg = 0x06, .multicast_ctrl_reg = 0x04, .start_ctrl_reg = 0x01,
@@ -409,7 +413,6 @@ const struct ksz_chip_data ksz_switch_chips[] = { .regs = ksz8863_regs, .masks = ksz8863_masks, .shifts = ksz8863_shifts, - .stp_ctrl_reg = 0x02, .broadcast_ctrl_reg = 0x06, .multicast_ctrl_reg = 0x04, .start_ctrl_reg = 0x01,
@@ -431,7 +434,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_names = ksz9477_mib_names, .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, - .stp_ctrl_reg = 0x0B04, + .regs = ksz9477_regs, .broadcast_ctrl_reg = 0x0332, .multicast_ctrl_reg = 0x0331, .start_ctrl_reg = 0x0300,
@@ -458,7 +461,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_names = ksz9477_mib_names, .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, - .stp_ctrl_reg = 0x0B04, + .regs = ksz9477_regs, .broadcast_ctrl_reg = 0x0332, .multicast_ctrl_reg = 0x0331, .start_ctrl_reg = 0x0300,
@@ -484,7 +487,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_names = ksz9477_mib_names, .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, - .stp_ctrl_reg = 0x0B04, + .regs = ksz9477_regs, .broadcast_ctrl_reg = 0x0332, .multicast_ctrl_reg = 0x0331, .start_ctrl_reg = 0x0300,
@@ -507,7 +510,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_names = ksz9477_mib_names, .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, - .stp_ctrl_reg = 0x0B04, + .regs = ksz9477_regs, .broadcast_ctrl_reg = 0x0332, .multicast_ctrl_reg = 0x0331, .start_ctrl_reg = 0x0300,
@@ -532,7 +535,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_names = ksz9477_mib_names, .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, - .stp_ctrl_reg = 0x0B04, + .regs = ksz9477_regs, .broadcast_ctrl_reg = 0x0332, .multicast_ctrl_reg = 0x0331, .start_ctrl_reg = 0x0300,
@@ -553,7 +556,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_names = ksz9477_mib_names, .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, - .stp_ctrl_reg = 0x0B04, + .regs = ksz9477_regs, .broadcast_ctrl_reg = 0x0332, .multicast_ctrl_reg = 0x0331, .start_ctrl_reg = 0x0300,
@@ -574,7 +577,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_names = ksz9477_mib_names, .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, - .stp_ctrl_reg = 0x0B04, + .regs = ksz9477_regs, .broadcast_ctrl_reg = 0x0332, .multicast_ctrl_reg = 0x0331, .start_ctrl_reg = 0x0300,
@@ -599,7 +602,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_names = ksz9477_mib_names, .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, - .stp_ctrl_reg = 0x0B04, + .regs = ksz9477_regs, .broadcast_ctrl_reg = 0x0332, .multicast_ctrl_reg = 0x0331, .start_ctrl_reg = 0x0300,
@@ -624,7 +627,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .mib_names = ksz9477_mib_names, .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), .reg_mib_cnt = MIB_COUNTER_NUM, - .stp_ctrl_reg = 0x0B04, + .regs = ksz9477_regs, .broadcast_ctrl_reg = 0x0332, .multicast_ctrl_reg = 0x0331, .start_ctrl_reg = 0x0300,
@@ -1131,12 +1134,12 @@ void ksz_port_stp_state_set(struct dsa_switch *ds, int port, u8 state) {struct ksz_device *dev = ds->priv;struct ksz_port *p; +const u16 *regs;u8 data; -int reg; - reg = dev->info->stp_ctrl_reg; + regs = dev->info->regs; -ksz_pread8 (dev, port, reg, &data); +ksz_pread8 (dev, port, regs[P_STP_CTRL ], &data); data &= ~(PORT_TX_ENABLE |PORT_RX_ENABLE |PORT_LEARN_DISABLE );switch (state) {
@@ -1160,7 +1163,7 @@ void ksz_port_stp_state_set(struct dsa_switch *ds, int port, u8 state)return ; } -ksz_pwrite8 (dev, port, reg, data); +ksz_pwrite8 (dev, port, regs[P_STP_CTRL ], data); p = &dev->ports[port]; p->stp_state = state;
drivers/net/dsa/microchip/ksz_common.h +1 -0
@@ -164,6 +164,7 @@ enum ksz_regs {P_REMOTE_STATUS ,P_SPEED_STATUS ,S_TAIL_TAG_CTRL , + P_STP_CTRL, }; enum ksz_masks {
Signature · 1 line
2.36.1
PATCH 7/7 net: dsa: microchip: move remaining register offset to ksz_chip_reg
In reply to Arun RamadossThis patch moves the broadcast ctrl, multicast ctrl and start control registers from ksz_chip_dat to ksz_chip_reg.
--- drivers/net/dsa/microchip/ksz_common.c | 57 +++++++------------------- drivers/net/dsa/microchip/ksz_common.h | 3 ++ 2 files changed, 18 insertions(+), 42 deletions(-)
drivers/net/dsa/microchip/ksz_common.c +15 -42
@@ -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 ;
drivers/net/dsa/microchip/ksz_common.h +3 -0
@@ -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 {
Signature · 1 line
2.36.1
This series was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:
Quoted 14 lines · On Tue, 28 Jun 2022 22:43:22 +0530 you wrote:
This patch series tries to use the same approach as struct ksz8 for register which has different address for different switch family. It moves the struct ksz8 from
ksz8.hto structksz_chip_reg. Based on the switch detect, the corresponding mask, reg and shifts are assigned.Arun Ramadoss (7):
net: dsa: microchip: moveksz8->regstoksz_common
net: dsa: microchip: moveksz8->maskstoksz_common
net: dsa: microchip: moveksz8->shiftstoksz_common
net: dsa: microchip: remove the struct ksz8
net: dsa: microchip: change the size of reg from u8 to u16
net: dsa: microchip: addP_STP_CTRLtoksz_chip_reg
net: dsa: microchip: move remaining register offset toksz_chip_reg
Quoted 1 line
[...]
Here is the summary with links:
- [net-next,1/7] net: dsa: microchip: move ksz8->regs to ksz_common
https://git.kernel.org/netdev/net-next/c/486f9ca715d7 - [net-next,2/7] net: dsa: microchip: move ksz8->masks to ksz_common https://git.kernel.org/netdev/net-next/c/d23a5e18606c - [net-next,3/7] net: dsa: microchip: move ksz8->shifts to ksz_common https://git.kernel.org/netdev/net-next/c/34e48383636f - [net-next,4/7] net: dsa: microchip: remove the struct ksz8 https://git.kernel.org/netdev/net-next/c/47d82864eee1 - [net-next,5/7] net: dsa: microchip: change the size of reg from u8 to u16 https://git.kernel.org/netdev/net-next/c/a02579df160e - [net-next,6/7] net: dsa: microchip: add P_STP_CTRL to ksz_chip_reg https://git.kernel.org/netdev/net-next/c/6877102f95f3 - [net-next,7/7] net: dsa: microchip: move remaining register offset to ksz_chip_reg https://git.kernel.org/netdev/net-next/c/9d95329c65db
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html