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: 140540 Delivered-To: patches@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp694977ljj; Fri, 29 Jun 2018 04:04:47 -0700 (PDT) X-Received: by 2002:a2e:3101:: with SMTP id x1-v6mr10386374ljx.8.1530270287207; Fri, 29 Jun 2018 04:04:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530270287; cv=none; d=google.com; s=arc-20160816; b=OErB1xYpeLEIfvSMfrNyhKCoB65lz2TADtJZzAaKiWMgynWGxmYI22ixmw8iZvGc70 P5VupExIBmYkP+j+yutYzOH33sPoXJTsNfgd+SE4gFfzdQtBEKfjKTrT2FWrIkgePwZY ip1jr5Bkp+jBMyNBR8MPFK7chOVg+hJsDmaF2MfuxoaWzAZn0e4bAD4WHkPxt4ws7g/1 mjNBOqTwKH/TrkjMQnA8TH2hNrNw+qqi05ZLxRFyNE8ggMVGXYWpFxqLED9YeZK59FB2 PZICRFFdulNpFXBJw0bcxvo7B/L+nvzolEZ7tA9vhYAbErSN8mIIEvkDSX3whN5Zv/PA qJLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=BuTTFPhc5eXmbh+i+z8Sz0MJW5cNW9ZK+b2mqoGMSxk=; b=0At/+CyMgnjrAPh1RH8k5JmzyxlDhJ5C04bsC/2OI94XLLm2mtbdu6BbMtKvcrDPbc JcSb7omm16o9D5ziW7cnJ4Qp671pTs0YtC0e0Xn6izwG9qbWxKZV5lZoT5xvuyxmTkk3 NPSwdhHuRcHUaqIyvb0DOXxvlTgzi/88skjH2EKIpX81vjlLJvqyT+kOPPbvCz7VSBJX i/BsFg8T+bgnXwj8eGyhNT72e4QIVldWyyeONo1eGa9GsU1qe0YuuOtCs2cXSv/TnL94 BbMRlDlm4Ygkcl/sz+kDoFw6O2v+As+SvcFAdTvfg5dLWKmn2HRTJabMfpuvk48lwICs gHUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Xn2G7bpX; 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 c10-v6sor293169ljb.13.2018.06.29.04.04.47 for (Google Transport Security); Fri, 29 Jun 2018 04:04:47 -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=Xn2G7bpX; 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; 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=MJEg7PbmPrYrYDNfUDRNdzFQ1scgkDNnvYhn+HM/iFApv0bw2EzRxfz+HVcu0g2lPB tXE9MehBcSygHKCLHnhIuN6Wi1l6H3pJYRXYMxR4er5yXyhTpcNX12/+C2msKvnqaHml rbuS330Pgqn7EwNBHIP1OkvcpB2+Vxt9/4JHhnZ9u6kBVS18B0l4JEKv3myO13aui6rS mvZHyq+qKgMXPZY6sed/IKzY1hhbSOKSZo6mwLP719oKtz7Qy8cavacGS7n/0Ktbtxke VDA2AQ2DdBLHlTaCQeY/AIcA2kgyFyCXOv6Uk5EkScU1y5aCHbPuvUzDdNtl/lVhHfVm wg3g== X-Gm-Message-State: APt69E1MHoOWsQfdDjN6onX3GqMkcnztac6QG0UTXTSxr53PRA2SOpaZ 5WPGowbLa4IwzUK1Gnwy6ygcSNmE 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) Return-Path: 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> 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(+) -- 2.17.1 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: 140541 Delivered-To: patches@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp695020ljj; Fri, 29 Jun 2018 04:04:48 -0700 (PDT) X-Received: by 2002:a2e:1b03:: with SMTP id b3-v6mr9579140ljb.24.1530270288679; Fri, 29 Jun 2018 04:04:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530270288; cv=none; d=google.com; s=arc-20160816; b=OJ9sQqjUECWM3xCKyxQ1sR+3wTWgFGpqbDbGXr2PbbB8qfrkw/pm5Ak7YxRL4CN8Pp olFZjtumPmkam5WVL75eeHG/3KoB/QIA9/6ZdYuDGcvPBmeB93DjWe1VOGIeiS7Yjx/Y Q4YWb3VX1B8XKSxW+oGJvlR+hkC0i6Jl2fI8cszoqXSJsF9Sf4yp/h/sumPGLU/orT8y gddf3HnHs6u40YDDn0FcvZ9KcXn6e7i1CZpMPThMDp8jQ9Nz9Wy+UB6MFy7JCjLLIpOo JFt+IFZQFia2EovhDGfheC0Tb6lcDhtFiE2lL2Q7iXw8i25+CM54PhDCFuvtK+X1Tbre fX9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=+IVmNs6WjTGEnYxR2SJvpLhr4W9jz2jhg1z//SWxo+0=; b=eG+vpmHtt/wkQ2DYkXy0FnAgxE1V5wnXqb3CuLi96oeLzCT/7+bYoilpKWBbbLuV+K JQH2La7PWZA4rPPBNmy7mJKCOcWNW0w5xFT8agAphMQQ3az253k0VzZ1gyzQbO6/aYBr Lt6Hkpj1rF7qwfkwx4Nul8lAzPYdbTdCG2/YyqHs7op3Dg79Yg1Wt6iurY/w9u2geS5a hlJSP63HZmcRu87x7DZAIz7TFhMMJAVcTLjNCW1xeyVrspLfxu+Z7dvkOaCNZgKILDhc P4yIJyWojzTQWUeCxcinSkK5u6yZ92uglvkZZtFsACvgP/b7sdqKyeWuqaUYSSEQCp9j muAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LjQU0EAf; 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 f12-v6sor2217765ljg.73.2018.06.29.04.04.48 for (Google Transport Security); Fri, 29 Jun 2018 04:04:48 -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=LjQU0EAf; 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; 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=k2EG/dIs0kez1/8QratYrb2M/pFSqMANrLPuMCT5PEjuQrZe0t/UcILbH14qW8WHBB v7JxcVqlhrYQqD3k+0UKBQGcHKpt7/Grz5YgeM4mK5ANwo3NuECBn1OQ6cGimq4joVKn w8kr65REeQc610aiVEyZLWboAjXMSXcfLVMFEhjtWwrBHXprGL5HwJ7DFjCF15q1l9N6 1y71+htri3gqdfEWs+D47fB71CM2pdtxO45GjmcyDtir8nxR4jGOrPs/Y2JqPn6O337i RB45njnoO04wJa36L2CetVxXbMAJteHunKczW13d4aVy0CUYVvf8Ej2/Q2pge8Op49ug kwEQ== X-Gm-Message-State: APt69E0iTml1XOg9j/9cYRLpwiK6Qr60bH73qTLQnHgl9bumADg9DjRt DAWabhemy/MHGcfbXsq8kNN1bQRA 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) Return-Path: 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> 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(+) -- 2.17.1 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: 140542 Delivered-To: patches@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp695067ljj; Fri, 29 Jun 2018 04:04:50 -0700 (PDT) X-Received: by 2002:a19:120d:: with SMTP id h13-v6mr9873279lfi.13.1530270290617; Fri, 29 Jun 2018 04:04:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530270290; cv=none; d=google.com; s=arc-20160816; b=gyhSPdjAHD024S7DGooihMNd7QZNL87DXVRvAwlsoz0RAsJQNIdiCeCdkIGLUnJ9SO foea5pxcTglcPiOQunlzG/SKhyiRla746c+PxdvBUgQtWvnKQgE6xZQ6gqrN30h6vcrs tD/0EpW6qtPHq7dKSEzSvOQYusQnG+cnt3DPgyRaIPmZRghl0+yM9BjRSljSQ5MJcOQd XsLw2z6/GxZyOkEuU223dyiG8arl3Uyfd1++VvYgM6kOxcPEyo5DdYBNGSzuBA/WIZXo CNYSMreX+fsbjyxtT/x7USbMQ3PSUlc8rve6/YcLBWJ9oudXCqPy/Hp59ggwmh0cBwWU M+eA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=n/200TFAI5rWvodrt4dmZF2gjgm4n0cXeaHfsLRnUBY=; b=VKiXH9GbnC9jq/tcpQQIIBzRW9RIxsKs7MImdntovdy53Ik4YSNICt3ywFnZ0bVwlv pNv+M2YA+qdVrNnLTdJ7fMcdMLijsti6xyc4+z4roCitZrHxHU9ZY3bweHTCFS19EqnZ aBsDuBjLzbUN32vacqyvQTtm/Vyj+HWFybydRjzCjySp15VSS/ozG7zdu8VUHFgGM15f vT63Tul0uYz0Z1IEQR2uK19foRrpl06FTjEHb/7rlDo39TKF7lPJuQSHBLn5F7ZeqBRA XSNQ/fjXqFCU6++bD18kmWq95M7r7QDw4AnXggdXnigxqePGh+b7P6DkTSde0aG57smY Zbww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bdHMVJsK; 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 2-v6sor2164724ljd.65.2018.06.29.04.04.49 for (Google Transport Security); Fri, 29 Jun 2018 04:04:50 -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=bdHMVJsK; 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; 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=IuoOn40lJE5NuaH4Igd1oRryJ8stWZA3mZtJV1SOjNZv5m5p0ut3jNIqZD7DxWdYWM XnXqhUiNSQGnB4og+D+WgT7syjpmIoArbWZzFrOMzVQBTQ7omzepsJc3LOACRqOkOEWF Bs2RCsl30ju6DhymfVRh+p/hFruvxxo4jU5u+h/k5NLaG0FBNbdrxGvwM4oCxMv/Msde buuRP9gn6gfLDyhuhV5qiSDqrsb7m5hH0Rx46Nw1fjxTyw/bYXsEbjtLCAbtg4u/ps3D h+s+cCVOUWKtqeje/ME+nZWuPHxC/v/+4/ohaCAllSmgjXS5fyezwLBRcVe3xvZMRBpD yGPA== X-Gm-Message-State: APt69E2wWtlPi45h9GxlTHqpbFzwtqq3fSV2rDpExU8NJrfxJWKmUJP7 lR2Ul/yWoMVqv8Xs56VX/STbj3WkR5MEag== 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) Return-Path: 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> 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(+) -- 2.17.1 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) {}