From: kernel@martin.sperl.org (kernel at martin.sperl.org)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v5 12/20] clk: bcm2835: expose raw clock-registers via debugfs
Date: Sun, 28 Feb 2016 15:37:03 +0000 [thread overview]
Message-ID: <1456673831-2408-13-git-send-email-kernel@martin.sperl.org> (raw)
In-Reply-To: <1456673831-2408-1-git-send-email-kernel@martin.sperl.org>
From: Martin Sperl <kernel@martin.sperl.org>
For debugging purposes under some circumstance
it helps to be able to see the actual clock registers.
E.g: when looking at the clock divider it is helpful to
see what the actual clock divider is.
This patch exposes all the clock registers specific to each
clock/pll/pll-divider via debugfs.
Signed-off-by: Martin Sperl <kernel@martin.sperl.org>
---
drivers/clk/bcm/clk-bcm2835.c | 101 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 101 insertions(+)
diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c
index 211d231..366f975 100644
--- a/drivers/clk/bcm/clk-bcm2835.c
+++ b/drivers/clk/bcm/clk-bcm2835.c
@@ -38,6 +38,7 @@
#include <linux/clk-provider.h>
#include <linux/clkdev.h>
#include <linux/clk/bcm2835.h>
+#include <linux/debugfs.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
@@ -314,6 +315,27 @@ static inline u32 cprman_read(struct bcm2835_cprman *cprman, u32 reg)
return readl(cprman->regs + reg);
}
+static int bcm2835_debugfs_regset(struct bcm2835_cprman *cprman, u32 base,
+ struct debugfs_reg32 *regs, size_t nregs,
+ struct dentry *dentry)
+{
+ struct dentry *regdump;
+ struct debugfs_regset32 *regset;
+
+ regset = devm_kzalloc(cprman->dev, sizeof(*regset), GFP_KERNEL);
+ if (!regset)
+ return -ENOMEM;
+
+ regset->regs = regs;
+ regset->nregs = nregs;
+ regset->base = cprman->regs + base;
+
+ regdump = debugfs_create_regset32("regdump", S_IRUGO, dentry,
+ regset);
+
+ return regdump ? 0 : -ENOMEM;
+}
+
/*
* These are fixed clocks. They're probably not all root clocks and it may
* be possible to turn them on and off but until this is mapped out better
@@ -627,6 +649,36 @@ static int bcm2835_pll_set_rate(struct clk_hw *hw,
return 0;
}
+static int bcm2835_pll_debug_init(struct clk_hw *hw,
+ struct dentry *dentry)
+{
+ struct bcm2835_pll *pll = container_of(hw, struct bcm2835_pll, hw);
+ struct bcm2835_cprman *cprman = pll->cprman;
+ const struct bcm2835_pll_data *data = pll->data;
+ struct debugfs_reg32 *regs;
+
+ regs = devm_kzalloc(cprman->dev, 7 * sizeof(*regs), GFP_KERNEL);
+ if (!regs)
+ return -ENOMEM;
+
+ regs[0].name = "cm_ctrl";
+ regs[0].offset = data->cm_ctrl_reg;
+ regs[1].name = "a2w_ctrl";
+ regs[1].offset = data->a2w_ctrl_reg;
+ regs[2].name = "frac";
+ regs[2].offset = data->frac_reg;
+ regs[3].name = "ana0";
+ regs[3].offset = data->ana_reg_base + 0 * 4;
+ regs[4].name = "ana1";
+ regs[4].offset = data->ana_reg_base + 1 * 4;
+ regs[5].name = "ana2";
+ regs[5].offset = data->ana_reg_base + 2 * 4;
+ regs[6].name = "ana3";
+ regs[6].offset = data->ana_reg_base + 3 * 4;
+
+ return bcm2835_debugfs_regset(cprman, 0, regs, 7, dentry);
+}
+
static const struct clk_ops bcm2835_pll_clk_ops = {
.is_prepared = bcm2835_pll_is_on,
.prepare = bcm2835_pll_on,
@@ -634,6 +686,7 @@ static const struct clk_ops bcm2835_pll_clk_ops = {
.recalc_rate = bcm2835_pll_get_rate,
.set_rate = bcm2835_pll_set_rate,
.round_rate = bcm2835_pll_round_rate,
+ .debug_init = bcm2835_pll_debug_init,
};
struct bcm2835_pll_divider {
@@ -725,6 +778,26 @@ static int bcm2835_pll_divider_set_rate(struct clk_hw *hw,
return 0;
}
+static int bcm2835_pll_divider_debug_init(struct clk_hw *hw,
+ struct dentry *dentry)
+{
+ struct bcm2835_pll_divider *divider = bcm2835_pll_divider_from_hw(hw);
+ struct bcm2835_cprman *cprman = divider->cprman;
+ const struct bcm2835_pll_divider_data *data = divider->data;
+ struct debugfs_reg32 *regs;
+
+ regs = devm_kzalloc(cprman->dev, 7 * sizeof(*regs), GFP_KERNEL);
+ if (!regs)
+ return -ENOMEM;
+
+ regs[0].name = "cm";
+ regs[0].offset = data->cm_reg;
+ regs[1].name = "a2w";
+ regs[1].offset = data->a2w_reg;
+
+ return bcm2835_debugfs_regset(cprman, 0, regs, 2, dentry);
+}
+
static const struct clk_ops bcm2835_pll_divider_clk_ops = {
.is_prepared = bcm2835_pll_divider_is_on,
.prepare = bcm2835_pll_divider_on,
@@ -732,6 +805,7 @@ static const struct clk_ops bcm2835_pll_divider_clk_ops = {
.recalc_rate = bcm2835_pll_divider_get_rate,
.set_rate = bcm2835_pll_divider_set_rate,
.round_rate = bcm2835_pll_divider_round_rate,
+ .debug_init = bcm2835_pll_divider_debug_init,
};
/*
@@ -971,6 +1045,31 @@ static u8 bcm2835_clock_get_parent(struct clk_hw *hw)
return (src & CM_SRC_MASK) >> CM_SRC_SHIFT;
}
+static struct debugfs_reg32 bcm2835_debugfs_clock_reg32[] = {
+ {
+ .name = "ctl",
+ .offset = 0,
+ },
+ {
+ .name = "div",
+ .offset = 4,
+ },
+};
+
+static int bcm2835_clock_debug_init(struct clk_hw *hw,
+ struct dentry *dentry)
+{
+ struct bcm2835_clock *clock = bcm2835_clock_from_hw(hw);
+ struct bcm2835_cprman *cprman = clock->cprman;
+ const struct bcm2835_clock_data *data = clock->data;
+
+ return bcm2835_debugfs_regset(
+ cprman, data->ctl_reg,
+ bcm2835_debugfs_clock_reg32,
+ ARRAY_SIZE(bcm2835_debugfs_clock_reg32),
+ dentry);
+}
+
static const struct clk_ops bcm2835_clock_clk_ops = {
.is_prepared = bcm2835_clock_is_on,
.prepare = bcm2835_clock_on,
@@ -980,6 +1079,7 @@ static const struct clk_ops bcm2835_clock_clk_ops = {
.determine_rate = bcm2835_clock_determine_rate,
.set_parent = bcm2835_clock_set_parent,
.get_parent = bcm2835_clock_get_parent,
+ .debug_init = bcm2835_clock_debug_init,
};
static int bcm2835_vpu_clock_is_on(struct clk_hw *hw)
@@ -998,6 +1098,7 @@ static const struct clk_ops bcm2835_vpu_clock_clk_ops = {
.determine_rate = bcm2835_clock_determine_rate,
.set_parent = bcm2835_clock_set_parent,
.get_parent = bcm2835_clock_get_parent,
+ .debug_init = bcm2835_clock_debug_init,
};
static struct clk *bcm2835_register_pll(struct bcm2835_cprman *cprman,
--
1.7.10.4
next prev parent reply other threads:[~2016-02-28 15:37 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-28 15:36 [PATCH v5 00/20] add additional clocks and frac/mash support kernel at martin.sperl.org
2016-02-28 15:36 ` [PATCH v5 01/20] clk: bcm2835: pll_off should only set CM_PLL_ANARST kernel at martin.sperl.org
2016-02-28 17:58 ` Stefan Wahren
2016-02-28 15:36 ` [PATCH v5 02/20] clk: bcm2835: clean up coding style issues kernel at martin.sperl.org
2016-02-28 15:36 ` [PATCH v5 03/20] clk: bcm2835: add locking to pll*_on/off methods kernel at martin.sperl.org
2016-02-28 18:04 ` Stefan Wahren
2016-02-28 15:36 ` [PATCH v5 04/20] clk: bcm2835: remove uart0/1_pclk fixed clocks kernel at martin.sperl.org
2016-02-28 15:36 ` [PATCH v5 05/20] clk: bcm2835: enable clocks that have been enabled by firmware kernel at martin.sperl.org
2016-02-28 15:36 ` [PATCH v5 06/20] clk: bcm2835: remove use of BCM2835_CLOCK_COUNT in driver kernel at martin.sperl.org
2016-02-28 15:36 ` [PATCH v5 07/20] clk: bcm2835: reorganize bcm2835_clock_array assignment kernel at martin.sperl.org
2016-02-28 15:36 ` [PATCH v5 08/20] clk: bcm2835: add fractional support kernel at martin.sperl.org
2016-02-28 15:37 ` [PATCH v5 09/20] clk: bcm2835: enable management of PCM clock kernel at martin.sperl.org
2016-02-28 15:37 ` [PATCH v5 10/20] clk: bcm2835: implement correct clamping for mash clocks kernel at martin.sperl.org
2016-02-28 15:37 ` [PATCH v5 11/20] clk: bcm2835: divider value has to be 1 or more kernel at martin.sperl.org
2016-02-28 15:37 ` kernel at martin.sperl.org [this message]
2016-02-28 15:37 ` [PATCH v5 13/20] clk: bcm2835: expose current divider, parent and mash via debugfs kernel at martin.sperl.org
2016-02-28 15:37 ` [PATCH v5 14/20] clk: bcm2835: added missing PLL clock divider kernel at martin.sperl.org
2016-02-28 15:37 ` [PATCH v5 15/20] clk: bcm2835: add additional clocks kernel at martin.sperl.org
2016-02-28 15:37 ` [PATCH v5 16/20] clk: bcm2835: add the camera related clocks cam0, cam1 and ccp2 kernel at martin.sperl.org
2016-02-28 15:37 ` [PATCH v5 17/20] clk: bcm2835: add the dsi clocks kernel at martin.sperl.org
2016-02-28 15:37 ` [PATCH v5 18/20] clk: bcm2835: add arm clock kernel at martin.sperl.org
2016-02-28 15:37 ` [PATCH v5 19/20] clk: bcm2835: add gates that require PM_DEBUG to be set kernel at martin.sperl.org
2016-02-28 17:48 ` [PATCH v5 00/20] add additional clocks and frac/mash support Stefan Wahren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1456673831-2408-13-git-send-email-kernel@martin.sperl.org \
--to=kernel@martin.sperl.org \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).