Skip to contentSkip to conversation

amba: Allow pclk to be controlled by power domain

PATCH RESEND In review Bjorn Andersson 3 participants 5 messages Jan 31, 2019 – Feb 21, 2019

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

PATCH RESEND 1/1 amba: Allow pclk to be controlled by power domain

On the Qualcomm SDM845 platform the apb_pclk is controlled as part of the QDSS power/clock domain. Handle this by allowing amba to operate without direct apb_pclk control, when a powerdomain is attached and no clock is described.

---

Resending this separate from the series it was originally part of.

 drivers/amba/bus.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/amba/bus.c +7 -2
index 41b706403ef7..3e13050c6d59 100644
@@ -219,8 +219,13 @@ static int amba_get_enable_pclk(struct amba_device *pcdev)
 	int ret;
 
 	pcdev->pclk = clk_get(&pcdev->dev, "apb_pclk");
-	if (IS_ERR(pcdev->pclk))
-		return PTR_ERR(pcdev->pclk);
+	if (IS_ERR(pcdev->pclk)) {
+		/* Continue with no clock specified, but pm_domain attached */
+		if (PTR_ERR(pcdev->pclk) == -ENOENT && pcdev->dev.pm_domain)
+			pcdev->pclk = NULL;
+		else
+			return PTR_ERR(pcdev->pclk);
+	}
 
 	ret = clk_prepare_enable(pcdev->pclk);
 	if (ret)
Signature · 1 line
2.18.0
Tested-by on v1 1/1
#1 lore raw
Quoted 24 lines · Bjorn Andersson

On the Qualcomm SDM845 platform the apb_pclk is controlled as part of the QDSS power/clock domain. Handle this by allowing amba to operate without direct apb_pclk control, when a powerdomain is attached and no clock is described.

---

Resending this separate from the series it was originally part of.

  drivers/amba/bus.c | 9 +++++++--
  1 file changed, 7 insertions(+), 2 deletions(-)
drivers/amba/bus.c +0 -2
index 41b706403ef7..3e13050c6d59 100644
@@ -219,8 +219,13 @@ static int amba_get_enable_pclk(struct amba_device *pcdev)
  	int ret;
 
  	pcdev->pclk = clk_get(&pcdev->dev, "apb_pclk");
-	if (IS_ERR(pcdev->pclk))
-		return PTR_ERR(pcdev->pclk);

drivers/amba/bus.c static int amba_get_enable_pclk(struct amba_device *pcdev) · line 231

Quoted 10 lines
drivers/amba/bus.c +7 -0
+	if (IS_ERR(pcdev->pclk)) {
+		/* Continue with no clock specified, but pm_domain attached */
+		if (PTR_ERR(pcdev->pclk) == -ENOENT && pcdev->dev.pm_domain)
+			pcdev->pclk = NULL;
+		else
+			return PTR_ERR(pcdev->pclk);
+	}
 
  	ret = clk_prepare_enable(pcdev->pclk);
  	if (ret)

Thanks.

Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#2 lore raw
In reply to Bjorn Andersson
Quoted 19 lines · Bjorn Andersson

On the Qualcomm SDM845 platform the apb_pclk is controlled as part of the QDSS power/clock domain. Handle this by allowing amba to operate without direct apb_pclk control, when a powerdomain is attached and no clock is described.

---

Resending this separate from the series it was originally part of.

 drivers/amba/bus.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/amba/bus.c +0 -0
index 41b706403ef7..3e13050c6d59 100644

drivers/amba/bus.c static int amba_get_enable_pclk(struct amba_device *pcdev) · line 225

Quoted 9 lines
drivers/amba/bus.c +4 -2
@@ -219,8 +219,13 @@ static int amba_get_enable_pclk(struct amba_device *pcdev)
        int ret;
 
        pcdev->pclk = clk_get(&pcdev->dev, "apb_pclk");
-       if (IS_ERR(pcdev->pclk))
-               return PTR_ERR(pcdev->pclk);
+       if (IS_ERR(pcdev->pclk)) {
+               /* Continue with no clock specified, but pm_domain attached */
+               if (PTR_ERR(pcdev->pclk) == -ENOENT && pcdev->dev.pm_domain)
+                       pcdev->pclk = NULL;

This looks fragile to me.

I would prefer to make a do match with DT, to check whether the clock is needed or not. Moreover, there should be no reason to check for the ->dev.pm_domain, because, if there was an error while doing the attach, that should already have been reported/propagated.

Quoted 9 lines
drivers/amba/bus.c +3 -1
+               else
+                       return PTR_ERR(pcdev->pclk);
+       }
 
        ret = clk_prepare_enable(pcdev->pclk);
        if (ret)
--

2.18.0

Kind regards
Uffe

#3 lore raw
Quoted 33 lines · Ulf Hansson
Quoted 19 lines · Bjorn Andersson

On the Qualcomm SDM845 platform the apb_pclk is controlled as part of the QDSS power/clock domain. Handle this by allowing amba to operate without direct apb_pclk control, when a powerdomain is attached and no clock is described.

---

Resending this separate from the series it was originally part of.

 drivers/amba/bus.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/amba/bus.c +0 -0
index 41b706403ef7..3e13050c6d59 100644

drivers/amba/bus.c static int amba_get_enable_pclk(struct amba_device *pcdev) · line 225

Quoted 9 lines
drivers/amba/bus.c +4 -2
@@ -219,8 +219,13 @@ static int amba_get_enable_pclk(struct amba_device *pcdev)
        int ret;
 
        pcdev->pclk = clk_get(&pcdev->dev, "apb_pclk");
-       if (IS_ERR(pcdev->pclk))
-               return PTR_ERR(pcdev->pclk);
+       if (IS_ERR(pcdev->pclk)) {
+               /* Continue with no clock specified, but pm_domain attached */
+               if (PTR_ERR(pcdev->pclk) == -ENOENT && pcdev->dev.pm_domain)
+                       pcdev->pclk = NULL;

This looks fragile to me.

Quoted 2 lines

I would prefer to make a do match with DT, to check whether the clock is needed or not.

Can you please elaborate on what you want me to match on?

As an example you can find the patch depending on this here:
https://lore.kernel.org/lkml/60ebf1617f0285c89e921bf3839cba6906d493c9.1548419933.git.saiprakash.ranjan@codeaurora.org/

Quoted 4 lines

Moreover, there should be no reason to check for the ->dev.pm_domain, because, if there was an error while doing the attach, that should already have been reported/propagated.

The purpose of this check was to extend the current requirement of a clock to require either a clock or a power domain, rather than just making the clock optional - which would be the result if this part is omitted.

Regards,
Bjorn

Quoted 12 lines
Quoted 9 lines
drivers/amba/bus.c +3 -1
+               else
+                       return PTR_ERR(pcdev->pclk);
+       }
 
        ret = clk_prepare_enable(pcdev->pclk);
        if (ret)
--

2.18.0

Kind regards
Uffe

#4 lore raw
Quoted 36 lines · Bjorn Andersson
Quoted 33 lines · Ulf Hansson
Quoted 19 lines · Bjorn Andersson

On the Qualcomm SDM845 platform the apb_pclk is controlled as part of the QDSS power/clock domain. Handle this by allowing amba to operate without direct apb_pclk control, when a powerdomain is attached and no clock is described.

---

Resending this separate from the series it was originally part of.

 drivers/amba/bus.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/amba/bus.c +0 -0
index 41b706403ef7..3e13050c6d59 100644

drivers/amba/bus.c static int amba_get_enable_pclk(struct amba_device *pcdev) · line 225

Quoted 9 lines
drivers/amba/bus.c +4 -2
@@ -219,8 +219,13 @@ static int amba_get_enable_pclk(struct amba_device *pcdev)
        int ret;
 
        pcdev->pclk = clk_get(&pcdev->dev, "apb_pclk");
-       if (IS_ERR(pcdev->pclk))
-               return PTR_ERR(pcdev->pclk);
+       if (IS_ERR(pcdev->pclk)) {
+               /* Continue with no clock specified, but pm_domain attached */
+               if (PTR_ERR(pcdev->pclk) == -ENOENT && pcdev->dev.pm_domain)
+                       pcdev->pclk = NULL;

This looks fragile to me.

Quoted 7 lines
Quoted 2 lines

I would prefer to make a do match with DT, to check whether the clock is needed or not.

Can you please elaborate on what you want me to match on?

As an example you can find the patch depending on this here:
https://lore.kernel.org/lkml/60ebf1617f0285c89e921bf3839cba6906d493c9.1548419933.git.saiprakash.ranjan@codeaurora.org/

I would extend the compatible with a "soc-id" prefix and match on that.

If that doesn't work, I guess we need check for the soc family/id, thus use soc_device_match().

Quoted 10 lines
Quoted 5 lines

Moreover, there should be no reason to check for the ->dev.pm_domain, because, if there was an error while doing the attach, that should already have been reported/propagated.

The purpose of this check was to extend the current requirement of a clock to require either a clock or a power domain, rather than just making the clock optional - which would be the result if this part is omitted.

Well, that would break the current requirement for everybody else, which is that the clock is required and the PM domain is optional.

[...]

Kind regards
Uffe