parport-lowlevel.txt 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471
  1. PARPORT interface documentation
  2. -------------------------------
  3. Time-stamp: <2000-02-24 13:30:20 twaugh>
  4. Described here are the following functions:
  5. Global functions:
  6. parport_register_driver
  7. parport_unregister_driver
  8. parport_enumerate
  9. parport_register_device
  10. parport_unregister_device
  11. parport_claim
  12. parport_claim_or_block
  13. parport_release
  14. parport_yield
  15. parport_yield_blocking
  16. parport_wait_peripheral
  17. parport_poll_peripheral
  18. parport_wait_event
  19. parport_negotiate
  20. parport_read
  21. parport_write
  22. parport_open
  23. parport_close
  24. parport_device_id
  25. parport_device_coords
  26. parport_find_class
  27. parport_find_device
  28. parport_set_timeout
  29. Port functions (can be overridden by low-level drivers):
  30. SPP:
  31. port->ops->read_data
  32. port->ops->write_data
  33. port->ops->read_status
  34. port->ops->read_control
  35. port->ops->write_control
  36. port->ops->frob_control
  37. port->ops->enable_irq
  38. port->ops->disable_irq
  39. port->ops->data_forward
  40. port->ops->data_reverse
  41. EPP:
  42. port->ops->epp_write_data
  43. port->ops->epp_read_data
  44. port->ops->epp_write_addr
  45. port->ops->epp_read_addr
  46. ECP:
  47. port->ops->ecp_write_data
  48. port->ops->ecp_read_data
  49. port->ops->ecp_write_addr
  50. Other:
  51. port->ops->nibble_read_data
  52. port->ops->byte_read_data
  53. port->ops->compat_write_data
  54. The parport subsystem comprises 'parport' (the core port-sharing
  55. code), and a variety of low-level drivers that actually do the port
  56. accesses. Each low-level driver handles a particular style of port
  57. (PC, Amiga, and so on).
  58. The parport interface to the device driver author can be broken down
  59. into global functions and port functions.
  60. The global functions are mostly for communicating between the device
  61. driver and the parport subsystem: acquiring a list of available ports,
  62. claiming a port for exclusive use, and so on. They also include
  63. 'generic' functions for doing standard things that will work on any
  64. IEEE 1284-capable architecture.
  65. The port functions are provided by the low-level drivers, although the
  66. core parport module provides generic 'defaults' for some routines.
  67. The port functions can be split into three groups: SPP, EPP, and ECP.
  68. SPP (Standard Parallel Port) functions modify so-called 'SPP'
  69. registers: data, status, and control. The hardware may not actually
  70. have registers exactly like that, but the PC does and this interface is
  71. modelled after common PC implementations. Other low-level drivers may
  72. be able to emulate most of the functionality.
  73. EPP (Enhanced Parallel Port) functions are provided for reading and
  74. writing in IEEE 1284 EPP mode, and ECP (Extended Capabilities Port)
  75. functions are used for IEEE 1284 ECP mode. (What about BECP? Does
  76. anyone care?)
  77. Hardware assistance for EPP and/or ECP transfers may or may not be
  78. available, and if it is available it may or may not be used. If
  79. hardware is not used, the transfer will be software-driven. In order
  80. to cope with peripherals that only tenuously support IEEE 1284, a
  81. low-level driver specific function is provided, for altering 'fudge
  82. factors'.
  83. GLOBAL FUNCTIONS
  84. ----------------
  85. parport_register_driver - register a device driver with parport
  86. -----------------------
  87. SYNOPSIS
  88. #include <linux/parport.h>
  89. struct parport_driver {
  90. const char *name;
  91. void (*attach) (struct parport *);
  92. void (*detach) (struct parport *);
  93. struct parport_driver *next;
  94. };
  95. int parport_register_driver (struct parport_driver *driver);
  96. DESCRIPTION
  97. In order to be notified about parallel ports when they are detected,
  98. parport_register_driver should be called. Your driver will
  99. immediately be notified of all ports that have already been detected,
  100. and of each new port as low-level drivers are loaded.
  101. A 'struct parport_driver' contains the textual name of your driver,
  102. a pointer to a function to handle new ports, and a pointer to a
  103. function to handle ports going away due to a low-level driver
  104. unloading. Ports will only be detached if they are not being used
  105. (i.e. there are no devices registered on them).
  106. The visible parts of the 'struct parport *' argument given to
  107. attach/detach are:
  108. struct parport
  109. {
  110. struct parport *next; /* next parport in list */
  111. const char *name; /* port's name */
  112. unsigned int modes; /* bitfield of hardware modes */
  113. struct parport_device_info probe_info;
  114. /* IEEE1284 info */
  115. int number; /* parport index */
  116. struct parport_operations *ops;
  117. ...
  118. };
  119. There are other members of the structure, but they should not be
  120. touched.
  121. The 'modes' member summarises the capabilities of the underlying
  122. hardware. It consists of flags which may be bitwise-ored together:
  123. PARPORT_MODE_PCSPP IBM PC registers are available,
  124. i.e. functions that act on data,
  125. control and status registers are
  126. probably writing directly to the
  127. hardware.
  128. PARPORT_MODE_TRISTATE The data drivers may be turned off.
  129. This allows the data lines to be used
  130. for reverse (peripheral to host)
  131. transfers.
  132. PARPORT_MODE_COMPAT The hardware can assist with
  133. compatibility-mode (printer)
  134. transfers, i.e. compat_write_block.
  135. PARPORT_MODE_EPP The hardware can assist with EPP
  136. transfers.
  137. PARPORT_MODE_ECP The hardware can assist with ECP
  138. transfers.
  139. PARPORT_MODE_DMA The hardware can use DMA, so you might
  140. want to pass ISA DMA-able memory
  141. (i.e. memory allocated using the
  142. GFP_DMA flag with kmalloc) to the
  143. low-level driver in order to take
  144. advantage of it.
  145. There may be other flags in 'modes' as well.
  146. The contents of 'modes' is advisory only. For example, if the
  147. hardware is capable of DMA, and PARPORT_MODE_DMA is in 'modes', it
  148. doesn't necessarily mean that DMA will always be used when possible.
  149. Similarly, hardware that is capable of assisting ECP transfers won't
  150. necessarily be used.
  151. RETURN VALUE
  152. Zero on success, otherwise an error code.
  153. ERRORS
  154. None. (Can it fail? Why return int?)
  155. EXAMPLE
  156. static void lp_attach (struct parport *port)
  157. {
  158. ...
  159. private = kmalloc (...);
  160. dev[count++] = parport_register_device (...);
  161. ...
  162. }
  163. static void lp_detach (struct parport *port)
  164. {
  165. ...
  166. }
  167. static struct parport_driver lp_driver = {
  168. "lp",
  169. lp_attach,
  170. lp_detach,
  171. NULL /* always put NULL here */
  172. };
  173. int lp_init (void)
  174. {
  175. ...
  176. if (parport_register_driver (&lp_driver)) {
  177. /* Failed; nothing we can do. */
  178. return -EIO;
  179. }
  180. ...
  181. }
  182. SEE ALSO
  183. parport_unregister_driver, parport_register_device, parport_enumerate
  184. parport_unregister_driver - tell parport to forget about this driver
  185. -------------------------
  186. SYNOPSIS
  187. #include <linux/parport.h>
  188. struct parport_driver {
  189. const char *name;
  190. void (*attach) (struct parport *);
  191. void (*detach) (struct parport *);
  192. struct parport_driver *next;
  193. };
  194. void parport_unregister_driver (struct parport_driver *driver);
  195. DESCRIPTION
  196. This tells parport not to notify the device driver of new ports or of
  197. ports going away. Registered devices belonging to that driver are NOT
  198. unregistered: parport_unregister_device must be used for each one.
  199. EXAMPLE
  200. void cleanup_module (void)
  201. {
  202. ...
  203. /* Stop notifications. */
  204. parport_unregister_driver (&lp_driver);
  205. /* Unregister devices. */
  206. for (i = 0; i < NUM_DEVS; i++)
  207. parport_unregister_device (dev[i]);
  208. ...
  209. }
  210. SEE ALSO
  211. parport_register_driver, parport_enumerate
  212. parport_enumerate - retrieve a list of parallel ports (DEPRECATED)
  213. -----------------
  214. SYNOPSIS
  215. #include <linux/parport.h>
  216. struct parport *parport_enumerate (void);
  217. DESCRIPTION
  218. Retrieve the first of a list of valid parallel ports for this machine.
  219. Successive parallel ports can be found using the 'struct parport
  220. *next' element of the 'struct parport *' that is returned. If 'next'
  221. is NULL, there are no more parallel ports in the list. The number of
  222. ports in the list will not exceed PARPORT_MAX.
  223. RETURN VALUE
  224. A 'struct parport *' describing a valid parallel port for the machine,
  225. or NULL if there are none.
  226. ERRORS
  227. This function can return NULL to indicate that there are no parallel
  228. ports to use.
  229. EXAMPLE
  230. int detect_device (void)
  231. {
  232. struct parport *port;
  233. for (port = parport_enumerate ();
  234. port != NULL;
  235. port = port->next) {
  236. /* Try to detect a device on the port... */
  237. ...
  238. }
  239. }
  240. ...
  241. }
  242. NOTES
  243. parport_enumerate is deprecated; parport_register_driver should be
  244. used instead.
  245. SEE ALSO
  246. parport_register_driver, parport_unregister_driver
  247. parport_register_device - register to use a port
  248. -----------------------
  249. SYNOPSIS
  250. #include <linux/parport.h>
  251. typedef int (*preempt_func) (void *handle);
  252. typedef void (*wakeup_func) (void *handle);
  253. typedef int (*irq_func) (int irq, void *handle, struct pt_regs *);
  254. struct pardevice *parport_register_device(struct parport *port,
  255. const char *name,
  256. preempt_func preempt,
  257. wakeup_func wakeup,
  258. irq_func irq,
  259. int flags,
  260. void *handle);
  261. DESCRIPTION
  262. Use this function to register your device driver on a parallel port
  263. ('port'). Once you have done that, you will be able to use
  264. parport_claim and parport_release in order to use the port.
  265. The ('name') argument is the name of the device that appears in /proc
  266. filesystem. The string must be valid for the whole lifetime of the
  267. device (until parport_unregister_device is called).
  268. This function will register three callbacks into your driver:
  269. 'preempt', 'wakeup' and 'irq'. Each of these may be NULL in order to
  270. indicate that you do not want a callback.
  271. When the 'preempt' function is called, it is because another driver
  272. wishes to use the parallel port. The 'preempt' function should return
  273. non-zero if the parallel port cannot be released yet -- if zero is
  274. returned, the port is lost to another driver and the port must be
  275. re-claimed before use.
  276. The 'wakeup' function is called once another driver has released the
  277. port and no other driver has yet claimed it. You can claim the
  278. parallel port from within the 'wakeup' function (in which case the
  279. claim is guaranteed to succeed), or choose not to if you don't need it
  280. now.
  281. If an interrupt occurs on the parallel port your driver has claimed,
  282. the 'irq' function will be called. (Write something about shared
  283. interrupts here.)
  284. The 'handle' is a pointer to driver-specific data, and is passed to
  285. the callback functions.
  286. 'flags' may be a bitwise combination of the following flags:
  287. Flag Meaning
  288. PARPORT_DEV_EXCL The device cannot share the parallel port at all.
  289. Use this only when absolutely necessary.
  290. The typedefs are not actually defined -- they are only shown in order
  291. to make the function prototype more readable.
  292. The visible parts of the returned 'struct pardevice' are:
  293. struct pardevice {
  294. struct parport *port; /* Associated port */
  295. void *private; /* Device driver's 'handle' */
  296. ...
  297. };
  298. RETURN VALUE
  299. A 'struct pardevice *': a handle to the registered parallel port
  300. device that can be used for parport_claim, parport_release, etc.
  301. ERRORS
  302. A return value of NULL indicates that there was a problem registering
  303. a device on that port.
  304. EXAMPLE
  305. static int preempt (void *handle)
  306. {
  307. if (busy_right_now)
  308. return 1;
  309. must_reclaim_port = 1;
  310. return 0;
  311. }
  312. static void wakeup (void *handle)
  313. {
  314. struct toaster *private = handle;
  315. struct pardevice *dev = private->dev;
  316. if (!dev) return; /* avoid races */
  317. if (want_port)
  318. parport_claim (dev);
  319. }
  320. static int toaster_detect (struct toaster *private, struct parport *port)
  321. {
  322. private->dev = parport_register_device (port, "toaster", preempt,
  323. wakeup, NULL, 0,
  324. private);
  325. if (!private->dev)
  326. /* Couldn't register with parport. */
  327. return -EIO;
  328. must_reclaim_port = 0;
  329. busy_right_now = 1;
  330. parport_claim_or_block (private->dev);
  331. ...
  332. /* Don't need the port while the toaster warms up. */
  333. busy_right_now = 0;
  334. ...
  335. busy_right_now = 1;
  336. if (must_reclaim_port) {
  337. parport_claim_or_block (private->dev);
  338. must_reclaim_port = 0;
  339. }
  340. ...
  341. }
  342. SEE ALSO
  343. parport_unregister_device, parport_claim
  344. parport_unregister_device - finish using a port
  345. -------------------------
  346. SYNPOPSIS
  347. #include <linux/parport.h>
  348. void parport_unregister_device (struct pardevice *dev);
  349. DESCRIPTION
  350. This function is the opposite of parport_register_device. After using
  351. parport_unregister_device, 'dev' is no longer a valid device handle.
  352. You should not unregister a device that is currently claimed, although
  353. if you do it will be released automatically.
  354. EXAMPLE
  355. ...
  356. kfree (dev->private); /* before we lose the pointer */
  357. parport_unregister_device (dev);
  358. ...
  359. SEE ALSO
  360. parport_unregister_driver
  361. parport_claim, parport_claim_or_block - claim the parallel port for a device
  362. -------------------------------------
  363. SYNOPSIS
  364. #include <linux/parport.h>
  365. int parport_claim (struct pardevice *dev);
  366. int parport_claim_or_block (struct pardevice *dev);
  367. DESCRIPTION
  368. These functions attempt to gain control of the parallel port on which
  369. 'dev' is registered. 'parport_claim' does not block, but
  370. 'parport_claim_or_block' may do. (Put something here about blocking
  371. interruptibly or non-interruptibly.)
  372. You should not try to claim a port that you have already claimed.
  373. RETURN VALUE
  374. A return value of zero indicates that the port was successfully
  375. claimed, and the caller now has possession of the parallel port.
  376. If 'parport_claim_or_block' blocks before returning successfully, the
  377. return value is positive.
  378. ERRORS
  379. -EAGAIN The port is unavailable at the moment, but another attempt
  380. to claim it may succeed.
  381. SEE ALSO
  382. parport_release
  383. parport_release - release the parallel port
  384. ---------------
  385. SYNOPSIS
  386. #include <linux/parport.h>
  387. void parport_release (struct pardevice *dev);
  388. DESCRIPTION
  389. Once a parallel port device has been claimed, it can be released using
  390. 'parport_release'. It cannot fail, but you should not release a
  391. device that you do not have possession of.
  392. EXAMPLE
  393. static size_t write (struct pardevice *dev, const void *buf,
  394. size_t len)
  395. {
  396. ...
  397. written = dev->port->ops->write_ecp_data (dev->port, buf,
  398. len);
  399. parport_release (dev);
  400. ...
  401. }
  402. SEE ALSO
  403. change_mode, parport_claim, parport_claim_or_block, parport_yield
  404. parport_yield, parport_yield_blocking - temporarily release a parallel port
  405. -------------------------------------
  406. SYNOPSIS
  407. #include <linux/parport.h>
  408. int parport_yield (struct pardevice *dev)
  409. int parport_yield_blocking (struct pardevice *dev);
  410. DESCRIPTION
  411. When a driver has control of a parallel port, it may allow another
  412. driver to temporarily 'borrow' it. 'parport_yield' does not block;
  413. 'parport_yield_blocking' may do.
  414. RETURN VALUE
  415. A return value of zero indicates that the caller still owns the port
  416. and the call did not block.
  417. A positive return value from 'parport_yield_blocking' indicates that
  418. the caller still owns the port and the call blocked.
  419. A return value of -EAGAIN indicates that the caller no longer owns the
  420. port, and it must be re-claimed before use.
  421. ERRORS
  422. -EAGAIN Ownership of the parallel port was given away.
  423. SEE ALSO
  424. parport_release
  425. parport_wait_peripheral - wait for status lines, up to 35ms
  426. -----------------------
  427. SYNOPSIS
  428. #include <linux/parport.h>
  429. int parport_wait_peripheral (struct parport *port,
  430. unsigned char mask,
  431. unsigned char val);
  432. DESCRIPTION
  433. Wait for the status lines in mask to match the values in val.
  434. RETURN VALUE
  435. -EINTR a signal is pending
  436. 0 the status lines in mask have values in val
  437. 1 timed out while waiting (35ms elapsed)
  438. SEE ALSO
  439. parport_poll_peripheral
  440. parport_poll_peripheral - wait for status lines, in usec
  441. -----------------------
  442. SYNOPSIS
  443. #include <linux/parport.h>
  444. int parport_poll_peripheral (struct parport *port,
  445. unsigned char mask,
  446. unsigned char val,
  447. int usec);
  448. DESCRIPTION
  449. Wait for the status lines in mask to match the values in val.
  450. RETURN VALUE
  451. -EINTR a signal is pending
  452. 0 the status lines in mask have values in val
  453. 1 timed out while waiting (usec microseconds have elapsed)
  454. SEE ALSO
  455. parport_wait_peripheral
  456. parport_wait_event - wait for an event on a port
  457. ------------------
  458. SYNOPSIS
  459. #include <linux/parport.h>
  460. int parport_wait_event (struct parport *port, signed long timeout)
  461. DESCRIPTION
  462. Wait for an event (e.g. interrupt) on a port. The timeout is in
  463. jiffies.
  464. RETURN VALUE
  465. 0 success
  466. <0 error (exit as soon as possible)
  467. >0 timed out
  468. parport_negotiate - perform IEEE 1284 negotiation
  469. -----------------
  470. SYNOPSIS
  471. #include <linux/parport.h>
  472. int parport_negotiate (struct parport *, int mode);
  473. DESCRIPTION
  474. Perform IEEE 1284 negotiation.
  475. RETURN VALUE
  476. 0 handshake OK; IEEE 1284 peripheral and mode available
  477. -1 handshake failed; peripheral not compliant (or none present)
  478. 1 handshake OK; IEEE 1284 peripheral present but mode not
  479. available
  480. SEE ALSO
  481. parport_read, parport_write
  482. parport_read - read data from device
  483. ------------
  484. SYNOPSIS
  485. #include <linux/parport.h>
  486. ssize_t parport_read (struct parport *, void *buf, size_t len);
  487. DESCRIPTION
  488. Read data from device in current IEEE 1284 transfer mode. This only
  489. works for modes that support reverse data transfer.
  490. RETURN VALUE
  491. If negative, an error code; otherwise the number of bytes transferred.
  492. SEE ALSO
  493. parport_write, parport_negotiate
  494. parport_write - write data to device
  495. -------------
  496. SYNOPSIS
  497. #include <linux/parport.h>
  498. ssize_t parport_write (struct parport *, const void *buf, size_t len);
  499. DESCRIPTION
  500. Write data to device in current IEEE 1284 transfer mode. This only
  501. works for modes that support forward data transfer.
  502. RETURN VALUE
  503. If negative, an error code; otherwise the number of bytes transferred.
  504. SEE ALSO
  505. parport_read, parport_negotiate
  506. parport_open - register device for particular device number
  507. ------------
  508. SYNOPSIS
  509. #include <linux/parport.h>
  510. struct pardevice *parport_open (int devnum, const char *name,
  511. int (*pf) (void *),
  512. void (*kf) (void *),
  513. void (*irqf) (int, void *,
  514. struct pt_regs *),
  515. int flags, void *handle);
  516. DESCRIPTION
  517. This is like parport_register_device but takes a device number instead
  518. of a pointer to a struct parport.
  519. RETURN VALUE
  520. See parport_register_device. If no device is associated with devnum,
  521. NULL is returned.
  522. SEE ALSO
  523. parport_register_device
  524. parport_close - unregister device for particular device number
  525. -------------
  526. SYNOPSIS
  527. #include <linux/parport.h>
  528. void parport_close (struct pardevice *dev);
  529. DESCRIPTION
  530. This is the equivalent of parport_unregister_device for parport_open.
  531. SEE ALSO
  532. parport_unregister_device, parport_open
  533. parport_device_id - obtain IEEE 1284 Device ID
  534. -----------------
  535. SYNOPSIS
  536. #include <linux/parport.h>
  537. ssize_t parport_device_id (int devnum, char *buffer, size_t len);
  538. DESCRIPTION
  539. Obtains the IEEE 1284 Device ID associated with a given device.
  540. RETURN VALUE
  541. If negative, an error code; otherwise, the number of bytes of buffer
  542. that contain the device ID. The format of the device ID is as
  543. follows:
  544. [length][ID]
  545. The first two bytes indicate the inclusive length of the entire Device
  546. ID, and are in big-endian order. The ID is a sequence of pairs of the
  547. form:
  548. key:value;
  549. NOTES
  550. Many devices have ill-formed IEEE 1284 Device IDs.
  551. SEE ALSO
  552. parport_find_class, parport_find_device
  553. parport_device_coords - convert device number to device coordinates
  554. ------------------
  555. SYNOPSIS
  556. #include <linux/parport.h>
  557. int parport_device_coords (int devnum, int *parport, int *mux,
  558. int *daisy);
  559. DESCRIPTION
  560. Convert between device number (zero-based) and device coordinates
  561. (port, multiplexor, daisy chain address).
  562. RETURN VALUE
  563. Zero on success, in which case the coordinates are (*parport, *mux,
  564. *daisy).
  565. SEE ALSO
  566. parport_open, parport_device_id
  567. parport_find_class - find a device by its class
  568. ------------------
  569. SYNOPSIS
  570. #include <linux/parport.h>
  571. typedef enum {
  572. PARPORT_CLASS_LEGACY = 0, /* Non-IEEE1284 device */
  573. PARPORT_CLASS_PRINTER,
  574. PARPORT_CLASS_MODEM,
  575. PARPORT_CLASS_NET,
  576. PARPORT_CLASS_HDC, /* Hard disk controller */
  577. PARPORT_CLASS_PCMCIA,
  578. PARPORT_CLASS_MEDIA, /* Multimedia device */
  579. PARPORT_CLASS_FDC, /* Floppy disk controller */
  580. PARPORT_CLASS_PORTS,
  581. PARPORT_CLASS_SCANNER,
  582. PARPORT_CLASS_DIGCAM,
  583. PARPORT_CLASS_OTHER, /* Anything else */
  584. PARPORT_CLASS_UNSPEC, /* No CLS field in ID */
  585. PARPORT_CLASS_SCSIADAPTER
  586. } parport_device_class;
  587. int parport_find_class (parport_device_class cls, int from);
  588. DESCRIPTION
  589. Find a device by class. The search starts from device number from+1.
  590. RETURN VALUE
  591. The device number of the next device in that class, or -1 if no such
  592. device exists.
  593. NOTES
  594. Example usage:
  595. int devnum = -1;
  596. while ((devnum = parport_find_class (PARPORT_CLASS_DIGCAM, devnum)) != -1) {
  597. struct pardevice *dev = parport_open (devnum, ...);
  598. ...
  599. }
  600. SEE ALSO
  601. parport_find_device, parport_open, parport_device_id
  602. parport_find_device - find a device by its class
  603. ------------------
  604. SYNOPSIS
  605. #include <linux/parport.h>
  606. int parport_find_device (const char *mfg, const char *mdl, int from);
  607. DESCRIPTION
  608. Find a device by vendor and model. The search starts from device
  609. number from+1.
  610. RETURN VALUE
  611. The device number of the next device matching the specifications, or
  612. -1 if no such device exists.
  613. NOTES
  614. Example usage:
  615. int devnum = -1;
  616. while ((devnum = parport_find_device ("IOMEGA", "ZIP+", devnum)) != -1) {
  617. struct pardevice *dev = parport_open (devnum, ...);
  618. ...
  619. }
  620. SEE ALSO
  621. parport_find_class, parport_open, parport_device_id
  622. parport_set_timeout - set the inactivity timeout
  623. -------------------
  624. SYNOPSIS
  625. #include <linux/parport.h>
  626. long parport_set_timeout (struct pardevice *dev, long inactivity);
  627. DESCRIPTION
  628. Set the inactivity timeout, in jiffies, for a registered device. The
  629. previous timeout is returned.
  630. RETURN VALUE
  631. The previous timeout, in jiffies.
  632. NOTES
  633. Some of the port->ops functions for a parport may take time, owing to
  634. delays at the peripheral. After the peripheral has not responded for
  635. 'inactivity' jiffies, a timeout will occur and the blocking function
  636. will return.
  637. A timeout of 0 jiffies is a special case: the function must do as much
  638. as it can without blocking or leaving the hardware in an unknown
  639. state. If port operations are performed from within an interrupt
  640. handler, for instance, a timeout of 0 jiffies should be used.
  641. Once set for a registered device, the timeout will remain at the set
  642. value until set again.
  643. SEE ALSO
  644. port->ops->xxx_read/write_yyy
  645. PORT FUNCTIONS
  646. --------------
  647. The functions in the port->ops structure (struct parport_operations)
  648. are provided by the low-level driver responsible for that port.
  649. port->ops->read_data - read the data register
  650. --------------------
  651. SYNOPSIS
  652. #include <linux/parport.h>
  653. struct parport_operations {
  654. ...
  655. unsigned char (*read_data) (struct parport *port);
  656. ...
  657. };
  658. DESCRIPTION
  659. If port->modes contains the PARPORT_MODE_TRISTATE flag and the
  660. PARPORT_CONTROL_DIRECTION bit in the control register is set, this
  661. returns the value on the data pins. If port->modes contains the
  662. PARPORT_MODE_TRISTATE flag and the PARPORT_CONTROL_DIRECTION bit is
  663. not set, the return value _may_ be the last value written to the data
  664. register. Otherwise the return value is undefined.
  665. SEE ALSO
  666. write_data, read_status, write_control
  667. port->ops->write_data - write the data register
  668. ---------------------
  669. SYNOPSIS
  670. #include <linux/parport.h>
  671. struct parport_operations {
  672. ...
  673. void (*write_data) (struct parport *port, unsigned char d);
  674. ...
  675. };
  676. DESCRIPTION
  677. Writes to the data register. May have side-effects (a STROBE pulse,
  678. for instance).
  679. SEE ALSO
  680. read_data, read_status, write_control
  681. port->ops->read_status - read the status register
  682. ----------------------
  683. SYNOPSIS
  684. #include <linux/parport.h>
  685. struct parport_operations {
  686. ...
  687. unsigned char (*read_status) (struct parport *port);
  688. ...
  689. };
  690. DESCRIPTION
  691. Reads from the status register. This is a bitmask:
  692. - PARPORT_STATUS_ERROR (printer fault, "nFault")
  693. - PARPORT_STATUS_SELECT (on-line, "Select")
  694. - PARPORT_STATUS_PAPEROUT (no paper, "PError")
  695. - PARPORT_STATUS_ACK (handshake, "nAck")
  696. - PARPORT_STATUS_BUSY (busy, "Busy")
  697. There may be other bits set.
  698. SEE ALSO
  699. read_data, write_data, write_control
  700. port->ops->read_control - read the control register
  701. -----------------------
  702. SYNOPSIS
  703. #include <linux/parport.h>
  704. struct parport_operations {
  705. ...
  706. unsigned char (*read_control) (struct parport *port);
  707. ...
  708. };
  709. DESCRIPTION
  710. Returns the last value written to the control register (either from
  711. write_control or frob_control). No port access is performed.
  712. SEE ALSO
  713. read_data, write_data, read_status, write_control
  714. port->ops->write_control - write the control register
  715. ------------------------
  716. SYNOPSIS
  717. #include <linux/parport.h>
  718. struct parport_operations {
  719. ...
  720. void (*write_control) (struct parport *port, unsigned char s);
  721. ...
  722. };
  723. DESCRIPTION
  724. Writes to the control register. This is a bitmask:
  725. _______
  726. - PARPORT_CONTROL_STROBE (nStrobe)
  727. _______
  728. - PARPORT_CONTROL_AUTOFD (nAutoFd)
  729. _____
  730. - PARPORT_CONTROL_INIT (nInit)
  731. _________
  732. - PARPORT_CONTROL_SELECT (nSelectIn)
  733. SEE ALSO
  734. read_data, write_data, read_status, frob_control
  735. port->ops->frob_control - write control register bits
  736. -----------------------
  737. SYNOPSIS
  738. #include <linux/parport.h>
  739. struct parport_operations {
  740. ...
  741. unsigned char (*frob_control) (struct parport *port,
  742. unsigned char mask,
  743. unsigned char val);
  744. ...
  745. };
  746. DESCRIPTION
  747. This is equivalent to reading from the control register, masking out
  748. the bits in mask, exclusive-or'ing with the bits in val, and writing
  749. the result to the control register.
  750. As some ports don't allow reads from the control port, a software copy
  751. of its contents is maintained, so frob_control is in fact only one
  752. port access.
  753. SEE ALSO
  754. read_data, write_data, read_status, write_control
  755. port->ops->enable_irq - enable interrupt generation
  756. ---------------------
  757. SYNOPSIS
  758. #include <linux/parport.h>
  759. struct parport_operations {
  760. ...
  761. void (*enable_irq) (struct parport *port);
  762. ...
  763. };
  764. DESCRIPTION
  765. The parallel port hardware is instructed to generate interrupts at
  766. appropriate moments, although those moments are
  767. architecture-specific. For the PC architecture, interrupts are
  768. commonly generated on the rising edge of nAck.
  769. SEE ALSO
  770. disable_irq
  771. port->ops->disable_irq - disable interrupt generation
  772. ----------------------
  773. SYNOPSIS
  774. #include <linux/parport.h>
  775. struct parport_operations {
  776. ...
  777. void (*disable_irq) (struct parport *port);
  778. ...
  779. };
  780. DESCRIPTION
  781. The parallel port hardware is instructed not to generate interrupts.
  782. The interrupt itself is not masked.
  783. SEE ALSO
  784. enable_irq
  785. port->ops->data_forward - enable data drivers
  786. -----------------------
  787. SYNOPSIS
  788. #include <linux/parport.h>
  789. struct parport_operations {
  790. ...
  791. void (*data_forward) (struct parport *port);
  792. ...
  793. };
  794. DESCRIPTION
  795. Enables the data line drivers, for 8-bit host-to-peripheral
  796. communications.
  797. SEE ALSO
  798. data_reverse
  799. port->ops->data_reverse - tristate the buffer
  800. -----------------------
  801. SYNOPSIS
  802. #include <linux/parport.h>
  803. struct parport_operations {
  804. ...
  805. void (*data_reverse) (struct parport *port);
  806. ...
  807. };
  808. DESCRIPTION
  809. Places the data bus in a high impedance state, if port->modes has the
  810. PARPORT_MODE_TRISTATE bit set.
  811. SEE ALSO
  812. data_forward
  813. port->ops->epp_write_data - write EPP data
  814. -------------------------
  815. SYNOPSIS
  816. #include <linux/parport.h>
  817. struct parport_operations {
  818. ...
  819. size_t (*epp_write_data) (struct parport *port, const void *buf,
  820. size_t len, int flags);
  821. ...
  822. };
  823. DESCRIPTION
  824. Writes data in EPP mode, and returns the number of bytes written.
  825. The 'flags' parameter may be one or more of the following,
  826. bitwise-or'ed together:
  827. PARPORT_EPP_FAST Use fast transfers. Some chips provide 16-bit and
  828. 32-bit registers. However, if a transfer
  829. times out, the return value may be unreliable.
  830. SEE ALSO
  831. epp_read_data, epp_write_addr, epp_read_addr
  832. port->ops->epp_read_data - read EPP data
  833. ------------------------
  834. SYNOPSIS
  835. #include <linux/parport.h>
  836. struct parport_operations {
  837. ...
  838. size_t (*epp_read_data) (struct parport *port, void *buf,
  839. size_t len, int flags);
  840. ...
  841. };
  842. DESCRIPTION
  843. Reads data in EPP mode, and returns the number of bytes read.
  844. The 'flags' parameter may be one or more of the following,
  845. bitwise-or'ed together:
  846. PARPORT_EPP_FAST Use fast transfers. Some chips provide 16-bit and
  847. 32-bit registers. However, if a transfer
  848. times out, the return value may be unreliable.
  849. SEE ALSO
  850. epp_write_data, epp_write_addr, epp_read_addr
  851. port->ops->epp_write_addr - write EPP address
  852. -------------------------
  853. SYNOPSIS
  854. #include <linux/parport.h>
  855. struct parport_operations {
  856. ...
  857. size_t (*epp_write_addr) (struct parport *port,
  858. const void *buf, size_t len, int flags);
  859. ...
  860. };
  861. DESCRIPTION
  862. Writes EPP addresses (8 bits each), and returns the number written.
  863. The 'flags' parameter may be one or more of the following,
  864. bitwise-or'ed together:
  865. PARPORT_EPP_FAST Use fast transfers. Some chips provide 16-bit and
  866. 32-bit registers. However, if a transfer
  867. times out, the return value may be unreliable.
  868. (Does PARPORT_EPP_FAST make sense for this function?)
  869. SEE ALSO
  870. epp_write_data, epp_read_data, epp_read_addr
  871. port->ops->epp_read_addr - read EPP address
  872. ------------------------
  873. SYNOPSIS
  874. #include <linux/parport.h>
  875. struct parport_operations {
  876. ...
  877. size_t (*epp_read_addr) (struct parport *port, void *buf,
  878. size_t len, int flags);
  879. ...
  880. };
  881. DESCRIPTION
  882. Reads EPP addresses (8 bits each), and returns the number read.
  883. The 'flags' parameter may be one or more of the following,
  884. bitwise-or'ed together:
  885. PARPORT_EPP_FAST Use fast transfers. Some chips provide 16-bit and
  886. 32-bit registers. However, if a transfer
  887. times out, the return value may be unreliable.
  888. (Does PARPORT_EPP_FAST make sense for this function?)
  889. SEE ALSO
  890. epp_write_data, epp_read_data, epp_write_addr
  891. port->ops->ecp_write_data - write a block of ECP data
  892. -------------------------
  893. SYNOPSIS
  894. #include <linux/parport.h>
  895. struct parport_operations {
  896. ...
  897. size_t (*ecp_write_data) (struct parport *port,
  898. const void *buf, size_t len, int flags);
  899. ...
  900. };
  901. DESCRIPTION
  902. Writes a block of ECP data. The 'flags' parameter is ignored.
  903. RETURN VALUE
  904. The number of bytes written.
  905. SEE ALSO
  906. ecp_read_data, ecp_write_addr
  907. port->ops->ecp_read_data - read a block of ECP data
  908. ------------------------
  909. SYNOPSIS
  910. #include <linux/parport.h>
  911. struct parport_operations {
  912. ...
  913. size_t (*ecp_read_data) (struct parport *port,
  914. void *buf, size_t len, int flags);
  915. ...
  916. };
  917. DESCRIPTION
  918. Reads a block of ECP data. The 'flags' parameter is ignored.
  919. RETURN VALUE
  920. The number of bytes read. NB. There may be more unread data in a
  921. FIFO. Is there a way of stunning the FIFO to prevent this?
  922. SEE ALSO
  923. ecp_write_block, ecp_write_addr
  924. port->ops->ecp_write_addr - write a block of ECP addresses
  925. -------------------------
  926. SYNOPSIS
  927. #include <linux/parport.h>
  928. struct parport_operations {
  929. ...
  930. size_t (*ecp_write_addr) (struct parport *port,
  931. const void *buf, size_t len, int flags);
  932. ...
  933. };
  934. DESCRIPTION
  935. Writes a block of ECP addresses. The 'flags' parameter is ignored.
  936. RETURN VALUE
  937. The number of bytes written.
  938. NOTES
  939. This may use a FIFO, and if so shall not return until the FIFO is empty.
  940. SEE ALSO
  941. ecp_read_data, ecp_write_data
  942. port->ops->nibble_read_data - read a block of data in nibble mode
  943. ---------------------------
  944. SYNOPSIS
  945. #include <linux/parport.h>
  946. struct parport_operations {
  947. ...
  948. size_t (*nibble_read_data) (struct parport *port,
  949. void *buf, size_t len, int flags);
  950. ...
  951. };
  952. DESCRIPTION
  953. Reads a block of data in nibble mode. The 'flags' parameter is ignored.
  954. RETURN VALUE
  955. The number of whole bytes read.
  956. SEE ALSO
  957. byte_read_data, compat_write_data
  958. port->ops->byte_read_data - read a block of data in byte mode
  959. -------------------------
  960. SYNOPSIS
  961. #include <linux/parport.h>
  962. struct parport_operations {
  963. ...
  964. size_t (*byte_read_data) (struct parport *port,
  965. void *buf, size_t len, int flags);
  966. ...
  967. };
  968. DESCRIPTION
  969. Reads a block of data in byte mode. The 'flags' parameter is ignored.
  970. RETURN VALUE
  971. The number of bytes read.
  972. SEE ALSO
  973. nibble_read_data, compat_write_data
  974. port->ops->compat_write_data - write a block of data in compatibility mode
  975. ----------------------------
  976. SYNOPSIS
  977. #include <linux/parport.h>
  978. struct parport_operations {
  979. ...
  980. size_t (*compat_write_data) (struct parport *port,
  981. const void *buf, size_t len, int flags);
  982. ...
  983. };
  984. DESCRIPTION
  985. Writes a block of data in compatibility mode. The 'flags' parameter
  986. is ignored.
  987. RETURN VALUE
  988. The number of bytes written.
  989. SEE ALSO
  990. nibble_read_data, byte_read_data