From: Steve deRosier <derosier@gmail.com>
To: Kalle Valo <kvalo@qca.qualcomm.com>
Cc: ath6kl@lists.infradead.org, linux-wireless@vger.kernel.org,
Julian Calaby <julian.calaby@gmail.com>,
Steve deRosier <steve.derosier@lairdtech.com>
Subject: [PATCH v3 1/2] ath6kl_sdio: Add reset gpio module parameter for CHIP_PWD_L pin
Date: Sun, 22 Nov 2015 16:15:46 -0800 [thread overview]
Message-ID: <1448237747-20037-2-git-send-email-steve.derosier@lairdtech.com> (raw)
In-Reply-To: <1448237747-20037-1-git-send-email-steve.derosier@lairdtech.com>
Many ath6k chips have a reset pin, usually labeled CHIP_PWD_L. This pin can
be pulled low by the host processor to hold the wifi chip in reset. By
holding the chip in reset, the lowest power consumption available can be
achieved.
This adds a module parameter so the ath6kl_sdio driver can control the
CHIP_PWD_L pin if the implementer so desires. This code is only available
if GPIOLIB is configured.
Signed-off-by: Steve deRosier <steve.derosier@lairdtech.com>
---
drivers/net/wireless/ath/ath6kl/sdio.c | 70 +++++++++++++++++++++++++++++++++-
1 file changed, 69 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c
index eab0ab9..d06aa41 100644
--- a/drivers/net/wireless/ath/ath6kl/sdio.c
+++ b/drivers/net/wireless/ath/ath6kl/sdio.c
@@ -23,6 +23,7 @@
#include <linux/mmc/sdio_ids.h>
#include <linux/mmc/sdio.h>
#include <linux/mmc/sd.h>
+#include <linux/gpio.h>
#include "hif.h"
#include "hif-ops.h"
#include "target.h"
@@ -69,6 +70,20 @@ struct ath6kl_sdio {
spinlock_t wr_async_lock;
};
+/* Delay to avoid the mmc driver calling the probe on the prior notice of
+ * the chip, which we just killed. If this is missing, it results in a
+ * spurious warning:
+ * "ath6kl_sdio: probe of mmc0:0001:1 failed with error -110"
+ *
+ * Time chosen experimentally, with padding
+ */
+#define ATH6KL_MMC_PROBE_DELAY 150
+static unsigned int reset_pwd_gpio = ARCH_NR_GPIOS;
+#ifdef CONFIG_GPIOLIB
+module_param(reset_pwd_gpio, uint, 0644);
+MODULE_PARM_DESC(reset_pwd_gpio, "WIFI CHIP_PWD reset pin GPIO");
+#endif
+
#define CMD53_ARG_READ 0
#define CMD53_ARG_WRITE 1
#define CMD53_ARG_BLOCK_BASIS 1
@@ -1414,20 +1429,73 @@ static struct sdio_driver ath6kl_sdio_driver = {
.drv.pm = ATH6KL_SDIO_PM_OPS,
};
+static int ath6kl_sdio_init_gpio(void)
+{
+ int ret = 0;
+
+ if (gpio_is_valid(reset_pwd_gpio)) {
+ /* Request the reset GPIO, and assert it to make sure we get a
+ * clean boot in-case we had a floating input or other issue.
+ */
+ ret = gpio_request_one(reset_pwd_gpio,
+ GPIOF_OUT_INIT_LOW |
+ GPIOF_EXPORT_DIR_FIXED,
+ "WIFI_RESET");
+ if (ret) {
+ ath6kl_err("Unable to get WIFI power gpio: %d\n", ret);
+ return ret;
+ }
+
+ ath6kl_dbg(ATH6KL_DBG_SUSPEND, "Setup wifi gpio #%d\n",
+ reset_pwd_gpio);
+ usleep_range(20, 50); /* Pin must be asserted at least 5 usec */
+ gpio_set_value(reset_pwd_gpio, 1); /* De-assert the pin */
+
+ msleep(ATH6KL_MMC_PROBE_DELAY);
+ }
+
+ return 0;
+}
+
+static void ath6kl_sdio_release_gpio(void)
+{
+ if (gpio_is_valid(reset_pwd_gpio)) {
+ /* Be sure we leave the chip in reset when we unload and also
+ * release the GPIO
+ */
+ gpio_set_value(reset_pwd_gpio, 0);
+ gpio_free(reset_pwd_gpio);
+ }
+}
+
static int __init ath6kl_sdio_init(void)
{
int ret;
- ret = sdio_register_driver(&ath6kl_sdio_driver);
+ ret = ath6kl_sdio_init_gpio();
if (ret)
+ goto err_gpio;
+
+ ret = sdio_register_driver(&ath6kl_sdio_driver);
+ if (ret) {
ath6kl_err("sdio driver registration failed: %d\n", ret);
+ goto err_register;
+ }
return ret;
+
+err_register:
+ ath6kl_sdio_release_gpio();
+
+err_gpio:
+ return ret;
}
static void __exit ath6kl_sdio_exit(void)
{
sdio_unregister_driver(&ath6kl_sdio_driver);
+
+ ath6kl_sdio_release_gpio();
}
module_init(ath6kl_sdio_init);
--
1.9.1
next prev parent reply other threads:[~2015-11-23 0:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-23 0:15 [PATCH v3 0/2] ath6kl_sdio: add control of CHIP_PWD_L via GPIO Steve deRosier
2015-11-23 0:15 ` Steve deRosier [this message]
2015-12-01 13:01 ` [PATCH v3 1/2] ath6kl_sdio: Add reset gpio module parameter for CHIP_PWD_L pin Kalle Valo
2015-12-06 0:19 ` kbuild test robot
2015-11-23 0:15 ` [PATCH v3 2/2] ath6kl_sdio: Add power gpio reset feature into sdio driver for suspend Steve deRosier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1448237747-20037-2-git-send-email-steve.derosier@lairdtech.com \
--to=derosier@gmail.com \
--cc=ath6kl@lists.infradead.org \
--cc=julian.calaby@gmail.com \
--cc=kvalo@qca.qualcomm.com \
--cc=linux-wireless@vger.kernel.org \
--cc=steve.derosier@lairdtech.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).