Skip to contentSkip to conversation

net: dsa: ksz: Add Microchip KSZ87xx support

PATCH Superseded Marek Vasut 2 participants 5 messages Jul 26, 2019 – Jul 29, 2019

Subsystems (5)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover net: dsa: ksz: Add Microchip KSZ87xx support

This series adds support for Microchip KSZ87xx switches, which are slightly simpler compared to KSZ9xxx .

Cc Andrew Lunn <[email protected]>
Cc David S. Miller <[email protected]>
Cc Florian Fainelli <[email protected]>
Cc Tristram Ha <[email protected]>
Cc Vivien Didelot <[email protected]>
Cc Woojung Huh <[email protected]>

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           | 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/Kconfig                               |    7 +
 net/dsa/tag_ksz.c                             |   62 +
 12 files changed, 2544 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
#1 lore raw

PATCH v3 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

Cc Andrew Lunn <[email protected]>
Cc David S. Miller <[email protected]>
Cc Florian Fainelli <[email protected]>
Cc Rob Herring <[email protected]>
Cc Tristram Ha <[email protected]>
Cc Vivien Didelot <[email protected]>
Cc Woojung Huh <[email protected]>

---
V2: No change
V3: No change

---
 Documentation/devicetree/bindings/net/dsa/ksz.txt | 3 +++
 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/net/dsa/ksz.txt +3 -0
index 4ac21cef370e..5e8429b6f9ca 100644
@@ -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
#2 lore raw

PATCH v3 2/3 net: dsa: ksz: Add KSZ8795 tag code

In reply to Marek Vasut

From: 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.

Cc Andrew Lunn <[email protected]>
Cc David S. Miller <[email protected]>
Cc Florian Fainelli <[email protected]>
Cc Tristram Ha <[email protected]>
Cc Vivien Didelot <[email protected]>
Cc Woojung Huh <[email protected]>

---
V2: No change
V3: 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
index 1e8650fa8acc..147b757ef8ea 100644
@@ -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		14
 
 enum 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
index 6e942dda1bcd..423fa4370608 100644
@@ -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
maintainer
#3 lore raw

Re: [PATCH V3 2/3] net: dsa: ksz: Add KSZ8795 tag code

From: Marek Vasut <[email protected]>
Date: Fri, 26 Jul 2019 18:23:07 +0200

net/dsa/Kconfig config NET_DSA_TAG_KSZ_COMMON · line 85

Quoted 10 lines
net/dsa/Kconfig +6 -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.

This Kconfig knob doesn't control the inclusion of code at all.

It's only use is in patch #3 where it is selected for the new NET_DSA_MICROCHIP_KSZ8795.

Therefore it isn't doing anything.

So please either make it control code inclusion or remove it.

Thank you.

#4 lore raw

PATCH v3 3/3 net: dsa: ksz: Add Microchip KSZ8795 DSA driver

In reply to Marek Vasut

From: Tristram Ha <[email protected]>

Add Microchip KSZ8795 DSA driver.

Cc Andrew Lunn <[email protected]>
Cc David S. Miller <[email protected]>
Cc Florian Fainelli <[email protected]>
Cc Tristram Ha <[email protected]>
Cc Vivien Didelot <[email protected]>
Cc Woojung Huh <[email protected]>

---
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()

---
 drivers/net/dsa/microchip/Kconfig       |   18 +
 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, 2470 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 +18 -0
index fe0a13b79c4b..d990c7128991 100644
@@ -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
index 68451b02f775..e3d799b95d7d 100644
@@ -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
index a3d2d67894bd..ce20cc90f9ef 100644
@@ -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
index ee7096d8af07..84fed4a2578b 100644
@@ -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
index beacf0e40f42..44c16aaf775c 100644
@@ -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