1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2014 Linaro Ltd.
5 * Author: Ulf Hansson <ulf.hansson@linaro.org>
7 * Implements PM domains using the generic PM domain for ux500.
9 #include <linux/device.h>
10 #include <linux/kernel.h>
11 #include <linux/platform_device.h>
12 #include <linux/printk.h>
13 #include <linux/slab.h>
14 #include <linux/err.h>
16 #include <linux/pm_domain.h>
18 #include <dt-bindings/arm/ux500_pm_domains.h>
20 static int pd_power_off(struct generic_pm_domain
*domain
)
23 * Handle the gating of the PM domain regulator here.
25 * Drivers/subsystems handling devices in the PM domain needs to perform
26 * register context save/restore from their respective runtime PM
27 * callbacks, to be able to enable PM domain gating/ungating.
32 static int pd_power_on(struct generic_pm_domain
*domain
)
35 * Handle the ungating of the PM domain regulator here.
37 * Drivers/subsystems handling devices in the PM domain needs to perform
38 * register context save/restore from their respective runtime PM
39 * callbacks, to be able to enable PM domain gating/ungating.
44 static struct generic_pm_domain ux500_pm_domain_vape
= {
46 .power_off
= pd_power_off
,
47 .power_on
= pd_power_on
,
50 static struct generic_pm_domain
*ux500_pm_domains
[NR_DOMAINS
] = {
51 [DOMAIN_VAPE
] = &ux500_pm_domain_vape
,
54 static const struct of_device_id ux500_pm_domain_matches
[] = {
55 { .compatible
= "stericsson,ux500-pm-domains", },
59 static int ux500_pm_domains_probe(struct platform_device
*pdev
)
61 struct device_node
*np
= pdev
->dev
.of_node
;
62 struct genpd_onecell_data
*genpd_data
;
68 genpd_data
= kzalloc(sizeof(*genpd_data
), GFP_KERNEL
);
72 genpd_data
->domains
= ux500_pm_domains
;
73 genpd_data
->num_domains
= ARRAY_SIZE(ux500_pm_domains
);
75 for (i
= 0; i
< ARRAY_SIZE(ux500_pm_domains
); ++i
)
76 pm_genpd_init(ux500_pm_domains
[i
], NULL
, false);
78 of_genpd_add_provider_onecell(np
, genpd_data
);
82 static struct platform_driver ux500_pm_domains_driver
= {
83 .probe
= ux500_pm_domains_probe
,
85 .name
= "ux500_pm_domains",
86 .of_match_table
= ux500_pm_domain_matches
,
90 static int __init
ux500_pm_domains_init(void)
92 return platform_driver_register(&ux500_pm_domains_driver
);
94 arch_initcall(ux500_pm_domains_init
);