Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp494139lqb; Wed, 17 Apr 2024 02:35:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVMIO2qUe7zFpzhH3Yl8/hnYHnx6JNxkiaGRfklC5mOZAVkuehzYHHPN4Jaf+Ezgq8S8YpBfLZzi4yx84ZMrLyKPhU0fzR6QVrYaipvjQ== X-Google-Smtp-Source: AGHT+IFsPC03FooNF7eDqpzcFLvwGrIlprpqajK05vw15BA1NiVE3QX5xrimNbW7LyfE5j0wv1xl X-Received: by 2002:a17:90b:4c04:b0:2aa:aad7:e473 with SMTP id na4-20020a17090b4c0400b002aaaad7e473mr5652924pjb.22.1713346553460; Wed, 17 Apr 2024 02:35:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713346553; cv=pass; d=google.com; s=arc-20160816; b=Md8dS3CEPkU/LiJprgm+w4xTtWyV6bE6XVpMROJ+OoMOc6pvu6b02wUf+K/RanF5C2 qtTtYHf99PhwBwXo7DIkut0xJxOeU5blasVF1sofwzDpAfRbk6AyMeXv3GBeYAnZGeoX x+NbTqrdcwJ6+d7tO9QzbRPD6rGsLBZNzkIbR8lcvdVSTKKfx8RxTm0fd8C7AB+b4sOU wy+VIW3YKuZtY+uK9+DNc11SHz7CDaPwtBcl7Dnnp4d+DoA2hSimA09tHWgEhfOsCDoK bzi+kGLj3ApoIoMj5TCeishqsniFawaTtZ9SXU85e3KPy65nQQTEiZZwOXqNOzudjYjk J+WA== ARC-Message-Signature: i=2; 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=HWaDtQEb7dwOp/Q7435hr2efY4FLjjZYmFKQ/nPyw3U=; fh=k15yWD4ZltoIGsKlbGcsGeIaHes0BFY8NEK3tQ/9pa0=; b=ziZ+3KG43Buq5dOXpAH5gLWJjaerhvj5LuQ/JJAjv9pepn2bq5f559V4FYNuQKWD63 KfhtouoLtUoTp8rcC6lfN69tQ/zHRkBn6hVw2ozkoN1euMZbAENRhXhi1ei3TEVfbAbK ZEGwA3Q3yIZy23AZCrc7mgf4Q33bfmK5iCLdOu8lXc6FG2K3dFlKKmZJjbHU9F/ZG+VQ g92WiEvDKFkFkJ2lPANqi8oh6xwCYaUDfAucS8UilMzpqoVhuJjfjQdX4cMY8yC5iyia uHsjh7B9WsG0uAkO4XH+mOQS9qjGTS5JXtX8eDNEDXYeHluCRL8Kr2aoRwx1ZIwHOKXh KarQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=lm9vnTGf; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-wireless+bounces-6438-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-wireless+bounces-6438-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id l7-20020a17090ac58700b002a2d9b88dc1si984167pjt.163.2024.04.17.02.35.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 02:35:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-6438-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=lm9vnTGf; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-wireless+bounces-6438-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-wireless+bounces-6438-linux.lists.archive=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id C51DD283534 for ; Wed, 17 Apr 2024 09:35:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D607913C683; Wed, 17 Apr 2024 09:34:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="lm9vnTGf" X-Original-To: linux-wireless@vger.kernel.org Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) (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 B27AC13B587; Wed, 17 Apr 2024 09:34:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713346466; cv=none; b=CGbVmy9xWQmurql5UMPS1l3q8S8CqH6hQyzHLTxGIxI/ctl+5pRMJzEDzfPmATs8R1fkvRAasVgffEzNgs6a7yzaiUr4iJeZNcOVAcOJJJlBO6WOCgj8On3iQFCaEEL4B+yq7GKuMqO4qZRXv+yItjjNgLGiUYIDBmaYuWSDlNE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713346466; c=relaxed/simple; bh=eGHupbbAXrOuVkyU7yVyj7B+fR4iB6zqnc40QsMfo1g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mfkEBLHRqmrtJGz2C20mnKMGt5+pWruowpeIuCS+B6ZHYmRJH9Rv/DkezFGvZD6HJqCLcvwjX1GEs3T8BvHnpAjvpI0b2gv40m5lqW5oXHO2qwqBeZpBCzj3CocM5M0oHxnkDhqT4F2PYSf6Hs3nk/qL9Vnxh/FTimK8C3CEFAY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=lm9vnTGf; arc=none smtp.client-ip=217.70.183.199 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: by mail.gandi.net (Postfix) with ESMTPSA id 4DB26FF807; Wed, 17 Apr 2024 09:34:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1713346456; 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=HWaDtQEb7dwOp/Q7435hr2efY4FLjjZYmFKQ/nPyw3U=; b=lm9vnTGflHUTqHkGsfltL26z4PU4h0vtaCrVhA+7oYPg9jP3QEVIZYebZjOCwN9BBUHBZn 7ivm/4AhqmXMXP9A0TYAy+kcKXNao/XROVxSvFACBLGavSGehOgBT66rx/bK4TGcVFaM3Z VhNzXKfugyz/b+to+VXZxmOVIDSC3xJgLplb3cCx7Pj3oBgLxk6jEKR6sTHRlEncPGCox7 pT0pZLbEaj4dlqHhcmhzJZuSho5nn/DcT2+sgJgyW031P+ybcXrqllMdMxp17sEpF5lcVW EVyHyOgupg3AS3gP0lNI9HWy2q2q0Ac4DA+1fo4ruJ/MuFuTZfe/AjC7SQvVpQ== From: =?utf-8?q?Alexis_Lothor=C3=A9?= Date: Wed, 17 Apr 2024 11:34:12 +0200 Subject: [PATCH 5/6] wifi: wilc1000: make sdio deinit function really deinit the sdio card Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20240417-mac_addr_at_probe-v1-5-67d6c9b3bc2b@bootlin.com> References: <20240417-mac_addr_at_probe-v1-0-67d6c9b3bc2b@bootlin.com> In-Reply-To: <20240417-mac_addr_at_probe-v1-0-67d6c9b3bc2b@bootlin.com> To: Ajay Singh , Claudiu Beznea , Kalle Valo Cc: Thomas Petazzoni , linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Alexis_Lothor=C3=A9?= X-Mailer: b4 0.13.0 X-GND-Sasl: alexis.lothore@bootlin.com In order to be able to read raw registers (eg the nv mac address) in wilc1000 during probe before the firmware is loaded and running, we need to run the basic sdio functions initialization, but then we also need to properly deinitialize those right after, to preserve the current driver behavior (keeping the chip idle/unconfigured until the corresponding interface is brought up). Calling wilc_sdio_deinit in its current form is not enough because it merely resets an internal flag. Implement a deinit sequence which symmetrically reset all steps performed in wilc_sdio_init (only for parts activating/deactivating features, for the sake of simplicity, let's ignore blocks size configuration reset) Signed-off-by: Alexis Lothoré --- drivers/net/wireless/microchip/wilc1000/sdio.c | 45 ++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/drivers/net/wireless/microchip/wilc1000/sdio.c b/drivers/net/wireless/microchip/wilc1000/sdio.c index a841dad08410..04d6565df2cb 100644 --- a/drivers/net/wireless/microchip/wilc1000/sdio.c +++ b/drivers/net/wireless/microchip/wilc1000/sdio.c @@ -627,7 +627,52 @@ static int wilc_sdio_read(struct wilc *wilc, u32 addr, u8 *buf, u32 size) static int wilc_sdio_deinit(struct wilc *wilc) { + struct sdio_func *func = dev_to_sdio_func(wilc->dev); struct wilc_sdio *sdio_priv = wilc->bus_data; + struct sdio_cmd52 cmd; + int ret; + + cmd.read_write = 1; + cmd.function = 0; + cmd.raw = 1; + + /* Disable all functions interrupts */ + cmd.address = SDIO_CCCR_IENx; + cmd.data = 0; + ret = wilc_sdio_cmd52(wilc, &cmd); + if (ret) { + dev_err(&func->dev, "Failed to disable functions interrupts\n"); + return ret; + } + + /* Disable all functions */ + cmd.address = SDIO_CCCR_IOEx; + cmd.data = 0; + ret = wilc_sdio_cmd52(wilc, &cmd); + if (ret) { + dev_err(&func->dev, + "Failed to reset all functions\n"); + return ret; + } + + /* Disable CSA */ + cmd.read_write = 0; + cmd.address = SDIO_FBR_BASE(1); + ret = wilc_sdio_cmd52(wilc, &cmd); + if (ret) { + dev_err(&func->dev, + "Failed to read CSA for function 1\n"); + return ret; + } + cmd.read_write = 1; + cmd.address = SDIO_FBR_BASE(1); + cmd.data &= ~SDIO_FBR_ENABLE_CSA; + ret = wilc_sdio_cmd52(wilc, &cmd); + if (ret) { + dev_err(&func->dev, + "Failed to disable CSA for function 1\n"); + return ret; + } sdio_priv->isinit = false; return 0; -- 2.44.0