From patchwork Tue Nov 22 08:42:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Sae X-Patchwork-Id: 24207 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2086158wrr; Tue, 22 Nov 2022 00:58:36 -0800 (PST) X-Google-Smtp-Source: AA0mqf4Q88XhzwxtTVfemuUL3dZe3lFPjmziOqP6WA8Wez8eCpC3RdSwMruGUHW2X3eEzutOEH7S X-Received: by 2002:a05:6402:444a:b0:459:401:c23e with SMTP id o10-20020a056402444a00b004590401c23emr4878895edb.23.1669107516624; Tue, 22 Nov 2022 00:58:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669107516; cv=none; d=google.com; s=arc-20160816; b=PDvpRtjJ1srd3pms+o3lRWi6TAx9Mm3QrPB6AxexzUJrFcuZIlK0P0+f2x+sgPWXFN oMWK5CXzA3YjHpF0KG/DwKHfwswNzROzZnQzSoVqDHi48OzGJEvc/uTkKQfEQ2a+uy1G i0rLBNBbDyUnbzFztXIBqROmflYFqwiWXTByF+uF3CqHQsUb3FiwqvhZ5fS/je3s4JZU p0X091tujVFgBG+XHb4qz/p8AiriXVJ6CPvuIJqrFnULv2+HRkpPkpykN2rLO8vgCS4v pokcv+RHz8xxbsfJLZ2lR0STyeT7AKLAmVnPcESaAD3OKlb+J1ES/U0le0BG1hRAPbwO vyUw== 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 :message-id:date:subject:cc:to:from; bh=ZNUqqQmPpR7KARgH9PBv85/eZ3fbnJrQ+wJY2fDLNSY=; b=0ZrQe6O2v6xuJbq3pI+6Mh2R0u/xN7XW2VxytmYJSzxcCxTVFwm7on7FIxPRC56AAq bad3QzMKPwP+ZsSUAtkN64+ImJixvtQtUk9H+dkmlUBzxbjub4DIjEUjC1Ke+IO1ZKjm wtRnWANlwJrMjvnRRU8POsc9GHbuuKH3bxPxg+GLMw5YZuuKUiJZNUkAAFuhPIbD6K3n aR+XnT1vKPJAF7Fc+Tu2+GVAgTRxJ71G6dWFsHxb3Qk3nfpw+4MahPZRQbZjQ0IMEhK4 CjinPflmjkAzcmfic/9XR1a6OkOPKaBKS2MJsj4qLEZhn5ynKXpDqwQRXNVyHDl4wVFB H+hA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m8-20020a056402430800b0045d27c0ba90si12100092edc.577.2022.11.22.00.58.12; Tue, 22 Nov 2022 00:58:36 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232971AbiKVImO (ORCPT + 99 others); Tue, 22 Nov 2022 03:42:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232973AbiKVImD (ORCPT ); Tue, 22 Nov 2022 03:42:03 -0500 Received: from out28-172.mail.aliyun.com (out28-172.mail.aliyun.com [115.124.28.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FF1D40902; Tue, 22 Nov 2022 00:42:01 -0800 (PST) X-Alimail-AntiSpam: AC=CONTINUE;BC=0.07454813|-1;CH=green;DM=|CONTINUE|false|;DS=CONTINUE|ham_system_inform|0.00569678-0.10483-0.889473;FP=0|0|0|0|0|-1|-1|-1;HT=ay29a033018047207;MF=frank.sae@motor-comm.com;NM=1;PH=DS;RN=14;RT=14;SR=0;TI=SMTPD_---.QE5BpFo_1669106515; Received: from sun-VirtualBox..(mailfrom:Frank.Sae@motor-comm.com fp:SMTPD_---.QE5BpFo_1669106515) by smtp.aliyun-inc.com; Tue, 22 Nov 2022 16:41:58 +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 v2] net: phy: add Motorcomm YT8531S phy id. Date: Tue, 22 Nov 2022 16:42:32 +0800 Message-Id: <20221122084232.3886-1-Frank.Sae@motor-comm.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, 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?1750186083295311035?= X-GMAIL-MSGID: =?utf-8?q?1750186083295311035?= 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. Since most functions of YT8531S are similar to YT8521 and we reuse some codes for YT8521 in the patch file. Signed-off-by: Frank --- patch v2: Hi Andrew, Thanks very much and based on your comments we modified the patch v2 as below. > > 2.31.0.windows.1 > > Does that mean you are hosting your Linux builds on Windows machine? The issue is fixed. drivers/net/phy/Kconfig | 2 +- drivers/net/phy/motorcomm.c | 52 +++++++++++++++++++++++++++++++++---- 2 files changed, 48 insertions(+), 6 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. config NATIONAL_PHY tristate "National Semiconductor PHYs" diff --git a/drivers/net/phy/motorcomm.c b/drivers/net/phy/motorcomm.c index bd1ab5d0631f..685190db72de 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 @@ -12,9 +12,10 @@ #include #define PHY_ID_YT8511 0x0000010a -#define PHY_ID_YT8521 0x0000011A +#define PHY_ID_YT8521 0x0000011A +#define PHY_ID_YT8531S 0x4F51E91A -/* 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) -/* 0xA000, 0xA001, 0xA003 ,and 0xA006 ~ 0xA00A are common ext registers +/* 0xA000, 0xA001, 0xA003, 0xA006 ~ 0xA00A and 0xA012 are common ext registers * 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) +#define YT8531S_SYNCE_CFG_REG 0xA012 +#define YT8531S_SCR_SYNCE_ENABLE BIT(6) + /* Extended Register end */ struct yt8521_priv { @@ -647,6 +651,26 @@ static int yt8521_probe(struct phy_device *phydev) return 0; } +/** + * 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 @@ -1750,11 +1774,28 @@ static struct phy_driver motorcomm_phy_drvs[] = { .suspend = yt8521_suspend, .resume = yt8521_resume, }, + { + PHY_ID_MATCH_EXACT(PHY_ID_YT8531S), + .name = "YT8531S Gigabit Ethernet", + .get_features = yt8521_get_features, + .probe = yt8531s_probe, + .read_page = yt8521_read_page, + .write_page = yt8521_write_page, + .get_wol = ytphy_get_wol, + .set_wol = ytphy_set_wol, + .config_aneg = yt8521_config_aneg, + .aneg_done = yt8521_aneg_done, + .config_init = yt8521_config_init, + .read_status = yt8521_read_status, + .soft_reset = yt8521_soft_reset, + .suspend = yt8521_suspend, + .resume = yt8521_resume, + }, }; module_phy_driver(motorcomm_phy_drvs); -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[] = { { PHY_ID_MATCH_EXACT(PHY_ID_YT8511) }, { PHY_ID_MATCH_EXACT(PHY_ID_YT8521) }, + { PHY_ID_MATCH_EXACT(PHY_ID_YT8531S) }, { /* sentinal */ } };