drivers/counter/104-quad-8.c
Source file repositories/reference/linux-study-clean/drivers/counter/104-quad-8.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/counter/104-quad-8.c- Extension
.c- Size
- 38553 bytes
- Lines
- 1372
- Domain
- Driver Families
- Bucket
- drivers/counter
- 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/bitfield.hlinux/bits.hlinux/counter.hlinux/device.hlinux/err.hlinux/io.hlinux/ioport.hlinux/interrupt.hlinux/isa.hlinux/kernel.hlinux/list.hlinux/module.hlinux/moduleparam.hlinux/regmap.hlinux/spinlock.hlinux/types.hlinux/unaligned.h
Detected Declarations
struct quad8function quad8_control_register_updatefunction quad8_signal_readfunction quad8_count_readfunction quad8_preset_register_setfunction quad8_flag_register_resetfunction quad8_count_writefunction quad8_function_getfunction quad8_function_readfunction quad8_function_writefunction quad8_direction_readfunction quad8_action_readfunction quad8_events_configurefunction list_for_each_entryfunction quad8_watch_validatefunction quad8_index_polarity_getfunction quad8_index_polarity_setfunction quad8_polarity_readfunction quad8_polarity_writefunction quad8_synchronous_mode_getfunction quad8_synchronous_mode_setfunction quad8_count_floor_readfunction quad8_count_mode_readfunction quad8_count_mode_writefunction quad8_count_enable_readfunction quad8_count_enable_writefunction quad8_error_noise_getfunction quad8_count_preset_readfunction quad8_count_preset_writefunction quad8_count_ceiling_readfunction quad8_count_ceiling_writefunction quad8_count_preset_enable_readfunction quad8_count_preset_enable_writefunction quad8_signal_cable_fault_readfunction quad8_signal_cable_fault_enable_readfunction quad8_signal_cable_fault_enable_writefunction quad8_signal_fck_prescaler_readfunction quad8_filter_clock_prescaler_setfunction quad8_signal_fck_prescaler_writefunction quad8_irq_handlerfunction quad8_init_counterfunction quad8_probe
Annotated Snippet
struct quad8 {
spinlock_t lock;
u8 cmr[QUAD8_NUM_COUNTERS];
u8 ior[QUAD8_NUM_COUNTERS];
u8 idr[QUAD8_NUM_COUNTERS];
unsigned int fck_prescaler[QUAD8_NUM_COUNTERS];
unsigned int preset[QUAD8_NUM_COUNTERS];
unsigned int cable_fault_enable;
struct regmap *map;
};
static const struct regmap_range quad8_wr_ranges[] = {
regmap_reg_range(0x0, 0xF), regmap_reg_range(0x11, 0x12), regmap_reg_range(0x17, 0x17),
};
static const struct regmap_range quad8_rd_ranges[] = {
regmap_reg_range(0x0, 0x12), regmap_reg_range(0x16, 0x18),
};
static const struct regmap_access_table quad8_wr_table = {
.yes_ranges = quad8_wr_ranges,
.n_yes_ranges = ARRAY_SIZE(quad8_wr_ranges),
};
static const struct regmap_access_table quad8_rd_table = {
.yes_ranges = quad8_rd_ranges,
.n_yes_ranges = ARRAY_SIZE(quad8_rd_ranges),
};
static const struct regmap_config quad8_regmap_config = {
.reg_bits = 8,
.reg_stride = 1,
.val_bits = 8,
.io_port = true,
.wr_table = &quad8_wr_table,
.rd_table = &quad8_rd_table,
};
/* Error flag */
#define FLAG_E BIT(4)
/* Up/Down flag */
#define FLAG_UD BIT(5)
/* Counting up */
#define UP 0x1
#define REGISTER_SELECTION GENMASK(6, 5)
/* Reset and Load Signal Decoders */
#define SELECT_RLD u8_encode_bits(0x0, REGISTER_SELECTION)
/* Counter Mode Register */
#define SELECT_CMR u8_encode_bits(0x1, REGISTER_SELECTION)
/* Input / Output Control Register */
#define SELECT_IOR u8_encode_bits(0x2, REGISTER_SELECTION)
/* Index Control Register */
#define SELECT_IDR u8_encode_bits(0x3, REGISTER_SELECTION)
/*
* Reset and Load Signal Decoders
*/
#define RESETS GENMASK(2, 1)
#define LOADS GENMASK(4, 3)
/* Reset Byte Pointer (three byte data pointer) */
#define RESET_BP BIT(0)
/* Reset Borrow Toggle, Carry toggle, Compare toggle, Sign, and Index flags */
#define RESET_BT_CT_CPT_S_IDX u8_encode_bits(0x2, RESETS)
/* Reset Error flag */
#define RESET_E u8_encode_bits(0x3, RESETS)
/* Preset Register to Counter */
#define TRANSFER_PR_TO_CNTR u8_encode_bits(0x1, LOADS)
/* Transfer Counter to Output Latch */
#define TRANSFER_CNTR_TO_OL u8_encode_bits(0x2, LOADS)
/* Transfer Preset Register LSB to FCK Prescaler */
#define TRANSFER_PR0_TO_PSC u8_encode_bits(0x3, LOADS)
/*
* Counter Mode Registers
*/
#define COUNT_ENCODING BIT(0)
#define COUNT_MODE GENMASK(2, 1)
#define QUADRATURE_MODE GENMASK(4, 3)
/* Binary count */
#define BINARY u8_encode_bits(0x0, COUNT_ENCODING)
/* Normal count */
#define NORMAL_COUNT 0x0
/* Range Limit */
#define RANGE_LIMIT 0x1
/* Non-recycle count */
#define NON_RECYCLE_COUNT 0x2
/* Modulo-N */
#define MODULO_N 0x3
/* Non-quadrature */
#define NON_QUADRATURE 0x0
/* Quadrature X1 */
#define QUADRATURE_X1 0x1
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bits.h`, `linux/counter.h`, `linux/device.h`, `linux/err.h`, `linux/io.h`, `linux/ioport.h`, `linux/interrupt.h`.
- Detected declarations: `struct quad8`, `function quad8_control_register_update`, `function quad8_signal_read`, `function quad8_count_read`, `function quad8_preset_register_set`, `function quad8_flag_register_reset`, `function quad8_count_write`, `function quad8_function_get`, `function quad8_function_read`, `function quad8_function_write`.
- Atlas domain: Driver Families / drivers/counter.
- 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.