Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * Copyright (C) 2014 Linaro Ltd.
0004  *
0005  * Author: Ulf Hansson <ulf.hansson@linaro.org>
0006  *
0007  * Implements PM domains using the generic PM domain for ux500.
0008  */
0009 #include <linux/printk.h>
0010 #include <linux/slab.h>
0011 #include <linux/err.h>
0012 #include <linux/of.h>
0013 #include <linux/pm_domain.h>
0014 
0015 #include <dt-bindings/arm/ux500_pm_domains.h>
0016 #include "pm_domains.h"
0017 
0018 static int pd_power_off(struct generic_pm_domain *domain)
0019 {
0020     /*
0021      * Handle the gating of the PM domain regulator here.
0022      *
0023      * Drivers/subsystems handling devices in the PM domain needs to perform
0024      * register context save/restore from their respective runtime PM
0025      * callbacks, to be able to enable PM domain gating/ungating.
0026      */
0027     return 0;
0028 }
0029 
0030 static int pd_power_on(struct generic_pm_domain *domain)
0031 {
0032     /*
0033      * Handle the ungating of the PM domain regulator here.
0034      *
0035      * Drivers/subsystems handling devices in the PM domain needs to perform
0036      * register context save/restore from their respective runtime PM
0037      * callbacks, to be able to enable PM domain gating/ungating.
0038      */
0039     return 0;
0040 }
0041 
0042 static struct generic_pm_domain ux500_pm_domain_vape = {
0043     .name = "VAPE",
0044     .power_off = pd_power_off,
0045     .power_on = pd_power_on,
0046 };
0047 
0048 static struct generic_pm_domain *ux500_pm_domains[NR_DOMAINS] = {
0049     [DOMAIN_VAPE] = &ux500_pm_domain_vape,
0050 };
0051 
0052 static const struct of_device_id ux500_pm_domain_matches[] __initconst = {
0053     { .compatible = "stericsson,ux500-pm-domains", },
0054     { },
0055 };
0056 
0057 int __init ux500_pm_domains_init(void)
0058 {
0059     struct device_node *np;
0060     struct genpd_onecell_data *genpd_data;
0061     int i;
0062 
0063     np = of_find_matching_node(NULL, ux500_pm_domain_matches);
0064     if (!np)
0065         return -ENODEV;
0066 
0067     genpd_data = kzalloc(sizeof(*genpd_data), GFP_KERNEL);
0068     if (!genpd_data)
0069         return -ENOMEM;
0070 
0071     genpd_data->domains = ux500_pm_domains;
0072     genpd_data->num_domains = ARRAY_SIZE(ux500_pm_domains);
0073 
0074     for (i = 0; i < ARRAY_SIZE(ux500_pm_domains); ++i)
0075         pm_genpd_init(ux500_pm_domains[i], NULL, false);
0076 
0077     of_genpd_add_provider_onecell(np, genpd_data);
0078     return 0;
0079 }