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
84 cnt = list_count_nodes(&ptp->tsevqs); in extts_fifo_show()
89 queue = list_first_entry(&ptp->tsevqs, struct timestamp_event_queue, in extts_fifo_show()
116 struct ptp_clock *ptp = dev_get_drvdata(dev); in period_store() local
117 struct ptp_clock_info *ops = ptp->info; in period_store()
144 struct ptp_clock *ptp = dev_get_drvdata(dev); in pps_enable_store() local
145 struct ptp_clock_info *ops = ptp->info; in pps_enable_store()
169 struct ptp_clock *ptp = dev_get_drvdata(dev); in unregister_vclock() local
170 struct ptp_clock_info *info = ptp->info; in unregister_vclock()
175 dev_info(dev->parent, "delete virtual clock ptp%d\n", in unregister_vclock()
191 struct ptp_clock *ptp = dev_get_drvdata(dev); in n_vclocks_show() local
194 if (mutex_lock_interruptible(&ptp->n_vclocks_mux)) in n_vclocks_show()
197 size = snprintf(page, PAGE_SIZE - 1, "%u\n", ptp->n_vclocks); in n_vclocks_show()
199 mutex_unlock(&ptp->n_vclocks_mux); in n_vclocks_show()
208 struct ptp_clock *ptp = dev_get_drvdata(dev); in n_vclocks_store() local
216 if (mutex_lock_interruptible(&ptp->n_vclocks_mux)) in n_vclocks_store()
219 if (num > ptp->max_vclocks) { in n_vclocks_store()
220 dev_err(dev, "max value is %d\n", ptp->max_vclocks); in n_vclocks_store()
225 if (num > ptp->n_vclocks) { in n_vclocks_store()
226 for (i = 0; i < num - ptp->n_vclocks; i++) { in n_vclocks_store()
227 vclock = ptp_vclock_register(ptp); in n_vclocks_store()
231 *(ptp->vclock_index + ptp->n_vclocks + i) = in n_vclocks_store()
234 dev_info(dev, "new virtual clock ptp%d\n", in n_vclocks_store()
240 if (num < ptp->n_vclocks) { in n_vclocks_store()
241 i = ptp->n_vclocks - num; in n_vclocks_store()
245 for (i = 1; i <= ptp->n_vclocks - num; i++) in n_vclocks_store()
246 *(ptp->vclock_index + ptp->n_vclocks - i) = -1; in n_vclocks_store()
250 if (!ptp->has_cycles) { in n_vclocks_store()
257 ptp->n_vclocks = num; in n_vclocks_store()
258 mutex_unlock(&ptp->n_vclocks_mux); in n_vclocks_store()
262 mutex_unlock(&ptp->n_vclocks_mux); in n_vclocks_store()
270 struct ptp_clock *ptp = dev_get_drvdata(dev); in max_vclocks_show() local
273 size = snprintf(page, PAGE_SIZE - 1, "%u\n", ptp->max_vclocks); in max_vclocks_show()
282 struct ptp_clock *ptp = dev_get_drvdata(dev); in max_vclocks_store() local
291 if (max == ptp->max_vclocks) in max_vclocks_store()
294 if (mutex_lock_interruptible(&ptp->n_vclocks_mux)) in max_vclocks_store()
297 if (max < ptp->n_vclocks) in max_vclocks_store()
307 size = sizeof(int) * ptp->n_vclocks; in max_vclocks_store()
308 memcpy(vclock_index, ptp->vclock_index, size); in max_vclocks_store()
310 kfree(ptp->vclock_index); in max_vclocks_store()
311 ptp->vclock_index = vclock_index; in max_vclocks_store()
312 ptp->max_vclocks = max; in max_vclocks_store()
314 mutex_unlock(&ptp->n_vclocks_mux); in max_vclocks_store()
318 mutex_unlock(&ptp->n_vclocks_mux); in max_vclocks_store()
347 struct ptp_clock *ptp = dev_get_drvdata(dev); in ptp_is_attribute_visible() local
348 struct ptp_clock_info *info = ptp->info; in ptp_is_attribute_visible()
363 if (ptp->is_virtual_clock) in ptp_is_attribute_visible()
383 static int ptp_pin_name2index(struct ptp_clock *ptp, const char *name) in ptp_pin_name2index() argument
386 for (i = 0; i < ptp->info->n_pins; i++) { in ptp_pin_name2index()
387 if (!strcmp(ptp->info->pin_config[i].name, name)) in ptp_pin_name2index()
396 struct ptp_clock *ptp = dev_get_drvdata(dev); in ptp_pin_show() local
400 index = ptp_pin_name2index(ptp, attr->attr.name); in ptp_pin_show()
404 if (mutex_lock_interruptible(&ptp->pincfg_mux)) in ptp_pin_show()
407 func = ptp->info->pin_config[index].func; in ptp_pin_show()
408 chan = ptp->info->pin_config[index].chan; in ptp_pin_show()
410 mutex_unlock(&ptp->pincfg_mux); in ptp_pin_show()
418 struct ptp_clock *ptp = dev_get_drvdata(dev); in ptp_pin_store() local
426 index = ptp_pin_name2index(ptp, attr->attr.name); in ptp_pin_store()
430 if (mutex_lock_interruptible(&ptp->pincfg_mux)) in ptp_pin_store()
432 err = ptp_set_pinfunc(ptp, index, func, chan); in ptp_pin_store()
433 mutex_unlock(&ptp->pincfg_mux); in ptp_pin_store()
440 int ptp_populate_pin_groups(struct ptp_clock *ptp) in ptp_populate_pin_groups() argument
442 struct ptp_clock_info *info = ptp->info; in ptp_populate_pin_groups()
448 ptp->pin_dev_attr = kcalloc(n_pins, sizeof(*ptp->pin_dev_attr), in ptp_populate_pin_groups()
450 if (!ptp->pin_dev_attr) in ptp_populate_pin_groups()
453 ptp->pin_attr = kcalloc(1 + n_pins, sizeof(*ptp->pin_attr), GFP_KERNEL); in ptp_populate_pin_groups()
454 if (!ptp->pin_attr) in ptp_populate_pin_groups()
458 struct device_attribute *da = &ptp->pin_dev_attr[i]; in ptp_populate_pin_groups()
464 ptp->pin_attr[i] = &da->attr; in ptp_populate_pin_groups()
467 ptp->pin_attr_group.name = "pins"; in ptp_populate_pin_groups()
468 ptp->pin_attr_group.attrs = ptp->pin_attr; in ptp_populate_pin_groups()
470 ptp->pin_attr_groups[0] = &ptp->pin_attr_group; in ptp_populate_pin_groups()
475 kfree(ptp->pin_dev_attr); in ptp_populate_pin_groups()
480 void ptp_cleanup_pin_groups(struct ptp_clock *ptp) in ptp_cleanup_pin_groups() argument
482 kfree(ptp->pin_attr); in ptp_cleanup_pin_groups()
483 kfree(ptp->pin_dev_attr); in ptp_cleanup_pin_groups()