Skip to contentSkip to conversation

net: dsa: microchip: Add LAN9646 switch support

PATCH Applied [email protected] 3 participants 5 messages Nov 9, 2024 – Nov 14, 2024

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover net: dsa: microchip: Add LAN9646 switch support

From: Tristram Ha <[email protected]>

This series of patches is to add LAN9646 switch support to the KSZ DSA driver.

Tristram Ha (2):
dt-bindings: net: dsa: microchip: Add LAN9646 switch support
net: dsa: microchip: Add LAN9646 switch support to KSZ DSA driver

 .../bindings/net/dsa/microchip,ksz.yaml       |  1 +
 drivers/net/dsa/microchip/ksz9477.c           |  4 ++
 drivers/net/dsa/microchip/ksz9477_i2c.c       | 14 +++++-
 drivers/net/dsa/microchip/ksz_common.c        | 50 ++++++++++++++++++-
 drivers/net/dsa/microchip/ksz_common.h        |  1 +
 drivers/net/dsa/microchip/ksz_spi.c           |  7 +++
 include/linux/platform_data/microchip-ksz.h   |  1 +
 7 files changed, 75 insertions(+), 3 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/2 dt-bindings: net: dsa: microchip: Add LAN9646 switch support

From: Tristram Ha <[email protected]>

LAN9646 switch is a 6-port switch with functions like KSZ9897. It has 4 internal PHYs and 1 SGMII port.

---
 Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml +1 -0
index 30c0c3e6f37a..c3502876276d 100644
@@ -34,6 +34,7 @@ properties:
       - microchip,ksz9563
       - microchip,ksz8563
       - microchip,ksz8567
+      - microchip,lan9646
 
   reset-gpios:
     description:
Signature · 1 line
2.34.1
Acked-by on v1 1/2
#2 lore raw

Re: [PATCH net-next 1/2] dt-bindings: net: dsa: microchip: Add LAN9646 switch support

Quoted 9 lines · On Fri, Nov 08, 2024 at 05:57:04PM -0800, [email protected] wrote:

From: Tristram Ha <[email protected]>

LAN9646 switch is a 6-port switch with functions like KSZ9897. It has 4 internal PHYs and 1 SGMII port.

---
 Documentation/devicetree/bindings/net/dsa/microchip,ksz.yaml | 1 +
 1 file changed, 1 insertion(+)

Best regards,
Krzysztof

#3 lore raw

PATCH 2/2 net: dsa: microchip: Add LAN9646 switch support to KSZ DSA driver

In reply to [email protected]

From: Tristram Ha <[email protected]>

LAN9646 switch is a 6-port switch with functions like KSZ9897. It has 4 internal PHYs and 1 SGMII port. The chip id read from hardware is same as KSZ9477, so software driver needs to create a new chip id and group allowable functions under its chip data structure to differentiate the product.

---
 drivers/net/dsa/microchip/ksz9477.c         |  4 ++
 drivers/net/dsa/microchip/ksz9477_i2c.c     | 14 +++++-
 drivers/net/dsa/microchip/ksz_common.c      | 50 ++++++++++++++++++++-
 drivers/net/dsa/microchip/ksz_common.h      |  1 +
 drivers/net/dsa/microchip/ksz_spi.c         |  7 +++
 include/linux/platform_data/microchip-ksz.h |  1 +
 6 files changed, 74 insertions(+), 3 deletions(-)
drivers/net/dsa/microchip/ksz9477.c +4 -0
index 0ba658a72d8f..d16817e0476f 100644
@@ -1131,6 +1131,10 @@ void ksz9477_config_cpu_port(struct dsa_switch *ds)
 		if (i == dev->cpu_port)
 			continue;
 		ksz_port_stp_state_set(ds, i, BR_STATE_DISABLED);
+
+		/* Power down the internal PHY if port is unused. */
+		if (dsa_is_unused_port(ds, i) && dev->info->internal_phy[i])
+			ksz_pwrite16(dev, i, 0x100, BMCR_PDOWN);
 	}
 }
 
drivers/net/dsa/microchip/ksz9477_i2c.c +13 -1
index 7d7560f23a73..1c6d7fc16772 100644
@@ -2,7 +2,7 @@
 /*
  * Microchip KSZ9477 series register access through I2C
  *
- * Copyright (C) 2018-2019 Microchip Technology Inc.
+ * Copyright (C) 2018-2024 Microchip Technology Inc.
  */
 
 #include <linux/i2c.h>
@@ -16,6 +16,8 @@ KSZ_REGMAP_TABLE(ksz9477, not_used, 16, 0, 0);
 
 static int ksz9477_i2c_probe(struct i2c_client *i2c)
 {
+	const struct ksz_chip_data *chip;
+	struct device *ddev = &i2c->dev;
 	struct regmap_config rc;
 	struct ksz_device *dev;
 	int i, ret;
@@ -24,6 +26,12 @@ static int ksz9477_i2c_probe(struct i2c_client *i2c)
 	if (!dev)
 		return -ENOMEM;
 
+	chip = device_get_match_data(ddev);
+	if (!chip)
+		return -EINVAL;
+
+	/* Save chip id to do special initialization when probing. */
+	dev->chip_id = chip->chip_id;
 	for (i = 0; i < __KSZ_NUM_REGMAPS; i++) {
 		rc = ksz9477_regmap_config[i];
 		rc.lock_arg = &dev->regmap_mutex;
@@ -111,6 +119,10 @@ static const struct of_device_id ksz9477_dt_ids[] = {
 		.compatible = "microchip,ksz9567",
 		.data = &ksz_switch_chips[KSZ9567]
 	},
+	{
+		.compatible = "microchip,lan9646",
+		.data = &ksz_switch_chips[LAN9646]
+	},
 	{},
 };
 MODULE_DEVICE_TABLE(of, ksz9477_dt_ids);
drivers/net/dsa/microchip/ksz_common.c +48 -2

110 lines not on this page · raw message

drivers/net/dsa/microchip/ksz_common.h +1 -0
index bec846e20682..719bf2f8a524 100644
@@ -214,6 +214,7 @@ enum ksz_model {
 	LAN9372,
 	LAN9373,
 	LAN9374,
+	LAN9646,
 };
 
 enum ksz_regs {
drivers/net/dsa/microchip/ksz_spi.c +7 -0
index 1c6652f2b9fe..108a958dc356 100644
@@ -54,6 +54,8 @@ static int ksz_spi_probe(struct spi_device *spi)
 	if (!chip)
 		return -EINVAL;
 
+	/* Save chip id to do special initialization when probing. */
+	dev->chip_id = chip->chip_id;
 	if (chip->chip_id == KSZ88X3_CHIP_ID)
 		regmap_config = ksz8863_regmap_config;
 	else if (chip->chip_id == KSZ8795_CHIP_ID ||
@@ -203,6 +205,10 @@ static const struct of_device_id ksz_dt_ids[] = {
 		.compatible = "microchip,lan9374",
 		.data = &ksz_switch_chips[LAN9374]
 	},
+	{
+		.compatible = "microchip,lan9646",
+		.data = &ksz_switch_chips[LAN9646]
+	},
 	{},
 };
 MODULE_DEVICE_TABLE(of, ksz_dt_ids);
@@ -228,6 +234,7 @@ static const struct spi_device_id ksz_spi_ids[] = {
 	{ "lan9372" },
 	{ "lan9373" },
 	{ "lan9374" },
+	{ "lan9646" },
 	{ },
 };
 MODULE_DEVICE_TABLE(spi, ksz_spi_ids);
include/linux/platform_data/microchip-ksz.h +1 -0
index 2ee1a679e592..0e0e8fe6975f 100644
@@ -42,6 +42,7 @@ enum ksz_chip_id {
 	LAN9372_CHIP_ID = 0x00937200,
 	LAN9373_CHIP_ID = 0x00937300,
 	LAN9374_CHIP_ID = 0x00937400,
+	LAN9646_CHIP_ID = 0x00964600,
 };
 
 struct ksz_platform_data {
Signature · 1 line
2.34.1
#4 lore raw
In reply to [email protected]
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Fri, 8 Nov 2024 17:57:03 -0800 you wrote:

From: Tristram Ha <[email protected]>

This series of patches is to add LAN9646 switch support to the KSZ DSA driver.

Tristram Ha (2):
dt-bindings: net: dsa: microchip: Add LAN9646 switch support
net: dsa: microchip: Add LAN9646 switch support to KSZ DSA driver

[...]

Here is the summary with links:
- [net-next,1/2] dt-bindings: net: dsa: microchip: Add LAN9646 switch support

    https://git.kernel.org/netdev/net-next/c/3a371e10521d
  - [net-next,2/2] net: dsa: microchip: Add LAN9646 switch support to KSZ DSA driver
    https://git.kernel.org/netdev/net-next/c/16220cb315a0

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html