Skip to content

Commit a3b884c

Browse files
Nicolas Pitresudeep-holla
authored andcommitted
firmware: arm_scmi: Add clock management to the SCMI power domain
Clocks requiring non-atomic contexts are supported by the generic clock PM layer since commit 0bfa082 ("PM: clk: make PM clock layer compatible with clocks that must sleep"). That means we can have SCMI-based clocks be managed by the SCMI power domain now. Link: https://lore.kernel.org/r/[email protected] Tested-by: Dien Pham <[email protected]> Reviewed-by: Gaku Inami <[email protected]> Signed-off-by: Nicolas Pitre <[email protected]> Signed-off-by: Sudeep Holla <[email protected]>
1 parent 6efb943 commit a3b884c

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

drivers/firmware/arm_scmi/scmi_pm_domain.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <linux/err.h>
99
#include <linux/io.h>
1010
#include <linux/module.h>
11+
#include <linux/pm_clock.h>
1112
#include <linux/pm_domain.h>
1213
#include <linux/scmi_protocol.h>
1314

@@ -52,6 +53,27 @@ static int scmi_pd_power_off(struct generic_pm_domain *domain)
5253
return scmi_pd_power(domain, false);
5354
}
5455

56+
static int scmi_pd_attach_dev(struct generic_pm_domain *pd, struct device *dev)
57+
{
58+
int ret;
59+
60+
ret = pm_clk_create(dev);
61+
if (ret)
62+
return ret;
63+
64+
ret = of_pm_clk_add_clks(dev);
65+
if (ret >= 0)
66+
return 0;
67+
68+
pm_clk_destroy(dev);
69+
return ret;
70+
}
71+
72+
static void scmi_pd_detach_dev(struct generic_pm_domain *pd, struct device *dev)
73+
{
74+
pm_clk_destroy(dev);
75+
}
76+
5577
static int scmi_pm_domain_probe(struct scmi_device *sdev)
5678
{
5779
int num_domains, i;
@@ -102,6 +124,10 @@ static int scmi_pm_domain_probe(struct scmi_device *sdev)
102124
scmi_pd->genpd.name = scmi_pd->name;
103125
scmi_pd->genpd.power_off = scmi_pd_power_off;
104126
scmi_pd->genpd.power_on = scmi_pd_power_on;
127+
scmi_pd->genpd.attach_dev = scmi_pd_attach_dev;
128+
scmi_pd->genpd.detach_dev = scmi_pd_detach_dev;
129+
scmi_pd->genpd.flags = GENPD_FLAG_PM_CLK |
130+
GENPD_FLAG_ACTIVE_WAKEUP;
105131

106132
pm_genpd_init(&scmi_pd->genpd, NULL,
107133
state == SCMI_POWER_STATE_GENERIC_OFF);

0 commit comments

Comments
 (0)