From patchwork Thu Feb 2 03:00:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Sae X-Patchwork-Id: 51632 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp4952wrn; Wed, 1 Feb 2023 19:04:42 -0800 (PST) X-Google-Smtp-Source: AK7set8N8BONzLuDZV4pYHH6kzbdcm3TTCCsNVNM7kZH4m3xMeLiF+wf3NzTvUgFnkffLV0hFIAs X-Received: by 2002:a17:907:1607:b0:88a:8e57:f05b with SMTP id hb7-20020a170907160700b0088a8e57f05bmr6462106ejc.22.1675307082319; Wed, 01 Feb 2023 19:04:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675307082; cv=none; d=google.com; s=arc-20160816; b=LaBQzpgF+YKlKHh4d6Ngibk+W28OFeEtkhwkRH3ctj0r7PU0lVt/gLvErXi42At0UE sQRZC+oA7/6tF2La95sFPLxpObsHbQMc4VUY5VeK4YjUa1yhQuASmqYkOkKVbJLqgoIT a1QhcrsY6NTuBn+6O3/4F1nKNCgUZsfaH6ZhJeExTs7OFx7ssgTeC4Vb+b1yB559rAkA wOt5/FxcPXh2+IQmhHgVrQ1Y2V7AWT6FbbH/GPpy+FFW/TTZE/e7uToFccDY2C/LcHOZ z46cCKwh2AlbH/A9U+Qln1aXu7prXTheCZXqtIjuqi+/XmPfJITIn+H0y0Csqsgnzuhb OD5Q== 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; bh=BGCBjqRSgrvslYtblF3RwhiSkZSHuFNowQzNFgL2gkY=; b=JcWnBie920I6uhN2/LpHMYGelJPEfA3ByUKeofyOzQXek7+lTnS7xbH1alZcyXzIs8 dpdnHKqkJbxDSFREEnXDDqK/KauAzf7+sLZK1OrV+1zlsL6mrAxotoKEdWdRNGUD+ys7 1DZcE8vq570uG9HGAswP9SktVXP7VDscuVxyjxBwdAcTBiCBtE88aXcLeGOFv1lwSMbH qdY0f/73bRsNGCc+L6nxBUM5WF54rk35k8+LX3JVmOLYsWLY9RD5D31SU3uFQYhsuX1F QiGzkMNdQKGYDkkq/hOt8K3Ys5/FOAIsWbfbYdPDSQNE85RABhejctqFQnT8m82y9RrU /bYg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=motor-comm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y14-20020a17090668ce00b008784bef345bsi26908686ejr.627.2023.02.01.19.04.17; Wed, 01 Feb 2023 19:04:42 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=motor-comm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231569AbjBBDBg (ORCPT + 99 others); Wed, 1 Feb 2023 22:01:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229848AbjBBDBP (ORCPT ); Wed, 1 Feb 2023 22:01:15 -0500 Received: from out28-218.mail.aliyun.com (out28-218.mail.aliyun.com [115.124.28.218]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0C1D1710; Wed, 1 Feb 2023 19:01:08 -0800 (PST) X-Alimail-AntiSpam: AC=CONTINUE;BC=0.08825052|-1;CH=green;DM=|CONTINUE|false|;DS=CONTINUE|ham_system_inform|0.0211176-0.234236-0.744646;FP=18301903329760103606|1|1|10|0|-1|-1|-1;HT=ay29a033018047192;MF=frank.sae@motor-comm.com;NM=1;PH=DS;RN=18;RT=18;SR=0;TI=SMTPD_---.R7sRql1_1675306863; Received: from sun-VirtualBox..(mailfrom:Frank.Sae@motor-comm.com fp:SMTPD_---.R7sRql1_1675306863) by smtp.aliyun-inc.com; Thu, 02 Feb 2023 11:01:05 +0800 From: Frank Sae To: Peter Geis , Andrew Lunn , Heiner Kallweit , Russell King , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , yanhong.wang@starfivetech.com Cc: xiaogang.fan@motor-comm.com, fei.zhang@motor-comm.com, hua.sun@motor-comm.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Frank , devicetree@vger.kernel.org Subject: [PATCH net-next v5 4/5] net: phy: Add dts support for Motorcomm yt8531s gigabit ethernet phy Date: Thu, 2 Feb 2023 11:00:36 +0800 Message-Id: <20230202030037.9075-5-Frank.Sae@motor-comm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202030037.9075-1-Frank.Sae@motor-comm.com> References: <20230202030037.9075-1-Frank.Sae@motor-comm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756686799140675247?= X-GMAIL-MSGID: =?utf-8?q?1756686799140675247?= Add dts support for Motorcomm yt8531s gigabit ethernet phy. Change yt8521_probe to support clk config of yt8531s. Becase yt8521_probe does the things which yt8531s is needed, so removed yt8531s function. This patch has been verified on AM335x platform with yt8531s board. Signed-off-by: Frank Sae Reviewed-by: Andrew Lunn --- drivers/net/phy/motorcomm.c | 51 ++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/drivers/net/phy/motorcomm.c b/drivers/net/phy/motorcomm.c index ee30e8ac1a7f..bdc6a55d59f1 100644 --- a/drivers/net/phy/motorcomm.c +++ b/drivers/net/phy/motorcomm.c @@ -258,8 +258,6 @@ #define YT8531_SCR_CLK_SRC_CLOCK_FROM_DIGITAL 3 #define YT8531_SCR_CLK_SRC_REF_25M 4 #define YT8531_SCR_CLK_SRC_SSC_25M 5 -#define YT8531S_SYNCE_CFG_REG 0xA012 -#define YT8531S_SCR_SYNCE_ENABLE BIT(6) /* Extended Register end */ @@ -858,7 +856,32 @@ static int yt8521_probe(struct phy_device *phydev) return -EINVAL; } } else if (phydev->drv->phy_id == PHY_ID_YT8531S) { - return 0; + switch (freq) { + case YTPHY_DTS_OUTPUT_CLK_DIS: + mask = YT8531_SCR_SYNCE_ENABLE; + val = 0; + break; + case YTPHY_DTS_OUTPUT_CLK_25M: + mask = YT8531_SCR_SYNCE_ENABLE | + YT8531_SCR_CLK_SRC_MASK | + YT8531_SCR_CLK_FRE_SEL_125M; + val = YT8531_SCR_SYNCE_ENABLE | + FIELD_PREP(YT8531_SCR_CLK_SRC_MASK, + YT8531_SCR_CLK_SRC_REF_25M); + break; + case YTPHY_DTS_OUTPUT_CLK_125M: + mask = YT8531_SCR_SYNCE_ENABLE | + YT8531_SCR_CLK_SRC_MASK | + YT8531_SCR_CLK_FRE_SEL_125M; + val = YT8531_SCR_SYNCE_ENABLE | + YT8531_SCR_CLK_FRE_SEL_125M | + FIELD_PREP(YT8531_SCR_CLK_SRC_MASK, + YT8531_SCR_CLK_SRC_PLL_125M); + break; + default: + phydev_warn(phydev, "Freq err:%u\n", freq); + return -EINVAL; + } } else { phydev_warn(phydev, "PHY id err\n"); return -EINVAL; @@ -868,26 +891,6 @@ static int yt8521_probe(struct phy_device *phydev) val); } -/** - * yt8531s_probe() - read chip config then set suitable polling_mode - * @phydev: a pointer to a &struct phy_device - * - * returns 0 or negative errno code - */ -static int yt8531s_probe(struct phy_device *phydev) -{ - int ret; - - /* Disable SyncE clock output by default */ - ret = ytphy_modify_ext_with_lock(phydev, YT8531S_SYNCE_CFG_REG, - YT8531S_SCR_SYNCE_ENABLE, 0); - if (ret < 0) - return ret; - - /* same as yt8521_probe */ - return yt8521_probe(phydev); -} - /** * ytphy_utp_read_lpa() - read LPA then setup lp_advertising for utp * @phydev: a pointer to a &struct phy_device @@ -1970,7 +1973,7 @@ static struct phy_driver motorcomm_phy_drvs[] = { PHY_ID_MATCH_EXACT(PHY_ID_YT8531S), .name = "YT8531S Gigabit Ethernet", .get_features = yt8521_get_features, - .probe = yt8531s_probe, + .probe = yt8521_probe, .read_page = yt8521_read_page, .write_page = yt8521_write_page, .get_wol = ytphy_get_wol,