parport-lowlevel.txt 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467
  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. This function will register three callbacks into your driver:
  266. 'preempt', 'wakeup' and 'irq'. Each of these may be NULL in order to
  267. indicate that you do not want a callback.
  268. When the 'preempt' function is called, it is because another driver
  269. wishes to use the parallel port. The 'preempt' function should return
  270. non-zero if the parallel port cannot be released yet -- if zero is
  271. returned, the port is lost to another driver and the port must be
  272. re-claimed before use.
  273. The 'wakeup' function is called once another driver has released the
  274. port and no other driver has yet claimed it. You can claim the
  275. parallel port from within the 'wakeup' function (in which case the
  276. claim is guaranteed to succeed), or choose not to if you don't need it
  277. now.
  278. If an interrupt occurs on the parallel port your driver has claimed,
  279. the 'irq' function will be called. (Write something about shared
  280. interrupts here.)
  281. The 'handle' is a pointer to driver-specific data, and is passed to
  282. the callback functions.
  283. 'flags' may be a bitwise combination of the following flags:
  284. Flag Meaning
  285. PARPORT_DEV_EXCL The device cannot share the parallel port at all.
  286. Use this only when absolutely necessary.
  287. The typedefs are not actually defined -- they are only shown in order
  288. to make the function prototype more readable.
  289. The visible parts of the returned 'struct pardevice' are:
  290. struct pardevice {
  291. struct parport *port; /* Associated port */
  292. void *private; /* Device driver's 'handle' */
  293. ...
  294. };
  295. RETURN VALUE
  296. A 'struct pardevice *': a handle to the registered parallel port
  297. device that can be used for parport_claim, parport_release, etc.
  298. ERRORS
  299. A return value of NULL indicates that there was a problem registering
  300. a device on that port.
  301. EXAMPLE
  302. static int preempt (void *handle)
  303. {
  304. if (busy_right_now)
  305. return 1;
  306. must_reclaim_port = 1;
  307. return 0;
  308. }
  309. static void wakeup (void *handle)
  310. {
  311. struct toaster *private = handle;
  312. struct pardevice *dev = private->dev;
  313. if (!dev) return; /* avoid races */
  314. if (want_port)
  315. parport_claim (dev);
  316. }
  317. static int toaster_detect (struct toaster *private, struct parport *port)
  318. {
  319. private->dev = parport_register_device (port, "toaster", preempt,
  320. wakeup, NULL, 0,
  321. private);
  322. if (!private->dev)
  323. /* Couldn't register with parport. */
  324. return -EIO;
  325. must_reclaim_port = 0;
  326. busy_right_now = 1;
  327. parport_claim_or_block (private->dev);
  328. ...
  329. /* Don't need the port while the toaster warms up. */
  330. busy_right_now = 0;
  331. ...
  332. busy_right_now = 1;
  333. if (must_reclaim_port) {
  334. parport_claim_or_block (private->dev);
  335. must_reclaim_port = 0;
  336. }
  337. ...
  338. }
  339. SEE ALSO
  340. parport_unregister_device, parport_claim
  341. parport_unregister_device - finish using a port
  342. -------------------------
  343. SYNPOPSIS
  344. #include <linux/parport.h>
  345. void parport_unregister_device (struct pardevice *dev);
  346. DESCRIPTION
  347. This function is the opposite of parport_register_device. After using
  348. parport_unregister_device, 'dev' is no longer a valid device handle.
  349. You should not unregister a device that is currently claimed, although
  350. if you do it will be released automatically.
  351. EXAMPLE
  352. ...
  353. kfree (dev->private); /* before we lose the pointer */
  354. parport_unregister_device (dev);
  355. ...
  356. SEE ALSO
  357. parport_unregister_driver
  358. parport_claim, parport_claim_or_block - claim the parallel port for a device
  359. -------------------------------------
  360. SYNOPSIS
  361. #include <linux/parport.h>
  362. int parport_claim (struct pardevice *dev);
  363. int parport_claim_or_block (struct pardevice *dev);
  364. DESCRIPTION
  365. These functions attempt to gain control of the parallel port on which
  366. 'dev' is registered. 'parport_claim' does not block, but
  367. 'parport_claim_or_block' may do. (Put something here about blocking
  368. interruptibly or non-interruptibly.)
  369. You should not try to claim a port that you have already claimed.
  370. RETURN VALUE
  371. A return value of zero indicates that the port was successfully
  372. claimed, and the caller now has possession of the parallel port.
  373. If 'parport_claim_or_block' blocks before returning successfully, the
  374. return value is positive.
  375. ERRORS
  376. -EAGAIN The port is unavailable at the moment, but another attempt
  377. to claim it may succeed.
  378. SEE ALSO
  379. parport_release
  380. parport_release - release the parallel port
  381. ---------------
  382. SYNOPSIS
  383. #include <linux/parport.h>
  384. void parport_release (struct pardevice *dev);
  385. DESCRIPTION
  386. Once a parallel port device has been claimed, it can be released using
  387. 'parport_release'. It cannot fail, but you should not release a
  388. device that you do not have possession of.
  389. EXAMPLE
  390. static size_t write (struct pardevice *dev, const void *buf,
  391. size_t len)
  392. {
  393. ...
  394. written = dev->port->ops->write_ecp_data (dev->port, buf,
  395. len);
  396. parport_release (dev);
  397. ...
  398. }
  399. SEE ALSO
  400. change_mode, parport_claim, parport_claim_or_block, parport_yield
  401. parport_yield, parport_yield_blocking - temporarily release a parallel port
  402. -------------------------------------
  403. SYNOPSIS
  404. #include <linux/parport.h>
  405. int parport_yield (struct pardevice *dev)
  406. int parport_yield_blocking (struct pardevice *dev);
  407. DESCRIPTION
  408. When a driver has control of a parallel port, it may allow another
  409. driver to temporarily 'borrow' it. 'parport_yield' does not block;
  410. 'parport_yield_blocking' may do.
  411. RETURN VALUE
  412. A return value of zero indicates that the caller still owns the port
  413. and the call did not block.
  414. A positive return value from 'parport_yield_blocking' indicates that
  415. the caller still owns the port and the call blocked.
  416. A return value of -EAGAIN indicates that the caller no longer owns the
  417. port, and it must be re-claimed before use.
  418. ERRORS
  419. -EAGAIN Ownership of the parallel port was given away.
  420. SEE ALSO
  421. parport_release
  422. parport_wait_peripheral - wait for status lines, up to 35ms
  423. -----------------------
  424. SYNOPSIS
  425. #include <linux/parport.h>
  426. int parport_wait_peripheral (struct parport *port,
  427. unsigned char mask,
  428. unsigned char val);
  429. DESCRIPTION
  430. Wait for the status lines in mask to match the values in val.
  431. RETURN VALUE
  432. -EINTR a signal is pending
  433. 0 the status lines in mask have values in val
  434. 1 timed out while waiting (35ms elapsed)
  435. SEE ALSO
  436. parport_poll_peripheral
  437. parport_poll_peripheral - wait for status lines, in usec
  438. -----------------------
  439. SYNOPSIS
  440. #include <linux/parport.h>
  441. int parport_poll_peripheral (struct parport *port,
  442. unsigned char mask,
  443. unsigned char val,
  444. int usec);
  445. DESCRIPTION
  446. Wait for the status lines in mask to match the values in val.
  447. RETURN VALUE
  448. -EINTR a signal is pending
  449. 0 the status lines in mask have values in val
  450. 1 timed out while waiting (usec microseconds have elapsed)
  451. SEE ALSO
  452. parport_wait_peripheral
  453. parport_wait_event - wait for an event on a port
  454. ------------------
  455. SYNOPSIS
  456. #include <linux/parport.h>
  457. int parport_wait_event (struct parport *port, signed long timeout)
  458. DESCRIPTION
  459. Wait for an event (e.g. interrupt) on a port. The timeout is in
  460. jiffies.
  461. RETURN VALUE
  462. 0 success
  463. <0 error (exit as soon as possible)
  464. >0 timed out
  465. parport_negotiate - perform IEEE 1284 negotiation
  466. -----------------
  467. SYNOPSIS
  468. #include <linux/parport.h>
  469. int parport_negotiate (struct parport *, int mode);
  470. DESCRIPTION
  471. Perform IEEE 1284 negotiation.
  472. RETURN VALUE
  473. 0 handshake OK; IEEE 1284 peripheral and mode available
  474. -1 handshake failed; peripheral not compliant (or none present)
  475. 1 handshake OK; IEEE 1284 peripheral present but mode not
  476. available
  477. SEE ALSO
  478. parport_read, parport_write
  479. parport_read - read data from device
  480. ------------
  481. SYNOPSIS
  482. #include <linux/parport.h>
  483. ssize_t parport_read (struct parport *, void *buf, size_t len);
  484. DESCRIPTION
  485. Read data from device in current IEEE 1284 transfer mode. This only
  486. works for modes that support reverse data transfer.
  487. RETURN VALUE
  488. If negative, an error code; otherwise the number of bytes transferred.
  489. SEE ALSO
  490. parport_write, parport_negotiate
  491. parport_write - write data to device
  492. -------------
  493. SYNOPSIS
  494. #include <linux/parport.h>
  495. ssize_t parport_write (struct parport *, const void *buf, size_t len);
  496. DESCRIPTION
  497. Write data to device in current IEEE 1284 transfer mode. This only
  498. works for modes that support forward data transfer.
  499. RETURN VALUE
  500. If negative, an error code; otherwise the number of bytes transferred.
  501. SEE ALSO
  502. parport_read, parport_negotiate
  503. parport_open - register device for particular device number
  504. ------------
  505. SYNOPSIS
  506. #include <linux/parport.h>
  507. struct pardevice *parport_open (int devnum, const char *name,
  508. int (*pf) (void *),
  509. void (*kf) (void *),
  510. void (*irqf) (int, void *,
  511. struct pt_regs *),
  512. int flags, void *handle);
  513. DESCRIPTION
  514. This is like parport_register_device but takes a device number instead
  515. of a pointer to a struct parport.
  516. RETURN VALUE
  517. See parport_register_device. If no device is associated with devnum,
  518. NULL is returned.
  519. SEE ALSO
  520. parport_register_device
  521. parport_close - unregister device for particular device number
  522. -------------
  523. SYNOPSIS
  524. #include <linux/parport.h>
  525. void parport_close (struct pardevice *dev);
  526. DESCRIPTION
  527. This is the equivalent of parport_unregister_device for parport_open.
  528. SEE ALSO
  529. parport_unregister_device, parport_open
  530. parport_device_id - obtain IEEE 1284 Device ID
  531. -----------------
  532. SYNOPSIS
  533. #include <linux/parport.h>
  534. ssize_t parport_device_id (int devnum, char *buffer, size_t len);
  535. DESCRIPTION
  536. Obtains the IEEE 1284 Device ID associated with a given device.
  537. RETURN VALUE
  538. If negative, an error code; otherwise, the number of bytes of buffer
  539. that contain the device ID. The format of the device ID is as
  540. follows:
  541. [length][ID]
  542. The first two bytes indicate the inclusive length of the entire Device
  543. ID, and are in big-endian order. The ID is a sequence of pairs of the
  544. form:
  545. key:value;
  546. NOTES
  547. Many devices have ill-formed IEEE 1284 Device IDs.
  548. SEE ALSO
  549. parport_find_class, parport_find_device
  550. parport_device_coords - convert device number to device coordinates
  551. ------------------
  552. SYNOPSIS
  553. #include <linux/parport.h>
  554. int parport_device_coords (int devnum, int *parport, int *mux,
  555. int *daisy);
  556. DESCRIPTION
  557. Convert between device number (zero-based) and device coordinates
  558. (port, multiplexor, daisy chain address).
  559. RETURN VALUE
  560. Zero on success, in which case the coordinates are (*parport, *mux,
  561. *daisy).
  562. SEE ALSO
  563. parport_open, parport_device_id
  564. parport_find_class - find a device by its class
  565. ------------------
  566. SYNOPSIS
  567. #include <linux/parport.h>
  568. typedef enum {
  569. PARPORT_CLASS_LEGACY = 0, /* Non-IEEE1284 device */
  570. PARPORT_CLASS_PRINTER,
  571. PARPORT_CLASS_MODEM,
  572. PARPORT_CLASS_NET,
  573. PARPORT_CLASS_HDC, /* Hard disk controller */
  574. PARPORT_CLASS_PCMCIA,
  575. PARPORT_CLASS_MEDIA, /* Multimedia device */
  576. PARPORT_CLASS_FDC, /* Floppy disk controller */
  577. PARPORT_CLASS_PORTS,
  578. PARPORT_CLASS_SCANNER,
  579. PARPORT_CLASS_DIGCAM,
  580. PARPORT_CLASS_OTHER, /* Anything else */
  581. PARPORT_CLASS_UNSPEC, /* No CLS field in ID */
  582. PARPORT_CLASS_SCSIADAPTER
  583. } parport_device_class;
  584. int parport_find_class (parport_device_class cls, int from);
  585. DESCRIPTION
  586. Find a device by class. The search starts from device number from+1.
  587. RETURN VALUE
  588. The device number of the next device in that class, or -1 if no such
  589. device exists.
  590. NOTES
  591. Example usage:
  592. int devnum = -1;
  593. while ((devnum = parport_find_class (PARPORT_CLASS_DIGCAM, devnum)) != -1) {
  594. struct pardevice *dev = parport_open (devnum, ...);
  595. ...
  596. }
  597. SEE ALSO
  598. parport_find_device, parport_open, parport_device_id
  599. parport_find_device - find a device by its class
  600. ------------------
  601. SYNOPSIS
  602. #include <linux/parport.h>
  603. int parport_find_device (const char *mfg, const char *mdl, int from);
  604. DESCRIPTION
  605. Find a device by vendor and model. The search starts from device
  606. number from+1.
  607. RETURN VALUE
  608. The device number of the next device matching the specifications, or
  609. -1 if no such device exists.
  610. NOTES
  611. Example usage:
  612. int devnum = -1;
  613. while ((devnum = parport_find_device ("IOMEGA", "ZIP+", devnum)) != -1) {
  614. struct pardevice *dev = parport_open (devnum, ...);
  615. ...
  616. }
  617. SEE ALSO
  618. parport_find_class, parport_open, parport_device_id
  619. parport_set_timeout - set the inactivity timeout
  620. -------------------
  621. SYNOPSIS
  622. #include <linux/parport.h>
  623. long parport_set_timeout (struct pardevice *dev, long inactivity);
  624. DESCRIPTION
  625. Set the inactivity timeout, in jiffies, for a registered device. The
  626. previous timeout is returned.
  627. RETURN VALUE
  628. The previous timeout, in jiffies.
  629. NOTES
  630. Some of the port->ops functions for a parport may take time, owing to
  631. delays at the peripheral. After the peripheral has not responded for
  632. 'inactivity' jiffies, a timeout will occur and the blocking function
  633. will return.
  634. A timeout of 0 jiffies is a special case: the function must do as much
  635. as it can without blocking or leaving the hardware in an unknown
  636. state. If port operations are performed from within an interrupt
  637. handler, for instance, a timeout of 0 jiffies should be used.
  638. Once set for a registered device, the timeout will remain at the set
  639. value until set again.
  640. SEE ALSO
  641. port->ops->xxx_read/write_yyy
  642. PORT FUNCTIONS
  643. --------------
  644. The functions in the port->ops structure (struct parport_operations)
  645. are provided by the low-level driver responsible for that port.
  646. port->ops->read_data - read the data register
  647. --------------------
  648. SYNOPSIS
  649. #include <linux/parport.h>
  650. struct parport_operations {
  651. ...
  652. unsigned char (*read_data) (struct parport *port);
  653. ...
  654. };
  655. DESCRIPTION
  656. If port->modes contains the PARPORT_MODE_TRISTATE flag and the
  657. PARPORT_CONTROL_DIRECTION bit in the control register is set, this
  658. returns the value on the data pins. If port->modes contains the
  659. PARPORT_MODE_TRISTATE flag and the PARPORT_CONTROL_DIRECTION bit is
  660. not set, the return value _may_ be the last value written to the data
  661. register. Otherwise the return value is undefined.
  662. SEE ALSO
  663. write_data, read_status, write_control
  664. port->ops->write_data - write the data register
  665. ---------------------
  666. SYNOPSIS
  667. #include <linux/parport.h>
  668. struct parport_operations {
  669. ...
  670. void (*write_data) (struct parport *port, unsigned char d);
  671. ...
  672. };
  673. DESCRIPTION
  674. Writes to the data register. May have side-effects (a STROBE pulse,
  675. for instance).
  676. SEE ALSO
  677. read_data, read_status, write_control
  678. port->ops->read_status - read the status register
  679. ----------------------
  680. SYNOPSIS
  681. #include <linux/parport.h>
  682. struct parport_operations {
  683. ...
  684. unsigned char (*read_status) (struct parport *port);
  685. ...
  686. };
  687. DESCRIPTION
  688. Reads from the status register. This is a bitmask:
  689. - PARPORT_STATUS_ERROR (printer fault, "nFault")
  690. - PARPORT_STATUS_SELECT (on-line, "Select")
  691. - PARPORT_STATUS_PAPEROUT (no paper, "PError")
  692. - PARPORT_STATUS_ACK (handshake, "nAck")
  693. - PARPORT_STATUS_BUSY (busy, "Busy")
  694. There may be other bits set.
  695. SEE ALSO
  696. read_data, write_data, write_control
  697. port->ops->read_control - read the control register
  698. -----------------------
  699. SYNOPSIS
  700. #include <linux/parport.h>
  701. struct parport_operations {
  702. ...
  703. unsigned char (*read_control) (struct parport *port);
  704. ...
  705. };
  706. DESCRIPTION
  707. Returns the last value written to the control register (either from
  708. write_control or frob_control). No port access is performed.
  709. SEE ALSO
  710. read_data, write_data, read_status, write_control
  711. port->ops->write_control - write the control register
  712. ------------------------
  713. SYNOPSIS
  714. #include <linux/parport.h>
  715. struct parport_operations {
  716. ...
  717. void (*write_control) (struct parport *port, unsigned char s);
  718. ...
  719. };
  720. DESCRIPTION
  721. Writes to the control register. This is a bitmask:
  722. _______
  723. - PARPORT_CONTROL_STROBE (nStrobe)
  724. _______
  725. - PARPORT_CONTROL_AUTOFD (nAutoFd)
  726. _____
  727. - PARPORT_CONTROL_INIT (nInit)
  728. _________
  729. - PARPORT_CONTROL_SELECT (nSelectIn)
  730. SEE ALSO
  731. read_data, write_data, read_status, frob_control
  732. port->ops->frob_control - write control register bits
  733. -----------------------
  734. SYNOPSIS
  735. #include <linux/parport.h>
  736. struct parport_operations {
  737. ...
  738. unsigned char (*frob_control) (struct parport *port,
  739. unsigned char mask,
  740. unsigned char val);
  741. ...
  742. };
  743. DESCRIPTION
  744. This is equivalent to reading from the control register, masking out
  745. the bits in mask, exclusive-or'ing with the bits in val, and writing
  746. the result to the control register.
  747. As some ports don't allow reads from the control port, a software copy
  748. of its contents is maintained, so frob_control is in fact only one
  749. port access.
  750. SEE ALSO
  751. read_data, write_data, read_status, write_control
  752. port->ops->enable_irq - enable interrupt generation
  753. ---------------------
  754. SYNOPSIS
  755. #include <linux/parport.h>
  756. struct parport_operations {
  757. ...
  758. void (*enable_irq) (struct parport *port);
  759. ...
  760. };
  761. DESCRIPTION
  762. The parallel port hardware is instructed to generate interrupts at
  763. appropriate moments, although those moments are
  764. architecture-specific. For the PC architecture, interrupts are
  765. commonly generated on the rising edge of nAck.
  766. SEE ALSO
  767. disable_irq
  768. port->ops->disable_irq - disable interrupt generation
  769. ----------------------
  770. SYNOPSIS
  771. #include <linux/parport.h>
  772. struct parport_operations {
  773. ...
  774. void (*disable_irq) (struct parport *port);
  775. ...
  776. };
  777. DESCRIPTION
  778. The parallel port hardware is instructed not to generate interrupts.
  779. The interrupt itself is not masked.
  780. SEE ALSO
  781. enable_irq
  782. port->ops->data_forward - enable data drivers
  783. -----------------------
  784. SYNOPSIS
  785. #include <linux/parport.h>
  786. struct parport_operations {
  787. ...
  788. void (*data_forward) (struct parport *port);
  789. ...
  790. };
  791. DESCRIPTION
  792. Enables the data line drivers, for 8-bit host-to-peripheral
  793. communications.
  794. SEE ALSO
  795. data_reverse
  796. port->ops->data_reverse - tristate the buffer
  797. -----------------------
  798. SYNOPSIS
  799. #include <linux/parport.h>
  800. struct parport_operations {
  801. ...
  802. void (*data_reverse) (struct parport *port);
  803. ...
  804. };
  805. DESCRIPTION
  806. Places the data bus in a high impedance state, if port->modes has the
  807. PARPORT_MODE_TRISTATE bit set.
  808. SEE ALSO
  809. data_forward
  810. port->ops->epp_write_data - write EPP data
  811. -------------------------
  812. SYNOPSIS
  813. #include <linux/parport.h>
  814. struct parport_operations {
  815. ...
  816. size_t (*epp_write_data) (struct parport *port, const void *buf,
  817. size_t len, int flags);
  818. ...
  819. };
  820. DESCRIPTION
  821. Writes data in EPP mode, and returns the number of bytes written.
  822. The 'flags' parameter may be one or more of the following,
  823. bitwise-or'ed together:
  824. PARPORT_EPP_FAST Use fast transfers. Some chips provide 16-bit and
  825. 32-bit registers. However, if a transfer
  826. times out, the return value may be unreliable.
  827. SEE ALSO
  828. epp_read_data, epp_write_addr, epp_read_addr
  829. port->ops->epp_read_data - read EPP data
  830. ------------------------
  831. SYNOPSIS
  832. #include <linux/parport.h>
  833. struct parport_operations {
  834. ...
  835. size_t (*epp_read_data) (struct parport *port, void *buf,
  836. size_t len, int flags);
  837. ...
  838. };
  839. DESCRIPTION
  840. Reads data in EPP mode, and returns the number of bytes read.
  841. The 'flags' parameter may be one or more of the following,
  842. bitwise-or'ed together:
  843. PARPORT_EPP_FAST Use fast transfers. Some chips provide 16-bit and
  844. 32-bit registers. However, if a transfer
  845. times out, the return value may be unreliable.
  846. SEE ALSO
  847. epp_write_data, epp_write_addr, epp_read_addr
  848. port->ops->epp_write_addr - write EPP address
  849. -------------------------
  850. SYNOPSIS
  851. #include <linux/parport.h>
  852. struct parport_operations {
  853. ...
  854. size_t (*epp_write_addr) (struct parport *port,
  855. const void *buf, size_t len, int flags);
  856. ...
  857. };
  858. DESCRIPTION
  859. Writes EPP addresses (8 bits each), and returns the number written.
  860. The 'flags' parameter may be one or more of the following,
  861. bitwise-or'ed together:
  862. PARPORT_EPP_FAST Use fast transfers. Some chips provide 16-bit and
  863. 32-bit registers. However, if a transfer
  864. times out, the return value may be unreliable.
  865. (Does PARPORT_EPP_FAST make sense for this function?)
  866. SEE ALSO
  867. epp_write_data, epp_read_data, epp_read_addr
  868. port->ops->epp_read_addr - read EPP address
  869. ------------------------
  870. SYNOPSIS
  871. #include <linux/parport.h>
  872. struct parport_operations {
  873. ...
  874. size_t (*epp_read_addr) (struct parport *port, void *buf,
  875. size_t len, int flags);
  876. ...
  877. };
  878. DESCRIPTION
  879. Reads EPP addresses (8 bits each), and returns the number read.
  880. The 'flags' parameter may be one or more of the following,
  881. bitwise-or'ed together:
  882. PARPORT_EPP_FAST Use fast transfers. Some chips provide 16-bit and
  883. 32-bit registers. However, if a transfer
  884. times out, the return value may be unreliable.
  885. (Does PARPORT_EPP_FAST make sense for this function?)
  886. SEE ALSO
  887. epp_write_data, epp_read_data, epp_write_addr
  888. port->ops->ecp_write_data - write a block of ECP data
  889. -------------------------
  890. SYNOPSIS
  891. #include <linux/parport.h>
  892. struct parport_operations {
  893. ...
  894. size_t (*ecp_write_data) (struct parport *port,
  895. const void *buf, size_t len, int flags);
  896. ...
  897. };
  898. DESCRIPTION
  899. Writes a block of ECP data. The 'flags' parameter is ignored.
  900. RETURN VALUE
  901. The number of bytes written.
  902. SEE ALSO
  903. ecp_read_data, ecp_write_addr
  904. port->ops->ecp_read_data - read a block of ECP data
  905. ------------------------
  906. SYNOPSIS
  907. #include <linux/parport.h>
  908. struct parport_operations {
  909. ...
  910. size_t (*ecp_read_data) (struct parport *port,
  911. void *buf, size_t len, int flags);
  912. ...
  913. };
  914. DESCRIPTION
  915. Reads a block of ECP data. The 'flags' parameter is ignored.
  916. RETURN VALUE
  917. The number of bytes read. NB. There may be more unread data in a
  918. FIFO. Is there a way of stunning the FIFO to prevent this?
  919. SEE ALSO
  920. ecp_write_block, ecp_write_addr
  921. port->ops->ecp_write_addr - write a block of ECP addresses
  922. -------------------------
  923. SYNOPSIS
  924. #include <linux/parport.h>
  925. struct parport_operations {
  926. ...
  927. size_t (*ecp_write_addr) (struct parport *port,
  928. const void *buf, size_t len, int flags);
  929. ...
  930. };
  931. DESCRIPTION
  932. Writes a block of ECP addresses. The 'flags' parameter is ignored.
  933. RETURN VALUE
  934. The number of bytes written.
  935. NOTES
  936. This may use a FIFO, and if so shall not return until the FIFO is empty.
  937. SEE ALSO
  938. ecp_read_data, ecp_write_data
  939. port->ops->nibble_read_data - read a block of data in nibble mode
  940. ---------------------------
  941. SYNOPSIS
  942. #include <linux/parport.h>
  943. struct parport_operations {
  944. ...
  945. size_t (*nibble_read_data) (struct parport *port,
  946. void *buf, size_t len, int flags);
  947. ...
  948. };
  949. DESCRIPTION
  950. Reads a block of data in nibble mode. The 'flags' parameter is ignored.
  951. RETURN VALUE
  952. The number of whole bytes read.
  953. SEE ALSO
  954. byte_read_data, compat_write_data
  955. port->ops->byte_read_data - read a block of data in byte mode
  956. -------------------------
  957. SYNOPSIS
  958. #include <linux/parport.h>
  959. struct parport_operations {
  960. ...
  961. size_t (*byte_read_data) (struct parport *port,
  962. void *buf, size_t len, int flags);
  963. ...
  964. };
  965. DESCRIPTION
  966. Reads a block of data in byte mode. The 'flags' parameter is ignored.
  967. RETURN VALUE
  968. The number of bytes read.
  969. SEE ALSO
  970. nibble_read_data, compat_write_data
  971. port->ops->compat_write_data - write a block of data in compatibility mode
  972. ----------------------------
  973. SYNOPSIS
  974. #include <linux/parport.h>
  975. struct parport_operations {
  976. ...
  977. size_t (*compat_write_data) (struct parport *port,
  978. const void *buf, size_t len, int flags);
  979. ...
  980. };
  981. DESCRIPTION
  982. Writes a block of data in compatibility mode. The 'flags' parameter
  983. is ignored.
  984. RETURN VALUE
  985. The number of bytes written.
  986. SEE ALSO
  987. nibble_read_data, byte_read_data