27 #include <linux/types.h>
28 #include <linux/errno.h>
29 #include <linux/kernel.h>
31 #include <linux/adb.h>
38 static volatile unsigned char *via;
79 static int macii_init_via(
void);
80 static void macii_start(
void);
82 static void macii_queue_poll(
void);
84 static int macii_probe(
void);
85 static int macii_init(
void);
88 static int macii_autopoll(
int devs);
89 static void macii_poll(
void);
90 static int macii_reset_bus(
void);
112 static unsigned char *reply_ptr;
113 static int reading_reply;
114 static int data_index;
117 static int last_status;
118 static int srq_asserted;
119 static int command_byte;
120 static int autopoll_devs;
140 static int macii_probe(
void)
146 printk(
"adb: Mac II ADB Driver v1.0 for Unified ADB\n");
158 err = macii_init_via();
172 static int macii_init_via(
void)
193 static void macii_queue_poll(
void)
207 if (!autopoll_devs)
return;
209 device_mask = (1 << (((command_byte & 0xF0) >> 4) + 1)) - 1;
210 if (autopoll_devs & ~device_mask)
211 next_device =
ffs(autopoll_devs & ~device_mask) - 1;
213 next_device =
ffs(autopoll_devs) - 1;
225 if (current_req !=
NULL) {
239 BUG_ON(request_is_queued(req));
242 err = macii_write(req);
249 BUG_ON(request_is_queued(req));
268 if (current_req !=
NULL) {
280 static int macii_autopoll(
int devs)
287 autopoll_devs = devs & 0xFFFE;
289 if (!autopoll_devs)
return 0;
293 if (current_req ==
NULL) {
299 err = macii_write(&req);
306 static inline int need_autopoll(
void) {
310 if ((command_byte & 0x0F) == 0x0C &&
311 ((1 << ((command_byte & 0xF0) >> 4)) & autopoll_devs))
317 static void macii_poll(
void)
320 macii_interrupt(0,
NULL);
325 static int macii_reset_bus(
void)
329 if (request_is_queued(&req))
342 static void macii_start(
void)
358 command_byte = req->
data[1];
408 reply_ptr = current_req->
reply;
435 if (data_index >= req->
nbytes) {
443 current_req = req->
next;
450 macii_autopoll(autopoll_devs);
461 via[
SR] = req->
data[data_index++];
489 if (!(
status & CTLR_IRQ)) {
491 if (!(last_status & CTLR_IRQ)) {
496 }
else if (x == 0x00) {
498 if (!(last_status & CTLR_IRQ))
522 current_req = req->
next;
537 macii_autopoll(autopoll_devs);