From nobody Wed Apr 15 19:44:53 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2DD5CC4332F for ; Mon, 21 Nov 2022 08:06:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229699AbiKUIGn (ORCPT ); Mon, 21 Nov 2022 03:06:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229598AbiKUIGl (ORCPT ); Mon, 21 Nov 2022 03:06:41 -0500 Received: from out28-75.mail.aliyun.com (out28-75.mail.aliyun.com [115.124.28.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC3121409D; Mon, 21 Nov 2022 00:06:39 -0800 (PST) X-Alimail-AntiSpam: AC=CONTINUE;BC=0.07487702|-1;CH=green;DM=|CONTINUE|false|;DS=CONTINUE|ham_system_inform|0.00576339-0.106031-0.888205;FP=0|0|0|0|0|-1|-1|-1;HT=ay29a033018047188;MF=frank.sae@motor-comm.com;NM=1;PH=DS;RN=14;RT=14;SR=0;TI=SMTPD_---.QCzvKBK_1669017959; Received: from sunhua.motor-comm.com(mailfrom:Frank.Sae@motor-comm.com fp:SMTPD_---.QCzvKBK_1669017959) by smtp.aliyun-inc.com; Mon, 21 Nov 2022 16:06:37 +0800 From: Frank To: Peter Geis , Andrew Lunn , Heiner Kallweit , Russell King , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: yinghong.zhang@motor-comm.com, fei.zhang@motor-comm.com, hua.sun@motor-comm.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Frank Subject: [PATCH net-next] net: phy: add Motorcomm YT8531S phy id. Date: Mon, 21 Nov 2022 16:06:38 +0800 Message-Id: <20221121080638.547-1-Frank.Sae@motor-comm.com> X-Mailer: git-send-email 2.31.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" We added patch for motorcomm.c to support YT8531S. This patch has been tested on AM335x platform which has one YT8531S interface card and passed all test cases. The tested cases indluding: YT8531S UTP function with support of 10M/100M/1000M; YT8531S Fiber function with support of 100M/1000M; and YT8531S Combo function that supports auto detection of media type. =20 Since most functions of YT8531S are similar to YT8521 and we reuse some codes for YT8521 in the patch file. Signed-off-by: Frank --- drivers/net/phy/Kconfig | 2 +- drivers/net/phy/motorcomm.c | 50 ++++++++++++++++++++++++++++++++++--- 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig index 040c8bf6d05b..af00cf44cd97 100644 --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig @@ -260,7 +260,7 @@ config MOTORCOMM_PHY tristate "Motorcomm PHYs" help Enables support for Motorcomm network PHYs. - Currently supports the YT8511, YT8521 Gigabit Ethernet PHYs. + Currently supports the YT8511, YT8521, YT8531S Gigabit Ethernet PHYs. =20 config NATIONAL_PHY tristate "National Semiconductor PHYs" diff --git a/drivers/net/phy/motorcomm.c b/drivers/net/phy/motorcomm.c index bd1ab5d0631f..4c46c3edc0d9 100644 --- a/drivers/net/phy/motorcomm.c +++ b/drivers/net/phy/motorcomm.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0+ /* - * Motorcomm 8511/8521 PHY driver. + * Motorcomm 8511/8521/8531S PHY driver. * * Author: Peter Geis * Author: Frank @@ -13,8 +13,9 @@ =20 #define PHY_ID_YT8511 0x0000010a #define PHY_ID_YT8521 0x0000011A +#define PHY_ID_YT8531S 0x4F51E91A =20 -/* YT8521 Register Overview +/* YT8521/YT8531S Register Overview * UTP Register space | FIBER Register space * ------------------------------------------------------------ * | UTP MII | FIBER MII | @@ -147,7 +148,7 @@ #define YT8521_LINK_TIMER_CFG2_REG 0xA5 #define YT8521_LTCR_EN_AUTOSEN BIT(15) =20 -/* 0xA000, 0xA001, 0xA003 ,and 0xA006 ~ 0xA00A are common ext registers +/* 0xA000, 0xA001, 0xA003 , 0xA006 ~ 0xA00A and 0xA012 are common ext regi= sters * of yt8521 phy. There is no need to switch reg space when operating these * registers. */ @@ -221,6 +222,9 @@ */ #define YTPHY_WCR_TYPE_PULSE BIT(0) =20 +#define YT8531S_SYNCE_CFG_REG 0xA012 +#define YT8531S_SCR_SYNCE_ENABLE BIT(6) + /* Extended Register end */ =20 struct yt8521_priv { @@ -647,6 +651,26 @@ static int yt8521_probe(struct phy_device *phydev) return 0; } =20 +/** + * 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 =3D 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 @@ -1750,11 +1774,28 @@ static struct phy_driver motorcomm_phy_drvs[] =3D { .suspend =3D yt8521_suspend, .resume =3D yt8521_resume, }, + { + PHY_ID_MATCH_EXACT(PHY_ID_YT8531S), + .name =3D "YT8531S Gigabit Ethernet", + .get_features =3D yt8521_get_features, + .probe =3D yt8531s_probe, + .read_page =3D yt8521_read_page, + .write_page =3D yt8521_write_page, + .get_wol =3D ytphy_get_wol, + .set_wol =3D ytphy_set_wol, + .config_aneg =3D yt8521_config_aneg, + .aneg_done =3D yt8521_aneg_done, + .config_init =3D yt8521_config_init, + .read_status =3D yt8521_read_status, + .soft_reset =3D yt8521_soft_reset, + .suspend =3D yt8521_suspend, + .resume =3D yt8521_resume, + }, }; =20 module_phy_driver(motorcomm_phy_drvs); =20 -MODULE_DESCRIPTION("Motorcomm 8511/8521 PHY driver"); +MODULE_DESCRIPTION("Motorcomm 8511/8521/8531S PHY driver"); MODULE_AUTHOR("Peter Geis"); MODULE_AUTHOR("Frank"); MODULE_LICENSE("GPL"); @@ -1762,6 +1803,7 @@ MODULE_LICENSE("GPL"); static const struct mdio_device_id __maybe_unused motorcomm_tbl[] =3D { { PHY_ID_MATCH_EXACT(PHY_ID_YT8511) }, { PHY_ID_MATCH_EXACT(PHY_ID_YT8521) }, + { PHY_ID_MATCH_EXACT(PHY_ID_YT8531S) }, { /* sentinal */ } }; =20 --=20 2.31.0.windows.1