drivers/macintosh/via-cuda.c
Source file repositories/reference/linux-study-clean/drivers/macintosh/via-cuda.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/macintosh/via-cuda.c- Extension
.c- Size
- 19635 bytes
- Lines
- 803
- Domain
- Driver Families
- Bucket
- drivers/macintosh
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/stdarg.hlinux/types.hlinux/errno.hlinux/kernel.hlinux/delay.hlinux/adb.hlinux/cuda.hlinux/spinlock.hlinux/interrupt.hlinux/of_address.hlinux/of_irq.hasm/machdep.hasm/pmac_feature.hasm/macintosh.hasm/macints.hasm/mac_via.hasm/io.hlinux/init.h
Detected Declarations
function TREQ_assertedfunction assert_TIPfunction assert_TIP_and_TACKfunction assert_TACKfunction toggle_TACKfunction negate_TACKfunction negate_TIP_and_TACKfunction find_via_cudafunction find_via_cudafunction via_cuda_startfunction cuda_probefunction sync_egretfunction cuda_init_viafunction cuda_send_requestfunction cuda_adb_autopollfunction cuda_reset_adb_busfunction cuda_requestfunction cuda_writefunction cuda_startfunction cuda_pollfunction cuda_interruptfunction cuda_inputfunction cuda_get_timefunction cuda_set_rtc_timemodule init via_cuda_startexport cuda_requestexport cuda_poll
Annotated Snippet
device_initcall(via_cuda_start);
#ifdef CONFIG_ADB
static int
cuda_probe(void)
{
#ifdef CONFIG_PPC
if (sys_ctrler != SYS_CTRLER_CUDA)
return -ENODEV;
#else
if (macintosh_config->adb_type != MAC_ADB_CUDA &&
macintosh_config->adb_type != MAC_ADB_EGRET)
return -ENODEV;
#endif
if (via == NULL)
return -ENODEV;
return 0;
}
#endif /* CONFIG_ADB */
static int __init sync_egret(void)
{
if (TREQ_asserted(in_8(&via[B]))) {
/* Complete the inbound transfer */
assert_TIP_and_TACK();
while (1) {
negate_TACK();
mdelay(1);
(void)in_8(&via[SR]);
assert_TACK();
if (!TREQ_asserted(in_8(&via[B])))
break;
}
negate_TIP_and_TACK();
} else if (in_8(&via[B]) & TIP) {
/* Terminate the outbound transfer */
negate_TACK();
assert_TACK();
mdelay(1);
negate_TIP_and_TACK();
}
/* Clear shift register interrupt */
if (in_8(&via[IFR]) & SR_INT)
(void)in_8(&via[SR]);
return 0;
}
#define WAIT_FOR(cond, what) \
do { \
int x; \
for (x = 1000; !(cond); --x) { \
if (x == 0) { \
pr_err("Timeout waiting for " what "\n"); \
return -ENXIO; \
} \
udelay(100); \
} \
} while (0)
static int
__init cuda_init_via(void)
{
#ifdef CONFIG_PPC
out_8(&via[IER], 0x7f); /* disable interrupts from VIA */
(void)in_8(&via[IER]);
#else
out_8(&via[IER], SR_INT); /* disable SR interrupt from VIA */
#endif
out_8(&via[DIRB], (in_8(&via[DIRB]) | TACK | TIP) & ~TREQ); /* TACK & TIP out */
out_8(&via[ACR], (in_8(&via[ACR]) & ~SR_CTRL) | SR_EXT); /* SR data in */
(void)in_8(&via[SR]); /* clear any left-over data */
if (mcu_is_egret)
return sync_egret();
negate_TIP_and_TACK();
/* delay 4ms and then clear any pending interrupt */
mdelay(4);
(void)in_8(&via[SR]);
out_8(&via[IFR], SR_INT);
/* sync with the CUDA - assert TACK without TIP */
assert_TACK();
/* wait for the CUDA to assert TREQ in response */
WAIT_FOR(TREQ_asserted(in_8(&via[B])), "CUDA response to sync");
/* wait for the interrupt and then clear it */
Annotation
- Immediate include surface: `linux/stdarg.h`, `linux/types.h`, `linux/errno.h`, `linux/kernel.h`, `linux/delay.h`, `linux/adb.h`, `linux/cuda.h`, `linux/spinlock.h`.
- Detected declarations: `function TREQ_asserted`, `function assert_TIP`, `function assert_TIP_and_TACK`, `function assert_TACK`, `function toggle_TACK`, `function negate_TACK`, `function negate_TIP_and_TACK`, `function find_via_cuda`, `function find_via_cuda`, `function via_cuda_start`.
- Atlas domain: Driver Families / drivers/macintosh.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.