Skip to contentSkip to conversation

firmware: qcom: scm: Convert to platform driver

PATCH Superseded Andy Gross 2 participants 3 messages Jul 20, 2015 – Sep 4, 2015

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Andy Gross

author
#0 lore raw

PATCH 1/1 firmware: qcom: scm: Convert to platform driver

This patch creates a platform driver for the SCM so that we can adequately manage resources. This removes clients having to carry the necessary clocks to use the SCM resources.

---
 .../devicetree/bindings/firmware/qcom,scm.txt      |   25 ++++
 drivers/firmware/qcom_scm.c                        |  138 +++++++++++++++++++-
 2 files changed, 159 insertions(+), 4 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/firmware/qcom,scm.txt
Documentation/devicetree/bindings/firmware/qcom,scm.txt new file +25 -0
new file mode 100644
index 0000000..debcd32
@@ -0,0 +1,25 @@
+QCOM Secure Channel Manager (SCM)
+
+Qualcomm processors include an interface to communicate to the secure firmware.
+This interface allows for clients to request different types of actions.  These
+can include CPU power up/down, HDCP requests, loading of firmware, and other
+assorted actions.
+
+Required properties:
+- compatible: must contain "qcom,scm"
+- clocks: Should contain the core, iface, and bus clocks.
+- clock-names: Must contain "core" for the core clock, "iface" for the interface
+  clock and "bus" for the bus clock.
+
+Example:
+
+	firmware {
+		compatible = "simple-bus";
+
+		scm {
+			compatible = "qcom,scm";
+			clocks = <&gcc GCC_CE1_CLK> , <&gcc GCC_CE1_AXI_CLK>, <&gcc GCC_CE1_AHB_CLK>;
+			clock-names = "core", "bus", "iface";
+		};
+	};
+
drivers/firmware/qcom_scm.c +134 -4

165 lines not on this page · raw message

Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
#1 lore raw
Quoted 6 lines · Andy Gross

This patch creates a platform driver for the SCM so that we can adequately manage resources. This removes clients having to carry the necessary clocks to use the SCM resources.

---

It would be nice if we could use this platform device for doing the DMAish memory allocations that we do in this driver too. I guess one complication there is that we would need to allocate memory with the DMA APIs before CPUs are brought up (early_initcall level).

drivers/firmware/qcom_scm.c line 20

Quoted 12 lines
drivers/firmware/qcom_scm.c +3 -1
index 45c008d..5dd0514 100644
@@ -15,14 +15,57 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  * 02110-1301, USA.
  */
-
+#include <linux/platform_device.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>

This include is here twice.

Quoted 7 lines
drivers/firmware/qcom_scm.c +2 -0
 #include <linux/cpumask.h>
 #include <linux/export.h>
 #include <linux/types.h>
 #include <linux/qcom_scm.h>
+#include <linux/of.h>
+#include <linux/clk.h>
 

[...]

Quoted 6 lines
drivers/firmware/qcom_scm.c +6 -0
+
+/**
+ * qcom_scm_is_available() - Checks if SCM is available
+ */
+bool qcom_scm_is_available(void)
+{

drivers/firmware/qcom_scm.c EXPORT_SYMBOL(qcom_scm_hdcp_available); · line 168

Quoted 10 lines
drivers/firmware/qcom_scm.c +10 -0
+	return !!__scm;
+}
+EXPORT_SYMBOL(qcom_scm_is_available);
+
+static int qcom_scm_remove(struct platform_device *pdev)
+{
+	__scm = NULL;
+
+	return 0;
+}

Maybe we just shouldn't allow this? The firmware isn't going anywhere at runtime, and this driver is currently marked as bool in the Kconfig.

drivers/firmware/qcom_scm.c EXPORT_SYMBOL(qcom_scm_hdcp_available); · line 219

Quoted 11 lines
drivers/firmware/qcom_scm.c +11 -0
+
+static const struct of_device_id qcom_scm_dt_match[] = {
+	{ .compatible = "qcom,scm",},
+	{},
+};
+
+MODULE_DEVICE_TABLE(of, qcom_scm_dt_match);
+
+static struct platform_driver qcom_scm_driver = {
+	.driver = {
+		.name	= "scm",

Maybe 'qcom_scm' ?

drivers/firmware/qcom_scm.c EXPORT_SYMBOL(qcom_scm_hdcp_available); · line 226

Quoted 7 lines
drivers/firmware/qcom_scm.c +7 -0
+		.of_match_table = qcom_scm_dt_match,
+	},
+	.probe = qcom_scm_probe,
+	.remove = qcom_scm_remove,
+};
+
+module_platform_driver(qcom_scm_driver);

Isn't there some sort of builtin_platform_driver() macro for builtin modules?

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
author
#2 lore raw
Quoted 5 lines · Stephen Boyd
Quoted 4 lines · Andy Gross

This patch creates a platform driver for the SCM so that we can adequately manage resources. This removes clients having to carry the necessary clocks to use the SCM resources.

Quoted 8 lines
Quoted 2 lines

---

It would be nice if we could use this platform device for doing the DMAish memory allocations that we do in this driver too. I guess one complication there is that we would need to allocate memory with the DMA APIs before CPUs are brought up (early_initcall level).

Yeah that's one thing we could do but we'd have to defer the memory stuff until it's used the first time (specific calls require it).

Quoted 36 lines

drivers/firmware/qcom_scm.c line 20

Quoted 13 lines
drivers/firmware/qcom_scm.c +3 -1
index 45c008d..5dd0514 100644
@@ -15,14 +15,57 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  * 02110-1301, USA.
  */
-
+#include <linux/platform_device.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>

This include is here twice.

Quoted 7 lines
drivers/firmware/qcom_scm.c +2 -0
 #include <linux/cpumask.h>
 #include <linux/export.h>
 #include <linux/types.h>
 #include <linux/qcom_scm.h>
+#include <linux/of.h>
+#include <linux/clk.h>
 

[...]

Quoted 12 lines
drivers/firmware/qcom_scm.c +12 -0
+
+/**
+ * qcom_scm_is_available() - Checks if SCM is available
+ */
+bool qcom_scm_is_available(void)
+{
+	return !!__scm;
+}
+EXPORT_SYMBOL(qcom_scm_is_available);
+
+static int qcom_scm_remove(struct platform_device *pdev)
+{
Quoted 8 lines

drivers/firmware/qcom_scm.c EXPORT_SYMBOL(qcom_scm_hdcp_available); · line 168

Quoted 4 lines
drivers/firmware/qcom_scm.c +4 -0
+	__scm = NULL;
+
+	return 0;
+}

Maybe we just shouldn't allow this? The firmware isn't going anywhere at runtime, and this driver is currently marked as bool in the Kconfig.

Fair enough.

Quoted 14 lines

drivers/firmware/qcom_scm.c EXPORT_SYMBOL(qcom_scm_hdcp_available); · line 219

Quoted 12 lines
drivers/firmware/qcom_scm.c +11 -0
+
+static const struct of_device_id qcom_scm_dt_match[] = {
+	{ .compatible = "qcom,scm",},
+	{},
+};
+
+MODULE_DEVICE_TABLE(of, qcom_scm_dt_match);
+
+static struct platform_driver qcom_scm_driver = {
+	.driver = {
+		.name	= "scm",

Maybe 'qcom_scm' ?

yeah i should have used that.

Quoted 11 lines

drivers/firmware/qcom_scm.c EXPORT_SYMBOL(qcom_scm_hdcp_available); · line 226

Quoted 8 lines
drivers/firmware/qcom_scm.c +7 -0
+		.of_match_table = qcom_scm_dt_match,
+	},
+	.probe = qcom_scm_probe,
+	.remove = qcom_scm_remove,
+};
+
+module_platform_driver(qcom_scm_driver);

Isn't there some sort of builtin_platform_driver() macro for builtin modules?

I'll take a look and convert.

Signature · 3 lines
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project