Blame view
drivers/ptp/ptp_qoriq_debugfs.c
2.32 KB
19df7510d
|
1 2 3 4 5 6 7 8 9 |
// SPDX-License-Identifier: GPL-2.0+ /* Copyright 2019 NXP */ #include <linux/device.h> #include <linux/debugfs.h> #include <linux/fsl/ptp_qoriq.h> static int ptp_qoriq_fiper1_lpbk_get(void *data, u64 *val) { |
1e562c815
|
10 11 |
struct ptp_qoriq *ptp_qoriq = data; struct ptp_qoriq_registers *regs = &ptp_qoriq->regs; |
19df7510d
|
12 |
u32 ctrl; |
f038ddf25
|
13 |
ctrl = ptp_qoriq->read(®s->ctrl_regs->tmr_ctrl); |
19df7510d
|
14 15 16 17 18 19 20 |
*val = ctrl & PP1L ? 1 : 0; return 0; } static int ptp_qoriq_fiper1_lpbk_set(void *data, u64 val) { |
1e562c815
|
21 22 |
struct ptp_qoriq *ptp_qoriq = data; struct ptp_qoriq_registers *regs = &ptp_qoriq->regs; |
19df7510d
|
23 |
u32 ctrl; |
f038ddf25
|
24 |
ctrl = ptp_qoriq->read(®s->ctrl_regs->tmr_ctrl); |
19df7510d
|
25 26 27 28 |
if (val == 0) ctrl &= ~PP1L; else ctrl |= PP1L; |
f038ddf25
|
29 |
ptp_qoriq->write(®s->ctrl_regs->tmr_ctrl, ctrl); |
19df7510d
|
30 31 |
return 0; } |
84239b445
|
32 33 34 |
DEFINE_DEBUGFS_ATTRIBUTE(ptp_qoriq_fiper1_fops, ptp_qoriq_fiper1_lpbk_get, ptp_qoriq_fiper1_lpbk_set, "%llu "); |
19df7510d
|
35 36 37 |
static int ptp_qoriq_fiper2_lpbk_get(void *data, u64 *val) { |
1e562c815
|
38 39 |
struct ptp_qoriq *ptp_qoriq = data; struct ptp_qoriq_registers *regs = &ptp_qoriq->regs; |
19df7510d
|
40 |
u32 ctrl; |
f038ddf25
|
41 |
ctrl = ptp_qoriq->read(®s->ctrl_regs->tmr_ctrl); |
19df7510d
|
42 43 44 45 46 47 48 |
*val = ctrl & PP2L ? 1 : 0; return 0; } static int ptp_qoriq_fiper2_lpbk_set(void *data, u64 val) { |
1e562c815
|
49 50 |
struct ptp_qoriq *ptp_qoriq = data; struct ptp_qoriq_registers *regs = &ptp_qoriq->regs; |
19df7510d
|
51 |
u32 ctrl; |
f038ddf25
|
52 |
ctrl = ptp_qoriq->read(®s->ctrl_regs->tmr_ctrl); |
19df7510d
|
53 54 55 56 |
if (val == 0) ctrl &= ~PP2L; else ctrl |= PP2L; |
f038ddf25
|
57 |
ptp_qoriq->write(®s->ctrl_regs->tmr_ctrl, ctrl); |
19df7510d
|
58 59 |
return 0; } |
84239b445
|
60 61 62 |
DEFINE_DEBUGFS_ATTRIBUTE(ptp_qoriq_fiper2_fops, ptp_qoriq_fiper2_lpbk_get, ptp_qoriq_fiper2_lpbk_set, "%llu "); |
19df7510d
|
63 |
|
1e562c815
|
64 |
void ptp_qoriq_create_debugfs(struct ptp_qoriq *ptp_qoriq) |
19df7510d
|
65 66 |
{ struct dentry *root; |
1e562c815
|
67 |
root = debugfs_create_dir(dev_name(ptp_qoriq->dev), NULL); |
19df7510d
|
68 69 70 71 |
if (IS_ERR(root)) return; if (!root) goto err_root; |
1e562c815
|
72 |
ptp_qoriq->debugfs_root = root; |
19df7510d
|
73 |
|
84239b445
|
74 |
if (!debugfs_create_file_unsafe("fiper1-loopback", 0600, root, |
1e562c815
|
75 |
ptp_qoriq, &ptp_qoriq_fiper1_fops)) |
19df7510d
|
76 |
goto err_node; |
84239b445
|
77 |
if (!debugfs_create_file_unsafe("fiper2-loopback", 0600, root, |
1e562c815
|
78 |
ptp_qoriq, &ptp_qoriq_fiper2_fops)) |
19df7510d
|
79 80 81 82 83 |
goto err_node; return; err_node: debugfs_remove_recursive(root); |
1e562c815
|
84 |
ptp_qoriq->debugfs_root = NULL; |
19df7510d
|
85 |
err_root: |
1e562c815
|
86 87 |
dev_err(ptp_qoriq->dev, "failed to initialize debugfs "); |
19df7510d
|
88 |
} |
1e562c815
|
89 |
void ptp_qoriq_remove_debugfs(struct ptp_qoriq *ptp_qoriq) |
19df7510d
|
90 |
{ |
1e562c815
|
91 92 |
debugfs_remove_recursive(ptp_qoriq->debugfs_root); ptp_qoriq->debugfs_root = NULL; |
19df7510d
|
93 |
} |