staging: erofs: integrate decompression inplace
[linux/fpc-iii.git] / drivers / ptp / ptp_qoriq_debugfs.c
blobe8dddcedf288a6291e9333f78b962415430b7726
1 // SPDX-License-Identifier: GPL-2.0+
2 /* Copyright 2019 NXP
3 */
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 ptp_qoriq *ptp_qoriq = data;
11 struct ptp_qoriq_registers *regs = &ptp_qoriq->regs;
12 u32 ctrl;
14 ctrl = ptp_qoriq->read(&regs->ctrl_regs->tmr_ctrl);
15 *val = ctrl & PP1L ? 1 : 0;
17 return 0;
20 static int ptp_qoriq_fiper1_lpbk_set(void *data, u64 val)
22 struct ptp_qoriq *ptp_qoriq = data;
23 struct ptp_qoriq_registers *regs = &ptp_qoriq->regs;
24 u32 ctrl;
26 ctrl = ptp_qoriq->read(&regs->ctrl_regs->tmr_ctrl);
27 if (val == 0)
28 ctrl &= ~PP1L;
29 else
30 ctrl |= PP1L;
32 ptp_qoriq->write(&regs->ctrl_regs->tmr_ctrl, ctrl);
33 return 0;
36 DEFINE_DEBUGFS_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 ptp_qoriq *ptp_qoriq = data;
42 struct ptp_qoriq_registers *regs = &ptp_qoriq->regs;
43 u32 ctrl;
45 ctrl = ptp_qoriq->read(&regs->ctrl_regs->tmr_ctrl);
46 *val = ctrl & PP2L ? 1 : 0;
48 return 0;
51 static int ptp_qoriq_fiper2_lpbk_set(void *data, u64 val)
53 struct ptp_qoriq *ptp_qoriq = data;
54 struct ptp_qoriq_registers *regs = &ptp_qoriq->regs;
55 u32 ctrl;
57 ctrl = ptp_qoriq->read(&regs->ctrl_regs->tmr_ctrl);
58 if (val == 0)
59 ctrl &= ~PP2L;
60 else
61 ctrl |= PP2L;
63 ptp_qoriq->write(&regs->ctrl_regs->tmr_ctrl, ctrl);
64 return 0;
67 DEFINE_DEBUGFS_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 ptp_qoriq *ptp_qoriq)
72 struct dentry *root;
74 root = debugfs_create_dir(dev_name(ptp_qoriq->dev), NULL);
75 if (IS_ERR(root))
76 return;
77 if (!root)
78 goto err_root;
80 ptp_qoriq->debugfs_root = root;
82 if (!debugfs_create_file_unsafe("fiper1-loopback", 0600, root,
83 ptp_qoriq, &ptp_qoriq_fiper1_fops))
84 goto err_node;
85 if (!debugfs_create_file_unsafe("fiper2-loopback", 0600, root,
86 ptp_qoriq, &ptp_qoriq_fiper2_fops))
87 goto err_node;
88 return;
90 err_node:
91 debugfs_remove_recursive(root);
92 ptp_qoriq->debugfs_root = NULL;
93 err_root:
94 dev_err(ptp_qoriq->dev, "failed to initialize debugfs\n");
97 void ptp_qoriq_remove_debugfs(struct ptp_qoriq *ptp_qoriq)
99 debugfs_remove_recursive(ptp_qoriq->debugfs_root);
100 ptp_qoriq->debugfs_root = NULL;