pm-domains.c (cfee1b50775869de9076d021ea11a8438854dcba) pm-domains.c (0d946ef4646092a23de2baf7b9d3063fe5571e82)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Rockchip Generic power domain support.
4 *
5 * Copyright (c) 2015 ROCKCHIP, Co. Ltd.
6 */
7
8#include <linux/io.h>

--- 790 unchanged lines hidden (view full) ---

799 regmap_write(pmu->regmap, domain_reg_offset, count);
800 /* ... and then power up count. */
801 regmap_write(pmu->regmap, domain_reg_offset + 4, count);
802}
803
804static int rockchip_pm_add_subdomain(struct rockchip_pmu *pmu,
805 struct device_node *parent)
806{
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Rockchip Generic power domain support.
4 *
5 * Copyright (c) 2015 ROCKCHIP, Co. Ltd.
6 */
7
8#include <linux/io.h>

--- 790 unchanged lines hidden (view full) ---

799 regmap_write(pmu->regmap, domain_reg_offset, count);
800 /* ... and then power up count. */
801 regmap_write(pmu->regmap, domain_reg_offset + 4, count);
802}
803
804static int rockchip_pm_add_subdomain(struct rockchip_pmu *pmu,
805 struct device_node *parent)
806{
807 struct device_node *np;
808 struct generic_pm_domain *child_domain, *parent_domain;
809 int error;
810
807 struct generic_pm_domain *child_domain, *parent_domain;
808 int error;
809
811 for_each_child_of_node(parent, np) {
810 for_each_child_of_node_scoped(parent, np) {
812 u32 idx;
813
814 error = of_property_read_u32(parent, "reg", &idx);
815 if (error) {
816 dev_err(pmu->dev,
817 "%pOFn: failed to retrieve domain id (reg): %d\n",
818 parent, error);
811 u32 idx;
812
813 error = of_property_read_u32(parent, "reg", &idx);
814 if (error) {
815 dev_err(pmu->dev,
816 "%pOFn: failed to retrieve domain id (reg): %d\n",
817 parent, error);
819 goto err_out;
818 return error;
820 }
821 parent_domain = pmu->genpd_data.domains[idx];
822
823 error = rockchip_pm_add_one_domain(pmu, np);
824 if (error) {
825 dev_err(pmu->dev, "failed to handle node %pOFn: %d\n",
826 np, error);
819 }
820 parent_domain = pmu->genpd_data.domains[idx];
821
822 error = rockchip_pm_add_one_domain(pmu, np);
823 if (error) {
824 dev_err(pmu->dev, "failed to handle node %pOFn: %d\n",
825 np, error);
827 goto err_out;
826 return error;
828 }
829
830 error = of_property_read_u32(np, "reg", &idx);
831 if (error) {
832 dev_err(pmu->dev,
833 "%pOFn: failed to retrieve domain id (reg): %d\n",
834 np, error);
827 }
828
829 error = of_property_read_u32(np, "reg", &idx);
830 if (error) {
831 dev_err(pmu->dev,
832 "%pOFn: failed to retrieve domain id (reg): %d\n",
833 np, error);
835 goto err_out;
834 return error;
836 }
837 child_domain = pmu->genpd_data.domains[idx];
838
839 error = pm_genpd_add_subdomain(parent_domain, child_domain);
840 if (error) {
841 dev_err(pmu->dev, "%s failed to add subdomain %s: %d\n",
842 parent_domain->name, child_domain->name, error);
835 }
836 child_domain = pmu->genpd_data.domains[idx];
837
838 error = pm_genpd_add_subdomain(parent_domain, child_domain);
839 if (error) {
840 dev_err(pmu->dev, "%s failed to add subdomain %s: %d\n",
841 parent_domain->name, child_domain->name, error);
843 goto err_out;
842 return error;
844 } else {
845 dev_dbg(pmu->dev, "%s add subdomain: %s\n",
846 parent_domain->name, child_domain->name);
847 }
848
849 rockchip_pm_add_subdomain(pmu, np);
850 }
851
852 return 0;
843 } else {
844 dev_dbg(pmu->dev, "%s add subdomain: %s\n",
845 parent_domain->name, child_domain->name);
846 }
847
848 rockchip_pm_add_subdomain(pmu, np);
849 }
850
851 return 0;
853
854err_out:
855 of_node_put(np);
856 return error;
857}
858
859static int rockchip_pm_domain_probe(struct platform_device *pdev)
860{
861 struct device *dev = &pdev->dev;
862 struct device_node *np = dev->of_node;
852}
853
854static int rockchip_pm_domain_probe(struct platform_device *pdev)
855{
856 struct device *dev = &pdev->dev;
857 struct device_node *np = dev->of_node;
863 struct device_node *node;
864 struct device *parent;
865 struct rockchip_pmu *pmu;
866 const struct rockchip_pmu_info *pmu_info;
867 int error;
868
869 if (!np) {
870 dev_err(dev, "device tree node not found\n");
871 return -ENODEV;

--- 41 unchanged lines hidden (view full) ---

913 error = -ENODEV;
914
915 /*
916 * Prevent any rockchip_pmu_block() from racing with the remainder of
917 * setup (clocks, register initialization).
918 */
919 mutex_lock(&dmc_pmu_mutex);
920
858 struct device *parent;
859 struct rockchip_pmu *pmu;
860 const struct rockchip_pmu_info *pmu_info;
861 int error;
862
863 if (!np) {
864 dev_err(dev, "device tree node not found\n");
865 return -ENODEV;

--- 41 unchanged lines hidden (view full) ---

907 error = -ENODEV;
908
909 /*
910 * Prevent any rockchip_pmu_block() from racing with the remainder of
911 * setup (clocks, register initialization).
912 */
913 mutex_lock(&dmc_pmu_mutex);
914
921 for_each_available_child_of_node(np, node) {
915 for_each_available_child_of_node_scoped(np, node) {
922 error = rockchip_pm_add_one_domain(pmu, node);
923 if (error) {
924 dev_err(dev, "failed to handle node %pOFn: %d\n",
925 node, error);
916 error = rockchip_pm_add_one_domain(pmu, node);
917 if (error) {
918 dev_err(dev, "failed to handle node %pOFn: %d\n",
919 node, error);
926 of_node_put(node);
927 goto err_out;
928 }
929
930 error = rockchip_pm_add_subdomain(pmu, node);
931 if (error < 0) {
932 dev_err(dev, "failed to handle subdomain node %pOFn: %d\n",
933 node, error);
920 goto err_out;
921 }
922
923 error = rockchip_pm_add_subdomain(pmu, node);
924 if (error < 0) {
925 dev_err(dev, "failed to handle subdomain node %pOFn: %d\n",
926 node, error);
934 of_node_put(node);
935 goto err_out;
936 }
937 }
938
939 if (error) {
940 dev_dbg(dev, "no power domains defined\n");
941 goto err_out;
942 }

--- 494 unchanged lines hidden ---
927 goto err_out;
928 }
929 }
930
931 if (error) {
932 dev_dbg(dev, "no power domains defined\n");
933 goto err_out;
934 }

--- 494 unchanged lines hidden ---