drivers/pps/generators/pps_gen_tio.c
Source file repositories/reference/linux-study-clean/drivers/pps/generators/pps_gen_tio.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pps/generators/pps_gen_tio.c- Extension
.c- Size
- 6587 bytes
- Lines
- 269
- Domain
- Driver Families
- Bucket
- drivers/pps
- 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.
- 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/bitfield.hlinux/bits.hlinux/cleanup.hlinux/container_of.hlinux/device.hlinux/hrtimer.hlinux/io-64-nonatomic-hi-lo.hlinux/mod_devicetable.hlinux/module.hlinux/platform_device.hlinux/pps_gen_kernel.hlinux/timekeeping.hlinux/types.hasm/cpu_device_id.h
Detected Declarations
struct pps_tiofunction pps_tio_readfunction pps_ctl_writefunction pps_compv_writefunction first_eventfunction pps_tio_disablefunction pps_tio_enablefunction pps_tio_direction_outputfunction pps_generate_next_pulsefunction hrtimer_callbackfunction pps_tio_gen_enablefunction pps_tio_get_timefunction pps_gen_tio_probefunction pps_gen_tio_remove
Annotated Snippet
struct pps_tio {
struct pps_gen_source_info gen_info;
struct pps_gen_device *pps_gen;
struct hrtimer timer;
void __iomem *base;
u32 prev_count;
spinlock_t lock;
struct device *dev;
};
static inline u32 pps_tio_read(u32 offset, struct pps_tio *tio)
{
return readl(tio->base + offset);
}
static inline void pps_ctl_write(u32 value, struct pps_tio *tio)
{
writel(value, tio->base + TIOCTL);
}
/*
* For COMPV register, It's safer to write
* higher 32-bit followed by lower 32-bit
*/
static inline void pps_compv_write(u64 value, struct pps_tio *tio)
{
hi_lo_writeq(value, tio->base + TIOCOMPV);
}
static inline ktime_t first_event(struct pps_tio *tio)
{
return ktime_set(ktime_get_real_seconds() + 1, MAGIC_CONST);
}
static u32 pps_tio_disable(struct pps_tio *tio)
{
u32 ctrl;
ctrl = pps_tio_read(TIOCTL, tio);
pps_compv_write(0, tio);
ctrl &= ~TIOCTL_EN;
pps_ctl_write(ctrl, tio);
tio->pps_gen->enabled = false;
tio->prev_count = 0;
return ctrl;
}
static void pps_tio_enable(struct pps_tio *tio)
{
u32 ctrl;
ctrl = pps_tio_read(TIOCTL, tio);
ctrl |= TIOCTL_EN;
pps_ctl_write(ctrl, tio);
tio->pps_gen->enabled = true;
}
static void pps_tio_direction_output(struct pps_tio *tio)
{
u32 ctrl;
ctrl = pps_tio_disable(tio);
/*
* We enable the device, be sure that the
* 'compare' value is invalid
*/
pps_compv_write(0, tio);
ctrl &= ~(TIOCTL_DIR | TIOCTL_EP);
ctrl |= TIOCTL_EP_TOGGLE_EDGE;
pps_ctl_write(ctrl, tio);
pps_tio_enable(tio);
}
static bool pps_generate_next_pulse(ktime_t expires, struct pps_tio *tio)
{
u64 art;
if (!ktime_real_to_base_clock(expires, CSID_X86_ART, &art)) {
pps_tio_disable(tio);
return false;
}
pps_compv_write(art - ART_HW_DELAY_CYCLES, tio);
return true;
}
static enum hrtimer_restart hrtimer_callback(struct hrtimer *timer)
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bits.h`, `linux/cleanup.h`, `linux/container_of.h`, `linux/device.h`, `linux/hrtimer.h`, `linux/io-64-nonatomic-hi-lo.h`, `linux/mod_devicetable.h`.
- Detected declarations: `struct pps_tio`, `function pps_tio_read`, `function pps_ctl_write`, `function pps_compv_write`, `function first_event`, `function pps_tio_disable`, `function pps_tio_enable`, `function pps_tio_direction_output`, `function pps_generate_next_pulse`, `function hrtimer_callback`.
- Atlas domain: Driver Families / drivers/pps.
- Implementation status: source 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.