Re: [PATCH 4/5] ARM: pxa168: added special case handler for keypad interrupts

From: Eric Miao
Date: Tue Aug 31 2010 - 03:16:13 EST


On Tue, Aug 31, 2010 at 3:13 PM, Mark F. Brown <mark.brown314@xxxxxxxxx> wrote:
> On Tue, Aug 31, 2010 at 3:05 AM, Eric Miao <eric.y.miao@xxxxxxxxx> wrote:
>> On Tue, Aug 31, 2010 at 2:28 PM, Mark F. Brown <mark.brown314@xxxxxxxxx> wrote:
>>> On Tue, Aug 31, 2010 at 12:53 AM, Haojian Zhuang
>>> <haojian.zhuang@xxxxxxxxx> wrote:
>>>> On Thu, Aug 26, 2010 at 5:18 PM, Mark F. Brown <mark.brown314@xxxxxxxxx> wrote:
>>>>> Signed-off-by: Mark F. Brown <mark.brown314@xxxxxxxxx>
>>>>> ---
>>>>> Âarch/arm/mach-mmp/irq-pxa168.c | Â 23 ++++++++++++++++++++++-
>>>>> Â1 files changed, 22 insertions(+), 1 deletions(-)
>>>>>
>>>>> diff --git a/arch/arm/mach-mmp/irq-pxa168.c b/arch/arm/mach-mmp/irq-pxa168.c
>>>>> index 52ff2f0..bfb0984 100644
>>>>> --- a/arch/arm/mach-mmp/irq-pxa168.c
>>>>> +++ b/arch/arm/mach-mmp/irq-pxa168.c
>>>>> @@ -17,6 +17,8 @@
>>>>> Â#include <linux/io.h>
>>>>>
>>>>> Â#include <mach/regs-icu.h>
>>>>> +#include <mach/regs-apmu.h>
>>>>> +#include <mach/cputype.h>
>>>>>
>>>>> Â#include "common.h"
>>>>>
>>>>> @@ -42,6 +44,19 @@ static struct irq_chip icu_irq_chip = {
>>>>> Â Â Â Â.unmask = icu_unmask_irq,
>>>>> Â};
>>>>>
>>>>> +void handle_pxa168_keypad_irq(unsigned int irq, struct irq_desc *desc)
>>>>> +{
>>>>> + Â Â Â uint32_t val;
>>>>> + Â Â Â uint32_t mask = APMU_PXA168_KP_WAKE_CLR;
>>>>> +
>>>>> + Â Â Â /* clear keypad wake event */
>>>>> + Â Â Â val = __raw_readl(APMU_WAKE_CLR);
>>>>> + Â Â Â __raw_writel(val | Âmask, APMU_WAKE_CLR);
>>>>> +
>>>>> + Â Â Â /* handle irq */
>>>>> + Â Â Â handle_level_irq(irq, desc);
>>>>> +}
>>>>> +
>>>>
>>>> Why should you clear wakeup event status in IRQ handler? If system is
>>>> resumed by keypad event, you should clear this wakeup source in resume
>>>> code. I think that IRQ code should not be binded with wakeup event at
>>>> here.
>>>>
>>>>> Âvoid __init icu_init_irq(void)
>>>>> Â{
>>>>> Â Â Â Âint irq;
>>>>> @@ -49,7 +64,13 @@ void __init icu_init_irq(void)
>>>>> Â Â Â Âfor (irq = 0; irq < 64; irq++) {
>>>>> Â Â Â Â Â Â Â Âicu_mask_irq(irq);
>>>>> Â Â Â Â Â Â Â Âset_irq_chip(irq, &icu_irq_chip);
>>>>> - Â Â Â Â Â Â Â set_irq_handler(irq, handle_level_irq);
>>>>> +
>>>>> + Â Â Â Â Â Â Â /* special handler for keypad */
>>>>> + Â Â Â Â Â Â Â if (cpu_is_pxa168() && irq == IRQ_PXA168_KEYPAD)
>>>>> + Â Â Â Â Â Â Â Â Â Â Â set_irq_handler(irq, handle_pxa168_keypad_irq);
>>>>> + Â Â Â Â Â Â Â else
>>>>> + Â Â Â Â Â Â Â Â Â Â Â set_irq_handler(irq, handle_level_irq);
>>>>> +
>>>>> Â Â Â Â Â Â Â Âset_irq_flags(irq, IRQF_VALID);
>>>>> Â Â Â Â}
>>>>> Â}
>>>>> --
>>>>> 1.7.0.4
>>>>>
>>>>> --
>>>>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>>>>> the body of a message to majordomo@xxxxxxxxxxxxxxx
>>>>> More majordomo info at Âhttp://vger.kernel.org/majordomo-info.html
>>>>> Please read the FAQ at Âhttp://www.tux.org/lkml/
>>>>>
>>>>
>>>
>>> Haojian, this is an usual case, but without that clear wake event you
>>> will not be able to clear the keypad interrupt. For my push to open
>>> source I re-wrote the workaround code and added it as a special case
>>> IRQ handler. In the Marvell pxa168 code base it is actually located in
>>> the keypad interrupt handler as the function clear_wakeup(). I felt it
>>> was better to isolate this code in the mmp common code base instead.
>>
>> I'd rather the irq handler not being changed and use platform_data instead.
>> How about something below:
>>
>> diff --git a/arch/arm/mach-mmp/include/mach/pxa168.h
>> b/arch/arm/mach-mmp/include/mach/pxa168.h
>> index 27e1bc7..d2b7946 100644
>> --- a/arch/arm/mach-mmp/include/mach/pxa168.h
>> +++ b/arch/arm/mach-mmp/include/mach/pxa168.h
>> @@ -5,6 +5,7 @@ struct sys_timer;
>>
>> Âextern struct sys_timer pxa168_timer;
>> Âextern void __init pxa168_init_irq(void);
>> +extern void pxa168_clear_keypad_wakeup(void);
>>
>> Â#include <linux/i2c.h>
>> Â#include <mach/devices.h>
>> @@ -97,4 +98,10 @@ static inline int pxa168_add_nand(struct
>> pxa3xx_nand_platform_data *info)
>> Â{
>> Â Â Â Âreturn pxa_register_device(&pxa168_device_nand, info, sizeof(*info));
>> Â}
>> +
>> +static inline int pxa168_add_keypad(struct pxa27x_keypad_platform_data *info)
>> +{
>> + Â Â Â info->clear_wakeup = pxa168_clear_keypad_wakeup;
>> + Â Â Â return pxa_register_device(&pxa168_device_keypad, info, sizeof(*info));
>> +}
>> Â#endif /* __ASM_MACH_PXA168_H */
>> diff --git a/arch/arm/mach-pxa/include/mach/pxa27x_keypad.h
>> b/arch/arm/mach-pxa/include/mach/pxa27x_keypad.h
>> index 7b4eadc..3a6bfe7 100644
>> --- a/arch/arm/mach-pxa/include/mach/pxa27x_keypad.h
>> +++ b/arch/arm/mach-pxa/include/mach/pxa27x_keypad.h
>> @@ -52,6 +52,7 @@ struct pxa27x_keypad_platform_data {
>>
>> Â Â Â Â/* key debounce interval */
>>    Âunsigned int  Âdebounce_interval;
>> +    void      Â(*clear_wakeup);
>> Â};
>>
>> Âextern void pxa_set_keypad_info(struct pxa27x_keypad_platform_data *info);
>> diff --git a/drivers/input/keyboard/pxa27x_keypad.c
>> b/drivers/input/keyboard/pxa27x_keypad.c
>> index f32404f..3fb94fe 100644
>> --- a/drivers/input/keyboard/pxa27x_keypad.c
>> +++ b/drivers/input/keyboard/pxa27x_keypad.c
>> @@ -330,10 +330,20 @@ static void pxa27x_keypad_scan_direct(struct
>> pxa27x_keypad *keypad)
>> Â Â Â Âkeypad->direct_key_state = new_state;
>> Â}
>>
>> +static void clear_wakeup(struct pxa27x_keypad *keypad)
>> +{
>> + Â Â Â struct pxa27x_keypad_platform_data *pdata = keypad->pdata;
>> +
>> + Â Â Â if (pdata->clear_wakeup)
>> + Â Â Â Â Â Â Â (pdata->clear_wakeup)();
>> +}
>> +
>> Âstatic irqreturn_t pxa27x_keypad_irq_handler(int irq, void *dev_id)
>> Â{
>> Â Â Â Âstruct pxa27x_keypad *keypad = dev_id;
>> - Â Â Â unsigned long kpc = keypad_readl(KPC);
>> + Â Â Â unsigned long kpc;
>> +
>> + Â Â Â kpc = keypad_readl(KPC);
>>
>> Â Â Â Âif (kpc & KPC_DI)
>> Â Â Â Â Â Â Â Âpxa27x_keypad_scan_direct(keypad);
>>
>
> Ok if you are fine with that I will make that change and resubmit!
>

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/