From patchwork Mon Jan 15 14:56:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alexis_Lothor=C3=A9?= X-Patchwork-Id: 188223 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2614:b0:101:6a76:bbe3 with SMTP id mm20csp1760668dyc; Mon, 15 Jan 2024 07:08:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IFPUg7ALZIsqQ7SUy5dhqrjFQbpMGdCL4GyGKspYyvnvob2W0srWYTSRVF5d5FshVaz3dGu X-Received: by 2002:a17:907:3a14:b0:a2a:640d:3c64 with SMTP id fb20-20020a1709073a1400b00a2a640d3c64mr4609629ejc.32.1705331283718; Mon, 15 Jan 2024 07:08:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705331283; cv=none; d=google.com; s=arc-20160816; b=GzoCfBrbgYKq7/wP/0HThIl0ZYweq3nlkXkvoMfoeiLKKl62T2y5sKW9gQI49Z9JZ1 sMEJXxgXJiBtzlrhL0HfZCGXMrs2XM+SkHA1AXSRe7OOJsbUpkLqVvDAmMIn1CLZ/I5r iwvXBxyccysTB6FryZaqd7QJfJq0LF0aaD12/GFr6WcIxk1BXKybz4fFpEL8DAcAuUMm mGUMXoYFpXjyzxMmbUzhr5RlMMs+N+No1acrupRBCGt5ef4Ojqg0LDWi6xl4t16no4qj vCFNPATzDNPmWDYgnkivyJKVRV+6Xsm1MZy6NMheqDBnKJ93TXw5kGpzn3o07yYgqnq3 jOeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=zbYOaOM3QGrDC1DK3YRlyfVFVMs9CV5+vSCXqg6nHbs=; fh=jNt7BTrn7eCiWlnQ3eh96G8VRgXhssn8dx2sFpswZac=; b=BI15tLN8p63FN67bqh6r1zf7D5T5GlAIEV22ypWrUxPFtYUi3nDhQwpDgcy9znkQEg JKLZtAE5Js3FUoIJvukCM7VPaQsYFeWWNlc/ol5lJ13vMWLhFmS7B5b1kKaWaiNjFhcp jt8DFn1ZtBV+FF05gcgNH+TZaRwzXNY4ZbmmYW+z5E0Rbh+7m5TQ9VsIma8caFjJhzwc yhzEX2KyIVyPzivtLfeSGUBZYeN+xqQgQ7trDTVQs8IODyb1ibCigBSS1W2sFCGc48YE DvgAD19evulxSjbBgw1xOGV5r/OlLhVYNdxZ22PhSwHl3lQUKIdUNJz4Qx4EoYRVqn55 cDCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=VRCkCtrQ; spf=pass (google.com: domain of linux-kernel+bounces-26158-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26158-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id q19-20020a1709066b1300b00a27586b81e9si3757099ejr.256.2024.01.15.07.08.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 07:08:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26158-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=VRCkCtrQ; spf=pass (google.com: domain of linux-kernel+bounces-26158-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26158-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 56F4A1F229A9 for ; Mon, 15 Jan 2024 15:08:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EF60318638; Mon, 15 Jan 2024 15:06:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="VRCkCtrQ" Received: from mslow1.mail.gandi.net (mslow1.mail.gandi.net [217.70.178.240]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 15894182BF; Mon, 15 Jan 2024 15:06:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: from relay9-d.mail.gandi.net (unknown [217.70.183.199]) by mslow1.mail.gandi.net (Postfix) with ESMTP id A4CDAC6470; Mon, 15 Jan 2024 14:59:21 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 1246BFF80F; Mon, 15 Jan 2024 14:59:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1705330754; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zbYOaOM3QGrDC1DK3YRlyfVFVMs9CV5+vSCXqg6nHbs=; b=VRCkCtrQqelHjj9OS2DN1LwBbCx7PMCRs/YxKZgFM45s4k16/w4/tqPmVdhmB6mBRdqK7m w/tICl/5UzYHjurWgXpQEbZKaojMyY5YCK4zS/BZriki33p+OWdmYJzkc8+nVhzN7IPqSj 7LCtL1qxF73Aic6UJK3UKZibxvsWBSYCJpBUmSHZTi623MUVspF+jmfI8A/qd0xVyCA6hF x8zabXhn/jvtAc+A+XjfZWwDumDlVBqZh2gbWCfjYMPBxDWnC3AEBVma96Aco/2pR/cjgK sgWzh/wj+byWJcrlUlHLe2wPpYy6QXCNNi6Pa4h4kui9XF3wr3EgroA+9eStrQ== From: =?utf-8?q?Alexis_Lothor=C3=A9?= Date: Mon, 15 Jan 2024 15:56:33 +0100 Subject: [PATCH 4/5] wifi: wilc1000: fix incorrect power down sequence Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240115-wilc_1000_fixes-v1-4-54d29463a738@bootlin.com> References: <20240115-wilc_1000_fixes-v1-0-54d29463a738@bootlin.com> In-Reply-To: <20240115-wilc_1000_fixes-v1-0-54d29463a738@bootlin.com> To: linux-wireless@vger.kernel.org Cc: Ajay Singh , Claudiu Beznea , Kalle Valo , David Mosberger-Tang , Thomas Petazzoni , linux-kernel@vger.kernel.org, Michael Walle , =?utf-8?q?Alexis_Lothor=C3=A9?= X-Mailer: b4 0.12.4 X-GND-Sasl: alexis.lothore@bootlin.com X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788169456373465741 X-GMAIL-MSGID: 1788169456373465741 From: Ajay Singh Use the correct register configuration when the WILC chip is down so the successive interface up operation is successful. The modified registers values during chip down helps to avoid the "FW not responding" debug message which sometimes occurs because of temporary bus communication failure during the next start. Also, make sure on first communication with the chip that it is indeed woken up. Reported-by: Michael Walle Closes: https://lore.kernel.org/linux-wireless/20221026085415.6jgwrhq4sunqaypm@0002.3ffe.de/ Signed-off-by: Ajay Singh Signed-off-by: Alexis LothorĂ© --- drivers/net/wireless/microchip/wilc1000/wlan.c | 33 +++++++++++++++----------- drivers/net/wireless/microchip/wilc1000/wlan.h | 6 +++++ 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c index 9eb115c79c90..6b2f2269ddf8 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.c +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c @@ -1198,27 +1198,32 @@ int wilc_wlan_stop(struct wilc *wilc, struct wilc_vif *vif) acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); - ret = wilc->hif_func->hif_read_reg(wilc, WILC_GP_REG_0, ®); - if (ret) { - netdev_err(vif->ndev, "Error while reading reg\n"); + ret = wilc->hif_func->hif_read_reg(wilc, GLOBAL_MODE_CONTROL, ®); + if (ret) goto release; - } - ret = wilc->hif_func->hif_write_reg(wilc, WILC_GP_REG_0, - (reg | WILC_ABORT_REQ_BIT)); - if (ret) { - netdev_err(vif->ndev, "Error while writing reg\n"); + reg &= ~WILC_GLOBAL_MODE_ENABLE_WIFI; + ret = wilc->hif_func->hif_write_reg(wilc, GLOBAL_MODE_CONTROL, reg); + if (ret) + goto release; + + ret = wilc->hif_func->hif_read_reg(wilc, PWR_SEQ_MISC_CTRL, ®); + if (ret) + goto release; + + reg &= ~WILC_PWR_SEQ_ENABLE_WIFI_SLEEP; + ret = wilc->hif_func->hif_write_reg(wilc, PWR_SEQ_MISC_CTRL, reg); + if (ret) goto release; - } - ret = wilc->hif_func->hif_read_reg(wilc, WILC_FW_HOST_COMM, ®); + ret = wilc->hif_func->hif_read_reg(wilc, WILC_GP_REG_0, ®); if (ret) { netdev_err(vif->ndev, "Error while reading reg\n"); goto release; } - reg = BIT(0); - ret = wilc->hif_func->hif_write_reg(wilc, WILC_FW_HOST_COMM, reg); + ret = wilc->hif_func->hif_write_reg(wilc, WILC_GP_REG_0, + (reg | WILC_ABORT_REQ_BIT)); if (ret) { netdev_err(vif->ndev, "Error while writing reg\n"); goto release; @@ -1410,7 +1415,7 @@ static int init_chip(struct net_device *dev) struct wilc_vif *vif = netdev_priv(dev); struct wilc *wilc = vif->wilc; - acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY); + acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); chipid = wilc_get_chipid(wilc, true); @@ -1440,7 +1445,7 @@ static int init_chip(struct net_device *dev) } release: - release_bus(wilc, WILC_BUS_RELEASE_ONLY); + release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); return ret; } diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.h b/drivers/net/wireless/microchip/wilc1000/wlan.h index a72cd5cac81d..f02775f7e41f 100644 --- a/drivers/net/wireless/microchip/wilc1000/wlan.h +++ b/drivers/net/wireless/microchip/wilc1000/wlan.h @@ -156,6 +156,12 @@ #define WILC_GP_REG_0 0x149c #define WILC_GP_REG_1 0x14a0 +#define GLOBAL_MODE_CONTROL 0x1614 +#define PWR_SEQ_MISC_CTRL 0x3008 + +#define WILC_GLOBAL_MODE_ENABLE_WIFI BIT(0) +#define WILC_PWR_SEQ_ENABLE_WIFI_SLEEP BIT(28) + #define WILC_HAVE_SDIO_IRQ_GPIO BIT(0) #define WILC_HAVE_USE_PMU BIT(1) #define WILC_HAVE_SLEEP_CLK_SRC_RTC BIT(2)