linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bjorn Andersson <bjorn.andersson@linaro.org>
To: Andy Gross <andy.gross@linaro.org>,
	David Brown <david.brown@linaro.org>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>
Cc: Russell King <linux@armlinux.org.uk>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	Arun Kumar Neelakantam <aneela@codeaurora.org>,
	linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [(RFC) PATCH v2 7/7] soc: qcom: aoss-qmp: Add cooling device support
Date: Sun,  6 Jan 2019 00:09:15 -0800	[thread overview]
Message-ID: <20190106080915.4493-8-bjorn.andersson@linaro.org> (raw)
In-Reply-To: <20190106080915.4493-1-bjorn.andersson@linaro.org>

The AOSS provides three cooling devices "cx", "mx" and "ebi" that must
be enabled when temperature goes below a certain level to counter low
temperature issues. Probe these devices, when described in DeviceTree.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---

We do not yet have the necessary support in the thermal framework to implement
the cooling device associated with the QMP, so I've just included this patch as
an RFC in this series.

 .../bindings/soc/qcom/qcom,aoss-qmp.txt       | 18 ++++++++++
 drivers/soc/qcom/aoss-qmp.c                   | 36 +++++++++++++++++++
 2 files changed, 54 insertions(+)

diff --git a/Documentation/devicetree/bindings/soc/qcom/qcom,aoss-qmp.txt b/Documentation/devicetree/bindings/soc/qcom/qcom,aoss-qmp.txt
index 9b0d9785efe0..aae300f32421 100644
--- a/Documentation/devicetree/bindings/soc/qcom/qcom,aoss-qmp.txt
+++ b/Documentation/devicetree/bindings/soc/qcom/qcom,aoss-qmp.txt
@@ -42,6 +42,16 @@ power-domains.
 		    modem state (3), SLPI state (4), SPSS state (5) and Venus
 		    state (6).
 
+= SUBNODES
+The AOSS side channel also provides the controls for three cooling devices,
+these are expressed as subnodes of the QMP node. The name of the node is used
+to identify the resource and must therefor be "cx", "mx" or "ebi".
+
+- #cooling-cells:
+	Usage: optional
+	Value type: <u32>
+	Definition: must be 2
+
 = EXAMPLE
 
 The following example represents the AOSS side-channel message RAM and the
@@ -54,4 +64,12 @@ mechanism exposing the power-domains, as found in SDM845.
           mboxes = <&apss_shared 0>;
 
 	  #power-domain-cells = <1>;
+
+	  cx_cdev: cx {
+		#cooling-cells = <2>;
+	  };
+
+	  mx_cdev: mx {
+		#cooling-cells = <2>;
+	  };
   };
diff --git a/drivers/soc/qcom/aoss-qmp.c b/drivers/soc/qcom/aoss-qmp.c
index de52703b96b6..6e9299e3b2bd 100644
--- a/drivers/soc/qcom/aoss-qmp.c
+++ b/drivers/soc/qcom/aoss-qmp.c
@@ -33,6 +33,8 @@
 #define QMP_MAGIC	0x4d41494c
 #define QMP_VERSION	1
 
+#define QMP_MAX_COOLING_DEVICES		3
+
 /**
  * struct qmp - driver state for QMP implementation
  * @msgram: iomem referencing the message RAM used for communication
@@ -44,6 +46,8 @@
  * @event: wait_queue for synchronization with the IRQ
  * @tx_lock: provides syncrhonization between multiple callers of qmp_send()
  * @pd_pdev: platform device for the power-domain child device
+ * @cdev_pdevs: platform device for the cooling devices
+ * @cdev_count: number of valid @cdev_pdevs
  */
 struct qmp {
 	void __iomem *msgram;
@@ -60,6 +64,9 @@ struct qmp {
 	struct mutex tx_lock;
 
 	struct platform_device *pd_pdev;
+
+	struct platform_device *cdev_pdevs[QMP_MAX_COOLING_DEVICES];
+	size_t cdev_count;
 };
 
 static void qmp_kick(struct qmp *qmp)
@@ -230,6 +237,8 @@ EXPORT_SYMBOL(qmp_send);
 
 static int qmp_probe(struct platform_device *pdev)
 {
+	struct platform_device *cdev;
+	struct device_node *cdev_node;
 	struct resource *res;
 	struct qmp *qmp;
 	int irq;
@@ -279,13 +288,40 @@ static int qmp_probe(struct platform_device *pdev)
 			dev_err(&pdev->dev, "failed to register AOSS PD\n");
 	}
 
+	for_each_available_child_of_node(pdev->dev.of_node, cdev_node) {
+		if (!of_property_read_bool(cdev_node, "#cooling-cells"))
+			continue;
+
+		/* Register cooling device, with its device_node as platform_data */
+		cdev = platform_device_register_data(&pdev->dev,
+						     "aoss_qmp_cdev",
+						     PLATFORM_DEVID_AUTO,
+						     of_node_get(cdev_node),
+						     sizeof(cdev_node));
+		if (IS_ERR(cdev)) {
+			dev_err(&pdev->dev,
+				"failed to register cooling device: %pOFn\n",
+				cdev_node);
+			continue;
+		}
+
+		qmp->cdev_pdevs[qmp->cdev_count++] = cdev;
+	}
+
 	return 0;
 }
 
 static int qmp_remove(struct platform_device *pdev)
 {
 	struct qmp *qmp = platform_get_drvdata(pdev);
+	struct device_node *np;
+	int i;
 
+	for (i = 0; i < qmp->cdev_count; i++) {
+		np = dev_get_platdata(&qmp->cdev_pdevs[i]->dev);
+		platform_device_unregister(qmp->cdev_pdevs[i]);
+		of_node_put(np);
+	}
 	platform_device_unregister(qmp->pd_pdev);
 
 	qmp_close(qmp);
-- 
2.18.0


  parent reply	other threads:[~2019-01-06  8:10 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-06  8:09 [PATCH v2 0/7] Qualcomm AOSS QMP side channel binding and driver Bjorn Andersson
2019-01-06  8:09 ` [PATCH v2 1/7] dt-bindings: soc: qcom: Add AOSS QMP binding Bjorn Andersson
2019-01-11 22:10   ` Rob Herring
2019-01-14 22:30   ` Stephen Boyd
2019-01-06  8:09 ` [PATCH v2 2/7] soc: qcom: Add AOSS QMP communication driver Bjorn Andersson
2019-01-10 12:48   ` Arun Kumar Neelakantam
2019-01-14 22:36   ` Stephen Boyd
2019-01-14 23:20     ` Bjorn Andersson
2019-01-06  8:09 ` [PATCH v2 3/7] soc: qcom: Add AOSS QMP genpd provider Bjorn Andersson
2019-01-10  4:59   ` Sai Prakash Ranjan
2019-01-14 22:40   ` Stephen Boyd
2019-01-14 23:29     ` Bjorn Andersson
2019-01-06  8:09 ` [PATCH v2 4/7] remoteproc: q6v5-mss: Vote for rpmh power domains Bjorn Andersson
2019-01-09 14:39   ` Sibi Sankar
2019-01-06  8:09 ` [PATCH v2 5/7] remoteproc: q6v5-mss: Active powerdomain for SDM845 Bjorn Andersson
2019-01-09 14:40   ` Sibi Sankar
2019-01-06  8:09 ` [PATCH v2 6/7] amba: Allow pclk to be controlled by power domain Bjorn Andersson
2019-01-06  8:09 ` Bjorn Andersson [this message]
2019-01-11 22:11   ` [(RFC) PATCH v2 7/7] soc: qcom: aoss-qmp: Add cooling device support Rob Herring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190106080915.4493-8-bjorn.andersson@linaro.org \
    --to=bjorn.andersson@linaro.org \
    --cc=andy.gross@linaro.org \
    --cc=aneela@codeaurora.org \
    --cc=david.brown@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-soc@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mark.rutland@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=ulf.hansson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).