From patchwork Wed Nov 20 12:56:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 179842 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp2064130ilf; Wed, 20 Nov 2019 04:56:58 -0800 (PST) X-Google-Smtp-Source: APXvYqx1Di9cwJgm16IGqMjdkGNLHd7n2tQ2NfDzqfiSxGho+rExx4YGwAtbo+oD2QKuLuFvecNY X-Received: by 2002:a17:906:fac7:: with SMTP id lu7mr5340835ejb.5.1574254617899; Wed, 20 Nov 2019 04:56:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574254617; cv=none; d=google.com; s=arc-20160816; b=m3PpmyTLFkTUpSCS43wz3gTmf7LNVcXpw+pteopCP0eltVb/4JYuKcvvTacODfGEsp bwukJf6GUq22JzmRWyZcnZ1nuyZWXAU4TrbvQyRLjnGu4MCI3dUQGXrz3gi/xuMxeCE/ K2bM/yl/vXIYmI+DA/PmQHaIDtbCn01neZ27Yn51u9VMhxFSIgv0PjUC3ULQWlznECVJ n0y8iG4xPD/kF5W/pkyLfxqR8CYIA/n1pAEWv8hRlp6XFF89wKMKietjM1Wt9VBWP1aK TvczMc/tbw9yp3PjlHHfxj5cxfOyy22yucGIIC7dGHYG83/fbmi1GuodcVegTwxwoSkk 9bhg== 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=UM2VNIyhsEQWAdxoUvBsAp0FiOlz8ZfKGsaB/5AYX7U=; b=vm5LEFgzOBl4j08/TUuVlnsWkQv67n5d+thXxIqyv1l70AM6lNrOv1LB1K9EVpCUFj q8TxjtAqTi5Ro1vSn1cjNjwrO0SNhiAVoNfTjIDqe0/o7leq3qqPlAOHfjxfP24vUDE2 fz1YufnDpdjLAJuVknJ7QODdwidx8FbcVlGW7rPjBXlDVDnPPH3BYf9abq2Wj3is0MdF 1H2wFPkL6Dmt0+JI0CioElux4Q7ZcSYGo8wRi5j8wsKeYxwS7fzmG933O//SjnABTFiH H33fUk8Cb77f2lun3uslx2QquaI1o6xukQTGeW5/ThhHYh1r6nJHQeWNwojyLt/fI1yF 9qLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WD85C7u9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 d5si14456121edv.385.2019.11.20.04.56.57; Wed, 20 Nov 2019 04:56:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=WD85C7u9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S1729994AbfKTM44 (ORCPT + 26 others); Wed, 20 Nov 2019 07:56:56 -0500 Received: from mail-qt1-f193.google.com ([209.85.160.193]:33339 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729971AbfKTM4z (ORCPT ); Wed, 20 Nov 2019 07:56:55 -0500 Received: by mail-qt1-f193.google.com with SMTP id y39so28847380qty.0 for ; Wed, 20 Nov 2019 04:56:54 -0800 (PST) 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=UM2VNIyhsEQWAdxoUvBsAp0FiOlz8ZfKGsaB/5AYX7U=; b=WD85C7u9NWEMbHwM/sjKEJ4ryfnNgTq8BlVICVvxRxopHEEe+V0gp1qsTJaBODoV7L 0qE3b01AwO9mamaPEukWnzpvRAICFGL7Y8V75jkkn9rrt7FV3M5EGCKxmLZkRM//MeLu DL8MqTPlzvfuO5j1DL1pl2mCM/ht/AVuL48lXY70xE6x0XbDx9px3UdYVm+4OPRzs+ma SVnyBCFwbqQu4TrVCYt28lHsyhxIzzrQhY1C5NU4YtVLv5/nnBpk4oDMYrgFeukxKudZ Q7lrhjUG0BvDr12OTGAnxAi5mtLuYnTL8xM4L2OxgzHcTj+BIHpX6RX18JQx3Y+DsrKi N0Ug== 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=UM2VNIyhsEQWAdxoUvBsAp0FiOlz8ZfKGsaB/5AYX7U=; b=symqPNnFN3KJ9Q/DBtz0c1dsUqkkPitcRNLhuSGGSoyNqX4IWbueSusTV1Hb0n7cJX Z92Jtzt6yviqhSyzvAgT8e5KAmgjKMBzc0bRG9p3lZuhpIfGDWT4BjFKiZKzmrDRYeU/ IkrHY/mrzROHjOOagy9kCdMO0eXKWiT8hm24ZzGz3y2kJh5GUkgaM7qVG4jjyB3+xfsr yG2zwlS800s9YRsQcnZD/1m65xo35lcfFvgwoUnRnSvMWTfCapTJANHs9neTIj2jgtke TLJ7VHSTKPKHZfM55Bmgpljj1R/xmuTuXizpbZ7j1nvCzOecqqBT7Mj5/cmTuj2y+Vqf QntA== X-Gm-Message-State: APjAAAV28aQCRWR7KUCdabrTLuQtIJs8J7VTTGwWAwM/xdLFgeuOH8fr /cmyjvvUIzpwN3hRYD+ek7bVuw== X-Received: by 2002:ac8:288a:: with SMTP id i10mr2378040qti.139.1574254613445; Wed, 20 Nov 2019 04:56:53 -0800 (PST) Received: from Thara-Work-Ubuntu.fios-router.home (pool-71-255-246-27.washdc.fios.verizon.net. [71.255.246.27]) by smtp.googlemail.com with ESMTPSA id r2sm14109637qtc.28.2019.11.20.04.56.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Nov 2019 04:56:51 -0800 (PST) From: Thara Gopinath To: edubezval@gmail.com, rui.zhang@intel.com, ulf.hansson@linaro.org, daniel.lezcano@linaro.org, bjorn.andersson@linaro.org, agross@kernel.org Cc: amit.kucheria@verdurent.com, mark.rutland@arm.com, rjw@rjwysocki.net, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [Patch v4 4/7] thermal: Add generic power domain warming device driver. Date: Wed, 20 Nov 2019 07:56:30 -0500 Message-Id: <1574254593-16078-5-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1574254593-16078-1-git-send-email-thara.gopinath@linaro.org> References: <1574254593-16078-1-git-send-email-thara.gopinath@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Resources modeled as power domains in linux kenrel can be used to warm the SoC(eg. mx power domain on sdm845). To support this feature, introduce a generic power domain warming 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 --- v3->v4: - Removed late_init hook pd_warming_device_ops. - Use of_genpd_add_device instead of pm_genpd_add_device to attach device to the generic power domain. - Use thermal_of_cooling_device_parent_register to register the cooling device so that the device with genpd attached can be made parent of the cooling device. - With above changes, remove reference to generic_pm_domain in pd_warming_device. drivers/thermal/Kconfig | 10 +++ drivers/thermal/Makefile | 2 + drivers/thermal/pwr_domain_warming.c | 138 +++++++++++++++++++++++++++++++++++ include/linux/pwr_domain_warming.h | 29 ++++++++ 4 files changed, 179 insertions(+) create mode 100644 drivers/thermal/pwr_domain_warming.c create mode 100644 include/linux/pwr_domain_warming.h -- 2.1.4 diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig index 001a21a..0c5c93e 100644 --- a/drivers/thermal/Kconfig +++ b/drivers/thermal/Kconfig @@ -187,6 +187,16 @@ config DEVFREQ_THERMAL If you want this support, you should say Y here. +config PWR_DOMAIN_WARMING_THERMAL + bool "Power Domain based warming device" + depends on PM_GENERIC_DOMAINS_OF + help + This implements the generic power domain based warming + mechanism through increasing the performance state of + a power domain. + + If you want this support, you should say Y here. + config THERMAL_EMULATION bool "Thermal emulation mode support" help diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile index 74a37c7..382c64a 100644 --- a/drivers/thermal/Makefile +++ b/drivers/thermal/Makefile @@ -27,6 +27,8 @@ thermal_sys-$(CONFIG_CLOCK_THERMAL) += clock_cooling.o # devfreq cooling thermal_sys-$(CONFIG_DEVFREQ_THERMAL) += devfreq_cooling.o +thermal_sys-$(CONFIG_PWR_DOMAIN_WARMING_THERMAL) += pwr_domain_warming.o + # platform thermal drivers obj-y += broadcom/ obj-$(CONFIG_THERMAL_MMIO) += thermal_mmio.o diff --git a/drivers/thermal/pwr_domain_warming.c b/drivers/thermal/pwr_domain_warming.c new file mode 100644 index 0000000..40162b9 --- /dev/null +++ b/drivers/thermal/pwr_domain_warming.c @@ -0,0 +1,138 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2019, Linaro Ltd + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct pd_warming_device { + struct thermal_cooling_device *cdev; + struct device dev; + int max_state; + int cur_state; + bool runtime_resumed; +}; + +static int pd_wdev_get_max_state(struct thermal_cooling_device *cdev, + unsigned long *state) +{ + struct pd_warming_device *pd_wdev = cdev->devdata; + + *state = pd_wdev->max_state; + return 0; +} + +static int pd_wdev_get_cur_state(struct thermal_cooling_device *cdev, + unsigned long *state) +{ + struct pd_warming_device *pd_wdev = cdev->devdata; + + *state = dev_pm_genpd_get_performance_state(&pd_wdev->dev); + + return 0; +} + +static int pd_wdev_set_cur_state(struct thermal_cooling_device *cdev, + unsigned long state) +{ + struct pd_warming_device *pd_wdev = cdev->devdata; + struct device *dev = &pd_wdev->dev; + int ret; + + ret = dev_pm_genpd_set_performance_state(dev, state); + + if (ret) + return ret; + + if (state && !pd_wdev->runtime_resumed) { + ret = pm_runtime_get_sync(dev); + pd_wdev->runtime_resumed = true; + } else if (!state && pd_wdev->runtime_resumed) { + ret = pm_runtime_put(dev); + pd_wdev->runtime_resumed = false; + } + + return ret; +} + +static struct thermal_cooling_device_ops pd_warming_device_ops = { + .get_max_state = pd_wdev_get_max_state, + .get_cur_state = pd_wdev_get_cur_state, + .set_cur_state = pd_wdev_set_cur_state, +}; + +struct thermal_cooling_device * +pwr_domain_warming_register(struct device *parent, char *pd_name, int pd_id) +{ + struct pd_warming_device *pd_wdev; + struct of_phandle_args pd_args; + int ret; + + pd_wdev = kzalloc(sizeof(*pd_wdev), GFP_KERNEL); + if (!pd_wdev) + return ERR_PTR(-ENOMEM); + + dev_set_name(&pd_wdev->dev, "%s_warming_dev", pd_name); + pd_wdev->dev.parent = parent; + + ret = device_register(&pd_wdev->dev); + if (ret) + goto error; + + pd_args.np = parent->of_node; + pd_args.args[0] = pd_id; + pd_args.args_count = 1; + + ret = of_genpd_add_device(&pd_args, &pd_wdev->dev); + + if (ret) + goto error; + + ret = dev_pm_genpd_performance_state_count(&pd_wdev->dev); + if (ret < 0) + goto error; + + pd_wdev->max_state = ret - 1; + pm_runtime_enable(&pd_wdev->dev); + pd_wdev->runtime_resumed = false; + + pd_wdev->cdev = thermal_of_cooling_device_parent_register + (NULL, parent, pd_name, pd_wdev, + &pd_warming_device_ops); + if (IS_ERR(pd_wdev->cdev)) { + pr_err("unable to register %s cooling device\n", pd_name); + pm_runtime_disable(&pd_wdev->dev); + ret = PTR_ERR(pd_wdev->cdev); + goto error; + } + + return pd_wdev->cdev; +error: + put_device(&pd_wdev->dev); + kfree(pd_wdev); + return ERR_PTR(ret); +} +EXPORT_SYMBOL_GPL(pwr_domain_warming_register); + +void pwr_domain_warming_unregister(struct thermal_cooling_device *cdev) +{ + struct pd_warming_device *pd_wdev = cdev->devdata; + struct device *dev = &pd_wdev->dev; + + if (pd_wdev->runtime_resumed) { + dev_pm_genpd_set_performance_state(dev, 0); + pm_runtime_put(dev); + pd_wdev->runtime_resumed = false; + } + pm_runtime_disable(dev); + thermal_cooling_device_unregister(cdev); + kfree(pd_wdev); +} +EXPORT_SYMBOL_GPL(pwr_domain_warming_unregister); diff --git a/include/linux/pwr_domain_warming.h b/include/linux/pwr_domain_warming.h new file mode 100644 index 0000000..cb6550d --- /dev/null +++ b/include/linux/pwr_domain_warming.h @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2019, Linaro Ltd. + */ +#ifndef __PWR_DOMAIN_WARMING_H__ +#define __PWR_DOMAIN_WARMING_H__ + +#include +#include + +#ifdef CONFIG_PWR_DOMAIN_WARMING_THERMAL +struct thermal_cooling_device * +pwr_domain_warming_register(struct device *parent, char *pd_name, int pd_id); + +void pwr_domain_warming_unregister(struct thermal_cooling_device *cdev); + +#else +static inline struct thermal_cooling_device * +pwr_domain_warming_register(struct device *parent, char *pd_name, int pd_id) +{ + return ERR_PTR(-ENOSYS); +} + +static inline void +pwr_domain_warming_unregister(struct thermal_cooling_device *cdev) +{ +} +#endif /* CONFIG_PWR_DOMAIN_WARMING_THERMAL */ +#endif /* __PWR_DOMAIN_WARMING_H__ */ From patchwork Wed Nov 20 12:56:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thara Gopinath X-Patchwork-Id: 179843 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp2064222ilf; Wed, 20 Nov 2019 04:57:03 -0800 (PST) X-Google-Smtp-Source: APXvYqy1lsGArrnDLx1PxwvPL90RsFLR0Nk2pWOXxyD5lOFrjvWjzaHnO421kjdaOD90iQQDNnei X-Received: by 2002:adf:de86:: with SMTP id w6mr3200954wrl.220.1574254623357; Wed, 20 Nov 2019 04:57:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574254623; cv=none; d=google.com; s=arc-20160816; b=NAEMjxCwhJv2Qu97QM3gj0KKF0pa9Uk+gUQj+yrcAKLXbUT4L9WH36y2BIKUO6eM8P 4imxNOkdtvu5S79zH+Of9tJ5lqA+7R1LN6mng+OL3M4vDxhTg8vTolEXmyYF8TJTCC7X mBLOz1UuM5pWGyygG9YLPfX9xaKw3M1pvhWGge/F2nAD9U2Iu570wwgZfvqXbDilqNmU pGCvUkfidIPuntH9ZTxWcuLn5rsycZNxYv9tYp59HxJmfz7DvFbhxKYW+PxM7Hk8cMz1 9HgKc8TdwAMUxjKQ893tWtqjsJ1tz/HQYCYXAqwtthMA+YQCp54oVGeAGnVQ0f9Q3VzY 6jqw== 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=cANs+XnpVTcynqaWpfsqlgLUi206zYOAK/dPpz604Tg=; b=VXIdPdsmG+0RLnrsmtcyvdNzIe3Zo0SC8Z20yZN18j+0xj3BbmiHFlO0rDqHWC52YR U7K5V5SAtT/tam705NHk4zNrw1F9tgqTHm7coqRZG6IIbUegYp9MZVCeYZd+8Qcjcu8W euMNnnD9yI9OjAR9H6lUIBzdOiTTtXuTHjJM1q277v6q9/YFYUy3nqdkAFa0wZXPYP4l UubAA0b2n5iiH4Fnn/XKY5j7R3g5MzQMB2TRTL+3kB2JYpGYKMAA2g2G6pYQhvOxdiUS KnxVqfYpyCQhUggJ78/WqGOQ1w0AS3r818SXUR9uFcGwfn9P2wak6N5KGZZNo5GxhHlT lNAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="MJg7O/TJ"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 h58si17082461eda.18.2019.11.20.04.57.03; Wed, 20 Nov 2019 04:57:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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="MJg7O/TJ"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S1730009AbfKTM5A (ORCPT + 26 others); Wed, 20 Nov 2019 07:57:00 -0500 Received: from mail-qt1-f196.google.com ([209.85.160.196]:42349 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729971AbfKTM46 (ORCPT ); Wed, 20 Nov 2019 07:56:58 -0500 Received: by mail-qt1-f196.google.com with SMTP id t20so28777080qtn.9 for ; Wed, 20 Nov 2019 04:56:57 -0800 (PST) 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=cANs+XnpVTcynqaWpfsqlgLUi206zYOAK/dPpz604Tg=; b=MJg7O/TJk2K7ImDXGKhqrX6U/5p9NJhHcTR2lgYkod0HwVASuMcrBcy1ud268D1N0k b2DS/xpDFR5YAuK9gax0enejq1T5tamnZ8BlkYMGQiTKk1hoZ2cWWFGKLnyO7XRNqAk3 X2eT+CKejP1VK0TLb9TgYC7hkvgabZXMkU58QZv2au1anvF4cKaueiWBiPbypQ1qPC9d n+5Dzl0MxwU4kNB+nZ7TBGH6r2EAin5d3mKUjddUcOYF/pi772AziGhySCkrF2rr36eF YVeJpqt5QSlqI87Ri1KT7vhgJURoS0RxUES9B8fQ4qdrvuJxqP8HZqWaJHhNOuUpMJUd pwbg== 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=cANs+XnpVTcynqaWpfsqlgLUi206zYOAK/dPpz604Tg=; b=eX7mlc/HgfdgcmqzXVdmIaBVkKIU1mUNDmnClwSlIWbc2Fst1AUMimwM7NBe6xRCz4 +ufOT9sk37S59H/mQW7bqgyo736iuvt8NCDLM8dFOz787JtLQ69wm5F8YX0fORQeAW8+ wTRsMb2h4rfGpkrsVi4u/a5v6dj7XH6U8afpYjpEwsylHr7lw9iJFm1RQ5iieIyO2/6T IAZf/31yceWzKNCgBko5kysVOBlBsdxWo9Oms4jum4GTuFuCwL8Y81zgXBJdGU8Q5V2D mtEIq5ogpNW4Lt6k1V5RhpEPDoZkInkF/lbloflOIMan3x7Huok8j/XYwivxqWrab6lC 7rjg== X-Gm-Message-State: APjAAAWKfM2msNkHr7VMlfEAARs3xwYkBDac5CAvw5BHKQJv/Kqpds87 BpIbAIwQEBV+MIQMcbSwvlgErA== X-Received: by 2002:ac8:542:: with SMTP id c2mr2363165qth.56.1574254617325; Wed, 20 Nov 2019 04:56:57 -0800 (PST) Received: from Thara-Work-Ubuntu.fios-router.home (pool-71-255-246-27.washdc.fios.verizon.net. [71.255.246.27]) by smtp.googlemail.com with ESMTPSA id r2sm14109637qtc.28.2019.11.20.04.56.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Nov 2019 04:56:55 -0800 (PST) From: Thara Gopinath To: edubezval@gmail.com, rui.zhang@intel.com, ulf.hansson@linaro.org, daniel.lezcano@linaro.org, bjorn.andersson@linaro.org, agross@kernel.org Cc: amit.kucheria@verdurent.com, mark.rutland@arm.com, rjw@rjwysocki.net, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [Patch v4 5/7] soc: qcom: Extend RPMh power controller driver to register warming devices. Date: Wed, 20 Nov 2019 07:56:31 -0500 Message-Id: <1574254593-16078-6-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1574254593-16078-1-git-send-email-thara.gopinath@linaro.org> References: <1574254593-16078-1-git-send-email-thara.gopinath@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org RPMh power control hosts power domains that can be used as thermal warming devices. Register these power domains with the generic power domain warming device thermal framework. Signed-off-by: Thara Gopinath --- v3->v4: - Introduce a boolean value is_warming_dev in rpmhpd structure to indicate if a generic power domain can be used as a warming device or not.With this change, device tree no longer has to specify which power domain inside the rpmh power domain provider is a warming device. - Move registering of warming devices into a late initcall to ensure that warming devices are registerd after thermal framework is initialized. drivers/soc/qcom/rpmhpd.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) -- 2.1.4 diff --git a/drivers/soc/qcom/rpmhpd.c b/drivers/soc/qcom/rpmhpd.c index 9d37534..5666d1f 100644 --- a/drivers/soc/qcom/rpmhpd.c +++ b/drivers/soc/qcom/rpmhpd.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -48,6 +49,7 @@ struct rpmhpd { bool enabled; const char *res_name; u32 addr; + bool is_warming_dev; }; struct rpmhpd_desc { @@ -55,6 +57,8 @@ struct rpmhpd_desc { size_t num_pds; }; +const struct rpmhpd_desc *global_desc; + static DEFINE_MUTEX(rpmhpd_lock); /* SDM845 RPMH powerdomains */ @@ -89,6 +93,7 @@ static struct rpmhpd sdm845_mx = { .pd = { .name = "mx", }, .peer = &sdm845_mx_ao, .res_name = "mx.lvl", + .is_warming_dev = true, }; static struct rpmhpd sdm845_mx_ao = { @@ -396,7 +401,14 @@ static int rpmhpd_probe(struct platform_device *pdev) &rpmhpds[i]->pd); } - return of_genpd_add_provider_onecell(pdev->dev.of_node, data); + ret = of_genpd_add_provider_onecell(pdev->dev.of_node, data); + + if (ret) + return ret; + + global_desc = desc; + + return 0; } static struct platform_driver rpmhpd_driver = { @@ -413,3 +425,27 @@ static int __init rpmhpd_init(void) return platform_driver_register(&rpmhpd_driver); } core_initcall(rpmhpd_init); + +static int __init rpmhpd_init_warming_device(void) +{ + size_t num_pds; + struct rpmhpd **rpmhpds; + int i; + + if (!global_desc) + return -EINVAL; + + rpmhpds = global_desc->rpmhpds; + num_pds = global_desc->num_pds; + + if (!of_find_property(rpmhpds[0]->dev->of_node, "#cooling-cells", NULL)) + return 0; + + for (i = 0; i < num_pds; i++) + if (rpmhpds[i]->is_warming_dev) + pwr_domain_warming_register(rpmhpds[i]->dev, + rpmhpds[i]->res_name, i); + + return 0; +} +late_initcall(rpmhpd_init_warming_device);