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: 10496159 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 030126022E for ; Fri, 29 Jun 2018 11:06:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E35B82940C for ; Fri, 29 Jun 2018 11:06:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D62362948C; Fri, 29 Jun 2018 11:06:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 823DD2940C for ; Fri, 29 Jun 2018 11:06:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=orFgs0XnVqq9Tga/PMuUB8BHZ3eSfHRhzgBpUi+ascI=; b=Ab5Kq4pi4dho8Gezzssjpq+K0K TseLxdu8ypaONnKZNwdu+pMBTNlO+fJw/FW8QiouFepkuKgiswntbpCMdI7jUUrNFAxnRnNBWibzY YQj8pwID7JlaBMk7yMtEHdSEsuzG1p9ML5CggnxKFbEPqWvBgsFnlBpNF/gh6lBtbe867xqcovmz4 cpjGaM2Ts2XSeMeZBgTNLLX7gpgKFGuLwxeb7xiRFJIjabciXMOAJ9N/yfIaOTX/UoD9pQcUxb55Y P0w6PxiAAD/dpW8zf+4zkTh2ZBS9tW4g8CuwUVTHKWG2/9/VsU5iX61CYvIokpPa/mT4WD7SR3Yw0 75lEHxjw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fYrEg-0000E1-Ad; Fri, 29 Jun 2018 11:06:42 +0000 Received: from mail-lj1-x241.google.com ([2a00:1450:4864:20::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fYrD2-0006NB-4n for linux-arm-kernel@lists.infradead.org; Fri, 29 Jun 2018 11:05:25 +0000 Received: by mail-lj1-x241.google.com with SMTP id i125-v6so6988042lji.2 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=QqOI2Yce02v+a9grmg/OWI2pfyD7yO/qPkze+xS3XEpvq5WHF15hC/LIaEIy+OFi9n 30HoXcKLBicfqICabZzeVSY3527WcUFllUSvgC0zsKzOi8tFvCaZD3c3aFxsOc48HxA0 zhyg55kvK9EU9kZX0bgJr1uARRJ739UL/f6h8tIfIQbjTiaRnxsgdDC7cNpJt7m40hw7 kLxgH1gMdNLQDe2Z/biFrbBtn5JoADqZCZJI5QvWPsuHv+O1+YLTGY213bYPaBX0YhTP dyabe2sZNGD3qdt2vGoFmIj8lOdRwJSjibiN+N5VPAAIO9s9cGQYgz6r1VrqWa0hHazB aibA== X-Gm-Message-State: APt69E0r/0JjI9U+YNQJlgxCCDWOlZ4NHhmlcJuTnvm3TRYXEwshWJWU 0JnZNONlQWZ8LBiL19adAirwfA== 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180629_040500_691154_60B7689F X-CRM114-Status: GOOD ( 15.76 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Lucas Stach , Geert Uytterhoeven , Kevin Hilman , Viresh Kumar , Jon Hunter , Todor Tomov , linux-arm-msm@vger.kernel.org, linux-tegra@vger.kernel.org, Rajendra Nayak , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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) {