drivers/comedi/drivers/ni_tio.c
Source file repositories/reference/linux-study-clean/drivers/comedi/drivers/ni_tio.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/comedi/drivers/ni_tio.c- Extension
.c- Size
- 51290 bytes
- Lines
- 1831
- Domain
- Driver Families
- Bucket
- drivers/comedi
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/slab.hni_tio_internal.h
Detected Declarations
function Copyrightfunction GI_PRESCALE_X8function ni_tio_has_gate2_registersfunction ni_tio_writefunction ni_tio_readfunction ni_tio_reset_count_and_disarmfunction ni_tio_clock_period_psfunction ni_tio_set_bits_transientfunction ni_tio_set_bitsfunction ni_tio_get_soft_copyfunction ni_tio_clock_src_modifiersfunction ni_m_series_clock_src_selectfunction ni_660x_clock_src_selectfunction ni_tio_generic_clock_src_selectfunction ni_tio_set_sync_modefunction ni_tio_set_counter_modefunction ni_tio_armfunction ni_660x_clk_srcfunction ni_m_clk_srcfunction ni_tio_set_source_subselectfunction ni_tio_set_clock_srcfunction ni_tio_get_clock_srcfunction ni_tio_set_gate_rawfunction ni_tio_set_gate2_rawfunction ni_tio_set_gate_modefunction ni_tio_set_gate2_modefunction ni_660x_set_gatefunction ni_m_set_gatefunction ni_660x_set_gate2function ni_m_set_gate2function ni_tio_set_gate_src_rawfunction ni_tio_set_gate_srcfunction ni_tio_set_other_srcfunction ni_tio_get_other_srcfunction ni_660x_gate_to_generic_gatefunction ni_m_gate_to_generic_gatefunction ni_660x_gate2_to_generic_gatefunction ni_m_gate2_to_generic_gatefunction ni_tio_get_gate_modefunction ni_tio_get_gate2_modefunction ni_tio_get_gate_valfunction ni_tio_get_gate2_valfunction ni_tio_get_gate_srcfunction ni_tio_get_gate_src_rawfunction ni_tio_insn_configfunction ni_tio_get_routingfunction ni_tio_set_routingfunction ni_tio_unset_routing
Annotated Snippet
if (src == NI_M_RTSI_CLK(i)) {
clock_source = NI_GPCT_RTSI_CLOCK_SRC_BITS(i);
break;
}
}
if (i <= NI_M_MAX_RTSI_CHAN)
break;
for (i = 0; i <= NI_M_MAX_PFI_CHAN; ++i) {
if (src == NI_M_PFI_CLK(i)) {
clock_source = NI_GPCT_PFI_CLOCK_SRC_BITS(i);
break;
}
}
if (i <= NI_M_MAX_PFI_CHAN)
break;
return -EINVAL;
}
clock_source |= ni_tio_clock_src_modifiers(counter);
*clk_src = clock_source;
return 0;
}
static int ni_660x_clock_src_select(const struct ni_gpct *counter,
unsigned int *clk_src)
{
unsigned int clock_source = 0;
unsigned int cidx = counter->counter_index;
unsigned int src;
unsigned int i;
src = GI_BITS_TO_SRC(ni_tio_get_soft_copy(counter,
NITIO_INPUT_SEL_REG(cidx)));
switch (src) {
case NI_660X_TIMEBASE_1_CLK:
clock_source = NI_GPCT_TIMEBASE_1_CLOCK_SRC_BITS;
break;
case NI_660X_TIMEBASE_2_CLK:
clock_source = NI_GPCT_TIMEBASE_2_CLOCK_SRC_BITS;
break;
case NI_660X_TIMEBASE_3_CLK:
clock_source = NI_GPCT_TIMEBASE_3_CLOCK_SRC_BITS;
break;
case NI_660X_LOGIC_LOW_CLK:
clock_source = NI_GPCT_LOGIC_LOW_CLOCK_SRC_BITS;
break;
case NI_660X_SRC_PIN_I_CLK:
clock_source = NI_GPCT_SOURCE_PIN_i_CLOCK_SRC_BITS;
break;
case NI_660X_NEXT_GATE_CLK:
clock_source = NI_GPCT_NEXT_GATE_CLOCK_SRC_BITS;
break;
case NI_660X_NEXT_TC_CLK:
clock_source = NI_GPCT_NEXT_TC_CLOCK_SRC_BITS;
break;
default:
for (i = 0; i <= NI_660X_MAX_RTSI_CHAN; ++i) {
if (src == NI_660X_RTSI_CLK(i)) {
clock_source = NI_GPCT_RTSI_CLOCK_SRC_BITS(i);
break;
}
}
if (i <= NI_660X_MAX_RTSI_CHAN)
break;
for (i = 0; i <= NI_660X_MAX_SRC_PIN; ++i) {
if (src == NI_660X_SRC_PIN_CLK(i)) {
clock_source =
NI_GPCT_SOURCE_PIN_CLOCK_SRC_BITS(i);
break;
}
}
if (i <= NI_660X_MAX_SRC_PIN)
break;
return -EINVAL;
}
clock_source |= ni_tio_clock_src_modifiers(counter);
*clk_src = clock_source;
return 0;
}
static int ni_tio_generic_clock_src_select(const struct ni_gpct *counter,
unsigned int *clk_src)
{
switch (counter->counter_dev->variant) {
case ni_gpct_variant_e_series:
case ni_gpct_variant_m_series:
default:
return ni_m_series_clock_src_select(counter, clk_src);
case ni_gpct_variant_660x:
return ni_660x_clock_src_select(counter, clk_src);
Annotation
- Immediate include surface: `linux/module.h`, `linux/slab.h`, `ni_tio_internal.h`.
- Detected declarations: `function Copyright`, `function GI_PRESCALE_X8`, `function ni_tio_has_gate2_registers`, `function ni_tio_write`, `function ni_tio_read`, `function ni_tio_reset_count_and_disarm`, `function ni_tio_clock_period_ps`, `function ni_tio_set_bits_transient`, `function ni_tio_set_bits`, `function ni_tio_get_soft_copy`.
- Atlas domain: Driver Families / drivers/comedi.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.