[meta-intel] gpio sus configuration as interrupt

Kumar Nagaraj kumarn at hcl.com
Fri May 9 16:11:42 PDT 2014


Chiau,
                We have a developed custom board using BYT-I processor & have assigned GPIO_SUS[0],GPIO_SUS[1]....GPIO_SUS[4] to switches or buttons.
I configured these GPIOs as irqs using /mmc/host/sdhc-pci.c as reference.No error returned when configuring gpio_to_irq.I registered a single interrupt handler for all these gpios. However my interrupt handler did not get invoked when the buttons are pressed. Can you provide the reasons for this?

Following is the  gpio debugfs dump obtained using command cat /sys/kernel/debug/gpio

GPIOs     50-65,  i2c/5-00 27,pca9535,can sleep
GPIOs 82-125, platform/byt_gpio.2,byt_gpio.2
Gpio-0      in    IO pad-29     offset :0x1d0    mux:0
Gpio-1      in    IO pad-33     offset :0x210    mux:0
Gpio-2      in    IO pad-30     offset :0x1e0    mux:0
Gpio-3      in    IO pad-31     offset :0x1f0    mux:0
Gpio-4      in    IO pad-32     offset :0x200   mux:0


Code_snippet:

struct button_irq_desc
{
                int gpio;//gpio number
                int irq; // interrupt NO.
                int number; // NO. of relevant port pin
                char *name; // interrupt's name
};
static struct button_irq_desc button_irqs [] = {
                {82,0, 0, "VOL+"},
                {83,0, 1, "VOL-"},
                {84,0, 2, "PREV"},
                {85,0, 3, "NEXT"},
                {86,0, 4, "HOME"},
};
Buttons_Init()
{
.
.

                for (count = 0; count < sizeof(button_irqs)/sizeof(button_irqs[0]); count++)
                {
                                if (!gpio_is_valid(button_irqs[count].gpio))
                                {
                                                printk(KERN_ERR "GPIO Request is invalid\n");
                                                return;
                                }
                                error = gpio_request(button_irqs[count].gpio, "button_irqs[count].name");
                                if (error < 0)
                                                goto out;
                                error = gpio_direction_input(button_irqs[count].gpio);
                                if (error < 0)
                                                goto out_free_gpio;
                                button_irqs[count].irq = gpio_to_irq(button_irqs[count].gpio);
                                if (button_irqs[count].irq < 0)
                                 goto out_free_gpio;

                                // register the handler buttons_interrupt_handler for every interrupt line
                                error = request_irq(button_irqs[count].irq, buttons_interrupt_handler, IRQ_TYPE_EDGE_BOTH,button_irqs[count].name, (void *)&button_irqs[count]);
                                if (error)
{
                                                printk(KERN_ERR "Could not request IRQ_INT!\n");
                                                return error;
                                }
                }
.
.
}
Thanks & Regards,
Vijay Kumar


From: meta-intel-bounces at yoctoproject.org [mailto:meta-intel-bounces at yoctoproject.org] On Behalf Of Chew, Chiau Ee
Sent: Thursday, March 20, 2014 11:15 AM
To: Darren Hart; VijayKumar N
Cc: meta-intel at yoctoproject.org
Subject: Re: [meta-intel] gpio sus configuration as interrupt

Just in case you interpret wrongly. When I mentioned "Our GPIO driver do support input/output direction setting and interrupt" means the driver support direction setting and interrupt enabling.
If you were to use gpio as interrupt, the direction has to be IN.

Thanks,
Chiau Ee

From: Chew, Chiau Ee
Sent: Thursday, March 20, 2014 1:33 PM
To: 'Darren Hart'; VijayKumar N
Cc: Paul Eggleton; meta-intel at yoctoproject.org<mailto:meta-intel at yoctoproject.org>
Subject: RE: [meta-intel] gpio sus configuration as interrupt

When you "cat /sys/kernel/debug", you may see the following info:
GPIOs 82-125, platform/byt_gpio.2, byt_gpio.2,:
.
.
GPIOs 126-153, platform/byt_gpio.1, byt_gpio.1:
.
.
GPIOs 154-255, platform/byt_gpio.0, byt_gpio.0:


To interpret the above output:
byt_gpio.2- Sus core (SUS)
byt_gpio.1- North core (NCORE)
byt_gpio.0 - South core (SCORE)

For eg: Let's said you want to request for pin 2 in SUS core. Referring to the above output (byt_gpio.2 section), basically GPIOs82 is the pin0 of SUS core. Thus, if you want to request pin 2 of SUS core, your target pin number would be (82+2) = 84

Our GPIO driver do support input/output direction setting and interrupt.  Maybe you can take a look at drivers/mmc/host/sdhc-pci.c as reference on how to request gpio as irq in kernel driver code (refer to sdhci_pci_add_own_cd()).  And /Documentation/gpio.txt would be a good reference as well  as what Darren has mentioned.

Thanks,
Chiau Ee


From: Darren Hart [mailto:dvhart at linux.intel.com]
Sent: Thursday, March 20, 2014 12:13 PM
To: VijayKumar N
Cc: Paul Eggleton; Chew, Chiau Ee; meta-intel at yoctoproject.org<mailto:meta-intel at yoctoproject.org>
Subject: Re: [meta-intel] gpio sus configuration as interrupt

Gpiolib uses the Linux namespace for the GPIO lines, you just use those numbers, you do not differentiate based on register bank. See the output of /sys/kernel/debug/gpio for the ranges of each gpiochip (or bank in this case).

I personally have not done the gpios as interrupts so can't speak from experience there. The GPIO documentation does cover it though. Have you read through it?

--
Darren Hart
Yocto Project - Linux Kernel
Intel Open Source Technology Center

From: VijayKumar N <nvijaykumar.engineer at gmail.com<mailto:nvijaykumar.engineer at gmail.com>>
Date: Wednesday, March 19, 2014 at 20:35
To: Darren Hart <dvhart at linux.intel.com<mailto:dvhart at linux.intel.com>>
Cc: Paul Eggleton <paul.eggleton at linux.intel.com<mailto:paul.eggleton at linux.intel.com>>, "chiau.ee.chew" <chiau.ee.chew at intel.com<mailto:chiau.ee.chew at intel.com>>, <meta-intel at yoctoproject.org<mailto:meta-intel at yoctoproject.org>>
Subject: Re: [meta-intel] gpio sus configuration as interrupt

Thanks all for providing valuable information.
another query here,please provide your iputs:
Iam configuring GPIOs belonging to each of the register banks as direction input/ouput & also as interrupts from a different kernel driver.Iam using gpiolib APIs like gpio_request(),gpio_to_irq() to achive this.How do I differentiate configuring GPIOs related to each of the register bank ?Is it possible to configure GPIOs as input/output & also as interrupts?If yes,how?

Thanks & Regards,
Kumar

On Tue, Mar 18, 2014 at 11:09 PM, Darren Hart <dvhart at linux.intel.com<mailto:dvhart at linux.intel.com>> wrote:
On 3/18/14, 9:47, "Paul Eggleton" <paul.eggleton at linux.intel.com<mailto:paul.eggleton at linux.intel.com>> wrote:

>On Tuesday 18 March 2014 08:52:31 Darren Hart wrote:
>> On Intel there is an upcoming modification to the ACPI specification
>>that
>> will enable you to describe in ACPI via named method (_PRP) what you
>>can do
>> in Device Tree for the other architectures. In the meantime, board
>>files are
>> the most expedient option. For more detail on both the _PRP and board
>> files, see my "How not to write an x86 platform driver" presentation at
>>the
>> 2013 Embedded Linux Europe Conference:
>>
>>
>>http://events.linuxfoundation.org/sites/events/files/slides/x86-platform.
>>pdf
>>
>> And I think there is video..... but I can't seem to find it. Perhaps
>>your
>> google foo will prove superior ;-)
>
>http://www.youtube.com/watch?v=IZuNCN7wkqs
>
>(I watched it recently - great presentation BTW :)
Ah, great. Thank you Paul!

--
Darren Hart
Yocto Project - Linux Kernel
Intel Open Source Technology Center




::DISCLAIMER::
----------------------------------------------------------------------------------------------------------------------------------------------------

The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only.
E-mail transmission is not guaranteed to be secure or error-free as information could be intercepted, corrupted,
lost, destroyed, arrive late or incomplete, or may contain viruses in transmission. The e mail and its contents
(with or without referred errors) shall therefore not attach any liability on the originator or HCL or its affiliates.
Views or opinions, if any, presented in this email are solely those of the author and may not necessarily reflect the
views or opinions of HCL or its affiliates. Any form of reproduction, dissemination, copying, disclosure, modification,
distribution and / or publication of this message without the prior written consent of authorized representative of
HCL is strictly prohibited. If you have received this email in error please delete it and notify the sender immediately.
Before opening any email and/or attachments, please check them for viruses and other defects.

----------------------------------------------------------------------------------------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.yoctoproject.org/pipermail/meta-intel/attachments/20140509/9fa8b363/attachment.html>


More information about the meta-intel mailing list