Hello All,
I have mpc8313erdb evaluation board and currently I am writing GPIO
driver. Actually it is just simple test driver.
I did the irq_request in the driver init function, as request_irq
returns zero (0) if successful, otherwise -1 on error and errno
indicates the error. But when I load or insert the module using insmod
request_irq return with Return Value -38. I checked in errno.h file in
asm-generic and 38 means ENOSYS - Function not implemented.
Following is irq_request code:
----------------------
ret = request_irq(74, interrupt_handler, SA_INTERRUPT | SA_SHIRQ ,
"gpio", &mydev);
if(ret)
printk(KERN_INFO "Error in request_irq, value return = %d \n", ret);
----------------------
NOTE: 74 is the Interrupt ID Number for GPIO Interrupt. this
information is from Processor User Manual.
Following is the handler:
---------------------
static int interrupt_handler(int irqn, void *dev_id)
{
printk(KERN_INFO "Enter in interrupt handler\n");
return IRQ_HANDLED;
}
--------------------
Usually request_irq return EBUSY, EINVAL but in my case it returns
ENOSYS (errno 38). I tried to look information for this errno in
interrupt context but could not able to find anything useful or
understable. Could anyone please let me know why this specific errno
38 generated in request_irq ? ? ? and what are the possiblities for
resolving this error ? ? ?
Kindly please acknowledge ... thank you ...
Kind Regards,
Vijay Nikam
From: Michael Ellerman <hidden> Date: 2009-02-11 09:15:03
On Wed, 2009-02-11 at 14:13 +0530, Vijay Nikam wrote:
Hello All,
I have mpc8313erdb evaluation board and currently I am writing GPIO
driver. Actually it is just simple test driver.
I did the irq_request in the driver init function, as request_irq
returns zero (0) if successful, otherwise -1 on error and errno
indicates the error. But when I load or insert the module using insmod
request_irq return with Return Value -38. I checked in errno.h file in
asm-generic and 38 means ENOSYS - Function not implemented.
Following is irq_request code:
----------------------
ret = request_irq(74, interrupt_handler, SA_INTERRUPT | SA_SHIRQ ,
"gpio", &mydev);
if(ret)
printk(KERN_INFO "Error in request_irq, value return = %d \n", ret);
----------------------
NOTE: 74 is the Interrupt ID Number for GPIO Interrupt. this
information is from Processor User Manual.
Following is the handler:
---------------------
static int interrupt_handler(int irqn, void *dev_id)
{
printk(KERN_INFO "Enter in interrupt handler\n");
return IRQ_HANDLED;
}
--------------------
Usually request_irq return EBUSY, EINVAL but in my case it returns
ENOSYS (errno 38). I tried to look information for this errno in
interrupt context but could not able to find anything useful or
understable. Could anyone please let me know why this specific errno
38 generated in request_irq ? ? ? and what are the possiblities for
resolving this error ? ? ?
You don't mention what kernel version you're using. But you might be
hitting the check in __setup_irq():
if (desc->chip == &no_irq_chip)
return -ENOSYS;
That would make sense because you're trying to map a raw irq number,
which doesn't work. You first need to call irq_create_mapping(), like:
int virq;
virq = irq_create_mapping(NULL, 74);
rc = request_irq(virq, ...);
cheers
--
Michael Ellerman
OzLabs, IBM Australia Development Lab
wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)
We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person
Thanks for your prompt reply ...
I am using kernel version 2.6.20 ...
May I know what raw IRQ means ? ? ? and what is the reason I cant map
raw_irq_number ???
Kindly please acknowledge ... thank you ...
Kind Regards,
Vijay Nikam
On 2/11/09, Michael Ellerman [off-list ref] wrote:
On Wed, 2009-02-11 at 14:13 +0530, Vijay Nikam wrote:
quoted
Hello All,
I have mpc8313erdb evaluation board and currently I am writing GPIO
driver. Actually it is just simple test driver.
I did the irq_request in the driver init function, as request_irq
returns zero (0) if successful, otherwise -1 on error and errno
indicates the error. But when I load or insert the module using insmod
request_irq return with Return Value -38. I checked in errno.h file in
asm-generic and 38 means ENOSYS - Function not implemented.
Following is irq_request code:
----------------------
ret = request_irq(74, interrupt_handler, SA_INTERRUPT | SA_SHIRQ ,
"gpio", &mydev);
if(ret)
printk(KERN_INFO "Error in request_irq, value return = %d \n", ret);
----------------------
NOTE: 74 is the Interrupt ID Number for GPIO Interrupt. this
information is from Processor User Manual.
Following is the handler:
---------------------
static int interrupt_handler(int irqn, void *dev_id)
{
printk(KERN_INFO "Enter in interrupt handler\n");
return IRQ_HANDLED;
}
--------------------
Usually request_irq return EBUSY, EINVAL but in my case it returns
ENOSYS (errno 38). I tried to look information for this errno in
interrupt context but could not able to find anything useful or
understable. Could anyone please let me know why this specific errno
38 generated in request_irq ? ? ? and what are the possiblities for
resolving this error ? ? ?
You don't mention what kernel version you're using. But you might be
hitting the check in __setup_irq():
if (desc->chip == &no_irq_chip)
return -ENOSYS;
That would make sense because you're trying to map a raw irq number,
which doesn't work. You first need to call irq_create_mapping(), like:
int virq;
virq = irq_create_mapping(NULL, 74);
rc = request_irq(virq, ...);
cheers
--
Michael Ellerman
OzLabs, IBM Australia Development Lab
wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)
We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person
From: Michael Ellerman <hidden> Date: 2009-02-11 09:54:32
On Wed, 2009-02-11 at 15:11 +0530, Vijay Nikam wrote:
Thanks for your prompt reply ...
I am using kernel version 2.6.20 ...
OK, that kernel has the irq remapping stuff.
May I know what raw IRQ means ? ? ? and what is the reason I cant map
raw_irq_number ???
Sorry, that's not the best terminology.
I guess the right name is hardware irq number.
You can't map it because the kernel keeps a mapping between hardware irq
numbers and virtual irq numbers. request_irq() expects a virtual irq
number.
cheers
--
Michael Ellerman
OzLabs, IBM Australia Development Lab
wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)
We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person
Ok ... so that means if I am writing driver for any device I need to
take care of this mapping ? ? ? I mean I should use virq ? ? ?
I read in LDD book, they give directly irq no. they have given
parallel port example, here they have set or said irq no. defaults to
7 and they have not done any irq_mapping so what is the difference ? ?
? I mean how I should know when to use irq_mapping and when not ? ? ?
Also is it some difference between writng drivers on embedded Linux
level and Linux PC (i386) ? ? ?
Sorry for perhaps these basic questions as kind of new to Linux kernel
programming ... :-)
Kindly please acknowledge ... thank you ...
Kind Regards,
Vijay Nikam
On 2/11/09, Michael Ellerman [off-list ref] wrote:
On Wed, 2009-02-11 at 15:11 +0530, Vijay Nikam wrote:
quoted
Thanks for your prompt reply ...
I am using kernel version 2.6.20 ...
OK, that kernel has the irq remapping stuff.
quoted
May I know what raw IRQ means ? ? ? and what is the reason I cant map
raw_irq_number ???
Sorry, that's not the best terminology.
I guess the right name is hardware irq number.
You can't map it because the kernel keeps a mapping between hardware irq
numbers and virtual irq numbers. request_irq() expects a virtual irq
number.
cheers
--
Michael Ellerman
OzLabs, IBM Australia Development Lab
wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)
We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person
From: Scott Wood <hidden> Date: 2009-02-11 22:48:44
On Wed, Feb 11, 2009 at 03:43:26PM +0530, Vijay Nikam wrote:
Ok ... so that means if I am writing driver for any device I need to
take care of this mapping ? ? ? I mean I should use virq ? ? ?
I read in LDD book,
The problem with dead-tree books on a volatile subject is they quickly
get out of date.
they give directly irq no. they have given parallel port example, here
they have set or said irq no. defaults to 7 and they have not done any
irq_mapping so what is the difference ? ? ? I mean how I should know
when to use irq_mapping and when not ? ? ?
That's for legacy ISA interrupts. On powerpc, you generally will want to
get the interrupt from the device tree using irq_of_parse_and_map().
-Scott
On Wed, Feb 11, 2009 at 03:43:26PM +0530, Vijay Nikam wrote:
I read in LDD book, they give directly irq no. they have given
parallel port example, here they have set or said irq no. defaults to
7 and they have not done any irq_mapping so what is the difference ? ?
? I mean how I should know when to use irq_mapping and when not ? ? ?
Also is it some difference between writng drivers on embedded Linux
level and Linux PC (i386) ? ? ?
The basic request_irq() function is generic, but the value of the
arguments (especially the number for the IRQ line) is architecture
specific in many ways. This is one difference between the i386 code
and the powerpc code inside Linux. Most i386 hardware is standard
PC hardware with very clearly defined interrupt sources. Because of
this, the mapping from the numeric IRQ value to a real hardware
interrupt source is defined pretty clearly. The powerpc architecture
code has to support almost arbitrarily complex hardware, and the
embedded world is the source of most of the complexity. Because of
this, the powerpc code has to dynamically allocate those numeric
IRQ sources and tie them to a specific hardware interrupt. There
is functionality to take the information from your device tree and
convert it to a virtual IRQ. That happens automatically for some types
of devices like PCI cards, but your driver may have to do that mapping
itself in other cases. I believe the appropriate API for this is the
function irq_of_parse_and_map(). It takes a device node and index into
the interrupt list for that device and gives a virtual IRQ number.
Brad Boyer
flar@allandria.com
From: Benjamin Herrenschmidt <benh@kernel.crashing.org> Date: 2009-02-12 06:02:10
On Wed, 2009-02-11 at 14:35 -0800, Brad Boyer wrote:
On Wed, Feb 11, 2009 at 03:43:26PM +0530, Vijay Nikam wrote:
quoted
I read in LDD book, they give directly irq no. they have given
parallel port example, here they have set or said irq no. defaults to
7 and they have not done any irq_mapping so what is the difference ? ?
? I mean how I should know when to use irq_mapping and when not ? ? ?
Also is it some difference between writng drivers on embedded Linux
level and Linux PC (i386) ? ? ?
The basic request_irq() function is generic, but the value of the
arguments (especially the number for the IRQ line) is architecture
specific in many ways. This is one difference between the i386 code
and the powerpc code inside Linux. Most i386 hardware is standard
PC hardware with very clearly defined interrupt sources.
In fact, not even clearly anymore :-) IE, there are still some legacy
interrupts at fixed numbers but most things are remapped on x86 too
nowadays when using IO_APICs, the kernel obtains numbers from ACPI,
remaps them etc...
What saves x86 is that anything other than legacy ISA uses PCI nowadays
and thus that remapping is invisible to PCI drivers (as it is on
powerpc). The problem only bites with other bus types more common on
embedded hardware, as you mention further down.
Because of
this, the mapping from the numeric IRQ value to a real hardware
interrupt source is defined pretty clearly. The powerpc architecture
code has to support almost arbitrarily complex hardware, and the
embedded world is the source of most of the complexity. Because of
this, the powerpc code has to dynamically allocate those numeric
IRQ sources and tie them to a specific hardware interrupt. There
is functionality to take the information from your device tree and
convert it to a virtual IRQ. That happens automatically for some types
of devices like PCI cards, but your driver may have to do that mapping
itself in other cases. I believe the appropriate API for this is the
function irq_of_parse_and_map(). It takes a device node and index into
the interrupt list for that device and gives a virtual IRQ number.
Thanks for your replies ...
I checked the irq.c and irq.h and found the prototype of
irq_of_parse_and_map() and found from the comment that it is a wrapper
function contains a chain of irq_map_one() and irq_create_mapping()
...
It means that I can use irq_create_mapping() to know the virq also the
same suggessted by michael ... what is the difference between these
two i.e. irq_create_mapping() and irq_of_parse_and_map() ... I mean in
usage what could be the difference ? ? ?
If used the irq_of_parse_and_map() then the paraments I need to pass
are device_node *dev and index irq_of_parse_and_map(struct device_node
*dev, int index) ... then how I can pass the required information i.e.
dev and index ? ? ?
Also how I can read the device tree binary file ? ? ?
Kindly please acknowledge ... thank you ...
Kind Regards,
Vijay Nikam
On 2/12/09, Brad Boyer [off-list ref] wrote:
On Wed, Feb 11, 2009 at 03:43:26PM +0530, Vijay Nikam wrote:
quoted
I read in LDD book, they give directly irq no. they have given
parallel port example, here they have set or said irq no. defaults to
7 and they have not done any irq_mapping so what is the difference ? ?
? I mean how I should know when to use irq_mapping and when not ? ? ?
Also is it some difference between writng drivers on embedded Linux
level and Linux PC (i386) ? ? ?
The basic request_irq() function is generic, but the value of the
arguments (especially the number for the IRQ line) is architecture
specific in many ways. This is one difference between the i386 code
and the powerpc code inside Linux. Most i386 hardware is standard
PC hardware with very clearly defined interrupt sources. Because of
this, the mapping from the numeric IRQ value to a real hardware
interrupt source is defined pretty clearly. The powerpc architecture
code has to support almost arbitrarily complex hardware, and the
embedded world is the source of most of the complexity. Because of
this, the powerpc code has to dynamically allocate those numeric
IRQ sources and tie them to a specific hardware interrupt. There
is functionality to take the information from your device tree and
convert it to a virtual IRQ. That happens automatically for some types
of devices like PCI cards, but your driver may have to do that mapping
itself in other cases. I believe the appropriate API for this is the
function irq_of_parse_and_map(). It takes a device node and index into
the interrupt list for that device and gives a virtual IRQ number.
Brad Boyer
flar@allandria.com
From: Timur Tabi <hidden> Date: 2009-02-12 16:47:53
On Thu, Feb 12, 2009 at 4:51 AM, Vijay Nikam [off-list ref] wrote:
Also how I can read the device tree binary file ? ? ?
It would be a lot simpler if you just read the documentation (see
booting-without-of.txt) and looked at other device drivers to see what
they do.
--
Timur Tabi
Linux kernel developer at Freescale
From: David Gibson <hidden> Date: 2009-02-12 22:49:15
On Thu, Feb 12, 2009 at 10:39:36AM -0600, Timur Tabi wrote:
On Thu, Feb 12, 2009 at 4:51 AM, Vijay Nikam [off-list ref] wrote:
quoted
Also how I can read the device tree binary file ? ? ?
It would be a lot simpler if you just read the documentation (see
booting-without-of.txt) and looked at other device drivers to see what
they do.
You don't need to directly read the device tree, the provided helper
functions (irq_parse_and_map() and the like) will read the device tree
for you.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson