drivers/ptp/ptp_fc3.c
Source file repositories/reference/linux-study-clean/drivers/ptp/ptp_fc3.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/ptp/ptp_fc3.c- Extension
.c- Size
- 21557 bytes
- Lines
- 1011
- Domain
- Driver Families
- Bucket
- drivers/ptp
- 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/firmware.hlinux/platform_device.hlinux/module.hlinux/ptp_clock_kernel.hlinux/delay.hlinux/jiffies.hlinux/kernel.hlinux/timekeeping.hlinux/string.hlinux/of.hlinux/bitfield.hlinux/mfd/rsmu.hlinux/mfd/idtRC38xxx_reg.hlinux/unaligned.hptp_private.hptp_fc3.h
Detected Declarations
function ns2countersfunction tdc_meas2offsetfunction tdc_offset2phasefunction idtfc3_set_lpf_modefunction idtfc3_enable_lpffunction idtfc3_get_time_ref_freqfunction idtfc3_get_tdc_offset_signfunction idtfc3_lpf_bwfunction idtfc3_enable_tdcfunction get_tdc_measfunction check_tdc_fifo_overrunfunction get_tdc_meas_continuousfunction idtfc3_read_subcounterfunction idtfc3_tod_update_is_donefunction idtfc3_write_subcounterfunction idtfc3_timecounter_updatefunction idtfc3_timecounter_readfunction _idtfc3_gettimefunction idtfc3_gettimefunction _idtfc3_settimefunction idtfc3_settimefunction _idtfc3_adjtimefunction idtfc3_adjtimefunction _idtfc3_adjphasefunction idtfc3_adjphasefunction _idtfc3_adjfinefunction idtfc3_adjfinefunction idtfc3_enablefunction idtfc3_aux_workfunction idtfc3_hw_calibratefunction idtfc3_init_timecounterfunction idtfc3_get_tdc_apll_freqfunction idtfc3_get_fodfunction idtfc3_get_sync_countfunction idtfc3_setup_hw_paramfunction idtfc3_configure_hwfunction idtfc3_set_overheadfunction idtfc3_enable_ptpfunction idtfc3_load_firmwarefunction idtfc3_read_device_idfunction idtfc3_check_device_compatibilityfunction idtfc3_probefunction idtfc3_remove
Annotated Snippet
if (on) {
/* Only accept requests for external phase offset */
if ((rq->extts.flags & PTP_EXT_OFFSET) != (PTP_EXT_OFFSET))
err = -EOPNOTSUPP;
else
err = idtfc3_enable_tdc(idtfc3, true, CONTINUOUS);
} else {
err = idtfc3_enable_tdc(idtfc3, false, MEAS_MODE_INVALID);
}
break;
default:
break;
}
mutex_unlock(idtfc3->lock);
if (err)
dev_err(idtfc3->dev, "Failed in %s with err %d!", __func__, err);
return err;
}
static long idtfc3_aux_work(struct ptp_clock_info *ptp)
{
struct idtfc3 *idtfc3 = container_of(ptp, struct idtfc3, caps);
static int tdc_get;
mutex_lock(idtfc3->lock);
tdc_get %= TDC_GET_PERIOD;
if ((tdc_get == 0) || (tdc_get == TDC_GET_PERIOD / 2))
idtfc3_timecounter_read(idtfc3);
get_tdc_meas_continuous(idtfc3);
tdc_get++;
mutex_unlock(idtfc3->lock);
return idtfc3->tc_update_period;
}
static const struct ptp_clock_info idtfc3_caps = {
.owner = THIS_MODULE,
.max_adj = MAX_FFO_PPB,
.n_per_out = 1,
.n_ext_ts = 1,
.supported_extts_flags = PTP_STRICT_FLAGS | PTP_EXT_OFFSET,
.adjphase = &idtfc3_adjphase,
.adjfine = &idtfc3_adjfine,
.adjtime = &idtfc3_adjtime,
.gettime64 = &idtfc3_gettime,
.settime64 = &idtfc3_settime,
.enable = &idtfc3_enable,
.do_aux_work = &idtfc3_aux_work,
};
static int idtfc3_hw_calibrate(struct idtfc3 *idtfc3)
{
int err = 0;
u8 val;
mdelay(10);
/*
* Toggle TDC_DAC_RECAL_REQ:
* (1) set tdc_en to 1
* (2) set tdc_dac_recal_req to 0
* (3) set tdc_dac_recal_req to 1
*/
val = TDC_EN;
err = regmap_bulk_write(idtfc3->regmap, TDC_CTRL,
&val, sizeof(val));
if (err)
return err;
val = TDC_EN | TDC_DAC_RECAL_REQ;
err = regmap_bulk_write(idtfc3->regmap, TDC_CTRL,
&val, sizeof(val));
if (err)
return err;
mdelay(10);
/*
* Toggle APLL_REINIT:
* (1) set apll_reinit to 0
* (2) set apll_reinit to 1
*/
val = 0;
err = regmap_bulk_write(idtfc3->regmap, SOFT_RESET_CTRL,
&val, sizeof(val));
if (err)
return err;
val = APLL_REINIT;
err = regmap_bulk_write(idtfc3->regmap, SOFT_RESET_CTRL,
&val, sizeof(val));
if (err)
Annotation
- Immediate include surface: `linux/firmware.h`, `linux/platform_device.h`, `linux/module.h`, `linux/ptp_clock_kernel.h`, `linux/delay.h`, `linux/jiffies.h`, `linux/kernel.h`, `linux/timekeeping.h`.
- Detected declarations: `function ns2counters`, `function tdc_meas2offset`, `function tdc_offset2phase`, `function idtfc3_set_lpf_mode`, `function idtfc3_enable_lpf`, `function idtfc3_get_time_ref_freq`, `function idtfc3_get_tdc_offset_sign`, `function idtfc3_lpf_bw`, `function idtfc3_enable_tdc`, `function get_tdc_meas`.
- Atlas domain: Driver Families / drivers/ptp.
- 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.