clk: support clk tree dump
The previous code only dump the clk list. This patch is to support clk tree dump, and also dump the enable_cnt. The code used in patch is similar to dm_dump_all, but the code here only filter out the UCLASS_CLK devices. On i.MX8MM, Partial output: u-boot=> clk dump Rate Usecnt Name ------------------------------------------ 24000000 0 |-- clock-osc-24m 24000000 0 | |-- dram_pll_ref_sel 750000000 0 | | `-- dram_pll 750000000 0 | | `-- dram_pll_bypass 750000000 0 | | `-- dram_pll_out 24000000 0 | |-- arm_pll_ref_sel 1200000000 0 | | `-- arm_pll 1200000000 0 | | `-- arm_pll_bypass 1200000000 0 | | `-- arm_pll_out 1200000000 0 | | `-- arm_a53_src 1200000000 0 | | `-- arm_a53_cg 1200000000 0 | | `-- arm_a53_div 24000000 4 | |-- sys_pll1_ref_sel 800000000 4 | | `-- sys_pll1 800000000 4 | | `-- sys_pll1_bypass 800000000 4 | | `-- sys_pll1_out 40000000 0 | | |-- sys_pll1_40m Signed-off-by: Peng Fan <peng.fan@nxp.com>
This commit is contained in:
parent
0520be0f67
commit
aeeb2e6d9c
83
cmd/clk.c
83
cmd/clk.c
@ -7,51 +7,70 @@
|
|||||||
#include <clk.h>
|
#include <clk.h>
|
||||||
#if defined(CONFIG_DM) && defined(CONFIG_CLK)
|
#if defined(CONFIG_DM) && defined(CONFIG_CLK)
|
||||||
#include <dm.h>
|
#include <dm.h>
|
||||||
|
#include <dm/device.h>
|
||||||
|
#include <dm/root.h>
|
||||||
#include <dm/device-internal.h>
|
#include <dm/device-internal.h>
|
||||||
|
#include <linux/clk-provider.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_DM) && defined(CONFIG_CLK)
|
||||||
|
static void show_clks(struct udevice *dev, int depth, int last_flag)
|
||||||
|
{
|
||||||
|
int i, is_last;
|
||||||
|
struct udevice *child;
|
||||||
|
struct clk *clkp;
|
||||||
|
u32 rate;
|
||||||
|
|
||||||
|
clkp = dev_get_clk_ptr(dev);
|
||||||
|
if (device_get_uclass_id(dev) == UCLASS_CLK && clkp) {
|
||||||
|
rate = clk_get_rate(clkp);
|
||||||
|
|
||||||
|
printf(" %-12u %8d ", rate, clkp->enable_count);
|
||||||
|
|
||||||
|
for (i = depth; i >= 0; i--) {
|
||||||
|
is_last = (last_flag >> i) & 1;
|
||||||
|
if (i) {
|
||||||
|
if (is_last)
|
||||||
|
printf(" ");
|
||||||
|
else
|
||||||
|
printf("| ");
|
||||||
|
} else {
|
||||||
|
if (is_last)
|
||||||
|
printf("`-- ");
|
||||||
|
else
|
||||||
|
printf("|-- ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%s\n", dev->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
list_for_each_entry(child, &dev->child_head, sibling_node) {
|
||||||
|
is_last = list_is_last(&child->sibling_node, &dev->child_head);
|
||||||
|
show_clks(child, depth + 1, (last_flag << 1) | is_last);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int __weak soc_clk_dump(void)
|
int __weak soc_clk_dump(void)
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_DM) && defined(CONFIG_CLK)
|
struct udevice *root;
|
||||||
struct udevice *dev;
|
|
||||||
struct uclass *uc;
|
|
||||||
struct clk clk;
|
|
||||||
int ret;
|
|
||||||
ulong rate;
|
|
||||||
|
|
||||||
/* Device addresses start at 1 */
|
root = dm_root();
|
||||||
ret = uclass_get(UCLASS_CLK, &uc);
|
if (root) {
|
||||||
if (ret)
|
printf(" Rate Usecnt Name\n");
|
||||||
return ret;
|
printf("------------------------------------------\n");
|
||||||
|
show_clks(root, -1, 0);
|
||||||
uclass_foreach_dev(dev, uc) {
|
|
||||||
memset(&clk, 0, sizeof(clk));
|
|
||||||
ret = device_probe(dev);
|
|
||||||
if (ret)
|
|
||||||
goto noclk;
|
|
||||||
|
|
||||||
ret = clk_request(dev, &clk);
|
|
||||||
if (ret)
|
|
||||||
goto noclk;
|
|
||||||
|
|
||||||
rate = clk_get_rate(&clk);
|
|
||||||
clk_free(&clk);
|
|
||||||
|
|
||||||
if (rate == -ENODEV)
|
|
||||||
goto noclk;
|
|
||||||
|
|
||||||
printf("%-30.30s : %lu Hz\n", dev->name, rate);
|
|
||||||
continue;
|
|
||||||
noclk:
|
|
||||||
printf("%-30.30s : ? Hz\n", dev->name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
|
int __weak soc_clk_dump(void)
|
||||||
|
{
|
||||||
puts("Not implemented\n");
|
puts("Not implemented\n");
|
||||||
return 1;
|
return 1;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int do_clk_dump(cmd_tbl_t *cmdtp, int flag, int argc,
|
static int do_clk_dump(cmd_tbl_t *cmdtp, int flag, int argc,
|
||||||
char *const argv[])
|
char *const argv[])
|
||||||
|
Loading…
Reference in New Issue
Block a user