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