Lines Matching +full:lines +full:- +full:initial +full:- +full:states

1 // SPDX-License-Identifier: GPL-2.0
3 * Device driver for the via ADB on (many) Mac II-class machines
13 * 1999-08-02 (jmt) - Initial rewrite for Unified ADB.
14 * 2000-03-29 Tony Mantler <tonym@mac.linux-m68k.org>
15 * - Big overhaul, should actually work now.
16 * 2006-12-31 Finn Thain - Another overhaul.
24 * ftp://ftp.apple.com/developer/Tool_Chest/Devices_-_Hardware/Apple_Desktop_Bus/
39 /* VIA registers - spaced 0x200 bytes apart */
41 #define B 0 /* B-side data */
42 #define A RS /* A-side data */
43 #define DIRB (2*RS) /* B-side direction (1=output) */
44 #define DIRA (3*RS) /* A-side direction (1=output) */
56 #define ANH (15*RS) /* A-side data, no handshake */
72 /* ADB transaction states according to GMHW */
116 static unsigned char *reply_ptr; /* next byte in reply_buf or req->reply */
117 static bool reading_reply; /* store reply in reply_buf else req->reply */
118 static int data_index; /* index of the next byte to send from req->data */
119 static int reply_len; /* number of bytes received in reply_buf or req->reply */
131 if (macintosh_config->adb_type != MAC_ADB_II) in macii_probe()
132 return -ENODEV; in macii_probe()
168 /* We want CTLR_IRQ as input and ST_EVEN | ST_ODD as output lines. */ in macii_init_via()
208 higher_devs = autopoll_devs & -(1 << (poll_addr + 1)); in macii_queue_poll()
209 poll_addr = ffs(higher_devs ? higher_devs : autopoll_devs) - 1; in macii_queue_poll()
246 while (!req->complete) in macii_send_request()
257 if (req->nbytes < 2 || req->data[0] != ADB_PACKET || req->nbytes > 15) { in macii_write()
258 req->complete = 1; in macii_write()
259 return -EINVAL; in macii_write()
262 req->next = NULL; in macii_write()
263 req->sent = 0; in macii_write()
264 req->complete = 0; in macii_write()
265 req->reply_len = 0; in macii_write()
270 last_req->next = req; in macii_write()
284 /* Start auto-polling */
335 * And req->nbytes is the number of bytes of real data plus one. in macii_start()
341 via[SR] = req->data[1]; in macii_start()
353 * The notorious ADB interrupt handler - does all of the protocol handling.
359 * sees a transition on the PB4 and PB5 lines it will crank over the VIA shift
364 * CMD -> IDLE
366 * CMD -> EVEN -> ODD -> EVEN -> ... -> IDLE
368 * IDLE -> EVEN -> ODD -> EVEN -> ... -> IDLE
423 /* /CTLR_IRQ de-asserted after the command byte means in macii_interrupt()
428 last_cmd = req->data[1]; in macii_interrupt()
451 } else if (data_index >= req->nbytes) { in macii_interrupt()
452 req->sent = 1; in macii_interrupt()
454 if (req->reply_expected) { in macii_interrupt()
458 reply_ptr = req->reply; in macii_interrupt()
459 *reply_ptr = req->data[1]; in macii_interrupt()
464 } else if ((req->data[1] & OP_MASK) == TALK) { in macii_interrupt()
469 *reply_ptr = req->data[1]; in macii_interrupt()
475 req->complete = 1; in macii_interrupt()
476 current_req = req->next; in macii_interrupt()
477 if (req->done) in macii_interrupt()
478 (*req->done)(req); in macii_interrupt()
482 req->complete = 1; in macii_interrupt()
483 current_req = req->next; in macii_interrupt()
484 if (req->done) in macii_interrupt()
485 (*req->done)(req); in macii_interrupt()
489 via[SR] = req->data[data_index++]; in macii_interrupt()
520 req->reply_len = reply_len; in macii_interrupt()
522 req->complete = 1; in macii_interrupt()
523 current_req = req->next; in macii_interrupt()
524 if (req->done) in macii_interrupt()
525 (*req->done)(req); in macii_interrupt()