From patchwork Fri Sep 28 06:39:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10618989 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D9A4A417B for ; Fri, 28 Sep 2018 06:40:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF52D2AF85 for ; Fri, 28 Sep 2018 06:40:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C38BE2AF96; Fri, 28 Sep 2018 06:40:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 73FAB2AF85 for ; Fri, 28 Sep 2018 06:40:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728888AbeI1NCm (ORCPT ); Fri, 28 Sep 2018 09:02:42 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:39252 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726738AbeI1NCm (ORCPT ); Fri, 28 Sep 2018 09:02:42 -0400 Received: by mail-wm1-f68.google.com with SMTP id q8-v6so992271wmq.4 for ; Thu, 27 Sep 2018 23:40:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=HB1OoSZlkw0rh4TD3tTpYJC1r4uovVON5wUZjwGUgg0=; b=Ucqa18UBYWJkJMuLUHI7FARqhBH9QpP9vJMj12+UbTAq/nUCWC1OZtmAsQPsPI4vj/ JDlXs+sM4Dlhg9X7c6KrnQh19bWk32m+PskxHrteyJm88o2ey32u+6s4qj3IYYdzMuMJ Mi2nRRC5SFqcvsiBrcuy4tKPAWl5WeEj4XjpHoK2MNHrajaohu4vWi39NkYCp9E6CLqh mnBzwRp1k/5I+W96fnKnziymxnz1eXDLkSZBTcKonz/33/ZFQV/VQa9GNvyY7x5WIw8T fvrHFBgQU0cuwBvaWgMyfVlWgAT8adHIjmxpz3JKfk/xn1zEKmAwWW7q2AfFDMZdIzrt 4Jiw== X-Gm-Message-State: ABuFfoiHcE8dELekY04tsLlNAd7VKnSVLBItAITSXtrmdgfC7OH6ld8G wohBkeH52d4MCBCizsTqvXyQhQ== X-Google-Smtp-Source: ACcGV620it9X2aTM1CBOrJp07FWXYqGkmcLm1V9qGZLqfht4KsB7lrbtwBcYAiY6Cvot5i1wIo2atA== X-Received: by 2002:a1c:3795:: with SMTP id e143-v6mr673574wma.9.1538116828509; Thu, 27 Sep 2018 23:40:28 -0700 (PDT) Received: from localhost.localdomain ([151.66.32.138]) by smtp.gmail.com with ESMTPSA id y4-v6sm5605105wrd.25.2018.09.27.23.40.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Sep 2018 23:40:27 -0700 (PDT) From: Lorenzo Bianconi To: nbd@nbd.name Cc: sgruszka@redhat.com, linux-wireless@vger.kernel.org Subject: [PATCH v2 01/24] mt76x0: use mt76_poll in mt76x0_set_wlan_state Date: Fri, 28 Sep 2018 08:39:54 +0200 Message-Id: <20180928064017.26870-2-lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use mt76_poll utility routine in mt76x0_set_wlan_state to check if the PLL/XTAL is ready Signed-off-by: Lorenzo Bianconi --- .../net/wireless/mediatek/mt76/mt76x0/init.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/init.c b/drivers/net/wireless/mediatek/mt76/mt76x0/init.c index 3a88be267daf..5e3ec1bef144 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/init.c @@ -43,7 +43,7 @@ static void mt76x0_vht_cap_mask(struct ieee80211_supported_band *sband) static void mt76x0_set_wlan_state(struct mt76x0_dev *dev, u32 val, bool enable) { - int i; + u32 mask = MT_CMB_CTRL_XTAL_RDY | MT_CMB_CTRL_PLL_LD; /* Note: we don't turn off WLAN_CLK because that makes the device * not respond properly on the probe path. @@ -60,24 +60,12 @@ mt76x0_set_wlan_state(struct mt76x0_dev *dev, u32 val, bool enable) mt76_wr(dev, MT_WLAN_FUN_CTRL, val); udelay(20); - if (!enable) - return; - - for (i = 200; i; i--) { - val = mt76_rr(dev, MT_CMB_CTRL); - - if (val & MT_CMB_CTRL_XTAL_RDY && val & MT_CMB_CTRL_PLL_LD) - break; - - udelay(20); - } - /* Note: vendor driver tries to disable/enable wlan here and retry * but the code which does it is so buggy it must have never * triggered, so don't bother. */ - if (!i) - dev_err(dev->mt76.dev, "Error: PLL and XTAL check failed!\n"); + if (enable && !mt76_poll(dev, MT_CMB_CTRL, mask, mask, 2000)) + dev_err(dev->mt76.dev, "PLL and XTAL check failed\n"); } void mt76x0_chip_onoff(struct mt76x0_dev *dev, bool enable, bool reset)