Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp10523277rwb; Fri, 25 Nov 2022 05:31:12 -0800 (PST) X-Google-Smtp-Source: AA0mqf7/7TKJZtRt//6xX2aAm4VrqBRLegD2DVus97RgbqSO+BIY55nV1OC0bwMHVevVJBp5Ivpl X-Received: by 2002:a17:90a:a88e:b0:213:13ab:c309 with SMTP id h14-20020a17090aa88e00b0021313abc309mr40237212pjq.80.1669383072311; Fri, 25 Nov 2022 05:31:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669383072; cv=none; d=google.com; s=arc-20160816; b=Oovr86ZLmYlPmiJt323CD1M8idNTRvAjP06AYAO65dBf/nxRLHO8Ch3Zv/oKeJ0UCF Ufu6O2d4TLc96Wk4C+a8kg18k4K/yp6Js2whFj4zOu01TWccL9aXbpAnBJBuPtg4WY7m vi6x351wUR4sv4D4Tr6HmhMIrfzicbdihhreLit+VmQDZxS0PkKAOV37WzyarRKI3etz pO9sM3naHgxNgcKeTCnxskJJjHDbAua1n55RfWqZS4ULz8BWv3LGaGlFUJdmvdU8jmNM oVUqZrvZmKL6huelG+gnVqln+UnoXlS/Rjm/eFhL4cmpBKz66sYtEVnW9jndaBo4RbQd FwcA== 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=55j9+pE5serVzhnMTbv/yWHlwVqG0P8aXjk+91N8pmo=; b=t+2htpuLmOTJEFPWNujpsaZW2HLIMHcmJv/6sOH3g/GdF5Mf3zqImQac9GxcVXaMpG OX3q1s3pZFJ4UAzyuxfyoq502tpStQ9v6oD/cvxm/YMpXS1F4AFb59jFUyKl4Y0F4wTt h/OoYT9sIJ8Yuoqvrh3/YaWc0qSPvbJnQrQEw2JBYZQHW98M0CR6XNZRKYkhxgaxIOwH 5Q8Y5wgQ9H4nPRaheWjCpwAJa5+xU3q9hwCzG9WbFdYN1UaNda20VawVQn7ocqghEQpf gIY2TajEvGG6pqRDqlZv3wbB0go9QF/gIfV8CcdAQ9qTqR/nFt33pSsO3FW2NNDLN2/Q vsww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=SiOXIiLY; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q13-20020a170902dacd00b001844a8cf941si896730plx.538.2022.11.25.05.31.01; Fri, 25 Nov 2022 05:31:12 -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; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=SiOXIiLY; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229686AbiKYNSP (ORCPT + 86 others); Fri, 25 Nov 2022 08:18:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229688AbiKYNSM (ORCPT ); Fri, 25 Nov 2022 08:18:12 -0500 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3B296314; Fri, 25 Nov 2022 05:18:10 -0800 (PST) Received: (Authenticated sender: maxime.chevallier@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 91A2910000C; Fri, 25 Nov 2022 13:18:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1669382289; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=55j9+pE5serVzhnMTbv/yWHlwVqG0P8aXjk+91N8pmo=; b=SiOXIiLYraXwB85aZtJFfKRo6XCjpwXBNzHzXLTa1n1xVN9B4F4cVUdYoUL5xzUDi5aD8C mamEZ7hnUlvXa2l0lcG0A5M7Zg6Q8NohX8z9aNt8X8XcH28q5SGdwwiZeCN/3RhvmTMt9W rdKT+qb/vBD1ddGSoC9TKCw9tdjcoTskdaPB5e4lst2JvsPsG8k7vxTb1a76sCLqgf2OzT cuUSHHetIhIu52TSdgwzYLkmuvGdx1J7NqAmPQwDxrQup2/GcoyyNOBPVniPJ8WBqcAS8A 6KbMxbEpwSMpNa/ZiDj0eAjf5/EWyd6iMB8QtiFIr60CG3/gEmikL/BelB23AA== From: Maxime Chevallier To: davem@davemloft.net, Rob Herring Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Andrew Lunn , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Florian Fainelli , Heiner Kallweit , Russell King , linux-arm-kernel@lists.infradead.org, Krzysztof Kozlowski , devicetree@vger.kernel.org Subject: [PATCH net-next 1/3] net: pcs: altera-tse: use read_poll_timeout to wait for reset Date: Fri, 25 Nov 2022 14:17:59 +0100 Message-Id: <20221125131801.64234-2-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221125131801.64234-1-maxime.chevallier@bootlin.com> References: <20221125131801.64234-1-maxime.chevallier@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS 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 Software resets on the TSE PCS don't clear registers, but rather reset all internal state machines regarding AN, comma detection and encoding/decoding. Use read_poll_timeout to wait for the reset to clear instead of manually polling the register. Signed-off-by: Maxime Chevallier --- drivers/net/pcs/pcs-altera-tse.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/net/pcs/pcs-altera-tse.c b/drivers/net/pcs/pcs-altera-tse.c index 97a7cabff962..e86cadc391e8 100644 --- a/drivers/net/pcs/pcs-altera-tse.c +++ b/drivers/net/pcs/pcs-altera-tse.c @@ -60,7 +60,6 @@ static void tse_pcs_write(struct altera_tse_pcs *tse_pcs, int regnum, static int tse_pcs_reset(struct altera_tse_pcs *tse_pcs) { - int i = 0; u16 bmcr; /* Reset PCS block */ @@ -68,13 +67,9 @@ static int tse_pcs_reset(struct altera_tse_pcs *tse_pcs) bmcr |= BMCR_RESET; tse_pcs_write(tse_pcs, MII_BMCR, bmcr); - for (i = 0; i < SGMII_PCS_SW_RESET_TIMEOUT; i++) { - if (!(tse_pcs_read(tse_pcs, MII_BMCR) & BMCR_RESET)) - return 0; - udelay(1); - } - - return -ETIMEDOUT; + return read_poll_timeout(tse_pcs_read, bmcr, (bmcr & BMCR_RESET), + 10, SGMII_PCS_SW_RESET_TIMEOUT, 1, + tse_pcs, MII_BMCR); } static int alt_tse_pcs_validate(struct phylink_pcs *pcs, -- 2.38.1