SPI kerneldoc
[linux-2.6-block.git] / Documentation / DocBook / kernel-api.tmpl
CommitLineData
1da177e4
LT
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" []>
4
5<book id="LinuxKernelAPI">
6 <bookinfo>
7 <title>The Linux Kernel API</title>
8
9 <legalnotice>
10 <para>
11 This documentation is free software; you can redistribute
12 it and/or modify it under the terms of the GNU General Public
13 License as published by the Free Software Foundation; either
14 version 2 of the License, or (at your option) any later
15 version.
16 </para>
17
18 <para>
19 This program is distributed in the hope that it will be
20 useful, but WITHOUT ANY WARRANTY; without even the implied
21 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
22 See the GNU General Public License for more details.
23 </para>
24
25 <para>
26 You should have received a copy of the GNU General Public
27 License along with this program; if not, write to the Free
28 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 MA 02111-1307 USA
30 </para>
31
32 <para>
33 For more details see the file COPYING in the source
34 distribution of Linux.
35 </para>
36 </legalnotice>
37 </bookinfo>
38
39<toc></toc>
40
41 <chapter id="Basics">
42 <title>Driver Basics</title>
43 <sect1><title>Driver Entry and Exit points</title>
44!Iinclude/linux/init.h
45 </sect1>
46
47 <sect1><title>Atomic and pointer manipulation</title>
48!Iinclude/asm-i386/atomic.h
49!Iinclude/asm-i386/unaligned.h
50 </sect1>
51
1da177e4 52 <sect1><title>Delaying, scheduling, and timer routines</title>
4dc3b16b
PP
53!Iinclude/linux/sched.h
54!Ekernel/sched.c
55!Ekernel/timer.c
df78488d
TG
56 </sect1>
57 <sect1><title>High-resolution timers</title>
58!Iinclude/linux/ktime.h
59!Iinclude/linux/hrtimer.h
60!Ekernel/hrtimer.c
0fcb78c2
REB
61 </sect1>
62 <sect1><title>Workqueues and Kevents</title>
63!Ekernel/workqueue.c
1da177e4 64 </sect1>
4dc3b16b
PP
65 <sect1><title>Internal Functions</title>
66!Ikernel/exit.c
67!Ikernel/signal.c
9e37bd30
RD
68!Iinclude/linux/kthread.h
69!Ekernel/kthread.c
4dc3b16b
PP
70 </sect1>
71
72 <sect1><title>Kernel objects manipulation</title>
73<!--
74X!Iinclude/linux/kobject.h
75-->
76!Elib/kobject.c
77 </sect1>
78
79 <sect1><title>Kernel utility functions</title>
80!Iinclude/linux/kernel.h
ddad86c2 81!Ekernel/printk.c
4dc3b16b
PP
82!Ekernel/panic.c
83!Ekernel/sys.c
84!Ekernel/rcupdate.c
85 </sect1>
86
1da177e4
LT
87 </chapter>
88
89 <chapter id="adt">
90 <title>Data Types</title>
91 <sect1><title>Doubly Linked Lists</title>
92!Iinclude/linux/list.h
93 </sect1>
94 </chapter>
95
96 <chapter id="libc">
97 <title>Basic C Library Functions</title>
98
99 <para>
100 When writing drivers, you cannot in general use routines which are
101 from the C Library. Some of the functions have been found generally
102 useful and they are listed below. The behaviour of these functions
103 may vary slightly from those defined by ANSI, and these deviations
104 are noted in the text.
105 </para>
106
107 <sect1><title>String Conversions</title>
108!Ilib/vsprintf.c
109!Elib/vsprintf.c
110 </sect1>
111 <sect1><title>String Manipulation</title>
4dc3b16b
PP
112<!-- All functions are exported at now
113X!Ilib/string.c
114 -->
1da177e4
LT
115!Elib/string.c
116 </sect1>
117 <sect1><title>Bit Operations</title>
118!Iinclude/asm-i386/bitops.h
119 </sect1>
28e83baa
RD
120 </chapter>
121
122 <chapter id="kernel-lib">
123 <title>Basic Kernel Library Functions</title>
124
125 <para>
126 The Linux kernel provides more basic utility functions.
127 </para>
128
6e1907ff
RD
129 <sect1><title>Bitmap Operations</title>
130!Elib/bitmap.c
131!Ilib/bitmap.c
132 </sect1>
28e83baa
RD
133
134 <sect1><title>Command-line Parsing</title>
135!Elib/cmdline.c
136 </sect1>
2f72100c
RD
137
138 <sect1><title>CRC Functions</title>
139!Elib/crc16.c
140!Elib/crc32.c
141!Elib/crc-ccitt.c
142 </sect1>
1da177e4
LT
143 </chapter>
144
145 <chapter id="mm">
146 <title>Memory Management in Linux</title>
147 <sect1><title>The Slab Cache</title>
800590f5 148!Iinclude/linux/slab.h
1da177e4
LT
149!Emm/slab.c
150 </sect1>
151 <sect1><title>User Space Memory Access</title>
152!Iinclude/asm-i386/uaccess.h
8f2709b5 153!Earch/i386/lib/usercopy.c
1da177e4 154 </sect1>
4dc3b16b
PP
155 <sect1><title>More Memory Management Functions</title>
156!Iinclude/linux/rmap.h
157!Emm/readahead.c
158!Emm/filemap.c
159!Emm/memory.c
160!Emm/vmalloc.c
88ca3b94 161!Imm/page_alloc.c
4dc3b16b
PP
162!Emm/mempool.c
163!Emm/page-writeback.c
164!Emm/truncate.c
165 </sect1>
166 </chapter>
167
168
169 <chapter id="ipc">
170 <title>Kernel IPC facilities</title>
171
172 <sect1><title>IPC utilities</title>
173!Iipc/util.c
174 </sect1>
1da177e4
LT
175 </chapter>
176
177 <chapter id="kfifo">
178 <title>FIFO Buffer</title>
179 <sect1><title>kfifo interface</title>
180!Iinclude/linux/kfifo.h
181!Ekernel/kfifo.c
182 </sect1>
183 </chapter>
184
4c78a663
RD
185 <chapter id="relayfs">
186 <title>relay interface support</title>
187
188 <para>
189 Relay interface support
190 is designed to provide an efficient mechanism for tools and
191 facilities to relay large amounts of data from kernel space to
192 user space.
193 </para>
194
195 <sect1><title>relay interface</title>
196!Ekernel/relay.c
197!Ikernel/relay.c
198 </sect1>
199 </chapter>
200
1da177e4
LT
201 <chapter id="netcore">
202 <title>Linux Networking</title>
4dc3b16b
PP
203 <sect1><title>Networking Base Types</title>
204!Iinclude/linux/net.h
205 </sect1>
1da177e4
LT
206 <sect1><title>Socket Buffer Functions</title>
207!Iinclude/linux/skbuff.h
4dc3b16b
PP
208!Iinclude/net/sock.h
209!Enet/socket.c
1da177e4 210!Enet/core/skbuff.c
4dc3b16b
PP
211!Enet/core/sock.c
212!Enet/core/datagram.c
213!Enet/core/stream.c
1da177e4
LT
214 </sect1>
215 <sect1><title>Socket Filter</title>
216!Enet/core/filter.c
217 </sect1>
218 <sect1><title>Generic Network Statistics</title>
219!Iinclude/linux/gen_stats.h
220!Enet/core/gen_stats.c
221!Enet/core/gen_estimator.c
222 </sect1>
4dc3b16b
PP
223 <sect1><title>SUN RPC subsystem</title>
224<!-- The !D functionality is not perfect, garbage has to be protected by comments
225!Dnet/sunrpc/sunrpc_syms.c
226-->
227!Enet/sunrpc/xdr.c
228!Enet/sunrpc/svcsock.c
229!Enet/sunrpc/sched.c
230 </sect1>
1da177e4
LT
231 </chapter>
232
233 <chapter id="netdev">
234 <title>Network device support</title>
235 <sect1><title>Driver Support</title>
236!Enet/core/dev.c
c2da8aca 237!Enet/ethernet/eth.c
461ddf3b 238!Iinclude/linux/etherdevice.h
b3df0da8
RD
239!Edrivers/net/phy/phy.c
240!Idrivers/net/phy/phy.c
241!Edrivers/net/phy/phy_device.c
242!Idrivers/net/phy/phy_device.c
243!Edrivers/net/phy/mdio_bus.c
244!Idrivers/net/phy/mdio_bus.c
461ddf3b
RD
245<!-- FIXME: Removed for now since no structured comments in source
246X!Enet/core/wireless.c
247-->
1da177e4
LT
248 </sect1>
249 <sect1><title>Synchronous PPP</title>
250!Edrivers/net/wan/syncppp.c
251 </sect1>
252 </chapter>
253
254 <chapter id="modload">
255 <title>Module Support</title>
256 <sect1><title>Module Loading</title>
257!Ekernel/kmod.c
258 </sect1>
259 <sect1><title>Inter Module support</title>
260 <para>
261 Refer to the file kernel/module.c for more information.
262 </para>
263<!-- FIXME: Removed for now since no structured comments in source
264X!Ekernel/module.c
265-->
266 </sect1>
267 </chapter>
268
269 <chapter id="hardware">
270 <title>Hardware Interfaces</title>
271 <sect1><title>Interrupt Handling</title>
8f2709b5 272!Ekernel/irq/manage.c
1da177e4
LT
273 </sect1>
274
eed34d0f
RD
275 <sect1><title>DMA Channels</title>
276!Ekernel/dma.c
277 </sect1>
278
4dc3b16b 279 <sect1><title>Resources Management</title>
2b54960b 280!Ikernel/resource.c
e1ca66d1 281!Ekernel/resource.c
4dc3b16b
PP
282 </sect1>
283
1da177e4
LT
284 <sect1><title>MTRR Handling</title>
285!Earch/i386/kernel/cpu/mtrr/main.c
286 </sect1>
b0ef371e 287
1da177e4
LT
288 <sect1><title>PCI Support Library</title>
289!Edrivers/pci/pci.c
4dc3b16b
PP
290!Edrivers/pci/pci-driver.c
291!Edrivers/pci/remove.c
292!Edrivers/pci/pci-acpi.c
d75763d2 293!Edrivers/pci/search.c
4dc3b16b
PP
294!Edrivers/pci/msi.c
295!Edrivers/pci/bus.c
f05aab8e
RD
296<!-- FIXME: Removed for now since no structured comments in source
297X!Edrivers/pci/hotplug.c
298-->
4dc3b16b
PP
299!Edrivers/pci/probe.c
300!Edrivers/pci/rom.c
1da177e4
LT
301 </sect1>
302 <sect1><title>PCI Hotplug Support Library</title>
303!Edrivers/pci/hotplug/pci_hotplug_core.c
304 </sect1>
305 <sect1><title>MCA Architecture</title>
306 <sect2><title>MCA Device Functions</title>
307 <para>
308 Refer to the file arch/i386/kernel/mca.c for more information.
309 </para>
310<!-- FIXME: Removed for now since no structured comments in source
311X!Earch/i386/kernel/mca.c
312-->
313 </sect2>
314 <sect2><title>MCA Bus DMA</title>
315!Iinclude/asm-i386/mca_dma.h
316 </sect2>
317 </sect1>
318 </chapter>
319
b0ef371e
RD
320 <chapter id="firmware">
321 <title>Firmware Interfaces</title>
322 <sect1><title>DMI Interfaces</title>
323!Edrivers/firmware/dmi_scan.c
324 </sect1>
6e8c8188
RD
325 <sect1><title>EDD Interfaces</title>
326!Idrivers/firmware/edd.c
327 </sect1>
b0ef371e
RD
328 </chapter>
329
1da177e4
LT
330 <chapter id="security">
331 <title>Security Framework</title>
332!Esecurity/security.c
333 </chapter>
334
862f5f01
RD
335 <chapter id="audit">
336 <title>Audit Interfaces</title>
337!Ekernel/audit.c
338!Ikernel/auditsc.c
339!Ikernel/auditfilter.c
340 </chapter>
341
342 <chapter id="accounting">
343 <title>Accounting Framework</title>
344!Ikernel/acct.c
345 </chapter>
346
1da177e4
LT
347 <chapter id="pmfuncs">
348 <title>Power Management</title>
349!Ekernel/power/pm.c
350 </chapter>
351
4dc3b16b
PP
352 <chapter id="devdrivers">
353 <title>Device drivers infrastructure</title>
354 <sect1><title>Device Drivers Base</title>
355<!--
356X!Iinclude/linux/device.h
357-->
358!Edrivers/base/driver.c
4dc3b16b 359!Edrivers/base/core.c
78b2290f 360!Edrivers/base/class.c
4dc3b16b
PP
361!Edrivers/base/firmware_class.c
362!Edrivers/base/transport_class.c
363!Edrivers/base/dmapool.c
364<!-- Cannot be included, because
365 attribute_container_add_class_device_adapter
366 and attribute_container_classdev_to_container
367 exceed allowed 44 characters maximum
368X!Edrivers/base/attribute_container.c
369-->
370!Edrivers/base/sys.c
371<!--
372X!Edrivers/base/interface.c
373-->
374!Edrivers/base/platform.c
375!Edrivers/base/bus.c
376 </sect1>
377 <sect1><title>Device Drivers Power Management</title>
378!Edrivers/base/power/main.c
379!Edrivers/base/power/resume.c
380!Edrivers/base/power/suspend.c
381 </sect1>
382 <sect1><title>Device Drivers ACPI Support</title>
383<!-- Internal functions only
384X!Edrivers/acpi/sleep/main.c
385X!Edrivers/acpi/sleep/wakeup.c
386X!Edrivers/acpi/motherboard.c
387X!Edrivers/acpi/bus.c
388-->
389!Edrivers/acpi/scan.c
d758a8fa 390!Idrivers/acpi/scan.c
4dc3b16b
PP
391<!-- No correct structured comments
392X!Edrivers/acpi/pci_bind.c
393-->
394 </sect1>
395 <sect1><title>Device drivers PnP support</title>
396!Edrivers/pnp/core.c
397<!-- No correct structured comments
398X!Edrivers/pnp/system.c
399 -->
400!Edrivers/pnp/card.c
401!Edrivers/pnp/driver.c
402!Edrivers/pnp/manager.c
403!Edrivers/pnp/support.c
404 </sect1>
405 </chapter>
406
1da177e4
LT
407 <chapter id="blkdev">
408 <title>Block Devices</title>
1d193f4f 409!Eblock/ll_rw_blk.c
1da177e4
LT
410 </chapter>
411
cf3e43db
JC
412 <chapter id="chrdev">
413 <title>Char devices</title>
414!Efs/char_dev.c
415 </chapter>
416
1da177e4
LT
417 <chapter id="miscdev">
418 <title>Miscellaneous Devices</title>
419!Edrivers/char/misc.c
420 </chapter>
421
7d469722
RD
422 <chapter id="parportdev">
423 <title>Parallel Port Devices</title>
424!Iinclude/linux/parport.h
425!Edrivers/parport/ieee1284.c
426!Edrivers/parport/share.c
427!Idrivers/parport/daisy.c
428 </chapter>
429
da39aa8f
RD
430 <chapter id="message_devices">
431 <title>Message-based devices</title>
432 <sect1><title>Fusion message devices</title>
433!Edrivers/message/fusion/mptbase.c
434!Idrivers/message/fusion/mptbase.c
435!Edrivers/message/fusion/mptscsih.c
436!Idrivers/message/fusion/mptscsih.c
437!Idrivers/message/fusion/mptctl.c
438!Idrivers/message/fusion/mptspi.c
439!Idrivers/message/fusion/mptfc.c
440!Idrivers/message/fusion/mptlan.c
441 </sect1>
442 <sect1><title>I2O message devices</title>
443!Iinclude/linux/i2o.h
444!Idrivers/message/i2o/core.h
445!Edrivers/message/i2o/iop.c
446!Idrivers/message/i2o/iop.c
447!Idrivers/message/i2o/config-osm.c
448!Edrivers/message/i2o/exec-osm.c
449!Idrivers/message/i2o/exec-osm.c
450!Idrivers/message/i2o/bus-osm.c
451!Edrivers/message/i2o/device.c
452!Idrivers/message/i2o/device.c
453!Idrivers/message/i2o/driver.c
454!Idrivers/message/i2o/pci.c
455!Idrivers/message/i2o/i2o_block.c
456!Idrivers/message/i2o/i2o_scsi.c
457!Idrivers/message/i2o/i2o_proc.c
458 </sect1>
1da177e4
LT
459 </chapter>
460
461 <chapter id="snddev">
462 <title>Sound Devices</title>
4dc3b16b 463!Iinclude/sound/core.h
1da177e4 464!Esound/sound_core.c
4dc3b16b
PP
465!Iinclude/sound/pcm.h
466!Esound/core/pcm.c
467!Esound/core/device.c
468!Esound/core/info.c
469!Esound/core/rawmidi.c
470!Esound/core/sound.c
471!Esound/core/memory.c
472!Esound/core/pcm_memory.c
473!Esound/core/init.c
474!Esound/core/isadma.c
475!Esound/core/control.c
476!Esound/core/pcm_lib.c
477!Esound/core/hwdep.c
478!Esound/core/pcm_native.c
479!Esound/core/memalloc.c
1da177e4
LT
480<!-- FIXME: Removed for now since no structured comments in source
481X!Isound/sound_firmware.c
482-->
483 </chapter>
484
485 <chapter id="uart16x50">
486 <title>16x50 UART Driver</title>
4dc3b16b 487!Iinclude/linux/serial_core.h
1da177e4
LT
488!Edrivers/serial/serial_core.c
489!Edrivers/serial/8250.c
490 </chapter>
491
492 <chapter id="z85230">
493 <title>Z85230 Support Library</title>
494!Edrivers/net/wan/z85230.c
495 </chapter>
496
497 <chapter id="fbdev">
498 <title>Frame Buffer Library</title>
499
500 <para>
501 The frame buffer drivers depend heavily on four data structures.
502 These structures are declared in include/linux/fb.h. They are
503 fb_info, fb_var_screeninfo, fb_fix_screeninfo and fb_monospecs.
504 The last three can be made available to and from userland.
505 </para>
506
507 <para>
508 fb_info defines the current state of a particular video card.
509 Inside fb_info, there exists a fb_ops structure which is a
510 collection of needed functions to make fbdev and fbcon work.
511 fb_info is only visible to the kernel.
512 </para>
513
514 <para>
515 fb_var_screeninfo is used to describe the features of a video card
516 that are user defined. With fb_var_screeninfo, things such as
517 depth and the resolution may be defined.
518 </para>
519
520 <para>
521 The next structure is fb_fix_screeninfo. This defines the
522 properties of a card that are created when a mode is set and can't
523 be changed otherwise. A good example of this is the start of the
524 frame buffer memory. This "locks" the address of the frame buffer
525 memory, so that it cannot be changed or moved.
526 </para>
527
528 <para>
529 The last structure is fb_monospecs. In the old API, there was
530 little importance for fb_monospecs. This allowed for forbidden things
531 such as setting a mode of 800x600 on a fix frequency monitor. With
532 the new API, fb_monospecs prevents such things, and if used
533 correctly, can prevent a monitor from being cooked. fb_monospecs
534 will not be useful until kernels 2.5.x.
535 </para>
536
537 <sect1><title>Frame Buffer Memory</title>
538!Edrivers/video/fbmem.c
539 </sect1>
4dc3b16b 540<!--
1da177e4 541 <sect1><title>Frame Buffer Console</title>
4dc3b16b 542X!Edrivers/video/console/fbcon.c
1da177e4 543 </sect1>
4dc3b16b 544-->
1da177e4
LT
545 <sect1><title>Frame Buffer Colormap</title>
546!Edrivers/video/fbcmap.c
547 </sect1>
548<!-- FIXME:
549 drivers/video/fbgen.c has no docs, which stuffs up the sgml. Comment
550 out until somebody adds docs. KAO
551 <sect1><title>Frame Buffer Generic Functions</title>
552X!Idrivers/video/fbgen.c
553 </sect1>
554KAO -->
555 <sect1><title>Frame Buffer Video Mode Database</title>
556!Idrivers/video/modedb.c
557!Edrivers/video/modedb.c
558 </sect1>
559 <sect1><title>Frame Buffer Macintosh Video Mode Database</title>
8f2709b5 560!Edrivers/video/macmodes.c
1da177e4
LT
561 </sect1>
562 <sect1><title>Frame Buffer Fonts</title>
563 <para>
564 Refer to the file drivers/video/console/fonts.c for more information.
565 </para>
566<!-- FIXME: Removed for now since no structured comments in source
567X!Idrivers/video/console/fonts.c
568-->
569 </sect1>
570 </chapter>
e4477d2d
RD
571
572 <chapter id="input_subsystem">
573 <title>Input Subsystem</title>
574!Iinclude/linux/input.h
575!Edrivers/input/input.c
576!Edrivers/input/ff-core.c
577!Edrivers/input/ff-memless.c
578 </chapter>
33e34dc6
DB
579
580 <chapter id="spi">
581 <title>Serial Peripheral Interface (SPI)</title>
582 <para>
583 SPI is the "Serial Peripheral Interface", widely used with
584 embedded systems because it is a simple and efficient
585 interface: basically a multiplexed shift register.
586 Its three signal wires hold a clock (SCK, often in the range
587 of 1-20 MHz), a "Master Out, Slave In" (MOSI) data line, and
588 a "Master In, Slave Out" (MISO) data line.
589 SPI is a full duplex protocol; for each bit shifted out the
590 MOSI line (one per clock) another is shifted in on the MISO line.
591 Those bits are assembled into words of various sizes on the
592 way to and from system memory.
593 An additional chipselect line is usually active-low (nCS);
594 four signals are normally used for each peripheral, plus
595 sometimes an interrupt.
596 </para>
597 <para>
598 The SPI bus facilities listed here provide a generalized
599 interface to declare SPI busses and devices, manage them
600 according to the standard Linux driver model, and perform
601 input/output operations.
602 At this time, only "master" side interfaces are supported,
603 where Linux talks to SPI peripherals and does not implement
604 such a peripheral itself.
605 (Interfaces to support implementing SPI slaves would
606 necessarily look different.)
607 </para>
608 <para>
609 The programming interface is structured around two kinds of driver,
610 and two kinds of device.
611 A "Controller Driver" abstracts the controller hardware, which may
612 be as simple as a set of GPIO pins or as complex as a pair of FIFOs
613 connected to dual DMA engines on the other side of the SPI shift
614 register (maximizing throughput). Such drivers bridge between
615 whatever bus they sit on (often the platform bus) and SPI, and
616 expose the SPI side of their device as a
617 <structname>struct spi_master</structname>.
618 SPI devices are children of that master, represented as a
619 <structname>struct spi_device</structname> and manufactured from
620 <structname>struct spi_board_info</structname> descriptors which
621 are usually provided by board-specific initialization code.
622 A <structname>struct spi_driver</structname> is called a
623 "Protocol Driver", and is bound to a spi_device using normal
624 driver model calls.
625 </para>
626 <para>
627 The I/O model is a set of queued messages. Protocol drivers
628 submit one or more <structname>struct spi_message</structname>
629 objects, which are processed and completed asynchronously.
630 (There are synchronous wrappers, however.) Messages are
631 built from one or more <structname>struct spi_transfer</structname>
632 objects, each of which wraps a full duplex SPI transfer.
633 A variety of protocol tweaking options are needed, because
634 different chips adopt very different policies for how they
635 use the bits transferred with SPI.
636 </para>
637!Iinclude/linux/spi/spi.h
638!Fdrivers/spi/spi.c spi_register_board_info
639!Edrivers/spi/spi.c
640 </chapter>
641
1da177e4 642</book>