From patchwork Thu Aug 24 15:48:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 13364392 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 39782134DE for ; Thu, 24 Aug 2023 15:48:54 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B44E3199F; Thu, 24 Aug 2023 08:48:52 -0700 (PDT) Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: lukma@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 2054A8609B; Thu, 24 Aug 2023 17:48:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1692892131; bh=H7FM7ibaZ+AGk5z5tKpm5KmKsPsHbA7ASKu0Pd5KuWE=; h=From:To:Cc:Subject:Date:From; b=XQ5ZqWUaW6StxQF2LrjwD437t1fpL1Q+gl3CzHps57TvOvLXbRJdPTfJ+6PBU3K4M JK2ufVxymKLDflSu6BrwFVwm7JotTIb/gP1vz3gSataV/XJwDFIS+49allJTpFYTnr x71ZUgZtQDdMaucvsModMn99Yo9Dcfe3L6c+Vt9aOGs7R6II6/VrGGwanQIosGwj50 56r6zUzBoPCyletjIq2WJXxyGyPqEkkKXmnTWuEqWjuuBHu/b4SXlAOzPzJhASnTyL 90raq2VxV2KNytTurs3Y1pCEhTXTCxZp1GK7vU4tdCdUQcFR9kYYFWtyqWo4cRJ1sk 9lsxFSQQLp3TA== From: Lukasz Majewski To: Woojung Huh , UNGLinuxDriver@microchip.com Cc: Andrew Lunn , Florian Fainelli , Vladimir Oltean , davem@davemloft.net, Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Lukasz Majewski Subject: [PATCH 1/2] net: dsa: microchip: KSZ9477: Provide functions to access MMD registers Date: Thu, 24 Aug 2023 17:48:26 +0200 Message-Id: <20230824154827.166274-1-lukma@denx.de> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Those function are necessary to access MMD (indirect) port registers of the KSZ9477 device. Signed-off-by: Lukasz Majewski --- drivers/net/dsa/microchip/ksz9477.c | 31 +++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c index 83b7f2d5c1ea..cb6aa7c668a8 100644 --- a/drivers/net/dsa/microchip/ksz9477.c +++ b/drivers/net/dsa/microchip/ksz9477.c @@ -43,6 +43,37 @@ static void ksz9477_port_cfg32(struct ksz_device *dev, int port, int offset, bits, set ? bits : 0); } +static void ksz9477_port_mmd_setup(struct ksz_device *dev, uint port, u16 devid, + u16 reg, u16 len) +{ + u16 ctrl = PORT_MMD_OP_DATA_NO_INCR; + + if (len > 1) + ctrl = PORT_MMD_OP_DATA_INCR_RW; + + ksz_pwrite16(dev, port, REG_PORT_PHY_MMD_SETUP, + MMD_SETUP(PORT_MMD_OP_INDEX, devid)); + ksz_pwrite16(dev, port, REG_PORT_PHY_MMD_INDEX_DATA, reg); + ksz_pwrite16(dev, port, REG_PORT_PHY_MMD_SETUP, + MMD_SETUP(ctrl, devid)); +} + +static void ksz9477_port_mmd_read(struct ksz_device *dev, uint port, u16 devid, + u16 reg, u16 *buf, u16 len) +{ + ksz9477_port_mmd_setup(dev, port, devid, reg, len); + for (; len; buf++, len--) + ksz_pread16(dev, port, REG_PORT_PHY_MMD_INDEX_DATA, buf); +} + +static void ksz9477_port_mmd_write(struct ksz_device *dev, uint port, u16 devid, + u16 reg, u16 *buf, u16 len) +{ + ksz9477_port_mmd_setup(dev, port, devid, reg, len); + for (; len; buf++, len--) + ksz_pwrite16(dev, port, REG_PORT_PHY_MMD_INDEX_DATA, *buf); +} + int ksz9477_change_mtu(struct ksz_device *dev, int port, int mtu) { u16 frame_size; From patchwork Thu Aug 24 15:48:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 13364393 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CEAAC14263 for ; Thu, 24 Aug 2023 15:48:55 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D18411BCC; Thu, 24 Aug 2023 08:48:52 -0700 (PDT) Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: lukma@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 1C433865A6; Thu, 24 Aug 2023 17:48:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1692892131; bh=gP8UNuwoakIxdCMV5z1WU/b9JBiDLXA9aRP8LRKsjdw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=glTtxJ2Y9ahB6VC8n56U4h8Yv4aLeK/VP4Rw7n4goI0S2/Y6mdUCcDl9iSXVtz59x 7H9b6jAsKtUgsEiBx8o05Dqj1m4oSx1xug7/8uS6brEPLooU9o1rsy7xgtQ/M4HSjP 6mRhvtAKXCsfVMZMIcqjokzlt2bfeaSm9PUsHc7YXGKctaBjiW4Tf2O6wfLBC9m+Yg 3lMTfqY2nCT30CtqHfpAKsZ47QCBJo/+CYHwHxcJHthdZ3FAxJMXjnEcaljtWAjzT0 fga4xmTmMKfLdJgdelyy1KST4kKyTKsrzfiSefOXszoVjNPRdgnETE+d3pY70/FaNk +tggM73F5UaUA== From: Lukasz Majewski To: Woojung Huh , UNGLinuxDriver@microchip.com Cc: Andrew Lunn , Florian Fainelli , Vladimir Oltean , davem@davemloft.net, Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Lukasz Majewski Subject: [PATCH 2/2] net: dsa: microchip: Provide Module 4 KSZ9477 errata (DS80000754C) Date: Thu, 24 Aug 2023 17:48:27 +0200 Message-Id: <20230824154827.166274-2-lukma@denx.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230824154827.166274-1-lukma@denx.de> References: <20230824154827.166274-1-lukma@denx.de> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org The KSZ9477 errata points out the link up/down problem when EEE is enabled in the device to which the KSZ9477 tries to auto negotiate. The suggested workaround is to clear advertisement EEE registers (accessed as per port MMD one). Signed-off-by: Lukasz Majewski --- drivers/net/dsa/microchip/ksz9477.c | 40 ++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c index cb6aa7c668a8..563f497ba656 100644 --- a/drivers/net/dsa/microchip/ksz9477.c +++ b/drivers/net/dsa/microchip/ksz9477.c @@ -1128,6 +1128,44 @@ int ksz9477_enable_stp_addr(struct ksz_device *dev) return 0; } +static int ksz9477_errata(struct dsa_switch *ds) +{ + struct ksz_device *dev = ds->priv; + u16 val; + int p; + + /* KSZ9477 Errata DS80000754C + * + * Module 4: Energy Efficient Ethernet (EEE) feature select must be + * manually disabled + * The EEE feature is enabled by default, but it is not fully + * operational. It must be manually disabled through register + * controls. If not disabled, the PHY ports can auto-negotiate + * to enable EEE, and this feature can cause link drops when linked + * to another device supporting EEE. + * + * Only PHY ports (dsa user) [0-4] need to have the EEE advertisement + * bits cleared. + */ + + for (p = 0; p < ds->num_ports; p++) { + if (!dsa_is_user_port(ds, p)) + continue; + + ksz9477_port_mmd_read(dev, p, MMD_DEVICE_ID_EEE_ADV, + MMD_EEE_ADV, &val, 1); + + pr_err("%s: PORT: %d val: 0x%x pc: %d\n", __func__, p, val, + ds->num_ports); + + val &= ~(EEE_ADV_100MBIT | EEE_ADV_1GBIT); + ksz9477_port_mmd_write(dev, p, MMD_DEVICE_ID_EEE_ADV, + MMD_EEE_ADV, &val, 1); + } + + return 0; +} + int ksz9477_setup(struct dsa_switch *ds) { struct ksz_device *dev = ds->priv; @@ -1157,7 +1195,7 @@ int ksz9477_setup(struct dsa_switch *ds) /* enable global MIB counter freeze function */ ksz_cfg(dev, REG_SW_MAC_CTRL_6, SW_MIB_COUNTER_FREEZE, true); - return 0; + return ksz9477_errata(ds); } u32 ksz9477_get_port_addr(int port, int offset)