From patchwork Sat Aug 10 00:58:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 170990 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp10715967ile; Fri, 9 Aug 2019 17:58:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqxWsYxPHr3uMDUqz2Dal6OBb/uN91eQdZsHo103haRIXeAUyVTwpw3DBDxDZhYeN3hlT55D X-Received: by 2002:a17:902:740a:: with SMTP id g10mr22113493pll.82.1565398732537; Fri, 09 Aug 2019 17:58:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565398732; cv=none; d=google.com; s=arc-20160816; b=JS57TWBCXcwUR/BXHPsnhZvOAF71ccGFjDqv7kO8qMzCfdMcc6O0wKA5rmjNuKX4ms T5APBhVU5Oygcg8D73Xj0se8jdOjFTj3ovYxMnRsvKHNWxQ5p1+/sFnofK8J46U2N3ua DkmdTuxbnwaktz9yB70LgEPl4EmkYGeITy+yvOKE58Y6aFQ0J/sB4ttxO3zwwLDt7v2z ewM453GEhsSpkOyuBh5ivSToKjfNimPcxbr38qDntXqCPykYc+Oz4fkpLr0Znn9PNaNV M1MCrRjzomeNzvEePMIQqPB4PmEuXEA18Tt3hdkWRA/mvqnbh4pPvAa7NX5zlpLtEZ6E YL1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=RcURVu+t1YV/Q1cDxzF4oRy+NUvqDu1q0IfrRPR3n+o=; b=NuytuFea3LseYe8MzpapqISWqzgrywhUo4E46Imd668rlaKSWyAieP6wmVnAS2XgIP Op3Vs7elqc9e+wK5CdKZvndoQqNJawmrElOo4mDx0y0FXkkZLl4zHLyTUjTKn02jp7iM L3TMBsnj47zwyholpuebUNU9ZhP/VXsfRm+fcMjx9Z5Hspzf3a6PhmkrzlDxQ4oGZMNg fhhgDop1JD8nAJTlASlyh+jMFaFqGg99+hETLaaW/7t6t4n44PR/vH8K6WhtsinxyzIN i8GAwUF/jL/tKRLJt3xmb1uldktzHN/9xlZ1fG4YoTpU7LDR5LjWeq1hDwZrMdcItNEh Thqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hkbgyLEg; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m17si25793031pgc.461.2019.08.09.17.58.52; Fri, 09 Aug 2019 17:58:52 -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; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hkbgyLEg; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726137AbfHJA6v (ORCPT + 11 others); Fri, 9 Aug 2019 20:58:51 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:40328 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726022AbfHJA6v (ORCPT ); Fri, 9 Aug 2019 20:58:51 -0400 Received: by mail-qk1-f195.google.com with SMTP id s145so73089702qke.7 for ; Fri, 09 Aug 2019 17:58: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=RcURVu+t1YV/Q1cDxzF4oRy+NUvqDu1q0IfrRPR3n+o=; b=hkbgyLEgZlD9kHpDLYWfPn3m8j+o9fzLN89GQTQxBW9BUB4FkDqyFtttetF+aCOvlw G0sFDZLfF72FRteULz0pNkf92NQIbb2ISdlLx4oVag42hvjYfCStB0Z9sW1R4x1k10J0 IQmiPY4yaEV95Z+ufps543u6cREblT9A1d8THkUyhVdSqO9/x4DUipWpY1R6AbPWgs+U mMEgKPGvG7crdcydB5iGZ8Zc9N8+sZ42ksR1lkm5FpnqaRof0LZLBCDoSe7OKspv9cuB opSpXbTIxCBLskA52VzkGdi5JO8BCk14Jqr22prOnB4k9tqsMTzgg4PFBug1qj1oG4rB Ks4A== 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=RcURVu+t1YV/Q1cDxzF4oRy+NUvqDu1q0IfrRPR3n+o=; b=QmGDiFEps0bsS+bRdLrbVjLCtuN+BrP0PbNVPw73Z97frt6p5XOpbPZirnvR7EXkwJ eQQvRQemJ2b8ibJF7Ujm+ZhXTFnNZ90YDg4HfzPcFRBk3yCua6HjuK9gV9yF0AZbnhz6 5dZGgyQQW9hhVje3cGkrTcas2EAGeKe/yB43FRBPIXFp3EoJkh/ki4M0GpMpRvhKsavg ZkEvL+eJ0TL7hgdzXa8gDIGc1cGJv9YuEu1FVQab3vNyliyZR36GC+/cDYWD69DCqto4 fq79ZWYilynJj58q7VmfKI6ZZjWQmrR+zvNzxPFiF4CzrEFzzC4GPbTqsrh9iVd/rL8L AD6w== X-Gm-Message-State: APjAAAUBiG4WjROb8SXWcq3KMNCY8Ul9aiaIlKoFx0ExhZZW9UBEvi+d AQXd52KlyGL0pxtY7N7zIIWWqg== X-Received: by 2002:a37:8a81:: with SMTP id m123mr20602707qkd.360.1565398730185; Fri, 09 Aug 2019 17:58:50 -0700 (PDT) Received: from Thara-Work-Ubuntu.fios-router.home (pool-71-255-245-97.washdc.fios.verizon.net. [71.255.245.97]) by smtp.googlemail.com with ESMTPSA id t9sm4603105qtr.29.2019.08.09.17.58.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Aug 2019 17:58:49 -0700 (PDT) From: Thara Gopinath To: qualcomm-lt@lists.linaro.org, linux-pm@vger.kernel.org Cc: bjorn.andersson@linaro.org, ulf.hansson@linaro.org, rnayak@codeaurora.org Subject: [PATCH 1/4] PM/Domains: Add support for retrieving genpd performance states information Date: Fri, 9 Aug 2019 20:58:44 -0400 Message-Id: <1565398727-23090-2-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1565398727-23090-1-git-send-email-thara.gopinath@linaro.org> References: <1565398727-23090-1-git-send-email-thara.gopinath@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Add two new APIs in the genpd framework, dev_pm_genpd_get_performance_state to return the current performance state of a power domain and dev_pm_genpd_performance_state_count to return the total number of performance states supported by a power domain. Since the genpd framework does not maintain a count of number of performance states supported by a power domain, introduce a new callback(.get_performance_state_count) that can be used to retrieve this information from power domain drivers. Signed-off-by: Thara Gopinath --- drivers/base/power/domain.c | 38 ++++++++++++++++++++++++++++++++++++++ include/linux/pm_domain.h | 18 ++++++++++++++++++ 2 files changed, 56 insertions(+) -- 2.1.4 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index b063bc4..17e0375 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -413,6 +413,44 @@ int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state) } EXPORT_SYMBOL_GPL(dev_pm_genpd_set_performance_state); +int dev_pm_genpd_get_performance_state(struct device *dev, + unsigned int *state) +{ + struct generic_pm_domain *genpd; + + genpd = dev_to_genpd(dev); + if (IS_ERR(genpd)) + return -ENODEV; + + genpd_lock(genpd); + *state = genpd->performance_state; + genpd_unlock(genpd); + + return 0; +} +EXPORT_SYMBOL_GPL(dev_pm_genpd_get_performance_state); + +int dev_pm_genpd_performance_state_count(struct device *dev, + unsigned int *count) +{ + struct generic_pm_domain *genpd; + int ret; + + genpd = dev_to_genpd(dev); + if (IS_ERR(genpd)) + return -ENODEV; + + if (unlikely(!genpd->get_performance_state_count)) + return -EINVAL; + + genpd_lock(genpd); + ret = genpd->get_performance_state_count(genpd, count); + genpd_unlock(genpd); + + return ret; +} +EXPORT_SYMBOL_GPL(dev_pm_genpd_performance_state_count); + static int _genpd_power_on(struct generic_pm_domain *genpd, bool timed) { unsigned int state_idx = genpd->state_idx; diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 91d9bf4..0e5f502 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -117,6 +117,8 @@ struct generic_pm_domain { struct dev_pm_opp *opp); int (*set_performance_state)(struct generic_pm_domain *genpd, unsigned int state); + int (*get_performance_state_count)(struct generic_pm_domain *genpd, + unsigned int *count); struct gpd_dev_ops dev_ops; s64 max_off_time_ns; /* Maximum allowed "suspended" time. */ bool max_off_time_changed; @@ -204,6 +206,10 @@ int pm_genpd_init(struct generic_pm_domain *genpd, struct dev_power_governor *gov, bool is_off); int pm_genpd_remove(struct generic_pm_domain *genpd); int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state); +int dev_pm_genpd_get_performance_state(struct device *dev, + unsigned int *state); +int dev_pm_genpd_performance_state_count(struct device *dev, + unsigned int *count); extern struct dev_power_governor simple_qos_governor; extern struct dev_power_governor pm_domain_always_on_gov; @@ -251,6 +257,18 @@ static inline int dev_pm_genpd_set_performance_state(struct device *dev, return -ENOTSUPP; } +static inline int dev_pm_genpd_get_performance_state(struct device *dev, + unsigned int *state); +{ + return -ENOTSUPP; +} + +static inline int dev_pm_genpd_performance_state_count(struct device *dev, + unsigned int *count); +{ + return -ENOTSUPP; +} + #define simple_qos_governor (*(struct dev_power_governor *)(NULL)) #define pm_domain_always_on_gov (*(struct dev_power_governor *)(NULL)) #endif From patchwork Sat Aug 10 00:58:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 170991 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp10715976ile; Fri, 9 Aug 2019 17:58:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqyNIihj3hhyDlGdQpm7CIht0tjCTa1aZJpQGI+7Ssb2PgruZsw+8f+UhFazKcNE/TpbjWko X-Received: by 2002:a17:90a:2ec1:: with SMTP id h1mr12114267pjs.119.1565398733128; Fri, 09 Aug 2019 17:58:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565398733; cv=none; d=google.com; s=arc-20160816; b=0z+YCpd7adkrpYwIsFIdzmZlQ7maH0TSu3h0vvJXEqzQ1SETtBj5Q04R8FtMGjtqTx 291hvYFx6/Nd6P2tL50Pi8P6JIJq+Wg5TllRgax/8An/l8MhStdwhvjcyVMgyHDhpkJI 8o1PYfr+gZ6Xt/AGnISf3KfWf5g+MVuLFqWJnggxwXH990qIE9jEnjpaE2veZF5g2y3z Ryutqf99GIusEb3fwcoONsmpzU/RSzbSR8KB/C5H6gOOOQ7gdCmryZKWzmIlPb/QJX3m M1wxGfUQSFheSxgGj1482cGnBDCsbkDZ+eiFKEPRrC5axGER9EDktD9rYWV2os6zVhII V60Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=13LVANg+Nc4wFsq66FKdnpOxcNuSuCvqcBPgkyt37SU=; b=dTkEZUQyrMQHgLSawBCMeX8mJudEJuG599fQ9SVI75EeNyK1vtxRO/z1uwPUKnhjcq KpKxm1Mt5sc1vmNRNLGi+CxKZFLbsbY9yukL1Qxe1AlI4xTQZp/kz+W3aww+e081Vpdh xBl9v/jzUej30iJivNmmATwjk/KNg6jvKDnP8E3WVwEzbI/dyN41sqr1EoZDmxc1k1q3 3n/9B77++e4jQpqU9iL/MQM+sL6M2g9UmTnhjTzO7R14TUpqX6llSlLlj4iI9iZVDRqz MkzNjdNVQgyG+UldGGI2VlhTe+tuMVEU3aSncqR4ogTLSw1R83GI4cyHlBfA986upqB0 T82A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fkj1qM9f; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m17si25793031pgc.461.2019.08.09.17.58.52; Fri, 09 Aug 2019 17:58:53 -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; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fkj1qM9f; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726219AbfHJA6w (ORCPT + 11 others); Fri, 9 Aug 2019 20:58:52 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:40974 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726022AbfHJA6w (ORCPT ); Fri, 9 Aug 2019 20:58:52 -0400 Received: by mail-qk1-f195.google.com with SMTP id g17so2401634qkk.8 for ; Fri, 09 Aug 2019 17:58:51 -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=13LVANg+Nc4wFsq66FKdnpOxcNuSuCvqcBPgkyt37SU=; b=fkj1qM9fpuWVUyr8YFX96K/2OyizzEfajg6DpswTKkG/OhVeSk2Fc+uduUGyGafahx qEncxtkTPQmbq2yn6z4WOIm34roKXlIk1qnKVZx26SDb6Zu60Do/RIPcilBsUR3n6COx LdvK6eX0x75jB5f0AfwKR3PkNk1jVmVFnPUOUNnHvlavHjYrazxS9c7jJxYsn6vPy/Nh xdDHeO2W78Q8iIf/uQqfICn3+ujmhZxFZK66apZFPSas95MfmuIrSjcSgzIMf7wyyiPS dGz3da4NQjrVYfK6kI8mF4S2uF7QVTLAQ9N4Do7DPs5Kgyszx+8eBVLfOgOIjsJWR0+X XngQ== 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=13LVANg+Nc4wFsq66FKdnpOxcNuSuCvqcBPgkyt37SU=; b=bramyJozsIEeScA7TZGFhVaofFEJWdyq6rKsmp7s8ENs1Y6WdRGSW48aAqBDyDgbQa hYEcfeSm++CuRhyb+u/zM69Ycin+m6vmBsSQoAacUiGcfwqT7RZcmuD4COxSrlA+X7p+ NYal3BDHm7KyHUTkWd2rdPf8iAlni/gsngCH7uCpf2Zw+iKAPCg1J4ca+yHt+jtAl4Uz 6dI/b+RHvcSNpzr4n+DHvFduGj9+NeFsYJ0LQqsk7MDP6vzGIn8avu1fLGrR4AcRhb5T ykywrzbuMp04lLxCC39X+V8KmKAfxfg4uNq9PieAw/Nnpp3s6AkPl8wVzupp5G+mC0ja RcLQ== X-Gm-Message-State: APjAAAV9YxYXhU/daIQ8/LqlG6Td/BdxCkIY8Ene7QQhwMiqtqeps2sJ t8D/FicLZrxCOf63B8cUF7rujQ== X-Received: by 2002:a37:6905:: with SMTP id e5mr14664658qkc.121.1565398731271; Fri, 09 Aug 2019 17:58:51 -0700 (PDT) Received: from Thara-Work-Ubuntu.fios-router.home (pool-71-255-245-97.washdc.fios.verizon.net. [71.255.245.97]) by smtp.googlemail.com with ESMTPSA id t9sm4603105qtr.29.2019.08.09.17.58.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Aug 2019 17:58:50 -0700 (PDT) From: Thara Gopinath To: qualcomm-lt@lists.linaro.org, linux-pm@vger.kernel.org Cc: bjorn.andersson@linaro.org, ulf.hansson@linaro.org, rnayak@codeaurora.org Subject: [PATCH 2/4] soc: qcom: rpmhpd: Introduce function to retrieve power domain performance state count Date: Fri, 9 Aug 2019 20:58:45 -0400 Message-Id: <1565398727-23090-3-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1565398727-23090-1-git-send-email-thara.gopinath@linaro.org> References: <1565398727-23090-1-git-send-email-thara.gopinath@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Populate .get_performace_state_count in genpd ops to retrieve the count of performance states supported by a rpmh power domain. Signed-off-by: Thara Gopinath --- drivers/soc/qcom/rpmhpd.c | 11 +++++++++++ 1 file changed, 11 insertions(+) -- 2.1.4 diff --git a/drivers/soc/qcom/rpmhpd.c b/drivers/soc/qcom/rpmhpd.c index 5741ec3..c3ceffd 100644 --- a/drivers/soc/qcom/rpmhpd.c +++ b/drivers/soc/qcom/rpmhpd.c @@ -285,6 +285,15 @@ static unsigned int rpmhpd_get_performance_state(struct generic_pm_domain *genpd return dev_pm_opp_get_level(opp); } +static int rpmhpd_performance_states_count(struct generic_pm_domain *domain, + unsigned int *count) +{ + struct rpmhpd *pd = domain_to_rpmhpd(domain); + + *count = pd->level_count; + return 0; +} + static int rpmhpd_update_level_mapping(struct rpmhpd *rpmhpd) { int i; @@ -373,6 +382,8 @@ static int rpmhpd_probe(struct platform_device *pdev) rpmhpds[i]->pd.power_on = rpmhpd_power_on; rpmhpds[i]->pd.set_performance_state = rpmhpd_set_performance_state; rpmhpds[i]->pd.opp_to_performance_state = rpmhpd_get_performance_state; + rpmhpds[i]->pd.get_performance_state_count = + rpmhpd_performance_states_count; pm_genpd_init(&rpmhpds[i]->pd, NULL, true); data->domains[i] = &rpmhpds[i]->pd; From patchwork Sat Aug 10 00:58:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 170992 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp10715989ile; Fri, 9 Aug 2019 17:58:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqyN4CotSBYhkUlImbylSppVStcbUE0ShgNxGLEd4wNRRoA5l6j7H1pgX76GE19gBLKw/+bK X-Received: by 2002:a17:90a:5207:: with SMTP id v7mr11650987pjh.127.1565398734331; Fri, 09 Aug 2019 17:58:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565398734; cv=none; d=google.com; s=arc-20160816; b=GM7722RhqPYIwrTjx+xd+YC0sEOlR8ULWPQaThExWQ6Q/eBYJajXPD6MIqr06zj6W1 9vTrLAQUPlERMu0GDhOHbJ0jaqoPUgBE+O56XHcsKk0gV8DRikqhf+cM4/P1nt1rVV8m 1+nTjbeprp7wTD7BZAbyxHTonWv1XUnh8xX8OqWUqd5rWGzam2VeoodluDvKyDfNENM7 Mqz6WW5uR4sZ/kXU5fKfAMkm8Ys/HJdIOZu1mj0PHrWmnM9+ncA4aKomCw0HJ524O8ei 3lYHqBt5IjFspu9r8dd34o9uXLL1eI5t3L1jHA9r71emdJPNnwD2Jdt4sYr/vGUXb/sP PXvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=4IF9ScQESeKBDqqyLJCPFsIZb4YaXurMAPhBQcn8rBE=; b=U3Y4Ck3Fl+ZE2vXxIR7ynp8Rj+7SkWcfAzHOVX8Nrm8QamB4qpsr4kMJ6H1O36Sv2p 9uU2BlvZWIznPkSmxY8qqs3nMjbJPwUDENCADSW9yHPIz2nIrn+BykijZF9/2kiTulop rLGkILe1Lc7z13aBoVrqU+XSjlxOuFPqwtBsKBJxgsGTYfTkX4t1cZgZeIBSkF6ejnPg LyWt8RhNHXHL1cPvgTc2ck3lsOQDB9Y8Zb5VrXAm0Oq086cVbjCQ97A3jtZQ0IMWZPKk Ne9PLSDqAKPdSos3V9QvI5vl6EX0V3oyXYTsTq1mh/+gWZlEDKhAQY19p+IIFiLz71U9 iq/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZU4jIzke; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m17si25793031pgc.461.2019.08.09.17.58.54; Fri, 09 Aug 2019 17:58:54 -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; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZU4jIzke; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726263AbfHJA6x (ORCPT + 11 others); Fri, 9 Aug 2019 20:58:53 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:34518 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726022AbfHJA6x (ORCPT ); Fri, 9 Aug 2019 20:58:53 -0400 Received: by mail-qt1-f193.google.com with SMTP id q4so439995qtp.1 for ; Fri, 09 Aug 2019 17:58:52 -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=4IF9ScQESeKBDqqyLJCPFsIZb4YaXurMAPhBQcn8rBE=; b=ZU4jIzkezf53nUo8Z/wR2/OcpsWPiOjSJlCPYQ4MJOmc5/khwGT/LW6V1gyUOWrxim KGQxMxFSJ8XnVxDMrmIfXHBMbs+HE1P9YQjUvsTZGeA0DEPctyu0G5OylkXLDKgnPytY zYN8Qv4RN5qyWsH/KeHcwCY6RMlARbG8m8snj1IWwRcWCi0MVSSKllr1QeCOIapZh0tF 0ShEoEg2AvKS55liT4RhW9xavx655e4X2zznX/JE8TgDn/vtTTs93YPMfChxiYySH1Zg 13gyWSv/F19+GTFfY+Xy9n5Dnd166SCa2XFhcHTbvksTaHV+ELC4p7ZI30vbYS+NPQp9 U38Q== 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=4IF9ScQESeKBDqqyLJCPFsIZb4YaXurMAPhBQcn8rBE=; b=qk/RAfeWuJu4LmdJ5jKqO6J6B/nU8JZigNT1MlCX5j9Fi1aOXFhmQY1uzbNuKC2XiV 5i7C88I0e796/xEo1qGq1oyIIVJYy10h5R+kOFD35Iou7QC1EJ6MTl5w1N0Gpl6wKobo bjrh77RkPBPDrM3bMzad6KTdRJoS388n+G22r3AhynCff1GRZCZUOT6zpBpUOgd0P2cJ JATBgDeyfuqVj+Urw8n645WV/AaxeZUCkK2p0pKKUPsI1unj2ioR8Czd6TcXb0cA5tKh Q1zXr3BNGLfqMw0MKROkBPaI3LIwh4/lhUHsmNBkJBnDEvKG0rHqHHxJjXHbNfdCTTiE 6XDg== X-Gm-Message-State: APjAAAWbn9i35/SwkMfUJNr9lhmZWuTDxCmNWsl2+UGqaK2qrnZ2ztJQ vLu90rdSk+/J1GMdQUA5Q2V4fw== X-Received: by 2002:ad4:4026:: with SMTP id q6mr5105538qvp.12.1565398732189; Fri, 09 Aug 2019 17:58:52 -0700 (PDT) Received: from Thara-Work-Ubuntu.fios-router.home (pool-71-255-245-97.washdc.fios.verizon.net. [71.255.245.97]) by smtp.googlemail.com with ESMTPSA id t9sm4603105qtr.29.2019.08.09.17.58.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Aug 2019 17:58:51 -0700 (PDT) From: Thara Gopinath To: qualcomm-lt@lists.linaro.org, linux-pm@vger.kernel.org Cc: bjorn.andersson@linaro.org, ulf.hansson@linaro.org, rnayak@codeaurora.org Subject: [PATCH 3/4] thermal: qcom: Add RPMHPD cooling device driver. Date: Fri, 9 Aug 2019 20:58:46 -0400 Message-Id: <1565398727-23090-4-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1565398727-23090-1-git-send-email-thara.gopinath@linaro.org> References: <1565398727-23090-1-git-send-email-thara.gopinath@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The MX power domain in RPMH can be used to warm the the SoC in SDM845. To support this feature, introduce a RPMH power domain cooling device driver that can be plugged into the thermal framework.(The thermal framework itself requires further modifiction to support a warming device in place of a cooling device. Those extensions are not introduced in this patch series). Signed-off-by: Thara Gopinath --- drivers/thermal/qcom/Kconfig | 7 ++ drivers/thermal/qcom/Makefile | 1 + drivers/thermal/qcom/qcom-rpmhpd-cdev.c | 141 ++++++++++++++++++++++++++++++++ 3 files changed, 149 insertions(+) create mode 100644 drivers/thermal/qcom/qcom-rpmhpd-cdev.c -- 2.1.4 diff --git a/drivers/thermal/qcom/Kconfig b/drivers/thermal/qcom/Kconfig index aa9c1d8..a540130 100644 --- a/drivers/thermal/qcom/Kconfig +++ b/drivers/thermal/qcom/Kconfig @@ -20,3 +20,10 @@ config QCOM_SPMI_TEMP_ALARM trip points. The temperature reported by the thermal sensor reflects the real time die temperature if an ADC is present or an estimate of the temperature based upon the over temperature stage value. + +config CONFIG_QCOM_RPMHPD_CDEV + tristate "Qualcomm RPMHPD based cooling device" + depends on QCOM_RPMHPD + help + This enables RPMHPD based cooling devices. On SDM845, this is + MX power domain. diff --git a/drivers/thermal/qcom/Makefile b/drivers/thermal/qcom/Makefile index 7c8dc6e..e4eb520 100644 --- a/drivers/thermal/qcom/Makefile +++ b/drivers/thermal/qcom/Makefile @@ -4,3 +4,4 @@ obj-$(CONFIG_QCOM_TSENS) += qcom_tsens.o qcom_tsens-y += tsens.o tsens-common.o tsens-v0_1.o \ tsens-8960.o tsens-v2.o tsens-v1.o obj-$(CONFIG_QCOM_SPMI_TEMP_ALARM) += qcom-spmi-temp-alarm.o +obj-$(CONFIG_QCOM_RPMHPD_CDEV) += qcom-rpmhpd-cdev.o diff --git a/drivers/thermal/qcom/qcom-rpmhpd-cdev.c b/drivers/thermal/qcom/qcom-rpmhpd-cdev.c new file mode 100644 index 0000000..265523b --- /dev/null +++ b/drivers/thermal/qcom/qcom-rpmhpd-cdev.c @@ -0,0 +1,141 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2019, Linaro Ltd + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct rpmhpd_cooling_device { + struct thermal_cooling_device *cdev; + struct device *pwr_domain; + int max_state; + int cur_state; + bool is_pwr_domain_on; +}; + +static const char sdm845_rpmhpd_cdev_name[] = "mx"; + +static const struct of_device_id rpmhpd_cdev_match_table[] = { + { .compatible = "qcom,sdm845-rpmhpd-cdev", .data = &sdm845_rpmhpd_cdev_name }, + { } +}; +MODULE_DEVICE_TABLE(of, rpmhpd_cdev_match_table); + +static int rpmhpd_cdev_get_max_state(struct thermal_cooling_device *cdev, + unsigned long *state) +{ + struct rpmhpd_cooling_device *rpmhpd_cdev = cdev->devdata; + + *state = rpmhpd_cdev->max_state; + return 0; +} + +static int rpmhpd_cdev_get_cur_state(struct thermal_cooling_device *cdev, + unsigned long *state) +{ + struct rpmhpd_cooling_device *rpmhpd_cdev = cdev->devdata; + int perf_state; + + dev_pm_genpd_get_performance_state(rpmhpd_cdev->pwr_domain, + &perf_state); + *state = perf_state; + return 0; +} + +static int rpmhpd_cdev_set_cur_state(struct thermal_cooling_device *cdev, + unsigned long state) +{ + struct rpmhpd_cooling_device *rpmhpd_cdev = cdev->devdata; + struct device *pwr_domain = rpmhpd_cdev->pwr_domain; + int ret; + + ret = dev_pm_genpd_set_performance_state(pwr_domain, state); + + if (ret) + return ret; + + if (state && !rpmhpd_cdev->is_pwr_domain_on) { + ret = pm_runtime_get_sync(pwr_domain); + rpmhpd_cdev->is_pwr_domain_on = true; + } else if (!state && rpmhpd_cdev->is_pwr_domain_on) { + ret = pm_runtime_put(pwr_domain); + rpmhpd_cdev->is_pwr_domain_on = false; + } + + return ret; +} + +static struct thermal_cooling_device_ops rpmhpd_cooling_device_ops = { + .get_max_state = rpmhpd_cdev_get_max_state, + .get_cur_state = rpmhpd_cdev_get_cur_state, + .set_cur_state = rpmhpd_cdev_set_cur_state, +}; + +static int rpmhpd_cdev_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev, *pd_dev; + struct rpmhpd_cooling_device *rpmhpd_cdev; + const char *rpmhpd_cdev_name = of_device_get_match_data(dev); + unsigned int count; + int ret; + + if (!dev->pm_domain) { + pd_dev = dev_pm_domain_attach_by_name(dev, rpmhpd_cdev_name); + if (IS_ERR(pd_dev)) + return PTR_ERR(pd_dev); + } else { + pd_dev = dev; + } + + rpmhpd_cdev = devm_kzalloc(dev, sizeof(*rpmhpd_cdev), GFP_KERNEL); + if (!rpmhpd_cdev) { + ret = -ENOMEM; + goto detach_pd; + } + + ret = dev_pm_genpd_performance_state_count(pd_dev, &count); + if (ret) + goto detach_pd; + + rpmhpd_cdev->pwr_domain = pd_dev; + rpmhpd_cdev->max_state = count - 1; + rpmhpd_cdev->is_pwr_domain_on = false; + + pm_runtime_enable(pd_dev); + + rpmhpd_cdev->cdev = thermal_of_cooling_device_register + (dev->of_node, rpmhpd_cdev_name, + rpmhpd_cdev, + &rpmhpd_cooling_device_ops); + if (IS_ERR(rpmhpd_cdev->cdev)) { + dev_err(dev, "unable to register %s cooling device\n", + rpmhpd_cdev_name); + ret = PTR_ERR(rpmhpd_cdev->cdev); + goto detach_pd; + } + + return 0; + +detach_pd: + dev_pm_domain_detach(pd_dev, false); + return ret; +} + +static struct platform_driver rpmhpd_cdev_driver = { + .driver = { + .name = "qcom-rpmhpd-cdev", + .of_match_table = rpmhpd_cdev_match_table, + }, + .probe = rpmhpd_cdev_probe, +}; +module_platform_driver(rpmhpd_cdev_driver); + +MODULE_DESCRIPTION("Qualcomm RPMHPD cooling device driver"); +MODULE_LICENSE("GPL v2"); From patchwork Sat Aug 10 00:58:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 170993 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp10715998ile; Fri, 9 Aug 2019 17:58:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqwC8ktXzdRzTg4cUAQXOS6SiBo7ge2MeZbFijpFVZSYGJxw8xq9bMJyAkK3zpaVhcPzNhps X-Received: by 2002:a17:90a:8c92:: with SMTP id b18mr11908530pjo.97.1565398735177; Fri, 09 Aug 2019 17:58:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565398735; cv=none; d=google.com; s=arc-20160816; b=noisob1HsCtG7YGQzOaKo3wt9in3qsM1iY/UML2dKNe1vS5BNd2UxJn+6vhAGyplK0 RySO93+KoOzSmTlk1XNkaE7/4rakrmPdeE9lZ0ciZhC2/7CINTS7Hw67nHHl6v5U4ABy Dme8gYqjHh5BbkltkIJahmQxegBTLC7TvE0XgCk2dfdZvbVoKoFj2UoINFpqxI1mME3r 77EVaj9Kqtk2lXbNLFoc8Bp+nnVszq4gHY+wHceCANDLeGdkhipSEyBFCU9e3RV/iKiA j/VJBvEHw8gdNeVCr6h2qzyMc1xyyHPShZtn6AsKnkempu4dCikICUCjp/ojfkodqtJH /J8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=CuxrDfYHX+eqS5X0AI2ZfNX50adsNBjzE4KO2XDlGmw=; b=PRoWYZj1SX1WiXyxWsknLZz05Q3bTwaOJfclVZVG61uIfe0UXURDRLQKcTxDS/LAlt Y2VMp7OIhwqSS5cemYot7m1Upl9Gx/F2musYQGMg+3B+0pcXsn7Bwu4Ig9QSjqQWya3D O40efM4dZcMqeutQ91kUeTcDvmk3anZc47JiC/CV5QUclghl71AVKuRFLB/T+3ok/eb0 sKS42EE+GEtuWuyP11S6jWeQTk14ANNZlXXWQsD9M4s1h1DSMyEl2uj2kK2Oma4X6DWC cfVsDjbzCuVeVaVKj3xXUmkL+vnoZF4hQkR6vByU2cWwa68LUri0scGL7EkAVtAqjmDz uM2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wLJ6COGi; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m17si25793031pgc.461.2019.08.09.17.58.54; Fri, 09 Aug 2019 17:58:55 -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; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wLJ6COGi; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726557AbfHJA6y (ORCPT + 11 others); Fri, 9 Aug 2019 20:58:54 -0400 Received: from mail-qt1-f195.google.com ([209.85.160.195]:35102 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726022AbfHJA6y (ORCPT ); Fri, 9 Aug 2019 20:58:54 -0400 Received: by mail-qt1-f195.google.com with SMTP id d23so97650481qto.2 for ; Fri, 09 Aug 2019 17:58:53 -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=CuxrDfYHX+eqS5X0AI2ZfNX50adsNBjzE4KO2XDlGmw=; b=wLJ6COGi00EZzVvhlzI73V5txQJk5y+H6rWCcKlD954xIHUCfP8m2VYviThMqxBojP 4vib4/Y4ETOAh6PlCNzNGhIXDLUuWMHQFwyBzoQk7RYn6jHlfJlq67AJ0fgMGI0t0yok 2EyCycA76rfiaJAMaIk/rRQGEa74kWvRUJGTKo/qmU/nCkmNioxAHGo0XlWLfIPwTEgl oo5Z63gEJpR+GPEcVm999m+ms24PwgY+CGjMzz0SCH5bML0hHA3kgyp9zrMiRVnTgAsH bUk16dImjWgHom1eTH7oiju2B43/z+RtntSy9shtBqRzVryuolfBSaogj4cAZZH5ZZ4C y3Ag== 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=CuxrDfYHX+eqS5X0AI2ZfNX50adsNBjzE4KO2XDlGmw=; b=Seob9QGRZs0UeL5Y/uS9fNsSQoBSTcgo0Z0hnOXJ//0AHJaKlOAGnB47/w0BS0/4Sr wOCDWg6U/kSAFvwKJrKP1V/dRWyUDMJwChyo9uwYHY3qd/brP4C70IwkDmVz5SbFl2O+ D/Aa6c+V1u1hjPnaYQZsNA7JogVTje0wxeUtBpzAyMNBXjtrLE3vObt1QPcNR6dy7RFl RvZ+M8/cdywqHmRmt6WcKh7KGsAZmGsfjgjsHKWZyq1KySgUMPR4fpwGi+o5i53PkGEQ YUETu45kcRRYZ/3wVYP0UrlRdXj3ZuECiSA3GYHXyToUkXX8qguEnBFGyXnx7dU4btiR YBRQ== X-Gm-Message-State: APjAAAW9A/fDhsBTM0dXj+e2irJW2cN5v5piHY1oBNnym59CcSG/9Z1M DbmApTp2nM6i17lPANjy8tiT1g== X-Received: by 2002:a0c:b88e:: with SMTP id y14mr20116512qvf.93.1565398733254; Fri, 09 Aug 2019 17:58:53 -0700 (PDT) Received: from Thara-Work-Ubuntu.fios-router.home (pool-71-255-245-97.washdc.fios.verizon.net. [71.255.245.97]) by smtp.googlemail.com with ESMTPSA id t9sm4603105qtr.29.2019.08.09.17.58.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Aug 2019 17:58:52 -0700 (PDT) From: Thara Gopinath To: qualcomm-lt@lists.linaro.org, linux-pm@vger.kernel.org Cc: bjorn.andersson@linaro.org, ulf.hansson@linaro.org, rnayak@codeaurora.org Subject: [PATCH 4/4] arm64: dts: qcom: Extend AOSS RPMHPD node Date: Fri, 9 Aug 2019 20:58:47 -0400 Message-Id: <1565398727-23090-5-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1565398727-23090-1-git-send-email-thara.gopinath@linaro.org> References: <1565398727-23090-1-git-send-email-thara.gopinath@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org RPMHPD hosts resources that can be used to warm up Add nodes for these resources for sdm845 (mx power domain). Signed-off-by: Thara Gopinath --- arch/arm64/boot/dts/qcom/sdm845.dtsi | 7 +++++++ 1 file changed, 7 insertions(+) -- 2.1.4 diff --git a/arch/arm64/boot/dts/qcom/sdm845.dtsi b/arch/arm64/boot/dts/qcom/sdm845.dtsi index d0c0d4f..c5b8459 100644 --- a/arch/arm64/boot/dts/qcom/sdm845.dtsi +++ b/arch/arm64/boot/dts/qcom/sdm845.dtsi @@ -2602,6 +2602,13 @@ compatible = "qcom,sdm845-rsc-hlos"; #interconnect-cells = <1>; }; + + rpmh_mx_cdev: mx { + compatible = "qcom,sdm845-rpmhpd-cdev"; + #cooling-cells = <2>; + power-domains = <&rpmhpd SDM845_MX>; + power-domain-names = "mx"; + }; }; intc: interrupt-controller@17a00000 {