net: dsa: microchip: Add KSZ8895/KSZ8864 switch support
Subsystems (5)
v4 cover net: dsa: microchip: Add KSZ8895/KSZ8864 switch support
From: Tristram Ha <[email protected]>
This series of patches is to add KSZ8895/KSZ8864 switch support to the KSZ DSA driver.
v4
- Update with Paolo's suggestion
- Sort KSZ8864 and KSZ8895 behind KSZ8863
v3
- Correct microchip,ksz.yaml to pass yamllint check
v2
- Add maintainers for devicetree
Tristram Ha (2):
dt-bindings: net: dsa: microchip: Add KSZ8895/KSZ8864 switch support
net: dsa: microchip: Add KSZ8895/KSZ8864 switch support
.../bindings/net/dsa/microchip,ksz.yaml | 2 + drivers/net/dsa/microchip/ksz8795.c | 16 ++- drivers/net/dsa/microchip/ksz_common.c | 130 +++++++++++++++++- drivers/net/dsa/microchip/ksz_common.h | 20 ++- drivers/net/dsa/microchip/ksz_spi.c | 15 +- include/linux/platform_data/microchip-ksz.h | 2 + 6 files changed, 172 insertions(+), 13 deletions(-)
Signature · 1 line
2.34.1
PATCH v4 1/2 dt-bindings: net: dsa: microchip: Add KSZ8895/KSZ8864 switch support
From: Tristram Ha <[email protected]>
KSZ8895/KSZ8864 is a switch family developed before KSZ8795 and after KSZ8863, so it shares some registers and functions in those switches. KSZ8895 has 5 ports and so is more similar to KSZ8795.
KSZ8864 is a 4-port version of KSZ8895. The first port is removed while port 5 remains as a host port.
--- Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml +2 -0
@@ -22,7 +22,9 @@ properties: - microchip,ksz8794 - microchip,ksz8795 - microchip,ksz8863 + - microchip,ksz8864 # 4-port version of KSZ8895 family switch - microchip,ksz8873 + - microchip,ksz8895 # 5-port version of KSZ8895 family switch - microchip,ksz9477 - microchip,ksz9897 - microchip,ksz9896
Signature · 1 line
2.34.1
PATCH v4 2/2 net: dsa: microchip: Add KSZ8895/KSZ8864 switch support
In reply to [email protected]From: Tristram Ha <[email protected]>
KSZ8895/KSZ8864 is a switch family between KSZ8863/73 and KSZ8795, so it shares some registers and functions in those switches already implemented in the KSZ DSA driver.
--- drivers/net/dsa/microchip/ksz8795.c | 16 ++- drivers/net/dsa/microchip/ksz_common.c | 130 +++++++++++++++++++- drivers/net/dsa/microchip/ksz_common.h | 20 ++- drivers/net/dsa/microchip/ksz_spi.c | 15 ++- include/linux/platform_data/microchip-ksz.h | 2 + 5 files changed, 170 insertions(+), 13 deletions(-)
drivers/net/dsa/microchip/ksz8795.c +10 -6
@@ -121,6 +121,8 @@ int ksz8_change_mtu(struct ksz_device *dev, int port, int mtu)case KSZ8765_CHIP_ID :return ksz8795_change_mtu (dev, frame_size);case KSZ8830_CHIP_ID : +case KSZ8864_CHIP_ID : +case KSZ8895_CHIP_ID :return ksz8863_change_mtu (dev, frame_size); }
@@ -317,7 +319,7 @@ static void ksz8863_r_mib_pkt(struct ksz_device *dev, int port, u16 addr,void ksz8_r_mib_pkt (struct ksz_device *dev,int port,u16 addr,u64 *dropped,u64 *cnt) { -if (ksz_is_ksz88x3 (dev)) +if (ksz_is_ksz88x3 (dev) ||ksz_is_8895_family (dev))ksz8863_r_mib_pkt (dev, port, addr, dropped, cnt);else ksz8795_r_mib_pkt (dev, port, addr, dropped, cnt);
@@ -325,7 +327,7 @@ void ksz8_r_mib_pkt(struct ksz_device *dev, int port, u16 addr,void ksz8_freeze_mib (struct ksz_device *dev,int port,bool freeze) { -if (ksz_is_ksz88x3 (dev)) +if (ksz_is_ksz88x3 (dev) ||ksz_is_8895_family (dev))return ;/* enable the port for flush/freeze function */
@@ -343,7 +345,8 @@ void ksz8_port_init_cnt(struct ksz_device *dev, int port)struct ksz_port_mib *mib = &dev->ports[port].mib;u64 *dropped; -if (!ksz_is_ksz88x3 (dev)) { +/* For KSZ8795 family. */ +if (ksz_is_ksz87xx (dev)) {/* flush all enabled port MIB counters */ ksz_cfg (dev,REG_SW_CTRL_6 ,BIT (port), true);ksz_cfg (dev,REG_SW_CTRL_6 ,SW_MIB_COUNTER_FLUSH , true);
@@ -542,11 +545,11 @@ static int ksz8_r_sta_mac_table(struct ksz_device *dev, u16 addr, shifts[STATIC_MAC_FWD_PORTS ]; alu->is_override = (data_hi & masks[STATIC_MAC_TABLE_OVERRIDE ]) ?1 :0 ; -/* KSZ8795 family switches have STATIC_MAC_TABLE_USE_FID and +/* KSZ8795/KSZ8895 family switches have STATIC_MAC_TABLE_USE_FID and * STATIC_MAC_TABLE_FID definitions off by 1 when doing read on the * static MAC table compared to doing write. */ -if (ksz_is_ksz87xx (dev)) +if (ksz_is_ksz87xx (dev) ||ksz_is_8895_family (dev)) data_hi >>=1 ; alu->is_static = true; alu->is_use_fid = (data_hi & masks[STATIC_MAC_TABLE_USE_FID ]) ?1 :0 ;
@@ -1617,7 +1620,8 @@ void ksz8_config_cpu_port(struct dsa_switch *ds)for (i =0 ; i < dev->phy_port_cnt; i++) { p = &dev->ports[i]; -if (!ksz_is_ksz88x3 (dev)) { +/* For KSZ8795 family. */ +if (ksz_is_ksz87xx (dev)) {ksz_pread8 (dev, i, regs[P_REMOTE_STATUS ], &remote);if (remote &KSZ8_PORT_FIBER_MODE ) p->fiber =1 ;
drivers/net/dsa/microchip/ksz_common.c +126 -4
166 lines not on this page · raw message
drivers/net/dsa/microchip/ksz_common.h +18 -2
@@ -1,7 +1,7 @@/* SPDX-License-Identifier: GPL-2.0 */ /* Microchip switch driver common header * -* Copyright (C) 2017-2019 Microchip Technology Inc. +* Copyright (C) 2017-2024 Microchip Technology Inc. */ #ifndef __KSZ_COMMON_H
@@ -200,6 +200,8 @@ enum ksz_model {KSZ8794 ,KSZ8765 ,KSZ8830 , +KSZ8864 , +KSZ8895 ,KSZ9477 ,KSZ9896 , KSZ9897,
@@ -624,9 +626,16 @@ static inline bool ksz_is_ksz88x3(struct ksz_device *dev)return dev->chip_id ==KSZ8830_CHIP_ID ; } +static inline bool ksz_is_8895_family (struct ksz_device *dev) +{ +return dev->chip_id ==KSZ8895_CHIP_ID || + dev->chip_id ==KSZ8864_CHIP_ID ; +} +static inline bool is_ksz8 (struct ksz_device *dev) { -return ksz_is_ksz87xx (dev) ||ksz_is_ksz88x3 (dev); +return ksz_is_ksz87xx (dev) ||ksz_is_ksz88x3 (dev) || +ksz_is_8895_family (dev); }static inline int is_lan937x (struct ksz_device *dev)
@@ -655,6 +664,7 @@ static inline bool is_lan937x_tx_phy(struct ksz_device *dev, int port)#define SW_FAMILY_ID_M GENMASK(15, 8)#define KSZ87_FAMILY_ID 0x87#define KSZ88_FAMILY_ID 0x88 +#define KSZ8895_FAMILY_ID 0x95#define KSZ8_PORT_STATUS_0 0x08#define KSZ8_PORT_FIBER_MODE BIT(7)
@@ -663,6 +673,12 @@ static inline bool is_lan937x_tx_phy(struct ksz_device *dev, int port)#define KSZ87_CHIP_ID_94 0x6#define KSZ87_CHIP_ID_95 0x9#define KSZ88_CHIP_ID_63 0x3 +#define KSZ8895_CHIP_ID_95 0x4 +#define KSZ8895_CHIP_ID_95R 0x6 + +/* KSZ8895 specific register */ +#define REG_KSZ8864_CHIP_ID 0xFE +#define SW_KSZ8864 BIT(7)#define SW_REV_ID_M GENMASK(7, 4)
drivers/net/dsa/microchip/ksz_spi.c +14 -1
@@ -2,7 +2,7 @@/* * Microchip ksz series register access through SPI * -* Copyright (C) 2017 Microchip Technology Inc. +* Copyright (C) 2017-2024 Microchip Technology Inc. * Tristram Ha <[email protected]> */
@@ -60,6 +60,9 @@ static int ksz_spi_probe(struct spi_device *spi) chip->chip_id == KSZ8794_CHIP_ID || chip->chip_id == KSZ8765_CHIP_ID) regmap_config = ksz8795_regmap_config; + else if (chip->chip_id == KSZ8895_CHIP_ID || + chip->chip_id == KSZ8864_CHIP_ID) + regmap_config = ksz8863_regmap_config; else regmap_config = ksz9477_regmap_config;
@@ -136,10 +139,18 @@ static const struct of_device_id ksz_dt_ids[] = { .compatible = "microchip,ksz8863", .data = &ksz_switch_chips[KSZ8830 ] }, + { + .compatible = "microchip,ksz8864", + .data = &ksz_switch_chips[KSZ8864 ] + }, { .compatible = "microchip,ksz8873", .data = &ksz_switch_chips[KSZ8830 ] }, + { + .compatible = "microchip,ksz8895", + .data = &ksz_switch_chips[KSZ8895 ] + }, { .compatible ="microchip,ksz9477" , .data = &ksz_switch_chips[KSZ9477]
@@ -201,7 +212,9 @@ static const struct spi_device_id ksz_spi_ids[] = { { "ksz8794" }, { "ksz8795" }, { "ksz8863" }, + { "ksz8864" }, { "ksz8873" }, + { "ksz8895" }, { "ksz9477" }, { "ksz9896" }, { "ksz9897" },
include/linux/platform_data/microchip-ksz.h +2 -0
@@ -28,6 +28,8 @@ enum ksz_chip_id {KSZ8794_CHIP_ID =0x8794 ,KSZ8765_CHIP_ID =0x8765 ,KSZ8830_CHIP_ID =0x8830 , +KSZ8864_CHIP_ID =0x8864 , +KSZ8895_CHIP_ID =0x8895 ,KSZ9477_CHIP_ID =0x00947700 ,KSZ9896_CHIP_ID =0x00989600 , KSZ9897_CHIP_ID = 0x00989700,
Signature · 1 line
2.34.1
Paolo Abeni
maintainerQuoted 7 lines · On 8/15/24 04:20, [email protected] wrote:
From: Tristram Ha <[email protected]>
KSZ8895/KSZ8864 is a switch family between KSZ8863/73 and KSZ8795, so it shares some registers and functions in those switches already implemented in the KSZ DSA driver.
Signed-off-by Tristram Ha <[email protected]>
I usually wait for an explicit ack from the DSA crew on this kind of patches, but this one and it really looks really unlikely to indroduce any regression for the already supported chips and it's lingering since a bit, so I'm applying it now.
Thanks,
Paolo
Paolo Abeni
maintainerQuoted 7 lines · Paolo Abeni
Quoted 6 lines · On 8/15/24 04:20, [email protected] wrote:
From: Tristram Ha <[email protected]>
KSZ8895/KSZ8864 is a switch family between KSZ8863/73 and KSZ8795, so it shares some registers and functions in those switches already implemented in the KSZ DSA driver.
Quoted 6 lines
Quoted 1 line
Signed-off-by Tristram Ha <[email protected]>I usually wait for an explicit ack from the DSA crew on this kind of patches, but this one and it really looks really unlikely to indroduce any regression for the already supported chips and it's lingering since a bit, so I'm applying it now.
Unfortunatelly does not apply cleanly anymore since commit fd250fed1f8856c37caa7b9a5e6015ad6f5011e5.
Please rebase and re-send.
Thanks,
Paolo
PATCH v4 2/2 net: dsa: microchip: Add KSZ8895/KSZ8864 switch support
Hi Tristram,
drivers/net/dsa/microchip/ksz8795.c void ksz8_r_mib_pkt(struct ksz_device *dev, int port, u16 addr, · line 330
Quoted 6 lines
drivers/net/dsa/microchip/ksz8795.c +1
-1@@ -325,7 +327,7 @@ void ksz8_r_mib_pkt(struct ksz_device *dev, int port, u16 addr,void ksz8_freeze_mib (struct ksz_device *dev,int port,bool freeze) { -if (ksz_is_ksz88x3 (dev)) +if (ksz_is_ksz88x3 (dev) ||ksz_is_8895_family (dev))
Small comment, would it not be more clear and consistent to introduce a new ksz_is_ksz88xx function in ksz_common.h, being ksz_is_ksz88x3 || ksz_is_8895_family?
That would help with the renamed ksz88x3_dev_ops that you will encounter when rebasing. In fact, seeing your additions here, I would propose to rename this struct to ksz88xx_dev_ops.
Cheers, Pieter
Quoted 16 lines
Subject: [PATCH net-next v4 2/2] net: dsa: microchip: Add KSZ8895/KSZ8864 switch support
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Hi Tristram,
Review void ksz8_r_mib_pkt(struct ksz_device *dev, int port, u16
Quoted 1 line
(quoted diff) +0
-0@@ -325,7 +327,7 @@ void ksz8_r_mib_pkt(struct ksz_device *dev, int port, u16addr,
drivers/net/dsa/microchip/ksz8795.c void ksz8_r_mib_pkt(struct ksz_device *dev, int port, u16 addr, · line 330
Quoted 5 lines
drivers/net/dsa/microchip/ksz8795.c +1
-1void ksz8_freeze_mib (struct ksz_device *dev,int port,bool freeze) { -if (ksz_is_ksz88x3 (dev)) +if (ksz_is_ksz88x3 (dev) ||ksz_is_8895_family (dev))
Quoted 7 lines
Small comment, would it not be more clear and consistent to introduce a new
ksz_is_ksz88xxfunction inksz_common.h, beingksz_is_ksz88x3||ksz_is_8895_family?That would help with the renamed
ksz88x3_dev_opsthat you will encounter when rebasing. In fact, seeing your additions here, I would propose to rename this struct toksz88xx_dev_ops.
Will update and re-submit patches after testing with new code.
Quoted 21 lines
Subject: Re: [PATCH net-next v4 2/2] net: dsa: microchip: Add KSZ8895/KSZ8864 switch support
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Quoted 7 lines · Paolo Abeni
Quoted 6 lines · On 8/15/24 04:20, [email protected] wrote:
From: Tristram Ha <[email protected]>
KSZ8895/KSZ8864 is a switch family between KSZ8863/73 and KSZ8795, so it shares some registers and functions in those switches already implemented in the KSZ DSA driver.
Quoted 6 lines
Quoted 1 line
Signed-off-by Tristram Ha <[email protected]>I usually wait for an explicit ack from the DSA crew on this kind of patches, but this one and it really looks really unlikely to indroduce any regression for the already supported chips and it's lingering since a bit, so I'm applying it now.
Quoted 4 lines
Unfortunatelly does not apply cleanly anymore since commit
fd250fed1f8856c37caa7b9a5e6015ad6f5011e5.Please rebase and re-send.
Will update and re-submit patches after testing with new code.