Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp1467127ioo; Fri, 27 May 2022 09:09:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxurrZ+oEjuGcDnJVWnzxUIVmL8DLh83EZCs4uHuBMwaIpBuc13jrqwDWkiFgyO4e2ifmNm X-Received: by 2002:a05:6402:1007:b0:428:beb6:f483 with SMTP id c7-20020a056402100700b00428beb6f483mr45888779edu.391.1653667762616; Fri, 27 May 2022 09:09:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653667762; cv=none; d=google.com; s=arc-20160816; b=YQOjPvYYwC+d5c2nj/d55x1OeDLGDXt/bLJkaNd6OcIXv0trSI00CK4r+Blv4KKuqk EMJMkxWdwAkhgH/COONRv+jBPkZlVfZzJc1a6H0u0E3jdG3bY8BYDIZ6Ynzcpkcfox0v 6k/eALyt04KHBocT40Ynp0gapGpFcPwNNx6Ja+Il1X6Ko2QG8gizJ31HzlaeLq4xH5sj 5Hd9LqYLmtAGDmPPMQC/Hzg4hvhk9GQr8xPdOeYN8nMheFhJsesVbpkKnlN2IGVGIEQB dM+m6V8kYoMs8wfDTUvMFCaaPpModvZApBUO0rpK0sgl/RUHvJBQJZIiiM3I8+RD5V93 4ftw== 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:dkim-signature; bh=7HgQjxd0BVqoYu3f9XfN3/jWGEyfuW7PvuHOFMP4J2s=; b=PZ7Yh7OGB5dygg3XFKyqHMBfhL5OoiPEEOiM97TvboW0HkSCQ0RCR1Z4lgyEdCvRgC bAnWlijOOJHuUpI0/7E6e+KWVEjeMeKuu8DJwsjAX/lespP4g1Gwnrls8I/Xs897Yy6g uG8WkD/LIfmg5tSD8TKiEvJx2PLtKePO2EIuIY67olwa6ZNKulhBnjU0YaCPJ/FrzEkc cic2Ov5R1WwoJiJxEGmQHsyJBHc5CJICY+aG4vPBao1QktFIt3b1lNTn4xQQMTvmgpy4 QQ4NUH00ddw/WEw/8QNX+9r/iR1FM5LD5Q0Wy2GcXkcMcbcoOZu8AWGNcEDTuV80mukg 3qFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=PvqOM7G0; 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=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i10-20020a05640242ca00b0042ab8857df5si2227974edc.407.2022.05.27.09.08.53; Fri, 27 May 2022 09:09:22 -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=@intel.com header.s=Intel header.b=PvqOM7G0; 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=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244993AbiEZI5F (ORCPT + 99 others); Thu, 26 May 2022 04:57:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232417AbiEZI5C (ORCPT ); Thu, 26 May 2022 04:57:02 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85AFE3525C; Thu, 26 May 2022 01:57:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1653555420; x=1685091420; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=VYZcLDoZJWGwpGI3Sm3xsbMDc92hUIeYlIsQC6WcKIA=; b=PvqOM7G0s49LAxFkLgj0huKG2B0hdhKRH7tPWcuGPJ44v/OXfDTiDe8R C9NwcmFoKHIMFRYZmt/Al0Cv4kcmb4+WmDxQRt+ox6R6F9CwqZvTtzxc3 jl+QC5ZVWmZcXjfyyOL2lf+KqpgVUrPEf4WtHXn6aAMojlvl+2CVHceHA mu+Px5vrjaLK6p5jZwd22A2/Xegv3/jR++mWRzvLm/0fnJl8i6z13jos4 22n4MmaLTFg5cUF5rYYvBRi5lqkYe+J6KmqT6AxQEpcYveVbe2mLPdxYP YoL2xAmH4WvebulPkFqUQo43ye8yZwowMaeHmKbI886MoSpxqoI346mWf w==; X-IronPort-AV: E=McAfee;i="6400,9594,10358"; a="337136423" X-IronPort-AV: E=Sophos;i="5.91,252,1647327600"; d="scan'208";a="337136423" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 May 2022 01:57:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,252,1647327600"; d="scan'208";a="609601489" Received: from p12hl01tmin.png.intel.com ([10.158.65.216]) by orsmga001.jf.intel.com with ESMTP; 26 May 2022 01:56:56 -0700 From: Tan Tee Min To: Andrew Lunn , Heiner Kallweit , Russell King , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Dan Murphy Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Voon Wei Feng , Sit Michael Wei Hong , Ling Pei Lee , Looi Hong Aun , Wong Vee Khee , Tan Tee Min Subject: [PATCH net-next v2 1/1] net: phy: dp83867: retrigger SGMII AN when link change Date: Thu, 26 May 2022 17:03:47 +0800 Message-Id: <20220526090347.128742-1-tee.min.tan@linux.intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,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 There is a limitation in TI DP83867 PHY device where SGMII AN is only triggered once after the device is booted up. Even after the PHY TPI is down and up again, SGMII AN is not triggered and hence no new in-band message from PHY to MAC side SGMII. This could cause an issue during power up, when PHY is up prior to MAC. At this condition, once MAC side SGMII is up, MAC side SGMII wouldn`t receive new in-band message from TI PHY with correct link status, speed and duplex info. As suggested by TI, implemented a SW solution here to retrigger SGMII Auto-Neg whenever there is a link change. v2: Add Fixes tag in commit message. Fixes: 2a10154abcb7 ("net: phy: dp83867: Add TI dp83867 phy") Cc: # 5.4.x Signed-off-by: Sit, Michael Wei Hong Reviewed-by: Voon Weifeng Signed-off-by: Tan Tee Min --- drivers/net/phy/dp83867.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c index 8561f2d4443b..13dafe7a29bd 100644 --- a/drivers/net/phy/dp83867.c +++ b/drivers/net/phy/dp83867.c @@ -137,6 +137,7 @@ #define DP83867_DOWNSHIFT_2_COUNT 2 #define DP83867_DOWNSHIFT_4_COUNT 4 #define DP83867_DOWNSHIFT_8_COUNT 8 +#define DP83867_SGMII_AUTONEG_EN BIT(7) /* CFG3 bits */ #define DP83867_CFG3_INT_OE BIT(7) @@ -855,6 +856,32 @@ static int dp83867_phy_reset(struct phy_device *phydev) DP83867_PHYCR_FORCE_LINK_GOOD, 0); } +static void dp83867_link_change_notify(struct phy_device *phydev) +{ + /* There is a limitation in DP83867 PHY device where SGMII AN is + * only triggered once after the device is booted up. Even after the + * PHY TPI is down and up again, SGMII AN is not triggered and + * hence no new in-band message from PHY to MAC side SGMII. + * This could cause an issue during power up, when PHY is up prior + * to MAC. At this condition, once MAC side SGMII is up, MAC side + * SGMII wouldn`t receive new in-band message from TI PHY with + * correct link status, speed and duplex info. + * Thus, implemented a SW solution here to retrigger SGMII Auto-Neg + * whenever there is a link change. + */ + if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { + int val = 0; + + val = phy_clear_bits(phydev, DP83867_CFG2, + DP83867_SGMII_AUTONEG_EN); + if (val < 0) + return; + + phy_set_bits(phydev, DP83867_CFG2, + DP83867_SGMII_AUTONEG_EN); + } +} + static struct phy_driver dp83867_driver[] = { { .phy_id = DP83867_PHY_ID, @@ -879,6 +906,8 @@ static struct phy_driver dp83867_driver[] = { .suspend = genphy_suspend, .resume = genphy_resume, + + .link_change_notify = dp83867_link_change_notify, }, }; module_phy_driver(dp83867_driver); -- 2.25.1