diff options
author | msmith <msmith@FreeBSD.org> | 1998-08-03 19:14:33 +0000 |
---|---|---|
committer | msmith <msmith@FreeBSD.org> | 1998-08-03 19:14:33 +0000 |
commit | 2fdb23234a18b64b994328bb4be606a420e3b56d (patch) | |
tree | f8a4d5d9ba99cb367e9263ec96d08ecb8919f529 /sys/dev/ppbus/ppb_1284.c | |
parent | cfef94c8ca2347c78a745676fe6061eb1f172be7 (diff) | |
download | FreeBSD-src-2fdb23234a18b64b994328bb4be606a420e3b56d.zip FreeBSD-src-2fdb23234a18b64b994328bb4be606a420e3b56d.tar.gz |
Major ppbus updates from the author.
- ppbus now supports PLIP via the if_plip driver
- ieee1284 infrastructure added, including parallel-port PnP
- port microsequencer added, for scripting the sort of port I/O
that is common with parallel devices without endless calls up and down
through the driver structure.
- improved bus ownership behaviour among the ppbus-using drivers.
- improved I/O chipset feature detection
The vpo driver is now implemented using the microsequencer, leading to
some performance improvements as well as providing an extensive example
of its use.
Reviewed by: msmith
Submitted by: Nicolas Souchu <Nicolas.Souchu@prism.uvsq.fr>
Diffstat (limited to 'sys/dev/ppbus/ppb_1284.c')
-rw-r--r-- | sys/dev/ppbus/ppb_1284.c | 72 |
1 files changed, 54 insertions, 18 deletions
diff --git a/sys/dev/ppbus/ppb_1284.c b/sys/dev/ppbus/ppb_1284.c index d1ab1c5..0a0ddeb 100644 --- a/sys/dev/ppbus/ppb_1284.c +++ b/sys/dev/ppbus/ppb_1284.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ppb_1284.c,v 1.2 1997/09/01 00:51:44 bde Exp $ + * $Id: ppb_1284.c,v 1.3 1998/01/31 07:23:06 eivind Exp $ * */ @@ -38,14 +38,23 @@ #include <dev/ppbus/ppb_1284.h> /* - * nibble_1284_wait() + * do_1284_wait() * * Wait for the peripherial up to 40ms */ int -nibble_1284_wait(struct ppb_device *dev, char mask, char status) +do_1284_wait(struct ppb_device *dev, char mask, char status) { int i; + char r; + + /* try up to 5ms */ + for (i = 0; i < 20; i++) { + r = ppb_rstr(dev); + DELAY(25); + if ((r & mask) == status) + return (0); + } return (ppb_poll_device(dev, 4, mask, status, PPB_NOINTR)); } @@ -53,26 +62,55 @@ nibble_1284_wait(struct ppb_device *dev, char mask, char status) #define nibble2char(s) (((s & ~nACK) >> 3) | (~s & nBUSY) >> 4) /* + * byte_1284_inbyte() + * + * Read 1 byte in BYTE mode + */ +int +byte_1284_inbyte(struct ppb_device *dev, char *buffer) +{ + int error; + + /* notify the peripherial to put data on the lines */ + ppb_wctr(dev, PCD | AUTOFEED | nSTROBE | nINIT | nSELECTIN); + + /* wait for valid byte signal */ + if ((error = do_1284_wait(dev, nACK, 0))) + return (error); + + /* fetch data */ + *buffer = ppb_rdtr(dev); + + /* indicate that data has been received, not ready for another */ + ppb_wctr(dev, PCD | nAUTOFEED | nSTROBE | nINIT | nSELECTIN); + + /* wait peripherial's acknowledgement */ + if ((error = do_1284_wait(dev, nACK, nACK))) + return (error); + + /* acknowledge the peripherial */ + ppb_wctr(dev, PCD | nAUTOFEED | STROBE | nINIT | nSELECTIN); + + return (0); +} + +/* * nibble_1284_inbyte() * - * Read data in NIBBLE mode + * Read 1 byte in NIBBLE mode */ int nibble_1284_inbyte(struct ppb_device *dev, char *buffer) { - char nibble[2], r; + char nibble[2]; int i, error; - r = ppb_rctr(dev); - for (i = 0; i < 2; i++) { /* ready to take data (nAUTO low) */ - ppb_wctr(dev, r | AUTOFEED); + ppb_wctr(dev, AUTOFEED | nSTROBE | nINIT | nSELECTIN); - if ((error = nibble_1284_wait(dev, nACK, 0))) { - ppb_wctr(dev, r); + if ((error = do_1284_wait(dev, nACK, 0))) return (error); - } /* read nibble */ nibble[i] = ppb_rstr(dev); @@ -82,13 +120,11 @@ nibble_1284_inbyte(struct ppb_device *dev, char *buffer) #endif /* ack, not ready for another nibble */ - ppb_wctr(dev, r & ~AUTOFEED); + ppb_wctr(dev, nAUTOFEED | nSTROBE | nINIT | nSELECTIN); /* wait ack from peripherial */ - if ((error = nibble_1284_wait(dev, nACK, nACK))) { - ppb_wctr(dev, r); + if ((error = do_1284_wait(dev, nACK, nACK))) return (error); - } } *buffer = ((nibble2char(nibble[1]) << 4) & 0xf0) | @@ -112,11 +148,11 @@ nibble_1284_sync(struct ppb_device *dev) ctr = ppb_rctr(dev); ppb_wctr(dev, (ctr & ~AUTOFEED) | SELECTIN); - if (nibble_1284_wait(dev, nACK, 0)) + if (do_1284_wait(dev, nACK, 0)) return; ppb_wctr(dev, ctr | AUTOFEED); - nibble_1284_wait(dev, nACK, nACK); + do_1284_wait(dev, nACK, nACK); ppb_wctr(dev, (ctr & ~AUTOFEED) | SELECTIN); @@ -140,7 +176,7 @@ nibble_1284_mode(struct ppb_device *dev, int mode) DELAY(5); ppb_wctr(dev, (ctrl & ~SELECTIN) | AUTOFEED); - if ((error = nibble_1284_wait(dev, nACK | ERROR | SELECT | nFAULT, + if ((error = do_1284_wait(dev, nACK | ERROR | SELECT | nFAULT, ERROR | SELECT | nFAULT))) { ppb_wctr(dev, ctrl); return (error); |