Skip to contentSkip to conversation

display proper CPU frequency on hifive-unleashed

PATCH Superseded Sagar Shrikant Kadam 3 participants 9 messages Feb 18, 2020 – Feb 24, 2020

Subsystems (3)

v1 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

cover display proper CPU frequency on hifive-unleashed

U-Boot cmd "cpu detail" shows wrong values, as the current cpu driver is fetching cpu_freq by reading the dt node property "clock-frequency". There should be a fallback mechanism to handle a case where this property if not present in DT it should be read from the prci driver.

This patch series uses the clk_get_rate method to fetch proper core clock frequency. The series is based on U-Boot commit f2a73d6867ef ("Merge tag 'u-boot-stm32-20200214' of https://gitlab.denx.de/u-boot/custodians/u-boot-stm")

Thanks to Vincent Chen <[email protected]> for testing this patch.

=>-----------------------Log for reference------------------------ => cpu detail
0: cpu at 1 rv64imafdc

        ID = 1, freq = 4.30 GHz		<= Before patch
  1: cpu at 2      rv64imafdc
        ID = 2, freq = 4.30 GHz
  2: cpu at 3      rv64imafdc
        ID = 3, freq = 4.30 GHz
  3: cpu@4      rv64imafdc
        ID = 4, freq = 4.30 GHz

.................................................................

=> cpu detail
0: cpu at 1 rv64imafdc

        ID = 1, freq = 999.100 MHz	<= After patch
  1: cpu at 2      rv64imafdc
        ID = 2, freq = 999.100 MHz
  2: cpu at 3      rv64imafdc
        ID = 3, freq = 999.100 MHz
  3: cpu@4      rv64imafdc
        ID = 4, freq = 999.100 MHz

Sagar Shrikant Kadam (2):
fu540: prci: add request and free clock handlers
cpu: clk: riscv: populate proper CPU core clk frequency

 drivers/clk/sifive/fu540-prci.c | 24 ++++++++++++++++++++++++
 drivers/cpu/riscv_cpu.c         | 39 ++++++++++++++++++++++++++++++++++++++-
 2 files changed, 62 insertions(+), 1 deletion(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/2 fu540: prci: add request and free clock handlers

Add handlers to check if a valid clock id is used to request clock by any driver using clk_request/clk_free API calls.

---
 drivers/clk/sifive/fu540-prci.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/clk/sifive/fu540-prci.c +24 -0
index 8847178..ecf29a0 100644
@@ -580,6 +580,28 @@ static ulong sifive_fu540_prci_set_rate(struct clk *clk, ulong rate)
 	return rate;
 }
 
+static int sifive_fu540_prci_clk_request(struct clk *clk)
+{
+	debug("%s(clk=%p) (dev=%p, id=%lu)\n", __func__, clk, clk->dev,
+	      clk->id);
+
+	if (clk->id >= ARRAY_SIZE(__prci_init_clocks))
+		return -EINVAL;
+
+	return 0;
+}
+
+static int sifive_fu540_prci_clk_free(struct clk *clk)
+{
+	debug("%s(clk=%p) (dev=%p, id=%lu)\n", __func__, clk, clk->dev,
+	      clk->id);
+
+	if (clk->id >= ARRAY_SIZE(__prci_init_clocks))
+		return -EINVAL;
+
+	return 0;
+}
+
 static int sifive_fu540_prci_probe(struct udevice *dev)
 {
 	int i, err;
@@ -611,6 +633,8 @@ static int sifive_fu540_prci_probe(struct udevice *dev)
 static struct clk_ops sifive_fu540_prci_ops = {
 	.set_rate = sifive_fu540_prci_set_rate,
 	.get_rate = sifive_fu540_prci_get_rate,
+	.request  = sifive_fu540_prci_clk_request,
+	.rfree	  = sifive_fu540_prci_clk_free,
 };
 
 static const struct udevice_id sifive_fu540_prci_ids[] = {
Signature · 1 line
2.7.4
#2 lore raw

PATCH 1/2 fu540: prci: add request and free clock handlers

drivers/clk/sifive/fu540-prci.c static ulong sifive_fu540_prci_set_rate(struct clk *clk, ulong rate) · line 604

Quoted 11 lines · Sagar Shrikant Kadam
drivers/clk/sifive/fu540-prci.c +11 -0
+static int sifive_fu540_prci_clk_free(struct clk *clk)
+{
+	debug("%s(clk=%p) (dev=%p, id=%lu)\n", __func__, clk, clk->dev,
+	      clk->id);
+
+	if (clk->id >= ARRAY_SIZE(__prci_init_clocks))
+		return -EINVAL;
+
+	return 0;
+}
+

I don't think this function is necessary, since no struct clk should be passed to clk_free except one which was previously successfully requested.

drivers/clk/sifive/fu540-prci.c static int sifive_fu540_prci_probe(struct udevice *dev) · line 640

Quoted 13 lines

static int sifive_fu540_prci_probe(struct udevice *dev) {

drivers/clk/sifive/fu540-prci.c +2 -0
 	int i, err;
@@ -611,6 +633,8 @@ static int sifive_fu540_prci_probe(struct udevice *dev)
 static struct clk_ops sifive_fu540_prci_ops = {
 	.set_rate = sifive_fu540_prci_set_rate,
 	.get_rate = sifive_fu540_prci_get_rate,
+	.request  = sifive_fu540_prci_clk_request,
+	.rfree	  = sifive_fu540_prci_clk_free,
 };
 
 static const struct udevice_id sifive_fu540_prci_ids[] = {

--Sean

#3 lore raw

PATCH 1/2 fu540: prci: add request and free clock handlers

Hi Sean,

Quoted 10 lines

-----Original Message-----
From: Sean Anderson <[email protected]>
Sent: Friday, February 21, 2020 11:53 AM
To: Sagar Kadam <[email protected]>; u-boot at lists.denx.de
Cc: lukma at denx.de; bmeng.cn at gmail.com; Anup.Patel at wdc.com; Paul Walmsley ( Sifive) <[email protected]>; Vincent Chen <[email protected]>
Subject: Re: [PATCH v1 1/2] fu540: prci: add request and free clock handlers

On 2/18/20 11:13 AM, Sagar Shrikant Kadam wrote:

Quoted 14 lines

drivers/clk/sifive/fu540-prci.c static ulong sifive_fu540_prci_set_rate(struct clk *clk, ulong rate) · line 593

Quoted 10 lines
drivers/clk/sifive/fu540-prci.c +10 -0
+static int sifive_fu540_prci_clk_free(struct clk *clk) {
+	debug("%s(clk=%p) (dev=%p, id=%lu)\n", __func__, clk, clk->dev,
+	      clk->id);
+
+	if (clk->id >= ARRAY_SIZE(__prci_init_clocks))
+		return -EINVAL;
+
+	return 0;
+}
+

I don't think this function is necessary, since no struct clk should be passed to clk_free except one which was previously successfully requested.

Thanks for suggestion.
I can drop this id check and keep the debug message as done in other similar drivers.

BR,
Sagar Kadam

Quoted 14 lines

drivers/clk/sifive/fu540-prci.c static int sifive_fu540_prci_probe(struct udevice · line 640

Quoted 12 lines

static int sifive_fu540_prci_probe(struct udevice *dev) {

drivers/clk/sifive/fu540-prci.c +2 -0
 	int i, err;
@@ -611,6 +633,8 @@ static int sifive_fu540_prci_probe(struct udevice
 *dev)  static struct clk_ops sifive_fu540_prci_ops = {
 	.set_rate = sifive_fu540_prci_set_rate,
 	.get_rate = sifive_fu540_prci_get_rate,
+	.request  = sifive_fu540_prci_clk_request,
+	.rfree	  = sifive_fu540_prci_clk_free,
 };
 
 static const struct udevice_id sifive_fu540_prci_ids[] = {

--Sean

#4 lore raw

PATCH 2/2 cpu: clk: riscv: populate proper CPU core clk frequency

In reply to Sagar Shrikant Kadam

Fetch core clock frequency from prci if clock-frequency for CPU nodes is missing in device tree, so that the cmd "#cpu detail" will show the correct CPU frequency.

U-Boot command "#cpu detail" is showing wrong frequency values. This patch fixes this issue by getting the core clock set in prci driver if clock-frequency is not added to CPU nodes in device tree. It is tested on HiFive Unleashed A00 board.

---
 drivers/cpu/riscv_cpu.c | 39 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 38 insertions(+), 1 deletion(-)
drivers/cpu/riscv_cpu.c +38 -1
index 28ad0aa..eb5491f 100644
@@ -9,6 +9,8 @@
 #include <errno.h>
 #include <dm/device-internal.h>
 #include <dm/lists.h>
+#include <clk-uclass.h>
+#include <dt-bindings/clock/sifive-fu540-prci.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -25,11 +27,46 @@ static int riscv_cpu_get_desc(struct udevice *dev, char *buf, int size)
 	return 0;
 }
 
+static ulong riscv_get_clkrate(int clk_index)
+{
+	int ret;
+	struct udevice *dev;
+	struct clk clk;
+	ulong rate;
+
+	ret = uclass_get_device_by_driver(UCLASS_CLK,
+					  DM_GET_DRIVER(sifive_fu540_prci),
+					  &dev);
+	if (ret < 0) {
+		pr_err("%s: Could not get device driver\n", __func__);
+		return ret;
+	}
+
+	clk.id = clk_index;
+	ret = clk_request(dev, &clk);
+	if (ret < 0) {
+		pr_err("%s: request to clock device failed...\n", __func__);
+		return ret;
+	}
+
+	rate = clk_get_rate(&clk);
+
+	clk_free(&clk);
+
+	return rate;
+}
+
 static int riscv_cpu_get_info(struct udevice *dev, struct cpu_info *info)
 {
 	const char *mmu;
+	int ret;
 
-	dev_read_u32(dev, "clock-frequency", (u32 *)&info->cpu_freq);
+	ret = dev_read_u32(dev, "clock-frequency", (u32 *)&info->cpu_freq);
+	if (ret) {
+		/* if clock-frequency is missing in DT, read it from prci */
+		debug("Fetch core clk configured by prci\n");
+		info->cpu_freq = riscv_get_clkrate(PRCI_CLK_COREPLL);
+	}
 
 	mmu = dev_read_string(dev, "mmu-type");
 	if (!mmu)
Signature · 1 line
2.7.4
#5 lore raw

PATCH 2/2 cpu: clk: riscv: populate proper CPU core clk frequency

+Sean Anderson

Hi Sagar,

Quoted 21 lines · Sagar Shrikant Kadam

Fetch core clock frequency from prci if clock-frequency for CPU nodes is missing in device tree, so that the cmd "#cpu detail" will show the correct CPU frequency.

U-Boot command "#cpu detail" is showing wrong frequency values. This patch fixes this issue by getting the core clock set in prci driver if clock-frequency is not added to CPU nodes in device tree. It is tested on HiFive Unleashed A00 board.

---
 drivers/cpu/riscv_cpu.c | 39 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 38 insertions(+), 1 deletion(-)
drivers/cpu/riscv_cpu.c +0 -0
index 28ad0aa..eb5491f 100644

drivers/cpu/riscv_cpu.c line 13

Quoted 5 lines
drivers/cpu/riscv_cpu.c +2 -0
@@ -9,6 +9,8 @@
 #include <errno.h>
 #include <dm/device-internal.h>
 #include <dm/lists.h>
+#include <clk-uclass.h>
+#include <dt-bindings/clock/sifive-fu540-prci.h>

It's wrong to include a SoC specific header file in a generic driver.

Quoted 42 lines
drivers/cpu/riscv_cpu.c +30 -1
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -25,11 +27,46 @@ static int riscv_cpu_get_desc(struct udevice *dev, char *buf, int size)
        return 0;
 }
 
+static ulong riscv_get_clkrate(int clk_index)
+{
+       int ret;
+       struct udevice *dev;
+       struct clk clk;
+       ulong rate;
+
+       ret = uclass_get_device_by_driver(UCLASS_CLK,
+                                         DM_GET_DRIVER(sifive_fu540_prci),
+                                         &dev);
+       if (ret < 0) {
+               pr_err("%s: Could not get device driver\n", __func__);
+               return ret;
+       }
+
+       clk.id = clk_index;
+       ret = clk_request(dev, &clk);
+       if (ret < 0) {
+               pr_err("%s: request to clock device failed...\n", __func__);
+               return ret;
+       }
+
+       rate = clk_get_rate(&clk);
+
+       clk_free(&clk);
+
+       return rate;
+}
+
 static int riscv_cpu_get_info(struct udevice *dev, struct cpu_info *info)
 {
        const char *mmu;
+       int ret;
 
-       dev_read_u32(dev, "clock-frequency", (u32 *)&info->cpu_freq);

drivers/cpu/riscv_cpu.c static int riscv_cpu_get_desc(struct udevice *dev, char *buf, int size)

Quoted 10 lines
drivers/cpu/riscv_cpu.c +6 -1
+       ret = dev_read_u32(dev, "clock-frequency", (u32 *)&info->cpu_freq);
+       if (ret) {
+               /* if clock-frequency is missing in DT, read it from prci */
+               debug("Fetch core clk configured by prci\n");
+               info->cpu_freq = riscv_get_clkrate(PRCI_CLK_COREPLL);
+       }
 
        mmu = dev_read_string(dev, "mmu-type");
        if (!mmu)
--

What you were trying to do in this patch, I believe the following 2 patches already did it.

http://patchwork.ozlabs.org/patch/1236177/
http://patchwork.ozlabs.org/patch/1236180/

Regards,
Bin

#6 lore raw

PATCH 2/2 cpu: clk: riscv: populate proper CPU core clk frequency

Hello Bin,

Quoted 35 lines

-----Original Message-----
From: Bin Meng <[email protected]>
Sent: Wednesday, February 19, 2020 9:40 PM
To: Sagar Kadam <[email protected]>; Sean Anderson <[email protected]>
Cc: U-Boot Mailing List <[email protected]>; Lukasz Majewski <[email protected]>; Anup Patel <[email protected]>; Paul Walmsley ( Sifive) <[email protected]>; Vincent Chen <[email protected]>
Subject: Re: [PATCH v1 2/2] cpu: clk: riscv: populate proper CPU core clk frequency

+Sean Anderson

Hi Sagar,

Quoted 10 lines · Sagar Shrikant Kadam

Fetch core clock frequency from prci if clock-frequency for CPU nodes is missing in device tree, so that the cmd "#cpu detail" will show the correct CPU frequency.

U-Boot command "#cpu detail" is showing wrong frequency values. This patch fixes this issue by getting the core clock set in prci driver if clock-frequency is not added to CPU nodes in device tree. It is tested on HiFive Unleashed A00 board.

Quoted 4 lines
---
 drivers/cpu/riscv_cpu.c | 39

++++++++++++++++++++++++++++++++++++++-

Quoted 2 lines
 1 file changed, 38 insertions(+), 1 deletion(-)
Quoted 13 lines

drivers/cpu/riscv_cpu.c line 13

Quoted 10 lines
drivers/cpu/riscv_cpu.c +2 -0
index 28ad0aa..eb5491f 100644
@@ -9,6 +9,8 @@
 #include <errno.h>
 #include <dm/device-internal.h>
 #include <dm/lists.h>
+#include <clk-uclass.h>
+#include <dt-bindings/clock/sifive-fu540-prci.h>

It's wrong to include a SoC specific header file in a generic driver.

Thanks for review.
Ok. I will remove this.

Quoted 58 lines

drivers/cpu/riscv_cpu.c static int riscv_cpu_get_desc(struct udevice *dev,

Quoted 5 lines
drivers/cpu/riscv_cpu.c +0 -0
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -25,11 +27,46 @@ static int riscv_cpu_get_desc(struct udevice *dev,

char *buf, int size)

Quoted 38 lines
drivers/cpu/riscv_cpu.c +30 -1
        return 0;
 }
 
+static ulong riscv_get_clkrate(int clk_index)
+{
+       int ret;
+       struct udevice *dev;
+       struct clk clk;
+       ulong rate;
+
+       ret = uclass_get_device_by_driver(UCLASS_CLK,
+                                         DM_GET_DRIVER(sifive_fu540_prci),
+                                         &dev);
+       if (ret < 0) {
+               pr_err("%s: Could not get device driver\n", __func__);
+               return ret;
+       }
+
+       clk.id = clk_index;
+       ret = clk_request(dev, &clk);
+       if (ret < 0) {
+               pr_err("%s: request to clock device failed...\n", __func__);
+               return ret;
+       }
+
+       rate = clk_get_rate(&clk);
+
+       clk_free(&clk);
+
+       return rate;
+}
+
 static int riscv_cpu_get_info(struct udevice *dev, struct cpu_info *info)
 {
        const char *mmu;
+       int ret;
 
-       dev_read_u32(dev, "clock-frequency", (u32 *)&info->cpu_freq);

drivers/cpu/riscv_cpu.c static int riscv_cpu_get_desc(struct udevice *dev, char *buf, int size)

Quoted 10 lines
drivers/cpu/riscv_cpu.c +6 -1
+       ret = dev_read_u32(dev, "clock-frequency", (u32 *)&info->cpu_freq);
+       if (ret) {
+               /* if clock-frequency is missing in DT, read it from prci */
+               debug("Fetch core clk configured by prci\n");
+               info->cpu_freq = riscv_get_clkrate(PRCI_CLK_COREPLL);
+       }
 
        mmu = dev_read_string(dev, "mmu-type");
        if (!mmu)
--

What you were trying to do in this patch, I believe the following 2 patches already did it.

Quoted 3 lines

http://patchwork.ozlabs.org/patch/1236177/
http://patchwork.ozlabs.org/patch/1236180/

Thanks for sharing the links. Unfortunately I didn?t come across it. I applied these two patches within my repo (assuming there are not extra dependencies) and would like to share my observation:
The implementation in the patch links shared here read's clock dt property in clk_get_by_index. If the cpu dt node doesn't contain clock property it return's negative value and so the clk_get_rate here won't be be executed.

+ ret = clk_get_by_index(dev, 0, &clk);
+ if (!ret) {
+ ret = clk_get_rate(&clk);

Thus when I tested this on hifive unleashed the "cpu detail" showed frequency as 0 Hz.

Please correct me if I am wrong, but IMHO here we can check for negative return code [if (ret < 0)] instead of (!ret) and if "clocks" is missing in dt property then get the clock driver using uclass_get_device_by_driver->request the clock -> and get clock rate, just like below

- if (!ret) {
+ if (ret < 0) {
+ ret = uclass_get_device_by_driver(UCLASS_CLK,
+ DM_GET_DRIVER(sifive_fu540_prci),
+ &dev);

+               clk.id = 0;
+               ret = clk_request(dev, &clk);
+               if (ret < 0) {

+ pr_err("%s: request to clock device failed...\n", __func__);
+ return ret;
+ }
+

Also there is missing "include linux/err.h" which is needed by IS_ERR_VALUE Please let me know if I can rebase and update my patches above the two patch's you pointed to.

Quoted 2 lines

Regards,
Bin

#7 lore raw

PATCH 2/2 cpu: clk: riscv: populate proper CPU core clk frequency

Quoted 14 lines · Sagar Kadam
Quoted 6 lines

What you were trying to do in this patch, I believe the following 2 patches already did it.

http://patchwork.ozlabs.org/patch/1236177/
http://patchwork.ozlabs.org/patch/1236180/

Thanks for sharing the links. Unfortunately I didn?t come across it. I applied these two patches within my repo (assuming there are not extra dependencies) and would like to share my observation:
The implementation in the patch links shared here read's clock dt property in clk_get_by_index. If the cpu dt node doesn't contain clock property it return's negative value and so the clk_get_rate here won't be be executed.

Review

Quoted 3 lines
(quoted diff) +3 -0
+	ret = clk_get_by_index(dev, 0, &clk);
+	if (!ret) {
+		ret = clk_get_rate(&clk);

This is working as designed. The idea is to use the clocks property if it exists and to fall back on clock-frequency otherwise.

Quoted 1 line

Thus when I tested this on hifive unleashed the "cpu detail" showed frequency as 0 Hz.

This is because the cpu nodes in the hifive/fu540 device tree have neither a clock-frequency property or a clocks property.

drivers/cpu/riscv_cpu.c static int riscv_cpu_get_desc(struct udevice *dev, char *buf, int size) · line 39

Quoted 9 lines

Please correct me if I am wrong, but IMHO here we can check for negative return code [if (ret < 0)] instead of (!ret) and if "clocks" is missing in dt property then get the clock driver using uclass_get_device_by_driver->request the clock -> and get clock rate, just like below

drivers/cpu/riscv_cpu.c +4 -1
-       if (!ret) {
+       if (ret < 0) {
+               ret = uclass_get_device_by_driver(UCLASS_CLK,
+                                                 DM_GET_DRIVER(sifive_fu540_prci),
+                                                 &dev);

This is again adding board-specific code to a generic driver. Add a UCLASS_CLOCK driver if you want to support clocks. That way there is no need for code like this.

drivers/cpu/riscv_cpu.c static int riscv_cpu_get_desc(struct udevice *dev, char *buf, int size) · line 48

Quoted 4 lines
drivers/cpu/riscv_cpu.c +4 -0
+               clk.id = 0;
+               ret = clk_request(dev, &clk);
+               if (ret < 0) {
+                       pr_err("%s: request to clock device failed...\n", __func__);

I belive pr_err is supported for linux compatibility. New code should use log_*. This is also probably debug-level and not err-level.

Quoted 5 lines
drivers/cpu/riscv_cpu.c +3 -0
+                       return ret;
+               }
+

Also there is missing "include linux/err.h" which is needed by IS_ERR_VALUE

Yes, I noticed that when rebasing. It will be fixed in the next version of the series.

Quoted 5 lines

Please let me know if I can rebase and update my patches above the two patch's you pointed to.

Quoted 2 lines

Regards,
Bin

--Sean

#8 lore raw

PATCH 2/2 cpu: clk: riscv: populate proper CPU core clk frequency

Hello Sean,

Quoted 26 lines

-----Original Message-----
From: Sean Anderson <[email protected]>
Sent: Friday, February 21, 2020 11:48 AM
To: Sagar Kadam <[email protected]>; Bin Meng <[email protected]>
Cc: U-Boot Mailing List <[email protected]>; Lukasz Majewski <[email protected]>; Anup Patel <[email protected]>; Paul Walmsley ( Sifive) <[email protected]>; Vincent Chen <[email protected]>
Subject: Re: [PATCH v1 2/2] cpu: clk: riscv: populate proper CPU core clk frequency

Quoted 7 lines · Sagar Kadam
Quoted 6 lines

What you were trying to do in this patch, I believe the following 2 patches already did it.

http://patchwork.ozlabs.org/patch/1236177/
http://patchwork.ozlabs.org/patch/1236180/

Quoted 6 lines

Thanks for sharing the links. Unfortunately I didn?t come across it. I applied these two patches within my repo (assuming there are not extra dependencies) and would like to share my observation:
The implementation in the patch links shared here read's clock dt property in clk_get_by_index. If the cpu dt node doesn't contain clock property it return's negative value and so the clk_get_rate here won't be be

Quoted 8 lines

executed.

Review

Quoted 4 lines
(quoted diff) +3 -0
+	ret = clk_get_by_index(dev, 0, &clk);
+	if (!ret) {
+		ret = clk_get_rate(&clk);

This is working as designed. The idea is to use the clocks property if it exists and to fall back on clock-frequency otherwise.

Thanks for clarifying.

Quoted 7 lines
Quoted 2 lines

Thus when I tested this on hifive unleashed the "cpu detail" showed

frequency as 0 Hz.

This is because the cpu nodes in the hifive/fu540 device tree have neither a clock-frequency property or a clocks property.

Yes, I will add clocks dt property.

Quoted 12 lines

drivers/cpu/riscv_cpu.c static int riscv_cpu_get_desc(struct udevice *dev, char *buf, int size) · line 39

Quoted 11 lines

Please correct me if I am wrong, but IMHO here we can check for negative return code [if (ret < 0)] instead of (!ret) and if "clocks" is missing in dt property then get the clock driver using uclass_get_device_by_driver->request the clock -> and get clock rate, just like below

drivers/cpu/riscv_cpu.c +4 -1
-       if (!ret) {
+       if (ret < 0) {
+               ret = uclass_get_device_by_driver(UCLASS_CLK,
+                                                 DM_GET_DRIVER(sifive_fu540_prci),
+                                                 &dev);
Quoted 3 lines

This is again adding board-specific code to a generic driver. Add a UCLASS_CLOCK driver if you want to support clocks. That way there is no need for code like this.

Thanks for suggestion.
I will remove board-specific code from generic driver.

Quoted 9 lines

Review

Quoted 6 lines
(quoted diff) +5 -0
+               clk.id = 0;
+               ret = clk_request(dev, &clk);
+               if (ret < 0) {
+                       pr_err("%s: request to clock device
+ failed...\n", __func__);

I belive pr_err is supported for linux compatibility. New code should use log_*. This is also probably debug-level and not err-level.

Ok. I will replace pr_err with log_debug.

Quoted 10 lines
Quoted 7 lines
drivers/cpu/riscv_cpu.c +3 -0
+                       return ret;
+               }
+

Also there is missing "include linux/err.h" which is needed by IS_ERR_VALUE

Yes, I noticed that when rebasing. It will be fixed in the next version of the series.

Thanks for updating.

BR,
Sagar Kadam

Quoted 8 lines
Quoted 6 lines

Please let me know if I can rebase and update my patches above the two patch's you pointed to.

Quoted 2 lines

Regards,
Bin

--Sean