Lines Matching full:ptp
2 /* Marvell PTP driver
12 #include "ptp.h"
16 #define DRV_NAME "Marvell PTP Driver"
45 /* To get the input clock frequency with which PTP co-processor in get_clock_rate()
72 struct ptp *ptp_get(void) in ptp_get()
75 struct ptp *ptp; in ptp_get() local
77 /* If the PTP pci device is found on the system and ptp in ptp_get()
78 * driver is bound to it then the PTP pci device is returned in ptp_get()
86 ptp = pci_get_drvdata(pdev); in ptp_get()
87 if (!ptp) in ptp_get()
88 ptp = ERR_PTR(-EPROBE_DEFER); in ptp_get()
89 if (IS_ERR(ptp)) in ptp_get()
92 return ptp; in ptp_get()
95 void ptp_put(struct ptp *ptp) in ptp_put() argument
97 if (!ptp) in ptp_put()
100 pci_dev_put(ptp->pdev); in ptp_put()
103 static int ptp_adjfine(struct ptp *ptp, long scaled_ppm) in ptp_adjfine() argument
115 /* The hardware adds the clock compensation value to the PTP clock in ptp_adjfine()
129 comp = ((u64)1000000000ull << 32) / ptp->clock_rate; in ptp_adjfine()
138 writeq(comp, ptp->reg_base + PTP_CLOCK_COMP); in ptp_adjfine()
143 static int ptp_get_clock(struct ptp *ptp, u64 *clk) in ptp_get_clock() argument
145 /* Return the current PTP clock */ in ptp_get_clock()
146 *clk = readq(ptp->reg_base + PTP_CLOCK_HI); in ptp_get_clock()
155 struct ptp *ptp; in ptp_probe() local
160 ptp = devm_kzalloc(dev, sizeof(*ptp), GFP_KERNEL); in ptp_probe()
161 if (!ptp) { in ptp_probe()
166 ptp->pdev = pdev; in ptp_probe()
176 ptp->reg_base = pcim_iomap_table(pdev)[PCI_PTP_BAR_NO]; in ptp_probe()
178 ptp->clock_rate = get_clock_rate(); in ptp_probe()
180 /* Enable PTP clock */ in ptp_probe()
181 clock_cfg = readq(ptp->reg_base + PTP_CLOCK_CFG); in ptp_probe()
183 writeq(clock_cfg, ptp->reg_base + PTP_CLOCK_CFG); in ptp_probe()
185 clock_comp = ((u64)1000000000ull << 32) / ptp->clock_rate; in ptp_probe()
187 writeq(clock_comp, ptp->reg_base + PTP_CLOCK_COMP); in ptp_probe()
189 pci_set_drvdata(pdev, ptp); in ptp_probe()
194 devm_kfree(dev, ptp); in ptp_probe()
209 struct ptp *ptp = pci_get_drvdata(pdev); in ptp_remove() local
212 if (IS_ERR_OR_NULL(ptp)) in ptp_remove()
215 /* Disable PTP clock */ in ptp_remove()
216 clock_cfg = readq(ptp->reg_base + PTP_CLOCK_CFG); in ptp_remove()
218 writeq(clock_cfg, ptp->reg_base + PTP_CLOCK_CFG); in ptp_remove()
252 /* This function is the PTP mailbox handler invoked when in rvu_mbox_handler_ptp_op()
254 * It is used by netdev driver to get the PTP clock and to set in rvu_mbox_handler_ptp_op()
256 * notion of whether the driver is bound to ptp device below in rvu_mbox_handler_ptp_op()
259 if (!rvu->ptp) in rvu_mbox_handler_ptp_op()
264 err = ptp_adjfine(rvu->ptp, req->scaled_ppm); in rvu_mbox_handler_ptp_op()
267 err = ptp_get_clock(rvu->ptp, &rsp->clk); in rvu_mbox_handler_ptp_op()