drivers/comedi/drivers/ni_mio_common.c
Source file repositories/reference/linux-study-clean/drivers/comedi/drivers/ni_mio_common.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/comedi/drivers/ni_mio_common.c- Extension
.c- Size
- 176215 bytes
- Lines
- 6363
- 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/interrupt.hlinux/sched.hlinux/delay.hlinux/comedi/comedi_8255.hmite.h
Detected Declarations
struct mio_regmapstruct caldac_structenum aimodesenum ni_common_subdevicesenum timebase_nanosecondsfunction ni_writelfunction ni_writewfunction ni_writebfunction ni_readlfunction ni_readwfunction ni_readbfunction ni_writelfunction ni_writewfunction ni_writebfunction ni_readlfunction ni_readwfunction ni_readbfunction m_series_stc_writefunction m_series_stc_readfunction ni_stc_writewfunction ni_stc_writelfunction ni_stc_readwfunction ni_stc_readlfunction ni_set_bitfieldfunction ni_request_ai_mite_channelfunction ni_request_ao_mite_channelfunction ni_request_gpct_mite_channelfunction ni_request_cdo_mite_channelfunction ni_release_ai_mite_channelfunction ni_release_ao_mite_channelfunction ni_release_gpct_mite_channelfunction ni_release_cdo_mite_channelfunction ni_e_series_enable_second_irqfunction ni_clear_ai_fifofunction ni_ao_win_outwfunction ni_ao_win_outlfunction ni_ao_win_inwfunction ni_set_bitsfunction ni_sync_ai_dmafunction ni_ai_drain_dmafunction ni_ao_wait_for_dma_loadfunction ni_ao_fifo_loadfunction ni_ao_fifo_half_emptyfunction ni_ao_prep_fifofunction ni_ai_fifo_readfunction ni_handle_fifo_half_fullfunction ni_handle_fifo_dregsfunction get_last_sample_611x
Annotated Snippet
struct mio_regmap {
unsigned int mio_reg;
int size;
};
static const struct mio_regmap m_series_stc_write_regmap[] = {
[NISTC_INTA_ACK_REG] = { 0x104, 2 },
[NISTC_INTB_ACK_REG] = { 0x106, 2 },
[NISTC_AI_CMD2_REG] = { 0x108, 2 },
[NISTC_AO_CMD2_REG] = { 0x10a, 2 },
[NISTC_G0_CMD_REG] = { 0x10c, 2 },
[NISTC_G1_CMD_REG] = { 0x10e, 2 },
[NISTC_AI_CMD1_REG] = { 0x110, 2 },
[NISTC_AO_CMD1_REG] = { 0x112, 2 },
/*
* NISTC_DIO_OUT_REG maps to:
* { NI_M_DIO_REG, 4 } and { NI_M_SCXI_SER_DO_REG, 1 }
*/
[NISTC_DIO_OUT_REG] = { 0, 0 }, /* DOES NOT MAP CLEANLY */
[NISTC_DIO_CTRL_REG] = { 0, 0 }, /* DOES NOT MAP CLEANLY */
[NISTC_AI_MODE1_REG] = { 0x118, 2 },
[NISTC_AI_MODE2_REG] = { 0x11a, 2 },
[NISTC_AI_SI_LOADA_REG] = { 0x11c, 4 },
[NISTC_AI_SI_LOADB_REG] = { 0x120, 4 },
[NISTC_AI_SC_LOADA_REG] = { 0x124, 4 },
[NISTC_AI_SC_LOADB_REG] = { 0x128, 4 },
[NISTC_AI_SI2_LOADA_REG] = { 0x12c, 4 },
[NISTC_AI_SI2_LOADB_REG] = { 0x130, 4 },
[NISTC_G0_MODE_REG] = { 0x134, 2 },
[NISTC_G1_MODE_REG] = { 0x136, 2 },
[NISTC_G0_LOADA_REG] = { 0x138, 4 },
[NISTC_G0_LOADB_REG] = { 0x13c, 4 },
[NISTC_G1_LOADA_REG] = { 0x140, 4 },
[NISTC_G1_LOADB_REG] = { 0x144, 4 },
[NISTC_G0_INPUT_SEL_REG] = { 0x148, 2 },
[NISTC_G1_INPUT_SEL_REG] = { 0x14a, 2 },
[NISTC_AO_MODE1_REG] = { 0x14c, 2 },
[NISTC_AO_MODE2_REG] = { 0x14e, 2 },
[NISTC_AO_UI_LOADA_REG] = { 0x150, 4 },
[NISTC_AO_UI_LOADB_REG] = { 0x154, 4 },
[NISTC_AO_BC_LOADA_REG] = { 0x158, 4 },
[NISTC_AO_BC_LOADB_REG] = { 0x15c, 4 },
[NISTC_AO_UC_LOADA_REG] = { 0x160, 4 },
[NISTC_AO_UC_LOADB_REG] = { 0x164, 4 },
[NISTC_CLK_FOUT_REG] = { 0x170, 2 },
[NISTC_IO_BIDIR_PIN_REG] = { 0x172, 2 },
[NISTC_RTSI_TRIG_DIR_REG] = { 0x174, 2 },
[NISTC_INT_CTRL_REG] = { 0x176, 2 },
[NISTC_AI_OUT_CTRL_REG] = { 0x178, 2 },
[NISTC_ATRIG_ETC_REG] = { 0x17a, 2 },
[NISTC_AI_START_STOP_REG] = { 0x17c, 2 },
[NISTC_AI_TRIG_SEL_REG] = { 0x17e, 2 },
[NISTC_AI_DIV_LOADA_REG] = { 0x180, 4 },
[NISTC_AO_START_SEL_REG] = { 0x184, 2 },
[NISTC_AO_TRIG_SEL_REG] = { 0x186, 2 },
[NISTC_G0_AUTOINC_REG] = { 0x188, 2 },
[NISTC_G1_AUTOINC_REG] = { 0x18a, 2 },
[NISTC_AO_MODE3_REG] = { 0x18c, 2 },
[NISTC_RESET_REG] = { 0x190, 2 },
[NISTC_INTA_ENA_REG] = { 0x192, 2 },
[NISTC_INTA2_ENA_REG] = { 0, 0 }, /* E-Series only */
[NISTC_INTB_ENA_REG] = { 0x196, 2 },
[NISTC_INTB2_ENA_REG] = { 0, 0 }, /* E-Series only */
[NISTC_AI_PERSONAL_REG] = { 0x19a, 2 },
[NISTC_AO_PERSONAL_REG] = { 0x19c, 2 },
[NISTC_RTSI_TRIGA_OUT_REG] = { 0x19e, 2 },
[NISTC_RTSI_TRIGB_OUT_REG] = { 0x1a0, 2 },
/* doc for following line: mhddk/nimseries/ChipObjects/tMSeries.h */
[NISTC_RTSI_BOARD_REG] = { 0x1a2, 2 },
[NISTC_CFG_MEM_CLR_REG] = { 0x1a4, 2 },
[NISTC_ADC_FIFO_CLR_REG] = { 0x1a6, 2 },
[NISTC_DAC_FIFO_CLR_REG] = { 0x1a8, 2 },
[NISTC_AO_OUT_CTRL_REG] = { 0x1ac, 2 },
[NISTC_AI_MODE3_REG] = { 0x1ae, 2 },
};
static void m_series_stc_write(struct comedi_device *dev,
unsigned int data, unsigned int reg)
{
const struct mio_regmap *regmap;
if (reg < ARRAY_SIZE(m_series_stc_write_regmap)) {
regmap = &m_series_stc_write_regmap[reg];
} else {
dev_warn(dev->class_dev, "%s: unhandled register=0x%x\n",
__func__, reg);
return;
}
switch (regmap->size) {
Annotation
- Immediate include surface: `linux/interrupt.h`, `linux/sched.h`, `linux/delay.h`, `linux/comedi/comedi_8255.h`, `mite.h`.
- Detected declarations: `struct mio_regmap`, `struct caldac_struct`, `enum aimodes`, `enum ni_common_subdevices`, `enum timebase_nanoseconds`, `function ni_writel`, `function ni_writew`, `function ni_writeb`, `function ni_readl`, `function ni_readw`.
- 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.