Lines Matching full:ptp

3  * PTP 1588 clock support - sysfs interface.
16 struct ptp_clock *ptp = dev_get_drvdata(dev); in clock_name_show() local
17 return sysfs_emit(page, "%s\n", ptp->info->name); in clock_name_show()
25 struct ptp_clock *ptp = dev_get_drvdata(dev); in max_phase_adjustment_show() local
28 ptp->info->getmaxphase(ptp->info)); in max_phase_adjustment_show()
36 struct ptp_clock *ptp = dev_get_drvdata(dev); \
37 return snprintf(page, PAGE_SIZE-1, "%d\n", ptp->info->var); \
52 struct ptp_clock *ptp = dev_get_drvdata(dev); in extts_enable_store() local
53 struct ptp_clock_info *ops = ptp->info; in extts_enable_store()
77 struct ptp_clock *ptp = dev_get_drvdata(dev); in extts_fifo_show() local
78 struct timestamp_event_queue *queue = &ptp->tsevq; in extts_fifo_show()
86 if (mutex_lock_interruptible(&ptp->tsevq_mux)) in extts_fifo_show()
104 mutex_unlock(&ptp->tsevq_mux); in extts_fifo_show()
113 struct ptp_clock *ptp = dev_get_drvdata(dev); in period_store() local
114 struct ptp_clock_info *ops = ptp->info; in period_store()
141 struct ptp_clock *ptp = dev_get_drvdata(dev); in pps_enable_store() local
142 struct ptp_clock_info *ops = ptp->info; in pps_enable_store()
166 struct ptp_clock *ptp = dev_get_drvdata(dev); in unregister_vclock() local
167 struct ptp_clock_info *info = ptp->info; in unregister_vclock()
172 dev_info(dev->parent, "delete virtual clock ptp%d\n", in unregister_vclock()
188 struct ptp_clock *ptp = dev_get_drvdata(dev); in n_vclocks_show() local
191 if (mutex_lock_interruptible(&ptp->n_vclocks_mux)) in n_vclocks_show()
194 size = snprintf(page, PAGE_SIZE - 1, "%u\n", ptp->n_vclocks); in n_vclocks_show()
196 mutex_unlock(&ptp->n_vclocks_mux); in n_vclocks_show()
205 struct ptp_clock *ptp = dev_get_drvdata(dev); in n_vclocks_store() local
213 if (mutex_lock_interruptible(&ptp->n_vclocks_mux)) in n_vclocks_store()
216 if (num > ptp->max_vclocks) { in n_vclocks_store()
217 dev_err(dev, "max value is %d\n", ptp->max_vclocks); in n_vclocks_store()
222 if (num > ptp->n_vclocks) { in n_vclocks_store()
223 for (i = 0; i < num - ptp->n_vclocks; i++) { in n_vclocks_store()
224 vclock = ptp_vclock_register(ptp); in n_vclocks_store()
228 *(ptp->vclock_index + ptp->n_vclocks + i) = in n_vclocks_store()
231 dev_info(dev, "new virtual clock ptp%d\n", in n_vclocks_store()
237 if (num < ptp->n_vclocks) { in n_vclocks_store()
238 i = ptp->n_vclocks - num; in n_vclocks_store()
242 for (i = 1; i <= ptp->n_vclocks - num; i++) in n_vclocks_store()
243 *(ptp->vclock_index + ptp->n_vclocks - i) = -1; in n_vclocks_store()
247 if (!ptp->has_cycles) { in n_vclocks_store()
254 ptp->n_vclocks = num; in n_vclocks_store()
255 mutex_unlock(&ptp->n_vclocks_mux); in n_vclocks_store()
259 mutex_unlock(&ptp->n_vclocks_mux); in n_vclocks_store()
267 struct ptp_clock *ptp = dev_get_drvdata(dev); in max_vclocks_show() local
270 size = snprintf(page, PAGE_SIZE - 1, "%u\n", ptp->max_vclocks); in max_vclocks_show()
279 struct ptp_clock *ptp = dev_get_drvdata(dev); in max_vclocks_store() local
288 if (max == ptp->max_vclocks) in max_vclocks_store()
291 if (mutex_lock_interruptible(&ptp->n_vclocks_mux)) in max_vclocks_store()
294 if (max < ptp->n_vclocks) in max_vclocks_store()
303 size = sizeof(int) * ptp->n_vclocks; in max_vclocks_store()
304 memcpy(vclock_index, ptp->vclock_index, size); in max_vclocks_store()
306 kfree(ptp->vclock_index); in max_vclocks_store()
307 ptp->vclock_index = vclock_index; in max_vclocks_store()
308 ptp->max_vclocks = max; in max_vclocks_store()
310 mutex_unlock(&ptp->n_vclocks_mux); in max_vclocks_store()
314 mutex_unlock(&ptp->n_vclocks_mux); in max_vclocks_store()
343 struct ptp_clock *ptp = dev_get_drvdata(dev); in ptp_is_attribute_visible() local
344 struct ptp_clock_info *info = ptp->info; in ptp_is_attribute_visible()
359 if (ptp->is_virtual_clock) in ptp_is_attribute_visible()
379 static int ptp_pin_name2index(struct ptp_clock *ptp, const char *name) in ptp_pin_name2index() argument
382 for (i = 0; i < ptp->info->n_pins; i++) { in ptp_pin_name2index()
383 if (!strcmp(ptp->info->pin_config[i].name, name)) in ptp_pin_name2index()
392 struct ptp_clock *ptp = dev_get_drvdata(dev); in ptp_pin_show() local
396 index = ptp_pin_name2index(ptp, attr->attr.name); in ptp_pin_show()
400 if (mutex_lock_interruptible(&ptp->pincfg_mux)) in ptp_pin_show()
403 func = ptp->info->pin_config[index].func; in ptp_pin_show()
404 chan = ptp->info->pin_config[index].chan; in ptp_pin_show()
406 mutex_unlock(&ptp->pincfg_mux); in ptp_pin_show()
414 struct ptp_clock *ptp = dev_get_drvdata(dev); in ptp_pin_store() local
422 index = ptp_pin_name2index(ptp, attr->attr.name); in ptp_pin_store()
426 if (mutex_lock_interruptible(&ptp->pincfg_mux)) in ptp_pin_store()
428 err = ptp_set_pinfunc(ptp, index, func, chan); in ptp_pin_store()
429 mutex_unlock(&ptp->pincfg_mux); in ptp_pin_store()
436 int ptp_populate_pin_groups(struct ptp_clock *ptp) in ptp_populate_pin_groups() argument
438 struct ptp_clock_info *info = ptp->info; in ptp_populate_pin_groups()
444 ptp->pin_dev_attr = kcalloc(n_pins, sizeof(*ptp->pin_dev_attr), in ptp_populate_pin_groups()
446 if (!ptp->pin_dev_attr) in ptp_populate_pin_groups()
449 ptp->pin_attr = kcalloc(1 + n_pins, sizeof(*ptp->pin_attr), GFP_KERNEL); in ptp_populate_pin_groups()
450 if (!ptp->pin_attr) in ptp_populate_pin_groups()
454 struct device_attribute *da = &ptp->pin_dev_attr[i]; in ptp_populate_pin_groups()
460 ptp->pin_attr[i] = &da->attr; in ptp_populate_pin_groups()
463 ptp->pin_attr_group.name = "pins"; in ptp_populate_pin_groups()
464 ptp->pin_attr_group.attrs = ptp->pin_attr; in ptp_populate_pin_groups()
466 ptp->pin_attr_groups[0] = &ptp->pin_attr_group; in ptp_populate_pin_groups()
471 kfree(ptp->pin_dev_attr); in ptp_populate_pin_groups()
476 void ptp_cleanup_pin_groups(struct ptp_clock *ptp) in ptp_cleanup_pin_groups() argument
478 kfree(ptp->pin_attr); in ptp_cleanup_pin_groups()
479 kfree(ptp->pin_dev_attr); in ptp_cleanup_pin_groups()