[PATCH v6 10/11] arm64: dts: qcom: ipq5332: Add nodes to bringup multipd

2023-11-10 Thread Manikanta Mylavarapu
Enable nodes required for multipd remoteproc bring up.

Signed-off-by: Manikanta Mylavarapu 
---
Changes in v6:
- Added user pd remoteproc nodes in RDP442 dts

Changes in v5:
- Rebased on linux-next

Changes in v4:
- Rebased on linux-next

 arch/arm64/boot/dts/qcom/ipq5332-rdp441.dts | 21 
 arch/arm64/boot/dts/qcom/ipq5332-rdp442.dts | 59 +
 arch/arm64/boot/dts/qcom/ipq5332.dtsi   | 59 +
 3 files changed, 139 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/ipq5332-rdp441.dts 
b/arch/arm64/boot/dts/qcom/ipq5332-rdp441.dts
index e89e2e948603..e0e2f9238b47 100644
--- a/arch/arm64/boot/dts/qcom/ipq5332-rdp441.dts
+++ b/arch/arm64/boot/dts/qcom/ipq5332-rdp441.dts
@@ -21,6 +21,27 @@ _i2c1 {
status = "okay";
 };
 
+_wcss {
+   pd-1 {
+   firmware-name = "ath11k/IPQ5332/hw1.0/q6_fw1.mdt";
+   interrupts-extended = <_smp2p_in 8 IRQ_TYPE_NONE>,
+ <_smp2p_in 9 IRQ_TYPE_NONE>,
+ <_smp2p_in 12 IRQ_TYPE_NONE>,
+ <_smp2p_in 11 IRQ_TYPE_NONE>;
+   interrupt-names = "fatal",
+ "ready",
+ "spawn-ack",
+ "stop-ack";
+
+   qcom,smem-states = <_smp2p_out 8>,
+  <_smp2p_out 9>,
+  <_smp2p_out 10>;
+   qcom,smem-state-names = "shutdown",
+   "stop",
+   "spawn";
+   };
+};
+
  {
bus-width = <4>;
max-frequency = <19200>;
diff --git a/arch/arm64/boot/dts/qcom/ipq5332-rdp442.dts 
b/arch/arm64/boot/dts/qcom/ipq5332-rdp442.dts
index efd480a7afdf..9b145c62e18d 100644
--- a/arch/arm64/boot/dts/qcom/ipq5332-rdp442.dts
+++ b/arch/arm64/boot/dts/qcom/ipq5332-rdp442.dts
@@ -35,6 +35,65 @@ flash@0 {
};
 };
 
+_wcss {
+   pd-1 {
+   firmware-name = "ath11k/IPQ5332/hw1.0/q6_fw1.mdt";
+   interrupts-extended = <_smp2p_in 8 IRQ_TYPE_NONE>,
+ <_smp2p_in 9 IRQ_TYPE_NONE>,
+ <_smp2p_in 12 IRQ_TYPE_NONE>,
+ <_smp2p_in 11 IRQ_TYPE_NONE>;
+   interrupt-names = "fatal",
+ "ready",
+ "spawn-ack",
+ "stop-ack";
+
+   qcom,smem-states = <_smp2p_out 8>,
+  <_smp2p_out 9>,
+  <_smp2p_out 10>;
+   qcom,smem-state-names = "shutdown",
+   "stop",
+   "spawn";
+   };
+
+   pd-2 {
+   firmware-name = "ath11k/IPQ5332/hw1.0/q6_fw2.mdt";
+   interrupts-extended = <_smp2p_in 16 IRQ_TYPE_NONE>,
+ <_smp2p_in 17 IRQ_TYPE_NONE>,
+ <_smp2p_in 20 IRQ_TYPE_NONE>,
+ <_smp2p_in 19 IRQ_TYPE_NONE>;
+   interrupt-names = "fatal",
+ "ready",
+ "spawn-ack",
+ "stop-ack";
+
+   qcom,smem-states = <_smp2p_out 16>,
+  <_smp2p_out 17>,
+  <_smp2p_out 18>;
+   qcom,smem-state-names = "shutdown",
+   "stop",
+   "spawn";
+   };
+
+   pd-3 {
+   firmware-name = "ath11k/IPQ5332/hw1.0/q6_fw3.mdt";
+   interrupts-extended = <_smp2p_in 24 IRQ_TYPE_NONE>,
+ <_smp2p_in 25 IRQ_TYPE_NONE>,
+ <_smp2p_in 28 IRQ_TYPE_NONE>,
+ <_smp2p_in 27 IRQ_TYPE_NONE>;
+   interrupt-names = "fatal",
+ "ready",
+ "spawn-ack",
+ "stop-ack";
+
+   qcom,smem-states = <_smp2p_out 24>,
+  <_smp2p_out 25>,
+  <_smp2p_out 26>;
+   qcom,smem-state-names = "shutdown

[PATCH v6 01/11] dt-bindings: remoteproc: qcom: Add support for multipd model

2023-11-10 Thread Manikanta Mylavarapu
Add new binding document for multipd model remoteproc.
IPQ5332, IPQ9574 follows multipd model.

Signed-off-by: Manikanta Mylavarapu 
Reviewed-by: Krzysztof Kozlowski 
---
Changes in v6:
- No changes.

Changes in v5:
- No changes.

Changes in v4:
- No changes.

Changes in v3:
- Pick up R-b tag

Changes in v2:
- Fixed all comments and rebased on linux-next.
- Changed to BSD-3-Clause
- Added firmware-name.

 .../bindings/remoteproc/qcom,multipd-pil.yaml | 189 ++
 1 file changed, 189 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/remoteproc/qcom,multipd-pil.yaml

diff --git a/Documentation/devicetree/bindings/remoteproc/qcom,multipd-pil.yaml 
b/Documentation/devicetree/bindings/remoteproc/qcom,multipd-pil.yaml
new file mode 100644
index ..c52ac1640d7a
--- /dev/null
+++ b/Documentation/devicetree/bindings/remoteproc/qcom,multipd-pil.yaml
@@ -0,0 +1,189 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/remoteproc/qcom,multipd-pil.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Qualcomm Multipd Secure Peripheral Image Loader
+
+maintainers:
+  - Manikanta Mylavarapu 
+
+description:
+  Multipd Peripheral Image Loader loads firmware and boots Q6 protection 
domain,
+  WCSS protection domain remoteproc's on the Qualcomm IPQ9574, IPQ5332 SoC.
+  Protection domain is similar to process in Linux. Here QDSP6 processor runs
+  each wifi radio functionality on a separate process. One process can't access
+  other process resources, so this is termed as PD i.e protection domain.
+
+properties:
+  compatible:
+enum:
+  - qcom,ipq5332-q6-mpd
+  - qcom,ipq9574-q6-mpd
+
+  reg:
+maxItems: 1
+
+  firmware-name:
+maxItems: 2
+
+  interrupts:
+items:
+  - description: Watchdog interrupt
+  - description: Fatal interrupt
+  - description: Ready interrupt
+  - description: Handover interrupt
+  - description: Stop acknowledge interrupt
+
+  interrupt-names:
+items:
+  - const: wdog
+  - const: fatal
+  - const: ready
+  - const: handover
+  - const: stop-ack
+
+  qcom,smem-states:
+$ref: /schemas/types.yaml#/definitions/phandle-array
+description: States used by the AP to signal the remote processor
+items:
+  - description: Shutdown Q6
+  - description: Stop Q6
+
+  qcom,smem-state-names:
+description:
+  Names of the states used by the AP to signal the remote processor
+items:
+  - const: shutdown
+  - const: stop
+
+  memory-region:
+items:
+  - description: Q6 reserved region
+
+  glink-edge:
+$ref: /schemas/remoteproc/qcom,glink-edge.yaml#
+description:
+  Qualcomm G-Link subnode which represents communication edge, channels
+  and devices related to the Modem.
+unevaluatedProperties: false
+
+patternProperties:
+  "^pd-1|pd-2|pd-3":
+type: object
+description:
+  WCSS means 'wireless connectivity sub system', in simple words it's a
+  wifi radio block. In multipd model, Q6 root protection domain will
+  provide services to WCSS user protection domain. In other words WCSS
+  protection domains depends on Q6 protection domain i.e  Q6 should be up
+  before WCSS, similarly Q6 should shut down after all WCSS domains are
+  down. It can be achieved by building parent-child topology between Q6
+  and WCSS domain's i.e keeping wcss node as sub node of Q6 device node.
+
+properties:
+  firmware-name:
+maxItems: 1
+
+  interrupts:
+items:
+  - description: Fatal interrupt
+  - description: Ready interrupt
+  - description: Spawn acknowledge interrupt
+  - description: Stop acknowledge interrupt
+
+  interrupt-names:
+items:
+  - const: fatal
+  - const: ready
+  - const: spawn-ack
+  - const: stop-ack
+
+  qcom,smem-states:
+$ref: /schemas/types.yaml#/definitions/phandle-array
+description: States used by the AP to signal the remote processor
+items:
+  - description: Shutdown WCSS pd
+  - description: Stop WCSS pd
+  - description: Spawn WCSS pd
+
+  qcom,smem-state-names:
+description:
+  Names of the states used by the AP to signal the remote processor
+items:
+  - const: shutdown
+  - const: stop
+  - const: spawn
+
+required:
+  - firmware-name
+  - interrupts
+  - interrupt-names
+  - qcom,smem-states
+  - qcom,smem-state-names
+
+additionalProperties: false
+
+required:
+  - compatible
+  - firmware-name
+  - reg
+  - interrupts
+  - interrupt-names
+  - qcom,smem-states
+  - qcom,smem-state-names
+  - memory-region
+
+additionalProperties: false
+
+examples:
+  - |
+#include 
+q6v5_wcss: remoteproc@d10 {
+  

[PATCH v6 04/11] dt-bindings: clock: qcom: gcc-ipq5332: remove q6 bring up clock macros

2023-11-10 Thread Manikanta Mylavarapu
In multipd model Q6 firmware takes care of bringup clocks,
so remove them.

Signed-off-by: Manikanta Mylavarapu 
Reviewed-by: Krzysztof Kozlowski 
---
Changes in v6:
- No changes.

Changes in v5:
- No changes.

Changes in v4:
- Pick up R-b tag

Changes in v3:
- Rebased on linux-next

 include/dt-bindings/clock/qcom,ipq5332-gcc.h | 20 
 1 file changed, 20 deletions(-)

diff --git a/include/dt-bindings/clock/qcom,ipq5332-gcc.h 
b/include/dt-bindings/clock/qcom,ipq5332-gcc.h
index 8a405a0a96d0..da9b507c30bf 100644
--- a/include/dt-bindings/clock/qcom,ipq5332-gcc.h
+++ b/include/dt-bindings/clock/qcom,ipq5332-gcc.h
@@ -96,15 +96,7 @@
 #define GCC_PCNOC_BFDCD_CLK_SRC87
 #define GCC_PCNOC_LPASS_CLK88
 #define GCC_PRNG_AHB_CLK   89
-#define GCC_Q6_AHB_CLK 90
-#define GCC_Q6_AHB_S_CLK   91
-#define GCC_Q6_AXIM_CLK92
 #define GCC_Q6_AXIM_CLK_SRC93
-#define GCC_Q6_AXIS_CLK94
-#define GCC_Q6_TSCTR_1TO2_CLK  95
-#define GCC_Q6SS_ATBM_CLK  96
-#define GCC_Q6SS_PCLKDBG_CLK   97
-#define GCC_Q6SS_TRIG_CLK  98
 #define GCC_QDSS_AT_CLK99
 #define GCC_QDSS_AT_CLK_SRC100
 #define GCC_QDSS_CFG_AHB_CLK   101
@@ -134,7 +126,6 @@
 #define GCC_SNOC_PCIE3_2LANE_S_CLK 125
 #define GCC_SNOC_USB_CLK   126
 #define GCC_SYS_NOC_AT_CLK 127
-#define GCC_SYS_NOC_WCSS_AHB_CLK   128
 #define GCC_SYSTEM_NOC_BFDCD_CLK_SRC   129
 #define GCC_UNIPHY0_AHB_CLK130
 #define GCC_UNIPHY0_SYS_CLK131
@@ -155,17 +146,6 @@
 #define GCC_USB0_PIPE_CLK  146
 #define GCC_USB0_SLEEP_CLK 147
 #define GCC_WCSS_AHB_CLK_SRC   148
-#define GCC_WCSS_AXIM_CLK  149
-#define GCC_WCSS_AXIS_CLK  150
-#define GCC_WCSS_DBG_IFC_APB_BDG_CLK   151
-#define GCC_WCSS_DBG_IFC_APB_CLK   152
-#define GCC_WCSS_DBG_IFC_ATB_BDG_CLK   153
-#define GCC_WCSS_DBG_IFC_ATB_CLK   154
-#define GCC_WCSS_DBG_IFC_NTS_BDG_CLK   155
-#define GCC_WCSS_DBG_IFC_NTS_CLK   156
-#define GCC_WCSS_ECAHB_CLK 157
-#define GCC_WCSS_MST_ASYNC_BDG_CLK 158
-#define GCC_WCSS_SLV_ASYNC_BDG_CLK 159
 #define GCC_XO_CLK 160
 #define GCC_XO_CLK_SRC 161
 #define GCC_XO_DIV4_CLK162
-- 
2.34.1



[PATCH v6 11/11] arm64: dts: qcom: ipq9574: Add nodes to bring up multipd

2023-11-10 Thread Manikanta Mylavarapu
Enable nodes required for multipd remoteproc bring up.

Signed-off-by: Manikanta Mylavarapu 
---
Changes in v6:
- Rebased on linux-next

Changes in v5:
- Rebased on linux-next

Changes in v4:
- Rebased on linux-next

Changes in v3:
- Fixed all comments and rebased on linux-next.
- Removed WCSS userpd nodes from dtsi file,
  because it vary based on no of radio's connected.
 
Changes in v2:
- Corrected syntax like alignmnet and kept nodes in sorted
  order.
- Added 'firmware-name' property.

 arch/arm64/boot/dts/qcom/ipq9574.dtsi | 59 +++
 1 file changed, 59 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/ipq9574.dtsi 
b/arch/arm64/boot/dts/qcom/ipq9574.dtsi
index 5f83ee42a719..96cc5bb2e0be 100644
--- a/arch/arm64/boot/dts/qcom/ipq9574.dtsi
+++ b/arch/arm64/boot/dts/qcom/ipq9574.dtsi
@@ -212,6 +212,11 @@ smem@4aa0 {
hwlocks = <_mutex 3>;
no-map;
};
+
+   q6_region: wcnss@4ab0 {
+   reg = <0x0 0x4ab0 0x0 0x2b0>;
+   no-map;
+   };
};
 
soc: soc@0 {
@@ -741,6 +746,36 @@ frame@b128000 {
status = "disabled";
};
};
+
+   q6v5_wcss: remoteproc@cd0 {
+   compatible = "qcom,ipq9574-q6-mpd";
+   reg = <0x0cd0 0x4040>;
+   firmware-name = "ath11k/IPQ9574/hw1.0/q6_fw.mdt",
+   "ath11k/IPQ9574/hw1.0/m3_fw.mdt";
+   interrupts-extended = < GIC_SPI 325 
IRQ_TYPE_EDGE_RISING>,
+ <_smp2p_in 0 IRQ_TYPE_NONE>,
+ <_smp2p_in 1 IRQ_TYPE_NONE>,
+ <_smp2p_in 2 IRQ_TYPE_NONE>,
+ <_smp2p_in 3 IRQ_TYPE_NONE>;
+   interrupt-names = "wdog",
+ "fatal",
+ "ready",
+ "handover",
+ "stop-ack";
+
+   qcom,smem-states = <_smp2p_out 0>,
+  <_smp2p_out 1>;
+   qcom,smem-state-names = "shutdown",
+   "stop";
+   memory-region = <_region>;
+
+   glink-edge {
+   interrupts = ;
+   label = "rtr";
+   qcom,remote-pid = <1>;
+   mboxes = <_glb 8>;
+   };
+   };
};
 
thermal-zones {
@@ -998,4 +1033,28 @@ timer {
 ,
 ;
};
+
+   wcss: wcss-smp2p {
+   compatible = "qcom,smp2p";
+   qcom,smem = <435>, <428>;
+
+   interrupt-parent = <>;
+   interrupts = ;
+
+   mboxes = <_glb 9>;
+
+   qcom,local-pid = <0>;
+   qcom,remote-pid = <1>;
+
+   wcss_smp2p_out: master-kernel {
+   qcom,entry-name = "master-kernel";
+   #qcom,smem-state-cells = <1>;
+   };
+
+   wcss_smp2p_in: slave-kernel {
+   qcom,entry-name = "slave-kernel";
+   interrupt-controller;
+   #interrupt-cells = <2>;
+   };
+   };
 };
-- 
2.34.1



[PATCH v6 05/11] dt-bindings: clock: qcom: gcc-ipq9574: remove q6 bring up clock macros

2023-11-10 Thread Manikanta Mylavarapu
In multipd model Q6 firmware takes care of bringup clocks,
so remove them.

Signed-off-by: Manikanta Mylavarapu 
Reviewed-by: Krzysztof Kozlowski 
---
Changes in v6:
- No changes

Changes in v5:
- No changes

Changes in v4:
- Pick up R-b tag

Changes in v3:
- Rebased on linux-next

 include/dt-bindings/clock/qcom,ipq9574-gcc.h | 18 --
 1 file changed, 18 deletions(-)

diff --git a/include/dt-bindings/clock/qcom,ipq9574-gcc.h 
b/include/dt-bindings/clock/qcom,ipq9574-gcc.h
index 08fd3a37acaa..9217b90f6847 100644
--- a/include/dt-bindings/clock/qcom,ipq9574-gcc.h
+++ b/include/dt-bindings/clock/qcom,ipq9574-gcc.h
@@ -132,16 +132,8 @@
 #define GCC_NSSNOC_SNOC_1_CLK  123
 #define GCC_QDSS_ETR_USB_CLK   124
 #define WCSS_AHB_CLK_SRC   125
-#define GCC_Q6_AHB_CLK 126
-#define GCC_Q6_AHB_S_CLK   127
-#define GCC_WCSS_ECAHB_CLK 128
-#define GCC_WCSS_ACMT_CLK  129
-#define GCC_SYS_NOC_WCSS_AHB_CLK   130
 #define WCSS_AXI_M_CLK_SRC 131
-#define GCC_ANOC_WCSS_AXI_M_CLK132
 #define QDSS_AT_CLK_SRC133
-#define GCC_Q6SS_ATBM_CLK  134
-#define GCC_WCSS_DBG_IFC_ATB_CLK   135
 #define GCC_NSSNOC_ATB_CLK 136
 #define GCC_QDSS_AT_CLK137
 #define GCC_SYS_NOC_AT_CLK 138
@@ -154,27 +146,18 @@
 #define QDSS_TRACECLKIN_CLK_SRC145
 #define GCC_QDSS_TRACECLKIN_CLK146
 #define QDSS_TSCTR_CLK_SRC 147
-#define GCC_Q6_TSCTR_1TO2_CLK  148
-#define GCC_WCSS_DBG_IFC_NTS_CLK   149
 #define GCC_QDSS_TSCTR_DIV2_CLK150
 #define GCC_QDSS_TS_CLK151
 #define GCC_QDSS_TSCTR_DIV4_CLK152
 #define GCC_NSS_TS_CLK 153
 #define GCC_QDSS_TSCTR_DIV8_CLK154
 #define GCC_QDSS_TSCTR_DIV16_CLK   155
-#define GCC_Q6SS_PCLKDBG_CLK   156
-#define GCC_Q6SS_TRIG_CLK  157
-#define GCC_WCSS_DBG_IFC_APB_CLK   158
-#define GCC_WCSS_DBG_IFC_DAPBUS_CLK159
 #define GCC_QDSS_DAP_CLK   160
 #define GCC_QDSS_APB2JTAG_CLK  161
 #define GCC_QDSS_TSCTR_DIV3_CLK162
 #define QPIC_IO_MACRO_CLK_SRC  163
 #define GCC_QPIC_IO_MACRO_CLK   164
 #define Q6_AXI_CLK_SRC 165
-#define GCC_Q6_AXIM_CLK166
-#define GCC_WCSS_Q6_TBU_CLK167
-#define GCC_MEM_NOC_Q6_AXI_CLK 168
 #define Q6_AXIM2_CLK_SRC   169
 #define NSSNOC_MEMNOC_BFDCD_CLK_SRC170
 #define GCC_NSSNOC_MEMNOC_CLK  171
@@ -199,7 +182,6 @@
 #define GCC_UNIPHY2_SYS_CLK190
 #define GCC_CMN_12GPLL_SYS_CLK 191
 #define GCC_NSSNOC_XO_DCD_CLK  192
-#define GCC_Q6SS_BOOT_CLK  193
 #define UNIPHY_SYS_CLK_SRC 194
 #define NSS_TS_CLK_SRC 195
 #define GCC_ANOC_PCIE0_1LANE_M_CLK 196
-- 
2.34.1



[PATCH v6 00/11] Add multipd remoteproc support

2023-11-10 Thread Manikanta Mylavarapu
APSS brings Q6 out of reset and then Q6 brings
WCSS block (wifi radio's) out of reset.

   ---
  -->  |WiFi 2G radio|
  |--
  |
---   |
| APSS | --->   |QDSP6|  -|
-   ---   |
  |
  |
  |   --
  --> |WiFi 5G radio|
  --

Problem here is if any radio crashes, subsequently other
radio also should crash because Q6 crashed. Let's say
2G radio crashed, Q6 should pass this info to APSS. Only
Q6 processor interrupts registered with APSS. Obviously
Q6 should crash and raise fatal interrupt to APSS. Due
to this 5G radio also crashed. But no issue in 5G radio,
because of 2G radio crash 5G radio also impacted.

In multi pd model, this problem is resolved. Here WCSS
functionality (WiFi radio's) moved out from Q6 root pd
to a separate user pd. Due to this, radio's independently
pass their status info to APPS with out crashing Q6. So
other radio's won't be impacted.

Pd means protection domain. It's similar to process in Linux.
Here QDSP6 processor runs each wifi radio functionality on a
separate process. One process can't access other process
resources, so this is termed as PD i.e protection domain.

 APPS   QDSP6
---  -
| |  Crash notification  |  |   --
| |<-|--|---|WiFi|
| |  |  ||->|2G radio|
| |  |  --- ||  --
| |  |  | | ||
|Root |  Start/stop  Q6  |  |  R  | ||
|PD   |<-|->| | ||
|rproc|  Crash notification  |  |  O  | ||
| |  |  | | ||
|User |Start/stop UserPD1(2G)|  |  O  | ||
|PD1  |--|->| |-||
|rproc|  |  |  T  | ||
| |  |  | | ||
|User |Start/stop UserPD2(5G)|  |  P  | ||
|PD2  |--|->| |-||
|rproc|  |  |  D  | ||
| |  |  --- ||  ---
| | Crash notification   |  ||->|WiFi |
| |<-|--|---|5G radio |
---  |  |   ---
 

According to linux terminology, here consider Q6 as root
i.e it provide all services, WCSS (wifi radio's) as user
i.e it uses services provided by root.

Since Q6 root & WCSS user pd's able to communicate with
APSS individually, multipd remoteproc driver registers
each PD with rproc framework. Here clients (Wifi host drivers)
intrested on WCSS PD rproc, so multipd driver start's root
pd in the context of WCSS user pd rproc start. Similarly
on down path, root pd will be stopped after wcss user pd
stopped.

Here WCSS(user) PD is dependent on Q6(root) PD, so first
q6 pd should be up before wcss pd. After wcss pd goes down,
q6 pd should be turned off.

IPQ5332, IPQ9574 supports multipd remoteproc driver.

[V6]:
- Added user pd remoteproc nodes in RDP442 dts
- Removed extern keyword from msa lock/unlock
  function prototype

[V5]:
- Fixed all comments and rebased on linux-next.
- Exported symbols to resolve errors reported here
https://lore.kernel.org/oe-kbuild-all/202307301307.lgjsxmy8-...@intel.com/

[V4]:
- Fixed all comments and rebased on linux-next.
- All userpd's rproc handles stored in linked list.
- Removed data members from compatible specific data structure.
- In probe itself, traverse for each userpd and call
  'q6_register_userpd()'.

[V3]:
- Fixed all comments and rebased on linux-next.
- IPQ5018 support is dropped because it's base port
  patches not yet merged.
- IPQ5332 support is added with below patches.
  [03/11], [05/11], [06/11], [07/11], [10/11].

[V2]:
- Fixed all comments and rebased on linux-next.
- since clocks handled by QDSP6 firmware
  Added [04/13], [05/13], [06/13], [07/13] patches.

Manikanta Mylavarapu (11):
  dt-bindings: remoteproc: qcom: Add support for multipd model
  clk: qcom: ipq5332: remove q6 bring up clocks
  clk: qcom: ipq9574: remove q6 bring up clocks
  dt-bindings: clock: qcom: gcc-ipq5332: remove q6 bring up clock macros
  dt-bindings: clock: qcom: gcc-ipq9574: remove q6 bring up clock macros
  firmware: qcom_scm: ipq5332: add support to pass metadata size
  firmware: qcom_scm: ipq5332: add msa lock/unlock support
  remoteproc: qcom: q6v5: Add multipd interrupts support
  remoteproc: qcom: Add Hexagon ba

[PATCH v6 08/11] remoteproc: qcom: q6v5: Add multipd interrupts support

2023-11-10 Thread Manikanta Mylavarapu
In multipd model, root & user pd remoteproc's interrupts are
different. User pd needs additional interrupts like spawn.
Instead of going with qcom_q6v5_init(), we defined a new
function to register userpd rproc interrupts in mpd driver.
Since userpd rproc uses some of common interrupts like fatal,
ready, static is removed from ISR handler and used in userpd
interrupt registration.

Signed-off-by: Manikanta Mylavarapu 
---
Changes in v6:
- Rebased on linux-next

Changes in v5:
- Exported symbols to resolve errors reported here
https://lore.kernel.org/oe-kbuild-all/202307301307.lgjsxmy8-...@intel.com/

Changes in v4:
- Rebased on linux-next

Changes in v3:
- Rebased on linux-next

 drivers/remoteproc/qcom_q6v5.c | 41 +++---
 drivers/remoteproc/qcom_q6v5.h | 11 +
 2 files changed, 49 insertions(+), 3 deletions(-)

diff --git a/drivers/remoteproc/qcom_q6v5.c b/drivers/remoteproc/qcom_q6v5.c
index 4ee5e67a9f03..0e32f13c196d 100644
--- a/drivers/remoteproc/qcom_q6v5.c
+++ b/drivers/remoteproc/qcom_q6v5.c
@@ -112,7 +112,7 @@ static irqreturn_t q6v5_wdog_interrupt(int irq, void *data)
return IRQ_HANDLED;
 }
 
-static irqreturn_t q6v5_fatal_interrupt(int irq, void *data)
+irqreturn_t q6v5_fatal_interrupt(int irq, void *data)
 {
struct qcom_q6v5 *q6v5 = data;
size_t len;
@@ -132,8 +132,9 @@ static irqreturn_t q6v5_fatal_interrupt(int irq, void *data)
 
return IRQ_HANDLED;
 }
+EXPORT_SYMBOL_GPL(q6v5_fatal_interrupt);
 
-static irqreturn_t q6v5_ready_interrupt(int irq, void *data)
+irqreturn_t q6v5_ready_interrupt(int irq, void *data)
 {
struct qcom_q6v5 *q6v5 = data;
 
@@ -141,6 +142,7 @@ static irqreturn_t q6v5_ready_interrupt(int irq, void *data)
 
return IRQ_HANDLED;
 }
+EXPORT_SYMBOL_GPL(q6v5_ready_interrupt);
 
 /**
  * qcom_q6v5_wait_for_start() - wait for remote processor start signal
@@ -177,7 +179,17 @@ static irqreturn_t q6v5_handover_interrupt(int irq, void 
*data)
return IRQ_HANDLED;
 }
 
-static irqreturn_t q6v5_stop_interrupt(int irq, void *data)
+irqreturn_t q6v5_spawn_interrupt(int irq, void *data)
+{
+   struct qcom_q6v5 *q6v5 = data;
+
+   complete(>spawn_done);
+
+   return IRQ_HANDLED;
+}
+EXPORT_SYMBOL_GPL(q6v5_spawn_interrupt);
+
+irqreturn_t q6v5_stop_interrupt(int irq, void *data)
 {
struct qcom_q6v5 *q6v5 = data;
 
@@ -185,6 +197,7 @@ static irqreturn_t q6v5_stop_interrupt(int irq, void *data)
 
return IRQ_HANDLED;
 }
+EXPORT_SYMBOL_GPL(q6v5_stop_interrupt);
 
 /**
  * qcom_q6v5_request_stop() - request the remote processor to stop
@@ -214,6 +227,28 @@ int qcom_q6v5_request_stop(struct qcom_q6v5 *q6v5, struct 
qcom_sysmon *sysmon)
 }
 EXPORT_SYMBOL_GPL(qcom_q6v5_request_stop);
 
+/**
+ * qcom_q6v5_request_spawn() - request the remote processor to spawn
+ * @q6v5:  reference to qcom_q6v5 context
+ *
+ * Return: 0 on success, negative errno on failure
+ */
+int qcom_q6v5_request_spawn(struct qcom_q6v5 *q6v5)
+{
+   int ret;
+
+   ret = qcom_smem_state_update_bits(q6v5->spawn_state,
+ BIT(q6v5->spawn_bit), 
BIT(q6v5->spawn_bit));
+
+   ret = wait_for_completion_timeout(>spawn_done, 5 * HZ);
+
+   qcom_smem_state_update_bits(q6v5->spawn_state,
+   BIT(q6v5->spawn_bit), 0);
+
+   return ret == 0 ? -ETIMEDOUT : 0;
+}
+EXPORT_SYMBOL_GPL(qcom_q6v5_request_spawn);
+
 /**
  * qcom_q6v5_panic() - panic handler to invoke a stop on the remote
  * @q6v5:  reference to qcom_q6v5 context
diff --git a/drivers/remoteproc/qcom_q6v5.h b/drivers/remoteproc/qcom_q6v5.h
index 5a859c41896e..4e1bb1a68284 100644
--- a/drivers/remoteproc/qcom_q6v5.h
+++ b/drivers/remoteproc/qcom_q6v5.h
@@ -18,21 +18,27 @@ struct qcom_q6v5 {
 
struct qcom_smem_state *state;
struct qmp *qmp;
+   struct qcom_smem_state *shutdown_state;
+   struct qcom_smem_state *spawn_state;
 
struct icc_path *path;
 
unsigned stop_bit;
+   unsigned shutdown_bit;
+   unsigned spawn_bit;
 
int wdog_irq;
int fatal_irq;
int ready_irq;
int handover_irq;
int stop_irq;
+   int spawn_irq;
 
bool handover_issued;
 
struct completion start_done;
struct completion stop_done;
+   struct completion spawn_done;
 
int crash_reason;
 
@@ -50,7 +56,12 @@ void qcom_q6v5_deinit(struct qcom_q6v5 *q6v5);
 int qcom_q6v5_prepare(struct qcom_q6v5 *q6v5);
 int qcom_q6v5_unprepare(struct qcom_q6v5 *q6v5);
 int qcom_q6v5_request_stop(struct qcom_q6v5 *q6v5, struct qcom_sysmon *sysmon);
+int qcom_q6v5_request_spawn(struct qcom_q6v5 *q6v5);
 int qcom_q6v5_wait_for_start(struct qcom_q6v5 *q6v5, int timeout);
 unsigned long qcom_q6v5_panic(struct qcom_q6v5 *q6v5);
+irqreturn_t q6v5_fatal_interrupt(int irq, void *data);
+irqreturn_t q6v5_ready_interrupt(int irq, void *data);
+irqretu

[PATCH v6 03/11] clk: qcom: ipq9574: remove q6 bring up clocks

2023-11-10 Thread Manikanta Mylavarapu
In multipd model Q6 firmware takes care of bringup clocks,
so remove them from gcc driver.

Signed-off-by: Manikanta Mylavarapu 
---
Changes in v6:
- Rebased on linux-next.

Changes in v5:
- Rebased on linux-next.

Changes in v4:
- In V3 series this patch is [04/11]. Here it's moved to [03/11]
  because to compile dt-bindings patches.

Changes in v3:
- Rebased on linux-next.

 drivers/clk/qcom/gcc-ipq9574.c | 326 -
 1 file changed, 326 deletions(-)

diff --git a/drivers/clk/qcom/gcc-ipq9574.c b/drivers/clk/qcom/gcc-ipq9574.c
index e8190108e1ae..e6d8ab5fbf29 100644
--- a/drivers/clk/qcom/gcc-ipq9574.c
+++ b/drivers/clk/qcom/gcc-ipq9574.c
@@ -2567,24 +2567,6 @@ static struct clk_rcg2 system_noc_bfdcd_clk_src = {
},
 };
 
-static struct clk_branch gcc_q6ss_boot_clk = {
-   .halt_reg = 0x25080,
-   .halt_check = BRANCH_HALT_SKIP,
-   .clkr = {
-   .enable_reg = 0x25080,
-   .enable_mask = BIT(0),
-   .hw.init = &(const struct clk_init_data) {
-   .name = "gcc_q6ss_boot_clk",
-   .parent_hws = (const struct clk_hw *[]) {
-   _noc_bfdcd_clk_src.clkr.hw
-   },
-   .num_parents = 1,
-   .flags = CLK_SET_RATE_PARENT,
-   .ops = _branch2_ops,
-   },
-   },
-};
-
 static struct clk_branch gcc_nssnoc_snoc_clk = {
.halt_reg = 0x17028,
.clkr = {
@@ -2655,91 +2637,6 @@ static struct clk_rcg2 wcss_ahb_clk_src = {
},
 };
 
-static struct clk_branch gcc_q6_ahb_clk = {
-   .halt_reg = 0x25014,
-   .clkr = {
-   .enable_reg = 0x25014,
-   .enable_mask = BIT(0),
-   .hw.init = &(const struct clk_init_data) {
-   .name = "gcc_q6_ahb_clk",
-   .parent_hws = (const struct clk_hw *[]) {
-   _ahb_clk_src.clkr.hw
-   },
-   .num_parents = 1,
-   .flags = CLK_SET_RATE_PARENT,
-   .ops = _branch2_ops,
-   },
-   },
-};
-
-static struct clk_branch gcc_q6_ahb_s_clk = {
-   .halt_reg = 0x25018,
-   .clkr = {
-   .enable_reg = 0x25018,
-   .enable_mask = BIT(0),
-   .hw.init = &(const struct clk_init_data) {
-   .name = "gcc_q6_ahb_s_clk",
-   .parent_hws = (const struct clk_hw *[]) {
-   _ahb_clk_src.clkr.hw
-   },
-   .num_parents = 1,
-   .flags = CLK_SET_RATE_PARENT,
-   .ops = _branch2_ops,
-   },
-   },
-};
-
-static struct clk_branch gcc_wcss_ecahb_clk = {
-   .halt_reg = 0x25058,
-   .clkr = {
-   .enable_reg = 0x25058,
-   .enable_mask = BIT(0),
-   .hw.init = &(const struct clk_init_data) {
-   .name = "gcc_wcss_ecahb_clk",
-   .parent_hws = (const struct clk_hw *[]) {
-   _ahb_clk_src.clkr.hw
-   },
-   .num_parents = 1,
-   .flags = CLK_SET_RATE_PARENT,
-   .ops = _branch2_ops,
-   },
-   },
-};
-
-static struct clk_branch gcc_wcss_acmt_clk = {
-   .halt_reg = 0x2505c,
-   .clkr = {
-   .enable_reg = 0x2505c,
-   .enable_mask = BIT(0),
-   .hw.init = &(const struct clk_init_data) {
-   .name = "gcc_wcss_acmt_clk",
-   .parent_hws = (const struct clk_hw *[]) {
-   _ahb_clk_src.clkr.hw
-   },
-   .num_parents = 1,
-   .flags = CLK_SET_RATE_PARENT,
-   .ops = _branch2_ops,
-   },
-   },
-};
-
-static struct clk_branch gcc_sys_noc_wcss_ahb_clk = {
-   .halt_reg = 0x2e030,
-   .clkr = {
-   .enable_reg = 0x2e030,
-   .enable_mask = BIT(0),
-   .hw.init = &(const struct clk_init_data) {
-   .name = "gcc_sys_noc_wcss_ahb_clk",
-   .parent_hws = (const struct clk_hw *[]) {
-   _ahb_clk_src.clkr.hw
-   },
-   .num_parents = 1,
-   .flags = CLK_SET_RATE_PARENT,
-   .ops = _branch2_ops,
-   },
-   },
-};
-
 static const struct freq_tbl ftbl_wcss_axi_m_clk_src[] = {
F(2400, P_XO, 1, 0, 0),
F(1, P_GPLL0, 6, 0, 0),
@@ -2760,23 +2657,6 @@ static struct clk_rcg2 wcss_axi_m_clk_src = {
},
 };

[PATCH v6 07/11] firmware: qcom_scm: ipq5332: add msa lock/unlock support

2023-11-10 Thread Manikanta Mylavarapu
IPQ5332 user pd remoteproc firmwares need to be locked
with MSA(modem secure access) features. This patch add
support to lock/unlock MSA features.

Signed-off-by: Manikanta Mylavarapu 
---
Changes in v6:
- Removed extern keyword from msa lock/unlock
  function prototype.

Changes in v5:
- Moved to EXPORT_SYMBOL_GPL() because scm driver moved to
  using EXPORT_SYMBOL_GPL() now.

Changes in v4:
- Rebased on linux-next

 drivers/firmware/qcom/qcom_scm.c   | 78 ++
 drivers/firmware/qcom/qcom_scm.h   |  2 +
 include/linux/firmware/qcom/qcom_scm.h |  2 +
 3 files changed, 82 insertions(+)

diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c
index 865f07c020a7..965164e3506b 100644
--- a/drivers/firmware/qcom/qcom_scm.c
+++ b/drivers/firmware/qcom/qcom_scm.c
@@ -754,6 +754,84 @@ bool qcom_scm_pas_supported(u32 peripheral)
 }
 EXPORT_SYMBOL_GPL(qcom_scm_pas_supported);
 
+/**
+ * qcom_scm_msa_lock() - Lock given peripheral firmware region as MSA
+ *
+ * @peripheral:peripheral id
+ *
+ * Return 0 on success.
+ */
+int qcom_scm_msa_lock(u32 peripheral)
+{
+   int ret;
+   struct qcom_scm_desc desc = {
+   .svc = QCOM_SCM_SVC_PIL,
+   .cmd = QCOM_SCM_MSA_LOCK,
+   .arginfo = QCOM_SCM_ARGS(1),
+   .args[0] = peripheral,
+   .owner = ARM_SMCCC_OWNER_SIP,
+   };
+   struct qcom_scm_res res;
+
+   if (!__qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_PIL,
+ QCOM_SCM_MSA_LOCK))
+   return 0;
+
+   ret = qcom_scm_clk_enable();
+   if (ret)
+   return ret;
+
+   ret = qcom_scm_bw_enable();
+   if (ret)
+   return ret;
+
+   ret = qcom_scm_call(__scm->dev, , );
+   qcom_scm_bw_disable();
+   qcom_scm_clk_disable();
+
+   return ret ? : res.result[0];
+}
+EXPORT_SYMBOL_GPL(qcom_scm_msa_lock);
+
+/**
+ * qcom_scm_msa_unlock() - Unlock given peripheral MSA firmware region
+ *
+ * @peripheral:peripheral id
+ *
+ * Return 0 on success.
+ */
+int qcom_scm_msa_unlock(u32 peripheral)
+{
+   int ret;
+   struct qcom_scm_desc desc = {
+   .svc = QCOM_SCM_SVC_PIL,
+   .cmd = QCOM_SCM_MSA_UNLOCK,
+   .arginfo = QCOM_SCM_ARGS(1),
+   .args[0] = peripheral,
+   .owner = ARM_SMCCC_OWNER_SIP,
+   };
+   struct qcom_scm_res res;
+
+   if (!__qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_PIL,
+ QCOM_SCM_MSA_UNLOCK))
+   return 0;
+
+   ret = qcom_scm_clk_enable();
+   if (ret)
+   return ret;
+
+   ret = qcom_scm_bw_enable();
+   if (ret)
+   return ret;
+
+   ret = qcom_scm_call(__scm->dev, , );
+   qcom_scm_bw_disable();
+   qcom_scm_clk_disable();
+
+   return ret ? : res.result[0];
+}
+EXPORT_SYMBOL_GPL(qcom_scm_msa_unlock);
+
 static int __qcom_scm_pas_mss_reset(struct device *dev, bool reset)
 {
struct qcom_scm_desc desc = {
diff --git a/drivers/firmware/qcom/qcom_scm.h b/drivers/firmware/qcom/qcom_scm.h
index 4342d795940b..3b8fd08e8033 100644
--- a/drivers/firmware/qcom/qcom_scm.h
+++ b/drivers/firmware/qcom/qcom_scm.h
@@ -99,6 +99,8 @@ int scm_legacy_call(struct device *dev, const struct 
qcom_scm_desc *desc,
 #define QCOM_SCM_PIL_PAS_SHUTDOWN  0x06
 #define QCOM_SCM_PIL_PAS_IS_SUPPORTED  0x07
 #define QCOM_SCM_PIL_PAS_MSS_RESET 0x0a
+#define QCOM_SCM_MSA_LOCK  0x24
+#define QCOM_SCM_MSA_UNLOCK0x25
 
 #define QCOM_SCM_SVC_IO0x05
 #define QCOM_SCM_IO_READ   0x01
diff --git a/include/linux/firmware/qcom/qcom_scm.h 
b/include/linux/firmware/qcom/qcom_scm.h
index ccaf28846054..5526369d9568 100644
--- a/include/linux/firmware/qcom/qcom_scm.h
+++ b/include/linux/firmware/qcom/qcom_scm.h
@@ -79,6 +79,8 @@ int qcom_scm_pas_mem_setup(u32 peripheral, phys_addr_t addr, 
phys_addr_t size);
 int qcom_scm_pas_auth_and_reset(u32 peripheral);
 int qcom_scm_pas_shutdown(u32 peripheral);
 bool qcom_scm_pas_supported(u32 peripheral);
+int qcom_scm_msa_lock(u32 peripheral);
+int qcom_scm_msa_unlock(u32 peripheral);
 
 int qcom_scm_io_readl(phys_addr_t addr, unsigned int *val);
 int qcom_scm_io_writel(phys_addr_t addr, unsigned int val);
-- 
2.34.1



[PATCH v6 09/11] remoteproc: qcom: Add Hexagon based multipd rproc driver

2023-11-10 Thread Manikanta Mylavarapu
It adds support to bring up remoteproc's on multipd model.
Pd means protection domain. It's similar to process in Linux.
Here QDSP6 processor runs each wifi radio functionality on a
separate process. One process can't access other process
resources, so this is termed as PD i.e protection domain.

Here we have two pd's called root and user pd. We can correlate
Root pd as root and user pd as user in linux. Root pd has more
privileges than user pd. Root will provide services to user pd.

>From remoteproc driver perspective, root pd corresponds to QDSP6
processor bring up and user pd corresponds to Wifi radio (WCSS)
bring up.

Here WCSS(user) PD is dependent on Q6(root) PD, so first
q6 pd should be up before wcss pd. After wcss pd goes down,
q6 pd should be turned off.

 APPS   QDSP6
---  -
| |  Crash notification  |  |   --
| |<-|--|---|User|
| |  |  ||->|PD1 |
| |  |  --- ||  --
| |  |  | | ||
|Root |  Start/stop  Q6  |  |  R  | ||
|PD   |<-|->| | ||
|rproc|  Crash notification  |  |  O  | ||
| |  |  | | ||
|User |Start/stop UserPD1|  |  O  | ||
|PD1  |--|->| |-||
|rproc|  |  |  T  | ||
| |  |  | | ||
|User |Start/stop UserPD2|  |  P  | ||
|PD2  |--|->| |-||
|rproc|  |  |  D  | ||
| |  |  --- ||  --
| | Crash notification   |  ||->|User|
| |<-|--|---|PD2 |
---  |  |   --
 

IPQ5332, IPQ9574 supports multipd remoteproc driver.

Signed-off-by: Manikanta Mylavarapu 
---
Changes in v6:
- Rebased on linux-next

Changes in v5:
- Fixed all comments and rebased on linux-next.
- Removed EPROBE_DEFER dance.

Changes in v4:
- Fixed all comments and rebased on linux-next.
- All userpd's rproc handles stored in linked list. Get
  userpd rproc handles whenever required from list instead
  of traversing with 'for_each_available_child_of_node'.
- Removed data members from compatible specific data structure.
  Because these are required for user pd's. Since we removed
  user pd compatible, then no need of this data members.
- In probe itself, traverse for each userpd and call
  'q6_register_userpd()'. In case of failure, call
  'q6_release_resources()' to clear already allocated
  user pd rproc's.

Changes in v3:
- Fixed all comments and rebased on linux-next.
- Removed WCSS userpd compatibles.
- Removed AHB/PCIE terms from driver.
- Removed logic to get ASID from DT node, instead computed
  from UserPD spawn bit no.
- IPQ5018 support is dropped because it's base port patches not
  yet merged so added IPQ5332 support.
- Added msa lock, unlock scm calls for WCSS user pd up/down.
- Added bootinfo support to share userpd load-address & size to
  QDSP6 root pd.

Changes in v2:
- Common functionalities moved to seperate patches
- qcom_get_pd_asid() moved to mpd driver
- Last DMA block alone memset to zero
- Added diagram to show how userpd data is organized and sent to
  trustzone
- Rewritten commit message since most of the content available
  in cover page
- Removed 'remote_id' becuase it's not required for bring up.

 drivers/remoteproc/Kconfig |  19 +
 drivers/remoteproc/Makefile|   1 +
 drivers/remoteproc/qcom_q6v5_mpd.c | 802 +
 3 files changed, 822 insertions(+)
 create mode 100644 drivers/remoteproc/qcom_q6v5_mpd.c

diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
index 48845dc8fa85..f5592e91c1a2 100644
--- a/drivers/remoteproc/Kconfig
+++ b/drivers/remoteproc/Kconfig
@@ -234,6 +234,25 @@ config QCOM_Q6V5_PAS
  CDSP (Compute DSP), MPSS (Modem Peripheral SubSystem), and
  SLPI (Sensor Low Power Island).
 
+config QCOM_Q6V5_MPD
+   tristate "Qualcomm Hexagon based MPD model Peripheral Image Loader"
+   depends on OF && ARCH_QCOM
+   depends on QCOM_SMEM
+   depends on RPMSG_QCOM_SMD || RPMSG_QCOM_SMD=n
+   depends on RPMSG_QCOM_GLINK_SMEM || RPMSG_QCOM_GLINK_SMEM=n
+   depends on QCOM_SYSMON || QCOM_SYSMON=n
+   depends on RPMSG_QCOM_GLINK || RPMSG_QCOM_GLINK=n
+   depends on QCOM_AOSS_QMP || QCOM_AOSS_QMP=n
+   select QCOM_MDT_LOADER
+   select QCOM_PIL_INFO
+   select QCOM_Q6V5_COMMO

[PATCH v6 02/11] clk: qcom: ipq5332: remove q6 bring up clocks

2023-11-10 Thread Manikanta Mylavarapu
In multipd model Q6 firmware takes care of bringup clocks,
so remove them from gcc driver.

Signed-off-by: Manikanta Mylavarapu 
---
Changes in v6:
- Rebased on linux-next.

Changes in v5:
- Rebased on linux-next.

Changes in v4:
- In V3 series this patch is [05/11]. Here it's moved to [02/11]
  because to compile dt-bindings patches.

 drivers/clk/qcom/gcc-ipq5332.c | 380 -
 1 file changed, 380 deletions(-)

diff --git a/drivers/clk/qcom/gcc-ipq5332.c b/drivers/clk/qcom/gcc-ipq5332.c
index f98591148a97..dbaf7aa60520 100644
--- a/drivers/clk/qcom/gcc-ipq5332.c
+++ b/drivers/clk/qcom/gcc-ipq5332.c
@@ -2194,150 +2194,6 @@ static struct clk_branch gcc_prng_ahb_clk = {
},
 };
 
-static struct clk_branch gcc_q6_ahb_clk = {
-   .halt_reg = 0x25014,
-   .halt_check = BRANCH_HALT_VOTED,
-   .clkr = {
-   .enable_reg = 0x25014,
-   .enable_mask = BIT(0),
-   .hw.init = &(const struct clk_init_data) {
-   .name = "gcc_q6_ahb_clk",
-   .parent_hws = (const struct clk_hw*[]) {
-   _wcss_ahb_clk_src.clkr.hw,
-   },
-   .num_parents = 1,
-   .flags = CLK_SET_RATE_PARENT,
-   .ops = _branch2_ops,
-   },
-   },
-};
-
-static struct clk_branch gcc_q6_ahb_s_clk = {
-   .halt_reg = 0x25018,
-   .halt_check = BRANCH_HALT_VOTED,
-   .clkr = {
-   .enable_reg = 0x25018,
-   .enable_mask = BIT(0),
-   .hw.init = &(const struct clk_init_data) {
-   .name = "gcc_q6_ahb_s_clk",
-   .parent_hws = (const struct clk_hw*[]) {
-   _wcss_ahb_clk_src.clkr.hw,
-   },
-   .num_parents = 1,
-   .flags = CLK_SET_RATE_PARENT,
-   .ops = _branch2_ops,
-   },
-   },
-};
-
-static struct clk_branch gcc_q6_axim_clk = {
-   .halt_reg = 0x2500c,
-   .halt_check = BRANCH_HALT_VOTED,
-   .clkr = {
-   .enable_reg = 0x2500c,
-   .enable_mask = BIT(0),
-   .hw.init = &(const struct clk_init_data) {
-   .name = "gcc_q6_axim_clk",
-   .parent_hws = (const struct clk_hw*[]) {
-   _q6_axim_clk_src.clkr.hw,
-   },
-   .num_parents = 1,
-   .flags = CLK_SET_RATE_PARENT,
-   .ops = _branch2_ops,
-   },
-   },
-};
-
-static struct clk_branch gcc_q6_axis_clk = {
-   .halt_reg = 0x25010,
-   .halt_check = BRANCH_HALT_VOTED,
-   .clkr = {
-   .enable_reg = 0x25010,
-   .enable_mask = BIT(0),
-   .hw.init = &(const struct clk_init_data) {
-   .name = "gcc_q6_axis_clk",
-   .parent_hws = (const struct clk_hw*[]) {
-   _system_noc_bfdcd_clk_src.clkr.hw,
-   },
-   .num_parents = 1,
-   .flags = CLK_SET_RATE_PARENT,
-   .ops = _branch2_ops,
-   },
-   },
-};
-
-static struct clk_branch gcc_q6_tsctr_1to2_clk = {
-   .halt_reg = 0x25020,
-   .halt_check = BRANCH_HALT_VOTED,
-   .clkr = {
-   .enable_reg = 0x25020,
-   .enable_mask = BIT(0),
-   .hw.init = &(const struct clk_init_data) {
-   .name = "gcc_q6_tsctr_1to2_clk",
-   .parent_hws = (const struct clk_hw*[]) {
-   _qdss_tsctr_div2_clk_src.hw,
-   },
-   .num_parents = 1,
-   .flags = CLK_SET_RATE_PARENT,
-   .ops = _branch2_ops,
-   },
-   },
-};
-
-static struct clk_branch gcc_q6ss_atbm_clk = {
-   .halt_reg = 0x2501c,
-   .halt_check = BRANCH_HALT_VOTED,
-   .clkr = {
-   .enable_reg = 0x2501c,
-   .enable_mask = BIT(0),
-   .hw.init = &(const struct clk_init_data) {
-   .name = "gcc_q6ss_atbm_clk",
-   .parent_hws = (const struct clk_hw*[]) {
-   _qdss_at_clk_src.clkr.hw,
-   },
-   .num_parents = 1,
-   .flags = CLK_SET_RATE_PARENT,
-   .ops = _branch2_ops,
-   },
-   },
-};
-
-static struct clk_branch gcc_q6ss_pclkdbg_clk = {
-   .halt_reg = 0x25024,
-   .halt_check = BRANCH_HALT_VOTED,
-   .clkr = {
-   .enable_reg = 0x25024,
-   .enable_mask = BIT(0),
-   

[PATCH v6 06/11] firmware: qcom_scm: ipq5332: add support to pass metadata size

2023-11-10 Thread Manikanta Mylavarapu
IPQ5332 security software running under trustzone
requires metadata size. With V2 cmd, pass metadata
size as well.

Signed-off-by: Manikanta Mylavarapu 
---
Changes in v6:
- Rebased on linux-next

Changes in v5:
- Rebased on linux-next

Changes in v4:
- Rebased on linux-next

 drivers/firmware/qcom/qcom_scm.c | 8 
 drivers/firmware/qcom/qcom_scm.h | 1 +
 2 files changed, 9 insertions(+)

diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c
index 520de9b5633a..865f07c020a7 100644
--- a/drivers/firmware/qcom/qcom_scm.c
+++ b/drivers/firmware/qcom/qcom_scm.c
@@ -573,6 +573,14 @@ int qcom_scm_pas_init_image(u32 peripheral, const void 
*metadata, size_t size,
 
desc.args[1] = mdata_phys;
 
+   if (__qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_PIL,
+QCOM_SCM_PAS_INIT_IMAGE_V2)) {
+   desc.cmd = QCOM_SCM_PAS_INIT_IMAGE_V2;
+   desc.arginfo =
+   QCOM_SCM_ARGS(3, QCOM_SCM_VAL, QCOM_SCM_RW, 
QCOM_SCM_VAL);
+   desc.args[2] = size;
+   }
+
ret = qcom_scm_call(__scm->dev, , );
 
qcom_scm_bw_disable();
diff --git a/drivers/firmware/qcom/qcom_scm.h b/drivers/firmware/qcom/qcom_scm.h
index 4532907e8489..4342d795940b 100644
--- a/drivers/firmware/qcom/qcom_scm.h
+++ b/drivers/firmware/qcom/qcom_scm.h
@@ -93,6 +93,7 @@ int scm_legacy_call(struct device *dev, const struct 
qcom_scm_desc *desc,
 
 #define QCOM_SCM_SVC_PIL   0x02
 #define QCOM_SCM_PIL_PAS_INIT_IMAGE0x01
+#define QCOM_SCM_PAS_INIT_IMAGE_V2 0x1a
 #define QCOM_SCM_PIL_PAS_MEM_SETUP 0x02
 #define QCOM_SCM_PIL_PAS_AUTH_AND_RESET0x05
 #define QCOM_SCM_PIL_PAS_SHUTDOWN  0x06
-- 
2.34.1



Re: [PATCH v5 09/11] remoteproc: qcom: Add Hexagon based multipd rproc driver

2023-11-08 Thread Manikanta Mylavarapu




On 8/2/2023 7:36 PM, Manikanta Mylavarapu wrote:

It adds support to bring up remoteproc's on multipd model.
Pd means protection domain. It's similar to process in Linux.
Here QDSP6 processor runs each wifi radio functionality on a
separate process. One process can't access other process
resources, so this is termed as PD i.e protection domain.

Here we have two pd's called root and user pd. We can correlate
Root pd as root and user pd as user in linux. Root pd has more
privileges than user pd. Root will provide services to user pd.

 From remoteproc driver perspective, root pd corresponds to QDSP6
processor bring up and user pd corresponds to Wifi radio (WCSS)
bring up.

Here WCSS(user) PD is dependent on Q6(root) PD, so first
q6 pd should be up before wcss pd. After wcss pd goes down,
q6 pd should be turned off.



Thanks Krzysztof, Kalle, Rob, Bjorn for all your reviews.
I have addressed them in this series.
Can you please suggest and help me to take this forward ?

Thanks & Regards,
Manikanta.