From patchwork Mon Nov 23 00:15:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve deRosier X-Patchwork-Id: 7677171 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7156F9F1D3 for ; Mon, 23 Nov 2015 00:17:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8D074206EA for ; Mon, 23 Nov 2015 00:17:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 92DD5206E9 for ; Mon, 23 Nov 2015 00:17:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752895AbbKWARr (ORCPT ); Sun, 22 Nov 2015 19:17:47 -0500 Received: from mail-qg0-f52.google.com ([209.85.192.52]:36041 "EHLO mail-qg0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752813AbbKWARo (ORCPT ); Sun, 22 Nov 2015 19:17:44 -0500 Received: by qgcc31 with SMTP id c31so62993561qgc.3 for ; Sun, 22 Nov 2015 16:17:44 -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=QciKC53Kdsm2ED2VNVcM7Dg0eKZfyuQ0cxJuRgPK4VA=; b=tlUMqOGIWRGh63VLDvk78fYY/s9faYEHnVxq0knuFglw/ikdtzOGmYV09u345Tg4DF /sf2Olu06uJ451+tSd6BSa15Hz6a1YrhMXQc5YaZXQsitmQmxTRLRJmT1ZCp2zw9JCzA 5bALBDowdYnjqGOPJV5ooYLXDUNrDSybS9PNlRHgBOurlOEN4L1LXi2uM3MTI4lzkPbY LtnR/+hKjyy/xnaG/961l5JWyx8pot4fnfOuTh8P0rGM9QQ0oZw3wlPMBLvjtZIhUUyX /FvVTA/77m2IWmoaDPHJG1S9Yh5rLW7QHU3Q56t58zyeDBo9vJXGVGqWHSP0BNmk/+Fa myMw== X-Received: by 10.140.92.163 with SMTP id b32mr24751162qge.85.1448237864371; Sun, 22 Nov 2015 16:17:44 -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 q133sm2376767qhq.20.2015.11.22.16.17.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 22 Nov 2015 16:17:44 -0800 (PST) From: Steve deRosier X-Google-Original-From: Steve deRosier To: Kalle Valo Cc: ath6kl@lists.infradead.org, linux-wireless@vger.kernel.org, Julian Calaby , Steve deRosier Subject: [PATCH v3 2/2] ath6kl_sdio: Add power gpio reset feature into sdio driver for suspend Date: Sun, 22 Nov 2015 16:15:47 -0800 Message-Id: <1448237747-20037-3-git-send-email-steve.derosier@lairdtech.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1448237747-20037-1-git-send-email-steve.derosier@lairdtech.com> References: <1448237747-20037-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.4 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 | 40 ++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index d06aa41..cef311d 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -1295,8 +1295,44 @@ static int ath6kl_sdio_pm_resume(struct device *device) return 0; } -static SIMPLE_DEV_PM_OPS(ath6kl_sdio_pm_ops, ath6kl_sdio_pm_suspend, - ath6kl_sdio_pm_resume); +/* 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, +}; #define ATH6KL_SDIO_PM_OPS (&ath6kl_sdio_pm_ops)