From patchwork Wed Nov 18 23:20:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve deRosier X-Patchwork-Id: 7653451 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 376A89F1D3 for ; Wed, 18 Nov 2015 23:22:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5AF79205F7 for ; Wed, 18 Nov 2015 23:22:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0B25F20603 for ; Wed, 18 Nov 2015 23:22:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757386AbbKRXWm (ORCPT ); Wed, 18 Nov 2015 18:22:42 -0500 Received: from mail-qk0-f170.google.com ([209.85.220.170]:36790 "EHLO mail-qk0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757222AbbKRXWl (ORCPT ); Wed, 18 Nov 2015 18:22:41 -0500 Received: by qkda6 with SMTP id a6so20223388qkd.3 for ; Wed, 18 Nov 2015 15:22: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=NXj3FuDW4bYHBXa+bFk8zqBqj3pFcKBvX7XmonwPkCY=; b=jiwO4q26Dy0VbFyNO8cZkfJNMaEhFTO0dBjUAYlVUo88+DwnZZ725S1p/ZQas7GU0P e+9vlferLfoc7kQnfWervh8ILJA8VOSdGDWwG6mrZ2O42ymgvr1H83PDU7El0KNWUDxf CXbyG+1dimGz5Uc6YhvlBCJJ264UTZF6tXUQj9nDDy4dD7e+12xVMcCGaszwz7QfowJI Fz5gUyJKnQBte3/MpVqduAZtgX7XlmmNj04g/4z65LzC4EccR0qxwE2h6M68zQ+bDjAT oEfqWfiMNEu+MXrBnc+fjXCadWUGdI0MWTquckJ45ItXgNmUnCDp/4rliXOiUBBEmdmK UTTw== X-Received: by 10.55.82.137 with SMTP id g131mr4302649qkb.66.1447888960980; Wed, 18 Nov 2015 15:22:40 -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 v202sm739351qka.38.2015.11.18.15.22.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 18 Nov 2015 15:22: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 v2 2/2] ath6kl_sdio: Add power gpio reset feature into sdio driver for suspend Date: Wed, 18 Nov 2015 15:20:48 -0800 Message-Id: <1447888848-19530-3-git-send-email-steve.derosier@lairdtech.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1447888848-19530-1-git-send-email-steve.derosier@lairdtech.com> References: <1447888848-19530-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.3 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 c0755eb..c411033 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -1288,8 +1288,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)