drivers/qcom: add Command DB support
v2 cover drivers/qcom: add Command DB support
Changes in [v2]:
- Use reserved memory regions instead of regs in DT
- Code cleanup suggested by Bjorn and Stephen
- Remove unused structures and functions.
- Update function names from _get_ to _read_
- Add documentation
These patches add support for reading a shared memory database in the newer QCOM SoCs called Command DB. With the new architecture on SDM845, shared resources like clocks, regulators etc., have dynamic properties. These properties may change based on external components, board configurations or available feature set. A remote processor detects these parameters and fills up the database with the resource and available state information. Platform drivers that need these shared resources will need to query this database to get the address and properties and vote for the state.
The information in the database is static. The database is read-only memory location that is available for Linux. A pre-defined string is used as a key into an entry in the database. Generally, platform drivers query the database only at init to get the information they need.
[v1]: https://www.spinics.net/lists/linux-arm-msm/msg32462.html
Lina Iyer (2):
drivers: qcom: add command DB driver
dt-bindings: introduce Command DB for QCOM SoCs
.../devicetree/bindings/arm/msm/cmd-db.txt | 38 +++ drivers/soc/qcom/Kconfig | 9 + drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/cmd-db.c | 321 +++++++++++++++++++++ include/soc/qcom/cmd-db.h | 50 ++++ 5 files changed, 419 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/msm/cmd-db.txt create mode 100644 drivers/soc/qcom/cmd-db.c create mode 100644 include/soc/qcom/cmd-db.h
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH v2 1/2 drivers: qcom: add command DB driver
From: Mahesh Sivasubramanian <[email protected]>
Command DB is a simple database in the shared memory of QCOM SoCs, that provides information regarding shared resources. Some shared resources in the SoC have properties that are probed dynamically at boot by the remote processor. The information pertaining to the SoC and the platform are made available in the shared memory. Drivers can query this information using predefined strings.
--- drivers/soc/qcom/Kconfig | 9 ++ drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/cmd-db.c | 321 ++++++++++++++++++++++++++++++++++++++++++++++ include/soc/qcom/cmd-db.h | 50 ++++++++ 4 files changed, 381 insertions(+) create mode 100644 drivers/soc/qcom/cmd-db.c create mode 100644 include/soc/qcom/cmd-db.h
drivers/soc/qcom/Kconfig +9 -0
@@ -3,6 +3,15 @@ # menu "Qualcomm SoC drivers" +config QCOM_COMMAND_DB + bool "Qualcomm Command DB" + depends on ARCH_QCOM || COMPILE_TEST + help + Command DB queries shared memory by key string for shared system + resources. Platform drivers that require to set state of a shared + resource on a RPM-hardened platform must use this database to get + SoC specific identifier and information for the shared resources. + config QCOM_GLINK_SSR tristate "Qualcomm Glink SSR driver" depends on RPMSG
drivers/soc/qcom/Makefile +1 -0
@@ -1,4 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_QCOM_COMMAND_DB) += cmd-db.o obj-$(CONFIG_QCOM_GLINK_SSR) += glink_ssr.o obj-$(CONFIG_QCOM_GSBI) += qcom_gsbi.o obj-$(CONFIG_QCOM_MDT_LOADER) += mdt_loader.o
drivers/soc/qcom/cmd-db.c new file +321 -0
321 lines not on this page · raw message
include/soc/qcom/cmd-db.h new file +50 -0
50 lines not on this page · raw message
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH v2 1/2] drivers: qcom: add command DB driver
Quoted 9 lines · Lina Iyer
From: Mahesh Sivasubramanian <[email protected]>
Command DB is a simple database in the shared memory of QCOM SoCs, that provides information regarding shared resources. Some shared resources in the SoC have properties that are probed dynamically at boot by the remote processor. The information pertaining to the SoC and the platform are made available in the shared memory. Drivers can query this information using predefined strings.
Quoted 3 lines
Signed-off-by Mahesh Sivasubramanian <[email protected]>Signed-off-by Lina Iyer <[email protected]>---
*snip*
Quoted 24 lines
drivers/soc/qcom/cmd-db.c new file +18
-0@@ -0,0 +1,321 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. */ + +#include <linux/kernel.h> +#include <linux/of.h> +#include <linux/of_address.h> +#include <linux/of_platform.h> +#include <linux/of_reserved_mem.h> +#include <linux/platform_device.h> +#include <linux/types.h> + +#include <soc/qcom/cmd-db.h> + +#define NUM_PRIORITY 2 +#define MAX_SLV_ID 8 +#define CMD_DB_MAGIC 0x0C0330DBUL +#define SLAVE_ID_MASK 0x7 +#define SLAVE_ID_SHIFT 16
drivers/soc/qcom/cmd-db.c line 28
Quoted 10 lines
drivers/soc/qcom/cmd-db.c new file +10
-0+ +#define ENTRY_HEADER (hdr) ((void *)cmd_db_header + \ + sizeof(*cmd_db_header) + \ + hdr->header_offset) + +#define RSC_OFFSET (hdr, ent) ((void *)cmd_db_header + \ + sizeof(*cmd_db_header) + \ + hdr.data_offset + ent.offset) + +#define MIN (a, b) (((a) < (b)) ? (a) : (b))
I'm not sure if this was addressed before. Why use a custom macro and not min() or min_t()?
Jordan
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH v2 1/2] drivers: qcom: add command DB driver
Quoted 45 lines · Jordan Crouse
Quoted 9 lines · Lina Iyer
From: Mahesh Sivasubramanian <[email protected]>
Command DB is a simple database in the shared memory of QCOM SoCs, that provides information regarding shared resources. Some shared resources in the SoC have properties that are probed dynamically at boot by the remote processor. The information pertaining to the SoC and the platform are made available in the shared memory. Drivers can query this information using predefined strings.
Quoted 3 lines
Signed-off-by Mahesh Sivasubramanian <[email protected]>Signed-off-by Lina Iyer <[email protected]>---
*snip*
Quoted 29 lines
drivers/soc/qcom/cmd-db.c new file +23
-0@@ -0,0 +1,321 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. */ + +#include <linux/kernel.h> +#include <linux/of.h> +#include <linux/of_address.h> +#include <linux/of_platform.h> +#include <linux/of_reserved_mem.h> +#include <linux/platform_device.h> +#include <linux/types.h> + +#include <soc/qcom/cmd-db.h> + +#define NUM_PRIORITY 2 +#define MAX_SLV_ID 8 +#define CMD_DB_MAGIC 0x0C0330DBUL +#define SLAVE_ID_MASK 0x7 +#define SLAVE_ID_SHIFT 16 + +#define ENTRY_HEADER (hdr) ((void *)cmd_db_header + \ + sizeof(*cmd_db_header) + \ + hdr->header_offset) +
Quoted 9 lines
drivers/soc/qcom/cmd-db.c line 28
Quoted 5 lines
drivers/soc/qcom/cmd-db.c new file +5
-0+#define RSC_OFFSET (hdr, ent) ((void *)cmd_db_header + \ + sizeof(*cmd_db_header) + \ + hdr.data_offset + ent.offset) + +#define MIN (a, b) (((a) < (b)) ? (a) : (b))I'm not sure if this was addressed before. Why use a custom macro and not
min()ormin_t()?
I didn't realize the existance of this. cscope brought out a ton of 'min' defn. Will fix in the next spin.
Thanks,
Lina
PATCH v2 2/2 dt-bindings: introduce Command DB for QCOM SoCs
In reply to Lina IyerFrom: Mahesh Sivasubramanian <[email protected]>
Command DB provides information on shared resources like clocks, regulators etc., probed at boot by the remote subsytem and made available in shared memory.
--- .../devicetree/bindings/arm/msm/cmd-db.txt | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/msm/cmd-db.txt
Documentation/devicetree/bindings/arm/msm/cmd-db.txt new file +38 -0
@@ -0,0 +1,38 @@ +Command DB +--------- + +Command DB is a database that provides a mapping between resource key and the +resource address for a system resource managed by a remote processor. The data +is stored in a shared memory region and is loaded by the remote processor. + +Some of the Qualcomm Technologies Inc SoC's have hardware accelerators for +controlling shared resources. Depending on the board configuration the shared +resource properties may change. These properties are dynamically probed by the +remote processor and made available in the shared memory. + +The devicetree representation of the command DB driver should be: + +PROPERTIES: +- compatible: + Usage: required + Value type: <string> + Definition: Should be "qcom,cmd-db" + +- memory-region: + Usage: required + Value type: <phandle> + Definition: The phandle to the reserved memory region. + +Example: + + reserved-memory { + [...] + cmd_db_mem: qcom,cmd-db@c3f000c { + reg = <0x0 0xc3f000c 0x0 0x8>; + }; + }; + + qcom,cmd-db@c3f000c { + compatible = "qcom,cmd-db"; + memory-region = <&cmd_db_mem>; + };
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH v2 2/2] dt-bindings: introduce Command DB for QCOM SoCs
Quoted 41 lines · Lina Iyer
From: Mahesh Sivasubramanian <[email protected]>
Command DB provides information on shared resources like clocks, regulators etc., probed at boot by the remote subsytem and made available in shared memory.
Signed-off-by Mahesh Sivasubramanian <[email protected]>Signed-off-by Lina Iyer <[email protected]>--- .../devicetree/bindings/arm/msm/cmd-db.txt | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/msm/cmd-db.txtDocumentation/devicetree/bindings/arm/msm/cmd-db.txt new file +21
-0@@ -0,0 +1,38 @@ +Command DB +--------- + +Command DB is a database that provides a mapping between resource key and the +resource address for a system resource managed by a remote processor. The data +is stored in a shared memory region and is loaded by the remote processor. + +Some of the Qualcomm Technologies Inc SoC's have hardware accelerators for +controlling shared resources. Depending on the board configuration the shared +resource properties may change. These properties are dynamically probed by the +remote processor and made available in the shared memory. + +The devicetree representation of the command DB driver should be: + +PROPERTIES: +- compatible: + Usage: required + Value type: <string> + Definition: Should be "qcom,cmd-db" + +- memory-region:
Documentation/devicetree/bindings/arm/msm/cmd-db.txt line 31
Quoted 10 lines
Documentation/devicetree/bindings/arm/msm/cmd-db.txt new file +10
-0+ Usage: required + Value type: <phandle> + Definition: The phandle to the reserved memory region. + +Example: + + reserved-memory { + [...] + cmd_db_mem: qcom,cmd-db@c3f000c { + reg = <0x0 0xc3f000c 0x0 0x8>;
I was hoping that we can describe the actual memory here, as I got the impression that it will also be a chunk of memory carved out from System RAM.
If not it would seem unlikely that there's a 8 byte carveout in the middle of DDR, what else is here?
Documentation/devicetree/bindings/arm/msm/cmd-db.txt line 36
Quoted 5 lines
Documentation/devicetree/bindings/arm/msm/cmd-db.txt new file +5
-0+ }; + }; + + qcom,cmd-db@c3f000c { + compatible = "qcom,cmd-db";
Add "qcom,cmd-db" to "reserved_mem_matches" in drivers/of/platform.c, use of_reserved_mem_lookup(pdev->dev.of_node) to get the reserved_mem and you can just put the compatible directly on the reserved-memory node.
That way you don't need this separate node that doesn't really represent anything.
Documentation/devicetree/bindings/arm/msm/cmd-db.txt line 38
Quoted 2 lines
Documentation/devicetree/bindings/arm/msm/cmd-db.txt new file +2
-0+ memory-region = <&cmd_db_mem>; + };
Regards,
Bjorn
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 2/2] dt-bindings: introduce Command DB for QCOM SoCs
Quoted 49 lines · Bjorn Andersson
Quoted 47 lines · Lina Iyer
From: Mahesh Sivasubramanian <[email protected]>
Command DB provides information on shared resources like clocks, regulators etc., probed at boot by the remote subsytem and made available in shared memory.
Signed-off-by Mahesh Sivasubramanian <[email protected]>Signed-off-by Lina Iyer <[email protected]>--- .../devicetree/bindings/arm/msm/cmd-db.txt | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/msm/cmd-db.txtDocumentation/devicetree/bindings/arm/msm/cmd-db.txt new file +27
-0@@ -0,0 +1,38 @@ +Command DB +--------- + +Command DB is a database that provides a mapping between resource key and the +resource address for a system resource managed by a remote processor. The data +is stored in a shared memory region and is loaded by the remote processor. + +Some of the Qualcomm Technologies Inc SoC's have hardware accelerators for +controlling shared resources. Depending on the board configuration the shared +resource properties may change. These properties are dynamically probed by the +remote processor and made available in the shared memory. + +The devicetree representation of the command DB driver should be: + +PROPERTIES: +- compatible: + Usage: required + Value type: <string> + Definition: Should be "qcom,cmd-db" + +- memory-region: + Usage: required + Value type: <phandle> + Definition: The phandle to the reserved memory region. + +Example: +
Quoted 9 lines
Documentation/devicetree/bindings/arm/msm/cmd-db.txt line 31
Quoted 4 lines
Documentation/devicetree/bindings/arm/msm/cmd-db.txt new file +4
-0+ reserved-memory { + [...] + cmd_db_mem: qcom,cmd-db@c3f000c { + reg = <0x0 0xc3f000c 0x0 0x8>;I was hoping that we can describe the actual memory here, as I got the impression that it will also be a chunk of memory carved out from System RAM.
Yes, it can be described. But, the location should always be read from the address above. Generally, the CMD DB memory would not change, but it is not always guaranteed.
Quoted 14 lines
If not it would seem unlikely that there's a 8 byte carveout in the middle of DDR, what else is here?
Documentation/devicetree/bindings/arm/msm/cmd-db.txt line 36
Quoted 5 lines
Documentation/devicetree/bindings/arm/msm/cmd-db.txt new file +5
-0+ }; + }; + + qcom,cmd-db@c3f000c { + compatible = "qcom,cmd-db";Add "qcom,cmd-db" to "
reserved_mem_matches" indrivers/of/platform.c, useof_reserved_mem_lookup(pdev->dev.of_node)to get thereserved_memand you can just put the compatible directly on the reserved-memory node.
Quoted 3 lines
That way you don't need this separate node that doesn't really represent anything.
Oh okay. I can take care of that.
Thanks,
Lina
Quoted 2 lines
Quoted 2 lines
Documentation/devicetree/bindings/arm/msm/cmd-db.txt new file +2
-0+ memory-region = <&cmd_db_mem>; + };