2019-01-21 10:41:42 +00:00
|
|
|
// 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)
|
|
|
|
{
|
2019-02-12 04:23:56 +00:00
|
|
|
struct ptp_qoriq *ptp_qoriq = data;
|
|
|
|
struct ptp_qoriq_registers *regs = &ptp_qoriq->regs;
|
2019-01-21 10:41:42 +00:00
|
|
|
u32 ctrl;
|
|
|
|
|
2019-02-12 04:23:59 +00:00
|
|
|
ctrl = ptp_qoriq->read(®s->ctrl_regs->tmr_ctrl);
|
2019-01-21 10:41:42 +00:00
|
|
|
*val = ctrl & PP1L ? 1 : 0;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ptp_qoriq_fiper1_lpbk_set(void *data, u64 val)
|
|
|
|
{
|
2019-02-12 04:23:56 +00:00
|
|
|
struct ptp_qoriq *ptp_qoriq = data;
|
|
|
|
struct ptp_qoriq_registers *regs = &ptp_qoriq->regs;
|
2019-01-21 10:41:42 +00:00
|
|
|
u32 ctrl;
|
|
|
|
|
2019-02-12 04:23:59 +00:00
|
|
|
ctrl = ptp_qoriq->read(®s->ctrl_regs->tmr_ctrl);
|
2019-01-21 10:41:42 +00:00
|
|
|
if (val == 0)
|
|
|
|
ctrl &= ~PP1L;
|
|
|
|
else
|
|
|
|
ctrl |= PP1L;
|
|
|
|
|
2019-02-12 04:23:59 +00:00
|
|
|
ptp_qoriq->write(®s->ctrl_regs->tmr_ctrl, ctrl);
|
2019-01-21 10:41:42 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-01-25 02:28:59 +00:00
|
|
|
DEFINE_DEBUGFS_ATTRIBUTE(ptp_qoriq_fiper1_fops, ptp_qoriq_fiper1_lpbk_get,
|
|
|
|
ptp_qoriq_fiper1_lpbk_set, "%llu\n");
|
2019-01-21 10:41:42 +00:00
|
|
|
|
|
|
|
static int ptp_qoriq_fiper2_lpbk_get(void *data, u64 *val)
|
|
|
|
{
|
2019-02-12 04:23:56 +00:00
|
|
|
struct ptp_qoriq *ptp_qoriq = data;
|
|
|
|
struct ptp_qoriq_registers *regs = &ptp_qoriq->regs;
|
2019-01-21 10:41:42 +00:00
|
|
|
u32 ctrl;
|
|
|
|
|
2019-02-12 04:23:59 +00:00
|
|
|
ctrl = ptp_qoriq->read(®s->ctrl_regs->tmr_ctrl);
|
2019-01-21 10:41:42 +00:00
|
|
|
*val = ctrl & PP2L ? 1 : 0;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ptp_qoriq_fiper2_lpbk_set(void *data, u64 val)
|
|
|
|
{
|
2019-02-12 04:23:56 +00:00
|
|
|
struct ptp_qoriq *ptp_qoriq = data;
|
|
|
|
struct ptp_qoriq_registers *regs = &ptp_qoriq->regs;
|
2019-01-21 10:41:42 +00:00
|
|
|
u32 ctrl;
|
|
|
|
|
2019-02-12 04:23:59 +00:00
|
|
|
ctrl = ptp_qoriq->read(®s->ctrl_regs->tmr_ctrl);
|
2019-01-21 10:41:42 +00:00
|
|
|
if (val == 0)
|
|
|
|
ctrl &= ~PP2L;
|
|
|
|
else
|
|
|
|
ctrl |= PP2L;
|
|
|
|
|
2019-02-12 04:23:59 +00:00
|
|
|
ptp_qoriq->write(®s->ctrl_regs->tmr_ctrl, ctrl);
|
2019-01-21 10:41:42 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-01-25 02:28:59 +00:00
|
|
|
DEFINE_DEBUGFS_ATTRIBUTE(ptp_qoriq_fiper2_fops, ptp_qoriq_fiper2_lpbk_get,
|
|
|
|
ptp_qoriq_fiper2_lpbk_set, "%llu\n");
|
2019-01-21 10:41:42 +00:00
|
|
|
|
2019-02-12 04:23:56 +00:00
|
|
|
void ptp_qoriq_create_debugfs(struct ptp_qoriq *ptp_qoriq)
|
2019-01-21 10:41:42 +00:00
|
|
|
{
|
|
|
|
struct dentry *root;
|
|
|
|
|
2019-02-12 04:23:56 +00:00
|
|
|
root = debugfs_create_dir(dev_name(ptp_qoriq->dev), NULL);
|
2019-01-21 10:41:42 +00:00
|
|
|
if (IS_ERR(root))
|
|
|
|
return;
|
|
|
|
if (!root)
|
|
|
|
goto err_root;
|
|
|
|
|
2019-02-12 04:23:56 +00:00
|
|
|
ptp_qoriq->debugfs_root = root;
|
2019-01-21 10:41:42 +00:00
|
|
|
|
2019-01-25 02:28:59 +00:00
|
|
|
if (!debugfs_create_file_unsafe("fiper1-loopback", 0600, root,
|
2019-02-12 04:23:56 +00:00
|
|
|
ptp_qoriq, &ptp_qoriq_fiper1_fops))
|
2019-01-21 10:41:42 +00:00
|
|
|
goto err_node;
|
2019-01-25 02:28:59 +00:00
|
|
|
if (!debugfs_create_file_unsafe("fiper2-loopback", 0600, root,
|
2019-02-12 04:23:56 +00:00
|
|
|
ptp_qoriq, &ptp_qoriq_fiper2_fops))
|
2019-01-21 10:41:42 +00:00
|
|
|
goto err_node;
|
|
|
|
return;
|
|
|
|
|
|
|
|
err_node:
|
|
|
|
debugfs_remove_recursive(root);
|
2019-02-12 04:23:56 +00:00
|
|
|
ptp_qoriq->debugfs_root = NULL;
|
2019-01-21 10:41:42 +00:00
|
|
|
err_root:
|
2019-02-12 04:23:56 +00:00
|
|
|
dev_err(ptp_qoriq->dev, "failed to initialize debugfs\n");
|
2019-01-21 10:41:42 +00:00
|
|
|
}
|
|
|
|
|
2019-02-12 04:23:56 +00:00
|
|
|
void ptp_qoriq_remove_debugfs(struct ptp_qoriq *ptp_qoriq)
|
2019-01-21 10:41:42 +00:00
|
|
|
{
|
2019-02-12 04:23:56 +00:00
|
|
|
debugfs_remove_recursive(ptp_qoriq->debugfs_root);
|
|
|
|
ptp_qoriq->debugfs_root = NULL;
|
2019-01-21 10:41:42 +00:00
|
|
|
}
|