12 #include <linux/types.h>
13 #include <linux/errno.h>
14 #include <linux/kernel.h>
16 #include <linux/adb.h>
17 #include <linux/cuda.h>
22 #include <asm/machdep.h>
31 static volatile unsigned char __iomem *via;
79 static unsigned char cuda_rbuf[16];
80 static unsigned char *reply_ptr;
81 static int reading_reply;
82 static int data_index;
87 static int cuda_fully_inited;
90 static int cuda_probe(
void);
92 static int cuda_adb_autopoll(
int devs);
93 static int cuda_reset_adb_bus(
void);
96 static int cuda_init_via(
void);
97 static void cuda_start(
void);
99 static void cuda_input(
unsigned char *
buf,
int nb);
110 .send_request = cuda_send_request,
111 .autopoll = cuda_adb_autopoll,
113 .reset_bus = cuda_reset_adb_bus,
129 err = cuda_init_via();
176 err = cuda_init_via();
203 static int __init via_cuda_start(
void)
219 if (
request_irq(cuda_irq, cuda_interrupt, 0,
"ADB", cuda_interrupt)) {
224 printk(
"Macintosh CUDA driver v0.5 for Unified ADB.\n");
226 cuda_fully_inited = 1;
249 #define WAIT_FOR(cond, what) \
252 for (x = 1000; !(cond); --x) { \
254 printk("Timeout waiting for " what "\n"); \
289 out_8(&via[IFR], SR_INT);
295 WAIT_FOR(
in_8(&via[B]) & TREQ,
"CUDA response to sync (3)");
296 WAIT_FOR(
in_8(&via[IFR]) & SR_INT,
"CUDA response to sync (4)");
298 out_8(&via[IFR], SR_INT);
311 if ((via ==
NULL) || !cuda_fully_inited) {
332 cuda_adb_autopoll(
int devs)
336 if ((via ==
NULL) || !cuda_fully_inited)
347 cuda_reset_adb_bus(
void)
351 if ((via ==
NULL) || !cuda_fully_inited)
380 return cuda_write(req);
398 if (current_req != 0) {
407 spin_unlock_irqrestore(&cuda_lock, flags);
440 cuda_interrupt(0,
NULL);
446 cuda_interrupt(
int irq,
void *
arg)
450 unsigned char ibuf[16];
454 spin_lock(&cuda_lock);
467 spin_unlock(&cuda_lock);
470 out_8(&via[IFR], SR_INT);
480 printk(
"cuda: state=idle, status=%x\n", status);
484 reply_ptr = cuda_rbuf;
491 printk(
"cuda: state=awaiting_reply, status=%x\n", status);
495 reply_ptr = current_req->
reply;
509 printk(
"cuda: state=sent_first_byte status=%x\n", status);
519 if (data_index >= req->
nbytes) {
527 current_req = req->
next;
534 out_8(&via[SR], req->
data[data_index++]);
540 *reply_ptr++ =
in_8(&via[SR]);
547 if (status !=
TIP + TREQ)
548 printk(
"cuda: state=reading status=%x\n", status);
569 current_req = req->
next;
579 ibuf_len = reply_ptr - cuda_rbuf;
580 memcpy(ibuf, cuda_rbuf, ibuf_len);
582 if (status == TREQ) {
585 reply_ptr = cuda_rbuf;
596 spin_unlock(&cuda_lock);
597 if (complete && req) {
608 cuda_input(ibuf, ibuf_len);
613 cuda_input(
unsigned char *
buf,
int nb)
620 if (nb == 5 && buf[2] == 0x2c) {
622 if (xmon_wants_key) {
623 xmon_adb_keycode = buf[3];
634 printk(
"data from cuda (%d bytes):", nb);
635 for (i = 0; i < nb; ++
i)