From patchwork Tue Jul 7 12:58:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 234995 Delivered-To: patches@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp889181ilg; Tue, 7 Jul 2020 05:58:27 -0700 (PDT) X-Received: by 2002:a2e:8e97:: with SMTP id z23mr19265276ljk.288.1594126707835; Tue, 07 Jul 2020 05:58:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594126707; cv=none; d=google.com; s=arc-20160816; b=pTOW/Q7pQxqt/xRWa3TQVRGKy6oRrTKuJA44YiBeVrvrx0WXrLf/Qb4my2N82oKj3T Vsa0VtuNS3z4r5DFFyI8ppwWPEDHM+2IQSuvJDTjaOnQCts8ehWAYxcQb90iOOLpcAU/ gQqtZRRO1YX0Jjfe/LOVTOgJdPNlAflqH7E6pGdrqa2VgieJ8Oir9bZjUHxMtfSNIV5k aUdMwC7pL3QQOvtmoe7my5JvqCDaJG2wFsSL0dUg1P5YKz78L5POVxC2NFIxbK1OlDrk 2bpjU9GxGB+t6Dd17HryMAphIFat+RxQRY+QZI4fEr7lLXLwEyCl3mojP4fV9CTjx9Yt UhXw== 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=EkXZj4/pMT9pPcwacUaB98YwreiOuCxYZG9xrLmembw=; b=n6kAD4V5ip3TLS5sualKE+gGLh9Ap1WwyKU64wRkfpm6Tk3n4c5hWnshViIofj+trK wSuJF8MaejqmBbHw4n0sbPmYWA3qBTJRWHc4BJ/LefDgStm+vV8blUI9ocCLrixKKqpY wloghY8lpY8ZNVy1+NCvPCrKGN8KANmoM0RfvKXuug/MzWNynB9/aaQB1r8+ezlZ0402 fzssHjzYX+7ybABsru9eLvyg7oJMM3kSTHjbMIBitjXxAhoW3M33tSdayTFXEILId6Bd 98MscXHlg2RFJwlj9r/OlL2HHzQ6kFfNPVQ9zig+FyGx9v/2GJcZNt7psxEv9ahrwNrQ bkrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=A88VM81I; 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 x11sor11949433lji.36.2020.07.07.05.58.27 for (Google Transport Security); Tue, 07 Jul 2020 05:58:27 -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=A88VM81I; 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=EkXZj4/pMT9pPcwacUaB98YwreiOuCxYZG9xrLmembw=; b=A88VM81IK+t1ZB6Q06hKJOLn4l/0OxUy5gRIgQgiNvaI4lyYmybOHoi/Kq63L95xjX gvrkw8iwNxowjbR//1jD2C9h/2B+2Y7lMHhfflH1wkEMCNxGZ4zpTDUMSuNHMJfydVGL H+QNZxR3i8p13BIcbZS2lymhDrCnxZEThXWkx8xn0eZsbHjtBOQ5XlisMuOq+IcPN1x9 Ex5iWq77Zn4FWWNlbIThuGbV76s0DBIw1XeLaWo0DHMA4AWPHKFim5m7DuY2k9syFmEq o4IwrkUrIPDk7gR9hjW3FFC2DOwDjCRSzJWl8DkMPvg/1NUqpxhF9Zru8ZCwIC53Dghd wbbQ== 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=EkXZj4/pMT9pPcwacUaB98YwreiOuCxYZG9xrLmembw=; b=bJ/k8XmK9v8TKIIaTxiY6XK0ljfuOFCAxUDpFY2uUfmAcUQwJW9+Y3LFTGZ0SC/IfB kNUzY8w8f95z2UP8VZ728XUBeVb7xSOxu1vTbAv4XBB0zqtcLzSHlJhpec3MUTZ8I9za 3GOlYxsTXMUcJ7LdZVVuMvUC4QpJccrfyZT/xtmgptMuIRL+McxABoWy1elpUevibAV9 ncRgJdO5jKLivcV346k14/+WGfiGg0xrOzHo0mwAthPc9jgi7KJSjuN18x2dQDlPJRnU uUDYY3ryzijKNtoTmPRsck/4GVGcmiHai0kna/vEB5sLI2hiL41IpHM0Op7dP1pRpfVQ ql2A== X-Gm-Message-State: AOAM533LzvtP2h+CQBmfym9P6cTslBAWgsf/usCQOeUGKO2//06lXb/U b88AwZhCHFkOUztr4ASwdEbhwN2N X-Google-Smtp-Source: ABdhPJyBSriC7tiBtcgSZ/HW3ozSjjB3SMNR1qyrVjRG5PFGhtQNnT1gJ+8CVfwWMf7aVvGYjk6GIw== X-Received: by 2002:a2e:9883:: with SMTP id b3mr23503453ljj.390.1594126707435; Tue, 07 Jul 2020 05:58:27 -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 11sm9554395lfz.78.2020.07.07.05.58.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 05:58:26 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Lorenzo Pieralisi , linux-pm@vger.kernel.org Cc: "Rafael J . Wysocki" , Daniel Lezcano , Lina Iyer , Lukasz Luba , Vincent Guittot , Stephen Boyd , Bjorn Andersson , Benjamin Gaignard , Saravana Kannan , Ulf Hansson , linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 4/5] cpuidle: psci: Convert PM domain to platform driver Date: Tue, 7 Jul 2020 14:58:03 +0200 Message-Id: <20200707125804.13030-5-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200707125804.13030-1-ulf.hansson@linaro.org> References: <20200707125804.13030-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. Reviewed-by: Lina Iyer Signed-off-by: Ulf Hansson --- drivers/cpuidle/cpuidle-psci-domain.c | 45 +++++++++++++++++---------- 1 file changed, 28 insertions(+), 17 deletions(-) -- 2.20.1 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)