diff mbox series

[U-Boot,35/41] dm: core: device: enable power domain in probe

Message ID 20180528122526.20597-36-peng.fan@nxp.com
State Superseded
Delegated to: Stefano Babic
Headers show
Series imx: add i.MX8QXP support | expand

Commit Message

Peng Fan May 28, 2018, 12:25 p.m. UTC
Enable power domain associated with the device when probe.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Simon Glass <sjg@chromium.org>
---
 drivers/core/device.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Simon Glass May 30, 2018, 7:18 p.m. UTC | #1
On 28 May 2018 at 06:25, Peng Fan <peng.fan@nxp.com> wrote:
> Enable power domain associated with the device when probe.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> Cc: Simon Glass <sjg@chromium.org>
> ---
>  drivers/core/device.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>

How is this feature tested at present? Can you add something to the
power-domain test?
Peng Fan July 18, 2018, 12:56 p.m. UTC | #2
Hi Simon

> -----Original Message-----
> From: sjg@google.com [mailto:sjg@google.com] On Behalf Of Simon Glass
> Sent: 2018年5月31日 3:19
> To: Peng Fan <peng.fan@nxp.com>
> Cc: Stefano Babic <sbabic@denx.de>; Fabio Estevam
> <fabio.estevam@nxp.com>; U-Boot Mailing List <u-boot@lists.denx.de>
> Subject: Re: [PATCH 35/41] dm: core: device: enable power domain in probe
> 
> On 28 May 2018 at 06:25, Peng Fan <peng.fan@nxp.com> wrote:
> > Enable power domain associated with the device when probe.
> >
> > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > Cc: Simon Glass <sjg@chromium.org>
> > ---
> >  drivers/core/device.c | 7 +++++++
> >  1 file changed, 7 insertions(+)
> >
> 
> How is this feature tested at present? Can you add something to the
> power-domain test?

Sorry for late reply. 
Do you mean add code to test/dm/power-domain.c?
And the test is run test/run?

Thanks,
Peng.
Simon Glass July 19, 2018, 1:32 a.m. UTC | #3
Hi Peng,

On 18 July 2018 at 06:56, Peng Fan <peng.fan@nxp.com> wrote:
> Hi Simon
>
>> -----Original Message-----
>> From: sjg@google.com [mailto:sjg@google.com] On Behalf Of Simon Glass
>> Sent: 2018年5月31日 3:19
>> To: Peng Fan <peng.fan@nxp.com>
>> Cc: Stefano Babic <sbabic@denx.de>; Fabio Estevam
>> <fabio.estevam@nxp.com>; U-Boot Mailing List <u-boot@lists.denx.de>
>> Subject: Re: [PATCH 35/41] dm: core: device: enable power domain in probe
>>
>> On 28 May 2018 at 06:25, Peng Fan <peng.fan@nxp.com> wrote:
>> > Enable power domain associated with the device when probe.
>> >
>> > Signed-off-by: Peng Fan <peng.fan@nxp.com>
>> > Cc: Simon Glass <sjg@chromium.org>
>> > ---
>> >  drivers/core/device.c | 7 +++++++
>> >  1 file changed, 7 insertions(+)
>> >
>>
>> How is this feature tested at present? Can you add something to the
>> power-domain test?
>
> Sorry for late reply.
> Do you mean add code to test/dm/power-domain.c?
> And the test is run test/run?

Yes and yes - or 'make tests'.

We really should have a 'make check' target.

Regards,
Simon
diff mbox series

Patch

diff --git a/drivers/core/device.c b/drivers/core/device.c
index e048e1a659..b6950d9dbb 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -26,6 +26,7 @@ 
 #include <dm/util.h>
 #include <linux/err.h>
 #include <linux/list.h>
+#include <power-domain.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -296,6 +297,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;
@@ -375,6 +377,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;