Skip to contentSkip to conversation

Add support for MT8195 SCP 2nd core

PATCH Superseded Tinghan Shen 6 participants 30 messages Sep 27, 2022 – Jan 17, 2023

Subsystems (5)

v3 of 17 Superseded Latest is v17 →

lore
Share & tools
lore
#0 lore raw

v3 cover Add support for MT8195 SCP 2nd core

The mediatek remoteproc driver currently only allows bringing up a single core SCP, e.g. MT8183. It also only bringing up the 1st core in SoCs with a dual-core SCP, e.g. MT8195. This series support to bring-up the 2nd core of the dual-core SCP.

v2 -> v3:
1. change the representation of dual-core SCP in dts file and update SCP yaml
2. rewrite SCP driver to reflect the change of dts node
3. add SCP core 1 node to mt8195.dtsi
4. remove redundant call of rproc_boot for SCP
5. refine IPI error message

v1 -> v2:
1. update dt-binding property description
2. remove kconfig for scp dual driver
3. merge mtk_scp_dual.c and mtk_scp_subdev.c to mtk_scp.c

Tinghan Shen (11):
dt-bindings: remoteproc: mediatek: Give the subnode a persistent name
dt-bindings: remoteproc: mediatek: Support MT8195 dual-core SCP
arm64: dts: mt8195: Add SCP core 1 node
remoteproc: mediatek: Remove redundant rproc_boot
remoteproc: mediatek: Add SCP core 1 register definitions
remoteproc: mediatek: Add MT8195 SCP core 1 operations
remoteproc: mediatek: Probe MT8195 SCP core 1
remoteproc: mediatek: Control SCP core 1 boot by rproc subdevice
remoteproc: mediatek: Setup MT8195 SCP core 1 SRAM offset
remoteproc: mediatek: Handle MT8195 SCP core 1 watchdog timeout
remoteproc: mediatek: Refine ipi handler error message

 .../bindings/remoteproc/mtk,scp.yaml          | 132 ++++++++--
 .../arm64/boot/dts/mediatek/mt8183-kukui.dtsi |   2 +-
 arch/arm64/boot/dts/mediatek/mt8195.dtsi      |  14 +-
 .../mediatek/vcodec/mtk_vcodec_fw_scp.c       |   2 +-
 drivers/remoteproc/mtk_common.h               |  35 +++
 drivers/remoteproc/mtk_scp.c                  | 241 +++++++++++++++++-
 include/linux/remoteproc/mtk_scp.h            |   1 +
 7 files changed, 397 insertions(+), 30 deletions(-)
Signature · 1 line
2.18.0
#1 lore raw

PATCH v3 1/11 dt-bindings: remoteproc: mediatek: Give the subnode a persistent name

The node name doesn't matter to add the subnode as a cros-ec rpmsg device. Give it a clear persistent node name to simplify scp yaml.

---
 .../bindings/remoteproc/mtk,scp.yaml          | 35 ++++++++++---------
 .../arm64/boot/dts/mediatek/mt8183-kukui.dtsi |  2 +-
 2 files changed, 20 insertions(+), 17 deletions(-)
Documentation/devicetree/bindings/remoteproc/mtk,scp.yaml +19 -16
index 7e091eaffc18..786bed897916 100644
@@ -58,6 +58,23 @@ properties:
   memory-region:
     maxItems: 1
 
+  cros-ec-rpmsg:
+    type: object
+    description:
+      This subnode represents the rpmsg device. The names of the devices
+      are not important. The properties of this node are defined by the
+      individual bindings for the rpmsg devices.
+
+    properties:
+      mediatek,rpmsg-name:
+        $ref: /schemas/types.yaml#/definitions/string-array
+        description:
+          Contains the name for the rpmsg device. Used to match
+          the subnode to rpmsg device announced by SCP.
+
+    required:
+      - mediatek,rpmsg-name
+
 required:
   - compatible
   - reg
@@ -89,21 +106,7 @@ allOf:
         reg-names:
           maxItems: 2
 
-additionalProperties:
-  type: object
-  description:
-    Subnodes of the SCP represent rpmsg devices. The names of the devices
-    are not important. The properties of these nodes are defined by the
-    individual bindings for the rpmsg devices.
-  properties:
-    mediatek,rpmsg-name:
-      $ref: /schemas/types.yaml#/definitions/string-array
-      description:
-        Contains the name for the rpmsg device. Used to match
-        the subnode to rpmsg device announced by SCP.
-
-  required:
-    - mediatek,rpmsg-name
+additionalProperties: false
 
 examples:
   - |
@@ -118,7 +121,7 @@ examples:
         clocks = <&infracfg CLK_INFRA_SCPSYS>;
         clock-names = "main";
 
-        cros_ec {
+        cros-ec-rpmsg {
             mediatek,rpmsg-name = "cros-ec-rpmsg";
         };
     };
arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi +1 -1
index b4b86bb1f1a7..693ad5f2a82e 100644
@@ -816,7 +816,7 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&scp_pins>;
 
-	cros_ec {
+	cros-ec-rpmsg {
 		compatible = "google,cros-ec-rpmsg";
 		mediatek,rpmsg-name = "cros-ec-rpmsg";
 	};
Signature · 1 line
2.18.0
#2 lore raw

Re: [PATCH v3 01/11] dt-bindings: remoteproc: mediatek: Give the subnode a persistent name

arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi

Quoted 73 lines · Tinghan Shen

The node name doesn't matter to add the subnode as a cros-ec rpmsg device. Give it a clear persistent node name to simplify scp yaml.

---
  .../bindings/remoteproc/mtk,scp.yaml          | 35 ++++++++++---------
  .../arm64/boot/dts/mediatek/mt8183-kukui.dtsi |  2 +-
  2 files changed, 20 insertions(+), 17 deletions(-)
Documentation/devicetree/bindings/remoteproc/mtk,scp.yaml +19 -16
index 7e091eaffc18..786bed897916 100644
@@ -58,6 +58,23 @@ properties:
    memory-region:
      maxItems: 1
 
+  cros-ec-rpmsg:
+    type: object
+    description:
+      This subnode represents the rpmsg device. The names of the devices
+      are not important. The properties of this node are defined by the
+      individual bindings for the rpmsg devices.
+
+    properties:
+      mediatek,rpmsg-name:
+        $ref: /schemas/types.yaml#/definitions/string-array
+        description:
+          Contains the name for the rpmsg device. Used to match
+          the subnode to rpmsg device announced by SCP.
+
+    required:
+      - mediatek,rpmsg-name
+
  required:
    - compatible
    - reg
@@ -89,21 +106,7 @@ allOf:
          reg-names:
            maxItems: 2
 
-additionalProperties:
-  type: object
-  description:
-    Subnodes of the SCP represent rpmsg devices. The names of the devices
-    are not important. The properties of these nodes are defined by the
-    individual bindings for the rpmsg devices.
-  properties:
-    mediatek,rpmsg-name:
-      $ref: /schemas/types.yaml#/definitions/string-array
-      description:
-        Contains the name for the rpmsg device. Used to match
-        the subnode to rpmsg device announced by SCP.
-
-  required:
-    - mediatek,rpmsg-name
+additionalProperties: false
 
  examples:
    - |
@@ -118,7 +121,7 @@ examples:
          clocks = <&infracfg CLK_INFRA_SCPSYS>;
          clock-names = "main";
 
-        cros_ec {
+        cros-ec-rpmsg {
              mediatek,rpmsg-name = "cros-ec-rpmsg";
          };
      };
arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi +0 -0
index b4b86bb1f1a7..693ad5f2a82e 100644

DTS changes should be in separate patch.

Regards,
Peng.

Quoted 9 lines
arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi +1 -1
@@ -816,7 +816,7 @@
  	pinctrl-names = "default";
  	pinctrl-0 = <&scp_pins>;
 
-	cros_ec {
+	cros-ec-rpmsg {
  		compatible = "google,cros-ec-rpmsg";
  		mediatek,rpmsg-name = "cros-ec-rpmsg";
  	};
#3 lore raw

Re: [PATCH v3 01/11] dt-bindings: remoteproc: mediatek: Give the subnode a persistent name

In reply to Tinghan Shen
Quoted 14 lines · Tinghan Shen

The node name doesn't matter to add the subnode as a cros-ec rpmsg device. Give it a clear persistent node name to simplify scp yaml.

---
 .../bindings/remoteproc/mtk,scp.yaml          | 35 ++++++++++---------
 .../arm64/boot/dts/mediatek/mt8183-kukui.dtsi |  2 +-
 2 files changed, 20 insertions(+), 17 deletions(-)
Documentation/devicetree/bindings/remoteproc/mtk,scp.yaml +0 -0
index 7e091eaffc18..786bed897916 100644

Documentation/devicetree/bindings/remoteproc/mtk,scp.yaml properties: · line 62

Quoted 5 lines
Documentation/devicetree/bindings/remoteproc/mtk,scp.yaml +2 -0
@@ -58,6 +58,23 @@ properties:
   memory-region:
     maxItems: 1
 
+  cros-ec-rpmsg:
+    type: object

additionalProperties: false on this level

Documentation/devicetree/bindings/remoteproc/mtk,scp.yaml properties: · line 64

Quoted 2 lines
Documentation/devicetree/bindings/remoteproc/mtk,scp.yaml +2 -0
+    description:
+      This subnode represents the rpmsg device. The names of the devices

What are the devices? You wrote that it is one device, not devices.

Documentation/devicetree/bindings/remoteproc/mtk,scp.yaml properties: · line 66

Quoted 2 lines
Documentation/devicetree/bindings/remoteproc/mtk,scp.yaml +2 -0
+      are not important. The properties of this node are defined by the
+      individual bindings for the rpmsg devices.

??? No, you need to define the properties of the node, e.g. by a ref.

Documentation/devicetree/bindings/remoteproc/mtk,scp.yaml properties: · line 73

Quoted 7 lines
Documentation/devicetree/bindings/remoteproc/mtk,scp.yaml +7 -0
+
+    properties:
+      mediatek,rpmsg-name:
+        $ref: /schemas/types.yaml#/definitions/string-array
+        description:
+          Contains the name for the rpmsg device. Used to match
+          the subnode to rpmsg device announced by SCP.

maxItems... but is it really a string-array?

Documentation/devicetree/bindings/remoteproc/mtk,scp.yaml allOf: · line 108

Quoted 11 lines
Documentation/devicetree/bindings/remoteproc/mtk,scp.yaml +4 -0
+
+    required:
+      - mediatek,rpmsg-name
+
 required:
   - compatible
   - reg
@@ -89,21 +106,7 @@ allOf:
         reg-names:
           maxItems: 2
 

Best regards,
Krzysztof

#4 lore raw

PATCH v3 2/11 dt-bindings: remoteproc: mediatek: Support MT8195 dual-core SCP

In reply to Tinghan Shen

The MT8195 SCP is a dual-core RISC-V MCU. Extend the yaml file to describe the 2nd core as a subnode of the boot core.

The configuration register is shared by MT8195 SCP core 0 and core 1. The core 1 can retrieve the information of configuration registers from parent node.

---
 .../bindings/remoteproc/mtk,scp.yaml          | 97 ++++++++++++++++++-
 1 file changed, 92 insertions(+), 5 deletions(-)
Documentation/devicetree/bindings/remoteproc/mtk,scp.yaml +92 -5
index 786bed897916..c012265be4eb 100644
@@ -75,6 +75,83 @@ properties:
     required:
       - mediatek,rpmsg-name
 
+  '#address-cells':
+    const: 1
+
+  '#size-cells':
+    const: 1
+
+  ranges: true
+
+patternProperties:
+  "^scp-c[0-9]+@[a-f0-9]+$":
+    type: object
+    description:
+      The MediaTek SCP integrated to SoC might be a multi-core version.
+      The other cores are represented as child nodes of the boot core.
+      There are some integration differences for the IP like the usage of
+      address translator for translating SoC bus addresses into address space
+      for the processor.
+
+      Each SCP core has own cache memory. The SRAM and L1TCM are shared by
+      cores. The power of cache, SRAM and L1TCM power should be enabled
+      before booting SCP cores. The size of cache, SRAM, and L1TCM are varied
+      on differnt SoCs.
+
+      The SCP cores do not use an MMU, but has a set of registers to
+      control the translations between 32-bit CPU addresses into system bus
+      addresses. Cache and memory access settings are provided through a
+      Memory Protection Unit (MPU), programmable only from the SCP.
+
+    properties:
+      compatible:
+        enum:
+          - mediatek,mt8195-scp-core
+
+      reg:
+        description: The base address and size of SRAM.
+        maxItems: 1
+
+      reg-names:
+        const: sram
+
+      interrupts:
+        maxItems: 1
+
+      firmware-name:
+        $ref: /schemas/types.yaml#/definitions/string
+        description:
+          If present, name (or relative path) of the file within the
+          firmware search path containing the firmware image used when
+          initializing sub cores of multi-core SCP.
+
+      memory-region:
+        maxItems: 1
+
+      cros-ec-rpmsg:
+        type: object
+        description:
+          This subnode represents the rpmsg device. The namesof the devices
+          are not important. The properties of this node are defined by the
+          individual bindings for the rpmsg devices.
+
+        properties:
+          mediatek,rpmsg-name:
+            $ref: /schemas/types.yaml#/definitions/string-array
+            description:
+              Contains the name for the rpmsg device. Used to match
+              the subnode to rpmsg device announced by SCP.
+
+        required:
+          - mediatek,rpmsg-name
+
+    required:
+      - compatible
+      - reg
+      - reg-names
+
+    additionalProperties: false
+
 required:
   - compatible
   - reg
@@ -110,16 +187,26 @@ additionalProperties: false
 
 examples:
   - |
-    #include <dt-bindings/clock/mt8192-clk.h>
-
     scp@10500000 {
-        compatible = "mediatek,mt8192-scp";
+        compatible = "mediatek,mt8195-scp";
         reg = <0x10500000 0x80000>,
               <0x10700000 0x8000>,
               <0x10720000 0xe0000>;
         reg-names = "sram", "cfg", "l1tcm";
-        clocks = <&infracfg CLK_INFRA_SCPSYS>;
-        clock-names = "main";
+
+        #address-cells = <1>;
+        #size-cells = <1>;
+        ranges = <0x105a0000 0x105a0000 0x20000>;
+
+        scp-c1@105a0000 {
+                compatible = "mediatek,mt8195-scp-core";
+                reg = <0x105a0000 0x20000>;
+                reg-names = "sram";
+
+                cros-ec-rpmsg {
+                    mediatek,rpmsg-name = "cros-ec-rpmsg";
+                };
+        };
 
         cros-ec-rpmsg {
             mediatek,rpmsg-name = "cros-ec-rpmsg";
Signature · 1 line
2.18.0
#5 lore raw

Re: [PATCH v3 02/11] dt-bindings: remoteproc: mediatek: Support MT8195 dual-core SCP

Quoted 6 lines · Tinghan Shen

The MT8195 SCP is a dual-core RISC-V MCU. Extend the yaml file to describe the 2nd core as a subnode of the boot core.

The configuration register is shared by MT8195 SCP core 0 and core 1. The core 1 can retrieve the information of configuration registers from parent node.

I think the commit message would not convince people you put scp 1 as subnode of scp 0.

Regards,
Peng.

Quoted 126 lines
---
  .../bindings/remoteproc/mtk,scp.yaml          | 97 ++++++++++++++++++-
  1 file changed, 92 insertions(+), 5 deletions(-)
Documentation/devicetree/bindings/remoteproc/mtk,scp.yaml +92 -5
index 786bed897916..c012265be4eb 100644
@@ -75,6 +75,83 @@ properties:
      required:
        - mediatek,rpmsg-name
 
+  '#address-cells':
+    const: 1
+
+  '#size-cells':
+    const: 1
+
+  ranges: true
+
+patternProperties:
+  "^scp-c[0-9]+@[a-f0-9]+$":
+    type: object
+    description:
+      The MediaTek SCP integrated to SoC might be a multi-core version.
+      The other cores are represented as child nodes of the boot core.
+      There are some integration differences for the IP like the usage of
+      address translator for translating SoC bus addresses into address space
+      for the processor.
+
+      Each SCP core has own cache memory. The SRAM and L1TCM are shared by
+      cores. The power of cache, SRAM and L1TCM power should be enabled
+      before booting SCP cores. The size of cache, SRAM, and L1TCM are varied
+      on differnt SoCs.
+
+      The SCP cores do not use an MMU, but has a set of registers to
+      control the translations between 32-bit CPU addresses into system bus
+      addresses. Cache and memory access settings are provided through a
+      Memory Protection Unit (MPU), programmable only from the SCP.
+
+    properties:
+      compatible:
+        enum:
+          - mediatek,mt8195-scp-core
+
+      reg:
+        description: The base address and size of SRAM.
+        maxItems: 1
+
+      reg-names:
+        const: sram
+
+      interrupts:
+        maxItems: 1
+
+      firmware-name:
+        $ref: /schemas/types.yaml#/definitions/string
+        description:
+          If present, name (or relative path) of the file within the
+          firmware search path containing the firmware image used when
+          initializing sub cores of multi-core SCP.
+
+      memory-region:
+        maxItems: 1
+
+      cros-ec-rpmsg:
+        type: object
+        description:
+          This subnode represents the rpmsg device. The namesof the devices
+          are not important. The properties of this node are defined by the
+          individual bindings for the rpmsg devices.
+
+        properties:
+          mediatek,rpmsg-name:
+            $ref: /schemas/types.yaml#/definitions/string-array
+            description:
+              Contains the name for the rpmsg device. Used to match
+              the subnode to rpmsg device announced by SCP.
+
+        required:
+          - mediatek,rpmsg-name
+
+    required:
+      - compatible
+      - reg
+      - reg-names
+
+    additionalProperties: false
+
  required:
    - compatible
    - reg
@@ -110,16 +187,26 @@ additionalProperties: false
 
  examples:
    - |
-    #include <dt-bindings/clock/mt8192-clk.h>
-
      scp@10500000 {
-        compatible = "mediatek,mt8192-scp";
+        compatible = "mediatek,mt8195-scp";
          reg = <0x10500000 0x80000>,
                <0x10700000 0x8000>,
                <0x10720000 0xe0000>;
          reg-names = "sram", "cfg", "l1tcm";
-        clocks = <&infracfg CLK_INFRA_SCPSYS>;
-        clock-names = "main";
+
+        #address-cells = <1>;
+        #size-cells = <1>;
+        ranges = <0x105a0000 0x105a0000 0x20000>;
+
+        scp-c1@105a0000 {
+                compatible = "mediatek,mt8195-scp-core";
+                reg = <0x105a0000 0x20000>;
+                reg-names = "sram";
+
+                cros-ec-rpmsg {
+                    mediatek,rpmsg-name = "cros-ec-rpmsg";
+                };
+        };
 
          cros-ec-rpmsg {
              mediatek,rpmsg-name = "cros-ec-rpmsg";
#6 lore raw

Re: [PATCH v3 02/11] dt-bindings: remoteproc: mediatek: Support MT8195 dual-core SCP

Quoted 9 lines · Peng Fan
Quoted 6 lines · Tinghan Shen

The MT8195 SCP is a dual-core RISC-V MCU. Extend the yaml file to describe the 2nd core as a subnode of the boot core.

The configuration register is shared by MT8195 SCP core 0 and core 1. The core 1 can retrieve the information of configuration registers from parent node.

Quoted 6 lines

I think the commit message would not convince people you put scp 1 as subnode of scp 0.

Regards,
Peng.

Hi Peng,

Thanks for your review. I should give the most reasonable explanation for why SCP 1 is a subnode.

Adding SCP 1 as a subnode helps to assure finish probing SCP 1 before starting SCP 0 by using of_platform_populate. It's because that I want to probe SCP 1 as a remoteproc subdevice of SCP 0. such that when SCP 0 crashed, SCP 0 can reboot SCP 1.

Regards,
TingHan

#7 lore raw

RE: [PATCH v3 02/11] dt-bindings: remoteproc: mediatek: Support MT8195 dual-core SCP

Quoted 21 lines

Subject: Re: [PATCH v3 02/11] dt-bindings: remoteproc: mediatek: Support MT8195 dual-core SCP

Quoted 9 lines · Peng Fan
Quoted 6 lines · Tinghan Shen

The MT8195 SCP is a dual-core RISC-V MCU. Extend the yaml file to describe the 2nd core as a subnode of the boot core.

The configuration register is shared by MT8195 SCP core 0 and core
1. The core 1 can retrieve the information of configuration registers from parent node.

Quoted 6 lines

I think the commit message would not convince people you put scp 1 as subnode of scp 0.

Regards,
Peng.

Hi Peng,

Quoted 7 lines

Thanks for your review. I should give the most reasonable explanation for why SCP 1 is a subnode.

Adding SCP 1 as a subnode helps to assure finish probing SCP 1 before starting SCP 0 by using of_platform_populate. It's because that I want to probe SCP 1 as a remoteproc subdevice of SCP 0.
such that when SCP 0 crashed, SCP 0 can reboot SCP 1.

Binding is for describing hardware..

Regards,
Peng.

Quoted 7 lines

Regards,
TingHan

#8 lore raw

Re: [PATCH v3 02/11] dt-bindings: remoteproc: mediatek: Support MT8195 dual-core SCP

In reply to TingHan Shen (沈廷翰)
Quoted 18 lines · TingHan Shen (沈廷翰)
Quoted 9 lines · Peng Fan
Quoted 6 lines · Tinghan Shen

The MT8195 SCP is a dual-core RISC-V MCU. Extend the yaml file to describe the 2nd core as a subnode of the boot core.

The configuration register is shared by MT8195 SCP core 0 and core 1. The core 1 can retrieve the information of configuration registers from parent node.

Quoted 6 lines

I think the commit message would not convince people you put scp 1 as subnode of scp 0.

Regards,
Peng.

Hi Peng,

Quoted 7 lines

Thanks for your review. I should give the most reasonable explanation for why SCP 1 is a subnode.

Adding SCP 1 as a subnode helps to assure finish probing SCP 1 before starting SCP 0 by using of_platform_populate. It's because that I want to probe SCP 1 as a remoteproc subdevice of SCP 0. such that when SCP 0 crashed, SCP 0 can reboot SCP 1.

As Peng noted, this is not proper description of hardware. The SCP 0/1 do not have parent-child relationship, so do not model it that way in Devicetree.

Probe ordering is operating system specific, not related to bindings.

Best regards,
Krzysztof

#9 lore raw

Re: [PATCH v3 02/11] dt-bindings: remoteproc: mediatek: Support MT8195 dual-core SCP

In reply to Tinghan Shen
Quoted 20 lines · Tinghan Shen

The MT8195 SCP is a dual-core RISC-V MCU. Extend the yaml file to describe the 2nd core as a subnode of the boot core.

The configuration register is shared by MT8195 SCP core 0 and core 1. The core 1 can retrieve the information of configuration registers from parent node.

---
 .../bindings/remoteproc/mtk,scp.yaml          | 97 ++++++++++++++++++-
 1 file changed, 92 insertions(+), 5 deletions(-)
Documentation/devicetree/bindings/remoteproc/mtk,scp.yaml +0 -0
index 786bed897916..c012265be4eb 100644
@@ -75,6 +75,83 @@ properties:
     required:
       - mediatek,rpmsg-name
 

Documentation/devicetree/bindings/remoteproc/mtk,scp.yaml properties: · line 87

Quoted 10 lines
Documentation/devicetree/bindings/remoteproc/mtk,scp.yaml +10 -0
+  '#address-cells':
+    const: 1
+
+  '#size-cells':
+    const: 1
+
+  ranges: true
+
+patternProperties:
+  "^scp-c[0-9]+@[a-f0-9]+$":

drop c[0-9]. Node names should be generic

Quoted 39 lines
Documentation/devicetree/bindings/remoteproc/mtk,scp.yaml +39 -0
+    type: object
+    description:
+      The MediaTek SCP integrated to SoC might be a multi-core version.
+      The other cores are represented as child nodes of the boot core.
+      There are some integration differences for the IP like the usage of
+      address translator for translating SoC bus addresses into address space
+      for the processor.
+
+      Each SCP core has own cache memory. The SRAM and L1TCM are shared by
+      cores. The power of cache, SRAM and L1TCM power should be enabled
+      before booting SCP cores. The size of cache, SRAM, and L1TCM are varied
+      on differnt SoCs.
+
+      The SCP cores do not use an MMU, but has a set of registers to
+      control the translations between 32-bit CPU addresses into system bus
+      addresses. Cache and memory access settings are provided through a
+      Memory Protection Unit (MPU), programmable only from the SCP.
+
+    properties:
+      compatible:
+        enum:
+          - mediatek,mt8195-scp-core
+
+      reg:
+        description: The base address and size of SRAM.
+        maxItems: 1
+
+      reg-names:
+        const: sram
+
+      interrupts:
+        maxItems: 1
+
+      firmware-name:
+        $ref: /schemas/types.yaml#/definitions/string
+        description:
+          If present, name (or relative path) of the file within the
+          firmware search path containing the firmware image used when
+          initializing sub cores of multi-core SCP.

Documentation/devicetree/bindings/remoteproc/mtk,scp.yaml properties: · line 136

Quoted 10 lines
Documentation/devicetree/bindings/remoteproc/mtk,scp.yaml +10 -0
+
+      memory-region:
+        maxItems: 1
+
+      cros-ec-rpmsg:
+        type: object
+        description:
+          This subnode represents the rpmsg device. The namesof the devices
+          are not important. The properties of this node are defined by the
+          individual bindings for the rpmsg devices.

Same comments as with patch #1.

Quoted 33 lines
Documentation/devicetree/bindings/remoteproc/mtk,scp.yaml +19 -3
+
+        properties:
+          mediatek,rpmsg-name:
+            $ref: /schemas/types.yaml#/definitions/string-array
+            description:
+              Contains the name for the rpmsg device. Used to match
+              the subnode to rpmsg device announced by SCP.
+
+        required:
+          - mediatek,rpmsg-name
+
+    required:
+      - compatible
+      - reg
+      - reg-names
+
+    additionalProperties: false
+
 required:
   - compatible
   - reg
@@ -110,16 +187,26 @@ additionalProperties: false
 
 examples:
   - |
-    #include <dt-bindings/clock/mt8192-clk.h>
-
     scp@10500000 {
-        compatible = "mediatek,mt8192-scp";
+        compatible = "mediatek,mt8195-scp";
         reg = <0x10500000 0x80000>,
               <0x10700000 0x8000>,
               <0x10720000 0xe0000>;

Documentation/devicetree/bindings/remoteproc/mtk,scp.yaml additionalProperties: false · line 202

Quoted 10 lines
Documentation/devicetree/bindings/remoteproc/mtk,scp.yaml +7 -2
         reg-names = "sram", "cfg", "l1tcm";
-        clocks = <&infracfg CLK_INFRA_SCPSYS>;
-        clock-names = "main";
+
+        #address-cells = <1>;
+        #size-cells = <1>;
+        ranges = <0x105a0000 0x105a0000 0x20000>;
+
+        scp-c1@105a0000 {
+                compatible = "mediatek,mt8195-scp-core";

Messed indentation. Use 4 spaces for example indentation.

Best regards,
Krzysztof

#10 lore raw

PATCH v3 3/11 arm64: dts: mt8195: Add SCP core 1 node

In reply to Tinghan Shen

Add the 2nd core(core 1) of MT8195 dual-core SCP to devicetree file. Reserve some SRAM spaces for the core 1 image.

---
 arch/arm64/boot/dts/mediatek/mt8195.dtsi | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/mediatek/mt8195.dtsi +13 -1
index 905d1a90b406..48d457bd39b8 100644
@@ -760,12 +760,24 @@
 
 		scp: scp@10500000 {
 			compatible = "mediatek,mt8195-scp";
-			reg = <0 0x10500000 0 0x100000>,
+			reg = <0 0x10500000 0 0xa0000>,
 			      <0 0x10720000 0 0xe0000>,
 			      <0 0x10700000 0 0x8000>;
 			reg-names = "sram", "cfg", "l1tcm";
 			interrupts = <GIC_SPI 462 IRQ_TYPE_LEVEL_HIGH 0>;
 			status = "disabled";
+
+			#address-cells = <1>;
+			#size-cells = <1>;
+			ranges = <0x105a0000 0 0x105a0000 0x20000>;
+
+			scp_c1: scp-c1@105a0000 {
+				compatible = "mediatek,mt8195-scp-core";
+				reg = <0x105a0000 0x20000>;
+				reg-names = "sram";
+				interrupts = <GIC_SPI 463 IRQ_TYPE_LEVEL_HIGH 0>;
+				status = "disabled";
+			};
 		};
 
 		scp_adsp: clock-controller@10720000 {
Signature · 1 line
2.18.0
#11 lore raw

Re: [PATCH v3 03/11] arm64: dts: mt8195: Add SCP core 1 node

Il 27/09/22 04:55, Tinghan Shen ha scritto:

Quoted 25 lines

Add the 2nd core(core 1) of MT8195 dual-core SCP to devicetree file. Reserve some SRAM spaces for the core 1 image.

---
  arch/arm64/boot/dts/mediatek/mt8195.dtsi | 14 +++++++++++++-
  1 file changed, 13 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/mediatek/mt8195.dtsi +3 -1
index 905d1a90b406..48d457bd39b8 100644
@@ -760,12 +760,24 @@
 
  		scp: scp@10500000 {
  			compatible = "mediatek,mt8195-scp";
-			reg = <0 0x10500000 0 0x100000>,
+			reg = <0 0x10500000 0 0xa0000>,
  			      <0 0x10720000 0 0xe0000>,
  			      <0 0x10700000 0 0x8000>;
  			reg-names = "sram", "cfg", "l1tcm";
  			interrupts = <GIC_SPI 462 IRQ_TYPE_LEVEL_HIGH 0>;
  			status = "disabled";
+
+			#address-cells = <1>;

arch/arm64/boot/dts/mediatek/mt8195.dtsi line 780

Quoted 10 lines
arch/arm64/boot/dts/mediatek/mt8195.dtsi +10 -0
+			#size-cells = <1>;
+			ranges = <0x105a0000 0 0x105a0000 0x20000>;
+
+			scp_c1: scp-c1@105a0000 {
+				compatible = "mediatek,mt8195-scp-core";
+				reg = <0x105a0000 0x20000>;
+				reg-names = "sram";
+				interrupts = <GIC_SPI 463 IRQ_TYPE_LEVEL_HIGH 0>;
+				status = "disabled";
+			};

I think that the best way of describing a dual-core SCP in devicetree would be either something like:

scp: scp@10500000 {
	compatible = "mediatek,mt8195-scp";
	reg = <0 0x10500000 0 0xa0000>, <0 0x105a0000 0 0x20000>,
	      <0 0x10720000 0 0xe0000>, <0 0x10700000 0 0x8000>;
	reg-names = "sram", "sram-c1", "cfg", "l1tcm";
	interrupts = <GIC_SPI 462 IRQ_TYPE_LEVEL_HIGH 0>,
		     <GIC_SPI 463 IRQ_TYPE_LEVEL_HIGH 0>;
	status = "disabled";
};

...but that may pose an issue when trying to assign different (or more instances of the same) subnode(s) to each core... for which, I'd be more for something like:

scp: scp@10500000 {
	compatible = "mediatek,mt8195-scp";
	reg = <0 0x10720000 0 0xe0000>, <0 0x10700000 0 0x8000>;
	reg-names = "cfg", "l1tcm";
	#address-cells = <1>;
	#size-cells = <1>;
	ranges = <0 0 0x10500000 0x100000>;
	status = "disabled";

	scp_c0: scp-core@0 {
		compatible = "mediatek,mt8195-scp-core";
		reg = <0x0 0xa0000>;
		reg-names = "sram";
		interrupts = <GIC_SPI 462 IRQ_TYPE_LEVEL_HIGH 0>;
	};

	scp_c1: scp-core@a0000 {
		compatible = "mediatek,mt8195-scp-core";
		reg = <0xa0000 0x20000>;
		reg-names = "sram";
		interrupts = <GIC_SPI 463 IRQ_TYPE_LEVEL_HIGH 0>;
	};
};

Regards,
Angelo

#12 lore raw

Re: [PATCH v3 03/11] arm64: dts: mt8195: Add SCP core 1 node

Quoted 77 lines · AngeloGioacchino Del Regno

Il 27/09/22 04:55, Tinghan Shen ha scritto:

Quoted 25 lines

Add the 2nd core(core 1) of MT8195 dual-core SCP to devicetree file. Reserve some SRAM spaces for the core 1 image.

---
  arch/arm64/boot/dts/mediatek/mt8195.dtsi | 14 +++++++++++++-
  1 file changed, 13 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/mediatek/mt8195.dtsi +3 -1
index 905d1a90b406..48d457bd39b8 100644
@@ -760,12 +760,24 @@
 
  		scp: scp@10500000 {
  			compatible = "mediatek,mt8195-scp";
-			reg = <0 0x10500000 0 0x100000>,
+			reg = <0 0x10500000 0 0xa0000>,
  			      <0 0x10720000 0 0xe0000>,
  			      <0 0x10700000 0 0x8000>;
  			reg-names = "sram", "cfg", "l1tcm";
  			interrupts = <GIC_SPI 462 IRQ_TYPE_LEVEL_HIGH 0>;
  			status = "disabled";
+
+			#address-cells = <1>;

arch/arm64/boot/dts/mediatek/mt8195.dtsi line 780

Quoted 10 lines
arch/arm64/boot/dts/mediatek/mt8195.dtsi +10 -0
+			#size-cells = <1>;
+			ranges = <0x105a0000 0 0x105a0000 0x20000>;
+
+			scp_c1: scp-c1@105a0000 {
+				compatible = "mediatek,mt8195-scp-core";
+				reg = <0x105a0000 0x20000>;
+				reg-names = "sram";
+				interrupts = <GIC_SPI 463 IRQ_TYPE_LEVEL_HIGH 0>;
+				status = "disabled";
+			};

I think that the best way of describing a dual-core SCP in devicetree would be either something like:

scp: scp@10500000 {
	compatible = "mediatek,mt8195-scp";
	reg = <0 0x10500000 0 0xa0000>, <0 0x105a0000 0 0x20000>,
	      <0 0x10720000 0 0xe0000>, <0 0x10700000 0 0x8000>;
	reg-names = "sram", "sram-c1", "cfg", "l1tcm";
	interrupts = <GIC_SPI 462 IRQ_TYPE_LEVEL_HIGH 0>,
		     <GIC_SPI 463 IRQ_TYPE_LEVEL_HIGH 0>;
	status = "disabled";
};

...but that may pose an issue when trying to assign different (or more instances of the same) subnode(s) to each core... for which, I'd be more for something like:

scp: scp@10500000 {
	compatible = "mediatek,mt8195-scp";
	reg = <0 0x10720000 0 0xe0000>, <0 0x10700000 0 0x8000>;
	reg-names = "cfg", "l1tcm";
	#address-cells = <1>;
	#size-cells = <1>;
	ranges = <0 0 0x10500000 0x100000>;
	status = "disabled";

	scp_c0: scp-core@0 {
		compatible = "mediatek,mt8195-scp-core";
		reg = <0x0 0xa0000>;
		reg-names = "sram";
		interrupts = <GIC_SPI 462 IRQ_TYPE_LEVEL_HIGH 0>;
	};

	scp_c1: scp-core@a0000 {
		compatible = "mediatek,mt8195-scp-core";
		reg = <0xa0000 0x20000>;
		reg-names = "sram";
		interrupts = <GIC_SPI 463 IRQ_TYPE_LEVEL_HIGH 0>;
	};
};
Quoted 4 lines

Regards,
Angelo

Hi Angelo,

I'm thinking about identifying the cores by the order of the sub nodes, i.e. core 0 must be the first sub node and core 1 must be the second sub node, because the scp cores in the example have the same compatible name.

I'm hesitant to make the sub nodes appear in a certain order. Is it appropriate? Or, would it be more readable to create a new core id property? Or utilizing different compatble strings for cores? I would appreciat it if you could share your opinion.

Signature · 2 lines
Best regards,
TingHan
#13 lore raw

Re: [PATCH v3 03/11] arm64: dts: mt8195: Add SCP core 1 node

Il 17/01/23 09:19, TingHan Shen (沈廷翰) ha scritto:

Quoted 84 lines · AngeloGioacchino Del Regno
Quoted 77 lines

Il 27/09/22 04:55, Tinghan Shen ha scritto:

Quoted 25 lines

Add the 2nd core(core 1) of MT8195 dual-core SCP to devicetree file. Reserve some SRAM spaces for the core 1 image.

---
   arch/arm64/boot/dts/mediatek/mt8195.dtsi | 14 +++++++++++++-
   1 file changed, 13 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/mediatek/mt8195.dtsi +3 -1
index 905d1a90b406..48d457bd39b8 100644
@@ -760,12 +760,24 @@
 
   		scp: scp@10500000 {
   			compatible = "mediatek,mt8195-scp";
-			reg = <0 0x10500000 0 0x100000>,
+			reg = <0 0x10500000 0 0xa0000>,
   			      <0 0x10720000 0 0xe0000>,
   			      <0 0x10700000 0 0x8000>;
   			reg-names = "sram", "cfg", "l1tcm";
   			interrupts = <GIC_SPI 462 IRQ_TYPE_LEVEL_HIGH 0>;
   			status = "disabled";
+
+			#address-cells = <1>;

arch/arm64/boot/dts/mediatek/mt8195.dtsi line 780

Quoted 10 lines
arch/arm64/boot/dts/mediatek/mt8195.dtsi +10 -0
+			#size-cells = <1>;
+			ranges = <0x105a0000 0 0x105a0000 0x20000>;
+
+			scp_c1: scp-c1@105a0000 {
+				compatible = "mediatek,mt8195-scp-core";
+				reg = <0x105a0000 0x20000>;
+				reg-names = "sram";
+				interrupts = <GIC_SPI 463 IRQ_TYPE_LEVEL_HIGH 0>;
+				status = "disabled";
+			};

I think that the best way of describing a dual-core SCP in devicetree would be either something like:

scp: scp@10500000 {
	compatible = "mediatek,mt8195-scp";
	reg = <0 0x10500000 0 0xa0000>, <0 0x105a0000 0 0x20000>,
	      <0 0x10720000 0 0xe0000>, <0 0x10700000 0 0x8000>;
	reg-names = "sram", "sram-c1", "cfg", "l1tcm";
	interrupts = <GIC_SPI 462 IRQ_TYPE_LEVEL_HIGH 0>,
		     <GIC_SPI 463 IRQ_TYPE_LEVEL_HIGH 0>;
	status = "disabled";
};

...but that may pose an issue when trying to assign different (or more instances of the same) subnode(s) to each core... for which, I'd be more for something like:

scp: scp@10500000 {
	compatible = "mediatek,mt8195-scp";
	reg = <0 0x10720000 0 0xe0000>, <0 0x10700000 0 0x8000>;
	reg-names = "cfg", "l1tcm";
	#address-cells = <1>;
	#size-cells = <1>;
	ranges = <0 0 0x10500000 0x100000>;
	status = "disabled";

	scp_c0: scp-core@0 {
		compatible = "mediatek,mt8195-scp-core";
		reg = <0x0 0xa0000>;
		reg-names = "sram";
		interrupts = <GIC_SPI 462 IRQ_TYPE_LEVEL_HIGH 0>;
	};

	scp_c1: scp-core@a0000 {
		compatible = "mediatek,mt8195-scp-core";
		reg = <0xa0000 0x20000>;
		reg-names = "sram";
		interrupts = <GIC_SPI 463 IRQ_TYPE_LEVEL_HIGH 0>;
	};
};
Quoted 4 lines

Regards,
Angelo

Hi Angelo,

Quoted 9 lines

I'm thinking about identifying the cores by the order of the sub nodes, i.e. core 0 must be the first sub node and core 1 must be the second sub node, because the scp cores in the example have the same compatible name.

I'm hesitant to make the sub nodes appear in a certain order. Is it appropriate? Or, would it be more readable to create a new core id property? Or utilizing different compatble strings for cores? I would appreciat it if you could share your opinion.

Assuming that in a future >2 cores architecture only the first core, which I will call "core 0" for commodity, will have "special treatment" and core 1, 2, 3...N will always be "interchangeable", I think that something like mediatek,scp-leader would work to identify the first core.

Cheers!
Angelo

#14 lore raw

PATCH v3 4/11 remoteproc: mediatek: Remove redundant rproc_boot

In reply to Tinghan Shen

The video codec doesn't need to explicitly boot SCP in its flow because the SCP remote processor enables auto boot.

The redundant usage of rproc_boot increases the number of rproc.power over 1 and prevents successfully shutting down SCP by rproc_shutdown.

---
 .../mediatek/vcodec/mtk_vcodec_fw_scp.c         |  2 +-
 drivers/remoteproc/mtk_scp.c                    | 17 +++++++++++++++++
 include/linux/remoteproc/mtk_scp.h              |  1 +
 3 files changed, 19 insertions(+), 1 deletion(-)
drivers/media/platform/mediatek/vcodec/mtk_vcodec_fw_scp.c +1 -1
index d8e66b645bd8..c3194f88ff31 100644
@@ -6,7 +6,7 @@
 
 static int mtk_vcodec_scp_load_firmware(struct mtk_vcodec_fw *fw)
 {
-	return rproc_boot(scp_get_rproc(fw->scp));
+	return scp_boot(fw->scp);
 }
 
 static unsigned int mtk_vcodec_scp_get_vdec_capa(struct mtk_vcodec_fw *fw)
drivers/remoteproc/mtk_scp.c +17 -0
index d421a2ccaa1e..bf68bccab78b 100644
@@ -673,6 +673,23 @@ struct rproc *scp_get_rproc(struct mtk_scp *scp)
 }
 EXPORT_SYMBOL_GPL(scp_get_rproc);
 
+/**
+ * scp_boot() - Boot SCP
+ *
+ * @scp:	mtk_scp structure
+ **/
+int scp_boot(struct mtk_scp *scp)
+{
+	struct rproc *rproc = scp->rproc;
+
+	/* scp already booted when power > 0 */
+	if (atomic_read(&rproc->power) > 0)
+		return 0;
+	else
+		return rproc_boot(scp->rproc);
+}
+EXPORT_SYMBOL_GPL(scp_boot);
+
 /**
  * scp_get_vdec_hw_capa() - get video decoder hardware capability
  *
include/linux/remoteproc/mtk_scp.h +1 -0
index 7c2b7cc9fe6c..e463105b351c 100644
@@ -52,6 +52,7 @@ void scp_put(struct mtk_scp *scp);
 
 struct device *scp_get_device(struct mtk_scp *scp);
 struct rproc *scp_get_rproc(struct mtk_scp *scp);
+int scp_boot(struct mtk_scp *scp);
 
 int scp_ipi_register(struct mtk_scp *scp, u32 id, scp_ipi_handler_t handler,
 		     void *priv);
Signature · 1 line
2.18.0
#15 lore raw

Re: [PATCH v3 04/11] remoteproc: mediatek: Remove redundant rproc_boot

Il 27/09/22 04:55, Tinghan Shen ha scritto:

Quoted 7 lines

The video codec doesn't need to explicitly boot SCP in its flow because the SCP remote processor enables auto boot.

The redundant usage of rproc_boot increases the number of rproc.power over 1 and prevents successfully shutting down SCP by rproc_shutdown.

You should Cc stable on this commit, as it's a quite important fix.

Regards,
Angelo

#16 lore raw

Re: [PATCH v3 04/11] remoteproc: mediatek: Remove redundant rproc_boot

Quoted 7 lines · AngeloGioacchino Del Regno

Il 27/09/22 04:55, Tinghan Shen ha scritto:

Quoted 6 lines

The video codec doesn't need to explicitly boot SCP in its flow because the SCP remote processor enables auto boot.

The redundant usage of rproc_boot increases the number of rproc.power over 1 and prevents successfully shutting down SCP by rproc_shutdown.

Quoted 7 lines
Quoted 1 line

You should Cc stable on this commit, as it's a quite important fix.

Regards,
Angelo

Hi Angelo,

Ok, I'll add it at next version.

Thanks,
TingHan

#17 lore raw

Re: [PATCH v3 04/11] remoteproc: mediatek: Remove redundant rproc_boot

Quoted 10 lines · TingHan Shen (沈廷翰)
Quoted 9 lines · AngeloGioacchino Del Regno

Il 27/09/22 04:55, Tinghan Shen ha scritto:

Quoted 7 lines

The video codec doesn't need to explicitly boot SCP in its flow because the SCP remote processor enables auto boot.

The redundant usage of rproc_boot increases the number of rproc.power over 1 and prevents successfully shutting down SCP by rproc_shutdown.

Quoted 8 lines
Quoted 5 lines

You should Cc stable on this commit, as it's a quite important fix.

Regards,
Angelo

Hi Angelo,

Ok, I'll add it at next version.

If this patch is not relevant with the SCP 1 support in this patchset, better separate this patch out as a standalone fix.

Regards,
Peng.

Quoted 3 lines

Thanks,
TingHan

#18 lore raw

Re: [PATCH v3 04/11] remoteproc: mediatek: Remove redundant rproc_boot

Quoted 18 lines · Peng Fan
Quoted 16 lines · TingHan Shen (沈廷翰)
Quoted 14 lines · AngeloGioacchino Del Regno

Il 27/09/22 04:55, Tinghan Shen ha scritto:

Quoted 7 lines

The video codec doesn't need to explicitly boot SCP in its flow because the SCP remote processor enables auto boot.

The redundant usage of rproc_boot increases the number of rproc.power over 1 and prevents successfully shutting down SCP by rproc_shutdown.

You should Cc stable on this commit, as it's a quite important fix.

Regards,
Angelo

Quoted 6 lines
Quoted 3 lines

Hi Angelo,

Ok, I'll add it at next version.

If this patch is not relevant with the SCP 1 support in this patchset, better separate this patch out as a standalone fix.

Ok, I'll send it separately.

Regards,
TingHan

Quoted 7 lines

Regards,
Peng.

Quoted 3 lines

Thanks,
TingHan

#19 lore raw

PATCH v3 5/11 remoteproc: mediatek: Add SCP core 1 register definitions

In reply to Tinghan Shen

Add MT8195 SCP core 1 related register definitions.

---
 drivers/remoteproc/mtk_common.h | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
drivers/remoteproc/mtk_common.h +21 -0
index ea6fa1100a00..3778894c96f3 100644
@@ -47,6 +47,7 @@
 #define MT8192_SCP2SPM_IPC_CLR		0x4094
 #define MT8192_GIPC_IN_SET		0x4098
 #define MT8192_HOST_IPC_INT_BIT		BIT(0)
+#define MT8195_CORE1_HOST_IPC_INT_BIT	BIT(4)
 
 #define MT8192_CORE0_SW_RSTN_CLR	0x10000
 #define MT8192_CORE0_SW_RSTN_SET	0x10004
@@ -56,6 +57,26 @@
 
 #define MT8195_L1TCM_SRAM_PDN_RESERVED_RSI_BITS		GENMASK(7, 4)
 
+#define MT8195_CPU1_SRAM_PD			0x1084
+#define MT8195_SSHUB2APMCU_IPC_SET		0x4088
+#define MT8195_SSHUB2APMCU_IPC_CLR		0x408C
+#define MT8195_CORE1_SW_RSTN_CLR		0x20000
+#define MT8195_CORE1_SW_RSTN_SET		0x20004
+#define MT8195_CORE1_MEM_ATT_PREDEF		0x20008
+#define MT8195_CORE1_WDT_IRQ			0x20030
+#define MT8195_CORE1_WDT_CFG			0x20034
+
+#define MT8195_SEC_CTRL				0x85000
+#define MT8195_CORE_OFFSET_ENABLE_D		BIT(13)
+#define MT8195_CORE_OFFSET_ENABLE_I		BIT(12)
+#define MT8195_L2TCM_OFFSET_RANGE_0_LOW		0x850b0
+#define MT8195_L2TCM_OFFSET_RANGE_0_HIGH	0x850b4
+#define MT8195_L2TCM_OFFSET			0x850d0
+#define SCP_SRAM_REMAP_LOW			0
+#define SCP_SRAM_REMAP_HIGH			1
+#define SCP_SRAM_REMAP_OFFSET			2
+#define SCP_SRAM_REMAP_SIZE			3
+
 #define SCP_FW_VER_LEN			32
 #define SCP_SHARE_BUFFER_SIZE		288
 
Signature · 1 line
2.18.0
#21 lore raw

PATCH v3 6/11 remoteproc: mediatek: Add MT8195 SCP core 1 operations

In reply to Tinghan Shen

The SCP rproc driver has a set of chip dependent callbacks for boot sequence and IRQ handling. Implement these callbacks for MT8195 SCP core 1.

---
 drivers/remoteproc/mtk_scp.c | 57 ++++++++++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)
drivers/remoteproc/mtk_scp.c +57 -0
index bf68bccab78b..1d17d77b8a14 100644
@@ -176,6 +176,16 @@ static void mt8192_scp_reset_deassert(struct mtk_scp *scp)
 	writel(1, scp->reg_base + MT8192_CORE0_SW_RSTN_CLR);
 }
 
+static void mt8195_scp_c1_reset_assert(struct mtk_scp *scp)
+{
+	writel(1, scp->reg_base + MT8195_CORE1_SW_RSTN_SET);
+}
+
+static void mt8195_scp_c1_reset_deassert(struct mtk_scp *scp)
+{
+	writel(1, scp->reg_base + MT8195_CORE1_SW_RSTN_CLR);
+}
+
 static void mt8183_scp_irq_handler(struct mtk_scp *scp)
 {
 	u32 scp_to_host;
@@ -212,6 +222,18 @@ static void mt8192_scp_irq_handler(struct mtk_scp *scp)
 	}
 }
 
+static void mt8195_scp_c1_irq_handler(struct mtk_scp *scp)
+{
+	u32 scp_to_host;
+
+	scp_to_host = readl(scp->reg_base + MT8195_SSHUB2APMCU_IPC_SET);
+
+	if (scp_to_host & MT8192_SCP_IPC_INT_BIT)
+		scp_ipi_handler(scp);
+
+	writel(scp_to_host, scp->reg_base + MT8195_SSHUB2APMCU_IPC_CLR);
+}
+
 static irqreturn_t scp_irq_handler(int irq, void *priv)
 {
 	struct mtk_scp *scp = priv;
@@ -453,6 +475,19 @@ static int mt8195_scp_before_load(struct mtk_scp *scp)
 	return 0;
 }
 
+static int mt8195_scp_c1_before_load(struct mtk_scp *scp)
+{
+	scp_sram_power_on(scp->reg_base + MT8195_CPU1_SRAM_PD, 0);
+
+	/* hold SCP in reset while loading FW. */
+	scp->data->scp_reset_assert(scp);
+
+	/* enable MPU for all memory regions */
+	writel(0xff, scp->reg_base + MT8195_CORE1_MEM_ATT_PREDEF);
+
+	return 0;
+}
+
 static int scp_load(struct rproc *rproc, const struct firmware *fw)
 {
 	struct mtk_scp *scp = rproc->priv;
@@ -625,6 +660,15 @@ static void mt8195_scp_stop(struct mtk_scp *scp)
 	writel(0, scp->reg_base + MT8192_CORE0_WDT_CFG);
 }
 
+static void mt8195_scp_c1_stop(struct mtk_scp *scp)
+{
+	/* Power off CPU SRAM */
+	scp_sram_power_off(scp->reg_base + MT8195_CPU1_SRAM_PD, 0);
+
+	/* Disable SCP watchdog */
+	writel(0, scp->reg_base + MT8195_CORE1_WDT_CFG);
+}
+
 static int scp_stop(struct rproc *rproc)
 {
 	struct mtk_scp *scp = (struct mtk_scp *)rproc->priv;
@@ -1007,12 +1051,25 @@ static const struct mtk_scp_of_data mt8195_of_data = {
 	.host_to_scp_int_bit = MT8192_HOST_IPC_INT_BIT,
 };
 
+static const struct mtk_scp_of_data mt8195_core_of_data = {
+	.scp_clk_get = mt8195_scp_clk_get,
+	.scp_before_load = mt8195_scp_c1_before_load,
+	.scp_irq_handler = mt8195_scp_c1_irq_handler,
+	.scp_reset_assert = mt8195_scp_c1_reset_assert,
+	.scp_reset_deassert = mt8195_scp_c1_reset_deassert,
+	.scp_stop = mt8195_scp_c1_stop,
+	.scp_da_to_va = mt8192_scp_da_to_va,
+	.host_to_scp_reg = MT8192_GIPC_IN_SET,
+	.host_to_scp_int_bit = MT8195_CORE1_HOST_IPC_INT_BIT,
+};
+
 static const struct of_device_id mtk_scp_of_match[] = {
 	{ .compatible = "mediatek,mt8183-scp", .data = &mt8183_of_data },
 	{ .compatible = "mediatek,mt8186-scp", .data = &mt8186_of_data },
 	{ .compatible = "mediatek,mt8188-scp", .data = &mt8188_of_data },
 	{ .compatible = "mediatek,mt8192-scp", .data = &mt8192_of_data },
 	{ .compatible = "mediatek,mt8195-scp", .data = &mt8195_of_data },
+	{ .compatible = "mediatek,mt8195-scp-core", .data = &mt8195_core_of_data },
 	{},
 };
 MODULE_DEVICE_TABLE(of, mtk_scp_of_match);
Signature · 1 line
2.18.0
#22 lore raw

PATCH v3 7/11 remoteproc: mediatek: Probe MT8195 SCP core 1

In reply to Tinghan Shen

The MT8195 SCP configuration registers for core 0 and core 1 is the same. Let SCP core 1 to reuse the mapped address requested by SCP core 0.

---
 drivers/remoteproc/mtk_common.h |  2 ++
 drivers/remoteproc/mtk_scp.c    | 27 +++++++++++++++++++++++----
 2 files changed, 25 insertions(+), 4 deletions(-)
drivers/remoteproc/mtk_common.h +2 -0
index 3778894c96f3..54265c515315 100644
@@ -140,6 +140,8 @@ struct mtk_scp {
 	size_t dram_size;
 
 	struct rproc_subdev *rpmsg_subdev;
+
+	struct mtk_scp *main_scp;
 };
 
 /**
drivers/remoteproc/mtk_scp.c +23 -4
index 1d17d77b8a14..f7b738743ba9 100644
@@ -917,10 +917,29 @@ static int scp_probe(struct platform_device *pdev)
 		scp->l1tcm_phys = res->start;
 	}
 
-	scp->reg_base = devm_platform_ioremap_resource_byname(pdev, "cfg");
-	if (IS_ERR(scp->reg_base))
-		return dev_err_probe(dev, PTR_ERR(scp->reg_base),
-				     "Failed to parse and map cfg memory\n");
+	if (of_device_is_compatible(np, "mediatek,mt8195-scp-core")) {
+		struct device_node *pnp;
+		struct platform_device *scp_pdev;
+
+		pnp = of_get_parent(np);
+		if (!pnp)
+			return dev_err_probe(dev, -ENODEV, "Failed to get parent core 0\n");
+
+		scp_pdev = of_find_device_by_node(pnp);
+		of_node_put(pnp);
+		if (!scp_pdev)
+			return dev_err_probe(dev, -ENODEV, "Failed to get scp core 0 pdev\n");
+
+		scp->main_scp = platform_get_drvdata(scp_pdev);
+		scp->reg_base = scp->main_scp->reg_base;
+	} else {
+		res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cfg");
+		scp->reg_base = devm_ioremap_resource(dev, res);
+
+		if (IS_ERR(scp->reg_base))
+			return dev_err_probe(dev, PTR_ERR(scp->reg_base),
+					     "Failed to parse and map cfg memory\n");
+	}
 
 	ret = scp->data->scp_clk_get(scp);
 	if (ret)
Signature · 1 line
2.18.0
#23 lore raw

PATCH v3 8/11 remoteproc: mediatek: Control SCP core 1 boot by rproc subdevice

In reply to Tinghan Shen

Register SCP core 1 as a subdevice of core 0 to control the boot sequence and watchdog handling. The core 1 has to boot after core 0 because the SCP clock and SRAM power is controlled by SCP core 0.
When SCP core 0 reports a watchdog timeout event, the SRAM is emptied before rebooting the SCP core 0, forcing the reload of the SCP core 1 image.

---
 drivers/remoteproc/mtk_common.h |  8 ++++
 drivers/remoteproc/mtk_scp.c    | 71 +++++++++++++++++++++++++++++++++
 2 files changed, 79 insertions(+)
drivers/remoteproc/mtk_common.h +8 -0
index 54265c515315..dcde25f8bbf9 100644
@@ -95,6 +95,13 @@ struct scp_ipi_desc {
 	void *priv;
 };
 
+struct scp_subdev_core {
+	struct rproc_subdev subdev;
+	struct mtk_scp *scp;
+};
+
+#define to_subdev_core(d) container_of(d, struct scp_subdev_core, subdev)
+
 struct mtk_scp;
 
 struct mtk_scp_of_data {
@@ -142,6 +149,7 @@ struct mtk_scp {
 	struct rproc_subdev *rpmsg_subdev;
 
 	struct mtk_scp *main_scp;
+	struct rproc_subdev *core_subdev;
 };
 
 /**
drivers/remoteproc/mtk_scp.c +71 -0

95 lines not on this page · raw message

Signature · 1 line
2.18.0
#24 lore raw

PATCH v3 9/11 remoteproc: mediatek: Setup MT8195 SCP core 1 SRAM offset

In reply to Tinghan Shen

Because MT8195 SCP core 0 and core 1 both boot from head of SRAM and have the same viewpoint of SRAM, SCP has a "Core 1 SRAM offset" to control the viewpoint of SCP core 1 to allow core 1 boot from different SRAM location.

The "Core 1 SRAM offset" configuration is composed by specifying a range and an offset. When SCP core 1 accesses a SRAM address located in the configured range, SCP bus adds the configured offset to the address to shift the final physical destination on SCP SRAM. This shift is transparent to the software running on SCP core 1.

---
 drivers/remoteproc/mtk_scp.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
drivers/remoteproc/mtk_scp.c +23 -0
index 2d43338b96da..0f1b587f8502 100644
@@ -477,6 +477,8 @@ static int mt8195_scp_before_load(struct mtk_scp *scp)
 
 static int mt8195_scp_c1_before_load(struct mtk_scp *scp)
 {
+	u32 sec_ctrl;
+
 	scp_sram_power_on(scp->reg_base + MT8195_CPU1_SRAM_PD, 0);
 
 	/* hold SCP in reset while loading FW. */
@@ -485,6 +487,27 @@ static int mt8195_scp_c1_before_load(struct mtk_scp *scp)
 	/* enable MPU for all memory regions */
 	writel(0xff, scp->reg_base + MT8195_CORE1_MEM_ATT_PREDEF);
 
+	/* The value of SRAM offset range is from the viewpoint of SCP core 1.
+	 * This configuration adds an offset on SCP bus when SCP core 1 accesses SCP SRAM
+	 * to solve the SCP core 0 and core 1 both fetch the 1st instruction from the same
+	 * SRAM address.
+	 *
+	 * Because SCP core 0 and core 1 both boot from the head of sram, this must be
+	 * configured before boot SCP core 1.
+	 *
+	 * Configure the range of SRAM addresses will be added offset.
+	 */
+	writel(0, scp->reg_base + MT8195_L2TCM_OFFSET_RANGE_0_LOW);
+	writel(scp->sram_size, scp->reg_base + MT8195_L2TCM_OFFSET_RANGE_0_HIGH);
+
+	/* configure the offset value */
+	writel(scp->sram_phys - scp->main_scp->sram_phys, scp->reg_base + MT8195_L2TCM_OFFSET);
+
+	/* enable adding sram offset when fetching instruction and data */
+	sec_ctrl = readl(scp->reg_base + MT8195_SEC_CTRL);
+	sec_ctrl |= MT8195_CORE_OFFSET_ENABLE_I | MT8195_CORE_OFFSET_ENABLE_D;
+	writel(sec_ctrl, scp->reg_base + MT8195_SEC_CTRL);
+
 	return 0;
 }
 
Signature · 1 line
2.18.0
#25 lore raw

PATCH v3 10/11 remoteproc: mediatek: Handle MT8195 SCP core 1 watchdog timeout

In reply to Tinghan Shen

The MT8195 SCP core 1 watchdog timeout needs to be handled in the SCP core 0 IRQ handler because the MT8195 SCP core 1 watchdog timeout IRQ is wired on the same IRQ entry for core 0 watchdog timeout. MT8195 SCP has a watchdog status register to identify the watchdog timeout source when IRQ triggered.

---
 drivers/remoteproc/mtk_common.h |  4 +++
 drivers/remoteproc/mtk_scp.c    | 44 ++++++++++++++++++++++++++++++++-
 2 files changed, 47 insertions(+), 1 deletion(-)
drivers/remoteproc/mtk_common.h +4 -0
index dcde25f8bbf9..6cd04ca9e681 100644
@@ -55,6 +55,10 @@
 #define MT8192_CORE0_WDT_IRQ		0x10030
 #define MT8192_CORE0_WDT_CFG		0x10034
 
+#define MT8195_SYS_STATUS		0x4004
+#define MT8195_CORE0_WDT		BIT(16)
+#define MT8195_CORE1_WDT		BIT(17)
+
 #define MT8195_L1TCM_SRAM_PDN_RESERVED_RSI_BITS		GENMASK(7, 4)
 
 #define MT8195_CPU1_SRAM_PD			0x1084
drivers/remoteproc/mtk_scp.c +43 -1

56 lines not on this page · raw message

Signature · 1 line
2.18.0
#26 lore raw

PATCH v3 11/11 remoteproc: mediatek: Refine ipi handler error message

In reply to Tinghan Shen

The error message doesn't accurately reflect the cause of the error. The error is due to a handler not being found, not an invalid IPI ID.

---
 drivers/remoteproc/mtk_scp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/remoteproc/mtk_scp.c +1 -1
index 159f3c69cd69..8b1765c61442 100644
@@ -106,7 +106,7 @@ static void scp_ipi_handler(struct mtk_scp *scp)
 	scp_ipi_lock(scp, id);
 	handler = ipi_desc[id].handler;
 	if (!handler) {
-		dev_err(scp->dev, "No such ipi id = %d\n", id);
+		dev_err(scp->dev, "No handler for ipi id = %d\n", id);
 		scp_ipi_unlock(scp, id);
 		return;
 	}
Signature · 1 line
2.18.0
maintainer
#28 lore raw
In reply to Tinghan Shen

Good day,

A lot of comments related to the handling of SCP 0 and 1 have already been made on this patchset, along with my own advice from the previous patchset on how to move forward. As such I will wait for a new revision.

Thanks,
Mathieu

Quoted 42 lines · Tinghan Shen

The mediatek remoteproc driver currently only allows bringing up a single core SCP, e.g. MT8183. It also only bringing up the 1st core in SoCs with a dual-core SCP, e.g. MT8195. This series support to bring-up the 2nd core of the dual-core SCP.

v2 -> v3:
1. change the representation of dual-core SCP in dts file and update SCP yaml
2. rewrite SCP driver to reflect the change of dts node
3. add SCP core 1 node to mt8195.dtsi
4. remove redundant call of rproc_boot for SCP
5. refine IPI error message

v1 -> v2:
1. update dt-binding property description
2. remove kconfig for scp dual driver
3. merge mtk_scp_dual.c and mtk_scp_subdev.c to mtk_scp.c

Tinghan Shen (11):
dt-bindings: remoteproc: mediatek: Give the subnode a persistent name
dt-bindings: remoteproc: mediatek: Support MT8195 dual-core SCP
arm64: dts: mt8195: Add SCP core 1 node
remoteproc: mediatek: Remove redundant rproc_boot
remoteproc: mediatek: Add SCP core 1 register definitions
remoteproc: mediatek: Add MT8195 SCP core 1 operations
remoteproc: mediatek: Probe MT8195 SCP core 1
remoteproc: mediatek: Control SCP core 1 boot by rproc subdevice
remoteproc: mediatek: Setup MT8195 SCP core 1 SRAM offset
remoteproc: mediatek: Handle MT8195 SCP core 1 watchdog timeout
remoteproc: mediatek: Refine ipi handler error message

 .../bindings/remoteproc/mtk,scp.yaml          | 132 ++++++++--
 .../arm64/boot/dts/mediatek/mt8183-kukui.dtsi |   2 +-
 arch/arm64/boot/dts/mediatek/mt8195.dtsi      |  14 +-
 .../mediatek/vcodec/mtk_vcodec_fw_scp.c       |   2 +-
 drivers/remoteproc/mtk_common.h               |  35 +++
 drivers/remoteproc/mtk_scp.c                  | 241 +++++++++++++++++-
 include/linux/remoteproc/mtk_scp.h            |   1 +
 7 files changed, 397 insertions(+), 30 deletions(-)
Signature · 1 line
2.18.0
#29 lore raw
Quoted 8 lines · Mathieu Poirier

Good day,

A lot of comments related to the handling of SCP 0 and 1 have already been made on this patchset, along with my own advice from the previous patchset on how to move forward. As such I will wait for a new revision.

Thanks,
Mathieu

Sorry for late response.
I'll update the series based on all of your comments. Thank you!

Quoted 44 lines · Tinghan Shen
Quoted 42 lines

The mediatek remoteproc driver currently only allows bringing up a single core SCP, e.g. MT8183. It also only bringing up the 1st core in SoCs with a dual-core SCP, e.g. MT8195. This series support to bring-up the 2nd core of the dual-core SCP.

v2 -> v3:
1. change the representation of dual-core SCP in dts file and update SCP yaml
2. rewrite SCP driver to reflect the change of dts node
3. add SCP core 1 node to mt8195.dtsi
4. remove redundant call of rproc_boot for SCP
5. refine IPI error message

v1 -> v2:
1. update dt-binding property description
2. remove kconfig for scp dual driver
3. merge mtk_scp_dual.c and mtk_scp_subdev.c to mtk_scp.c

Tinghan Shen (11):
dt-bindings: remoteproc: mediatek: Give the subnode a persistent name
dt-bindings: remoteproc: mediatek: Support MT8195 dual-core SCP
arm64: dts: mt8195: Add SCP core 1 node
remoteproc: mediatek: Remove redundant rproc_boot
remoteproc: mediatek: Add SCP core 1 register definitions
remoteproc: mediatek: Add MT8195 SCP core 1 operations
remoteproc: mediatek: Probe MT8195 SCP core 1
remoteproc: mediatek: Control SCP core 1 boot by rproc subdevice
remoteproc: mediatek: Setup MT8195 SCP core 1 SRAM offset
remoteproc: mediatek: Handle MT8195 SCP core 1 watchdog timeout
remoteproc: mediatek: Refine ipi handler error message

 .../bindings/remoteproc/mtk,scp.yaml          | 132 ++++++++--
 .../arm64/boot/dts/mediatek/mt8183-kukui.dtsi |   2 +-
 arch/arm64/boot/dts/mediatek/mt8195.dtsi      |  14 +-
 .../mediatek/vcodec/mtk_vcodec_fw_scp.c       |   2 +-
 drivers/remoteproc/mtk_common.h               |  35 +++
 drivers/remoteproc/mtk_scp.c                  | 241 +++++++++++++++++-
 include/linux/remoteproc/mtk_scp.h            |   1 +
 7 files changed, 397 insertions(+), 30 deletions(-)
Signature · 1 line
2.18.0
Signature · 2 lines
Best regards,
TingHan