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 snprintf(page, PAGE_SIZE-1, "%s\n", ptp->info->name); in clock_name_show()
25 struct ptp_clock *ptp = dev_get_drvdata(dev); \
26 return snprintf(page, PAGE_SIZE-1, "%d\n", ptp->info->var); \
41 struct ptp_clock *ptp = dev_get_drvdata(dev); in extts_enable_store() local
42 struct ptp_clock_info *ops = ptp->info; in extts_enable_store()
66 struct ptp_clock *ptp = dev_get_drvdata(dev); in extts_fifo_show() local
67 struct timestamp_event_queue *queue = &ptp->tsevq; in extts_fifo_show()
75 if (mutex_lock_interruptible(&ptp->tsevq_mux)) in extts_fifo_show()
92 mutex_unlock(&ptp->tsevq_mux); in extts_fifo_show()
101 struct ptp_clock *ptp = dev_get_drvdata(dev); in period_store() local
102 struct ptp_clock_info *ops = ptp->info; in period_store()
129 struct ptp_clock *ptp = dev_get_drvdata(dev); in pps_enable_store() local
130 struct ptp_clock_info *ops = ptp->info; in pps_enable_store()
154 struct ptp_clock *ptp = dev_get_drvdata(dev); in unregister_vclock() local
155 struct ptp_clock_info *info = ptp->info; in unregister_vclock()
160 dev_info(dev->parent, "delete virtual clock ptp%d\n", in unregister_vclock()
176 struct ptp_clock *ptp = dev_get_drvdata(dev); in n_vclocks_show() local
179 if (mutex_lock_interruptible(&ptp->n_vclocks_mux)) in n_vclocks_show()
182 size = snprintf(page, PAGE_SIZE - 1, "%u\n", ptp->n_vclocks); in n_vclocks_show()
184 mutex_unlock(&ptp->n_vclocks_mux); in n_vclocks_show()
193 struct ptp_clock *ptp = dev_get_drvdata(dev); in n_vclocks_store() local
201 if (mutex_lock_interruptible(&ptp->n_vclocks_mux)) in n_vclocks_store()
204 if (num > ptp->max_vclocks) { in n_vclocks_store()
205 dev_err(dev, "max value is %d\n", ptp->max_vclocks); in n_vclocks_store()
210 if (num > ptp->n_vclocks) { in n_vclocks_store()
211 for (i = 0; i < num - ptp->n_vclocks; i++) { in n_vclocks_store()
212 vclock = ptp_vclock_register(ptp); in n_vclocks_store()
216 *(ptp->vclock_index + ptp->n_vclocks + i) = in n_vclocks_store()
219 dev_info(dev, "new virtual clock ptp%d\n", in n_vclocks_store()
225 if (num < ptp->n_vclocks) { in n_vclocks_store()
226 i = ptp->n_vclocks - num; in n_vclocks_store()
230 for (i = 1; i <= ptp->n_vclocks - num; i++) in n_vclocks_store()
231 *(ptp->vclock_index + ptp->n_vclocks - i) = -1; in n_vclocks_store()
239 ptp->n_vclocks = num; in n_vclocks_store()
240 mutex_unlock(&ptp->n_vclocks_mux); in n_vclocks_store()
244 mutex_unlock(&ptp->n_vclocks_mux); in n_vclocks_store()
252 struct ptp_clock *ptp = dev_get_drvdata(dev); in max_vclocks_show() local
255 size = snprintf(page, PAGE_SIZE - 1, "%u\n", ptp->max_vclocks); in max_vclocks_show()
264 struct ptp_clock *ptp = dev_get_drvdata(dev); in max_vclocks_store() local
273 if (max == ptp->max_vclocks) in max_vclocks_store()
276 if (mutex_lock_interruptible(&ptp->n_vclocks_mux)) in max_vclocks_store()
279 if (max < ptp->n_vclocks) in max_vclocks_store()
289 size = sizeof(int) * ptp->n_vclocks; in max_vclocks_store()
290 memcpy(vclock_index, ptp->vclock_index, size); in max_vclocks_store()
292 kfree(ptp->vclock_index); in max_vclocks_store()
293 ptp->vclock_index = vclock_index; in max_vclocks_store()
294 ptp->max_vclocks = max; in max_vclocks_store()
296 mutex_unlock(&ptp->n_vclocks_mux); in max_vclocks_store()
300 mutex_unlock(&ptp->n_vclocks_mux); in max_vclocks_store()
328 struct ptp_clock *ptp = dev_get_drvdata(dev); in ptp_is_attribute_visible() local
329 struct ptp_clock_info *info = ptp->info; in ptp_is_attribute_visible()
344 if (ptp->is_virtual_clock) in ptp_is_attribute_visible()
361 static int ptp_pin_name2index(struct ptp_clock *ptp, const char *name) in ptp_pin_name2index() argument
364 for (i = 0; i < ptp->info->n_pins; i++) { in ptp_pin_name2index()
365 if (!strcmp(ptp->info->pin_config[i].name, name)) in ptp_pin_name2index()
374 struct ptp_clock *ptp = dev_get_drvdata(dev); in ptp_pin_show() local
378 index = ptp_pin_name2index(ptp, attr->attr.name); in ptp_pin_show()
382 if (mutex_lock_interruptible(&ptp->pincfg_mux)) in ptp_pin_show()
385 func = ptp->info->pin_config[index].func; in ptp_pin_show()
386 chan = ptp->info->pin_config[index].chan; in ptp_pin_show()
388 mutex_unlock(&ptp->pincfg_mux); in ptp_pin_show()
396 struct ptp_clock *ptp = dev_get_drvdata(dev); in ptp_pin_store() local
404 index = ptp_pin_name2index(ptp, attr->attr.name); in ptp_pin_store()
408 if (mutex_lock_interruptible(&ptp->pincfg_mux)) in ptp_pin_store()
410 err = ptp_set_pinfunc(ptp, index, func, chan); in ptp_pin_store()
411 mutex_unlock(&ptp->pincfg_mux); in ptp_pin_store()
418 int ptp_populate_pin_groups(struct ptp_clock *ptp) in ptp_populate_pin_groups() argument
420 struct ptp_clock_info *info = ptp->info; in ptp_populate_pin_groups()
426 ptp->pin_dev_attr = kcalloc(n_pins, sizeof(*ptp->pin_dev_attr), in ptp_populate_pin_groups()
428 if (!ptp->pin_dev_attr) in ptp_populate_pin_groups()
431 ptp->pin_attr = kcalloc(1 + n_pins, sizeof(*ptp->pin_attr), GFP_KERNEL); in ptp_populate_pin_groups()
432 if (!ptp->pin_attr) in ptp_populate_pin_groups()
436 struct device_attribute *da = &ptp->pin_dev_attr[i]; in ptp_populate_pin_groups()
442 ptp->pin_attr[i] = &da->attr; in ptp_populate_pin_groups()
445 ptp->pin_attr_group.name = "pins"; in ptp_populate_pin_groups()
446 ptp->pin_attr_group.attrs = ptp->pin_attr; in ptp_populate_pin_groups()
448 ptp->pin_attr_groups[0] = &ptp->pin_attr_group; in ptp_populate_pin_groups()
453 kfree(ptp->pin_dev_attr); in ptp_populate_pin_groups()
458 void ptp_cleanup_pin_groups(struct ptp_clock *ptp) in ptp_cleanup_pin_groups() argument
460 kfree(ptp->pin_attr); in ptp_cleanup_pin_groups()
461 kfree(ptp->pin_dev_attr); in ptp_cleanup_pin_groups()