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