add ksz9567 with I2C support to ksz9477 driver
v2 cover add ksz9567 with I2C support to ksz9477 driver
Resurrect KSZ9477 I2C driver support patch originally sent to the list by Tristram Ha and resolve outstanding issues. It now works as similarly to the ksz9477 SPI driver as possible, using the same regmap macros.
Add support for ksz9567 to the ksz9477 driver (tested on a board with ksz9567 connected via I2C).
Remove NET_DSA_TAG_KSZ_COMMON since it's not needed.
Changes since v1:
Put ksz9477_i2c.c includes in alphabetical order.
Added Reviewed-Bys.
George McCollister (2):
net: dsa: microchip: add ksz9567 to ksz9477 driver
net: dsa: microchip: remove NET_DSA_TAG_KSZ_COMMON
Tristram Ha (1):
net: dsa: microchip: add KSZ9477 I2C driver
drivers/net/dsa/microchip/Kconfig | 7 +++ drivers/net/dsa/microchip/Makefile | 1 + drivers/net/dsa/microchip/ksz9477.c | 9 +++ drivers/net/dsa/microchip/ksz9477_i2c.c | 101 ++++++++++++++++++++++++++++++++ drivers/net/dsa/microchip/ksz9477_spi.c | 1 + drivers/net/dsa/microchip/ksz_common.h | 2 + net/dsa/Kconfig | 9 +-- net/dsa/Makefile | 2 +- 8 files changed, 124 insertions(+), 8 deletions(-) create mode 100644 drivers/net/dsa/microchip/ksz9477_i2c.c
Signature · 1 line
2.11.0
PATCH v2 1/3 net: dsa: microchip: add KSZ9477 I2C driver
From: Tristram Ha <[email protected]>
Add KSZ9477 I2C driver support. The code ksz9477.c and ksz_common.c are used together to generate the I2C driver.
---
Changes since v1:
- Adjust order of includes so they are in alphabetical order.
drivers/net/dsa/microchip/Kconfig | 7 +++ drivers/net/dsa/microchip/Makefile | 1 + drivers/net/dsa/microchip/ksz9477_i2c.c | 100 ++++++++++++++++++++++++++++++++ drivers/net/dsa/microchip/ksz_common.h | 2 + 4 files changed, 110 insertions(+) create mode 100644 drivers/net/dsa/microchip/ksz9477_i2c.c
drivers/net/dsa/microchip/Kconfig +7 -0
@@ -9,6 +9,13 @@ menuconfig NET_DSA_MICROCHIP_KSZ9477 help This driver adds support for Microchip KSZ9477 switch chips. +config NET_DSA_MICROCHIP_KSZ9477_I2C + tristate "KSZ9477 series I2C connected switch driver" + depends on NET_DSA_MICROCHIP_KSZ9477 && I2C + select REGMAP_I2C + help + Select to enable support for registering switches configured through I2C. + config NET_DSA_MICROCHIP_KSZ9477_SPI tristate "KSZ9477 series SPI connected switch driver" depends on NET_DSA_MICROCHIP_KSZ9477 && SPI
drivers/net/dsa/microchip/Makefile +1 -0
@@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_NET_DSA_MICROCHIP_KSZ_COMMON) += ksz_common.o obj-$(CONFIG_NET_DSA_MICROCHIP_KSZ9477) += ksz9477.o +obj-$(CONFIG_NET_DSA_MICROCHIP_KSZ9477_I2C) += ksz9477_i2c.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/ksz9477_i2c.c new file +100 -0
100 lines not on this page · raw message
drivers/net/dsa/microchip/ksz_common.h +2 -0
@@ -294,6 +294,8 @@ static inline void ksz_pwrite32(struct ksz_device *dev, int port, int offset,#define KSZ_SPI_OP_RD 3#define KSZ_SPI_OP_WR 2 +#define swabnot_used (x) 0 +#define KSZ_SPI_OP_FLAG_MASK (opcode, swp, regbits, regpad) \ swab##swp((opcode) << ((regbits) + (regpad)))
Signature · 1 line
2.11.0
Andrew Lunn
maintainerRe: [PATCH net-next v2 1/3] net: dsa: microchip: add KSZ9477 I2C driver
Hi George
drivers/net/dsa/microchip/ksz_common.h static inline void ksz_pwrite32(struct ksz_device *dev, int port, int offset, · line 301
Quoted 11 lines
drivers/net/dsa/microchip/ksz_common.h +4
-0+KSZ_REGMAP_TABLE (ksz9477, not_used,16 ,0 ,0 ); +@@ -294,6 +294,8 @@ static inline void ksz_pwrite32(struct ksz_device *dev, int port, int offset,#define KSZ_SPI_OP_RD 3#define KSZ_SPI_OP_WR 2 +#define swabnot_used (x) 0 +#define KSZ_SPI_OP_FLAG_MASK (opcode, swp, regbits, regpad) \ swab##swp((opcode) << ((regbits) + (regpad)))
There seems to be quite a lot of macro magic here which is not obvious. Can this be simplified or made more obvious?
Andrew
Re: [PATCH net-next v2 1/3] net: dsa: microchip: add KSZ9477 I2C driver
Andrew,
Quoted 9 lines · Andrew Lunn
Hi George
Quoted 6 lines
drivers/net/dsa/microchip/ksz_common.h +2
-0+KSZ_REGMAP_TABLE (ksz9477, not_used,16 ,0 ,0 ); +@@ -294,6 +294,8 @@ static inline void ksz_pwrite32(struct ksz_device *dev, int port, int offset,#define KSZ_SPI_OP_RD 3#define KSZ_SPI_OP_WR 2
Quoted 8 lines
drivers/net/dsa/microchip/ksz_common.h static inline void ksz_pwrite32(struct ksz_device *dev, int port, int offset, · line 300
Quoted 5 lines
drivers/net/dsa/microchip/ksz_common.h +2
-0+#define swabnot_used (x) 0 +#define KSZ_SPI_OP_FLAG_MASK (opcode, swp, regbits, regpad) \ swab##swp((opcode) << ((regbits) + (regpad)))There seems to be quite a lot of macro magic here which is not obvious. Can this be simplified or made more obvious?
I thought about this for quite some time. To reduce the "macro magic" the SPI specific parts will need to be removed from the common macro and arguments for read_flag_mask and write_flag_mask would need to be added to both KSZ_REGMAP_TABLE and KSZ_REGMAP_TABLE. That would leave us with two macros that have 7 arguments. Not really an improvement IMHO. Alternatively we could have different macros for SPI and I2C (or not use the macros at all and define the i2c regmaps in ksz9477_i2c.c) at the cost of ~20 lines of duplication. I prefer the "macro magic" approach, however if you won't let the patch through the way it is I'll respect your decision, just let me know which of the three proposed approaches you want to go with.
Quoted 2 lines
Andrew
Cheers,
George
PATCH v2 2/3 net: dsa: microchip: add ksz9567 to ksz9477 driver
In reply to George McCollisterAdd support for the KSZ9567 7-Port Gigabit Ethernet Switch to the ksz9477 driver. The KSZ9567 supports both SPI and I2C. Oddly the ksz9567 is already in the device tree binding documentation.
---
Changes since v1:
- Added Reviewed-by.
drivers/net/dsa/microchip/ksz9477.c | 9 +++++++++ drivers/net/dsa/microchip/ksz9477_i2c.c | 1 + drivers/net/dsa/microchip/ksz9477_spi.c | 1 + 3 files changed, 11 insertions(+)
drivers/net/dsa/microchip/ksz9477.c +9 -0
@@ -1529,6 +1529,15 @@ static const struct ksz_chip_data ksz9477_switch_chips[] = { .cpu_ports = 0x07, /* can be configured as cpu port */ .port_cnt = 3, /* total port count */ }, + { + .chip_id = 0x00956700, + .dev_name = "KSZ9567", + .num_vlans = 4096, + .num_alus = 4096, + .num_statics = 16, + .cpu_ports = 0x7F, /* can be configured as cpu port */ + .port_cnt = 7, /* total physical port count */ + }, };static int ksz9477_switch_init (struct ksz_device *dev)
drivers/net/dsa/microchip/ksz9477_i2c.c +1 -0
@@ -77,6 +77,7 @@ MODULE_DEVICE_TABLE(i2c, ksz9477_i2c_id);static const struct of_device_id ksz9477_dt_ids[] = { { .compatible ="microchip,ksz9477" }, { .compatible ="microchip,ksz9897" }, + { .compatible ="microchip,ksz9567" }, {}, };MODULE_DEVICE_TABLE (of, ksz9477_dt_ids);
drivers/net/dsa/microchip/ksz9477_spi.c +1 -0
@@ -81,6 +81,7 @@ static const struct of_device_id ksz9477_dt_ids[] = { { .compatible = "microchip,ksz9893" }, { .compatible = "microchip,ksz9563" }, { .compatible = "microchip,ksz8563" }, + { .compatible = "microchip,ksz9567" }, {}, };MODULE_DEVICE_TABLE (of, ksz9477_dt_ids);
Signature · 1 line
2.11.0
Re: [PATCH net-next v2 2/3] net: dsa: microchip: add ksz9567 to ksz9477 driver
Quoted 6 lines · George McCollister
Add support for the KSZ9567 7-Port Gigabit Ethernet Switch to the ksz9477 driver. The KSZ9567 supports both SPI and I2C. Oddly the ksz9567 is already in the device tree binding documentation.
Signed-off-by George McCollister <[email protected]>Reviewed-by Marek Vasut <[email protected]>
Andrew
Re: [PATCH net-next v2 2/3] net: dsa: microchip: add ksz9567 to ksz9477 driver
In reply to George McCollisterQuoted 6 lines · George McCollister
Add support for the KSZ9567 7-Port Gigabit Ethernet Switch to the ksz9477 driver. The KSZ9567 supports both SPI and I2C. Oddly the ksz9567 is already in the device tree binding documentation.
Signed-off-by George McCollister <[email protected]>Reviewed-by Marek Vasut <[email protected]>
Signature · 1 line
Florian
PATCH v2 3/3 net: dsa: microchip: remove NET_DSA_TAG_KSZ_COMMON
In reply to George McCollisterRemove the superfluous NET_DSA_TAG_KSZ_COMMON and just use the existing NET_DSA_TAG_KSZ. Update the description to mention the three switch families it supports. No functional change.
---
Changes since v1:
- Added Reviewed-by.
net/dsa/Kconfig | 9 ++------- net/dsa/Makefile | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-)
net/dsa/Kconfig +2 -7
@@ -73,16 +73,11 @@ config NET_DSA_TAG_MTK Say Y or M if you want to enable support for tagging frames for Mediatek switches. -config NET_DSA_TAG_KSZ_COMMON - tristate - default n - config NET_DSA_TAG_KSZ - tristate "Tag driver for Microchip 9893 family of switches" - select NET_DSA_TAG_KSZ_COMMON + tristate "Tag driver for Microchip 8795/9477/9893 families of switches" help Say Y if you want to enable support for tagging frames for the - Microchip 9893 family of switches. + Microchip 8795/9477/9893 families of switches. config NET_DSA_TAG_QCA tristate "Tag driver for Qualcomm Atheros QCA8K switches"
net/dsa/Makefile +1 -1
@@ -9,7 +9,7 @@ obj-$(CONFIG_NET_DSA_TAG_BRCM_COMMON) += tag_brcm.o obj-$(CONFIG_NET_DSA_TAG_DSA) += tag_dsa.o obj-$(CONFIG_NET_DSA_TAG_EDSA) += tag_edsa.o obj-$(CONFIG_NET_DSA_TAG_GSWIP) += tag_gswip.o -obj-$(CONFIG_NET_DSA_TAG_KSZ_COMMON) += tag_ksz.o +obj-$(CONFIG_NET_DSA_TAG_KSZ) += tag_ksz.o obj-$(CONFIG_NET_DSA_TAG_LAN9303) += tag_lan9303.o obj-$(CONFIG_NET_DSA_TAG_MTK) += tag_mtk.o obj-$(CONFIG_NET_DSA_TAG_QCA) += tag_qca.o
Signature · 1 line
2.11.0
Re: [PATCH net-next v2 3/3] net: dsa: microchip: remove NET_DSA_TAG_KSZ_COMMON
Quoted 6 lines · George McCollister
Remove the superfluous
NET_DSA_TAG_KSZ_COMMONand just use the existingNET_DSA_TAG_KSZ. Update the description to mention the three switch families it supports. No functional change.Signed-off-by George McCollister <[email protected]>Reviewed-by Marek Vasut <[email protected]>
Signature · 1 line
Florian
Re: [PATCH net-next v2 3/3] net: dsa: microchip: remove NET_DSA_TAG_KSZ_COMMON
In reply to George McCollisterQuoted 6 lines · George McCollister
Remove the superfluous
NET_DSA_TAG_KSZ_COMMONand just use the existingNET_DSA_TAG_KSZ. Update the description to mention the three switch families it supports. No functional change.Signed-off-by George McCollister <[email protected]>Reviewed-by Marek Vasut <[email protected]>
Andrew
David Miller
maintainerFrom: George McCollister <[email protected]>
Date: Tue, 10 Sep 2019 08:18:33 -0500
Quoted 4 lines
Resurrect KSZ9477 I2C driver support patch originally sent to the list by Tristram Ha and resolve outstanding issues. It now works as similarly to the ksz9477 SPI driver as possible, using the same regmap macros.
Quoted 8 lines
Add support for ksz9567 to the ksz9477 driver (tested on a board with ksz9567 connected via I2C).
Remove
NET_DSA_TAG_KSZ_COMMONsince it's not needed.Changes since v1:
Putksz9477_i2c.cincludes in alphabetical order.
Added Reviewed-Bys.
Series applied.
Please follow up with Andrew about the macros.
Thanks.