parport-lowlevel.txt 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472
  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