platform: tegra: Add powergate supporting function
Sumit Singh [Fri, 3 Apr 2015 05:41:32 +0000 (10:41 +0530)]
Add a function which provides powergate-id for a
powergate partition reading from device tree.

Bug 200105664

Change-Id: I4567b74bdf705561ee3e7991893e940ad7e59798
Signed-off-by: Sumit Singh <sumsingh@nvidia.com>
Reviewed-on: http://git-master/r/727339
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Tested-by: Bharat Nihalani <bnihalani@nvidia.com>

drivers/platform/tegra/pm_domains.c
include/linux/tegra_pm_domains.h

index b0f54d5..c7aebd0 100644 (file)
@@ -512,6 +512,26 @@ void tegra_pd_remove_sd(struct generic_pm_domain *sd)
 }
 EXPORT_SYMBOL(tegra_pd_remove_sd);
 
+int tegra_pd_get_powergate_id(struct of_device_id *dev_id)
+{
+       struct device_node *dn = NULL;
+       u32 partition_id;
+       int ret = -EINVAL;
+
+       for_each_matching_node(dn, dev_id) {
+               ret = of_property_read_u32(dn, "partition-id", &partition_id);
+               break;
+       }
+
+       if (ret) {
+               pr_err("Reading powergate-id failed\n");
+               return ret;
+       }
+
+       return partition_id;
+}
+EXPORT_SYMBOL(tegra_pd_get_powergate_id);
+
 #else
 
 struct domain_client {
index 83b167a..2cfa6b2 100644 (file)
@@ -68,4 +68,13 @@ static inline void tegra_ape_pd_add_device(struct device *dev) { }
 static inline void tegra_ape_pd_remove_device(struct device *dev) { }
 #endif /* CONFIG_TEGRA_MC_DOMAINS */
 
+#ifdef CONFIG_PM_GENERIC_DOMAINS_OF
+int tegra_pd_get_powergate_id(struct of_device_id *dev_id);
+#else
+static inline int tegra_pd_get_powergate_id(struct of_device_id *dev_id)
+{
+       return -EINVAL;
+}
+#endif
+
 #endif /* _INCLUDE_TEGRA_PM_DOMAINS_H_ */