net: dsa: ksz: Add Microchip KSZ87xx support
Subsystems (5)
v4 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 | 17 + drivers/net/dsa/microchip/Makefile | 2 + drivers/net/dsa/microchip/ksz8795.c | 1311 +++++++++++++++++ drivers/net/dsa/microchip/ksz8795_reg.h | 1004 +++++++++++++ drivers/net/dsa/microchip/ksz8795_spi.c | 104 ++ drivers/net/dsa/microchip/ksz_common.c | 3 +- drivers/net/dsa/microchip/ksz_common.h | 28 + drivers/net/dsa/microchip/ksz_priv.h | 1 + include/net/dsa.h | 2 + net/dsa/tag_ksz.c | 62 + 11 files changed, 2536 insertions(+), 1 deletion(-) 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 v4 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
V3: No change
V4: 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 v4 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
V3: No change
V4: Drop Kconfig entry
--- include/net/dsa.h | 2 ++ net/dsa/tag_ksz.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 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/tag_ksz.c +62 -0
74 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v4 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)
V3: - Drop ksz8795_phy_setup()
V4: - Update Kconfig entries, to not select the KSZ8795_DSA_TAG, which was removed
--- drivers/net/dsa/microchip/Kconfig | 17 + drivers/net/dsa/microchip/Makefile | 2 + drivers/net/dsa/microchip/ksz8795.c | 1311 +++++++++++++++++++++++ drivers/net/dsa/microchip/ksz8795_reg.h | 1004 +++++++++++++++++ drivers/net/dsa/microchip/ksz8795_spi.c | 104 ++ drivers/net/dsa/microchip/ksz_common.c | 3 +- drivers/net/dsa/microchip/ksz_common.h | 28 + drivers/net/dsa/microchip/ksz_priv.h | 1 + 8 files changed, 2469 insertions(+), 1 deletion(-) 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 +17 -0
@@ -16,3 +16,20 @@ 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_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 +1311 -0
1,311 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.c +2 -1
@@ -373,7 +373,8 @@ int ksz_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy)/* setup slave port */ dev->dev_ops->port_setup (dev, port, false); - dev->dev_ops->phy_setup (dev, port, phy); +if (dev->dev_ops->phy_setup) + dev->dev_ops->phy_setup (dev, port, phy);/* port_stp_state_set() will be called after to enable the port so * there is no need to do anything.
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
David Miller
maintainerFrom: Marek Vasut <[email protected]>
Date: Mon, 29 Jul 2019 19:49:44 +0200
Quoted 4 lines
This series adds support for Microchip KSZ87xx switches, which are slightly simpler compared to KSZ9xxx .
Signed-off-by Marek Vasut <[email protected]>
Series applied to net-next, thank you.