devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] MediaTek GCE json-schema and multi-gce clocks
@ 2022-05-24 15:15 AngeloGioacchino Del Regno
  2022-05-24 15:15 ` [PATCH v2 1/2] dt-bindings: mailbox: mtk-gce: Convert txt to json-schema AngeloGioacchino Del Regno
  2022-05-24 15:15 ` [PATCH v2 2/2] mailbox: mtk-cmdq-mailbox: Simplify getting multi-gce clocks AngeloGioacchino Del Regno
  0 siblings, 2 replies; 4+ messages in thread
From: AngeloGioacchino Del Regno @ 2022-05-24 15:15 UTC (permalink / raw)
  To: jassisinghbrar
  Cc: robh+dt, krzysztof.kozlowski+dt, matthias.bgg, houlong.wei,
	linux-kernel, devicetree, linux-arm-kernel, linux-mediatek,
	AngeloGioacchino Del Regno

v1 of "dt-bindings: mailbox: mtk-gce: Convert txt to json-schema"
exposed some readability issues for the mtk-cmdq-mailbox driver but,
upon further inspection, I've found that there is a shorter way to
achieve the Multi-GCE support as it's limited to simply managing two
clocks instead of one.

This series converts the mtk-gce freeform documentation to json-schema
and adds a second clock for the dual-gce (multi-gce) case, as to stop
looking for aliases in the entire devicetree to get clocks from the
secondary GCE node: declaring both clocks on both nodes is simply the
right thing to do, as operating one GCE Mailbox requires both clocks
to be enabled, since there may be interop between the two GCEs.

For now, the only Dual-GCE SoC is MT8195, for which no devicetree is
upstream yet.

AngeloGioacchino Del Regno (2):
  dt-bindings: mailbox: mtk-gce: Convert txt to json-schema
  mailbox: mtk-cmdq-mailbox: Simplify getting multi-gce clocks

 .../bindings/mailbox/mediatek,gce-mbox.yaml   | 124 ++++++++++++++++++
 .../devicetree/bindings/mailbox/mtk-gce.txt   |  82 ------------
 drivers/mailbox/mtk-cmdq-mailbox.c            |  32 +----
 3 files changed, 131 insertions(+), 107 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mailbox/mediatek,gce-mbox.yaml
 delete mode 100644 Documentation/devicetree/bindings/mailbox/mtk-gce.txt

-- 
2.35.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/2] dt-bindings: mailbox: mtk-gce: Convert txt to json-schema
  2022-05-24 15:15 [PATCH v2 0/2] MediaTek GCE json-schema and multi-gce clocks AngeloGioacchino Del Regno
@ 2022-05-24 15:15 ` AngeloGioacchino Del Regno
  2022-05-26 12:54   ` Krzysztof Kozlowski
  2022-05-24 15:15 ` [PATCH v2 2/2] mailbox: mtk-cmdq-mailbox: Simplify getting multi-gce clocks AngeloGioacchino Del Regno
  1 sibling, 1 reply; 4+ messages in thread
From: AngeloGioacchino Del Regno @ 2022-05-24 15:15 UTC (permalink / raw)
  To: jassisinghbrar
  Cc: robh+dt, krzysztof.kozlowski+dt, matthias.bgg, houlong.wei,
	linux-kernel, devicetree, linux-arm-kernel, linux-mediatek,
	AngeloGioacchino Del Regno

Convert the mtk-gce documentation from freeform text format to a
json-schema.

Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
 .../bindings/mailbox/mediatek,gce-mbox.yaml   | 124 ++++++++++++++++++
 .../devicetree/bindings/mailbox/mtk-gce.txt   |  82 ------------
 2 files changed, 124 insertions(+), 82 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mailbox/mediatek,gce-mbox.yaml
 delete mode 100644 Documentation/devicetree/bindings/mailbox/mtk-gce.txt

diff --git a/Documentation/devicetree/bindings/mailbox/mediatek,gce-mbox.yaml b/Documentation/devicetree/bindings/mailbox/mediatek,gce-mbox.yaml
new file mode 100644
index 000000000000..bc64dac69f61
--- /dev/null
+++ b/Documentation/devicetree/bindings/mailbox/mediatek,gce-mbox.yaml
@@ -0,0 +1,124 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mailbox/mediatek,gce-mbox.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MediaTek Global Command Engine (GCE) mailbox
+
+maintainers:
+  - Houlong Wei <houlong.wei@mediatek.com>
+
+description: |
+  The Global Command Engine (GCE) is used to help read/write registers
+  with critical time limitation, such as updating display configuration
+  during the vblank.
+  The GCE can be used to implement the Command Queue (CMDQ) driver.
+  Values for properties used by the GCE, such as sub-system IDs, thread
+  priority and event IDs are defined in 'dt-bindings/gce/<chip>-gce.h'.
+
+properties:
+  compatible:
+    enum:
+      - mediatek,mt6779-gce
+      - mediatek,mt8173-gce
+      - mediatek,mt8183-gce
+      - mediatek,mt8186-gce
+      - mediatek,mt8192-gce
+      - mediatek,mt8195-gce
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks: true
+
+  clock-names: true
+
+  '#mbox-cells':
+    description: |
+      The first cell describes the mailbox channel, which is the GCE Thread ID;
+      The second cell describes the priority of the GCE thread.
+    const: 2
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+  - '#mbox-cells'
+
+additionalProperties: false
+
+if:
+  properties:
+    compatible:
+      contains:
+        enum:
+          - mediatek,mt8195-gce
+then:
+  properties:
+    clocks:
+      items:
+        - description: GCE0 clock for Multi-GCE
+        - description: GCE1 clock for Multi-GCE
+
+    clock-names:
+      items:
+        - const: gce0
+        - const: gce1
+else:
+  properties:
+    clocks:
+      items:
+        - description: GCE clock for Single-GCE
+
+    clock-names:
+      items:
+        - const: gce
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/clock/mt8173-clk.h>
+    #include <dt-bindings/gce/mt8173-gce.h>
+
+    soc {
+        #address-cells = <2>;
+        #size-cells = <2>;
+
+        gce: mailbox@10212000 {
+            compatible = "mediatek,mt8173-gce";
+            reg = <0 0x10212000 0 0x1000>;
+            interrupts = <GIC_SPI 135 IRQ_TYPE_LEVEL_LOW>;
+            clocks = <&infracfg CLK_INFRA_GCE>;
+            clock-names = "gce";
+            #mbox-cells = <2>;
+        };
+
+        /* Client device using a GCE Thread */
+        mmsys: syscon@14000000 {
+            compatible = "mediatek,mt8173-mmsys", "syscon";
+            reg = <0 0x14000000 0 0x1000>;
+            mboxes = <&gce 0 CMDQ_THR_PRIO_HIGHEST>,
+                     <&gce 1 CMDQ_THR_PRIO_HIGHEST>;
+            mediatek,gce-client-reg = <&gce SUBSYS_1400XXXX 0 0x1000>;
+            #clock-cells = <1>;
+            #reset-cells = <1>;
+        };
+
+        /* Client device listening to specific GCE Events */
+        mutex: mutex@14020000 {
+            compatible = "mediatek,mt8173-disp-mutex";
+            reg = <0 0x14020000 0 0x1000>;
+            interrupts = <GIC_SPI 169 IRQ_TYPE_LEVEL_LOW>;
+            power-domains = <&spm 1>;
+            clocks = <&mmsys CLK_MM_MUTEX_32K>;
+            mediatek,gce-events = <CMDQ_EVENT_MUTEX0_STREAM_EOF>,
+                                  <CMDQ_EVENT_MUTEX1_STREAM_EOF>;
+        };
+    };
diff --git a/Documentation/devicetree/bindings/mailbox/mtk-gce.txt b/Documentation/devicetree/bindings/mailbox/mtk-gce.txt
deleted file mode 100644
index c2aeba63bd47..000000000000
--- a/Documentation/devicetree/bindings/mailbox/mtk-gce.txt
+++ /dev/null
@@ -1,82 +0,0 @@
-MediaTek GCE
-===============
-
-The Global Command Engine (GCE) is used to help read/write registers with
-critical time limitation, such as updating display configuration during the
-vblank. The GCE can be used to implement the Command Queue (CMDQ) driver.
-
-CMDQ driver uses mailbox framework for communication. Please refer to
-mailbox.txt for generic information about mailbox device-tree bindings.
-
-Required properties:
-- compatible: can be "mediatek,mt8173-gce", "mediatek,mt8183-gce",
-  "mediatek,mt8186-gce", "mediatek,mt8192-gce", "mediatek,mt8195-gce" or
-  "mediatek,mt6779-gce".
-- reg: Address range of the GCE unit
-- interrupts: The interrupt signal from the GCE block
-- clock: Clocks according to the common clock binding
-- clock-names: Must be "gce" to stand for GCE clock
-- #mbox-cells: Should be 2.
-	<&phandle channel priority>
-	phandle: Label name of a gce node.
-	channel: Channel of mailbox. Be equal to the thread id of GCE.
-	priority: Priority of GCE thread.
-
-Required properties for a client device:
-- mboxes: Client use mailbox to communicate with GCE, it should have this
-  property and list of phandle, mailbox specifiers.
-Optional properties for a client device:
-- mediatek,gce-client-reg: Specify the sub-system id which is corresponding
-  to the register address, it should have this property and list of phandle,
-  sub-system specifiers.
-  <&phandle subsys_number start_offset size>
-  phandle: Label name of a gce node.
-  subsys_number: specify the sub-system id which is corresponding
-                 to the register address.
-  start_offset: the start offset of register address that GCE can access.
-  size: the total size of register address that GCE can access.
-
-Optional properties for a client mutex node:
-- mediatek,gce-events: GCE events used by clients. The event numbers are
-  defined in 'dt-bindings/gce/<chip>-gce.h'.
-
-Some vaules of properties are defined in 'dt-bindings/gce/mt8173-gce.h',
-'dt-bindings/gce/mt8183-gce.h', 'dt-bindings/gce/mt8186-gce.h'
-'dt-bindings/gce/mt8192-gce.h', 'dt-bindings/gce/mt8195-gce.h' or
-'dt-bindings/gce/mt6779-gce.h'.
-Such as sub-system ids, thread priority, event ids.
-
-Example:
-
-	gce: gce@10212000 {
-		compatible = "mediatek,mt8173-gce";
-		reg = <0 0x10212000 0 0x1000>;
-		interrupts = <GIC_SPI 135 IRQ_TYPE_LEVEL_LOW>;
-		clocks = <&infracfg CLK_INFRA_GCE>;
-		clock-names = "gce";
-		#mbox-cells = <2>;
-	};
-
-Example for a client device:
-
-	mmsys: clock-controller@14000000 {
-		compatible = "mediatek,mt8173-mmsys";
-		mboxes = <&gce 0 CMDQ_THR_PRIO_LOWEST>,
-			 <&gce 1 CMDQ_THR_PRIO_LOWEST>;
-		mutex-event-eof = <CMDQ_EVENT_MUTEX0_STREAM_EOF
-				CMDQ_EVENT_MUTEX1_STREAM_EOF>;
-		mediatek,gce-client-reg = <&gce SUBSYS_1400XXXX 0x3000 0x1000>,
-					  <&gce SUBSYS_1401XXXX 0x2000 0x100>;
-		...
-	};
-
-Example for a client mutex node:
-	mutex: mutex@14020000 {
-		compatible = "mediatek,mt8173-disp-mutex";
-		reg = <0 0x14020000 0 0x1000>;
-		interrupts = <GIC_SPI 169 IRQ_TYPE_LEVEL_LOW>;
-		power-domains = <&scpsys MT8173_POWER_DOMAIN_MM>;
-		clocks = <&mmsys CLK_MM_MUTEX_32K>;
-		mediatek,gce-events = <CMDQ_EVENT_MUTEX0_STREAM_EOF>,
-				      <CMDQ_EVENT_MUTEX1_STREAM_EOF>;
-	};
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] mailbox: mtk-cmdq-mailbox: Simplify getting multi-gce clocks
  2022-05-24 15:15 [PATCH v2 0/2] MediaTek GCE json-schema and multi-gce clocks AngeloGioacchino Del Regno
  2022-05-24 15:15 ` [PATCH v2 1/2] dt-bindings: mailbox: mtk-gce: Convert txt to json-schema AngeloGioacchino Del Regno
@ 2022-05-24 15:15 ` AngeloGioacchino Del Regno
  1 sibling, 0 replies; 4+ messages in thread
From: AngeloGioacchino Del Regno @ 2022-05-24 15:15 UTC (permalink / raw)
  To: jassisinghbrar
  Cc: robh+dt, krzysztof.kozlowski+dt, matthias.bgg, houlong.wei,
	linux-kernel, devicetree, linux-arm-kernel, linux-mediatek,
	AngeloGioacchino Del Regno

Instead of looking for gceX aliases across the entire devicetree and
getting clocks by then reading these nodes with of_clk_get(), since
the maximum number of GCEs is two, it is more convenient to simply
assign two clocks to both of the GCE nodes.

Luckily, as of now, there is no devicetree for any multi-gce device
upstream: remove the aforementioned mechanism in favor of getting
both "gce0" and "gce1" clocks with devm_clk_bulk_get() instead.

Compatibility with single-gce mailboxes is retained by assigning
only one id to the clk_bulk_data, as the number of clocks to handle
is already signaled by the "gce_num" member of struct cmdq.

While at it, also beautify the clocks get failure message.

Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
 drivers/mailbox/mtk-cmdq-mailbox.c | 32 +++++++-----------------------
 1 file changed, 7 insertions(+), 25 deletions(-)

diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c
index 2578e5aaa935..89a0fdde730c 100644
--- a/drivers/mailbox/mtk-cmdq-mailbox.c
+++ b/drivers/mailbox/mtk-cmdq-mailbox.c
@@ -527,11 +527,6 @@ static int cmdq_probe(struct platform_device *pdev)
 	struct cmdq *cmdq;
 	int err, i;
 	struct gce_plat *plat_data;
-	struct device_node *phandle = dev->of_node;
-	struct device_node *node;
-	int alias_id = 0;
-	static const char * const clk_name = "gce";
-	static const char * const clk_names[] = { "gce0", "gce1" };
 
 	cmdq = devm_kzalloc(dev, sizeof(*cmdq), GFP_KERNEL);
 	if (!cmdq)
@@ -567,29 +562,16 @@ static int cmdq_probe(struct platform_device *pdev)
 		dev, cmdq->base, cmdq->irq);
 
 	if (cmdq->gce_num > 1) {
-		for_each_child_of_node(phandle->parent, node) {
-			alias_id = of_alias_get_id(node, clk_name);
-			if (alias_id >= 0 && alias_id < cmdq->gce_num) {
-				cmdq->clocks[alias_id].id = clk_names[alias_id];
-				cmdq->clocks[alias_id].clk = of_clk_get(node, 0);
-				if (IS_ERR(cmdq->clocks[alias_id].clk)) {
-					of_node_put(node);
-					return dev_err_probe(dev,
-							     PTR_ERR(cmdq->clocks[alias_id].clk),
-							     "failed to get gce clk: %d\n",
-							     alias_id);
-				}
-			}
-		}
+		cmdq->clocks[0].id = "gce0";
+		cmdq->clocks[1].id = "gce1";
 	} else {
-		cmdq->clocks[alias_id].id = clk_name;
-		cmdq->clocks[alias_id].clk = devm_clk_get(&pdev->dev, clk_name);
-		if (IS_ERR(cmdq->clocks[alias_id].clk)) {
-			return dev_err_probe(dev, PTR_ERR(cmdq->clocks[alias_id].clk),
-					     "failed to get gce clk\n");
-		}
+		cmdq->clocks[0].id = "gce";
 	}
 
+	err = devm_clk_bulk_get(&pdev->dev, cmdq->gce_num, cmdq->clocks);
+	if (err)
+		return dev_err_probe(dev, err, "Failed to get GCE clocks\n");
+
 	cmdq->mbox.dev = dev;
 	cmdq->mbox.chans = devm_kcalloc(dev, cmdq->thread_nr,
 					sizeof(*cmdq->mbox.chans), GFP_KERNEL);
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/2] dt-bindings: mailbox: mtk-gce: Convert txt to json-schema
  2022-05-24 15:15 ` [PATCH v2 1/2] dt-bindings: mailbox: mtk-gce: Convert txt to json-schema AngeloGioacchino Del Regno
@ 2022-05-26 12:54   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2022-05-26 12:54 UTC (permalink / raw)
  To: AngeloGioacchino Del Regno, jassisinghbrar
  Cc: robh+dt, krzysztof.kozlowski+dt, matthias.bgg, houlong.wei,
	linux-kernel, devicetree, linux-arm-kernel, linux-mediatek

On 24/05/2022 17:15, AngeloGioacchino Del Regno wrote:
> Convert the mtk-gce documentation from freeform text format to a
> json-schema.
> 
> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> ---
>  .../bindings/mailbox/mediatek,gce-mbox.yaml   | 124 ++++++++++++++++++
>  .../devicetree/bindings/mailbox/mtk-gce.txt   |  82 ------------
>  2 files changed, 124 insertions(+), 82 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/mailbox/mediatek,gce-mbox.yaml
>  delete mode 100644 Documentation/devicetree/bindings/mailbox/mtk-gce.txt
> 


Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>


Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-05-26 12:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-24 15:15 [PATCH v2 0/2] MediaTek GCE json-schema and multi-gce clocks AngeloGioacchino Del Regno
2022-05-24 15:15 ` [PATCH v2 1/2] dt-bindings: mailbox: mtk-gce: Convert txt to json-schema AngeloGioacchino Del Regno
2022-05-26 12:54   ` Krzysztof Kozlowski
2022-05-24 15:15 ` [PATCH v2 2/2] mailbox: mtk-cmdq-mailbox: Simplify getting multi-gce clocks AngeloGioacchino Del Regno

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).