From patchwork Fri Jun 29 11:04:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 936791 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-tegra-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Xn2G7bpX"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41HDLs327lz9rvt for ; Fri, 29 Jun 2018 21:04:53 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934639AbeF2LEt (ORCPT ); Fri, 29 Jun 2018 07:04:49 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:36423 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934321AbeF2LEs (ORCPT ); Fri, 29 Jun 2018 07:04:48 -0400 Received: by mail-lj1-f195.google.com with SMTP id o26-v6so6982942ljg.3 for ; Fri, 29 Jun 2018 04:04:47 -0700 (PDT) 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; bh=BuTTFPhc5eXmbh+i+z8Sz0MJW5cNW9ZK+b2mqoGMSxk=; b=Xn2G7bpXZxMkpLKEi18So2C0NMEF8rHvpKSX+CW99PiN+YMgWrshsyKapZ2QvIqHE7 HxJsEXo+VKSXTwobzcxoNTIaeZkhLjuN5T15zmc4Q/HHmdT0ICra5o66w75k3JefYaMF lKJSMk0nquK4wQ3ANbQtfH0+A5vUtZ4obENNc= 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; bh=BuTTFPhc5eXmbh+i+z8Sz0MJW5cNW9ZK+b2mqoGMSxk=; b=nue+zhRJS8eHgo0snXMdohp0PIt+RHZG7ck+63GRECBluxiF9h0cFya66cK8kQ3Hu2 odrtCclbpa7k52vc4HOB7lT0g4CfTDIIhDdArskHijK952Hz0LNajwjdU8omM1wWxbhf cEpXzXHb3XDoXE9gg9k4T/q1vpHMhyoTCup3fG8ASPxCLRxmlq3C2Yq16acR9GzNVN+z JqpNjQq+7MRPvwNCB6bCFlTQsI+vfUM62UmUjMxIeggLEn3tgHk12bCh09+KhzAn2oYx 8jHGh6ApLReQGLfNz+l3TAoRJGSTDYzOF7ilPK4EqxwwITkoM9YiGeHX7to7KnI8PFnR J+sw== X-Gm-Message-State: APt69E0Ck3k6P2oXbCst8NDTbXTdQ1v0hBcR1vwYgMkKuEV6WfWySOok iptrJ8slOEJ+/NCRxLWHs5uhOV9ckOU= X-Google-Smtp-Source: ADUXVKJho0YZEZCoLxdWVRdTvlEe6/8x517WcjEo8/oesC/N58zy0wYNOH51G6FOSiosiWvRVFgzEA== X-Received: by 2002:a2e:2ac3:: with SMTP id q186-v6mr10180589ljq.44.1530270286829; Fri, 29 Jun 2018 04:04:46 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id 89-v6sm508359lfs.32.2018.06.29.04.04.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Jun 2018 04:04:46 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Ulf Hansson , Jon Hunter , Geert Uytterhoeven , Todor Tomov , Rajendra Nayak , Lucas Stach , Viresh Kumar , Kevin Hilman , linux-arm-kernel@lists.infradead.org, linux-tegra@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 1/3] PM / Domains: dt: Add a power-domain-names property Date: Fri, 29 Jun 2018 13:04:30 +0200 Message-Id: <20180629110432.5179-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180629110432.5179-1-ulf.hansson@linaro.org> References: <20180629110432.5179-1-ulf.hansson@linaro.org> Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org Let's add a power-domain-names property, to allow consumer drivers to match the power-domains specifiers via a list of power domain names. This follows the same concept as for other similar DT bindings. Signed-off-by: Ulf Hansson --- Documentation/devicetree/bindings/power/power_domain.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Documentation/devicetree/bindings/power/power_domain.txt b/Documentation/devicetree/bindings/power/power_domain.txt index 9b387f861aed..4d6bc8829468 100644 --- a/Documentation/devicetree/bindings/power/power_domain.txt +++ b/Documentation/devicetree/bindings/power/power_domain.txt @@ -114,18 +114,26 @@ Required properties: - power-domains : A list of PM domain specifiers, as defined by bindings of the power controller that is the PM domain provider. +Optional properties: + - power-domain-names : A list of power domain name strings sorted in the same + order as the power-domains property. Consumers drivers will use + power-domain-names to match power domains with power-domains + specifiers. + Example: leaky-device@12350000 { compatible = "foo,i-leak-current"; reg = <0x12350000 0x1000>; power-domains = <&power 0>; + power-domain-names = "io"; }; leaky-device@12351000 { compatible = "foo,i-leak-current"; reg = <0x12351000 0x1000>; power-domains = <&power 0>, <&power 1> ; + power-domain-names = "io", "clk"; }; The first example above defines a typical PM domain consumer device, which is From patchwork Fri Jun 29 11:04:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 936793 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-tegra-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="LjQU0EAf"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41HDLx2mzjz9ryk for ; Fri, 29 Jun 2018 21:04:57 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934321AbeF2LEx (ORCPT ); Fri, 29 Jun 2018 07:04:53 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:34631 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934247AbeF2LEt (ORCPT ); Fri, 29 Jun 2018 07:04:49 -0400 Received: by mail-lj1-f194.google.com with SMTP id l12-v6so7001340lja.1 for ; Fri, 29 Jun 2018 04:04:49 -0700 (PDT) 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; bh=+IVmNs6WjTGEnYxR2SJvpLhr4W9jz2jhg1z//SWxo+0=; b=LjQU0EAfPEnJvxP+AfC26VVvE2JFRXe2Ikc9PW7Izhsi1AoDlE/Xq3A09ktDRe2WXv lKDnX8vcrbxWfGnC41CfFRS1tIGhamXxoIrDutBrjaYIKIsmcPKvb8Azxv+tU8RNEZ7z Gfqm80fcJ7u1SirEsITI9L67+jC8C2ofYAKqg= 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; bh=+IVmNs6WjTGEnYxR2SJvpLhr4W9jz2jhg1z//SWxo+0=; b=KswykRlfeva4DC5GwWOiZ+JIRzjoDehudLRSXgYa4jER0w0l4arPNaSec9w4bEzevO 8VRaIg8tsK1In20EPvsvsIDr2CAcPRNpfk8b2SXwdimswwV3UCiXXVrSz9Ml/gL63NrJ hUd9am1axxTMp8/UGdoHJ7pfVHmjBg1MGB49WXN6WchmtXnZa6c9JfauhZ8tWp9q+Xrh IJYdS+jA4anUxaXbHpIGBychaMpdrkBKbgGEtpS81hvDGelNgL8s6lcmNqcdIsHNYbx0 1xdvHVN9M3D5FoW84E3P1DK4NVdqWMV6M6+GX71cAWIWpH8AMOuyKA4ONFyaR2bQKIJS c2iA== X-Gm-Message-State: APt69E2zrcrfC+Uo0a6ZcKwADVRzWorz149uMLhcuhaqoxmTKD4tcV3b 7OoTWyk905CDFR7qj9d2ggvXSA== X-Google-Smtp-Source: AAOMgpcaU6YDlw7pKH/AB1I3YtnJZypBhQL8fqo+Tx7ieHY7ICx9dNGh/9pbATnNcW9pOEdONDxBcg== X-Received: by 2002:a2e:5142:: with SMTP id b2-v6mr9457394lje.30.1530270288265; Fri, 29 Jun 2018 04:04:48 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id 89-v6sm508359lfs.32.2018.06.29.04.04.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Jun 2018 04:04:47 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Ulf Hansson , Jon Hunter , Geert Uytterhoeven , Todor Tomov , Rajendra Nayak , Lucas Stach , Viresh Kumar , Kevin Hilman , linux-arm-kernel@lists.infradead.org, linux-tegra@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 2/3] PM / Domains: Introduce option to attach a device by name to genpd Date: Fri, 29 Jun 2018 13:04:31 +0200 Message-Id: <20180629110432.5179-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180629110432.5179-1-ulf.hansson@linaro.org> References: <20180629110432.5179-1-ulf.hansson@linaro.org> Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org For the multiple PM domain case, let's introduce a new function called genpd_dev_pm_attach_by_name(). This allows a device to be associated with its PM domain through genpd, by using a name based lookup. Note that, genpd_dev_pm_attach_by_name() shall only be called by the driver core / PM core, similar to how the existing dev_pm_domain_attach_by_id() makes use of genpd_dev_pm_attach_by_id(). However, this is implemented by following changes on top. Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 24 ++++++++++++++++++++++++ include/linux/pm_domain.h | 8 ++++++++ 2 files changed, 32 insertions(+) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index c298de8a8308..a70e4b7a3b14 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -2372,6 +2372,30 @@ struct device *genpd_dev_pm_attach_by_id(struct device *dev, } EXPORT_SYMBOL_GPL(genpd_dev_pm_attach_by_id); +/** + * genpd_dev_pm_attach_by_name - Associate a device with one of its PM domains. + * @dev: The device used to lookup the PM domain. + * @name: The name of the PM domain. + * + * Parse device's OF node to find a PM domain specifier using the + * power-domain-names DT property. For further description see + * genpd_dev_pm_attach_by_id(). + */ +struct device *genpd_dev_pm_attach_by_name(struct device *dev, char *name) +{ + int index; + + if (!dev->of_node) + return NULL; + + index = of_property_match_string(dev->of_node, "power-domain-names", + name); + if (index < 0) + return NULL; + + return genpd_dev_pm_attach_by_id(dev, index); +} + static const struct of_device_id idle_state_match[] = { { .compatible = "domain-idle-state", }, { } diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index cb8d84090cfb..03e14a38462d 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -239,6 +239,8 @@ unsigned int of_genpd_opp_to_performance_state(struct device *dev, int genpd_dev_pm_attach(struct device *dev); struct device *genpd_dev_pm_attach_by_id(struct device *dev, unsigned int index); +struct device *genpd_dev_pm_attach_by_name(struct device *dev, + char *name); #else /* !CONFIG_PM_GENERIC_DOMAINS_OF */ static inline int of_genpd_add_provider_simple(struct device_node *np, struct generic_pm_domain *genpd) @@ -290,6 +292,12 @@ static inline struct device *genpd_dev_pm_attach_by_id(struct device *dev, return NULL; } +static inline struct device *genpd_dev_pm_attach_by_name(struct device *dev, + char *name) +{ + return NULL; +} + static inline struct generic_pm_domain *of_genpd_remove_last(struct device_node *np) { From patchwork Fri Jun 29 11:04:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 936792 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-tegra-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="bdHMVJsK"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41HDLw4jk7z9rvt for ; Fri, 29 Jun 2018 21:04:56 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934247AbeF2LEy (ORCPT ); Fri, 29 Jun 2018 07:04:54 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:46499 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934443AbeF2LEv (ORCPT ); Fri, 29 Jun 2018 07:04:51 -0400 Received: by mail-lj1-f196.google.com with SMTP id u6-v6so6978522lju.13 for ; Fri, 29 Jun 2018 04:04:50 -0700 (PDT) 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; bh=n/200TFAI5rWvodrt4dmZF2gjgm4n0cXeaHfsLRnUBY=; b=bdHMVJsK6XKphntS4FF5q6H1MBibMjfN2I/rVTup28TzP406UdevK7LZzBQxY1hxfF FVVCBLw7sml9e26b5zgHS6/yRrXwWfka7fjp/A9EFZH4yOmqRbiOz4MjUyu7dmHs81Eu riC6iBDJFtkXYpon4ZkE/0+fK2c5TwAhlsZqE= 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; bh=n/200TFAI5rWvodrt4dmZF2gjgm4n0cXeaHfsLRnUBY=; b=fTVxYg3Cdxh+sciogG0KWTLha71NZPj9nGFfmUG4zQIlQkqQ3xh8h4KiOAUyhWdGmV WgVEUPpqkAC8ci2RF9lLCwo7aEhaL+9jYU4LBKcRRDijNxv+PW5HRMXhBWaf9tHWUHCm HBjhOJD1nQiZzpQU7wHdKGYM6Y9tfnaiyqOT9Y7nZOSepYkFe8EelWgb+3qQOxu6UIt5 GZhQSINvnksRfcMNWzCOU4ZzW255UtridAaA8S5v0dM2MecMAXKeED+joNOxwltcOFhG qxXMn9jBrp29kNtxeaSwGbj/RXIS4waCf/opSb9o2J75N7QNoIwREtsNLt6tRBnat8pJ PJ3Q== X-Gm-Message-State: APt69E0KI7g1X2g8dbCc2XPtwWqtNNFxhh4GYxRciz9mIG35m3GWjUo8 eUfbZgfRvlrWzBsrScBUOl9gcA== X-Google-Smtp-Source: ADUXVKKDTcoB5MwWUlKsKaePV2qfh23WpG758LAfup4nUXURRTmyUtQsz3G10hID/iM24qcIhues6g== X-Received: by 2002:a2e:9516:: with SMTP id f22-v6mr9683298ljh.9.1530270289801; Fri, 29 Jun 2018 04:04:49 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id 89-v6sm508359lfs.32.2018.06.29.04.04.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Jun 2018 04:04:49 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Ulf Hansson , Jon Hunter , Geert Uytterhoeven , Todor Tomov , Rajendra Nayak , Lucas Stach , Viresh Kumar , Kevin Hilman , linux-arm-kernel@lists.infradead.org, linux-tegra@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 3/3] PM / Domains: Introduce dev_pm_domain_attach_by_name() Date: Fri, 29 Jun 2018 13:04:32 +0200 Message-Id: <20180629110432.5179-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180629110432.5179-1-ulf.hansson@linaro.org> References: <20180629110432.5179-1-ulf.hansson@linaro.org> Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org For the multiple PM domain case, let's introduce a new API called dev_pm_domain_attach_by_name(). This allows a consumer driver to associate its device with one of its PM domains, by using a name based lookup. Do note that, currently it's only genpd that supports multiple PM domains per device, but dev_pm_domain_attach_by_name() can easily by extended to cover other PM domain types, if/when needed. Signed-off-by: Ulf Hansson --- drivers/base/power/common.c | 17 +++++++++++++++++ include/linux/pm_domain.h | 7 +++++++ 2 files changed, 24 insertions(+) diff --git a/drivers/base/power/common.c b/drivers/base/power/common.c index df41b4780b3b..b413951c6abc 100644 --- a/drivers/base/power/common.c +++ b/drivers/base/power/common.c @@ -152,6 +152,23 @@ struct device *dev_pm_domain_attach_by_id(struct device *dev, } EXPORT_SYMBOL_GPL(dev_pm_domain_attach_by_id); +/** + * dev_pm_domain_attach_by_name - Associate a device with one of its PM domains. + * @dev: The device used to lookup the PM domain. + * @name: The name of the PM domain. + * + * For a detailed function description, see dev_pm_domain_attach_by_id(). + */ +struct device *dev_pm_domain_attach_by_name(struct device *dev, + char *name) +{ + if (dev->pm_domain) + return ERR_PTR(-EEXIST); + + return genpd_dev_pm_attach_by_name(dev, name); +} +EXPORT_SYMBOL_GPL(dev_pm_domain_attach_by_name); + /** * dev_pm_domain_detach - Detach a device from its PM domain. * @dev: Device to detach. diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 03e14a38462d..776c546d581a 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -309,6 +309,8 @@ struct generic_pm_domain *of_genpd_remove_last(struct device_node *np) int dev_pm_domain_attach(struct device *dev, bool power_on); struct device *dev_pm_domain_attach_by_id(struct device *dev, unsigned int index); +struct device *dev_pm_domain_attach_by_name(struct device *dev, + char *name); void dev_pm_domain_detach(struct device *dev, bool power_off); void dev_pm_domain_set(struct device *dev, struct dev_pm_domain *pd); #else @@ -321,6 +323,11 @@ static inline struct device *dev_pm_domain_attach_by_id(struct device *dev, { return NULL; } +static inline struct device *dev_pm_domain_attach_by_name(struct device *dev, + char *name) +{ + return NULL; +} static inline void dev_pm_domain_detach(struct device *dev, bool power_off) {} static inline void dev_pm_domain_set(struct device *dev, struct dev_pm_domain *pd) {}