From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932117AbcEMLlb (ORCPT ); Fri, 13 May 2016 07:41:31 -0400 Received: from mga03.intel.com ([134.134.136.65]:33414 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751139AbcEMLl3 (ORCPT ); Fri, 13 May 2016 07:41:29 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,614,1455004800"; d="scan'208";a="702217799" Subject: Re: [RESEND PATCH] mmc: sdhci: fix wakeup configuration To: Ludovic Desroches References: <1463131622-6380-1-git-send-email-ludovic.desroches@atmel.com> Cc: ulf.hansson@linaro.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, nicolas.ferre@atmel.com, Kevin Liu , Jialing Fu , Jisheng Zhang From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Message-ID: <5735BC71.4020500@intel.com> Date: Fri, 13 May 2016 14:37:21 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 MIME-Version: 1.0 In-Reply-To: <1463131622-6380-1-git-send-email-ludovic.desroches@atmel.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org + cc some Marvell people because they added this code On 13/05/16 12:27, Ludovic Desroches wrote: > Activating wakeup event is not enough to get a wakeup signal. The > corresponding events have to be enabled in the Interrupt Status Enable > Register too. That seems to follow the specification. Did you find that you actually needed this change to get it to work? > > Signed-off-by: Ludovic Desroches > --- > Hi, > > I just updated sdhci_enable_irq_wakeups() not sdhci_disable_irq_wakeups() > because I don't think it is necessary to configure SDHCI_INT_ENABLE at this > step, it will be done with sdhci_init() or sdhci_enable_card_detection(). OK, but that should be in the commit message and commented in the code too. > > While I was writing this patch, several questions came to my mind: > - Is the naming correct? wakeup signal is not an irq. 'enable_irq_wakeups' can > be a bit confusing. I don't support renaming things unless the names are really really bad. These names are OK. > - If we want to wakeup from irq, we may have to set SDHCI_INT_ENABLE and > SDHCI_SIGNAL_ENABLE and not rely on a previous configuration, isn't it? I imagine the card interrupt will occur when it is enabled. I don't know about card insert / remove. What works for you? > > Regards > > Ludovic > > drivers/mmc/host/sdhci.c | 26 ++++++++++++++++++-------- > 1 file changed, 18 insertions(+), 8 deletions(-) > > diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c > index b284924..6fc69ed 100644 > --- a/drivers/mmc/host/sdhci.c > +++ b/drivers/mmc/host/sdhci.c > @@ -2638,18 +2638,28 @@ static irqreturn_t sdhci_thread_irq(int irq, void *dev_id) > \*****************************************************************************/ > > #ifdef CONFIG_PM > +/* > + * To enable wakeup events, the corresponding events have to be enabled in > + * the Interrupt Status Enable register too. See 'Table 1-6: Wakeup Signal > + * Table' in the SD Host Controller Standard Specification. > + */ > void sdhci_enable_irq_wakeups(struct sdhci_host *host) > { > - u8 val; > - u8 mask = SDHCI_WAKE_ON_INSERT | SDHCI_WAKE_ON_REMOVE > - | SDHCI_WAKE_ON_INT; > + u8 wakeup_val; > + u8 wakeup_mask = SDHCI_WAKE_ON_INSERT | SDHCI_WAKE_ON_REMOVE | > + SDHCI_WAKE_ON_INT; Please don't rename variables, or tidy-up code that you are not changing. > + u32 irq_val = SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE | > + SDHCI_INT_CARD_INT; > > - val = sdhci_readb(host, SDHCI_WAKE_UP_CONTROL); > - val |= mask ; These 2 line are actually unchanged. > + wakeup_val = sdhci_readb(host, SDHCI_WAKE_UP_CONTROL); > + wakeup_val |= wakeup_mask; > /* Avoid fake wake up */ > - if (host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) > - val &= ~(SDHCI_WAKE_ON_INSERT | SDHCI_WAKE_ON_REMOVE); > - sdhci_writeb(host, val, SDHCI_WAKE_UP_CONTROL); > + if (host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) { > + wakeup_val &= ~(SDHCI_WAKE_ON_INSERT | SDHCI_WAKE_ON_REMOVE); > + irq_val &= ~(SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE); > + } > + sdhci_writeb(host, wakeup_val, SDHCI_WAKE_UP_CONTROL); > + sdhci_writel(host, irq_val, SDHCI_INT_ENABLE); > } > EXPORT_SYMBOL_GPL(sdhci_enable_irq_wakeups); > >