From patchwork Wed Aug 12 19:00:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lina Iyer X-Patchwork-Id: 52352 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by patches.linaro.org (Postfix) with ESMTPS id A4DB122F0C for ; Wed, 12 Aug 2015 19:00:50 +0000 (UTC) Received: by wijp15 with SMTP id p15sf9461369wij.3 for ; Wed, 12 Aug 2015 12:00:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=gDmgKSkd57Roc4isQfUDcAr1BoAayHfI/dCHpzItgYs=; b=JzRfh4JJlUSBQwv4r+ps5y+Mu/6Ld0kMkJZBayfs0Vx86XBNhqDm7xo6utfv1MPNYx 2spWf4ImPe6ysmHHLXbAqaOiakIZIt1NXRz84jLpMW33M4qEvh1A6ywaeEWzi6gCTJ3d awLtKqNPFSDyifHGEPZPt1UPJCKqNSfHapGjgYTu/y0uet56+3UziWmUGbPU41KQf7uO gsIlIrVsD3+h/DUZ8XL95jqI0uItXb3HiuVVukiGK7OZ6HA26Bn75F+ewmg6otfE0vBB phjOadJxIJMdFooMCHHp5mUUfs1efaVpI/a3K08KdSRt2K3ZpMmRTo9//9fp+AkzT44t 2suQ== X-Gm-Message-State: ALoCoQkbFGW6Pgxxj9Y4W/sZ2Bwf005P20pcdasBbbu7+fTkh5UdY+cwUYbOW3rEWvMqIrg2SjCJ X-Received: by 10.194.19.33 with SMTP id b1mr10022905wje.6.1439406049982; Wed, 12 Aug 2015 12:00:49 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.37.196 with SMTP id a4ls72837lak.27.gmail; Wed, 12 Aug 2015 12:00:49 -0700 (PDT) X-Received: by 10.152.4.98 with SMTP id j2mr32230473laj.67.1439406049804; Wed, 12 Aug 2015 12:00:49 -0700 (PDT) Received: from mail-lb0-f176.google.com (mail-lb0-f176.google.com. [209.85.217.176]) by mx.google.com with ESMTPS id e8si5723602laa.121.2015.08.12.12.00.49 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Aug 2015 12:00:49 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 as permitted sender) client-ip=209.85.217.176; Received: by lbbtg9 with SMTP id tg9so14997097lbb.1 for ; Wed, 12 Aug 2015 12:00:49 -0700 (PDT) X-Received: by 10.112.160.42 with SMTP id xh10mr33171142lbb.88.1439406049655; Wed, 12 Aug 2015 12:00:49 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.7.198 with SMTP id l6csp499432lba; Wed, 12 Aug 2015 12:00:48 -0700 (PDT) X-Received: by 10.70.34.49 with SMTP id w17mr48020040pdi.35.1439406047262; Wed, 12 Aug 2015 12:00:47 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ln7si10823391pbc.164.2015.08.12.12.00.46; Wed, 12 Aug 2015 12:00:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751958AbbHLTAp (ORCPT + 12 others); Wed, 12 Aug 2015 15:00:45 -0400 Received: from mail-pd0-f182.google.com ([209.85.192.182]:32889 "EHLO mail-pd0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751955AbbHLTAp (ORCPT ); Wed, 12 Aug 2015 15:00:45 -0400 Received: by pdrh1 with SMTP id h1so10287699pdr.0 for ; Wed, 12 Aug 2015 12:00:44 -0700 (PDT) X-Received: by 10.70.46.161 with SMTP id w1mr71016829pdm.66.1439406044487; Wed, 12 Aug 2015 12:00:44 -0700 (PDT) Received: from ubuntu.localdomain (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id pj3sm7343297pdb.6.2015.08.12.12.00.42 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 12 Aug 2015 12:00:43 -0700 (PDT) From: Lina Iyer To: rjw@rjwysocki.net, ulf.hansson@linaro.org, khilman@linaro.org Cc: geert@linux-m68k.org, k.kozlowski@samsung.com, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, msivasub@codeaurora.org, agross@codeaurora.org, robherring2@gmail.com, sboyd@codeaurora.org, Lina Iyer , Rob Herring , Catalin Marinas , Mark Rutland , Lorenzo Pieralisi Subject: [PATCH v2 2/2] ARM: domain: Add platform handlers for CPU PM domains Date: Wed, 12 Aug 2015 13:00:24 -0600 Message-Id: <1439406024-41893-2-git-send-email-lina.iyer@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1439406024-41893-1-git-send-email-lina.iyer@linaro.org> References: <1439406024-41893-1-git-send-email-lina.iyer@linaro.org> In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: lina.iyer@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , In addition to the common power up/down actions of CPU PM domain core, platforms may have additional configuration before the CPU domain can b powered off or considered active. Allow platform drivers to register handlers for CPU PM domains. Platform drivers may register their callbacks against a compatible string defined by their PM domain provider device node in the DT. At domain init, the platform driver can initialize the platform specific genpd attributes. The init callback would need to return successfully, for the platform power_on/off handlers to be registered with the CPU PM domain. The code uses __init section to reduce memory needed for platform handlers and therefore can be freed after the driver is initialized, a desirable outcome for single kernel image. Cc: Rob Herring Cc: Stephen Boyd Cc: Kevin Hilman Cc: Ulf Hansson Cc: Catalin Marinas Cc: Mark Rutland Cc: Lorenzo Pieralisi Signed-off-by: Lina Iyer --- Changes since v1: - Removed references to ARM - Use OF_DECLARE_1 for __init section tables --- arch/arm/common/domains.c | 38 ++++++++++++++++++++++++++++++++++++++ arch/arm/include/asm/cpu-pd.h | 11 +++++++++++ include/asm-generic/vmlinux.lds.h | 2 ++ 3 files changed, 51 insertions(+) diff --git a/arch/arm/common/domains.c b/arch/arm/common/domains.c index 4bc32a5..b1d9cc0 100644 --- a/arch/arm/common/domains.c +++ b/arch/arm/common/domains.c @@ -26,8 +26,28 @@ /* List of CPU PM domains we care about */ static LIST_HEAD(of_cpu_pd_list); +static const struct of_device_id __cpu_pd_of_table_sentinel + __used __section(__cpu_pd_of_table_end); + +static inline +struct cpu_pm_domain *to_cpu_pd(struct generic_pm_domain *d) +{ + struct cpu_pm_domain *pd; + + list_for_each_entry(pd, &of_cpu_pd_list, link) { + if (pd->genpd == d) + return pd; + } + + return NULL; +} + static int cpu_pd_power_down(struct generic_pm_domain *genpd) { + struct cpu_pm_domain *pd = to_cpu_pd(genpd); + + if (pd->platform_ops.power_off) + pd->platform_ops.power_off(genpd); /* * Notify CPU PM domain power down * TODO: Call the notificated directly from here. @@ -39,6 +59,11 @@ static int cpu_pd_power_down(struct generic_pm_domain *genpd) static int cpu_pd_power_up(struct generic_pm_domain *genpd) { + struct cpu_pm_domain *pd = to_cpu_pd(genpd); + + if (pd->platform_ops.power_on) + pd->platform_ops.power_on(genpd); + /* Notify CPU PM domain power up */ cpu_cluster_pm_exit(); @@ -203,6 +228,8 @@ static int __init of_cpu_pd_init(void) { struct device_node *dn; struct cpu_pm_domain *pd; + const struct of_device_id *m = &__cpu_pd_of_table; + void (*pd_init)(struct device_node *) = NULL; for_each_compatible_node(dn, NULL, "cpu,pd") { @@ -213,6 +240,17 @@ static int __init of_cpu_pd_init(void) if (!pd) return -ENOMEM; + /* Find a compatible platform driver */ + for (; m->compatible; m++) { + if (of_device_is_compatible(dn, m->compatible)) { + pd_init = m->data; + break; + } + } + + if (pd_init) + pd_init(dn); + of_register_cpu_pd(dn, pd); } diff --git a/arch/arm/include/asm/cpu-pd.h b/arch/arm/include/asm/cpu-pd.h index 4785260..65db517 100644 --- a/arch/arm/include/asm/cpu-pd.h +++ b/arch/arm/include/asm/cpu-pd.h @@ -15,13 +15,24 @@ #include #include +struct cpu_pd_ops { + int (*power_on)(struct generic_pm_domain *d); + int (*power_off)(struct generic_pm_domain *d); +}; + struct cpu_pm_domain { struct list_head link; struct generic_pm_domain *genpd; + struct cpu_pd_ops platform_ops; struct device_node *dn; }; extern int of_init_cpu_domain(struct device_node *dn, struct cpu_pm_domain *pd); extern struct cpu_pm_domain *of_get_cpu_domain(struct device_node *dn); +extern const struct of_device_id __cpu_pd_of_table; + +#define CPU_PD_METHOD_OF_DECLARE(name, compat, fn) \ + OF_DECLARE_1(cpu_pd, name, compat, fn) + #endif /* __CPU_PD_H__ */ diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index 8bd374d..f952933 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -179,6 +179,7 @@ #define RESERVEDMEM_OF_TABLES() OF_TABLE(CONFIG_OF_RESERVED_MEM, reservedmem) #define CPU_METHOD_OF_TABLES() OF_TABLE(CONFIG_SMP, cpu_method) #define CPUIDLE_METHOD_OF_TABLES() OF_TABLE(CONFIG_CPU_IDLE, cpuidle_method) +#define CPU_PD_OF_TABLES() OF_TABLE(CONFIG_PM_GENERIC_DOMAINS, cpu_pd) #define EARLYCON_OF_TABLES() OF_TABLE(CONFIG_SERIAL_EARLYCON, earlycon) #define KERNEL_DTB() \ @@ -514,6 +515,7 @@ IOMMU_OF_TABLES() \ CPU_METHOD_OF_TABLES() \ CPUIDLE_METHOD_OF_TABLES() \ + CPU_PD_OF_TABLES() \ KERNEL_DTB() \ IRQCHIP_OF_MATCH_TABLE() \ EARLYCON_TABLE() \