drivers/counter/ti-ecap-capture.c
Source file repositories/reference/linux-study-clean/drivers/counter/ti-ecap-capture.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/counter/ti-ecap-capture.c- Extension
.c- Size
- 16170 bytes
- Lines
- 611
- 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/atomic.hlinux/clk.hlinux/counter.hlinux/err.hlinux/interrupt.hlinux/io.hlinux/module.hlinux/mod_devicetable.hlinux/mutex.hlinux/platform_device.hlinux/pm_runtime.hlinux/regmap.h
Detected Declarations
struct ecap_cnt_devfunction ecap_cnt_capture_get_evmodefunction ecap_cnt_capture_set_evmodefunction ecap_cnt_capture_enablefunction ecap_cnt_capture_disablefunction ecap_cnt_count_get_valfunction ecap_cnt_count_set_valfunction ecap_cnt_count_readfunction ecap_cnt_count_writefunction ecap_cnt_function_readfunction ecap_cnt_action_readfunction ecap_cnt_watch_validatefunction ecap_cnt_clk_get_freqfunction ecap_cnt_pol_readfunction ecap_cnt_pol_writefunction ecap_cnt_cap_readfunction ecap_cnt_cap_writefunction ecap_cnt_nb_ovf_readfunction ecap_cnt_nb_ovf_writefunction ecap_cnt_ceiling_readfunction ecap_cnt_enable_readfunction ecap_cnt_enable_writefunction ecap_cnt_isrfunction ecap_cnt_probefunction ecap_cnt_removefunction ecap_cnt_suspendfunction ecap_cnt_resume
Annotated Snippet
struct ecap_cnt_dev {
bool enabled;
struct mutex lock;
struct clk *clk;
struct regmap *regmap;
atomic_t nb_ovf;
struct {
u8 ev_mode;
u32 time_cntr;
} pm_ctx;
};
static u8 ecap_cnt_capture_get_evmode(struct counter_device *counter)
{
struct ecap_cnt_dev *ecap_dev = counter_priv(counter);
unsigned int regval;
pm_runtime_get_sync(counter->parent);
regmap_read(ecap_dev->regmap, ECAP_ECCTL_REG, ®val);
pm_runtime_put_sync(counter->parent);
return regval;
}
static void ecap_cnt_capture_set_evmode(struct counter_device *counter, u8 ev_mode)
{
struct ecap_cnt_dev *ecap_dev = counter_priv(counter);
pm_runtime_get_sync(counter->parent);
regmap_update_bits(ecap_dev->regmap, ECAP_ECCTL_REG, ECAP_EV_MODE_MASK, ev_mode);
pm_runtime_put_sync(counter->parent);
}
static void ecap_cnt_capture_enable(struct counter_device *counter)
{
struct ecap_cnt_dev *ecap_dev = counter_priv(counter);
pm_runtime_get_sync(counter->parent);
/* Enable interrupts on events */
regmap_update_bits(ecap_dev->regmap, ECAP_ECINT_EN_FLG_REG,
ECAP_EVT_EN_MASK, ECAP_EVT_EN_MASK);
/* Run counter */
regmap_update_bits(ecap_dev->regmap, ECAP_ECCTL_REG, ECAP_ECCTL_CFG_MASK,
ECAP_SYNCO_DIS_MASK | ECAP_STOPVALUE_MASK | ECAP_ECCTL_EN_MASK);
}
static void ecap_cnt_capture_disable(struct counter_device *counter)
{
struct ecap_cnt_dev *ecap_dev = counter_priv(counter);
/* Stop counter */
regmap_update_bits(ecap_dev->regmap, ECAP_ECCTL_REG, ECAP_ECCTL_EN_MASK, 0);
/* Disable interrupts on events */
regmap_update_bits(ecap_dev->regmap, ECAP_ECINT_EN_FLG_REG, ECAP_EVT_EN_MASK, 0);
pm_runtime_put_sync(counter->parent);
}
static u32 ecap_cnt_count_get_val(struct counter_device *counter, unsigned int reg)
{
struct ecap_cnt_dev *ecap_dev = counter_priv(counter);
unsigned int regval;
pm_runtime_get_sync(counter->parent);
regmap_read(ecap_dev->regmap, reg, ®val);
pm_runtime_put_sync(counter->parent);
return regval;
}
static void ecap_cnt_count_set_val(struct counter_device *counter, unsigned int reg, u32 val)
{
struct ecap_cnt_dev *ecap_dev = counter_priv(counter);
pm_runtime_get_sync(counter->parent);
regmap_write(ecap_dev->regmap, reg, val);
pm_runtime_put_sync(counter->parent);
}
static int ecap_cnt_count_read(struct counter_device *counter,
struct counter_count *count, u64 *val)
{
*val = ecap_cnt_count_get_val(counter, ECAP_TSCNT_REG);
return 0;
}
Annotation
- Immediate include surface: `linux/atomic.h`, `linux/clk.h`, `linux/counter.h`, `linux/err.h`, `linux/interrupt.h`, `linux/io.h`, `linux/module.h`, `linux/mod_devicetable.h`.
- Detected declarations: `struct ecap_cnt_dev`, `function ecap_cnt_capture_get_evmode`, `function ecap_cnt_capture_set_evmode`, `function ecap_cnt_capture_enable`, `function ecap_cnt_capture_disable`, `function ecap_cnt_count_get_val`, `function ecap_cnt_count_set_val`, `function ecap_cnt_count_read`, `function ecap_cnt_count_write`, `function ecap_cnt_function_read`.
- 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.