From patchwork Tue Nov 17 05:32:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve deRosier X-Patchwork-Id: 7632951 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 67678BF90C for ; Tue, 17 Nov 2015 05:34:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 82C2C20511 for ; Tue, 17 Nov 2015 05:34:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 64CD12050E for ; Tue, 17 Nov 2015 05:34:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751526AbbKQFen (ORCPT ); Tue, 17 Nov 2015 00:34:43 -0500 Received: from mail-qg0-f41.google.com ([209.85.192.41]:36337 "EHLO mail-qg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751147AbbKQFel (ORCPT ); Tue, 17 Nov 2015 00:34:41 -0500 Received: by qgad10 with SMTP id d10so65982455qga.3 for ; Mon, 16 Nov 2015 21:34:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=n3x3zOBiXOnr6qUJsKNy5l39Wzmk3RLv+YKhwqdedAw=; b=aujM5ZR13plTs7j9fym7Oy/zgieRp79HJUzOILMjKapeJQ6b+6H3yI3Pt0yfPyOHDk 9hL+ToP1QYOVO4/mT8m3yhE2QqHkKK0xsa7ItWzeHtN0I1elB2eDOL35xLvPpXDsgmK6 Nyt+1VuyIDl8cncLKrSarIbF5LiDNQwQ8ULOtTRg9fHpuUn6KWYsDxYpFlc0UGPCiTrG oPtug/+WOOmSRqIjSLzeFwNGXoEP5RC9FbFbsxHVZ7/TgwN7y83+tbJcVCXVqfE08GF1 QzE9DbRjdQR7imrsIfJtapdwxgaZCD/el9vv3NYPhtkeocqod+uWXxV/GtAXlESo/VI6 Ox0g== X-Received: by 10.140.95.66 with SMTP id h60mr40837717qge.14.1447738481017; Mon, 16 Nov 2015 21:34:41 -0800 (PST) Received: from elmer.corp.lairdtech.com (c-50-184-185-234.hsd1.ca.comcast.net. [50.184.185.234]) by smtp.gmail.com with ESMTPSA id c48sm9692963qge.49.2015.11.16.21.34.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 16 Nov 2015 21:34:40 -0800 (PST) From: Steve deRosier X-Google-Original-From: Steve deRosier To: Kalle Valo Cc: ath6kl@lists.infradead.org, linux-wireless@vger.kernel.org, Steve deRosier Subject: [PATCH 2/2] ath6kl_sdio: Add power gpio reset feature into sdio driver for suspend Date: Mon, 16 Nov 2015 21:32:53 -0800 Message-Id: <1447738373-15804-3-git-send-email-steve.derosier@lairdtech.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1447738373-15804-1-git-send-email-steve.derosier@lairdtech.com> References: <1447738373-15804-1-git-send-email-steve.derosier@lairdtech.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This change adds pm suspend callbacks in order to trigger a gpio line to push the CHIP_PWD_L reset/power line low on suspend. This puts the chip into the lowest power state on suspend. On resume, it releases the line, allowing the chip to boot. Slower, but provides a clean reset of the chip and recovery from standby. Signed-off-by: Steve deRosier --- drivers/net/wireless/ath/ath6kl/sdio.c | 45 ++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index 7a732f3..b296809 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -1290,9 +1290,54 @@ static int ath6kl_sdio_pm_resume(struct device *device) return 0; } +#ifdef CONFIG_GPIOLIB +/* Below handlers leverage the PM system to make sure we turn on and off + * the power gpio at the right time. If we do it in the earlier power on + * and off handlers for the sdio, we get errors from the mmc subsystem. + */ +static int ath6kl_sdio_pm_suspend_late(struct device *device) +{ + ath6kl_dbg(ATH6KL_DBG_SUSPEND, "sdio pm ath6kl_sdio_pm_suspend_late\n"); + + if (gpio_is_valid(reset_pwd_gpio)) + gpio_set_value(reset_pwd_gpio, 0); + + return 0; +} + +static int ath6kl_sdio_pm_resume_early(struct device *device) +{ + ath6kl_dbg(ATH6KL_DBG_SUSPEND, "sdio pm ath6kl_sdio_pm_resume_early\n"); + + if (gpio_is_valid(reset_pwd_gpio)) + gpio_set_value(reset_pwd_gpio, 1); + + usleep_range(1000, 5000); /* wait for power up */ + + return 0; +} + +/* The GPIO version requires the more complex dev_pm_ops setup */ +const struct dev_pm_ops ath6kl_sdio_pm_ops = { + .suspend = ath6kl_sdio_pm_suspend, + .suspend_late = ath6kl_sdio_pm_suspend_late, + .resume_early = ath6kl_sdio_pm_resume_early, + .resume = ath6kl_sdio_pm_resume, + .freeze = ath6kl_sdio_pm_suspend, + .thaw = ath6kl_sdio_pm_resume, + .poweroff = ath6kl_sdio_pm_suspend, + .poweroff_late = ath6kl_sdio_pm_suspend_late, + .restore_early = ath6kl_sdio_pm_resume_early, + .restore = ath6kl_sdio_pm_resume, +}; + +#else + static SIMPLE_DEV_PM_OPS(ath6kl_sdio_pm_ops, ath6kl_sdio_pm_suspend, ath6kl_sdio_pm_resume); +#endif /* CONFIG_GPIOLIB */ + #define ATH6KL_SDIO_PM_OPS (&ath6kl_sdio_pm_ops) #else