From 7a3f15e7181cf5a9667ff410260397f0e51c9020 Mon Sep 17 00:00:00 2001 From: Matthias Brugger Date: Thu, 5 Sep 2019 10:48:49 +0200 Subject: dm: Fix default address cells return value Default address cells value on the livetree access function returns the wrong value. Fix this so that the value returned corresponds to the device tree specification. Signed-off-by: Matthias Brugger --- include/dm/of.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/dm/of.h b/include/dm/of.h index 461e25aa19d..6bef73b441c 100644 --- a/include/dm/of.h +++ b/include/dm/of.h @@ -111,7 +111,7 @@ static inline const char *of_node_full_name(const struct device_node *np) /* Default #address and #size cells */ #if !defined(OF_ROOT_NODE_ADDR_CELLS_DEFAULT) -#define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 1 +#define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 2 #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1 #endif -- cgit v1.3.1 From 9c1e982218b2eaa4afed835fe12ef91d14c9659c Mon Sep 17 00:00:00 2001 From: Peng Fan Date: Tue, 17 Sep 2019 09:29:19 +0000 Subject: power: domain: add dev_power_domain_on Add this new API to power on multiple domains attached to a device. Signed-off-by: Peng Fan Reviewed-by: Lokesh Vutla Changed to static inline and added a condition into C file: Signed-off-by: Simon Glass --- drivers/power/domain/power-domain-uclass.c | 21 +++++++++++++++++++++ include/power-domain.h | 17 +++++++++++++++++ 2 files changed, 38 insertions(+) (limited to 'include') diff --git a/drivers/power/domain/power-domain-uclass.c b/drivers/power/domain/power-domain-uclass.c index 2ea0ff24c7a..c961436d62f 100644 --- a/drivers/power/domain/power-domain-uclass.c +++ b/drivers/power/domain/power-domain-uclass.c @@ -107,6 +107,27 @@ int power_domain_off(struct power_domain *power_domain) return ops->off(power_domain); } +#if !CONFIG_IS_ENABLED(OF_PLATDATA) +int dev_power_domain_on(struct udevice *dev) +{ + struct power_domain pd; + int i, count, ret; + + count = dev_count_phandle_with_args(dev, "power-domains", + "#power-domain-cells"); + for (i = 0; i < count; i++) { + ret = power_domain_get_by_index(dev, &pd, i); + if (ret) + return ret; + ret = power_domain_on(&pd); + if (ret) + return ret; + } + + return 0; +} +#endif + UCLASS_DRIVER(power_domain) = { .id = UCLASS_POWER_DOMAIN, .name = "power_domain", diff --git a/include/power-domain.h b/include/power-domain.h index ef15dc9f607..490fedbb128 100644 --- a/include/power-domain.h +++ b/include/power-domain.h @@ -155,4 +155,21 @@ static inline int power_domain_off(struct power_domain *power_domain) } #endif +/** + * dev_power_domain_on - Enable power domains for a device . + * + * @dev: The client device. + * + * @return 0 if OK, or a negative error code. + */ +#if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) && \ + CONFIG_IS_ENABLED(POWER_DOMAIN) +int dev_power_domain_on(struct udevice *dev); +#else +static inline int dev_power_domain_on(struct udevice *dev) +{ + return 0; +} +#endif + #endif -- cgit v1.3.1 From d8efa2ce2abe293c97576f47ccac708e233553b6 Mon Sep 17 00:00:00 2001 From: Jean-Jacques Hiblot Date: Thu, 26 Sep 2019 15:43:54 +0200 Subject: dm: device: Fix typo in the non-DEVRES version of devm_kmalloc_array() When DEVRES is not set, devm_kmalloc_array() is spelled devm_kmaloc_array() (with one 'l' only). Fixing it so that the name is the same with and without DEVRES. Signed-off-by: Jean-Jacques Hiblot Reviewed-by: Simon Glass --- include/dm/device.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/dm/device.h b/include/dm/device.h index defda0aebcb..44cc3d2bd01 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -945,8 +945,8 @@ static inline void *devm_kzalloc(struct udevice *dev, size_t size, gfp_t gfp) return kzalloc(size, gfp); } -static inline void *devm_kmaloc_array(struct udevice *dev, - size_t n, size_t size, gfp_t flags) +static inline void *devm_kmalloc_array(struct udevice *dev, + size_t n, size_t size, gfp_t flags) { /* TODO: add kmalloc_array() to linux/compat.h */ if (size != 0 && n > SIZE_MAX / size) -- cgit v1.3.1 From af94ad418dc72957d3b7398d83bfc5a1efd415db Mon Sep 17 00:00:00 2001 From: Lokesh Vutla Date: Fri, 27 Sep 2019 13:48:12 +0530 Subject: dm: core: Allow for not controlling the power-domain by DM framework In some remoteproc cases, enabling the power domain of the core will start running the core. In such cases image should be loaded before enabling the power domain. But the current DM framework enables the power-domain by default during probe. This is causing the remotecore to start and crash as there is no valid image loaded. In order to avoid this introduce a DM flag that doesn't allow for enabling/disabling the power-domain by DM framework. Signed-off-by: Lokesh Vutla Reviewed-by: Simon Glass --- drivers/core/device.c | 3 ++- include/dm/device.h | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/drivers/core/device.c b/drivers/core/device.c index 28363ff00ba..95f26efdd3b 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -393,7 +393,8 @@ int device_probe(struct udevice *dev) pinctrl_select_state(dev, "default"); if (CONFIG_IS_ENABLED(POWER_DOMAIN) && dev->parent && - device_get_uclass_id(dev) != UCLASS_POWER_DOMAIN) { + (device_get_uclass_id(dev) != UCLASS_POWER_DOMAIN) && + !(drv->flags & DM_FLAG_DEFAULT_PD_CTRL_OFF)) { ret = dev_power_domain_on(dev); if (ret) goto fail; diff --git a/include/dm/device.h b/include/dm/device.h index 44cc3d2bd01..d7ad9d6728b 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -61,6 +61,9 @@ struct driver_info; */ #define DM_FLAG_OS_PREPARE (1 << 10) +/* DM does not enable/disable the power domains corresponding to this device */ +#define DM_FLAG_DEFAULT_PD_CTRL_OFF (1 << 11) + /* * One or multiple of these flags are passed to device_remove() so that * a selective device removal as specified by the remove-stage and the -- cgit v1.3.1 From 0cf795a8024f36e2aaea3db8ab8b4d3805dc541c Mon Sep 17 00:00:00 2001 From: Lokesh Vutla Date: Fri, 27 Sep 2019 13:48:14 +0530 Subject: power: domain: Introduce dev_power_domain_off Add dev_power_domain_off() api to disable all the power-domains corresponding to a device Signed-off-by: Lokesh Vutla Reviewed-by: Simon Glass --- drivers/power/domain/power-domain-uclass.c | 35 ++++++++++++++++++++++++------ include/power-domain.h | 17 +++++++++++++++ 2 files changed, 45 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/drivers/power/domain/power-domain-uclass.c b/drivers/power/domain/power-domain-uclass.c index c961436d62f..80df5aff501 100644 --- a/drivers/power/domain/power-domain-uclass.c +++ b/drivers/power/domain/power-domain-uclass.c @@ -7,6 +7,7 @@ #include #include #include +#include static inline struct power_domain_ops *power_domain_dev_ops(struct udevice *dev) { @@ -107,11 +108,11 @@ int power_domain_off(struct power_domain *power_domain) return ops->off(power_domain); } -#if !CONFIG_IS_ENABLED(OF_PLATDATA) -int dev_power_domain_on(struct udevice *dev) +#if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) +static int dev_power_domain_ctrl(struct udevice *dev, bool on) { struct power_domain pd; - int i, count, ret; + int i, count, ret = 0; count = dev_count_phandle_with_args(dev, "power-domains", "#power-domain-cells"); @@ -119,12 +120,32 @@ int dev_power_domain_on(struct udevice *dev) ret = power_domain_get_by_index(dev, &pd, i); if (ret) return ret; - ret = power_domain_on(&pd); - if (ret) - return ret; + if (on) + ret = power_domain_on(&pd); + else + ret = power_domain_off(&pd); } - return 0; + /* + * power_domain_get() bound the device, thus + * we must remove it again to prevent unbinding + * active devices (which would result in unbind + * error). + */ + if (count > 0 && !on) + device_remove(pd.dev, DM_REMOVE_NORMAL); + + return ret; +} + +int dev_power_domain_on(struct udevice *dev) +{ + return dev_power_domain_ctrl(dev, true); +} + +int dev_power_domain_off(struct udevice *dev) +{ + return dev_power_domain_ctrl(dev, false); } #endif diff --git a/include/power-domain.h b/include/power-domain.h index 490fedbb128..72ff2ff25ba 100644 --- a/include/power-domain.h +++ b/include/power-domain.h @@ -172,4 +172,21 @@ static inline int dev_power_domain_on(struct udevice *dev) } #endif +/** + * dev_power_domain_off - Disable power domains for a device . + * + * @dev: The client device. + * + * @return 0 if OK, or a negative error code. + */ +#if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) && \ + CONFIG_IS_ENABLED(POWER_DOMAIN) +int dev_power_domain_off(struct udevice *dev); +#else +static inline int dev_power_domain_off(struct udevice *dev) +{ + return 0; +} +#endif + #endif -- cgit v1.3.1