* [U-Boot] [RFC][PATCH] cmd: clk: Add trivial implementation of clock dump for DM
@ 2018-08-08 20:10 Marek Vasut
2018-08-09 8:42 ` Ley Foon Tan
0 siblings, 1 reply; 3+ messages in thread
From: Marek Vasut @ 2018-08-08 20:10 UTC (permalink / raw)
To: u-boot
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>
---
cmd/clk.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/cmd/clk.c b/cmd/clk.c
index 73fb25092b..fd4231589c 100644
--- a/cmd/clk.c
+++ b/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,
--
2.16.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [U-Boot] [RFC][PATCH] cmd: clk: Add trivial implementation of clock dump for DM
2018-08-08 20:10 [U-Boot] [RFC][PATCH] cmd: clk: Add trivial implementation of clock dump for DM Marek Vasut
@ 2018-08-09 8:42 ` Ley Foon Tan
2018-10-02 11:20 ` Simon Glass
0 siblings, 1 reply; 3+ messages in thread
From: Ley Foon Tan @ 2018-08-09 8:42 UTC (permalink / raw)
To: u-boot
On Wed, 2018-08-08 at 22:10 +0200, Marek Vasut wrote:
> 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>
> ---
> cmd/clk.c | 37 +++++++++++++++++++++++++++++++++++++
> 1 file changed, 37 insertions(+)
>
> diff --git a/cmd/clk.c b/cmd/clk.c
> index 73fb25092b..fd4231589c 100644
> --- a/cmd/clk.c
> +++ b/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,
Reviewed-by: Ley Foon Tan <ley.foon.tan@intel.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [U-Boot] [RFC][PATCH] cmd: clk: Add trivial implementation of clock dump for DM
2018-08-09 8:42 ` Ley Foon Tan
@ 2018-10-02 11:20 ` Simon Glass
0 siblings, 0 replies; 3+ messages in thread
From: Simon Glass @ 2018-10-02 11:20 UTC (permalink / raw)
To: u-boot
On 9 August 2018 at 01:42, Ley Foon Tan <ley.foon.tan@intel.com> wrote:
> On Wed, 2018-08-08 at 22:10 +0200, Marek Vasut wrote:
>> 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>
>> ---
>> cmd/clk.c | 37 +++++++++++++++++++++++++++++++++++++
>> 1 file changed, 37 insertions(+)
Applied to u-boot-dm, and now in mainline, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-10-02 11:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-08 20:10 [U-Boot] [RFC][PATCH] cmd: clk: Add trivial implementation of clock dump for DM Marek Vasut
2018-08-09 8:42 ` Ley Foon Tan
2018-10-02 11:20 ` Simon Glass
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox