mirror of
https://github.com/linux-sunxi/u-boot-sunxi.git
synced 2024-02-12 11:16:03 +08:00
cmd: clk: Add trivial implementation of clock dump for DM
Add trivial implementation of the clk dump in case DM is enabled. This implementation just iterates over all the clock registered with the CLK uclass and prints their rate. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Chin Liang See <chin.liang.see@intel.com> Cc: Dinh Nguyen <dinguyen@kernel.org> Cc: Ley Foon Tan <ley.foon.tan@intel.com> Cc: Simon Glass <sjg@chromium.org> Cc: Tom Rini <trini@konsulko.com> Reviewed-by: Ley Foon Tan <ley.foon.tan@intel.com>
This commit is contained in:
37
cmd/clk.c
37
cmd/clk.c
@ -5,11 +5,48 @@
|
||||
#include <common.h>
|
||||
#include <command.h>
|
||||
#include <clk.h>
|
||||
#if defined(CONFIG_DM) && defined(CONFIG_CLK)
|
||||
#include <dm.h>
|
||||
#include <dm/device-internal.h>
|
||||
#endif
|
||||
|
||||
int __weak soc_clk_dump(void)
|
||||
{
|
||||
#if defined(CONFIG_DM) && defined(CONFIG_CLK)
|
||||
struct udevice *dev;
|
||||
struct uclass *uc;
|
||||
struct clk clk;
|
||||
int ret;
|
||||
|
||||
/* Device addresses start at 1 */
|
||||
ret = uclass_get(UCLASS_CLK, &uc);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
uclass_foreach_dev(dev, uc) {
|
||||
memset(&clk, 0, sizeof(clk));
|
||||
ret = device_probe(dev);
|
||||
if (ret) {
|
||||
printf("%-30.30s : ? Hz\n", dev->name);
|
||||
continue;
|
||||
}
|
||||
|
||||
ret = clk_request(dev, &clk);
|
||||
if (ret) {
|
||||
printf("%-30.30s : ? Hz\n", dev->name);
|
||||
continue;
|
||||
}
|
||||
|
||||
printf("%-30.30s : %lu Hz\n", dev->name, clk_get_rate(&clk));
|
||||
|
||||
clk_free(&clk);
|
||||
}
|
||||
|
||||
return 0;
|
||||
#else
|
||||
puts("Not implemented\n");
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int do_clk_dump(cmd_tbl_t *cmdtp, int flag, int argc,
|
||||
|
Reference in New Issue
Block a user