* [RESEND PATCH] mmc: sdhci: fix wakeup configuration
@ 2016-05-13 9:27 Ludovic Desroches
2016-05-13 11:37 ` Adrian Hunter
0 siblings, 1 reply; 6+ messages in thread
From: Ludovic Desroches @ 2016-05-13 9:27 UTC (permalink / raw)
To: adrian.hunter, ulf.hansson
Cc: linux-mmc, linux-kernel, nicolas.ferre, Ludovic Desroches
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.
Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
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().
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.
- 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?
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;
+ 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 ;
+ 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);
--
2.5.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [RESEND PATCH] mmc: sdhci: fix wakeup configuration
2016-05-13 9:27 [RESEND PATCH] mmc: sdhci: fix wakeup configuration Ludovic Desroches
@ 2016-05-13 11:37 ` Adrian Hunter
2016-05-13 12:19 ` Ludovic Desroches
0 siblings, 1 reply; 6+ messages in thread
From: Adrian Hunter @ 2016-05-13 11:37 UTC (permalink / raw)
To: Ludovic Desroches
Cc: ulf.hansson, linux-mmc, linux-kernel, nicolas.ferre, Kevin Liu,
Jialing Fu, Jisheng Zhang
+ 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 <ludovic.desroches@atmel.com>
> ---
> 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);
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RESEND PATCH] mmc: sdhci: fix wakeup configuration
2016-05-13 11:37 ` Adrian Hunter
@ 2016-05-13 12:19 ` Ludovic Desroches
2016-05-13 12:46 ` Adrian Hunter
0 siblings, 1 reply; 6+ messages in thread
From: Ludovic Desroches @ 2016-05-13 12:19 UTC (permalink / raw)
To: Adrian Hunter
Cc: Ludovic Desroches, ulf.hansson, linux-mmc, linux-kernel,
nicolas.ferre, Kevin Liu, Jialing Fu, Jisheng Zhang
On Fri, May 13, 2016 at 02:37:21PM +0300, Adrian Hunter wrote:
> + 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?
>
Yes, I din't wake up on card event without this patch.
> >
> > Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
> > ---
> > 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.
I'll add it.
>
> >
> > 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?
>
I only use wakeup events and not irqs in system PM (patches for
sdhci-of-at91 are not sent yet, I am waiting for the inclusion of other
patches).
What I mean is that if we want to wake up from irqs, it could be safer and
clearer to set explicitely SDHCI_INT_ENABLE and SDHCI_SIGNAL_ENABLE in
sdhci_enable_irq_wakeups(). It is just a thought and not needed for this
patch.
> >
> > 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.
>
I thought it will be better to have wakeup_val and irq_val instead of
val and irq_val. That's why I renamed it while introducing irq_val.
> > + 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);
> >
> >
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RESEND PATCH] mmc: sdhci: fix wakeup configuration
2016-05-13 12:19 ` Ludovic Desroches
@ 2016-05-13 12:46 ` Adrian Hunter
0 siblings, 0 replies; 6+ messages in thread
From: Adrian Hunter @ 2016-05-13 12:46 UTC (permalink / raw)
To: Ludovic Desroches
Cc: ulf.hansson, linux-mmc, linux-kernel, nicolas.ferre, Kevin Liu,
Jialing Fu, Jisheng Zhang
On 13/05/16 15:19, Ludovic Desroches wrote:
> On Fri, May 13, 2016 at 02:37:21PM +0300, Adrian Hunter wrote:
>> + 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?
>>
>
> Yes, I din't wake up on card event without this patch.
>
>>>
>>> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
>>> ---
>>> 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.
>
> I'll add it.
>
>>
>>>
>>> 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?
>>
>
> I only use wakeup events and not irqs in system PM (patches for
> sdhci-of-at91 are not sent yet, I am waiting for the inclusion of other
> patches).
It doesn't hurt to say in the commit message what driver or hardware needed
the change.
>
> What I mean is that if we want to wake up from irqs, it could be safer and
> clearer to set explicitely SDHCI_INT_ENABLE and SDHCI_SIGNAL_ENABLE in
> sdhci_enable_irq_wakeups(). It is just a thought and not needed for this
> patch.
>
>>>
>>> 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.
>>
>
> I thought it will be better to have wakeup_val and irq_val instead of
> val and irq_val. That's why I renamed it while introducing irq_val.
val and irq_val are fine.
>
>>> + 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);
>>>
>>>
>>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [RESEND PATCH] mmc: sdhci: fix wakeup configuration
@ 2016-05-13 13:14 Ludovic Desroches
2016-05-13 13:17 ` Ludovic Desroches
0 siblings, 1 reply; 6+ messages in thread
From: Ludovic Desroches @ 2016-05-13 13:14 UTC (permalink / raw)
To: adrian.hunter, ulf.hansson
Cc: linux-mmc, linux-kernel, nicolas.ferre, kliu5, jlfu, jszhang,
Ludovic Desroches
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.
Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
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().
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.
- 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?
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;
+ 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 ;
+ 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);
--
2.5.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [RESEND PATCH] mmc: sdhci: fix wakeup configuration
2016-05-13 13:14 Ludovic Desroches
@ 2016-05-13 13:17 ` Ludovic Desroches
0 siblings, 0 replies; 6+ messages in thread
From: Ludovic Desroches @ 2016-05-13 13:17 UTC (permalink / raw)
To: adrian.hunter, ulf.hansson
Cc: linux-mmc, linux-kernel, nicolas.ferre, kliu5, jlfu, jszhang,
Ludovic Desroches
Mistake while sending v2, sorry for the noise.
On Fri, May 13, 2016 at 03:14:46PM +0200, 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.
>
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
> ---
> 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().
>
> 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.
> - 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?
>
> 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;
> + 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 ;
> + 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);
>
> --
> 2.5.0
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-05-13 13:17 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-13 9:27 [RESEND PATCH] mmc: sdhci: fix wakeup configuration Ludovic Desroches
2016-05-13 11:37 ` Adrian Hunter
2016-05-13 12:19 ` Ludovic Desroches
2016-05-13 12:46 ` Adrian Hunter
-- strict thread matches above, loose matches on Subject: below --
2016-05-13 13:14 Ludovic Desroches
2016-05-13 13:17 ` Ludovic Desroches
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).