drivers/ptp/ptp_qoriq.c
Source file repositories/reference/linux-study-clean/drivers/ptp/ptp_qoriq.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/ptp/ptp_qoriq.c- Extension
.c- Size
- 17326 bytes
- Lines
- 701
- Domain
- Driver Families
- Bucket
- drivers/ptp
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/device.hlinux/hrtimer.hlinux/kernel.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/timex.hlinux/slab.hlinux/clk.hlinux/fsl/ptp_qoriq.h
Detected Declarations
function Copyrightfunction tmr_cnt_writefunction tmr_offset_readfunction tmr_offset_writefunction set_alarmfunction set_fipersfunction extts_clean_upfunction ptp_qoriq_isrfunction ptp_qoriq_adjfinefunction ptp_qoriq_adjtimefunction ptp_qoriq_gettimefunction ptp_qoriq_settimefunction ptp_qoriq_enablefunction ptp_qoriq_nominal_freqfunction ptp_qoriq_auto_configfunction ptp_qoriq_perout_loopbackfunction ptp_qoriq_initfunction ptp_qoriq_freefunction ptp_qoriq_probefunction ptp_qoriq_removeexport extts_clean_upexport ptp_qoriq_isrexport ptp_qoriq_adjfineexport ptp_qoriq_adjtimeexport ptp_qoriq_gettimeexport ptp_qoriq_settimeexport ptp_qoriq_enableexport ptp_qoriq_initexport ptp_qoriq_free
Annotated Snippet
if (update_event) {
event.timestamp = ((u64) hi) << 32;
event.timestamp |= lo;
ptp_clock_event(ptp_qoriq->clock, &event);
}
if (!ptp_qoriq->extts_fifo_support)
break;
} while (ptp_qoriq->read(®s->ctrl_regs->tmr_stat) & valid);
return 0;
}
EXPORT_SYMBOL_GPL(extts_clean_up);
/*
* Interrupt service routine
*/
irqreturn_t ptp_qoriq_isr(int irq, void *priv)
{
struct ptp_qoriq *ptp_qoriq = priv;
struct ptp_qoriq_registers *regs = &ptp_qoriq->regs;
struct ptp_clock_event event;
u32 ack = 0, mask, val, irqs;
spin_lock(&ptp_qoriq->lock);
val = ptp_qoriq->read(®s->ctrl_regs->tmr_tevent);
mask = ptp_qoriq->read(®s->ctrl_regs->tmr_temask);
spin_unlock(&ptp_qoriq->lock);
irqs = val & mask;
if (irqs & ETS1) {
ack |= ETS1;
extts_clean_up(ptp_qoriq, 0, true);
}
if (irqs & ETS2) {
ack |= ETS2;
extts_clean_up(ptp_qoriq, 1, true);
}
if (irqs & PP1) {
ack |= PP1;
event.type = PTP_CLOCK_PPS;
ptp_clock_event(ptp_qoriq->clock, &event);
}
if (ack) {
ptp_qoriq->write(®s->ctrl_regs->tmr_tevent, ack);
return IRQ_HANDLED;
} else
return IRQ_NONE;
}
EXPORT_SYMBOL_GPL(ptp_qoriq_isr);
/*
* PTP clock operations
*/
int ptp_qoriq_adjfine(struct ptp_clock_info *ptp, long scaled_ppm)
{
u64 adj, diff;
u32 tmr_add;
int neg_adj = 0;
struct ptp_qoriq *ptp_qoriq = container_of(ptp, struct ptp_qoriq, caps);
struct ptp_qoriq_registers *regs = &ptp_qoriq->regs;
if (scaled_ppm < 0) {
neg_adj = 1;
scaled_ppm = -scaled_ppm;
}
tmr_add = ptp_qoriq->tmr_add;
adj = tmr_add;
/*
* Calculate diff and round() to the nearest integer
*
* diff = adj * (ppb / 1000000000)
* = adj * scaled_ppm / 65536000000
*/
diff = mul_u64_u64_div_u64(adj, scaled_ppm, 32768000000);
diff = DIV64_U64_ROUND_UP(diff, 2);
tmr_add = neg_adj ? tmr_add - diff : tmr_add + diff;
ptp_qoriq->write(®s->ctrl_regs->tmr_add, tmr_add);
return 0;
Annotation
- Immediate include surface: `linux/device.h`, `linux/hrtimer.h`, `linux/kernel.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`, `linux/timex.h`, `linux/slab.h`.
- Detected declarations: `function Copyright`, `function tmr_cnt_write`, `function tmr_offset_read`, `function tmr_offset_write`, `function set_alarm`, `function set_fipers`, `function extts_clean_up`, `function ptp_qoriq_isr`, `function ptp_qoriq_adjfine`, `function ptp_qoriq_adjtime`.
- Atlas domain: Driver Families / drivers/ptp.
- Implementation status: integration 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.