Lines Matching +full:reset +full:- +full:pin +full:- +full:assert +full:- +full:time +full:- +full:ms

1 // SPDX-License-Identifier: GPL-2.0
7 * This MCU controls system power, Parameter RAM, Real Time Clock and the
35 /* VIA registers - spaced 0x200 bytes apart */
37 #define B 0 /* B-side data */
38 #define A RS /* A-side data */
39 #define DIRB (2*RS) /* B-side direction (1=output) */
40 #define DIRA (3*RS) /* A-side direction (1=output) */
52 #define ANH (15*RS) /* A-side data, no handshake */
58 * VIA pin | Egret pin
59 * ----------------+------------------------------------------
64 * VIA pin | Cuda pin
65 * ----------------+------------------------------------------
209 if (macintosh_config->adb_type != MAC_ADB_CUDA && in find_via_cuda()
210 macintosh_config->adb_type != MAC_ADB_EGRET) in find_via_cuda()
215 mcu_is_egret = macintosh_config->adb_type == MAC_ADB_EGRET; in find_via_cuda()
241 vias = of_find_node_by_name(NULL, "via-cuda"); in find_via_cuda()
247 printk(KERN_ERR "via-cuda: No \"reg\" property !\n"); in find_via_cuda()
252 printk(KERN_ERR "via-cuda: Can't translate address !\n"); in find_via_cuda()
257 printk(KERN_ERR "via-cuda: Can't map address !\n"); in find_via_cuda()
294 return -ENODEV; in via_cuda_start()
301 printk(KERN_ERR "via-cuda: can't map interrupts for %pOF\n", in via_cuda_start()
303 return -ENODEV; in via_cuda_start()
308 printk(KERN_ERR "via-cuda: can't request irq %d\n", cuda_irq); in via_cuda_start()
309 return -EAGAIN; in via_cuda_start()
326 return -ENODEV; in cuda_probe()
328 if (macintosh_config->adb_type != MAC_ADB_CUDA && in cuda_probe()
329 macintosh_config->adb_type != MAC_ADB_EGRET) in cuda_probe()
330 return -ENODEV; in cuda_probe()
333 return -ENODEV; in cuda_probe()
368 for (x = 1000; !(cond); --x) { \
371 return -ENXIO; \
389 (void)in_8(&via[SR]); /* clear any left-over data */ in cuda_init_via()
396 /* delay 4ms and then clear any pending interrupt */ in cuda_init_via()
401 /* sync with the CUDA - assert TACK without TIP */ in cuda_init_via()
404 /* wait for the CUDA to assert TREQ in response */ in cuda_init_via()
432 req->complete = 1; in cuda_send_request()
433 return -ENXIO; in cuda_send_request()
436 req->reply_expected = 1; in cuda_send_request()
443 while (!req->complete) in cuda_send_request()
457 return -ENXIO; in cuda_adb_autopoll()
465 /* Reset adb bus - how do we do this?? */
472 return -ENXIO; in cuda_reset_adb_bus()
490 req->complete = 1; in cuda_request()
491 return -ENXIO; in cuda_request()
494 req->nbytes = nbytes; in cuda_request()
495 req->done = done; in cuda_request()
498 req->data[i] = va_arg(list, int); in cuda_request()
500 req->reply_expected = 1; in cuda_request()
510 if (req->nbytes < 2 || req->data[0] > CUDA_PACKET) { in cuda_write()
511 req->complete = 1; in cuda_write()
512 return -EINVAL; in cuda_write()
514 req->next = NULL; in cuda_write()
515 req->sent = 0; in cuda_write()
516 req->complete = 0; in cuda_write()
517 req->reply_len = 0; in cuda_write()
521 last_req->next = req; in cuda_write()
537 /* assert cuda_state == idle */ in cuda_start()
546 out_8(&via[SR], current_req->data[data_index++]); in cuda_start()
561 #define ARRAY_FULL(a, p) ((p) - (a) == ARRAY_SIZE(a))
577 * just the shift register IRQ -- other VIA interrupt sources are disabled. in cuda_interrupt()
612 reply_ptr = current_req->reply; in cuda_interrupt()
627 out_8(&via[SR], current_req->data[data_index++]); in cuda_interrupt()
637 if (data_index >= req->nbytes) { in cuda_interrupt()
641 req->sent = 1; in cuda_interrupt()
642 if (req->reply_expected) { in cuda_interrupt()
645 current_req = req->next; in cuda_interrupt()
652 out_8(&via[SR], req->data[data_index++]); in cuda_interrupt()
660 full = reading_reply ? ARRAY_FULL(current_req->reply, reply_ptr) in cuda_interrupt()
687 req->reply_len = reply_ptr - req->reply; in cuda_interrupt()
688 if (req->data[0] == ADB_PACKET) { in cuda_interrupt()
690 if (req->reply_len <= 2 || (req->reply[1] & 2) != 0) { in cuda_interrupt()
692 req->reply_len = 0; in cuda_interrupt()
695 req->reply_len -= 2; in cuda_interrupt()
696 memmove(req->reply, req->reply + 2, req->reply_len); in cuda_interrupt()
699 current_req = req->next; in cuda_interrupt()
705 * re-entered from another CPU getting an interrupt in cuda_interrupt()
710 ibuf_len = reply_ptr - cuda_rbuf; in cuda_interrupt()
727 void (*done)(struct adb_request *) = req->done; in cuda_interrupt()
729 req->complete = 1; in cuda_interrupt()
731 * struct request will survive to setting req->complete to 1 in cuda_interrupt()
756 adb_input(buf+2, nb-2, buf[1] & 0x40); in cuda_input()
772 /* Offset between Unix time (1970-based) and Mac time (1904-based) */
788 return (time64_t)now - RTC_OFFSET; in cuda_get_time()
799 return -ENXIO; in cuda_set_rtc_time()