From patchwork Tue Jan 24 10:11:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 47633 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2070945wrn; Tue, 24 Jan 2023 02:25:25 -0800 (PST) X-Google-Smtp-Source: AMrXdXvCLi55aQzTRi5hVJ4pR9E+YyVSyjNRVLOSHW7T485wDgkDSoXD8SeGjBOuMumki+LB+mqs X-Received: by 2002:a17:907:6e2a:b0:871:e9a0:eba7 with SMTP id sd42-20020a1709076e2a00b00871e9a0eba7mr72707766ejc.57.1674555914299; Tue, 24 Jan 2023 02:25:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674555914; cv=none; d=google.com; s=arc-20160816; b=A3PtFayjR81odgxIWrkpmlFq8TTDavRwutHfMK1mP3RWQ9Krzea7GiSdYfGHGiZlI+ 1S1lC48yOQomqIlp+pO87TiqvtVFrgHXucMtQEUxTGXCVKFPA0WS3XP+NqXXQfEo3CZK fNEZiaKwZnFjeaJ0iDh/LNT0Pp6LG1tKAejvWoi/wdHnx5u7rP4JrzPHMQOl4qphGBZn HIUgjudyJjVs4752TsiGzrd5IjBTeV1Bb+8WWerxhwxh0teg4eRRD4c5BiKJxYnBN0Ds 1pSh6AUMbP1Si7IQZjcftcSH79RjIV0A9Y77bQ3pnkzMO/Nzo2yhb2DUos0CzEfW5qur BNKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=S8taYkiDRhxwSj2khSrYXtScgLWDxF1GD5X3Ip5sSGs=; b=mvmNlBbb8WGwEvyMvseFTNwP9V8GaGLvURIXcY38LHoMFFTWEZTLzJnk6aUu7CL0Lx uS+bE/9TuZRKLwQYTQ6rVqoiADhZBEWrXwiAkj6GSDMDuSkXCO9wWd8+SaSojw+1gniA 4nGgxB50Sqw3GmwmkmGSm7YK0+8Lz1rOsOV2OrBg6WVJdc+g1zlRfIcxp7J1SBbWkDAz OX5+hVQifIgqurr7RxCVvGXJN2GdbJFtSDpfwfH2/hHS6McNhNBaHumE3C3iuM7CInaw ISusZIB+TC0OYYSGXIqi1bNam8+Yk1CzUdWI1QTO2gdlBjYw6nUUWUhzNIILaMQ5StsO ZDbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=LLp84wia; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t25-20020a170906c39900b0087315952143si2019375ejz.146.2023.01.24.02.24.50; Tue, 24 Jan 2023 02:25:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=LLp84wia; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233788AbjAXKNx (ORCPT + 99 others); Tue, 24 Jan 2023 05:13:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233783AbjAXKNo (ORCPT ); Tue, 24 Jan 2023 05:13:44 -0500 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 301B841B6B for ; Tue, 24 Jan 2023 02:13:36 -0800 (PST) Received: by mail-wr1-x431.google.com with SMTP id b7so13360960wrt.3 for ; Tue, 24 Jan 2023 02:13:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=S8taYkiDRhxwSj2khSrYXtScgLWDxF1GD5X3Ip5sSGs=; b=LLp84wiadrhwgCkt5Iy//WkgeSBuROH6t0YeHNNNAtMvdohLlAiDAEDkQPNjfHsmOa SnQ0Hqj7fFh3RIR5ryXAvuJ0MXz2o3AGYojvwuFBQduvyX/fuU/CEGjXqQfOeXvm+B2N 38hUhIMVdjhF5Nde8peUn0fcZMHn89MyndOYvmVILwVapZkIIxp9Y/31L8hlcaXu1c3D FVnhP2FqR8jz8PfwwArxgb2uEFfXPo+3gwiHeIxg6C4RfRd9K8uhnGtl99WC50CBqpI2 fUKxyd6/aSmt4uHQl5nWmHv218zWtiUOPfENRl1AQNL9E5m3KmwTPCG21C6QBzfoRdtL t/wQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=S8taYkiDRhxwSj2khSrYXtScgLWDxF1GD5X3Ip5sSGs=; b=JayVTtkHBs/1BkSGswBc9xR5/v2Hj3z6PMMdTvoI1ov6EIaKmGeRGTZElmHQvRtYfx gXlRJuuGoM3ekhJTUlgLltLJxHAJTw7u5Thq1lBdMTc33T1jZmuFf8QEVZtS42eRcEpe Cbr4lcUz5xvaf6T7WwgSv5jLSeEbNSEXWcIEYHpBwJEnCCyAGDRdUTrYAV8CmGpoPSi7 ur4eDVMkCI350m+diUb6Ce+4ngzTQ4FUTh5+GBSebSDTL+UEEujbbmcWz7YvLmPnTssc v5ekWfytppartENVpOhObD6TJD+Zf8wSbbMMKFVb8PWu/ZdSwqLCfvtMyUoSrQK2gCou kB8A== X-Gm-Message-State: AO0yUKUU1DFvv8b/LoK1NcUd6ITH4E5UYvteoYxfvvjyKB/hFDgY82gL qNggVskkEnAO8CZ8cGkqlVnRUQ== X-Received: by 2002:adf:fa09:0:b0:2bf:ac2c:4489 with SMTP id m9-20020adffa09000000b002bfac2c4489mr2351847wrr.54.1674555214568; Tue, 24 Jan 2023 02:13:34 -0800 (PST) Received: from localhost.localdomain (laubervilliers-658-1-213-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.googlemail.com with ESMTPSA id r1-20020a0560001b8100b002bfae16ee2fsm1452595wru.111.2023.01.24.02.13.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Jan 2023 02:13:34 -0800 (PST) From: Jerome Brunet To: netdev@vger.kernel.org, "David S. Miller" , Andrew Lunn Cc: Jerome Brunet , linux-amlogic@lists.infradead.org, Kevin Hilman , Neil Armstrong , linux-kernel@vger.kernel.org, Heiner Kallweit , Qi Duan Subject: [PATCH v2 net] net: mdio-mux-meson-g12a: force internal PHY off on mux switch Date: Tue, 24 Jan 2023 11:11:57 +0100 Message-Id: <20230124101157.232234-1-jbrunet@baylibre.com> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 X-Patchwork-Bot: notify X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755899142548345466?= X-GMAIL-MSGID: =?utf-8?q?1755899142548345466?= Force the internal PHY off then on when switching to the internal path. This fixes problems where the PHY ID is not properly set. Fixes: 7090425104db ("net: phy: add amlogic g12a mdio mux support") Suggested-by: Qi Duan Co-developed-by: Heiner Kallweit Signed-off-by: Heiner Kallweit Signed-off-by: Jerome Brunet --- Changes since v1: - Fix variable position for reverse Xmas tree requirement. The initial discussion about this change can be found here: https://lore.kernel.org/all/1j4jslwen5.fsf@starbuckisacylon.baylibre.com/ drivers/net/mdio/mdio-mux-meson-g12a.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/net/mdio/mdio-mux-meson-g12a.c b/drivers/net/mdio/mdio-mux-meson-g12a.c index 4a2e94faf57e..c4542ecf5623 100644 --- a/drivers/net/mdio/mdio-mux-meson-g12a.c +++ b/drivers/net/mdio/mdio-mux-meson-g12a.c @@ -4,6 +4,7 @@ */ #include +#include #include #include #include @@ -150,6 +151,7 @@ static const struct clk_ops g12a_ephy_pll_ops = { static int g12a_enable_internal_mdio(struct g12a_mdio_mux *priv) { + u32 value; int ret; /* Enable the phy clock */ @@ -163,18 +165,25 @@ static int g12a_enable_internal_mdio(struct g12a_mdio_mux *priv) /* Initialize ephy control */ writel(EPHY_G12A_ID, priv->regs + ETH_PHY_CNTL0); - writel(FIELD_PREP(PHY_CNTL1_ST_MODE, 3) | - FIELD_PREP(PHY_CNTL1_ST_PHYADD, EPHY_DFLT_ADD) | - FIELD_PREP(PHY_CNTL1_MII_MODE, EPHY_MODE_RMII) | - PHY_CNTL1_CLK_EN | - PHY_CNTL1_CLKFREQ | - PHY_CNTL1_PHY_ENB, - priv->regs + ETH_PHY_CNTL1); + + /* Make sure we get a 0 -> 1 transition on the enable bit */ + value = FIELD_PREP(PHY_CNTL1_ST_MODE, 3) | + FIELD_PREP(PHY_CNTL1_ST_PHYADD, EPHY_DFLT_ADD) | + FIELD_PREP(PHY_CNTL1_MII_MODE, EPHY_MODE_RMII) | + PHY_CNTL1_CLK_EN | + PHY_CNTL1_CLKFREQ; + writel(value, priv->regs + ETH_PHY_CNTL1); writel(PHY_CNTL2_USE_INTERNAL | PHY_CNTL2_SMI_SRC_MAC | PHY_CNTL2_RX_CLK_EPHY, priv->regs + ETH_PHY_CNTL2); + value |= PHY_CNTL1_PHY_ENB; + writel(value, priv->regs + ETH_PHY_CNTL1); + + /* The phy needs a bit of time to power up */ + mdelay(10); + return 0; }