Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2604385rwd; Fri, 2 Jun 2023 11:44:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7+thiwqvaoGkDN8XE8BXb6kBr1/fR0CfCF12K83il7sA9oyBXWfrsdRuhCiM4UqL4x53VW X-Received: by 2002:a17:902:c215:b0:1b1:9b59:fc68 with SMTP id 21-20020a170902c21500b001b19b59fc68mr673723pll.13.1685731457288; Fri, 02 Jun 2023 11:44:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685731457; cv=none; d=google.com; s=arc-20160816; b=djB/BQ5+9cHkNgIeZK5FMaqzv3SfQ4NkoMuiLZDYCEH3sL/IDpeAy1H1R5WNZgjwC0 qxs3Z0Pl8uV9extKlN78V/x55vslhUvKelSZc0vp8bsyqxzUTkgpPRwWukqIH+mWGXWA GL48j2mDsGzGB3gBIuxXdmF/sKxRecoYZ8Itkd/ngUEpKcDF7GgVGi088JuOndxsQJUt xM0CmpQIQVc9DZsZkQtNAzGJpOgjzC2aEPeJW6i97qQ6Gk2KnTszYrVQ1JAkxaqEpPlo 4w7iYtpzreAGtSgiQdxRcjTEGp4/D1LrCCYrAoN9TnRPCorzV+jYW6eKkpN0P8ad6iu9 jZtg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=H3Qpx/+jMmvfQqocna3CXntjxMUQIwtPOt77ODV2isA=; b=wde4BS9xaRvrCr5sTxyf1ikvdcgCv/qTwwbF5VMSP9XkLIfem0qmWxYJLxizbtf0Mt y4CP7+COUgUM1RFZEs1G4/FVUfAnHxgb1L9CITjyNS5AGebMCMExAiQGO7TqRDBr40mO rnVe9UCjXN/InF3d42qu8rvPjw1pu4wJ/W40bY4H5AsAEJesRXA2Edxf88lKSnYZNyu3 kct0sruXbs12a/hTEQZ4i6YRZad0MR/wk30f0fNi1VSXvzWd4v+BpiTLH4cQm+gCaWXo jHa4D7Miu2tczl0hsgMbhrTb2+WI7J2wYo4/xm8m5tc4a5xw8dYunqdtClBS3iAREhmD O9/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=O6YWzhwu; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n1-20020a170902dc8100b001add3e4ee84si1290187pld.132.2023.06.02.11.44.02; Fri, 02 Jun 2023 11:44:17 -0700 (PDT) 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=@collabora.com header.s=mail header.b=O6YWzhwu; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236869AbjFBS1N (ORCPT + 99 others); Fri, 2 Jun 2023 14:27:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236128AbjFBS1L (ORCPT ); Fri, 2 Jun 2023 14:27:11 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0ED1018C; Fri, 2 Jun 2023 11:27:10 -0700 (PDT) Received: from arisu.hitronhub.home (unknown [23.233.251.139]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: detlev) by madras.collabora.co.uk (Postfix) with ESMTPSA id 442146606ED9; Fri, 2 Jun 2023 19:27:07 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1685730428; bh=Bhe0llT4DF8ZqHEPdTT4fQ2FZEjkEvA9p05FaGSuRXs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O6YWzhwuoHa0va1FR4AvEuwCw7FFiMWU9MoNvKXcKDqu80zNoLdWl3i8xSDl0Vf4S 0B3K8Ccml1Ures4OmFJA+w70k88KLkaRG3ZNlXpxezTY+AHzOzWhyIYkIDZDSA6h8u 0molKGU8pboV1HaXp2jME9vmrJ2EG2ySAoqlaTGDNVRSDJVZ9jLadn1Ot2mYm5Sz1g nV94/UlyPf9Nx2lxU1o54WQTAKn/MCCviN3jarDSbd8he4PHUTT038Vwwh3iwAA7nV /mJWENaNJScN+jc9+ZVUOBjXrmEqNvyMDbcGrDa9uS1hK3vlSfa/2nPGT0Rd1OWoo6 jlHL3lQ2Gi2Tw== From: Detlev Casanova To: linux-kernel@vger.kernel.org Cc: Andrew Lunn , Heiner Kallweit , Russell King , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , netdev@vger.kernel.org, devicetree@vger.kernel.org, Detlev Casanova Subject: [PATCH v2 1/3] net: phy: realtek: Add optional external PHY clock Date: Fri, 2 Jun 2023 14:26:57 -0400 Message-Id: <20230602182659.307876-2-detlev.casanova@collabora.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20230602182659.307876-1-detlev.casanova@collabora.com> References: <20230602182659.307876-1-detlev.casanova@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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 In some cases, the PHY can use an external clock source instead of a crystal. Add an optional clock in the phy node to make sure that the clock source is enabled, if specified, before probing. Signed-off-by: Detlev Casanova --- drivers/net/phy/realtek.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index 3d99fd6664d7..b13dd0b3c99e 100644 --- a/drivers/net/phy/realtek.c +++ b/drivers/net/phy/realtek.c @@ -12,6 +12,7 @@ #include #include #include +#include #define RTL821x_PHYSR 0x11 #define RTL821x_PHYSR_DUPLEX BIT(13) @@ -80,6 +81,7 @@ struct rtl821x_priv { u16 phycr1; u16 phycr2; bool has_phycr2; + struct clk *clk; }; static int rtl821x_read_page(struct phy_device *phydev) @@ -103,6 +105,11 @@ static int rtl821x_probe(struct phy_device *phydev) if (!priv) return -ENOMEM; + priv->clk = devm_clk_get_optional_enabled(dev, NULL); + if (IS_ERR(priv->clk)) + return dev_err_probe(dev, PTR_ERR(priv->clk), + "failed to get phy clock\n"); + ret = phy_read_paged(phydev, 0xa43, RTL8211F_PHYCR1); if (ret < 0) return ret; -- 2.39.3