drivers/comedi/drivers/pcmuio.c
Source file repositories/reference/linux-study-clean/drivers/comedi/drivers/pcmuio.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/comedi/drivers/pcmuio.c- Extension
.c- Size
- 18573 bytes
- Lines
- 625
- Domain
- Driver Families
- Bucket
- drivers/comedi
- 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/module.hlinux/interrupt.hlinux/comedi/comedidev.h
Detected Declarations
struct pcmuio_boardstruct pcmuio_asicstruct pcmuio_privatefunction pcmuio_asic_iobasefunction pcmuio_subdevice_to_asicfunction pcmuio_subdevice_to_portfunction pcmuio_writefunction pcmuio_readfunction currentfunction pcmuio_dio_insn_configfunction pcmuio_resetfunction pcmuio_stop_intrfunction pcmuio_handle_intr_subdevfunction pcmuio_handle_asic_interruptfunction pcmuio_interruptfunction pcmuio_start_intrfunction pcmuio_cancelfunction pcmuio_inttrig_start_intrfunction pcmuio_cmdfunction pcmuio_cmdtestfunction pcmuio_attachfunction pcmuio_detach
Annotated Snippet
struct pcmuio_board {
const char *name;
const int num_asics;
};
static const struct pcmuio_board pcmuio_boards[] = {
{
.name = "pcmuio48",
.num_asics = 1,
}, {
.name = "pcmuio96",
.num_asics = 2,
},
};
struct pcmuio_asic {
spinlock_t pagelock; /* protects the page registers */
spinlock_t spinlock; /* protects member variables */
unsigned int enabled_mask;
unsigned int active:1;
};
struct pcmuio_private {
struct pcmuio_asic asics[PCMUIO_MAX_ASICS];
unsigned int irq2;
};
static inline unsigned long pcmuio_asic_iobase(struct comedi_device *dev,
int asic)
{
return dev->iobase + (asic * PCMUIO_ASIC_IOSIZE);
}
static inline int pcmuio_subdevice_to_asic(struct comedi_subdevice *s)
{
/*
* subdevice 0 and 1 are handled by the first asic
* subdevice 2 and 3 are handled by the second asic
*/
return s->index / 2;
}
static inline int pcmuio_subdevice_to_port(struct comedi_subdevice *s)
{
/*
* subdevice 0 and 2 use port registers 0-2
* subdevice 1 and 3 use port registers 3-5
*/
return (s->index % 2) ? 3 : 0;
}
static void pcmuio_write(struct comedi_device *dev, unsigned int val,
int asic, int page, int port)
{
struct pcmuio_private *devpriv = dev->private;
struct pcmuio_asic *chip = &devpriv->asics[asic];
unsigned long iobase = pcmuio_asic_iobase(dev, asic);
unsigned long flags;
spin_lock_irqsave(&chip->pagelock, flags);
if (page == 0) {
/* Port registers are valid for any page */
outb(val & 0xff, iobase + PCMUIO_PORT_REG(port + 0));
outb((val >> 8) & 0xff, iobase + PCMUIO_PORT_REG(port + 1));
outb((val >> 16) & 0xff, iobase + PCMUIO_PORT_REG(port + 2));
} else {
outb(PCMUIO_PAGE(page), iobase + PCMUIO_PAGE_LOCK_REG);
outb(val & 0xff, iobase + PCMUIO_PAGE_REG(0));
outb((val >> 8) & 0xff, iobase + PCMUIO_PAGE_REG(1));
outb((val >> 16) & 0xff, iobase + PCMUIO_PAGE_REG(2));
}
spin_unlock_irqrestore(&chip->pagelock, flags);
}
static unsigned int pcmuio_read(struct comedi_device *dev,
int asic, int page, int port)
{
struct pcmuio_private *devpriv = dev->private;
struct pcmuio_asic *chip = &devpriv->asics[asic];
unsigned long iobase = pcmuio_asic_iobase(dev, asic);
unsigned long flags;
unsigned int val;
spin_lock_irqsave(&chip->pagelock, flags);
if (page == 0) {
/* Port registers are valid for any page */
val = inb(iobase + PCMUIO_PORT_REG(port + 0));
val |= (inb(iobase + PCMUIO_PORT_REG(port + 1)) << 8);
val |= (inb(iobase + PCMUIO_PORT_REG(port + 2)) << 16);
} else {
Annotation
- Immediate include surface: `linux/module.h`, `linux/interrupt.h`, `linux/comedi/comedidev.h`.
- Detected declarations: `struct pcmuio_board`, `struct pcmuio_asic`, `struct pcmuio_private`, `function pcmuio_asic_iobase`, `function pcmuio_subdevice_to_asic`, `function pcmuio_subdevice_to_port`, `function pcmuio_write`, `function pcmuio_read`, `function current`, `function pcmuio_dio_insn_config`.
- Atlas domain: Driver Families / drivers/comedi.
- 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.