Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1015570rwd; Wed, 31 May 2023 08:22:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Yyr2WUcUFzN99/pxcm+wYD1Spyqs62jNEhCP04heYaFMzdO0uDqsWKCVnd9cphZV7tGvo X-Received: by 2002:a17:902:e844:b0:1ae:6a3:d058 with SMTP id t4-20020a170902e84400b001ae06a3d058mr6948359plg.36.1685546535358; Wed, 31 May 2023 08:22:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685546535; cv=none; d=google.com; s=arc-20160816; b=zaDD3NSE0a+w7rKWebQN8wN4hGfrnufHZjF3qtkS/VjgHKyyheYip7IXLYrwdr6Ffw abs8TOj1nfAi0q7VoWwLWaTlnlPn3rvInGNqRMRukDL6eUe0a+neIXcphq5y2htwLCzR Kgtez9eb+29ccOfaOG0bO/TkgTOGtuGvY0pzE/VtNs7ZjA5knqcR09O/eIo95FwdAs1V 7uESAKV3Vqk/k3glgnJ+LyDtr77Ar0yzdGJUl07ihYKPxjl0bwey0YZLJhhQL201HAe8 iv7b07dMXz0PJZidbhjA7+fLXG8pAG7NuCpvMzs0+LoMLVEb/0Fw+NrWMcfzrhbX63YL RMGg== 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=chhdDKhLLkU7iNnoHy3CQuyi4OvsVU8MPbud8Mi9VXU=; b=DaG/emVGEj4Qf1+aFD20uO3lM5dTBH4c2FBHlszc6KIW6G/DqklLRfZ6rVSou0M93q wGBWkN4SDyDPu0ElU3lSN9WkftjtLjgIu2nZ3V0B1JsfQBv5aEMVKIAzpCXjXJ1q6uw9 VA4Wb/1NZ2G6eXCN5n3JCen9Nrik/bGJosb311jVoa7OHZ7XRdBMBHqTJjfKIc5Wg1IG mvlAOyb1lVYA4BDgXHdgsM9adodUf/QChOawDhpMexvBIVUwM6lvvNNIq5YStv3TLvwa J4+KacRtVOdTXj/2TGyd5dj9s/DNHyIPxZSuyaMIk8YiicnmzBvFHOFURYBwrygIQJqp SWtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=V7mMuiFu; 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 x21-20020a17090300d500b001b186709e78si686356plc.39.2023.05.31.08.22.02; Wed, 31 May 2023 08:22:15 -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=V7mMuiFu; 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 S233887AbjEaPE3 (ORCPT + 99 others); Wed, 31 May 2023 11:04:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234028AbjEaPEV (ORCPT ); Wed, 31 May 2023 11:04:21 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B14E5E43; Wed, 31 May 2023 08:04:12 -0700 (PDT) Received: from arisu.mtl.collabora.ca (mtl.collabora.ca [66.171.169.34]) (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 D5F846606EB2; Wed, 31 May 2023 16:04:09 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1685545451; bh=ojpftkR4i1FZMG72jz+SAgiRAqMlLbUDSyJeAdTo4nY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V7mMuiFuy/oZjT/E/zwMGXS97T7DIb4RyJ9VJp9TS9OvzuwpCTEXV5xrM8uS4ufMR MhCWdJhw/97WCAgQoMaMAshA2clPWxN+aEUuaXFCswmdlwGF7v60dei6rybplBpoAp CL82PTdQGLZhz4igNm94bDG0J28z772/+v2TWq+x0UhEVNgixsyUGZN8C7SMT9s8Iz xExkFD6cS8oXJ6zZnM538/tbRElTqVG5qbfsdvEpnUeESswWK6/BXNu7lS3UaT4YZT h0J8UO3PqOP0UmhikDx2wn+zy+nlwzyYKL567lhL8AS8L4LnaE+zCGtF0DryGOOHVE jLX6eljPHwUhg== 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 2/2] net: phy: realtek: Add optional external PHY clock Date: Wed, 31 May 2023 11:03:40 -0400 Message-Id: <20230531150340.522994-2-detlev.casanova@collabora.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20230531150340.522994-1-detlev.casanova@collabora.com> References: <20230531150340.522994-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..70c75dbbf799 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, "xtal"); + if (IS_ERR(priv->clk)) + return dev_err_probe(dev, PTR_ERR(priv->clk), + "failed to get phy xtal clock\n"); + ret = phy_read_paged(phydev, 0xa43, RTL8211F_PHYCR1); if (ret < 0) return ret; -- 2.39.3