From patchwork Mon Jun 15 15:20:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 187946 Delivered-To: patches@linaro.org Received: by 2002:a54:30ca:0:0:0:0:0 with SMTP id e10csp2633505ecs; Mon, 15 Jun 2020 08:21:06 -0700 (PDT) X-Received: by 2002:a2e:998c:: with SMTP id w12mr14057243lji.143.1592234466672; Mon, 15 Jun 2020 08:21:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592234466; cv=none; d=google.com; s=arc-20160816; b=T34oUtWU3mcWsbsw18Grw6/r0beSjA7Uu543Kj2Q0mMCuH0mpz1f0g+hUhjTIpOBy/ QubcLde4TXjoDev8XneYr5NlrSe5wGglkFRk0ATCFJSn9XldsWU8JTNKpO+uzbw2wpA2 tfPlKyjbWlfwgsdT50TVKVjMzxslZSedxQzbwvzVZYoThe8qXoK921LKzpwf/3d+O3Hv yZAYBGA0b6VmB9aHI63UJ4EV4mxbQAcSxwN8ntejgDNieSMguEK07oe72PwPCVY31uZw oJ968xInCUuek18ONsTx9H3AXTMP8wOybNtUb0JWtXxpizIzpakO8y72pfW5k0ou+fmU zxtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=GC70gu/KuM6k/D+t12MJpeTyl5aXSJlixkvFE052RDs=; b=y/AeM+7sCr8AanLLi3g1Q/5DEe6fTfCSMZqKxTCS+t6y1mh1Y5RmeoFIWKOC1DIIM/ fqu5bUpGF3Hi3p2/mYMdNmIV8hsiYlYp/tz16pc25CUu+gwbeXPKBb/ru9QJqOZ6rZ6f Rf0Q23PewZqVsyehtyi9yg2ZeK1kNsDrmvSU0ol/IQejRq6fSyd72CH9ucQByrEglXry 6abUeetQoViv+j4un0UXq5V/GjiKSYN7JBmcnw/W04nOLN6Yqju7qpNMDdhLO3x9/URi LEMRDYdQuFjEyJjv+SwRQVUCHCWfLmhl6OZmiqLUx5e1qS5lIt3Sflw+7+Xnys9aH4Vd lUCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JnL0VFDL; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id o13sor1419671lfc.2.2020.06.15.08.21.06 for (Google Transport Security); Mon, 15 Jun 2020 08:21:06 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JnL0VFDL; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GC70gu/KuM6k/D+t12MJpeTyl5aXSJlixkvFE052RDs=; b=JnL0VFDLFIILGO0nUCBh6p0+PJ00P5rFYB20L3+wdzaaf8acyU6+crOeQkjOcz8p/E NfwTDioK18cs92dba9RgtWPAcJDK+LIXfIhyOw3QuLi12wdFTNil8MGzDJchWaNQlfaa zFWw+iLfdLh3nXCfCUB0VlxhohW1EzmVJmRdCauuidUUtv7YYIXDeybeVxxORKB5vXnd Udwb7Ru4v7rRwdqK139qq9Jpmu+7RZ+IAxL8B44Pw/JCegI3nsv5BN+j6UFNiQeW24iX QDAOMGAC4aAlcWUSDRxGHPNdDzww078zeUC/8FqlNt7EVD3yO8oehMaZZ0FxB8sN/uAw P9iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GC70gu/KuM6k/D+t12MJpeTyl5aXSJlixkvFE052RDs=; b=K0VllytcaYqBFc6S178k9vxy6RzGvmkcGBuCWOYzTapGIU18JJMPnd2XyqrpDdsEtX 6SKoe5RAc+27m4PbEFCaiXBl/xhq7S30yF6Wbmj8QTxR6stqoMQXfqS1kiAlHTKpCuri QanKsPTiEb+YG7EYIxeQqRgXoBtObU31K40AxFCxHEaSWd6TSX2mH1PYxildIJWsX6ZJ YUeulxVprrCO4NtmNBEl/9mTsRhkkYKvFpyKHEz0Wt6CeZNELQtp7OeDgKbZHrPNZaif ns3t7KgF4IUpph4yA+9Da6dupboW5sL0OUvF6UO2CrgpZSzr1+oAQvnycZlSsNH0Gnh6 +nsg== X-Gm-Message-State: AOAM531u7rBdBh0H2LvKgEm5n7if6y4fYVcvC1x4WZQQ26VgIi3ISCwA R/I16lGVUqvSi+wdj8XKYhxkqY+b X-Google-Smtp-Source: ABdhPJzuWrj4m6EK3EepgYnbI6CxPwGIQzFsWlLIN5e2ApsKrVZA6GxkeECekZVHmqtxdz1F/MtQnw== X-Received: by 2002:ac2:48a6:: with SMTP id u6mr8375406lfg.49.1592234466371; Mon, 15 Jun 2020 08:21:06 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-98-128-181-7.NA.cust.bahnhof.se. [98.128.181.7]) by smtp.gmail.com with ESMTPSA id r13sm507045lfp.80.2020.06.15.08.21.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jun 2020 08:21:05 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , Saravana Kannan , linux-pm@vger.kernel.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , Lina Iyer , Vincent Guittot , Stephen Boyd , Bjorn Andersson , Benjamin Gaignard , Ulf Hansson , linux-arm-kernel@lists.infradead.org Subject: [PATCH 4/5] cpuidle: psci: Convert PM domain to platform driver Date: Mon, 15 Jun 2020 17:20:53 +0200 Message-Id: <20200615152054.6819-5-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200615152054.6819-1-ulf.hansson@linaro.org> References: <20200615152054.6819-1-ulf.hansson@linaro.org> MIME-Version: 1.0 To enable support for deferred probing and to allow implementation of the ->sync_state() callback from subsequent changes, let's convert into a platform driver. Signed-off-by: Ulf Hansson --- drivers/cpuidle/cpuidle-psci-domain.c | 45 +++++++++++++++++---------- 1 file changed, 28 insertions(+), 17 deletions(-) -- 2.20.1 Reviewed-by: Lina Iyer diff --git a/drivers/cpuidle/cpuidle-psci-domain.c b/drivers/cpuidle/cpuidle-psci-domain.c index e48e578aaa7d..bf527d2bb4b6 100644 --- a/drivers/cpuidle/cpuidle-psci-domain.c +++ b/drivers/cpuidle/cpuidle-psci-domain.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -42,8 +43,8 @@ static int psci_pd_power_off(struct generic_pm_domain *pd) return 0; } -static int __init psci_pd_parse_state_nodes(struct genpd_power_state *states, - int state_count) +static int psci_pd_parse_state_nodes(struct genpd_power_state *states, + int state_count) { int i, ret; u32 psci_state, *psci_state_buf; @@ -72,7 +73,7 @@ static int __init psci_pd_parse_state_nodes(struct genpd_power_state *states, return ret; } -static int __init psci_pd_parse_states(struct device_node *np, +static int psci_pd_parse_states(struct device_node *np, struct genpd_power_state **states, int *state_count) { int ret; @@ -100,7 +101,7 @@ static void psci_pd_free_states(struct genpd_power_state *states, kfree(states); } -static int __init psci_pd_init(struct device_node *np) +static int psci_pd_init(struct device_node *np) { struct generic_pm_domain *pd; struct psci_pd_provider *pd_provider; @@ -167,7 +168,7 @@ static int __init psci_pd_init(struct device_node *np) return ret; } -static void __init psci_pd_remove(void) +static void psci_pd_remove(void) { struct psci_pd_provider *pd_provider, *it; struct generic_pm_domain *genpd; @@ -185,7 +186,7 @@ static void __init psci_pd_remove(void) } } -static int __init psci_pd_init_topology(struct device_node *np, bool add) +static int psci_pd_init_topology(struct device_node *np, bool add) { struct device_node *node; struct of_phandle_args child, parent; @@ -211,24 +212,24 @@ static int __init psci_pd_init_topology(struct device_node *np, bool add) return 0; } -static int __init psci_pd_add_topology(struct device_node *np) +static int psci_pd_add_topology(struct device_node *np) { return psci_pd_init_topology(np, true); } -static void __init psci_pd_remove_topology(struct device_node *np) +static void psci_pd_remove_topology(struct device_node *np) { psci_pd_init_topology(np, false); } -static const struct of_device_id psci_of_match[] __initconst = { +static const struct of_device_id psci_of_match[] = { { .compatible = "arm,psci-1.0" }, {} }; -static int __init psci_idle_init_domains(void) +static int psci_cpuidle_domain_probe(struct platform_device *pdev) { - struct device_node *np = of_find_matching_node(NULL, psci_of_match); + struct device_node *np = pdev->dev.of_node; struct device_node *node; int ret = 0, pd_count = 0; @@ -237,7 +238,7 @@ static int __init psci_idle_init_domains(void) /* Currently limit the hierarchical topology to be used in OSI mode. */ if (!psci_has_osi_support()) - goto out; + return 0; /* * Parse child nodes for the "#power-domain-cells" property and @@ -256,7 +257,7 @@ static int __init psci_idle_init_domains(void) /* Bail out if not using the hierarchical CPU topology. */ if (!pd_count) - goto out; + return 0; /* Link genpd masters/subdomains to model the CPU topology. */ ret = psci_pd_add_topology(np); @@ -271,9 +272,8 @@ static int __init psci_idle_init_domains(void) goto remove_pd; } - of_node_put(np); pr_info("Initialized CPU PM domain topology\n"); - return pd_count; + return 0; put_node: of_node_put(node); @@ -281,10 +281,21 @@ static int __init psci_idle_init_domains(void) if (pd_count) psci_pd_remove(); pr_err("failed to create CPU PM domains ret=%d\n", ret); -out: - of_node_put(np); return ret; } + +static struct platform_driver psci_cpuidle_domain_driver = { + .probe = psci_cpuidle_domain_probe, + .driver = { + .name = "psci-cpuidle-domain", + .of_match_table = psci_of_match, + }, +}; + +static int __init psci_idle_init_domains(void) +{ + return platform_driver_register(&psci_cpuidle_domain_driver); +} subsys_initcall(psci_idle_init_domains); struct device *psci_dt_attach_cpu(int cpu)