Skip to contentSkip to conversation

configs: opos6uldev: undef CONFIG_POWER_DOMAIN when SPL_BUILD

PATCH New Peng Fan 2 participants 11 messages Jul 24, 2018 – Jul 27, 2018

lore
Share & tools
lore

Peng Fan

author
#0 lore raw

PATCH 1/4 configs: opos6uldev: undef CONFIG_POWER_DOMAIN when SPL_BUILD

Because CONFIG_POWER_DOMAIN is enabled in defconfig, however driver/power/domain is not built for SPL, there is build failure when power_domain_on added to device_probe. Because power domain is not needed in SPL, let's undef it.

Cc "Sébastien Szymanski" <[email protected]>
Cc Stefano Babic <[email protected]>

---

Need to find a way to avoid SPL build failure in future patch, but in this patchset let's undef CONFIG_POWER_DOMAIN first, because it is not needed.

 include/configs/opos6uldev.h | 1 +
 1 file changed, 1 insertion(+)
include/configs/opos6uldev.h +1 -0
index b634d9eb03..75fefec0ac 100644
@@ -15,6 +15,7 @@
 
 #ifdef CONFIG_SPL_BUILD
 #undef CONFIG_DM_REGULATOR
+#undef CONFIG_POWER_DOMAIN
 #endif
 #endif
 
Signature · 1 line
2.14.1
author
#1 lore raw

PATCH 2/4 power-domain: add dummy functions when CONFIG_POWER_DOMAIN not defined

Add dummy functions when CONFIG_POWER_DOMAIN not defined.

---
 include/power-domain.h | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
include/power-domain.h +28 -0
index aba8c0f65c..fe2a1c5119 100644
@@ -87,7 +87,14 @@ struct power_domain {
  * @power_domain	A pointer to a power domain struct to initialize.
  * @return 0 if OK, or a negative error code.
  */
+#ifdef CONFIG_POWER_DOMAIN
 int power_domain_get(struct udevice *dev, struct power_domain *power_domain);
+#else
+int power_domain_get(struct udevice *dev, struct power_domain *power_domain)
+{
+	return -EINVAL;
+}
+#endif
 
 /**
  * power_domain_free - Free a previously requested power domain.
@@ -96,7 +103,14 @@ int power_domain_get(struct udevice *dev, struct power_domain *power_domain);
  *		requested by power_domain_get().
  * @return 0 if OK, or a negative error code.
  */
+#ifdef CONFIG_POWER_DOMAIN
 int power_domain_free(struct power_domain *power_domain);
+#else
+int power_domain_free(struct power_domain *power_domain)
+{
+	return -EINVAL;
+}
+#endif
 
 /**
  * power_domain_on - Enable power to a power domain.
@@ -105,7 +119,14 @@ int power_domain_free(struct power_domain *power_domain);
  *		requested by power_domain_get().
  * @return 0 if OK, or a negative error code.
  */
+#ifdef CONFIG_POWER_DOMAIN
 int power_domain_on(struct power_domain *power_domain);
+#else
+int power_domain_on(struct power_domain *power_domain)
+{
+	return -EINVAL;
+}
+#endif
 
 /**
  * power_domain_off - Disable power ot a power domain.
@@ -114,6 +135,13 @@ int power_domain_on(struct power_domain *power_domain);
  *		requested by power_domain_get().
  * @return 0 if OK, or a negative error code.
  */
+#ifdef CONFIG_POWER_DOMAIN
 int power_domain_off(struct power_domain *power_domain);
+#else
+int power_domain_off(struct power_domain *power_domain)
+{
+	return -EINVAL;
+}
+#endif
 
 #endif
Signature · 1 line
2.14.1
#2 lore raw

PATCH 2/4 power-domain: add dummy functions when CONFIG_POWER_DOMAIN not defined

Hi Peng,

Quoted 13 lines · Peng Fan

Add dummy functions when CONFIG_POWER_DOMAIN not defined.

---
 include/power-domain.h | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
include/power-domain.h +0 -0
index aba8c0f65c..fe2a1c5119 100644

include/power-domain.h struct power_domain { · line 95

Quoted 9 lines
include/power-domain.h +5 -0
@@ -87,7 +87,14 @@ struct power_domain {
  * @power_domain       A pointer to a power domain struct to initialize.
  * @return 0 if OK, or a negative error code.
  */
+#ifdef CONFIG_POWER_DOMAIN
 int power_domain_get(struct udevice *dev, struct power_domain *power_domain);
+#else
+int power_domain_get(struct udevice *dev, struct power_domain *power_domain)
+{
+       return -EINVAL;

Actually shouldn't this be -ENOSYS?

Quoted 50 lines
include/power-domain.h +23 -1
+}
+#endif
 
 /**
  * power_domain_free - Free a previously requested power domain.
@@ -96,7 +103,14 @@ int power_domain_get(struct udevice *dev, struct power_domain *power_domain);
  *             requested by power_domain_get().
  * @return 0 if OK, or a negative error code.
  */
+#ifdef CONFIG_POWER_DOMAIN
 int power_domain_free(struct power_domain *power_domain);
+#else
+int power_domain_free(struct power_domain *power_domain)
+{
+       return -EINVAL;
+}
+#endif
 
 /**
  * power_domain_on - Enable power to a power domain.
@@ -105,7 +119,14 @@ int power_domain_free(struct power_domain *power_domain);
  *             requested by power_domain_get().
  * @return 0 if OK, or a negative error code.
  */
+#ifdef CONFIG_POWER_DOMAIN
 int power_domain_on(struct power_domain *power_domain);
+#else
+int power_domain_on(struct power_domain *power_domain)
+{
+       return -EINVAL;
+}
+#endif
 
 /**
  * power_domain_off - Disable power ot a power domain.
@@ -114,6 +135,13 @@ int power_domain_on(struct power_domain *power_domain);
  *             requested by power_domain_get().
  * @return 0 if OK, or a negative error code.
  */
+#ifdef CONFIG_POWER_DOMAIN
 int power_domain_off(struct power_domain *power_domain);
+#else
+int power_domain_off(struct power_domain *power_domain)
+{
+       return -EINVAL;
+}
+#endif
 
 #endif
--
Quoted 2 lines

2.14.1

Regards,
Simon

author
#3 lore raw

PATCH 3/4 dm: core: device: enable power domain in probe

In reply to Peng Fan

Enable power domain associated with the device when probe.

---
 drivers/core/device.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/core/device.c +7 -0
index d5f5fc31b0..207d566b71 100644
@@ -26,6 +26,7 @@
 #include <dm/util.h>
 #include <linux/err.h>
 #include <linux/list.h>
+#include <power-domain.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -304,6 +305,7 @@ static void *alloc_priv(int size, uint flags)
 
 int device_probe(struct udevice *dev)
 {
+	struct power_domain pd;
 	const struct driver *drv;
 	int size = 0;
 	int ret;
@@ -383,6 +385,11 @@ int device_probe(struct udevice *dev)
 	if (dev->parent && device_get_uclass_id(dev) != UCLASS_PINCTRL)
 		pinctrl_select_state(dev, "default");
 
+	if (dev->parent && device_get_uclass_id(dev) != UCLASS_POWER_DOMAIN) {
+		if (!power_domain_get(dev, &pd))
+			power_domain_on(&pd);
+	}
+
 	ret = uclass_pre_probe_device(dev);
 	if (ret)
 		goto fail;
Signature · 1 line
2.14.1
author
#5 lore raw

PATCH 4/4 dm: power-domain: query power domain after get device

In reply to Peng Fan

This is to test power_domain_on in device_probe. If the device has a power-domain property, enable it when probe the device. So add the test to check whether it is powered on or not.

---
 test/dm/power-domain.c | 2 ++
 1 file changed, 2 insertions(+)
test/dm/power-domain.c +2 -0
index a1e1df2bb2..48318218a9 100644
@@ -26,6 +26,8 @@ static int dm_test_power_domain(struct unit_test_state *uts)
 
 	ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "power-domain-test",
 					      &dev_test));
+	ut_asserteq(1, sandbox_power_domain_query(dev_power_domain,
+						  TEST_POWER_DOMAIN));
 	ut_assertok(sandbox_power_domain_test_get(dev_test));
 
 	ut_assertok(sandbox_power_domain_test_on(dev_test));
Signature · 1 line
2.14.1
#6 lore raw

PATCH 4/4 dm: power-domain: query power domain after get device

Quoted 10 lines · Peng Fan

This is to test power_domain_on in device_probe. If the device has a power-domain property, enable it when probe the device. So add the test to check whether it is powered on or not.

---
 test/dm/power-domain.c | 2 ++
 1 file changed, 2 insertions(+)
#7 lore raw

PATCH 1/4 configs: opos6uldev: undef CONFIG_POWER_DOMAIN when SPL_BUILD

In reply to Peng Fan

Hi Peng,

Quoted 8 lines · Peng Fan

Because CONFIG_POWER_DOMAIN is enabled in defconfig, however driver/power/domain is not built for SPL, there is build failure when power_domain_on added to device_probe. Because power domain is not needed in SPL, let's undef it.

Cc "Sébastien Szymanski" <[email protected]>
Cc Stefano Babic <[email protected]>
Quoted 8 lines

---

Need to find a way to avoid SPL build failure in future patch, but in this patchset let's undef CONFIG_POWER_DOMAIN first, because it is not needed.

 include/configs/opos6uldev.h | 1 +
 1 file changed, 1 insertion(+)

This should be handled by adding an SPL_POWER_DOMAIN option and converting existing uses to CONFIG_IS_ENABLED(POWER_DOMAIN)

Regards,
Simon

author
#8 lore raw

PATCH 1/4 configs: opos6uldev: undef CONFIG_POWER_DOMAIN when SPL_BUILD

Hi Simon,

Quoted 27 lines

-----Original Message-----
From: sjg at google.com [mailto:sjg at google.com] On Behalf Of Simon Glass
Sent: 2018年7月25日 10:46
To: Peng Fan <[email protected]>
Cc: U-Boot Mailing List <[email protected]>; dl-linux-imx <[email protected]>; Sébastien Szymanski <[email protected]>; Stefano Babic <[email protected]>
Subject: Re: [PATCH 1/4] configs: opos6uldev: undef CONFIG_POWER_DOMAIN when SPL_BUILD

Hi Peng,

Quoted 14 lines · Peng Fan

Because CONFIG_POWER_DOMAIN is enabled in defconfig, however driver/power/domain is not built for SPL, there is build failure when power_domain_on added to device_probe.
Because power domain is not needed in SPL, let's undef it.

Cc "Sébastien Szymanski" <[email protected]>
Cc Stefano Babic <[email protected]>

---

Need to find a way to avoid SPL build failure in future patch, but in this patchset let's undef CONFIG_POWER_DOMAIN first, because it is not needed.

Quoted 5 lines
Quoted 2 lines
 include/configs/opos6uldev.h | 1 +
 1 file changed, 1 insertion(+)

This should be handled by adding an SPL_POWER_DOMAIN option and converting existing uses to CONFIG_IS_ENABLED(POWER_DOMAIN)

The opos6uldev_defconfig has "CONFIG_POWER_DOMAIN=y", so when building
SPL, this macro is still effective.
Opos6uldev compiles driver/core/device.c which includes power-domain.h in my later patch. Because driver/power/domain is not built for SPL, so build failure for SPL.

The simple method for now is to undef CONFIG_POWER_DOMAIN for SPL build. If use CONFIG_IS_ENABLED, the undef CONFIG_POWER_DOMAIN will not be detected in Kconfig.

Simply introduce SPL_POWER_DOMAIN could not fix this issue. Need to let SPL choose CONFIG_SPL_POWER_DOMAIN, but not CONFIG_POWER_DOMAIN, I do not have a clear idea on how.

Thanks,
Peng.

Quoted 3 lines

Regards,
Simon

#9 lore raw

PATCH 1/4 configs: opos6uldev: undef CONFIG_POWER_DOMAIN when SPL_BUILD

Hi Peng,

Quoted 40 lines · Peng Fan

Hi Simon,

Quoted 27 lines

-----Original Message-----
From: sjg at google.com [mailto:sjg at google.com] On Behalf Of Simon Glass
Sent: 2018年7月25日 10:46
To: Peng Fan <[email protected]>
Cc: U-Boot Mailing List <[email protected]>; dl-linux-imx <[email protected]>; Sébastien Szymanski <[email protected]>; Stefano Babic <[email protected]>
Subject: Re: [PATCH 1/4] configs: opos6uldev: undef CONFIG_POWER_DOMAIN when SPL_BUILD

Hi Peng,

Quoted 14 lines · Peng Fan

Because CONFIG_POWER_DOMAIN is enabled in defconfig, however driver/power/domain is not built for SPL, there is build failure when power_domain_on added to device_probe.
Because power domain is not needed in SPL, let's undef it.

Cc "Sébastien Szymanski" <[email protected]>
Cc Stefano Babic <[email protected]>

---

Need to find a way to avoid SPL build failure in future patch, but in this patchset let's undef CONFIG_POWER_DOMAIN first, because it is not needed.

Quoted 5 lines
Quoted 2 lines
 include/configs/opos6uldev.h | 1 +
 1 file changed, 1 insertion(+)

This should be handled by adding an SPL_POWER_DOMAIN option and converting existing uses to CONFIG_IS_ENABLED(POWER_DOMAIN)

The opos6uldev_defconfig has "CONFIG_POWER_DOMAIN=y", so when building
SPL, this macro is still effective.
Opos6uldev compiles driver/core/device.c which includes power-domain.h in my later patch. Because driver/power/domain is not built for SPL, so build failure for SPL.

Quoted 5 lines

The simple method for now is to undef CONFIG_POWER_DOMAIN for SPL build. If use CONFIG_IS_ENABLED, the undef CONFIG_POWER_DOMAIN will not be detected in Kconfig.

Simply introduce SPL_POWER_DOMAIN could not fix this issue. Need to let SPL choose CONFIG_SPL_POWER_DOMAIN, but not CONFIG_POWER_DOMAIN, I do not have a clear idea on how.

Here's how it works:

1. Have two separate Kconfig options: CONFIG_POWER_DOMAIN and CONFIG_SPL_POWER_DOMAIN
2. Enable CONFIG_POWER_DOMAIN in the board config, but not CONFIG_SPL_POWER_DOMAIN
3. Use CONFIG_IS_ENABLED(POWER_DOMAIN) everywhere (with if() or #if)
4. Now, U-Boot proper will support POWER_DOMAIN, but SPL will not

The #undef mechanism is the old way of doing it, before we had CONFIG_IS_ENABLED

Regards,
Simon

author
#10 lore raw

PATCH 1/4 configs: opos6uldev: undef CONFIG_POWER_DOMAIN when SPL_BUILD

Hi Simon,

Quoted 28 lines
Quoted 11 lines
Quoted 9 lines
Quoted 6 lines

Need to find a way to avoid SPL build failure in future patch, but in this patchset let's undef CONFIG_POWER_DOMAIN first, because it is not needed.

 include/configs/opos6uldev.h | 1 +
 1 file changed, 1 insertion(+)

This should be handled by adding an SPL_POWER_DOMAIN option and converting existing uses to CONFIG_IS_ENABLED(POWER_DOMAIN)

The opos6uldev_defconfig has "CONFIG_POWER_DOMAIN=y", so when

building

Quoted 2 lines

SPL, this macro is still effective.
Opos6uldev compiles driver/core/device.c which includes power-domain.h in

my later patch.

Quoted 3 lines

Because driver/power/domain is not built for SPL, so build failure for SPL.

The simple method for now is to undef CONFIG_POWER_DOMAIN for SPL

build.

Quoted 1 line

If use CONFIG_IS_ENABLED, the undef CONFIG_POWER_DOMAIN will not be

detected in Kconfig.

Quoted 3 lines

Simply introduce SPL_POWER_DOMAIN could not fix this issue. Need to let SPL choose CONFIG_SPL_POWER_DOMAIN, but not

CONFIG_POWER_DOMAIN, I do not have a clear idea on how.

Here's how it works:

Quoted 9 lines

1. Have two separate Kconfig options: CONFIG_POWER_DOMAIN and CONFIG_SPL_POWER_DOMAIN 2. Enable CONFIG_POWER_DOMAIN in the board config, but not CONFIG_SPL_POWER_DOMAIN 3. Use CONFIG_IS_ENABLED(POWER_DOMAIN) everywhere (with if() or #if) 4. Now, U-Boot proper will support POWER_DOMAIN, but SPL will not

The #undef mechanism is the old way of doing it, before we had CONFIG_IS_ENABLED

Just posted out V2 following your suggestion.

Thanks,
Peng.

Quoted 2 lines

Regards,
Simon