Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5782409rwd; Mon, 5 Jun 2023 08:29:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7ZyCNdpAzAzLIiSS80tnNUHqK8gd6g7dAThcKJ8AEOU12BNxOVgTkFJeuTl54qE0ONHDvB X-Received: by 2002:a17:90a:11:b0:255:d628:c69b with SMTP id 17-20020a17090a001100b00255d628c69bmr3099978pja.6.1685978968673; Mon, 05 Jun 2023 08:29:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685978968; cv=none; d=google.com; s=arc-20160816; b=pftwumiPDGSJ6w1iMStQZv9WJTKmHQK+WuSg0TIB9DjrmN9/ghydRABpS51ERiWPwV Y+fildEG5RsLpJT0mhSfgIGqwcaEx7R8lutZhjDaaxN3zDnCd/5GFyanV1lpSZH/PPIh CqF9VPEFSHwG+Zy/Es/0dagySKmb74BaE7ETtaW4S/oe61mYI+UhPuvY5kZ5R8Chjqst vr+qYjLAEDOODupdHzb3OGDlp/XUyhXKQhXt1Y6zc8uKmPyusiAra+UmB1PbfmnjchS5 DAenpeSayWd4nK8TE4NWkjhwwCZVcHsp4NjCQl+fd+G+wXaQ5cx9+g3D/8pSFhJP4+c2 q1aw== 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=9+emfugo9/jqojZ717IbvJ2xd3/WKJwi84/mdvt8WwU=; b=1Bw16cKKaHaQYIHm/WzlMsqhzslcu9Ptm8Vqp63xaxMNO4cu4TLRnCHACqWATWSB03 PzaDLn2cQcNhjgKDDljPgxTnvS4UkOS1FydSORzKEgV/xwVF+W1LV1BP8GyGP79WYWuz Cfx5/J2oLuqXoS0dcCSdmj5vjcuOa5H9wf6cTS/DgnKMah6mgg6diRE+3vRn1HMgebYe 8snbQfnEbsOlNeXbPjuOWLqNE62jxd9nMHi2V37EeiEmLADC/Rru4B3anC8RuYJy77pK atoiGHo2SR/zvS6Wt/SuqZeo7cg/k/9abDTvv1R+6J9OA+po8HPStHXqyCzcCUh/MFQN Ir/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=eGOY0ZBk; 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 gt7-20020a17090af2c700b00250a2c9a793si5653917pjb.152.2023.06.05.08.29.16; Mon, 05 Jun 2023 08:29:28 -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=eGOY0ZBk; 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 S234735AbjFEPUY (ORCPT + 99 others); Mon, 5 Jun 2023 11:20:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234536AbjFEPUS (ORCPT ); Mon, 5 Jun 2023 11:20:18 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4558EA; Mon, 5 Jun 2023 08:20:17 -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 232536600368; Mon, 5 Jun 2023 16:20:15 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1685978416; bh=vWggyIWMQJwPp+5rrAFGhNQx/8NDyETfk2n0HVwyCl8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eGOY0ZBk4S0A2fnyPG482C+4kaHdXZ4SsW7HeHKjuh7/17gxCPUYADV6p3Aeh9oSK MEJrfiUmIXdPsT5dI5l80HRzhSr5nme8zfUk194FpwRgoe9QuSiDJozB3a2Rda5PYM wYXt4da5Go9KOVsiWlGrSjQsuNQZfuwgtNwDhUFkYNNPZb/x2Qt3lq4q/8C3uSF8bx NMdnPIEBvEx2cp3c0wKHUkaj69SM3w4NobSwB33nXxSF3Dm75bKhpKGLWBwuqaw9UW GAEHcTF7Xs5cZQulNWqdI4VGvPqBFwkHjoYKRJe2mGBD/4lEjhlrC9HexOZtWGE5Ys umtTXtwowXu2g== 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 , Florian Fainelli Subject: [PATCH v3 1/3] net: phy: realtek: Add optional external PHY clock Date: Mon, 5 Jun 2023 11:19:51 -0400 Message-Id: <20230605151953.48539-2-detlev.casanova@collabora.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20230605151953.48539-1-detlev.casanova@collabora.com> References: <20230605151953.48539-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 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. Reviewed-by: Florian Fainelli Reviewed-by: Andrew Lunn 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