Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp240001ioo; Thu, 26 May 2022 02:34:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmCqaTMKxgp2H5QP8jcYEv1lBOZ8lExCh5//+MmuMf1pMb64PQrrzmnBTSAdbOceQuyUmD X-Received: by 2002:a17:907:6d8e:b0:6fe:c382:1fab with SMTP id sb14-20020a1709076d8e00b006fec3821fabmr21151215ejc.483.1653557676131; Thu, 26 May 2022 02:34:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653557676; cv=none; d=google.com; s=arc-20160816; b=i5kjFoHNekxKyQ+gRi+MA+HGTSEOcCLpF83+swz/nuVdQZeJIOEDwDDnpjx+3+jYQO SCHv3YEge35tWnCg488IrobApFrwz5oYX3CqxAkg3ZfwQXL1FwWehiPK9tBvCB0Ke00n yCik8z5vq46/bcVM0jQrhqPRhdUbZab7tvCq9x/YiCk1u/ArNkhw667kPUU7C4MVQx6H UbZq7/y3dLpqI1iAbxbnluIYLN7+VLxxwkKWkdx4ATUr2kJ4nYikgWUB9srtEGu80wDA 2IF2LzSHtdyjUvqf3dlJ63zWAn1oG1YnHyRtjUeMDkeCRKXaDvRVgJut2XXDH0xtBkK7 qpNQ== 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=ZgCPvU0KpPgMml2Vogz6K7ZwiXxztn2DMZAdO/DPHS4=; b=C5COd66o7B1r8XI7D891t1jrCJPNpTSFxzkRS20zYJMyT12QO4bz/0g17RriNWz5Bx OjKbDwiyZl+ktVS0f3juszguSeWIbsHQrOJo/4EjlBeN9IWKindMrur/UkCXuf3RY0Vu qg9yiS/Hy9DotQIDyrqdShSxIQXjc6del0F4dKTHzeuU15d9q/qPG5zT0Ml5cCM/zLOV 9hkSFm8m8RaU1xXJIaGAMeG+Ss6kay+9Las1yMbz+64xBFAUDYfxyUmti/gLDZJFj/bv D2ohrVLID8DvFRnf31JuxdXXLc9D95wv3Vm0IYq2tTC6V4BAASlMlA3M+7OJPp9ceo4m QmJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dTTyDv38; 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 i12-20020a170906698c00b006febef95910si987627ejr.332.2022.05.26.02.34.08; Thu, 26 May 2022 02:34:36 -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=dTTyDv38; 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 S1343933AbiEZBbC (ORCPT + 99 others); Wed, 25 May 2022 21:31:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245169AbiEZBao (ORCPT ); Wed, 25 May 2022 21:30:44 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B19F8A76F4; Wed, 25 May 2022 18:30:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1653528627; x=1685064627; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=UaSIPRzQt8djgwCCogviIlJQSqF/rXfZ66henu/ROoY=; b=dTTyDv38O0Oyxwm3H23qgOh7Mmxfcd44npw5Wx54abP0fUA+37piwUgg 6JWCiQP+WEoj2CizKCuEvp43H+w9/w3GpxKxY+UkN+/AQW/7LZO7caUR5 iOHQtmjYbBAEl/97S2snN+Qf2ewgYe5Y4IDHYrAbvPc7k7VZQYKzUERAe 1gkC6pRgmK+uStAU/UgymoeJft26/oVsh3hztSPRCYyTQuUophT8cIQin n8Fm6kRwR7BVO1mnTvWmNCCoqyvqeuX8wsdSuRdES6nq2X2tupDw8tlmY 3oslxqf/AgchmI5P1T9gGld+gFDGcWnT48S2z/RL66YDk6TPwHE+osllK Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10358"; a="273713962" X-IronPort-AV: E=Sophos;i="5.91,252,1647327600"; d="scan'208";a="273713962" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 May 2022 18:30:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,252,1647327600"; d="scan'208";a="718002411" Received: from p12hl01tmin.png.intel.com ([10.158.65.216]) by fmsmga001.fm.intel.com with ESMTP; 25 May 2022 18:30:23 -0700 From: Tan Tee Min To: Andrew Lunn , Heiner Kallweit , Russell King , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Voon Wei Feng , Sit Michael Wei Hong , Ling Pei Lee , Looi Hong Aun , Tan Tee Min Subject: [PATCH net-next 1/1] net: phy: dp83867: retrigger SGMII AN when link change Date: Thu, 26 May 2022 09:37:14 +0800 Message-Id: <20220526013714.4119839-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, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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. 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