mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master v2 1/4] soc: imx: gpcv2: associate PGC device tree node with platform device
@ 2022-08-05  5:42 Ahmad Fatoum
  2022-08-05  5:42 ` [PATCH master v2 2/4] drivers: power: ignore power domains with barebox,allow-dummy Ahmad Fatoum
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Ahmad Fatoum @ 2022-08-05  5:42 UTC (permalink / raw)
  To: barebox; +Cc: mfe, lst, Ahmad Fatoum

We aren't using of_platform_device_create, but instead create our own
platform devices which lack a reference from the device tree node to the
newly created device. Add this reference to support of_device_ensure_probed.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
v1 -> v2:
  - new patch
---
 drivers/soc/imx/gpcv2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/soc/imx/gpcv2.c b/drivers/soc/imx/gpcv2.c
index 62cfc21519b1..a0e78ce55e3e 100644
--- a/drivers/soc/imx/gpcv2.c
+++ b/drivers/soc/imx/gpcv2.c
@@ -483,10 +483,10 @@ again:
 
 		pd_dev = xzalloc(sizeof(*pd_dev));
 		pd_dev->device_node = np;
+		pd_dev->device_node->dev = pd_dev;
 		pd_dev->id = domain_index;
 		pd_dev->parent = dev;
 		pd_dev->priv = domain;
-		pd_dev->device_node = np;
 		dev_set_name(pd_dev, imx_pgc_domain_id[0].name);
 
 		ret = platform_device_register(pd_dev);
-- 
2.30.2




^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH master v2 2/4] drivers: power: ignore power domains with barebox,allow-dummy
  2022-08-05  5:42 [PATCH master v2 1/4] soc: imx: gpcv2: associate PGC device tree node with platform device Ahmad Fatoum
@ 2022-08-05  5:42 ` Ahmad Fatoum
  2022-08-05  5:42 ` [PATCH master v2 3/4] ARM: i.MX8MM: assume USBOTG power domains to be powered Ahmad Fatoum
  2022-08-05  5:42 ` [PATCH master v2 4/4] ARM: i.MX8MN: " Ahmad Fatoum
  2 siblings, 0 replies; 6+ messages in thread
From: Ahmad Fatoum @ 2022-08-05  5:42 UTC (permalink / raw)
  To: barebox; +Cc: mfe, lst, Ahmad Fatoum

With deep probe enabled, we can know for certain whether a driver will
be found for a device or not. This allows us to specially handle devices
that lack a driver. We already do that for regulators, where the device
tree can specify barebox,allow-dummy-supply for regulators that are
known to be enabled by the time barebox runs. Add the same functionality
for power domains as well.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
v1 -> v2:
  - no change
---
 drivers/base/power.c | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/drivers/base/power.c b/drivers/base/power.c
index 96cac1a091f3..4a206051b137 100644
--- a/drivers/base/power.c
+++ b/drivers/base/power.c
@@ -139,14 +139,32 @@ static struct generic_pm_domain *genpd_get_from_provider(
 					struct of_phandle_args *genpdspec)
 {
 	struct generic_pm_domain *genpd = ERR_PTR(-ENOENT);
+	struct device_node *node = genpdspec->np;
 	struct of_genpd_provider *provider;
+	int ret;
 
 	if (!genpdspec)
 		return ERR_PTR(-EINVAL);
 
+	ret = of_device_ensure_probed(node);
+	if (ret) {
+		struct device_node *parent;
+
+		/*
+		 * If "barebox,allow-dummy" property is set for power domain
+		 * provider, assume it's turned on.
+		 */
+		parent = of_get_parent(node);
+		if (of_get_property(node, "barebox,allow-dummy", NULL) ||
+		    of_get_property(parent, "barebox,allow-dummy", NULL))
+			return NULL;
+
+		return ERR_PTR(ret);
+	}
+
 	/* Check if we have such a provider in our array */
 	list_for_each_entry(provider, &of_genpd_providers, link) {
-		if (provider->node == genpdspec->np)
+		if (provider->node == node)
 			genpd = provider->xlate(genpdspec, provider->data);
 		if (!IS_ERR(genpd))
 			break;
@@ -175,7 +193,7 @@ static int genpd_power_on(struct generic_pm_domain *genpd, unsigned int depth)
 {
 	int ret;
 
-	if (genpd_status_on(genpd))
+	if (!genpd || genpd_status_on(genpd))
 		return 0;
 
 	ret = _genpd_power_on(genpd, true);
@@ -211,7 +229,7 @@ static int __genpd_dev_pm_attach(struct device_d *dev, struct device_node *np,
 		return (ret == -ENOENT) ? -EPROBE_DEFER : ret;
 	}
 
-	dev_dbg(dev, "adding to PM domain %s\n", pd->name);
+	dev_dbg(dev, "adding to PM domain %s\n", pd ? pd->name : "dummy");
 
 	if (power_on)
 		ret = genpd_power_on(pd, 0);
-- 
2.30.2




^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH master v2 3/4] ARM: i.MX8MM: assume USBOTG power domains to be powered
  2022-08-05  5:42 [PATCH master v2 1/4] soc: imx: gpcv2: associate PGC device tree node with platform device Ahmad Fatoum
  2022-08-05  5:42 ` [PATCH master v2 2/4] drivers: power: ignore power domains with barebox,allow-dummy Ahmad Fatoum
@ 2022-08-05  5:42 ` Ahmad Fatoum
  2022-08-05  5:42 ` [PATCH master v2 4/4] ARM: i.MX8MN: " Ahmad Fatoum
  2 siblings, 0 replies; 6+ messages in thread
From: Ahmad Fatoum @ 2022-08-05  5:42 UTC (permalink / raw)
  To: barebox; +Cc: mfe, lst, Ahmad Fatoum

When i.MX8MM support was first added, upstream device tree did list no
power domains. Now it does and we defer probe of USB indefinitely
because we have no power domain driver. If we need to do PCI on the
i.MX8MM in barebox, there'll likely be no way around importing the power
domain driver, but for USB which used to work, only thing we need to do
is ignore the new power domain specification. Do so by adding the
new barebox,allow-dummy property to the new known-enabled power domains.

Fixes: 3f2f5980d517 ("dts: update to v5.16-rc1")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
v1 -> v2:
  - no change
---
 arch/arm/dts/imx8mm.dtsi | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/dts/imx8mm.dtsi b/arch/arm/dts/imx8mm.dtsi
index 78bbacb2b1b2..cdf212820594 100644
--- a/arch/arm/dts/imx8mm.dtsi
+++ b/arch/arm/dts/imx8mm.dtsi
@@ -5,6 +5,14 @@
 	};
 };
 
+&pgc_otg1 {
+	barebox,allow-dummy;
+};
+
+&pgc_otg2 {
+	barebox,allow-dummy;
+};
+
 &src {
 	compatible = "fsl,imx8mm-src", "fsl,imx8mq-src", "syscon", "simple-mfd";
 
-- 
2.30.2




^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH master v2 4/4] ARM: i.MX8MN: assume USBOTG power domains to be powered
  2022-08-05  5:42 [PATCH master v2 1/4] soc: imx: gpcv2: associate PGC device tree node with platform device Ahmad Fatoum
  2022-08-05  5:42 ` [PATCH master v2 2/4] drivers: power: ignore power domains with barebox,allow-dummy Ahmad Fatoum
  2022-08-05  5:42 ` [PATCH master v2 3/4] ARM: i.MX8MM: assume USBOTG power domains to be powered Ahmad Fatoum
@ 2022-08-05  5:42 ` Ahmad Fatoum
  2022-08-08 13:04   ` Sascha Hauer
  2 siblings, 1 reply; 6+ messages in thread
From: Ahmad Fatoum @ 2022-08-05  5:42 UTC (permalink / raw)
  To: barebox; +Cc: mfe, lst, Ahmad Fatoum

When i.MX8MN support was first added, upstream device tree did list no
power domains. Now it does and we defer probe of USB indefinitely
because we have no power domain driver. If we need to do PCI on the
i.MX8MM in barebox, there'll likely be no way around importing the power
domain driver, but for USB which used to work, only thing we need to do
is ignore the new power domain specification. Do so by adding the
new barebox,allow-dummy property to the new known-enabled power domain.

Fixes: b01786baa849 ("dts: update to v5.18-rc1")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
v1 -> v2:
  - no change
---
 arch/arm/dts/imx8mn-evk.dtsi | 2 ++
 arch/arm/dts/imx8mn.dtsi     | 5 +++++
 2 files changed, 7 insertions(+)
 create mode 100644 arch/arm/dts/imx8mn.dtsi

diff --git a/arch/arm/dts/imx8mn-evk.dtsi b/arch/arm/dts/imx8mn-evk.dtsi
index ceeb5f8b9384..aeb357007991 100644
--- a/arch/arm/dts/imx8mn-evk.dtsi
+++ b/arch/arm/dts/imx8mn-evk.dtsi
@@ -4,6 +4,8 @@
  * Copyright (C) 2017 Pengutronix, Lucas Stach <kernel@pengutronix.de>
  */
 
+#include "imx8mn.dtsi"
+
 / {
 	chosen {
 		environment-sd {
diff --git a/arch/arm/dts/imx8mn.dtsi b/arch/arm/dts/imx8mn.dtsi
new file mode 100644
index 000000000000..176125e73bce
--- /dev/null
+++ b/arch/arm/dts/imx8mn.dtsi
@@ -0,0 +1,5 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+
+&pgc_otg1 {
+	barebox,allow-dummy;
+};
-- 
2.30.2




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH master v2 4/4] ARM: i.MX8MN: assume USBOTG power domains to be powered
  2022-08-05  5:42 ` [PATCH master v2 4/4] ARM: i.MX8MN: " Ahmad Fatoum
@ 2022-08-08 13:04   ` Sascha Hauer
  2022-08-08 14:01     ` Ahmad Fatoum
  0 siblings, 1 reply; 6+ messages in thread
From: Sascha Hauer @ 2022-08-08 13:04 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox, mfe, lst

On Fri, Aug 05, 2022 at 07:42:15AM +0200, Ahmad Fatoum wrote:
> When i.MX8MN support was first added, upstream device tree did list no
> power domains. Now it does and we defer probe of USB indefinitely
> because we have no power domain driver. If we need to do PCI on the
> i.MX8MM in barebox, there'll likely be no way around importing the power
> domain driver, but for USB which used to work, only thing we need to do
> is ignore the new power domain specification. Do so by adding the
> new barebox,allow-dummy property to the new known-enabled power domain.
> 
> Fixes: b01786baa849 ("dts: update to v5.18-rc1")
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> v1 -> v2:
>   - no change
> ---
>  arch/arm/dts/imx8mn-evk.dtsi | 2 ++
>  arch/arm/dts/imx8mn.dtsi     | 5 +++++
>  2 files changed, 7 insertions(+)
>  create mode 100644 arch/arm/dts/imx8mn.dtsi
> 
> diff --git a/arch/arm/dts/imx8mn-evk.dtsi b/arch/arm/dts/imx8mn-evk.dtsi
> index ceeb5f8b9384..aeb357007991 100644
> --- a/arch/arm/dts/imx8mn-evk.dtsi
> +++ b/arch/arm/dts/imx8mn-evk.dtsi
> @@ -4,6 +4,8 @@
>   * Copyright (C) 2017 Pengutronix, Lucas Stach <kernel@pengutronix.de>
>   */
>  
> +#include "imx8mn.dtsi"
> +
>  / {
>  	chosen {
>  		environment-sd {

This file doesn't exist in master.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH master v2 4/4] ARM: i.MX8MN: assume USBOTG power domains to be powered
  2022-08-08 13:04   ` Sascha Hauer
@ 2022-08-08 14:01     ` Ahmad Fatoum
  0 siblings, 0 replies; 6+ messages in thread
From: Ahmad Fatoum @ 2022-08-08 14:01 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox, mfe, lst

Hi,

On 08.08.22 15:04, Sascha Hauer wrote:
> On Fri, Aug 05, 2022 at 07:42:15AM +0200, Ahmad Fatoum wrote:
>> When i.MX8MN support was first added, upstream device tree did list no
>> power domains. Now it does and we defer probe of USB indefinitely
>> because we have no power domain driver. If we need to do PCI on the
>> i.MX8MM in barebox, there'll likely be no way around importing the power
>> domain driver, but for USB which used to work, only thing we need to do
>> is ignore the new power domain specification. Do so by adding the
>> new barebox,allow-dummy property to the new known-enabled power domain.
>>
>> Fixes: b01786baa849 ("dts: update to v5.18-rc1")
>> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
>> ---
>> v1 -> v2:
>>   - no change
>> ---
>>  arch/arm/dts/imx8mn-evk.dtsi | 2 ++
>>  arch/arm/dts/imx8mn.dtsi     | 5 +++++
>>  2 files changed, 7 insertions(+)
>>  create mode 100644 arch/arm/dts/imx8mn.dtsi
>>
>> diff --git a/arch/arm/dts/imx8mn-evk.dtsi b/arch/arm/dts/imx8mn-evk.dtsi
>> index ceeb5f8b9384..aeb357007991 100644
>> --- a/arch/arm/dts/imx8mn-evk.dtsi
>> +++ b/arch/arm/dts/imx8mn-evk.dtsi
>> @@ -4,6 +4,8 @@
>>   * Copyright (C) 2017 Pengutronix, Lucas Stach <kernel@pengutronix.de>
>>   */
>>  
>> +#include "imx8mn.dtsi"
>> +
>>  / {
>>  	chosen {
>>  		environment-sd {
> 
> This file doesn't exist in master.

I just sent out v3. On merging next, you'll get a conflict
which can be resolved by deleteing imx8mn-evk.dts and sticking
#include "imx8mn.dtsi" into the new imx8mn-evk.dtsi.

Thanks,
Ahmad

> 
> Sascha
> 


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-08-08 14:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-05  5:42 [PATCH master v2 1/4] soc: imx: gpcv2: associate PGC device tree node with platform device Ahmad Fatoum
2022-08-05  5:42 ` [PATCH master v2 2/4] drivers: power: ignore power domains with barebox,allow-dummy Ahmad Fatoum
2022-08-05  5:42 ` [PATCH master v2 3/4] ARM: i.MX8MM: assume USBOTG power domains to be powered Ahmad Fatoum
2022-08-05  5:42 ` [PATCH master v2 4/4] ARM: i.MX8MN: " Ahmad Fatoum
2022-08-08 13:04   ` Sascha Hauer
2022-08-08 14:01     ` Ahmad Fatoum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox