drivers/counter/ti-eqep.c
Source file repositories/reference/linux-study-clean/drivers/counter/ti-eqep.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/counter/ti-eqep.c- Extension
.c- Size
- 14902 bytes
- Lines
- 595
- 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.
- 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/bitops.hlinux/clk.hlinux/counter.hlinux/interrupt.hlinux/kernel.hlinux/mod_devicetable.hlinux/module.hlinux/platform_device.hlinux/pm_runtime.hlinux/regmap.hlinux/types.h
Detected Declarations
struct ti_eqep_cntenum ti_eqep_count_funcfunction ti_eqep_count_readfunction ti_eqep_count_writefunction ti_eqep_function_readfunction ti_eqep_function_writefunction ti_eqep_action_readfunction ti_eqep_events_configurefunction list_for_each_entryfunction ti_eqep_watch_validatefunction ti_eqep_position_ceiling_readfunction ti_eqep_position_ceiling_writefunction ti_eqep_position_enable_readfunction ti_eqep_position_enable_writefunction ti_eqep_direction_readfunction ti_eqep_irq_handlerfunction ti_eqep_probefunction ti_eqep_remove
Annotated Snippet
struct ti_eqep_cnt {
struct regmap *regmap32;
struct regmap *regmap16;
};
static int ti_eqep_count_read(struct counter_device *counter,
struct counter_count *count, u64 *val)
{
struct ti_eqep_cnt *priv = counter_priv(counter);
u32 cnt;
regmap_read(priv->regmap32, QPOSCNT, &cnt);
*val = cnt;
return 0;
}
static int ti_eqep_count_write(struct counter_device *counter,
struct counter_count *count, u64 val)
{
struct ti_eqep_cnt *priv = counter_priv(counter);
u32 max;
regmap_read(priv->regmap32, QPOSMAX, &max);
if (val > max)
return -EINVAL;
return regmap_write(priv->regmap32, QPOSCNT, val);
}
static int ti_eqep_function_read(struct counter_device *counter,
struct counter_count *count,
enum counter_function *function)
{
struct ti_eqep_cnt *priv = counter_priv(counter);
u32 qdecctl;
regmap_read(priv->regmap16, QDECCTL, &qdecctl);
switch ((qdecctl & QDECCTL_QSRC) >> QDECCTL_QSRC_SHIFT) {
case TI_EQEP_COUNT_FUNC_QUAD_COUNT:
*function = COUNTER_FUNCTION_QUADRATURE_X4;
break;
case TI_EQEP_COUNT_FUNC_DIR_COUNT:
*function = COUNTER_FUNCTION_PULSE_DIRECTION;
break;
case TI_EQEP_COUNT_FUNC_UP_COUNT:
*function = COUNTER_FUNCTION_INCREASE;
break;
case TI_EQEP_COUNT_FUNC_DOWN_COUNT:
*function = COUNTER_FUNCTION_DECREASE;
break;
}
return 0;
}
static int ti_eqep_function_write(struct counter_device *counter,
struct counter_count *count,
enum counter_function function)
{
struct ti_eqep_cnt *priv = counter_priv(counter);
enum ti_eqep_count_func qsrc;
switch (function) {
case COUNTER_FUNCTION_QUADRATURE_X4:
qsrc = TI_EQEP_COUNT_FUNC_QUAD_COUNT;
break;
case COUNTER_FUNCTION_PULSE_DIRECTION:
qsrc = TI_EQEP_COUNT_FUNC_DIR_COUNT;
break;
case COUNTER_FUNCTION_INCREASE:
qsrc = TI_EQEP_COUNT_FUNC_UP_COUNT;
break;
case COUNTER_FUNCTION_DECREASE:
qsrc = TI_EQEP_COUNT_FUNC_DOWN_COUNT;
break;
default:
/* should never reach this path */
return -EINVAL;
}
return regmap_write_bits(priv->regmap16, QDECCTL, QDECCTL_QSRC,
qsrc << QDECCTL_QSRC_SHIFT);
}
static int ti_eqep_action_read(struct counter_device *counter,
struct counter_count *count,
struct counter_synapse *synapse,
enum counter_synapse_action *action)
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/clk.h`, `linux/counter.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/platform_device.h`.
- Detected declarations: `struct ti_eqep_cnt`, `enum ti_eqep_count_func`, `function ti_eqep_count_read`, `function ti_eqep_count_write`, `function ti_eqep_function_read`, `function ti_eqep_function_write`, `function ti_eqep_action_read`, `function ti_eqep_events_configure`, `function list_for_each_entry`, `function ti_eqep_watch_validate`.
- Atlas domain: Driver Families / drivers/counter.
- Implementation status: source implementation candidate.
- 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.