From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (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 3FA5D3F44D7 for ; Mon, 27 Jul 2026 10:21:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785147663; cv=none; b=gGzkaro5twFoawlxSX4EEduxz/rqNW3Fi52zUza0Q1H0qQi40mdHlOLfwB5XY2R7q/7GB4D1OMsONFsQ+j7Jbk5rWhC0sd+I3NY73kMmXE7474bzlOjqC6j9xPIRqDqEp+/w25Lh/eMlmO6pjqU/oU8e3cfAtfi/0u9gdcH1xIs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785147663; c=relaxed/simple; bh=BIDRldgZwguuxTScvq7SIry4n11WrGF0Y9q5s1x/4pc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XNx8BLz9EIS+o4w0TiZJVYQNK/0uaD6GOSf7pGADZzsNA/BNJD4YDTUYBFEf8jKax6Ur9ZIgaUnjTvkT2CAJbu9Lf1q4hRr3RuQstbfNf8fSMID2bQha3AEu4kSroPpKX8XrbhlsD8buyZsyvuEMk9tROcYBqGYx/8Tb9Zx74Fk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=V42x8F2I; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="V42x8F2I" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id A18BE4E40F98; Mon, 27 Jul 2026 10:20:59 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 74986601BE; Mon, 27 Jul 2026 10:20:59 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 016D211C131B5; Mon, 27 Jul 2026 12:20:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1785147658; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=Ih3eQKvCXt+AE7A7jpmRaaKpONc/RrDX6tZZblgWFo4=; b=V42x8F2IBJwM5gHxDnr7YFECEDeUagYxbSWWmTmIkSrEhxNhNnkV3ceB0q4JoGEYXnu5+r JUCMXSo5P21KfzqlgHFgWIL/XAArMnRG9CVxNnEAE3yywsffhrZtK4ronfv/73vSqwzENG slQAKqO8Yz/3RETQBbV/Uq+BHytE46ACMc5Z8J8aDCeaJQl/yz8sFY1vPSDuqIk32hIHbu HiUEe8RLhd536SXd77+zCVvmJE5wUpBTD4Srd8L02w+OT529M9latpLdIawKEJj/X9IfZG xKxVmeYA/jgyWZAIvIrqKZPI7hmLz2bS1WujLC+kgWza1egq6KVCBML3HMYHuw== From: "Bastien Curutchet (Schneider Electric)" Date: Mon, 27 Jul 2026 12:20:44 +0200 Subject: [PATCH net-next v3 02/10] net: dsa: microchip: split ksz8_config_cpu_port() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260727-ksz-new-ptp-v3-2-caba39e680e3@bootlin.com> References: <20260727-ksz-new-ptp-v3-0-caba39e680e3@bootlin.com> In-Reply-To: <20260727-ksz-new-ptp-v3-0-caba39e680e3@bootlin.com> To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Russell King , Simon Horman , Maxime Chevallier Cc: Pascal Eberhard , =?utf-8?q?Miqu=C3=A8l_Raynal?= , Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Bastien Curutchet (Schneider Electric)" X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 ksz8_config_cpu_port() is only called twice, once by ksz8_setup() and once by ksz8463_setup(). It contains a ksz8463 branch that could be avoided in the ksz8_setup() case and a ksz87xx/ksz88xx branches that could be avoided in ksz8463_setup() case. Create ksz8463_config_cpu_port() that only handles the ksz8463 case and remove the ksz8463 specificities from the common ksz8_config_cpu_port(). Signed-off-by: Bastien Curutchet (Schneider Electric) --- drivers/net/dsa/microchip/ksz8.c | 73 +++++++++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 28 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz8.c b/drivers/net/dsa/microchip/ksz8.c index 5ed63f425013..3bbca6f9cfc5 100644 --- a/drivers/net/dsa/microchip/ksz8.c +++ b/drivers/net/dsa/microchip/ksz8.c @@ -2029,6 +2029,50 @@ static void ksz88x3_config_rmii_clk(struct ksz_device *dev) KSZ88X3_PORT3_RMII_CLK_INTERNAL, rmii_clk_internal); } +static void ksz8463_config_cpu_port(struct dsa_switch *ds) +{ + struct ksz_device *dev = ds->priv; + struct ksz_port *p; + u8 fiber_ports = 0; + const u32 *masks; + const u16 *regs; + int i; + + masks = dev->info->masks; + regs = dev->info->regs; + + ksz_cfg(dev, regs[S_TAIL_TAG_CTRL], masks[SW_TAIL_TAG_ENABLE], true); + + ksz8_port_setup(dev, dev->cpu_port, true); + + for (i = 0; i < dev->phy_port_cnt; i++) + ksz_port_stp_state_set(ds, i, BR_STATE_DISABLED); + + for (i = 0; i < dev->phy_port_cnt; i++) { + p = &dev->ports[i]; + ksz_port_cfg(dev, i, regs[P_STP_CTRL], PORT_FORCE_FLOW_CTRL, + p->fiber); + if (p->fiber) + fiber_ports |= (1 << i); + } + + /* Setup fiber ports. */ + if (fiber_ports) { + fiber_ports &= 3; + regmap_update_bits(ksz_regmap_16(dev), KSZ8463_REG_CFG_CTRL, + fiber_ports << PORT_COPPER_MODE_S, + 0); + regmap_update_bits(ksz_regmap_16(dev), KSZ8463_REG_DSP_CTRL_6, + COPPER_RECEIVE_ADJUSTMENT, 0); + } + + /* Turn off PTP function as the switch enables it by default */ + regmap_update_bits(ksz_regmap_16(dev), KSZ8463_PTP_MSG_CONF1, + PTP_ENABLE, 0); + regmap_update_bits(ksz_regmap_16(dev), KSZ8463_PTP_CLK_CTRL, + PTP_CLK_ENABLE, 0); +} + static void ksz8_config_cpu_port(struct dsa_switch *ds) { struct ksz_device *dev = ds->priv; @@ -2036,7 +2080,6 @@ static void ksz8_config_cpu_port(struct dsa_switch *ds) const u32 *masks; const u16 *regs; u8 remote; - u8 fiber_ports = 0; int i; masks = dev->info->masks; @@ -2067,32 +2110,6 @@ static void ksz8_config_cpu_port(struct dsa_switch *ds) else ksz_port_cfg(dev, i, regs[P_STP_CTRL], PORT_FORCE_FLOW_CTRL, false); - if (p->fiber) - fiber_ports |= (1 << i); - } - if (ksz_is_ksz8463(dev)) { - /* Setup fiber ports. */ - if (fiber_ports) { - fiber_ports &= 3; - regmap_update_bits(ksz_regmap_16(dev), - KSZ8463_REG_CFG_CTRL, - fiber_ports << PORT_COPPER_MODE_S, - 0); - regmap_update_bits(ksz_regmap_16(dev), - KSZ8463_REG_DSP_CTRL_6, - COPPER_RECEIVE_ADJUSTMENT, 0); - } - - /* Turn off PTP function as the switch's proprietary way of - * handling timestamp is not supported in current Linux PTP - * stack implementation. - */ - regmap_update_bits(ksz_regmap_16(dev), - KSZ8463_PTP_MSG_CONF1, - PTP_ENABLE, 0); - regmap_update_bits(ksz_regmap_16(dev), - KSZ8463_PTP_CLK_CTRL, - PTP_CLK_ENABLE, 0); } } @@ -2332,7 +2349,7 @@ static int ksz8463_setup(struct dsa_switch *ds) regmap_update_bits(ksz_regmap_16(dev), regs[S_BROADCAST_CTRL], storm_mask, storm_rate); - ksz8_config_cpu_port(ds); + ksz8463_config_cpu_port(ds); ksz8_enable_stp_addr(dev); -- 2.55.0