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) {