Skip to contentSkip to conversation

IPQ40xx: clk: use dev_read_addr()

PATCH New Robert Marko 2 participants 9 messages Oct 28, 2020 – Dec 2, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/4 IPQ40xx: clk: use dev_read_addr()

Lets convert the driver to use dev_read_addr() instead of the devfdt_get_addr().

While we are here, lets also alphabetise the includes.

---
 arch/arm/mach-ipq40xx/clock-ipq4019.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-ipq40xx/clock-ipq4019.c +2 -2
index 31ae9719e8..1f385665cc 100644
@@ -8,8 +8,8 @@
  *
  */
 
-#include <common.h>
 #include <clk-uclass.h>
+#include <common.h>
 #include <dm.h>
 #include <errno.h>
 
@@ -35,7 +35,7 @@ static int msm_clk_probe(struct udevice *dev)
 {
 	struct msm_clk_priv *priv = dev_get_priv(dev);
 
-	priv->base = devfdt_get_addr(dev);
+	priv->base = dev_read_addr(dev);
 	if (priv->base == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
Signature · 1 line
2.28.0
#1 lore raw

PATCH 1/4 IPQ40xx: clk: use dev_read_addr()

Quoted 35 lines · Robert Marko

Lets convert the driver to use dev_read_addr() instead of the devfdt_get_addr().

While we are here, lets also alphabetise the includes.

---
 arch/arm/mach-ipq40xx/clock-ipq4019.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-ipq40xx/clock-ipq4019.c +2 -3
index 31ae9719e8..1f385665cc 100644
@@ -8,8 +8,8 @@
  *
  */
 
-#include <common.h>
 #include <clk-uclass.h>
+#include <common.h>
 #include <dm.h>
 #include <errno.h>
 
@@ -35,7 +35,7 @@ static int msm_clk_probe(struct udevice *dev)
 {
        struct msm_clk_priv *priv = dev_get_priv(dev);
 
-       priv->base = devfdt_get_addr(dev);
+       priv->base = dev_read_addr(dev);
        if (priv->base == FDT_ADDR_T_NONE)
                return -EINVAL;
 
--
Quoted 2 lines

2.28.0

Hi,
Is there something I can improve in the patch series?

Regards,
Robert

#2 lore raw

PATCH 2/4 IPQ40xx: clk: drop breaks in switch case

In reply to Robert Marko

There is no point in having break statements in the switch case as there is already a return before break.

So lets drop them from the driver.

---
 arch/arm/mach-ipq40xx/clock-ipq4019.c | 3 ---
 1 file changed, 3 deletions(-)
arch/arm/mach-ipq40xx/clock-ipq4019.c +0 -3
index 1f385665cc..ac2b830353 100644
@@ -25,7 +25,6 @@ ulong msm_set_rate(struct clk *clk, ulong rate)
 	case GCC_BLSP1_UART1_APPS_CLK: /*UART1*/
 		/* This clock is already initialized by SBL1 */
 		return 0;
-		break;
 	default:
 		return 0;
 	}
@@ -53,11 +52,9 @@ static int msm_enable(struct clk *clk)
 	case GCC_BLSP1_QUP1_SPI_APPS_CLK: /*SPI1*/
 		/* This clock is already initialized by SBL1 */
 		return 0;
-		break;
 	case GCC_PRNG_AHB_CLK: /*PRNG*/
 		/* This clock is already initialized by SBL1 */
 		return 0;
-		break;
 	default:
 		return 0;
 	}
Signature · 1 line
2.28.0
#3 lore raw

PATCH 2/4 IPQ40xx: clk: drop breaks in switch case

Quoted 6 lines · Robert Marko

There is no point in having break statements in the switch case as there is already a return before break.

So lets drop them from the driver.

Applied to u-boot/next, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201202/c36b3c4d/attachment.sig>
#4 lore raw

PATCH 3/4 IPQ40xx: clk: dont always return 0

In reply to Robert Marko

Currently the driver will go through the clock ID-s and set/enable them as needed.
But if the ID is unknown it will fall through the switch case to the default case which will always return 0.

This is not correct and default cases should return a error code since clock ID is unknown. So lets return -EINVAL instead.

---
 arch/arm/mach-ipq40xx/clock-ipq4019.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-ipq40xx/clock-ipq4019.c +2 -2
index ac2b830353..7308563ad1 100644
@@ -26,7 +26,7 @@ ulong msm_set_rate(struct clk *clk, ulong rate)
 		/* This clock is already initialized by SBL1 */
 		return 0;
 	default:
-		return 0;
+		return -EINVAL;
 	}
 }
 
@@ -56,7 +56,7 @@ static int msm_enable(struct clk *clk)
 		/* This clock is already initialized by SBL1 */
 		return 0;
 	default:
-		return 0;
+		return -EINVAL;
 	}
 }
 
Signature · 1 line
2.28.0
#5 lore raw

PATCH 3/4 IPQ40xx: clk: dont always return 0

Quoted 8 lines · Robert Marko

Currently the driver will go through the clock ID-s and set/enable them as needed.
But if the ID is unknown it will fall through the switch case to the default case which will always return 0.

This is not correct and default cases should return a error code since clock ID is unknown. So lets return -EINVAL instead.

Applied to u-boot/next, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201202/1d92f405/attachment.sig>
#6 lore raw

PATCH 4/4 IPQ40xx: clk: add USB clock handling

In reply to Robert Marko

USB clocks were completely forgotten as driver would always return 0 even if clock ID was unknown.

This behaviour changed with "IPQ40xx: clk: dont always return 0" and this will now causes the USB-s to fail probing as clock enable will return -EINVAL.

So to fix that lets add all of the USB clocks to the driver.

Fixes 430e1dcf ("IPQ40xx: Add USB nodes")
---
 arch/arm/mach-ipq40xx/clock-ipq4019.c | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm/mach-ipq40xx/clock-ipq4019.c +8 -0
index 7308563ad1..a3f872947d 100644
@@ -55,6 +55,14 @@ static int msm_enable(struct clk *clk)
 	case GCC_PRNG_AHB_CLK: /*PRNG*/
 		/* This clock is already initialized by SBL1 */
 		return 0;
+	case GCC_USB3_MASTER_CLK:
+	case GCC_USB3_SLEEP_CLK:
+	case GCC_USB3_MOCK_UTMI_CLK:
+	case GCC_USB2_MASTER_CLK:
+	case GCC_USB2_SLEEP_CLK:
+	case GCC_USB2_MOCK_UTMI_CLK:
+		/* These clocks is already initialized by SBL1 */
+		return 0;
 	default:
 		return -EINVAL;
 	}
Signature · 1 line
2.28.0
#7 lore raw

PATCH 4/4 IPQ40xx: clk: add USB clock handling

Quoted 10 lines · Robert Marko

USB clocks were completely forgotten as driver would always return 0 even if clock ID was unknown.

This behaviour changed with "IPQ40xx: clk: dont always return 0" and this will now causes the USB-s to fail probing as clock enable will return -EINVAL.

So to fix that lets add all of the USB clocks to the driver.

Fixes 430e1dcf ("IPQ40xx: Add USB nodes")

Applied to u-boot/next, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201202/05f13dc1/attachment.sig>
#8 lore raw

PATCH 1/4 IPQ40xx: clk: use dev_read_addr()

In reply to Robert Marko
Quoted 6 lines · Robert Marko

Lets convert the driver to use dev_read_addr() instead of the devfdt_get_addr().

While we are here, lets also alphabetise the includes.

Applied to u-boot/next, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201202/b18356c3/attachment.sig>