device-drivers.tmpl 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  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. <book id="LinuxDriversAPI">
  5. <bookinfo>
  6. <title>Linux Device Drivers</title>
  7. <legalnotice>
  8. <para>
  9. This documentation is free software; you can redistribute
  10. it and/or modify it under the terms of the GNU General Public
  11. License as published by the Free Software Foundation; either
  12. version 2 of the License, or (at your option) any later
  13. version.
  14. </para>
  15. <para>
  16. This program is distributed in the hope that it will be
  17. useful, but WITHOUT ANY WARRANTY; without even the implied
  18. warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  19. See the GNU General Public License for more details.
  20. </para>
  21. <para>
  22. You should have received a copy of the GNU General Public
  23. License along with this program; if not, write to the Free
  24. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  25. MA 02111-1307 USA
  26. </para>
  27. <para>
  28. For more details see the file COPYING in the source
  29. distribution of Linux.
  30. </para>
  31. </legalnotice>
  32. </bookinfo>
  33. <toc></toc>
  34. <chapter id="Basics">
  35. <title>Driver Basics</title>
  36. <sect1><title>Driver Entry and Exit points</title>
  37. !Iinclude/linux/init.h
  38. </sect1>
  39. <sect1><title>Atomic and pointer manipulation</title>
  40. !Iarch/x86/include/asm/atomic.h
  41. </sect1>
  42. <sect1><title>Delaying, scheduling, and timer routines</title>
  43. !Iinclude/linux/sched.h
  44. !Ekernel/sched/core.c
  45. !Ikernel/sched/cpupri.c
  46. !Ikernel/sched/fair.c
  47. !Iinclude/linux/completion.h
  48. !Ekernel/time/timer.c
  49. </sect1>
  50. <sect1><title>Wait queues and Wake events</title>
  51. !Iinclude/linux/wait.h
  52. !Ekernel/sched/wait.c
  53. </sect1>
  54. <sect1><title>High-resolution timers</title>
  55. !Iinclude/linux/ktime.h
  56. !Iinclude/linux/hrtimer.h
  57. !Ekernel/time/hrtimer.c
  58. </sect1>
  59. <sect1><title>Workqueues and Kevents</title>
  60. !Ekernel/workqueue.c
  61. </sect1>
  62. <sect1><title>Internal Functions</title>
  63. !Ikernel/exit.c
  64. !Ikernel/signal.c
  65. !Iinclude/linux/kthread.h
  66. !Ekernel/kthread.c
  67. </sect1>
  68. <sect1><title>Kernel objects manipulation</title>
  69. <!--
  70. X!Iinclude/linux/kobject.h
  71. -->
  72. !Elib/kobject.c
  73. </sect1>
  74. <sect1><title>Kernel utility functions</title>
  75. !Iinclude/linux/kernel.h
  76. !Ekernel/printk/printk.c
  77. !Ekernel/panic.c
  78. !Ekernel/sys.c
  79. !Ekernel/rcu/srcu.c
  80. !Ekernel/rcu/tree.c
  81. !Ekernel/rcu/tree_plugin.h
  82. !Ekernel/rcu/update.c
  83. </sect1>
  84. <sect1><title>Device Resource Management</title>
  85. !Edrivers/base/devres.c
  86. </sect1>
  87. </chapter>
  88. <chapter id="devdrivers">
  89. <title>Device drivers infrastructure</title>
  90. <sect1><title>The Basic Device Driver-Model Structures </title>
  91. !Iinclude/linux/device.h
  92. </sect1>
  93. <sect1><title>Device Drivers Base</title>
  94. !Idrivers/base/init.c
  95. !Edrivers/base/driver.c
  96. !Edrivers/base/core.c
  97. !Edrivers/base/syscore.c
  98. !Edrivers/base/class.c
  99. !Idrivers/base/node.c
  100. !Edrivers/base/firmware_class.c
  101. !Edrivers/base/transport_class.c
  102. <!-- Cannot be included, because
  103. attribute_container_add_class_device_adapter
  104. and attribute_container_classdev_to_container
  105. exceed allowed 44 characters maximum
  106. X!Edrivers/base/attribute_container.c
  107. -->
  108. !Edrivers/base/dd.c
  109. <!--
  110. X!Edrivers/base/interface.c
  111. -->
  112. !Iinclude/linux/platform_device.h
  113. !Edrivers/base/platform.c
  114. !Edrivers/base/bus.c
  115. </sect1>
  116. <sect1><title>Device Drivers DMA Management</title>
  117. !Edrivers/dma-buf/dma-buf.c
  118. !Edrivers/dma-buf/fence.c
  119. !Edrivers/dma-buf/seqno-fence.c
  120. !Iinclude/linux/fence.h
  121. !Iinclude/linux/seqno-fence.h
  122. !Edrivers/dma-buf/reservation.c
  123. !Iinclude/linux/reservation.h
  124. !Edrivers/base/dma-coherent.c
  125. !Edrivers/base/dma-mapping.c
  126. </sect1>
  127. <sect1><title>Device Drivers Power Management</title>
  128. !Edrivers/base/power/main.c
  129. </sect1>
  130. <sect1><title>Device Drivers ACPI Support</title>
  131. <!-- Internal functions only
  132. X!Edrivers/acpi/sleep/main.c
  133. X!Edrivers/acpi/sleep/wakeup.c
  134. X!Edrivers/acpi/motherboard.c
  135. X!Edrivers/acpi/bus.c
  136. -->
  137. !Edrivers/acpi/scan.c
  138. !Idrivers/acpi/scan.c
  139. <!-- No correct structured comments
  140. X!Edrivers/acpi/pci_bind.c
  141. -->
  142. </sect1>
  143. <sect1><title>Device drivers PnP support</title>
  144. !Idrivers/pnp/core.c
  145. <!-- No correct structured comments
  146. X!Edrivers/pnp/system.c
  147. -->
  148. !Edrivers/pnp/card.c
  149. !Idrivers/pnp/driver.c
  150. !Edrivers/pnp/manager.c
  151. !Edrivers/pnp/support.c
  152. </sect1>
  153. <sect1><title>Userspace IO devices</title>
  154. !Edrivers/uio/uio.c
  155. !Iinclude/linux/uio_driver.h
  156. </sect1>
  157. </chapter>
  158. <chapter id="parportdev">
  159. <title>Parallel Port Devices</title>
  160. !Iinclude/linux/parport.h
  161. !Edrivers/parport/ieee1284.c
  162. !Edrivers/parport/share.c
  163. !Idrivers/parport/daisy.c
  164. </chapter>
  165. <chapter id="message_devices">
  166. <title>Message-based devices</title>
  167. <sect1><title>Fusion message devices</title>
  168. !Edrivers/message/fusion/mptbase.c
  169. !Idrivers/message/fusion/mptbase.c
  170. !Edrivers/message/fusion/mptscsih.c
  171. !Idrivers/message/fusion/mptscsih.c
  172. !Idrivers/message/fusion/mptctl.c
  173. !Idrivers/message/fusion/mptspi.c
  174. !Idrivers/message/fusion/mptfc.c
  175. !Idrivers/message/fusion/mptlan.c
  176. </sect1>
  177. <sect1><title>I2O message devices</title>
  178. !Iinclude/linux/i2o.h
  179. !Idrivers/message/i2o/core.h
  180. !Edrivers/message/i2o/iop.c
  181. !Idrivers/message/i2o/iop.c
  182. !Idrivers/message/i2o/config-osm.c
  183. !Edrivers/message/i2o/exec-osm.c
  184. !Idrivers/message/i2o/exec-osm.c
  185. !Idrivers/message/i2o/bus-osm.c
  186. !Edrivers/message/i2o/device.c
  187. !Idrivers/message/i2o/device.c
  188. !Idrivers/message/i2o/driver.c
  189. !Idrivers/message/i2o/pci.c
  190. !Idrivers/message/i2o/i2o_block.c
  191. !Idrivers/message/i2o/i2o_scsi.c
  192. !Idrivers/message/i2o/i2o_proc.c
  193. </sect1>
  194. </chapter>
  195. <chapter id="snddev">
  196. <title>Sound Devices</title>
  197. !Iinclude/sound/core.h
  198. !Esound/sound_core.c
  199. !Iinclude/sound/pcm.h
  200. !Esound/core/pcm.c
  201. !Esound/core/device.c
  202. !Esound/core/info.c
  203. !Esound/core/rawmidi.c
  204. !Esound/core/sound.c
  205. !Esound/core/memory.c
  206. !Esound/core/pcm_memory.c
  207. !Esound/core/init.c
  208. !Esound/core/isadma.c
  209. !Esound/core/control.c
  210. !Esound/core/pcm_lib.c
  211. !Esound/core/hwdep.c
  212. !Esound/core/pcm_native.c
  213. !Esound/core/memalloc.c
  214. <!-- FIXME: Removed for now since no structured comments in source
  215. X!Isound/sound_firmware.c
  216. -->
  217. </chapter>
  218. <chapter id="uart16x50">
  219. <title>16x50 UART Driver</title>
  220. !Edrivers/tty/serial/serial_core.c
  221. !Edrivers/tty/serial/8250/8250_core.c
  222. </chapter>
  223. <chapter id="fbdev">
  224. <title>Frame Buffer Library</title>
  225. <para>
  226. The frame buffer drivers depend heavily on four data structures.
  227. These structures are declared in include/linux/fb.h. They are
  228. fb_info, fb_var_screeninfo, fb_fix_screeninfo and fb_monospecs.
  229. The last three can be made available to and from userland.
  230. </para>
  231. <para>
  232. fb_info defines the current state of a particular video card.
  233. Inside fb_info, there exists a fb_ops structure which is a
  234. collection of needed functions to make fbdev and fbcon work.
  235. fb_info is only visible to the kernel.
  236. </para>
  237. <para>
  238. fb_var_screeninfo is used to describe the features of a video card
  239. that are user defined. With fb_var_screeninfo, things such as
  240. depth and the resolution may be defined.
  241. </para>
  242. <para>
  243. The next structure is fb_fix_screeninfo. This defines the
  244. properties of a card that are created when a mode is set and can't
  245. be changed otherwise. A good example of this is the start of the
  246. frame buffer memory. This "locks" the address of the frame buffer
  247. memory, so that it cannot be changed or moved.
  248. </para>
  249. <para>
  250. The last structure is fb_monospecs. In the old API, there was
  251. little importance for fb_monospecs. This allowed for forbidden things
  252. such as setting a mode of 800x600 on a fix frequency monitor. With
  253. the new API, fb_monospecs prevents such things, and if used
  254. correctly, can prevent a monitor from being cooked. fb_monospecs
  255. will not be useful until kernels 2.5.x.
  256. </para>
  257. <sect1><title>Frame Buffer Memory</title>
  258. !Edrivers/video/fbdev/core/fbmem.c
  259. </sect1>
  260. <!--
  261. <sect1><title>Frame Buffer Console</title>
  262. X!Edrivers/video/console/fbcon.c
  263. </sect1>
  264. -->
  265. <sect1><title>Frame Buffer Colormap</title>
  266. !Edrivers/video/fbdev/core/fbcmap.c
  267. </sect1>
  268. <!-- FIXME:
  269. drivers/video/fbgen.c has no docs, which stuffs up the sgml. Comment
  270. out until somebody adds docs. KAO
  271. <sect1><title>Frame Buffer Generic Functions</title>
  272. X!Idrivers/video/fbgen.c
  273. </sect1>
  274. KAO -->
  275. <sect1><title>Frame Buffer Video Mode Database</title>
  276. !Idrivers/video/fbdev/core/modedb.c
  277. !Edrivers/video/fbdev/core/modedb.c
  278. </sect1>
  279. <sect1><title>Frame Buffer Macintosh Video Mode Database</title>
  280. !Edrivers/video/fbdev/macmodes.c
  281. </sect1>
  282. <sect1><title>Frame Buffer Fonts</title>
  283. <para>
  284. Refer to the file lib/fonts/fonts.c for more information.
  285. </para>
  286. <!-- FIXME: Removed for now since no structured comments in source
  287. X!Ilib/fonts/fonts.c
  288. -->
  289. </sect1>
  290. </chapter>
  291. <chapter id="input_subsystem">
  292. <title>Input Subsystem</title>
  293. <sect1><title>Input core</title>
  294. !Iinclude/linux/input.h
  295. !Edrivers/input/input.c
  296. !Edrivers/input/ff-core.c
  297. !Edrivers/input/ff-memless.c
  298. </sect1>
  299. <sect1><title>Multitouch Library</title>
  300. !Iinclude/linux/input/mt.h
  301. !Edrivers/input/input-mt.c
  302. </sect1>
  303. <sect1><title>Polled input devices</title>
  304. !Iinclude/linux/input-polldev.h
  305. !Edrivers/input/input-polldev.c
  306. </sect1>
  307. <sect1><title>Matrix keyboars/keypads</title>
  308. !Iinclude/linux/input/matrix_keypad.h
  309. </sect1>
  310. <sect1><title>Sparse keymap support</title>
  311. !Iinclude/linux/input/sparse-keymap.h
  312. !Edrivers/input/sparse-keymap.c
  313. </sect1>
  314. </chapter>
  315. <chapter id="spi">
  316. <title>Serial Peripheral Interface (SPI)</title>
  317. <para>
  318. SPI is the "Serial Peripheral Interface", widely used with
  319. embedded systems because it is a simple and efficient
  320. interface: basically a multiplexed shift register.
  321. Its three signal wires hold a clock (SCK, often in the range
  322. of 1-20 MHz), a "Master Out, Slave In" (MOSI) data line, and
  323. a "Master In, Slave Out" (MISO) data line.
  324. SPI is a full duplex protocol; for each bit shifted out the
  325. MOSI line (one per clock) another is shifted in on the MISO line.
  326. Those bits are assembled into words of various sizes on the
  327. way to and from system memory.
  328. An additional chipselect line is usually active-low (nCS);
  329. four signals are normally used for each peripheral, plus
  330. sometimes an interrupt.
  331. </para>
  332. <para>
  333. The SPI bus facilities listed here provide a generalized
  334. interface to declare SPI busses and devices, manage them
  335. according to the standard Linux driver model, and perform
  336. input/output operations.
  337. At this time, only "master" side interfaces are supported,
  338. where Linux talks to SPI peripherals and does not implement
  339. such a peripheral itself.
  340. (Interfaces to support implementing SPI slaves would
  341. necessarily look different.)
  342. </para>
  343. <para>
  344. The programming interface is structured around two kinds of driver,
  345. and two kinds of device.
  346. A "Controller Driver" abstracts the controller hardware, which may
  347. be as simple as a set of GPIO pins or as complex as a pair of FIFOs
  348. connected to dual DMA engines on the other side of the SPI shift
  349. register (maximizing throughput). Such drivers bridge between
  350. whatever bus they sit on (often the platform bus) and SPI, and
  351. expose the SPI side of their device as a
  352. <structname>struct spi_master</structname>.
  353. SPI devices are children of that master, represented as a
  354. <structname>struct spi_device</structname> and manufactured from
  355. <structname>struct spi_board_info</structname> descriptors which
  356. are usually provided by board-specific initialization code.
  357. A <structname>struct spi_driver</structname> is called a
  358. "Protocol Driver", and is bound to a spi_device using normal
  359. driver model calls.
  360. </para>
  361. <para>
  362. The I/O model is a set of queued messages. Protocol drivers
  363. submit one or more <structname>struct spi_message</structname>
  364. objects, which are processed and completed asynchronously.
  365. (There are synchronous wrappers, however.) Messages are
  366. built from one or more <structname>struct spi_transfer</structname>
  367. objects, each of which wraps a full duplex SPI transfer.
  368. A variety of protocol tweaking options are needed, because
  369. different chips adopt very different policies for how they
  370. use the bits transferred with SPI.
  371. </para>
  372. !Iinclude/linux/spi/spi.h
  373. !Fdrivers/spi/spi.c spi_register_board_info
  374. !Edrivers/spi/spi.c
  375. </chapter>
  376. <chapter id="i2c">
  377. <title>I<superscript>2</superscript>C and SMBus Subsystem</title>
  378. <para>
  379. I<superscript>2</superscript>C (or without fancy typography, "I2C")
  380. is an acronym for the "Inter-IC" bus, a simple bus protocol which is
  381. widely used where low data rate communications suffice.
  382. Since it's also a licensed trademark, some vendors use another
  383. name (such as "Two-Wire Interface", TWI) for the same bus.
  384. I2C only needs two signals (SCL for clock, SDA for data), conserving
  385. board real estate and minimizing signal quality issues.
  386. Most I2C devices use seven bit addresses, and bus speeds of up
  387. to 400 kHz; there's a high speed extension (3.4 MHz) that's not yet
  388. found wide use.
  389. I2C is a multi-master bus; open drain signaling is used to
  390. arbitrate between masters, as well as to handshake and to
  391. synchronize clocks from slower clients.
  392. </para>
  393. <para>
  394. The Linux I2C programming interfaces support only the master
  395. side of bus interactions, not the slave side.
  396. The programming interface is structured around two kinds of driver,
  397. and two kinds of device.
  398. An I2C "Adapter Driver" abstracts the controller hardware; it binds
  399. to a physical device (perhaps a PCI device or platform_device) and
  400. exposes a <structname>struct i2c_adapter</structname> representing
  401. each I2C bus segment it manages.
  402. On each I2C bus segment will be I2C devices represented by a
  403. <structname>struct i2c_client</structname>. Those devices will
  404. be bound to a <structname>struct i2c_driver</structname>,
  405. which should follow the standard Linux driver model.
  406. (At this writing, a legacy model is more widely used.)
  407. There are functions to perform various I2C protocol operations; at
  408. this writing all such functions are usable only from task context.
  409. </para>
  410. <para>
  411. The System Management Bus (SMBus) is a sibling protocol. Most SMBus
  412. systems are also I2C conformant. The electrical constraints are
  413. tighter for SMBus, and it standardizes particular protocol messages
  414. and idioms. Controllers that support I2C can also support most
  415. SMBus operations, but SMBus controllers don't support all the protocol
  416. options that an I2C controller will.
  417. There are functions to perform various SMBus protocol operations,
  418. either using I2C primitives or by issuing SMBus commands to
  419. i2c_adapter devices which don't support those I2C operations.
  420. </para>
  421. !Iinclude/linux/i2c.h
  422. !Fdrivers/i2c/i2c-boardinfo.c i2c_register_board_info
  423. !Edrivers/i2c/i2c-core.c
  424. </chapter>
  425. <chapter id="hsi">
  426. <title>High Speed Synchronous Serial Interface (HSI)</title>
  427. <para>
  428. High Speed Synchronous Serial Interface (HSI) is a
  429. serial interface mainly used for connecting application
  430. engines (APE) with cellular modem engines (CMT) in cellular
  431. handsets.
  432. HSI provides multiplexing for up to 16 logical channels,
  433. low-latency and full duplex communication.
  434. </para>
  435. !Iinclude/linux/hsi/hsi.h
  436. !Edrivers/hsi/hsi.c
  437. </chapter>
  438. </book>