Skip to content

Commit 6469f54

Browse files
David WoodhouseDavid Woodhouse
authored andcommitted
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Conflicts: drivers/mtd/mtdcore.c Merged in order that I can apply the Nomadik nand/onenand support patches.
2 parents 304e6d5 + 78f28b7 commit 6469f54

File tree

6,586 files changed

+725373
-390066
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

6,586 files changed

+725373
-390066
lines changed

CREDITS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2800,7 +2800,7 @@ D: Starter of Linux1394 effort
28002800
S: ask per mail for current address
28012801

28022802
N: Nicolas Pitre
2803-
E: nico@cam.org
2803+
E: nico@fluxnic.net
28042804
D: StrongARM SA1100 support integrator & hacker
28052805
D: Xscale PXA architecture
28062806
D: unified SMC 91C9x/91C11x ethernet driver (smc91x)

Documentation/00-INDEX

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ block/
8282
- info on the Block I/O (BIO) layer.
8383
blockdev/
8484
- info on block devices & drivers
85+
btmrvl.txt
86+
- info on Marvell Bluetooth driver usage.
8587
cachetlb.txt
8688
- describes the cache/TLB flushing interfaces Linux uses.
8789
cdrom/

Documentation/ABI/testing/sysfs-bus-pci

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,16 @@ Description:
8484
from this part of the device tree.
8585
Depends on CONFIG_HOTPLUG.
8686

87+
What: /sys/bus/pci/devices/.../reset
88+
Date: July 2009
89+
Contact: Michael S. Tsirkin <mst@redhat.com>
90+
Description:
91+
Some devices allow an individual function to be reset
92+
without affecting other functions in the same device.
93+
For devices that have this support, a file named reset
94+
will be present in sysfs. Writing 1 to this file
95+
will perform reset.
96+
8797
What: /sys/bus/pci/devices/.../vpd
8898
Date: February 2008
8999
Contact: Ben Hutchings <bhutchings@solarflare.com>

Documentation/DocBook/uio-howto.tmpl

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
<year>2006-2008</year>
2626
<holder>Hans-Jürgen Koch.</holder>
2727
</copyright>
28+
<copyright>
29+
<year>2009</year>
30+
<holder>Red Hat Inc, Michael S. Tsirkin (mst@redhat.com)</holder>
31+
</copyright>
2832

2933
<legalnotice>
3034
<para>
@@ -41,6 +45,13 @@ GPL version 2.
4145
</abstract>
4246

4347
<revhistory>
48+
<revision>
49+
<revnumber>0.9</revnumber>
50+
<date>2009-07-16</date>
51+
<authorinitials>mst</authorinitials>
52+
<revremark>Added generic pci driver
53+
</revremark>
54+
</revision>
4455
<revision>
4556
<revnumber>0.8</revnumber>
4657
<date>2008-12-24</date>
@@ -809,6 +820,158 @@ framework to set up sysfs files for this region. Simply leave it alone.
809820

810821
</chapter>
811822

823+
<chapter id="uio_pci_generic" xreflabel="Using Generic driver for PCI cards">
824+
<?dbhtml filename="uio_pci_generic.html"?>
825+
<title>Generic PCI UIO driver</title>
826+
<para>
827+
The generic driver is a kernel module named uio_pci_generic.
828+
It can work with any device compliant to PCI 2.3 (circa 2002) and
829+
any compliant PCI Express device. Using this, you only need to
830+
write the userspace driver, removing the need to write
831+
a hardware-specific kernel module.
832+
</para>
833+
834+
<sect1 id="uio_pci_generic_binding">
835+
<title>Making the driver recognize the device</title>
836+
<para>
837+
Since the driver does not declare any device ids, it will not get loaded
838+
automatically and will not automatically bind to any devices, you must load it
839+
and allocate id to the driver yourself. For example:
840+
<programlisting>
841+
modprobe uio_pci_generic
842+
echo &quot;8086 10f5&quot; &gt; /sys/bus/pci/drivers/uio_pci_generic/new_id
843+
</programlisting>
844+
</para>
845+
<para>
846+
If there already is a hardware specific kernel driver for your device, the
847+
generic driver still won't bind to it, in this case if you want to use the
848+
generic driver (why would you?) you'll have to manually unbind the hardware
849+
specific driver and bind the generic driver, like this:
850+
<programlisting>
851+
echo -n 0000:00:19.0 &gt; /sys/bus/pci/drivers/e1000e/unbind
852+
echo -n 0000:00:19.0 &gt; /sys/bus/pci/drivers/uio_pci_generic/bind
853+
</programlisting>
854+
</para>
855+
<para>
856+
You can verify that the device has been bound to the driver
857+
by looking for it in sysfs, for example like the following:
858+
<programlisting>
859+
ls -l /sys/bus/pci/devices/0000:00:19.0/driver
860+
</programlisting>
861+
Which if successful should print
862+
<programlisting>
863+
.../0000:00:19.0/driver -&gt; ../../../bus/pci/drivers/uio_pci_generic
864+
</programlisting>
865+
Note that the generic driver will not bind to old PCI 2.2 devices.
866+
If binding the device failed, run the following command:
867+
<programlisting>
868+
dmesg
869+
</programlisting>
870+
and look in the output for failure reasons
871+
</para>
872+
</sect1>
873+
874+
<sect1 id="uio_pci_generic_internals">
875+
<title>Things to know about uio_pci_generic</title>
876+
<para>
877+
Interrupts are handled using the Interrupt Disable bit in the PCI command
878+
register and Interrupt Status bit in the PCI status register. All devices
879+
compliant to PCI 2.3 (circa 2002) and all compliant PCI Express devices should
880+
support these bits. uio_pci_generic detects this support, and won't bind to
881+
devices which do not support the Interrupt Disable Bit in the command register.
882+
</para>
883+
<para>
884+
On each interrupt, uio_pci_generic sets the Interrupt Disable bit.
885+
This prevents the device from generating further interrupts
886+
until the bit is cleared. The userspace driver should clear this
887+
bit before blocking and waiting for more interrupts.
888+
</para>
889+
</sect1>
890+
<sect1 id="uio_pci_generic_userspace">
891+
<title>Writing userspace driver using uio_pci_generic</title>
892+
<para>
893+
Userspace driver can use pci sysfs interface, or the
894+
libpci libray that wraps it, to talk to the device and to
895+
re-enable interrupts by writing to the command register.
896+
</para>
897+
</sect1>
898+
<sect1 id="uio_pci_generic_example">
899+
<title>Example code using uio_pci_generic</title>
900+
<para>
901+
Here is some sample userspace driver code using uio_pci_generic:
902+
<programlisting>
903+
#include &lt;stdlib.h&gt;
904+
#include &lt;stdio.h&gt;
905+
#include &lt;unistd.h&gt;
906+
#include &lt;sys/types.h&gt;
907+
#include &lt;sys/stat.h&gt;
908+
#include &lt;fcntl.h&gt;
909+
#include &lt;errno.h&gt;
910+
911+
int main()
912+
{
913+
int uiofd;
914+
int configfd;
915+
int err;
916+
int i;
917+
unsigned icount;
918+
unsigned char command_high;
919+
920+
uiofd = open(&quot;/dev/uio0&quot;, O_RDONLY);
921+
if (uiofd &lt; 0) {
922+
perror(&quot;uio open:&quot;);
923+
return errno;
924+
}
925+
configfd = open(&quot;/sys/class/uio/uio0/device/config&quot;, O_RDWR);
926+
if (uiofd &lt; 0) {
927+
perror(&quot;config open:&quot;);
928+
return errno;
929+
}
930+
931+
/* Read and cache command value */
932+
err = pread(configfd, &amp;command_high, 1, 5);
933+
if (err != 1) {
934+
perror(&quot;command config read:&quot;);
935+
return errno;
936+
}
937+
command_high &amp;= ~0x4;
938+
939+
for(i = 0;; ++i) {
940+
/* Print out a message, for debugging. */
941+
if (i == 0)
942+
fprintf(stderr, &quot;Started uio test driver.\n&quot;);
943+
else
944+
fprintf(stderr, &quot;Interrupts: %d\n&quot;, icount);
945+
946+
/****************************************/
947+
/* Here we got an interrupt from the
948+
device. Do something to it. */
949+
/****************************************/
950+
951+
/* Re-enable interrupts. */
952+
err = pwrite(configfd, &amp;command_high, 1, 5);
953+
if (err != 1) {
954+
perror(&quot;config write:&quot;);
955+
break;
956+
}
957+
958+
/* Wait for next interrupt. */
959+
err = read(uiofd, &amp;icount, 4);
960+
if (err != 4) {
961+
perror(&quot;uio read:&quot;);
962+
break;
963+
}
964+
965+
}
966+
return errno;
967+
}
968+
969+
</programlisting>
970+
</para>
971+
</sect1>
972+
973+
</chapter>
974+
812975
<appendix id="app1">
813976
<title>Further information</title>
814977
<itemizedlist>

0 commit comments

Comments
 (0)