net: dsa: ksz: Add Microchip KSZ87xx support
Subsystems (5)
v2 cover net: dsa: ksz: Add Microchip KSZ87xx support
This series adds support for Microchip KSZ87xx switches, which are slightly simpler compared to KSZ9xxx .
Marek Vasut (1):
dt-bindings: net: dsa: ksz: document Microchip KSZ87xx family switches
Tristram Ha (2):
net: dsa: ksz: Add KSZ8795 tag code
net: dsa: ksz: Add Microchip KSZ8795 DSA driver
.../devicetree/bindings/net/dsa/ksz.txt | 3 + drivers/net/dsa/microchip/Kconfig | 18 + drivers/net/dsa/microchip/Makefile | 2 + drivers/net/dsa/microchip/ksz8795.c | 1324 +++++++++++++++++ drivers/net/dsa/microchip/ksz8795_reg.h | 1004 +++++++++++++ drivers/net/dsa/microchip/ksz8795_spi.c | 104 ++ drivers/net/dsa/microchip/ksz_common.h | 28 + drivers/net/dsa/microchip/ksz_priv.h | 1 + include/net/dsa.h | 2 + net/dsa/Kconfig | 7 + net/dsa/tag_ksz.c | 62 + 11 files changed, 2555 insertions(+) create mode 100644 drivers/net/dsa/microchip/ksz8795.c create mode 100644 drivers/net/dsa/microchip/ksz8795_reg.h create mode 100644 drivers/net/dsa/microchip/ksz8795_spi.c
Signature · 1 line
2.20.1
PATCH v2 1/3 dt-bindings: net: dsa: ksz: document Microchip KSZ87xx family switches
Document Microchip KSZ87xx family switches. These include KSZ8765 - 5 port switch
KSZ8794 - 4 port switch
KSZ8795 - 5 port switch
---
V2: No change
--- Documentation/devicetree/bindings/net/dsa/ksz.txt | 3 +++ 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/net/dsa/ksz.txt +3 -0
@@ -5,6 +5,9 @@ Required properties: - compatible: For external switch chips, compatible string must be exactly one of the following: + - "microchip,ksz8765" + - "microchip,ksz8794" + - "microchip,ksz8795" - "microchip,ksz9477" - "microchip,ksz9897" - "microchip,ksz9896"
Signature · 1 line
2.20.1
PATCH v2 2/3 net: dsa: ksz: Add KSZ8795 tag code
In reply to Marek VasutFrom: Tristram Ha <[email protected]>
Add DSA tag code for Microchip KSZ8795 switch. The switch is simpler and the tag is only 1 byte, instead of 2 as is the case with KSZ9477.
---
V2: No change
--- include/net/dsa.h | 2 ++ net/dsa/Kconfig | 7 ++++++ net/dsa/tag_ksz.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+)
include/net/dsa.h +2 -0
@@ -41,6 +41,7 @@ struct phylink_link_state;#define DSA_TAG_PROTO_TRAILER_VALUE 11#define DSA_TAG_PROTO_8021Q_VALUE 12#define DSA_TAG_PROTO_SJA1105_VALUE 13 +#define DSA_TAG_PROTO_KSZ8795_VALUE 14enum dsa_tag_protocol {DSA_TAG_PROTO_NONE =DSA_TAG_PROTO_NONE_VALUE ,
@@ -57,6 +58,7 @@ enum dsa_tag_protocol {DSA_TAG_PROTO_TRAILER =DSA_TAG_PROTO_TRAILER_VALUE ,DSA_TAG_PROTO_8021Q =DSA_TAG_PROTO_8021Q_VALUE ,DSA_TAG_PROTO_SJA1105 =DSA_TAG_PROTO_SJA1105_VALUE , + DSA_TAG_PROTO_KSZ8795 = DSA_TAG_PROTO_KSZ8795_VALUE, };struct packet_type ;
net/dsa/Kconfig +7 -0
@@ -77,6 +77,13 @@ config NET_DSA_TAG_KSZ_COMMON tristate default n +config NET_DSA_TAG_KSZ8795 + tristate "Tag driver for Microchip 8795 family of switches" + select NET_DSA_TAG_KSZ_COMMON + help + Say Y if you want to enable support for tagging frames for the + Microchip 8795 family of switches. + config NET_DSA_TAG_KSZ tristate "Tag driver for Microchip 9893 family of switches" select NET_DSA_TAG_KSZ_COMMON
net/dsa/tag_ksz.c +62 -0
74 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v2 3/3 net: dsa: ksz: Add Microchip KSZ8795 DSA driver
In reply to Marek VasutFrom: Tristram Ha <[email protected]>
Add Microchip KSZ8795 DSA driver.
---
V2: - Use reverse xmas tree for variable declaration
- Use BIT() macro where applicable
- Use regmap_update_bits() where applicable
- Replace ad-hoc stp_multicast_addr[] with ether_addr_copy(..., eth_stp_addr)
--- drivers/net/dsa/microchip/Kconfig | 18 + drivers/net/dsa/microchip/Makefile | 2 + drivers/net/dsa/microchip/ksz8795.c | 1324 +++++++++++++++++++++++ drivers/net/dsa/microchip/ksz8795_reg.h | 1004 +++++++++++++++++ drivers/net/dsa/microchip/ksz8795_spi.c | 104 ++ drivers/net/dsa/microchip/ksz_common.h | 28 + drivers/net/dsa/microchip/ksz_priv.h | 1 + 7 files changed, 2481 insertions(+) create mode 100644 drivers/net/dsa/microchip/ksz8795.c create mode 100644 drivers/net/dsa/microchip/ksz8795_reg.h create mode 100644 drivers/net/dsa/microchip/ksz8795_spi.c
drivers/net/dsa/microchip/Kconfig +18 -0
@@ -16,3 +16,21 @@ config NET_DSA_MICROCHIP_KSZ9477_SPI select REGMAP_SPI help Select to enable support for registering switches configured through SPI. + +menuconfig NET_DSA_MICROCHIP_KSZ8795 + tristate "Microchip KSZ8795 series switch support" + depends on NET_DSA + select NET_DSA_TAG_KSZ8795 + select NET_DSA_MICROCHIP_KSZ_COMMON + help + This driver adds support for Microchip KSZ8795 switch chips. + +config NET_DSA_MICROCHIP_KSZ8795_SPI + tristate "KSZ8795 series SPI connected switch driver" + depends on NET_DSA_MICROCHIP_KSZ8795 && SPI + select REGMAP_SPI + help + This driver accesses KSZ8795 chip through SPI. + + It is required to use the KSZ8795 switch driver as the only access + is through SPI.
drivers/net/dsa/microchip/Makefile +2 -0
@@ -2,3 +2,5 @@ obj-$(CONFIG_NET_DSA_MICROCHIP_KSZ_COMMON) += ksz_common.o obj-$(CONFIG_NET_DSA_MICROCHIP_KSZ9477) += ksz9477.o obj-$(CONFIG_NET_DSA_MICROCHIP_KSZ9477_SPI) += ksz9477_spi.o +obj-$(CONFIG_NET_DSA_MICROCHIP_KSZ8795) += ksz8795.o +obj-$(CONFIG_NET_DSA_MICROCHIP_KSZ8795_SPI) += ksz8795_spi.o
drivers/net/dsa/microchip/ksz8795.c new file +1324 -0
1,324 lines not on this page · raw message
drivers/net/dsa/microchip/ksz8795_reg.h new file +1004 -0
1,004 lines not on this page · raw message
drivers/net/dsa/microchip/ksz8795_spi.c new file +104 -0
104 lines not on this page · raw message
drivers/net/dsa/microchip/ksz_common.h +28 -0
@@ -68,6 +68,22 @@ static inline int ksz_read32(struct ksz_device *dev, u32 reg, u32 *val)return ret; } +static inline int ksz_read64 (struct ksz_device *dev,u32 reg,u64 *val) +{ +u32 value[2 ]; +int ret; + + ret =regmap_bulk_read (dev->regmap[2 ], reg, value,2 ); +if (!ret) { +/* Ick! ToDo: Add 64bit R/W to regmap on 32bit systems */ + value[0 ] =swab32 (value[0 ]); + value[1 ] =swab32 (value[1 ]); + *val =swab64 ((u64)*value); + } + +return ret; +} +static inline int ksz_write8 (struct ksz_device *dev,u32 reg,u8 value) {return regmap_write (dev->regmap[0 ], reg, value);
@@ -83,6 +99,18 @@ static inline int ksz_write32(struct ksz_device *dev, u32 reg, u32 value)return regmap_write (dev->regmap[2 ], reg, value); } +static inline int ksz_write64 (struct ksz_device *dev,u32 reg,u64 value) +{ +u32 val[2 ]; + +/* Ick! ToDo: Add 64bit R/W to regmap on 32bit systems */ + value =swab64 (value); + val[0 ] =swab32 (value &0xffffffffULL ); + val[1 ] =swab32 (value >>32ULL ); + +return regmap_bulk_write (dev->regmap[2 ], reg, val,2 ); +} +static inline void ksz_pread8 (struct ksz_device *dev,int port,int offset,u8 *data) {
drivers/net/dsa/microchip/ksz_priv.h +1 -0
@@ -150,6 +150,7 @@ int ksz_switch_register(struct ksz_device *dev, const struct ksz_dev_ops *ops);void ksz_switch_remove (struct ksz_device *dev); +int ksz8795_switch_register (struct ksz_device *dev);int ksz9477_switch_register (struct ksz_device *dev);#endif
Signature · 1 line
2.20.1
Andrew Lunn
maintainerRe: [PATCH V2 3/3] net: dsa: ksz: Add Microchip KSZ8795 DSA driver
On Thu, Jul 25, 2019 at 05:05:52PM +0200, Marek Vasut wrote:
Hi Marek
drivers/net/dsa/microchip/ksz8795.c line 934
Quoted 11 lines
drivers/net/dsa/microchip/ksz8795.c new file +11
-0+static void ksz8795_phy_setup (struct ksz_device *dev,int port, +struct phy_device *phy) +{ +if (port < dev->phy_port_cnt) { +/* +* SUPPORTED_Asym_Pause and SUPPORTED_Pause can be removed to +* disable flow control when rate limiting is used. +*/ +linkmode_copy (phy->advertising, phy->supported); + } +}
Please could you drop this, since your testing seems to indicate it is not needed.
Thanks
Andrew