Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5890254rwd; Wed, 24 May 2023 08:06:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ74v2BHOS5g1m+StrMH+zJhZ/Wh5t5CZJ66coWS/xVw99oPtmqUYYObY8/hvd2yIWO42Lp1 X-Received: by 2002:a05:6a00:1913:b0:64a:f730:154b with SMTP id y19-20020a056a00191300b0064af730154bmr3235845pfi.5.1684940782154; Wed, 24 May 2023 08:06:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684940782; cv=none; d=google.com; s=arc-20160816; b=ibrT4yJ5HCr95Ls6w3AoKDpq6cUkY14VVCeS1tTvDyx1Das8R1ScFtvW8Ant2t2wBy EV3rBfQ5kf2OT7JPbHaXIf2gUyp1Xm+FVSywL+gMIAlSgarYLLcExa+xlVYhYaE3Fuub rPjs/aFJ/GN60tFr5Dt0nhFBABkSr0J/el1iyzob5TXnl5UaG4xlTqh7vRU/F2mT/9Xa emID2dXyxlEgKdu/40H9PxFIASUQoAniOc0ZkJ5a9hbR3A3r87QSpvuGkcrgB3LuIyYh er2mA2wUG7roaMtvVQ+hAUkUER414b/hgpA0gaNF4aipLQkuwKOUf8PPNG9DogVDzYPk Q0BA== 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 :dkim-signature; bh=MdGq82Ks3L9ZKulL2OFYTbAZ8/ieg1hryBnyfjGMR+U=; b=QfYSX1V0djfjrn7FV5qMZdLQRnMiXSKi5SRFJtO9BnPlScTC05tpfYuumuk0jH6yzI rK5zzmGmAPLIJYMqxP6G48QjMnCGTldUK6y7DHhePR0wbibj1cJspilsA4EfhutBh288 +UNw15wuMLzV0fmFrT6lYDOHmOPd3GoxqAoZZSe4pjo3iv5QpPperAf5bnBZ+2fixcf6 KAhddDRDdAz/hlNsJPNqWw81Kbc4cju+p8IX5w4ynEGaARKD/zoSheoXptNHxEgHBOfw KD9JcTxf9gasZBhHo6PCOM/czEv8xJg8SsO35mw0a3AfNEJOhtmDxBJPDoKlcQNkz7GH meww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=zpZ0vP04; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s22-20020a639256000000b0053467c7b635si2759376pgn.85.2023.05.24.08.06.09; Wed, 24 May 2023 08:06: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=@microchip.com header.s=mchp header.b=zpZ0vP04; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235951AbjEXOpF (ORCPT + 99 others); Wed, 24 May 2023 10:45:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236062AbjEXOo7 (ORCPT ); Wed, 24 May 2023 10:44:59 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40100194; Wed, 24 May 2023 07:44:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1684939495; x=1716475495; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CP5atzyDeT3lvfQYbricTCjhs9mi8Czt0hAXYPTLMKY=; b=zpZ0vP04zqLLjOf4UU3UBkt4Qfq8fmSpQPooB5M4xunoPJahS7AYVkIu crmgtggLRbnnJQI936tH4NSMhmqm9qTMJ98oXvEUt1alOT1ulqxDFLN9D 3v7d3PKvMo6DyOMAxQxv7cGosX2BcqDaJB5+opbnsXiiK6V6zpotnpCNH wLjiCnsW8Sj+w5jcQEYlUtkkV0eJuyayJ54940ySwLHGOCnT7K4ANdYp/ g6rp5eFgtzTszUpMjuOrc2RtYPH6K7b6zYCEudlNK/CledLcUatvOy915 M8nFzKrIftqnMkRwmFPc0uMKcMIhB20xeMw4Y9uyTH81uF9fJwruKvr4l w==; X-IronPort-AV: E=Sophos;i="6.00,189,1681196400"; d="scan'208";a="212864734" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 24 May 2023 07:44:54 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Wed, 24 May 2023 07:44:53 -0700 Received: from CHE-LT-I17164LX.microchip.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.21 via Frontend Transport; Wed, 24 May 2023 07:44:49 -0700 From: Parthiban Veerasooran To: , , , , , , , , , CC: , , , , "Parthiban Veerasooran" Subject: [PATCH net-next v3 4/6] net: phy: microchip_t1s: fix reset complete status handling Date: Wed, 24 May 2023 20:15:37 +0530 Message-ID: <20230524144539.62618-5-Parthiban.Veerasooran@microchip.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230524144539.62618-1-Parthiban.Veerasooran@microchip.com> References: <20230524144539.62618-1-Parthiban.Veerasooran@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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 As per the datasheet DS-LAN8670-1-2-60001573C.pdf, the Reset Complete status bit in the STS2 register has to be checked before proceeding to the initial configuration. Reading STS2 register will also clear the Reset Complete interrupt which is non-maskable. Signed-off-by: Parthiban Veerasooran --- drivers/net/phy/microchip_t1s.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/net/phy/microchip_t1s.c b/drivers/net/phy/microchip_t1s.c index 8f29d9802131..05a88b561993 100644 --- a/drivers/net/phy/microchip_t1s.c +++ b/drivers/net/phy/microchip_t1s.c @@ -14,6 +14,9 @@ #define LAN867X_REG_IRQ_1_CTL 0x001C #define LAN867X_REG_IRQ_2_CTL 0x001D +#define LAN867X_REG_STS2 0x0019 + +#define LAN867x_RESET_COMPLETE_STS BIT(11) /* The arrays below are pulled from the following table from AN1699 * Access MMD Address Value Mask @@ -65,6 +68,27 @@ static int lan867x_revb1_config_init(struct phy_device *phydev) int err; + /* Read STS2 register and check for the Reset Complete status to do the + * init configuration. If the Reset Complete is not set, wait for 5us + * and then read STS2 register again and check for Reset Complete status. + * Still if it is failed then declare PHY reset error or else proceed + * for the PHY initial register configuration. + */ + err = phy_read_mmd(phydev, MDIO_MMD_VEND2, LAN867X_REG_STS2); + if (err < 0) + return err; + + if (!(err & LAN867x_RESET_COMPLETE_STS)) { + udelay(5); + err = phy_read_mmd(phydev, MDIO_MMD_VEND2, LAN867X_REG_STS2); + if (err < 0) + return err; + if (!(err & LAN867x_RESET_COMPLETE_STS)) { + phydev_err(phydev, "PHY reset failed\n"); + return -ENODEV; + } + } + /* Read-Modified Write Pseudocode (from AN1699) * current_val = read_register(mmd, addr) // Read current register value * new_val = current_val AND (NOT mask) // Clear bit fields to be written -- 2.34.1