UIO device tree bindings.
Subsystems (3)
Hi!
I'd like to get uio device tree bindings to work -- with recent FPGA parts it will be important. Latest version I see is
https://lists.ozlabs.org/pipermail/linuxppc-dev/2009-June/073087.html
... Is there anything newer?
I red the discussion, and main problem seems to be the "tell kernel to drive this device tree device", right?
Also I feel like there will be some fun testing it. Does anyone have ideas?
Thanks,
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 11 lines · Pavel Machek
Hi!
I'd like to get uio device tree bindings to work -- with recent FPGA parts it will be important. Latest version I see is
https://lists.ozlabs.org/pipermail/linuxppc-dev/2009-June/073087.html
... Is there anything newer?
I red the discussion, and main problem seems to be the "tell kernel to drive this device tree device", right?
So... here's the port to recent kernels. Not for mainline.
Documentation/devicetree/bindings/uio-generic.txt new file +16 -0
@@ -0,0 +1,16 @@ +UIO for custom devices + +A device which will be mapped using the UIO subsystem. + +Properties: + - compatible : should contain the specific model used, followed by + "generic-uio". + - reg : address range(s) of the device (up to MAX_UIO_MAPS) + - interrupts : interrupt of the device + +Example: + c64fpga at 0 { + compatible = "ptx,c64fpga001", "generic-uio"; + reg = <0x0 0x10000>; + interrupts = <0 0 3>; + };
drivers/uio/Kconfig +6 -0
@@ -59,6 +59,12 @@ config UIO_DMEM_GENIRQ If you don't know what to do here, say N. +config UIO_OF_GENIRQ + tristate "Userspace I/O device tree driver with generic IRQ handling" + depends on UIO_PDRV_GENIRQ && OF + help + Device tree wrapper for the above platform driver. + config UIO_AEC tristate "AEC video timestamp device" depends on PCI
drivers/uio/Makefile +1 -0
@@ -3,6 +3,7 @@ obj-$(CONFIG_UIO_CIF) += uio_cif.o obj-$(CONFIG_UIO_PDRV) += uio_pdrv.o obj-$(CONFIG_UIO_PDRV_GENIRQ) += uio_pdrv_genirq.o obj-$(CONFIG_UIO_DMEM_GENIRQ) += uio_dmem_genirq.o +obj-$(CONFIG_UIO_OF_GENIRQ) += uio_of_genirq.o obj-$(CONFIG_UIO_AEC) += uio_aec.o obj-$(CONFIG_UIO_SERCOS3) += uio_sercos3.o obj-$(CONFIG_UIO_PCI_GENERIC) += uio_pci_generic.o
drivers/uio/uio_of_genirq.c new file +95 -0
95 lines not on this page · raw message
drivers/uio/uio_pdrv_genirq.c +75 -68
205 lines not on this page · raw message
drivers/uio/uio_pdrv_genirq.h new file +14 -0
@@ -0,0 +1,14 @@ +#ifndef _LINUX_UIO_PDRV_GENIRQ_H +#define _LINUX_UIO_PDRV_GENIRQ_H + +struct uio_pdrv_genirq_platdata { +struct uio_info *uioinfo; +spinlock_t lock; +unsigned long flags; +struct device *dev; +}; + +extern int __uio_pdrv_genirq_probe (struct device *dev,struct uio_info *uioinfo, +struct resource *resources,unsigned int num_resources); + +#endif
include/linux/of_platform.h +5 -5
@@ -60,13 +60,13 @@ struct of_dev_auxdata {*/ struct of_platform_driver { -int (*probe)(struct platform_device * dev, +int (*probe)(struct platform_device *dev,const struct of_device_id *match); -int (*remove)(struct platform_device * dev); +int (*remove)(struct platform_device *dev); -int (*suspend)(struct platform_device * dev,pm_message_t state); -int (*resume)(struct platform_device * dev); -int (*shutdown)(struct platform_device * dev); +int (*suspend)(struct platform_device *dev,pm_message_t state); +int (*resume)(struct platform_device *dev); +int (*shutdown)(struct platform_device *dev);struct device_driver driver; };
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 6 lines · Pavel Machek
Quoted 5 lines · Pavel Machek
Hi!
I'd like to get uio device tree bindings to work -- with recent FPGA parts it will be important. Latest version I see is
Quoted 7 lines
Quoted 6 lines
https://lists.ozlabs.org/pipermail/linuxppc-dev/2009-June/073087.html
... Is there anything newer?
I red the discussion, and main problem seems to be the "tell kernel to drive this device tree device", right?
Problem seems to be the notion that the proposed devicetree entry would not describe the hardware, but its use. Not really sure I understand the problem, as I would see the hardware description to be "A hardware device which is compatible to and managed by the generic-uio driver". I would argue that this _is_ a hardware description (if not, what is ?), but I am not the one to make the call.
Quoted 4 lines
So... here's the port to recent kernels. Not for mainline.
Signed-off-by Pavel Machek <[email protected]>
Turns out this is exactly what I need, and your post saves me the time I would have spent writing essentially the same code and submitting it, only to have it rejected.
Thanks a lot for digging this up!
Guenter
Quoted 14 lines · Guenter Roeck
Quoted 6 lines · Pavel Machek
Quoted 5 lines · Pavel Machek
Hi!
I'd like to get uio device tree bindings to work -- with recent FPGA parts it will be important. Latest version I see is
Quoted 7 lines
Quoted 6 lines
https://lists.ozlabs.org/pipermail/linuxppc-dev/2009-June/073087.html
... Is there anything newer?
I red the discussion, and main problem seems to be the "tell kernel to drive this device tree device", right?
Quoted 6 lines
Problem seems to be the notion that the proposed devicetree entry would not describe the hardware, but its use. Not really sure I understand the problem, as I would see the hardware description to be "A hardware device which is compatible to and managed by the generic-uio driver". I would argue that this _is_ a hardware description (if not, what is ?), but I am not the one to make the call.
Well... one could argue that having "generic-uio" in board's device tree _is_ wrong, but having driver that binds to "generic-uio" is not. Hmm?
Or maybe we can do some magic with module parameter. That should be enough for expected use.
Quoted 9 lines
Quoted 4 lines
So... here's the port to recent kernels. Not for mainline.
Signed-off-by Pavel Machek <[email protected]>Turns out this is exactly what I need, and your post saves me the time I would have spent writing essentially the same code and submitting it, only to have it rejected.
Thanks a lot for digging this up!
You are welcome :-). Thanks for helping with testing ;-).
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 22 lines · Pavel Machek
Quoted 14 lines · Guenter Roeck
Quoted 6 lines · Pavel Machek
Quoted 5 lines · Pavel Machek
Hi!
I'd like to get uio device tree bindings to work -- with recent FPGA parts it will be important. Latest version I see is
Quoted 7 lines
Quoted 6 lines
https://lists.ozlabs.org/pipermail/linuxppc-dev/2009-June/073087.html
... Is there anything newer?
I red the discussion, and main problem seems to be the "tell kernel to drive this device tree device", right?
Quoted 6 lines
Problem seems to be the notion that the proposed devicetree entry would not describe the hardware, but its use. Not really sure I understand the problem, as I would see the hardware description to be "A hardware device which is compatible to and managed by the generic-uio driver". I would argue that this _is_ a hardware description (if not, what is ?), but I am not the one to make the call.
Quoted 4 lines
Well... one could argue that having "generic-uio" in board's device tree _is_ wrong, but having driver that binds to "generic-uio" is not. Hmm?
You mean like "ata-generic" ?
Quoted 3 lines
Or maybe we can do some magic with module parameter. That should be enough for expected use.
I don't think that would make a difference. I mean, just take ns16550 as another example. No one has problems declaring some block of hardware addresses to be compatible with "ns16550", even though it can be anything including a memory block on one of the FPGAs or ASICs we are talking about here, it can be anything but a NS16550, and many of the actual "compatible" strings are not defined anythere either.
So there is no problem with "ata-generic" and "ns16550", and no one cares if "fsl,mpc8349emitx-pata" or "xlnx,xps-uart16550-2.00.b" is defined or not, but "generic-uio" together with "ptx,c64fpga001" is unacceptable.
I think it has more to do with the uio driver not being an actual driver, but the kernel part of a user-space driver, though that is just a wild guess.
Guenter
Hi!
Quoted 10 lines
Quoted 3 lines
Or maybe we can do some magic with module parameter. That should be enough for expected use.
I don't think that would make a difference. I mean, just take ns16550 as another example. No one has problems declaring some block of hardware addresses to be compatible with "ns16550", even though it can be anything including a memory block on one of the FPGAs or ASICs we are talking about here, it can be anything but a NS16550, and many of the actual "compatible" strings are not defined anythere either.
Quoted 6 lines
So there is no problem with "ata-generic" and "ns16550", and no one cares if "fsl,mpc8349emitx-pata" or "xlnx,xps-uart16550-2.00.b" is defined or not, but "generic-uio" together with "ptx,c64fpga001" is unacceptable.
I think it has more to do with the uio driver not being an actual driver, but the kernel part of a user-space driver, though that is just a wild guess.
Well, it turned out that adding module parameter was not that much work... and yes I believe it is a tiny bit cleaner.
Here's updated patch, if you can please test this one.
[You can just pass "uio_of_genirq.of_id=generic-uio" to get previous behaviour. But don't tell anyone :-)]
Pavel
Documentation/devicetree/bindings/uio-generic.txt new file +16 -0
@@ -0,0 +1,16 @@ +UIO for custom devices + +A device which will be mapped using the UIO subsystem. + +Properties: + - compatible : should contain the specific model used, followed by + "generic-uio". + - reg : address range(s) of the device (up to MAX_UIO_MAPS) + - interrupts : interrupt of the device + +Example: + c64fpga at 0 { + compatible = "ptx,c64fpga001", "generic-uio"; + reg = <0x0 0x10000>; + interrupts = <0 0 3>; + };
arch/arm/boot/dts/socfpga_cyclone5.dts +6 -0
@@ -76,5 +76,11 @@ sysmgr@ffd08000 { cpu1-start-addr = <0xffd080c4>; }; + + xps-gpio@81400000 { + compatible = "generic-uio"; + reg = < 0x81400000 0x10000 >; + }; }; }; +
drivers/uio/Kconfig +6 -0
@@ -59,6 +59,12 @@ config UIO_DMEM_GENIRQ If you don't know what to do here, say N. +config UIO_OF_GENIRQ + tristate "Userspace I/O device tree driver with generic IRQ handling" + depends on UIO_PDRV_GENIRQ && OF + help + Device tree wrapper for the above platform driver. + config UIO_AEC tristate "AEC video timestamp device" depends on PCI
drivers/uio/Makefile +1 -0
@@ -3,6 +3,7 @@ obj-$(CONFIG_UIO_CIF) += uio_cif.o obj-$(CONFIG_UIO_PDRV) += uio_pdrv.o obj-$(CONFIG_UIO_PDRV_GENIRQ) += uio_pdrv_genirq.o obj-$(CONFIG_UIO_DMEM_GENIRQ) += uio_dmem_genirq.o +obj-$(CONFIG_UIO_OF_GENIRQ) += uio_of_genirq.o obj-$(CONFIG_UIO_AEC) += uio_aec.o obj-$(CONFIG_UIO_SERCOS3) += uio_sercos3.o obj-$(CONFIG_UIO_PCI_GENERIC) += uio_pci_generic.o
drivers/uio/uio_of_genirq.c new file +98 -0
98 lines not on this page · raw message
drivers/uio/uio_pdrv_genirq.c +75 -68
205 lines not on this page · raw message
drivers/uio/uio_pdrv_genirq.h new file +14 -0
@@ -0,0 +1,14 @@ +#ifndef _LINUX_UIO_PDRV_GENIRQ_H +#define _LINUX_UIO_PDRV_GENIRQ_H + +struct uio_pdrv_genirq_platdata { +struct uio_info *uioinfo; +spinlock_t lock; +unsigned long flags; +struct device *dev; +}; + +extern int __uio_pdrv_genirq_probe (struct device *dev,struct uio_info *uioinfo, +struct resource *resources,unsigned int num_resources); + +#endif
include/linux/of_platform.h +5 -5
@@ -60,13 +60,13 @@ struct of_dev_auxdata {*/ struct of_platform_driver { -int (*probe)(struct platform_device * dev, +int (*probe)(struct platform_device *dev,const struct of_device_id *match); -int (*remove)(struct platform_device * dev); +int (*remove)(struct platform_device *dev); -int (*suspend)(struct platform_device * dev,pm_message_t state); -int (*resume)(struct platform_device * dev); -int (*shutdown)(struct platform_device * dev); +int (*suspend)(struct platform_device *dev,pm_message_t state); +int (*resume)(struct platform_device *dev); +int (*shutdown)(struct platform_device *dev);struct device_driver driver; };
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Hi!
Quoted 17 lines
Quoted 10 lines
Quoted 3 lines
Or maybe we can do some magic with module parameter. That should be enough for expected use.
I don't think that would make a difference. I mean, just take ns16550 as another example. No one has problems declaring some block of hardware addresses to be compatible with "ns16550", even though it can be anything including a memory block on one of the FPGAs or ASICs we are talking about here, it can be anything but a NS16550, and many of the actual "compatible" strings are not defined anythere either.
Quoted 6 lines
So there is no problem with "ata-generic" and "ns16550", and no one cares if "fsl,mpc8349emitx-pata" or "xlnx,xps-uart16550-2.00.b" is defined or not, but "generic-uio" together with "ptx,c64fpga001" is unacceptable.
I think it has more to do with the uio driver not being an actual driver, but the kernel part of a user-space driver, though that is just a wild guess.
Quoted 7 lines
Well, it turned out that adding module parameter was not that much work... and yes I believe it is a tiny bit cleaner.
Here's updated patch, if you can please test this one.
[You can just pass "uio_of_genirq.of_id=generic-uio" to get previous behaviour. But don't tell anyone :-)]
Actually, looking at it some more, perhaps even solution is possible? (This will need uio_pdrv_genirq.of_id=generic-uio .)
Unfortunately, I don't have easy way to test this :-(. So feedback is essential.
drivers/uio/uio_pdrv_genirq.c +5 -1
@@ -271,9 +273,13 @@ static const struct dev_pm_ops uio_pdrv_genirq_dev_pm_ops = {#ifdef CONFIG_OF static const struct of_device_id uio_of_genirq_match[] = { - {/* empty for now */ }, + {/* This is filled with module_parm */ }, + {/* Sentinel */ }, };MODULE_DEVICE_TABLE (of, uio_of_genirq_match); + +module_param_string (of_id, uio_of_genirq_match[0 ].compatible,128 ,0 ); +MODULE_PARM_DESC (of_id,"Openfirmware id of the device to be handled by uio" );#else # define uio_of_genirq_match NULL#endif
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 22 lines · Pavel Machek
Hi!
Quoted 20 lines
Quoted 10 lines
Quoted 3 lines
Or maybe we can do some magic with module parameter. That should be enough for expected use.
I don't think that would make a difference. I mean, just take ns16550 as another example. No one has problems declaring some block of hardware addresses to be compatible with "ns16550", even though it can be anything including a memory block on one of the FPGAs or ASICs we are talking about here, it can be anything but a NS16550, and many of the actual "compatible" strings are not defined anythere either.
Quoted 6 lines
So there is no problem with "ata-generic" and "ns16550", and no one cares if "fsl,mpc8349emitx-pata" or "xlnx,xps-uart16550-2.00.b" is defined or not, but "generic-uio" together with "ptx,c64fpga001" is unacceptable.
I think it has more to do with the uio driver not being an actual driver, but the kernel part of a user-space driver, though that is just a wild guess.
Well, it turned out that adding module parameter was not that much work... and yes I believe it is a tiny bit cleaner.
Quoted 8 lines
Quoted 4 lines
Here's updated patch, if you can please test this one.
[You can just pass "uio_of_genirq.of_id=generic-uio" to get previous behaviour. But don't tell anyone :-)]
Actually, looking at it some more, perhaps even solution is possible? (This will need uio_pdrv_genirq.of_id=generic-uio .)
Possibly for your case, but not for mine, as I'll have several instances of the driver, and the hardware is not always present. Also, I am not sure if the match function runs before the module paratemers are initialized or afterwards, but that would be a matter of testing.
Anyway, after sleeping over it, I think I understand the concern better. "ns16550" describes some HW compatible to a specific chip with well defined functionality, and "generic-uio" doesn't. Maybe it would have to be something like "generic-uio-hw" instead.
Quoted 3 lines
Unfortunately, I don't have easy way to test this :-(. So feedback is essential.
I'll try to get it to work, but it will take a bit.
Thanks,
Guenter
Quoted 26 lines
Signed-off-by Pavel Machek <[email protected]>drivers/uio/uio_pdrv_genirq.c +5
-1@@ -271,9 +273,13 @@ static const struct dev_pm_ops uio_pdrv_genirq_dev_pm_ops = {#ifdef CONFIG_OF static const struct of_device_id uio_of_genirq_match[] = { - {/* empty for now */ }, + {/* This is filled with module_parm */ }, + {/* Sentinel */ }, };MODULE_DEVICE_TABLE (of, uio_of_genirq_match); + +module_param_string (of_id, uio_of_genirq_match[0 ].compatible,128 ,0 ); +MODULE_PARM_DESC (of_id,"Openfirmware id of the device to be handled by uio" );#else # define uio_of_genirq_match NULL#endif Signature · 3 lines
-- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Hi!
Quoted 25 lines
Quoted 25 lines
Quoted 24 lines
Quoted 10 lines
Quoted 3 lines
Or maybe we can do some magic with module parameter. That should be enough for expected use.
I don't think that would make a difference. I mean, just take ns16550 as another example. No one has problems declaring some block of hardware addresses to be compatible with "ns16550", even though it can be anything including a memory block on one of the FPGAs or ASICs we are talking about here, it can be anything but a NS16550, and many of the actual "compatible" strings are not defined anythere either.
Quoted 6 lines
So there is no problem with "ata-generic" and "ns16550", and no one cares if "fsl,mpc8349emitx-pata" or "xlnx,xps-uart16550-2.00.b" is defined or not, but "generic-uio" together with "ptx,c64fpga001" is unacceptable.
I think it has more to do with the uio driver not being an actual driver, but the kernel part of a user-space driver, though that is just a wild guess.
Well, it turned out that adding module parameter was not that much work... and yes I believe it is a tiny bit cleaner.
Here's updated patch, if you can please test this one.
[You can just pass "uio_of_genirq.of_id=generic-uio" to get previous behaviour. But don't tell anyone :-)]
Quoted 7 lines
Quoted 3 lines
Actually, looking at it some more, perhaps even solution is possible? (This will need uio_pdrv_genirq.of_id=generic-uio .)
Possibly for your case, but not for mine, as I'll have several instances of the driver, and the hardware is not always present. Also, I am not sure if the match function runs before the module paratemers are initialized or afterwards, but that would be a matter of testing.
I tested that much: it works ok.
And... yes, this should work for you. You'll simply put compatible="generic-uio" into the dts. (Ok, ugly part is that this is probably not acceptable for upstream.) Then you'll use this patch, with uio_pdrv_genirq.of_id=generic-uio commandline. It should pick up all the devices old version of patch picked. (Not sure how you'll assign right userland drivers to right devices, but that problem was that even with old patch version, right?)
Quoted 4 lines
Quoted 3 lines
Unfortunately, I don't have easy way to test this :-(. So feedback is essential.
I'll try to get it to work, but it will take a bit.
Thanks,
Pavel
Quoted 21 lines
Quoted 21 lines
Signed-off-by Pavel Machek <[email protected]>drivers/uio/uio_pdrv_genirq.c +5
-1@@ -271,9 +273,13 @@ static const struct dev_pm_ops uio_pdrv_genirq_dev_pm_ops = {#ifdef CONFIG_OF static const struct of_device_id uio_of_genirq_match[] = { - {/* empty for now */ }, + {/* This is filled with module_parm */ }, + {/* Sentinel */ }, };MODULE_DEVICE_TABLE (of, uio_of_genirq_match); + +module_param_string (of_id, uio_of_genirq_match[0 ].compatible,128 ,0 ); +MODULE_PARM_DESC (of_id,"Openfirmware id of the device to be handled by uio" );#else # define uio_of_genirq_match NULL#endif
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html