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
27 return sysfs_emit(page, "%d\n", ptp->info->getmaxphase(ptp->info)); in max_phase_adjustment_show()
35 struct ptp_clock *ptp = dev_get_drvdata(dev); \
36 return sysfs_emit(page, "%d\n", ptp->info->var); \
51 struct ptp_clock *ptp = dev_get_drvdata(dev); in extts_enable_store() local
52 struct ptp_clock_info *ops = ptp->info; in extts_enable_store()
76 struct ptp_clock *ptp = dev_get_drvdata(dev); in extts_fifo_show() local
83 cnt = list_count_nodes(&ptp->tsevqs); in extts_fifo_show()
88 queue = list_first_entry(&ptp->tsevqs, struct timestamp_event_queue, in extts_fifo_show()
115 struct ptp_clock *ptp = dev_get_drvdata(dev); in period_store() local
116 struct ptp_clock_info *ops = ptp->info; in period_store()
143 struct ptp_clock *ptp = dev_get_drvdata(dev); in pps_enable_store() local
144 struct ptp_clock_info *ops = ptp->info; in pps_enable_store()
168 struct ptp_clock *ptp = dev_get_drvdata(dev); in unregister_vclock() local
169 struct ptp_clock_info *info = ptp->info; in unregister_vclock()
174 dev_info(dev->parent, "delete virtual clock ptp%d\n", in unregister_vclock()
190 struct ptp_clock *ptp = dev_get_drvdata(dev); in n_vclocks_show() local
193 if (mutex_lock_interruptible(&ptp->n_vclocks_mux)) in n_vclocks_show()
196 size = sysfs_emit(page, "%u\n", ptp->n_vclocks); in n_vclocks_show()
198 mutex_unlock(&ptp->n_vclocks_mux); in n_vclocks_show()
207 struct ptp_clock *ptp = dev_get_drvdata(dev); in n_vclocks_store() local
215 if (mutex_lock_interruptible(&ptp->n_vclocks_mux)) in n_vclocks_store()
218 if (num > ptp->max_vclocks) { in n_vclocks_store()
219 dev_err(dev, "max value is %d\n", ptp->max_vclocks); in n_vclocks_store()
224 if (num > ptp->n_vclocks) { in n_vclocks_store()
225 for (i = 0; i < num - ptp->n_vclocks; i++) { in n_vclocks_store()
226 vclock = ptp_vclock_register(ptp); in n_vclocks_store()
230 *(ptp->vclock_index + ptp->n_vclocks + i) = in n_vclocks_store()
233 dev_info(dev, "new virtual clock ptp%d\n", in n_vclocks_store()
239 if (num < ptp->n_vclocks) { in n_vclocks_store()
240 i = ptp->n_vclocks - num; in n_vclocks_store()
244 for (i = 1; i <= ptp->n_vclocks - num; i++) in n_vclocks_store()
245 *(ptp->vclock_index + ptp->n_vclocks - i) = -1; in n_vclocks_store()
249 if (!ptp->has_cycles) { in n_vclocks_store()
256 ptp->n_vclocks = num; in n_vclocks_store()
257 mutex_unlock(&ptp->n_vclocks_mux); in n_vclocks_store()
261 mutex_unlock(&ptp->n_vclocks_mux); in n_vclocks_store()
269 struct ptp_clock *ptp = dev_get_drvdata(dev); in max_vclocks_show() local
272 size = sysfs_emit(page, "%u\n", ptp->max_vclocks); in max_vclocks_show()
281 struct ptp_clock *ptp = dev_get_drvdata(dev); in max_vclocks_store() local
290 if (max == ptp->max_vclocks) in max_vclocks_store()
293 if (mutex_lock_interruptible(&ptp->n_vclocks_mux)) in max_vclocks_store()
296 if (max < ptp->n_vclocks) in max_vclocks_store()
305 size = sizeof(int) * ptp->n_vclocks; in max_vclocks_store()
306 memcpy(vclock_index, ptp->vclock_index, size); in max_vclocks_store()
308 kfree(ptp->vclock_index); in max_vclocks_store()
309 ptp->vclock_index = vclock_index; in max_vclocks_store()
310 ptp->max_vclocks = max; in max_vclocks_store()
312 mutex_unlock(&ptp->n_vclocks_mux); in max_vclocks_store()
316 mutex_unlock(&ptp->n_vclocks_mux); in max_vclocks_store()
345 struct ptp_clock *ptp = dev_get_drvdata(dev); in ptp_is_attribute_visible() local
346 struct ptp_clock_info *info = ptp->info; in ptp_is_attribute_visible()
361 if (ptp->is_virtual_clock) in ptp_is_attribute_visible()
381 static int ptp_pin_name2index(struct ptp_clock *ptp, const char *name) in ptp_pin_name2index() argument
384 for (i = 0; i < ptp->info->n_pins; i++) { in ptp_pin_name2index()
385 if (!strcmp(ptp->info->pin_config[i].name, name)) in ptp_pin_name2index()
394 struct ptp_clock *ptp = dev_get_drvdata(dev); in ptp_pin_show() local
398 index = ptp_pin_name2index(ptp, attr->attr.name); in ptp_pin_show()
402 if (mutex_lock_interruptible(&ptp->pincfg_mux)) in ptp_pin_show()
405 func = ptp->info->pin_config[index].func; in ptp_pin_show()
406 chan = ptp->info->pin_config[index].chan; in ptp_pin_show()
408 mutex_unlock(&ptp->pincfg_mux); in ptp_pin_show()
416 struct ptp_clock *ptp = dev_get_drvdata(dev); in ptp_pin_store() local
424 index = ptp_pin_name2index(ptp, attr->attr.name); in ptp_pin_store()
428 if (mutex_lock_interruptible(&ptp->pincfg_mux)) in ptp_pin_store()
430 err = ptp_set_pinfunc(ptp, index, func, chan); in ptp_pin_store()
431 mutex_unlock(&ptp->pincfg_mux); in ptp_pin_store()
438 int ptp_populate_pin_groups(struct ptp_clock *ptp) in ptp_populate_pin_groups() argument
440 struct ptp_clock_info *info = ptp->info; in ptp_populate_pin_groups()
446 ptp->pin_dev_attr = kcalloc(n_pins, sizeof(*ptp->pin_dev_attr), in ptp_populate_pin_groups()
448 if (!ptp->pin_dev_attr) in ptp_populate_pin_groups()
451 ptp->pin_attr = kcalloc(1 + n_pins, sizeof(*ptp->pin_attr), GFP_KERNEL); in ptp_populate_pin_groups()
452 if (!ptp->pin_attr) in ptp_populate_pin_groups()
456 struct device_attribute *da = &ptp->pin_dev_attr[i]; in ptp_populate_pin_groups()
462 ptp->pin_attr[i] = &da->attr; in ptp_populate_pin_groups()
465 ptp->pin_attr_group.name = "pins"; in ptp_populate_pin_groups()
466 ptp->pin_attr_group.attrs = ptp->pin_attr; in ptp_populate_pin_groups()
468 ptp->pin_attr_groups[0] = &ptp->pin_attr_group; in ptp_populate_pin_groups()
473 kfree(ptp->pin_dev_attr); in ptp_populate_pin_groups()
478 void ptp_cleanup_pin_groups(struct ptp_clock *ptp) in ptp_cleanup_pin_groups() argument
480 kfree(ptp->pin_attr); in ptp_cleanup_pin_groups()
481 kfree(ptp->pin_dev_attr); in ptp_cleanup_pin_groups()