net: dsa: microchip: Add KSZ8895/KSZ8864 switch support
Subsystems (5)
v2 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.
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 v2 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
@@ -21,6 +21,8 @@ properties: - microchip,ksz8765 - microchip,ksz8794 - microchip,ksz8795 + - microchip,ksz8895 # 5-port version of KSZ8895 family switch + - microchip,ksz8864 # 4-port version of KSZ8895 family switch - microchip,ksz8863 - microchip,ksz8873 - microchip,ksz9477
Signature · 1 line
2.34.1
Rob Herring (Arm)
maintainerRe: [PATCH net-next v2 1/2] dt-bindings: net: dsa: microchip: Add KSZ8895/KSZ8864 switch support
Quoted 6 lines · On Thu, 08 Aug 2024 17:43:09 -0700, [email protected] wrote:
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.
Quoted 8 lines
KSZ8864 is a 4-port version of KSZ8895. The first port is removed while port 5 remains as a host port.
Signed-off-by Tristram Ha <[email protected]>--- Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml | 2 ++ 1 file changed, 2 insertions(+)
My bot found errors running 'make dt_binding_check' on your patch:
yamllint warnings/errors:./Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml:24:26: [error] syntax error: found character '\t' that cannot start any token (syntax)
dtschema/dtc warnings/errors:
doc reference errors (make refcheckdocs):
See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]
The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
pip3 install dtschema --upgrade
Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.
PATCH v2 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 KSZ8895_CHIP_ID : +case KSZ8864_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_ksz88x3 (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
@@ -199,6 +199,8 @@ enum ksz_model {KSZ8795 ,KSZ8794 ,KSZ8765 , +KSZ8895 , +KSZ8864 ,KSZ8830 ,KSZ9477 , KSZ9896,
@@ -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;
@@ -132,6 +135,14 @@ static const struct of_device_id ksz_dt_ids[] = { .compatible = "microchip,ksz8795", .data = &ksz_switch_chips[KSZ8795 ] }, + { + .compatible = "microchip,ksz8895", + .data = &ksz_switch_chips[KSZ8895 ] + }, + { + .compatible = "microchip,ksz8864", + .data = &ksz_switch_chips[KSZ8864 ] + }, { .compatible ="microchip,ksz8863" , .data = &ksz_switch_chips[KSZ8830]
@@ -200,6 +211,8 @@ static const struct spi_device_id ksz_spi_ids[] = { { "ksz8765" }, { "ksz8794" }, { "ksz8795" }, + { "ksz8895" }, + { "ksz8864" }, { "ksz8863" }, { "ksz8873" }, { "ksz9477" },
include/linux/platform_data/microchip-ksz.h +2 -0
@@ -27,6 +27,8 @@ enum ksz_chip_id {KSZ8795_CHIP_ID =0x8795 ,KSZ8794_CHIP_ID =0x8794 ,KSZ8765_CHIP_ID =0x8765 , +KSZ8895_CHIP_ID =0x8895 , +KSZ8864_CHIP_ID =0x8864 ,KSZ8830_CHIP_ID =0x8830 ,KSZ9477_CHIP_ID =0x00947700 , KSZ9896_CHIP_ID = 0x00989600,
Signature · 1 line
2.34.1