drivers/macintosh/macio-adb.c
Source file repositories/reference/linux-study-clean/drivers/macintosh/macio-adb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/macintosh/macio-adb.c- Extension
.c- Size
- 6741 bytes
- Lines
- 289
- Domain
- Driver Families
- Bucket
- drivers/macintosh
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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/types.hlinux/errno.hlinux/kernel.hlinux/delay.hlinux/spinlock.hlinux/interrupt.hlinux/pgtable.hlinux/of.hlinux/of_address.hlinux/of_irq.hlinux/adb.hasm/io.hasm/hydra.hasm/irq.hlinux/init.hlinux/ioport.h
Detected Declarations
struct pregstruct adb_regsfunction macio_probefunction macio_initfunction macio_adb_autopollfunction macio_adb_reset_busfunction macio_send_requestfunction macio_adb_interruptfunction macio_adb_poll
Annotated Snippet
struct preg {
unsigned char r;
char pad[15];
};
struct adb_regs {
struct preg intr;
struct preg data[9];
struct preg intr_enb;
struct preg dcount;
struct preg error;
struct preg ctrl;
struct preg autopoll;
struct preg active_hi;
struct preg active_lo;
struct preg test;
};
/* Bits in intr and intr_enb registers */
#define DFB 1 /* data from bus */
#define TAG 2 /* transfer access grant */
/* Bits in dcount register */
#define HMB 0x0f /* how many bytes */
#define APD 0x10 /* auto-poll data */
/* Bits in error register */
#define NRE 1 /* no response error */
#define DLE 2 /* data lost error */
/* Bits in ctrl register */
#define TAR 1 /* transfer access request */
#define DTB 2 /* data to bus */
#define CRE 4 /* command response expected */
#define ADB_RST 8 /* ADB reset */
/* Bits in autopoll register */
#define APE 1 /* autopoll enable */
static volatile struct adb_regs __iomem *adb;
static struct adb_request *current_req, *last_req;
static DEFINE_SPINLOCK(macio_lock);
static int macio_probe(void);
static int macio_init(void);
static irqreturn_t macio_adb_interrupt(int irq, void *arg);
static int macio_send_request(struct adb_request *req, int sync);
static int macio_adb_autopoll(int devs);
static void macio_adb_poll(void);
static int macio_adb_reset_bus(void);
struct adb_driver macio_adb_driver = {
.name = "MACIO",
.probe = macio_probe,
.init = macio_init,
.send_request = macio_send_request,
.autopoll = macio_adb_autopoll,
.poll = macio_adb_poll,
.reset_bus = macio_adb_reset_bus,
};
int macio_probe(void)
{
struct device_node *np __free(device_node) =
of_find_compatible_node(NULL, "adb", "chrp,adb0");
if (np)
return 0;
return -ENODEV;
}
int macio_init(void)
{
struct device_node *adbs __free(device_node) =
of_find_compatible_node(NULL, "adb", "chrp,adb0");
struct resource r;
unsigned int irq;
if (!adbs)
return -ENXIO;
if (of_address_to_resource(adbs, 0, &r))
return -ENXIO;
adb = ioremap(r.start, sizeof(struct adb_regs));
if (!adb)
return -ENOMEM;
Annotation
- Immediate include surface: `linux/types.h`, `linux/errno.h`, `linux/kernel.h`, `linux/delay.h`, `linux/spinlock.h`, `linux/interrupt.h`, `linux/pgtable.h`, `linux/of.h`.
- Detected declarations: `struct preg`, `struct adb_regs`, `function macio_probe`, `function macio_init`, `function macio_adb_autopoll`, `function macio_adb_reset_bus`, `function macio_send_request`, `function macio_adb_interrupt`, `function macio_adb_poll`.
- Atlas domain: Driver Families / drivers/macintosh.
- Implementation status: source 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.