hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (C) 2014 Linaro Ltd.
 *
 * Author: Ulf Hansson <ulf.hansson@linaro.org>
 *
 * Implements PM domains using the generic PM domain for ux500.
 */
#include <linux/printk.h>
#include <linux/slab.h>
#include <linux/err.h>
#include <linux/of.h>
#include <linux/pm_domain.h>
 
#include <dt-bindings/arm/ux500_pm_domains.h>
#include "pm_domains.h"
 
static int pd_power_off(struct generic_pm_domain *domain)
{
   /*
    * Handle the gating of the PM domain regulator here.
    *
    * Drivers/subsystems handling devices in the PM domain needs to perform
    * register context save/restore from their respective runtime PM
    * callbacks, to be able to enable PM domain gating/ungating.
    */
   return 0;
}
 
static int pd_power_on(struct generic_pm_domain *domain)
{
   /*
    * Handle the ungating of the PM domain regulator here.
    *
    * Drivers/subsystems handling devices in the PM domain needs to perform
    * register context save/restore from their respective runtime PM
    * callbacks, to be able to enable PM domain gating/ungating.
    */
   return 0;
}
 
static struct generic_pm_domain ux500_pm_domain_vape = {
   .name = "VAPE",
   .power_off = pd_power_off,
   .power_on = pd_power_on,
};
 
static struct generic_pm_domain *ux500_pm_domains[NR_DOMAINS] = {
   [DOMAIN_VAPE] = &ux500_pm_domain_vape,
};
 
static const struct of_device_id ux500_pm_domain_matches[] __initconst = {
   { .compatible = "stericsson,ux500-pm-domains", },
   { },
};
 
int __init ux500_pm_domains_init(void)
{
   struct device_node *np;
   struct genpd_onecell_data *genpd_data;
   int i;
 
   np = of_find_matching_node(NULL, ux500_pm_domain_matches);
   if (!np)
       return -ENODEV;
 
   genpd_data = kzalloc(sizeof(*genpd_data), GFP_KERNEL);
   if (!genpd_data)
       return -ENOMEM;
 
   genpd_data->domains = ux500_pm_domains;
   genpd_data->num_domains = ARRAY_SIZE(ux500_pm_domains);
 
   for (i = 0; i < ARRAY_SIZE(ux500_pm_domains); ++i)
       pm_genpd_init(ux500_pm_domains[i], NULL, false);
 
   of_genpd_add_provider_onecell(np, genpd_data);
   return 0;
}