Lines Matching +full:no +full:- +full:poll +full:- +full:on +full:- +full:init

1 // SPDX-License-Identifier: GPL-2.0
3 * Device driver for the via ADB on (many) Mac II-class machines
5 * Based on the original ADB keyboard handler Copyright (c) 1997 Alan Cox
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/
32 #include <linux/init.h>
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 */
64 #define SR_EXT 0x0c /* Shift on external clock */
100 .init = macii_init,
103 .poll = macii_poll,
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 */
121 static bool bus_timeout; /* no data was sent by the device */
122 static bool srq_asserted; /* have to poll for the device that asserted it */
126 static unsigned int autopoll_devs; /* bits set are device addresses to poll */
131 if (macintosh_config->adb_type != MAC_ADB_II) in macii_probe()
132 return -ENODEV; in macii_probe()
169 /* Shift register on input */ in macii_init_via()
178 /* Send an ADB poll (Talk Register 0 command prepended to the request queue) */
193 /* The device most recently polled may not be the best device to poll in macii_queue_poll()
203 higher_devs = autopoll_devs & -(1 << (poll_addr + 1)); in macii_queue_poll()
204 poll_addr = ffs(higher_devs ? higher_devs : autopoll_devs) - 1; in macii_queue_poll()
210 /* No need to repeat this Talk command. The transceiver will do that in macii_queue_poll()
231 /* Send an ADB request; if sync, poll out the reply 'till it's done */
241 while (!req->complete) in macii_send_request()
252 if (req->nbytes < 2 || req->data[0] != ADB_PACKET || req->nbytes > 15) { in macii_write()
253 req->complete = 1; in macii_write()
254 return -EINVAL; in macii_write()
257 req->next = NULL; in macii_write()
258 req->sent = 0; in macii_write()
259 req->complete = 0; in macii_write()
260 req->reply_len = 0; in macii_write()
265 last_req->next = req; in macii_write()
279 /* Start auto-polling */
286 /* bit 1 == device 1, and so on. */ in macii_autopoll()
330 * And req->nbytes is the number of bytes of real data plus one. in macii_start()
336 via[SR] = req->data[1]; in macii_start()
348 * The notorious ADB interrupt handler - does all of the protocol handling.
349 * Relies on the ADB controller sending and receiving data, thereby
351 * to be activity on the ADB bus. The chip will poll to achieve this.
354 * sees a transition on the PB4 and PB5 lines it will crank over the VIA shift
358 * Request with no reply expected (and empty transceiver buffer):
359 * CMD -> IDLE
361 * CMD -> EVEN -> ODD -> EVEN -> ... -> IDLE
363 * IDLE -> EVEN -> ODD -> EVEN -> ... -> IDLE
418 /* /CTLR_IRQ de-asserted after the command byte means in macii_interrupt()
423 last_cmd = req->data[1]; in macii_interrupt()
446 } else if (data_index >= req->nbytes) { in macii_interrupt()
447 req->sent = 1; in macii_interrupt()
449 if (req->reply_expected) { in macii_interrupt()
453 reply_ptr = req->reply; in macii_interrupt()
454 *reply_ptr = req->data[1]; in macii_interrupt()
459 } else if ((req->data[1] & OP_MASK) == TALK) { in macii_interrupt()
464 *reply_ptr = req->data[1]; in macii_interrupt()
470 req->complete = 1; in macii_interrupt()
471 current_req = req->next; in macii_interrupt()
472 if (req->done) in macii_interrupt()
473 (*req->done)(req); in macii_interrupt()
477 req->complete = 1; in macii_interrupt()
478 current_req = req->next; in macii_interrupt()
479 if (req->done) in macii_interrupt()
480 (*req->done)(req); in macii_interrupt()
484 via[SR] = req->data[data_index++]; in macii_interrupt()
515 req->reply_len = reply_len; in macii_interrupt()
517 req->complete = 1; in macii_interrupt()
518 current_req = req->next; in macii_interrupt()
519 if (req->done) in macii_interrupt()
520 (*req->done)(req); in macii_interrupt()