From nobody Wed Apr 1 14:08:24 2026 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 410E83A544E; Tue, 31 Mar 2026 10:04:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774951459; cv=none; b=AZnnxFKYtWwEM5YP0Y6qfeyp40rS5RpaHOxcUIzPSnGV9TCG5u5v6X1XWCzTci+/AgZNKngzm7vjFd+FlXqr/QE8V08puMrMN5KptMhFEzKgaUjCpLYU6r+LyDAOi6GQoSOZpr6YO19QqAXaWU+0rNi0PcFulVtIGigrAYQy+Jg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774951459; c=relaxed/simple; bh=aqwo6YDRLA2mVz94WYaEU1NWDqPecZfQ0fOXF3ovnY0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pi9h+L3Q3PSWeuWR43oVZ9Nqb3MSao86Pea+2977agJFwU7bA3DaRb5rmi7LMbe/ZDK760Y68Z6Ko+KYtxJ2Deyy5Dkf2bAPw3zp6ZJyqnj21o7Xmz6ZICKIE3fYCI9ygW71sy0sUM0aq8Y7JPHHUKx+87IgSAPEAFibQ4flkKM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com; spf=pass smtp.mailfrom=renesas.com; arc=none smtp.client-ip=210.160.252.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=renesas.com X-CSE-ConnectionGUID: Uh497dTgTGiqcxqODgNM9A== X-CSE-MsgGUID: /XF8lVXlTt6CWlTLQcrKaQ== Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 31 Mar 2026 19:04:10 +0900 Received: from [127.0.1.1] (unknown [10.226.78.135]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id F15B2416C823; Tue, 31 Mar 2026 19:04:06 +0900 (JST) From: Michael Dege Date: Tue, 31 Mar 2026 12:03:55 +0200 Subject: [PATCH net-next v3 01/13] net: renesas: rswitch: improve port change mode functions 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: quoted-printable Message-Id: <20260331-rswitch_add_vlans-v3-1-c37f41b1c556@renesas.com> References: <20260331-rswitch_add_vlans-v3-0-c37f41b1c556@renesas.com> In-Reply-To: <20260331-rswitch_add_vlans-v3-0-c37f41b1c556@renesas.com> To: Yoshihiro Shimoda , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?q?Niklas_S=C3=B6derlund?= , Paul Barker Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Dege X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1774951442; l=3529; i=michael.dege@renesas.com; s=20251023; h=from:subject:message-id; bh=aqwo6YDRLA2mVz94WYaEU1NWDqPecZfQ0fOXF3ovnY0=; b=lOC13aZSa196mt5Ii+fYj+aWJwzBUrL/t0pHWT8YuMExIKqjRSLg+EKYDBT/w6m7lMMheQ4B6 +Y+KKmtXZqrD0zFKPwmWOYhWJUBN1Wru76OpmTOs+5uugTBGMyoDGvi X-Developer-Key: i=michael.dege@renesas.com; a=ed25519; pk=gu1rwIcCrAxNMv2I8fIfiQvt51xzZwnQy4Ua/DscQt8= For ETHA and GWCA ports every mode change from operational to configuration and vice-versa requires to change the mode to "disable" first. This was done by calling the function twice. Let the change_mode functione take care of this requiered step in a single call. Signed-off-by: Michael Dege --- drivers/net/ethernet/renesas/rswitch_main.c | 39 +++++++++++++------------= ---- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/drivers/net/ethernet/renesas/rswitch_main.c b/drivers/net/ethe= rnet/renesas/rswitch_main.c index 6fe964816322..f6d1e610e7fa 100644 --- a/drivers/net/ethernet/renesas/rswitch_main.c +++ b/drivers/net/ethernet/renesas/rswitch_main.c @@ -176,14 +176,19 @@ static int rswitch_gwca_change_mode(struct rswitch_pr= ivate *priv, if (!rswitch_agent_clock_is_enabled(priv->addr, priv->gwca.index)) rswitch_agent_clock_ctrl(priv->addr, priv->gwca.index, 1); =20 - iowrite32(mode, priv->addr + GWMC); + iowrite32(GWMC_OPC_DISABLE, priv->addr + GWMC); =20 - ret =3D rswitch_reg_wait(priv->addr, GWMS, GWMS_OPS_MASK, mode); + ret =3D rswitch_reg_wait(priv->addr, GWMS, GWMS_OPS_MASK, GWMC_OPC_DISABL= E); =20 - if (mode =3D=3D GWMC_OPC_DISABLE) + if (mode =3D=3D GWMC_OPC_DISABLE) { rswitch_agent_clock_ctrl(priv->addr, priv->gwca.index, 0); =20 - return ret; + return ret; + } + + iowrite32(mode, priv->addr + GWMC); + + return rswitch_reg_wait(priv->addr, GWMS, GWMS_OPS_MASK, mode); } =20 static int rswitch_gwca_mcast_table_reset(struct rswitch_private *priv) @@ -682,9 +687,6 @@ static int rswitch_gwca_hw_init(struct rswitch_private = *priv) unsigned int i; int err; =20 - err =3D rswitch_gwca_change_mode(priv, GWMC_OPC_DISABLE); - if (err < 0) - return err; err =3D rswitch_gwca_change_mode(priv, GWMC_OPC_CONFIG); if (err < 0) return err; @@ -717,9 +719,6 @@ static int rswitch_gwca_hw_init(struct rswitch_private = *priv) return err; } =20 - err =3D rswitch_gwca_change_mode(priv, GWMC_OPC_DISABLE); - if (err < 0) - return err; return rswitch_gwca_change_mode(priv, GWMC_OPC_OPERATION); } =20 @@ -727,9 +726,6 @@ static int rswitch_gwca_hw_deinit(struct rswitch_privat= e *priv) { int err; =20 - err =3D rswitch_gwca_change_mode(priv, GWMC_OPC_DISABLE); - if (err < 0) - return err; err =3D rswitch_gwca_change_mode(priv, GWMC_OPC_RESET); if (err < 0) return err; @@ -1116,14 +1112,18 @@ static int rswitch_etha_change_mode(struct rswitch_= etha *etha, if (!rswitch_agent_clock_is_enabled(etha->coma_addr, etha->index)) rswitch_agent_clock_ctrl(etha->coma_addr, etha->index, 1); =20 - iowrite32(mode, etha->addr + EAMC); - - ret =3D rswitch_reg_wait(etha->addr, EAMS, EAMS_OPS_MASK, mode); + iowrite32(EAMC_OPC_DISABLE, etha->addr + EAMC); + ret =3D rswitch_reg_wait(etha->addr, EAMS, EAMS_OPS_MASK, EAMC_OPC_DISABL= E); =20 - if (mode =3D=3D EAMC_OPC_DISABLE) + if (mode =3D=3D EAMC_OPC_DISABLE) { rswitch_agent_clock_ctrl(etha->coma_addr, etha->index, 0); =20 - return ret; + return ret; + } + + iowrite32(mode, etha->addr + EAMC); + + return rswitch_reg_wait(etha->addr, EAMS, EAMS_OPS_MASK, mode); } =20 static void rswitch_etha_read_mac_address(struct rswitch_etha *etha) @@ -1203,9 +1203,6 @@ static int rswitch_etha_hw_init(struct rswitch_etha *= etha, const u8 *mac) { int err; =20 - err =3D rswitch_etha_change_mode(etha, EAMC_OPC_DISABLE); - if (err < 0) - return err; err =3D rswitch_etha_change_mode(etha, EAMC_OPC_CONFIG); if (err < 0) return err; --=20 2.43.0