1 // SPDX-License-Identifier: GPL-2.0+
4 #include <linux/device.h>
5 #include <linux/debugfs.h>
6 #include <linux/fsl/ptp_qoriq.h>
8 static int ptp_qoriq_fiper1_lpbk_get(void *data, u64 *val)
10 struct qoriq_ptp *qoriq_ptp = data;
11 struct qoriq_ptp_registers *regs = &qoriq_ptp->regs;
14 ctrl = qoriq_read(®s->ctrl_regs->tmr_ctrl);
15 *val = ctrl & PP1L ? 1 : 0;
20 static int ptp_qoriq_fiper1_lpbk_set(void *data, u64 val)
22 struct qoriq_ptp *qoriq_ptp = data;
23 struct qoriq_ptp_registers *regs = &qoriq_ptp->regs;
26 ctrl = qoriq_read(®s->ctrl_regs->tmr_ctrl);
32 qoriq_write(®s->ctrl_regs->tmr_ctrl, ctrl);
36 DEFINE_SIMPLE_ATTRIBUTE(ptp_qoriq_fiper1_fops, ptp_qoriq_fiper1_lpbk_get,
37 ptp_qoriq_fiper1_lpbk_set, "%llu\n");
39 static int ptp_qoriq_fiper2_lpbk_get(void *data, u64 *val)
41 struct qoriq_ptp *qoriq_ptp = data;
42 struct qoriq_ptp_registers *regs = &qoriq_ptp->regs;
45 ctrl = qoriq_read(®s->ctrl_regs->tmr_ctrl);
46 *val = ctrl & PP2L ? 1 : 0;
51 static int ptp_qoriq_fiper2_lpbk_set(void *data, u64 val)
53 struct qoriq_ptp *qoriq_ptp = data;
54 struct qoriq_ptp_registers *regs = &qoriq_ptp->regs;
57 ctrl = qoriq_read(®s->ctrl_regs->tmr_ctrl);
63 qoriq_write(®s->ctrl_regs->tmr_ctrl, ctrl);
67 DEFINE_SIMPLE_ATTRIBUTE(ptp_qoriq_fiper2_fops, ptp_qoriq_fiper2_lpbk_get,
68 ptp_qoriq_fiper2_lpbk_set, "%llu\n");
70 void ptp_qoriq_create_debugfs(struct qoriq_ptp *qoriq_ptp)
74 root = debugfs_create_dir(dev_name(qoriq_ptp->dev), NULL);
80 qoriq_ptp->debugfs_root = root;
82 if (!debugfs_create_file("fiper1-loopback", 0600, root, qoriq_ptp,
83 &ptp_qoriq_fiper1_fops))
85 if (!debugfs_create_file("fiper2-loopback", 0600, root, qoriq_ptp,
86 &ptp_qoriq_fiper2_fops))
91 debugfs_remove_recursive(root);
92 qoriq_ptp->debugfs_root = NULL;
94 dev_err(qoriq_ptp->dev, "failed to initialize debugfs\n");
97 void ptp_qoriq_remove_debugfs(struct qoriq_ptp *qoriq_ptp)
99 debugfs_remove_recursive(qoriq_ptp->debugfs_root);
100 qoriq_ptp->debugfs_root = NULL;