Lines Matching full:bus
42 #include <sys/bus.h>
59 do_1284_wait(device_t bus, uint8_t mask, uint8_t status) in do_1284_wait() argument
61 return (ppb_poll_bus(bus, 4, mask, status, PPB_NOINTR | PPB_POLL)); in do_1284_wait()
65 do_peripheral_wait(device_t bus, uint8_t mask, uint8_t status) in do_peripheral_wait() argument
67 return (ppb_poll_bus(bus, 100, mask, status, PPB_NOINTR | PPB_POLL)); in do_peripheral_wait()
78 ppb_1284_reset_error(device_t bus, int state) in ppb_1284_reset_error() argument
80 struct ppb_data *ppb = DEVTOSOFTC(bus); in ppb_1284_reset_error()
94 ppb_1284_get_state(device_t bus) in ppb_1284_get_state() argument
96 struct ppb_data *ppb = DEVTOSOFTC(bus); in ppb_1284_get_state()
108 ppb_1284_set_state(device_t bus, int state) in ppb_1284_set_state() argument
110 struct ppb_data *ppb = DEVTOSOFTC(bus); in ppb_1284_set_state()
125 ppb_1284_set_error(device_t bus, int error, int event) in ppb_1284_set_error() argument
127 struct ppb_data *ppb = DEVTOSOFTC(bus); in ppb_1284_set_error()
138 ppb_rstr(bus) & 0xff, event); in ppb_1284_set_error()
196 ppb_peripheral_negociate(device_t bus, int mode, int options) in ppb_peripheral_negociate() argument
201 ppb_set_mode(bus, PPB_COMPATIBLE); in ppb_peripheral_negociate()
202 ppb_1284_set_state(bus, PPB_PERIPHERAL_NEGOCIATION); in ppb_peripheral_negociate()
209 while (spin-- && (ppb_rstr(bus) & nBUSY)) in ppb_peripheral_negociate()
213 if (!(ppb_rstr(bus) & SELECT) || !spin) { in ppb_peripheral_negociate()
219 r = ppb_rdtr(bus); in ppb_peripheral_negociate()
225 ppb_wctr(bus, (STROBE | nINIT) & ~(SELECTIN)); in ppb_peripheral_negociate()
229 ppb_wctr(bus, (nINIT) & ~(SELECTIN | STROBE)); in ppb_peripheral_negociate()
235 ppb_1284_set_error(bus, PPB_MODE_UNSUPPORTED, 4); in ppb_peripheral_negociate()
239 ppb_1284_set_state(bus, PPB_PERIPHERAL_IDLE); in ppb_peripheral_negociate()
242 ppb_set_mode(bus, PPB_BYTE); in ppb_peripheral_negociate()
254 ppb_wctr(bus, SELECTIN); in ppb_peripheral_negociate()
258 ppb_wctr(bus, (SELECTIN) & ~(STROBE | nINIT)); in ppb_peripheral_negociate()
259 ppb_1284_set_error(bus, PPB_MODE_UNSUPPORTED, 4); in ppb_peripheral_negociate()
271 ppb_peripheral_terminate(bus, PPB_WAIT); in ppb_peripheral_negociate()
283 ppb_peripheral_terminate(device_t bus, int how) in ppb_peripheral_terminate() argument
291 ppb_1284_set_state(bus, PPB_PERIPHERAL_TERMINATION); in ppb_peripheral_terminate()
294 if ((error = do_peripheral_wait(bus, SELECT | nBUSY, 0))) { in ppb_peripheral_terminate()
295 ppb_1284_set_error(bus, PPB_TIMEOUT, 22); in ppb_peripheral_terminate()
300 ppb_wctr(bus, (nINIT | STROBE) & ~(AUTOFEED | SELECTIN)); in ppb_peripheral_terminate()
303 if ((error = do_peripheral_wait(bus, nBUSY, nBUSY))) { in ppb_peripheral_terminate()
304 ppb_1284_set_error(bus, PPB_TIMEOUT, 25); in ppb_peripheral_terminate()
309 ppb_wctr(bus, (SELECTIN | nINIT | STROBE) & ~(AUTOFEED)); in ppb_peripheral_terminate()
312 ppb_wctr(bus, (SELECTIN | nINIT) & ~(STROBE | AUTOFEED)); in ppb_peripheral_terminate()
315 if ((error = do_peripheral_wait(bus, nBUSY, 0))) { in ppb_peripheral_terminate()
316 ppb_1284_set_error(bus, PPB_TIMEOUT, 28); in ppb_peripheral_terminate()
321 ppb_set_mode(bus, PPB_COMPATIBLE); in ppb_peripheral_terminate()
322 ppb_1284_set_state(bus, PPB_FORWARD_IDLE); in ppb_peripheral_terminate()
333 byte_peripheral_outbyte(device_t bus, char *buffer, int last) in byte_peripheral_outbyte() argument
338 if ((error = do_1284_wait(bus, nBUSY, nBUSY))) { in byte_peripheral_outbyte()
339 ppb_1284_set_error(bus, PPB_TIMEOUT, 7); in byte_peripheral_outbyte()
344 if (!(ppb_rstr(bus) & SELECT)) { in byte_peripheral_outbyte()
345 ppb_peripheral_terminate(bus, PPB_WAIT); in byte_peripheral_outbyte()
353 ppb_wdtr(bus, *buffer); in byte_peripheral_outbyte()
356 ppb_wctr(bus, (AUTOFEED | STROBE) & ~(nINIT | SELECTIN)); in byte_peripheral_outbyte()
359 if ((error = do_peripheral_wait(bus, nBUSY, 0))) { in byte_peripheral_outbyte()
360 ppb_1284_set_error(bus, PPB_TIMEOUT, 16); in byte_peripheral_outbyte()
366 ppb_wctr(bus, (AUTOFEED) & ~(nINIT | STROBE | SELECTIN)); in byte_peripheral_outbyte()
368 ppb_wctr(bus, (nINIT) & ~(STROBE | SELECTIN | AUTOFEED)); in byte_peripheral_outbyte()
373 if ((error = do_peripheral_wait(bus, nACK | nBUSY, 0))) { in byte_peripheral_outbyte()
374 ppb_1284_set_error(bus, PPB_TIMEOUT, 16); in byte_peripheral_outbyte()
380 if (!(ppb_rstr(bus) & SELECT)) { in byte_peripheral_outbyte()
381 ppb_peripheral_terminate(bus, PPB_WAIT); in byte_peripheral_outbyte()
395 byte_peripheral_write(device_t bus, char *buffer, int len, int *sent) in byte_peripheral_write() argument
400 ppb_1284_set_state(bus, PPB_PERIPHERAL_TRANSFER); in byte_peripheral_write()
409 r = ppb_rctr(bus); in byte_peripheral_write()
410 ppb_wctr(bus, r & ~nINIT); in byte_peripheral_write()
416 error = ppb_poll_bus(bus, PPB_FOREVER, nBUSY, nBUSY, in byte_peripheral_write()
425 if ((error = byte_peripheral_outbyte(bus, buffer+i, (i == len-1)))) in byte_peripheral_write()
430 ppb_1284_set_state(bus, PPB_PERIPHERAL_IDLE); in byte_peripheral_write()
442 byte_1284_inbyte(device_t bus, char *buffer) in byte_1284_inbyte() argument
447 ppb_wctr(bus, (PCD | nINIT | AUTOFEED) & ~(STROBE | SELECTIN)); in byte_1284_inbyte()
450 if ((error = do_1284_wait(bus, nACK, 0))) { in byte_1284_inbyte()
451 ppb_1284_set_error(bus, PPB_TIMEOUT, 9); in byte_1284_inbyte()
456 *buffer = ppb_rdtr(bus); in byte_1284_inbyte()
459 ppb_wctr(bus, (nINIT) & ~(AUTOFEED | STROBE | SELECTIN)); in byte_1284_inbyte()
462 if ((error = do_1284_wait(bus, nACK, nACK))) { in byte_1284_inbyte()
463 ppb_1284_set_error(bus, PPB_TIMEOUT, 11); in byte_1284_inbyte()
468 ppb_wctr(bus, (nINIT | STROBE) & ~(AUTOFEED | SELECTIN)); in byte_1284_inbyte()
470 ppb_wctr(bus, (nINIT) & ~(AUTOFEED | STROBE | SELECTIN)); in byte_1284_inbyte()
482 nibble_1284_inbyte(device_t bus, char *buffer) in nibble_1284_inbyte() argument
489 ppb_wctr(bus, (nINIT | AUTOFEED) & ~(STROBE | SELECTIN)); in nibble_1284_inbyte()
494 if ((error = do_1284_wait(bus, nACK, 0))) { in nibble_1284_inbyte()
495 ppb_1284_set_error(bus, PPB_TIMEOUT, 9); in nibble_1284_inbyte()
500 nibble[i] = ppb_rstr(bus); in nibble_1284_inbyte()
503 ppb_wctr(bus, nINIT & ~(AUTOFEED | STROBE | SELECTIN)); in nibble_1284_inbyte()
506 if ((error = do_1284_wait(bus, nACK, nACK))) { in nibble_1284_inbyte()
507 ppb_1284_set_error(bus, PPB_TIMEOUT, 11); in nibble_1284_inbyte()
525 spp_1284_read(device_t bus, int mode, char *buffer, int max, int *read) in spp_1284_read() argument
533 state = ppb_1284_get_state(bus); in spp_1284_read()
537 if ((error = ppb_1284_negociate(bus, mode, 0))) in spp_1284_read()
546 ppb_1284_terminate(bus); in spp_1284_read()
547 if ((error = ppb_1284_negociate(bus, mode, 0))) in spp_1284_read()
552 while ((len < max) && !(ppb_rstr(bus) & (nFAULT))) { in spp_1284_read()
553 ppb_1284_set_state(bus, PPB_REVERSE_TRANSFER); in spp_1284_read()
562 if (nibble_1284_inbyte(bus, buffer+len)) in spp_1284_read()
566 if (byte_1284_inbyte(bus, buffer+len)) in spp_1284_read()
578 ppb_1284_set_state(bus, PPB_REVERSE_IDLE); in spp_1284_read()
583 ppb_1284_terminate(bus); in spp_1284_read()
593 ppb_1284_read_id(device_t bus, int mode, char *buffer, in ppb_1284_read_id() argument
604 if ((error = ppb_1284_negociate(bus, PPB_NIBBLE, PPB_REQUEST_ID))) in ppb_1284_read_id()
606 error = spp_1284_read(bus, PPB_NIBBLE, buffer, max, read); in ppb_1284_read_id()
609 if ((error = ppb_1284_negociate(bus, PPB_BYTE, PPB_REQUEST_ID))) in ppb_1284_read_id()
611 error = spp_1284_read(bus, PPB_BYTE, buffer, max, read); in ppb_1284_read_id()
617 ppb_1284_terminate(bus); in ppb_1284_read_id()
627 ppb_1284_read(device_t bus, int mode, char *buffer, in ppb_1284_read() argument
635 error = spp_1284_read(bus, mode, buffer, max, read); in ppb_1284_read()
654 ppb_1284_negociate(device_t bus, int mode, int options) in ppb_1284_negociate() argument
663 if (ppb_1284_get_state(bus) >= PPB_PERIPHERAL_NEGOCIATION) in ppb_1284_negociate()
664 ppb_peripheral_terminate(bus, PPB_WAIT); in ppb_1284_negociate()
666 if (ppb_1284_get_state(bus) != PPB_FORWARD_IDLE) in ppb_1284_negociate()
667 ppb_1284_terminate(bus); in ppb_1284_negociate()
674 ppb_set_mode(bus, PPB_COMPATIBLE); in ppb_1284_negociate()
677 ppb_1284_reset_error(bus, PPB_FORWARD_IDLE); in ppb_1284_negociate()
683 ppb_wctr(bus, (nINIT | SELECTIN) & ~(STROBE | AUTOFEED)); in ppb_1284_negociate()
687 ppb_1284_set_state(bus, PPB_NEGOCIATION); in ppb_1284_negociate()
690 ppb_wdtr(bus, request_mode); in ppb_1284_negociate()
694 ppb_wctr(bus, (nINIT | STROBE) & ~(AUTOFEED | SELECTIN)); in ppb_1284_negociate()
696 ppb_wctr(bus, (nINIT) & ~(STROBE | AUTOFEED | SELECTIN)); in ppb_1284_negociate()
703 ppb_wctr(bus, (nINIT | AUTOFEED) & ~(STROBE | SELECTIN)); in ppb_1284_negociate()
708 if (ppb_poll_bus(bus, 40, nACK | SELECT | nFAULT, in ppb_1284_negociate()
710 ppb_1284_set_error(bus, PPB_NOT_IEEE1284, 2); in ppb_1284_negociate()
716 if (do_1284_wait(bus, nACK | PERROR | SELECT | nFAULT, in ppb_1284_negociate()
718 ppb_1284_set_error(bus, PPB_NOT_IEEE1284, 2); in ppb_1284_negociate()
725 ppb_wctr(bus, (nINIT | STROBE | AUTOFEED) & ~SELECTIN); in ppb_1284_negociate()
729 ppb_wctr(bus, nINIT & ~(SELECTIN | AUTOFEED | STROBE)); in ppb_1284_negociate()
732 if (do_1284_wait(bus, nACK, nACK)) { in ppb_1284_negociate()
733 ppb_1284_set_error(bus, PPB_TIMEOUT, 6); in ppb_1284_negociate()
742 ppb_1284_terminate(bus); in ppb_1284_negociate()
746 if (do_1284_wait(bus, nACK | SELECT, nACK)) { in ppb_1284_negociate()
747 ppb_1284_set_error(bus, PPB_MODE_UNSUPPORTED, 7); in ppb_1284_negociate()
752 if (do_1284_wait(bus, nACK | SELECT, SELECT | nACK)) { in ppb_1284_negociate()
753 ppb_1284_set_error(bus, PPB_MODE_UNSUPPORTED, 7); in ppb_1284_negociate()
763 ppb_1284_set_state(bus, PPB_REVERSE_IDLE); in ppb_1284_negociate()
767 ppb_1284_set_state(bus, PPB_SETUP); in ppb_1284_negociate()
768 ppb_wctr(bus, (nINIT | AUTOFEED) & ~(SELECTIN | STROBE)); in ppb_1284_negociate()
772 if (do_1284_wait(bus, nACK | SELECT | nBUSY, in ppb_1284_negociate()
774 ppb_1284_set_error(bus, PPB_TIMEOUT, 30); in ppb_1284_negociate()
779 if (do_1284_wait(bus, nACK | SELECT | PERROR | nBUSY, in ppb_1284_negociate()
781 ppb_1284_set_error(bus, PPB_TIMEOUT, 30); in ppb_1284_negociate()
788 ppb_1284_set_state(bus, PPB_ECP_FORWARD_IDLE); in ppb_1284_negociate()
791 ppb_1284_set_state(bus, PPB_EPP_IDLE); in ppb_1284_negociate()
797 ppb_set_mode(bus, mode); in ppb_1284_negociate()
802 ppb_1284_terminate(bus); in ppb_1284_negociate()
814 ppb_1284_terminate(device_t bus) in ppb_1284_terminate() argument
823 ppb_1284_set_state(bus, PPB_TERMINATION); in ppb_1284_terminate()
827 ppb_wctr(bus, (nINIT | STROBE | SELECTIN) & ~(AUTOFEED)); in ppb_1284_terminate()
832 ppb_wctr(bus, (nINIT | SELECTIN) & ~(STROBE | AUTOFEED)); in ppb_1284_terminate()
835 if (do_1284_wait(bus, nACK | nBUSY | nFAULT, nFAULT)) { in ppb_1284_terminate()
836 ppb_1284_set_error(bus, PPB_TIMEOUT, 24); in ppb_1284_terminate()
841 ppb_wctr(bus, (nINIT | SELECTIN | AUTOFEED) & ~STROBE); in ppb_1284_terminate()
846 if (do_1284_wait(bus, nACK, nACK)) { in ppb_1284_terminate()
847 ppb_1284_set_error(bus, PPB_TIMEOUT, 27); in ppb_1284_terminate()
851 ppb_wctr(bus, (nINIT | SELECTIN) & ~(STROBE | AUTOFEED)); in ppb_1284_terminate()
855 ppb_set_mode(bus, PPB_COMPATIBLE); in ppb_1284_terminate()
856 ppb_1284_set_state(bus, PPB_FORWARD_IDLE); in ppb_1284_terminate()