Skip to contentSkip to conversation

NVIDIA Tegra NVDEC support

PATCH Superseded Mikko Perttunen 3 participants 8 messages Sep 3, 2021 – Sep 7, 2021

Subsystems (5)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Mikko Perttunen

author maintainer
#0 lore raw

v4 cover NVIDIA Tegra NVDEC support

Here's the v4 of the NVDEC support series, containing two fixes compared to v3:

* Fixed incorrect compatibility string in bindings YAML
* Added dma-coherent markers to Tegra194 device trees.

NVDEC hardware documentation can be found at
https://github.com/NVIDIA/open-gpu-doc/tree/master/classes/video

and example userspace can be found at
https://github.com/cyndis/vaapi-tegra-driver

Thanks,
Mikko

Mikko Perttunen (3):
dt-bindings: Add YAML bindings for NVDEC
arm64: tegra: Add NVDEC to Tegra186/194 device trees drm/tegra: Add NVDEC driver

 .../gpu/host1x/nvidia,tegra210-nvdec.yaml     | 109 ++++
 MAINTAINERS                                   |   1 +
 arch/arm64/boot/dts/nvidia/tegra186.dtsi      |  16 +
 arch/arm64/boot/dts/nvidia/tegra194.dtsi      |  38 ++
 drivers/gpu/drm/tegra/Makefile                |   3 +-
 drivers/gpu/drm/tegra/drm.c                   |   4 +
 drivers/gpu/drm/tegra/drm.h                   |   1 +
 drivers/gpu/drm/tegra/nvdec.c                 | 474 ++++++++++++++++++
 drivers/gpu/host1x/dev.c                      |  18 +
 include/linux/host1x.h                        |   2 +
 10 files changed, 665 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/gpu/host1x/nvidia,tegra210-nvdec.yaml
 create mode 100644 drivers/gpu/drm/tegra/nvdec.c
Signature · 1 line
2.32.0
author maintainer
#1 lore raw

PATCH v4 1/3 dt-bindings: Add YAML bindings for NVDEC

Add YAML device tree bindings for NVDEC, now in a more appropriate place compared to the old textual Host1x bindings.

---
v4:
* Fix incorrect compatibility string in 'if' condition v3:
* Drop host1x bindings
* Change read2 to read-1 in interconnect names v2:
* Fix issues pointed out in v1
* Add T194 nvidia,instance property

---
 .../gpu/host1x/nvidia,tegra210-nvdec.yaml     | 109 ++++++++++++++++++
 MAINTAINERS                                   |   1 +
 2 files changed, 110 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpu/host1x/nvidia,tegra210-nvdec.yaml
Documentation/devicetree/bindings/gpu/host1x/nvidia,tegra210-nvdec.yaml new file +109 -0
new file mode 100644
index 000000000000..33d01c7dc759
@@ -0,0 +1,109 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/gpu/host1x/nvidia,tegra210-nvdec.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: Device tree binding for NVIDIA Tegra NVDEC
+
+description: |
+  NVDEC is the hardware video decoder present on NVIDIA Tegra210
+  and newer chips. It is located on the Host1x bus and typically
+  programmed through Host1x channels.
+
+maintainers:
+  - Thierry Reding <[email protected]>
+  - Mikko Perttunen <[email protected]>
+
+properties:
+  $nodename:
+    pattern: "^nvdec@[0-9a-f]*$"
+
+  compatible:
+    enum:
+      - nvidia,tegra210-nvdec
+      - nvidia,tegra186-nvdec
+      - nvidia,tegra194-nvdec
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  clock-names:
+    items:
+      - const: nvdec
+
+  resets:
+    maxItems: 1
+
+  reset-names:
+    items:
+      - const: nvdec
+
+  power-domains:
+    maxItems: 1
+
+  iommus:
+    maxItems: 1
+
+  interconnects:
+    items:
+      - description: DMA read memory client
+      - description: DMA read 2 memory client
+      - description: DMA write memory client
+
+  interconnect-names:
+    items:
+      - const: dma-mem
+      - const: read-1
+      - const: write
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - resets
+  - reset-names
+  - power-domains
+
+if:
+  properties:
+    compatible:
+      contains:
+        const: nvidia,tegra194-nvdec
+then:
+  properties:
+    nvidia,instance:
+      items:
+        - description: 0 for NVDEC0, or 1 for NVDEC1
+
+additionalProperties: true
+
+examples:
+  - |
+    #include <dt-bindings/clock/tegra186-clock.h>
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/memory/tegra186-mc.h>
+    #include <dt-bindings/power/tegra186-powergate.h>
+    #include <dt-bindings/reset/tegra186-reset.h>
+
+    nvdec@15480000 {
+            compatible = "nvidia,tegra186-nvdec";
+            reg = <0x15480000 0x40000>;
+            clocks = <&bpmp TEGRA186_CLK_NVDEC>;
+            clock-names = "nvdec";
+            resets = <&bpmp TEGRA186_RESET_NVDEC>;
+            reset-names = "nvdec";
+
+            power-domains = <&bpmp TEGRA186_POWER_DOMAIN_NVDEC>;
+            interconnects = <&mc TEGRA186_MEMORY_CLIENT_NVDECSRD &emc>,
+                            <&mc TEGRA186_MEMORY_CLIENT_NVDECSRD1 &emc>,
+                            <&mc TEGRA186_MEMORY_CLIENT_NVDECSWR &emc>;
+            interconnect-names = "dma-mem", "read-1", "write";
+            iommus = <&smmu TEGRA186_SID_NVDEC>;
+    };
+
+
MAINTAINERS +1 -0
index 69932194e1ba..ce9e360639d5 100644
@@ -6230,6 +6230,7 @@ L:	[email protected]
 S:	Supported
 T:	git git://anongit.freedesktop.org/tegra/linux.git
 F:	Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.txt
+F:	Documentation/devicetree/bindings/gpu/host1x/
 F:	drivers/gpu/drm/tegra/
 F:	drivers/gpu/host1x/
 F:	include/linux/host1x.h
Signature · 1 line
2.32.0
maintainer
#2 lore raw

Re: [PATCH v4 1/3] dt-bindings: Add YAML bindings for NVDEC

Quoted 13 lines · Mikko Perttunen

Add YAML device tree bindings for NVDEC, now in a more appropriate place compared to the old textual Host1x bindings.

---
v4:
* Fix incorrect compatibility string in 'if' condition v3:
* Drop host1x bindings
* Change read2 to read-1 in interconnect names v2:
* Fix issues pointed out in v1
* Add T194 nvidia,instance property

Quoted 6 lines
---
 .../gpu/host1x/nvidia,tegra210-nvdec.yaml     | 109 ++++++++++++++++++
 MAINTAINERS                                   |   1 +
 2 files changed, 110 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpu/host1x/nvidia,tegra210-nvdec.yaml

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:
./Documentation/devicetree/bindings/gpu/host1x/nvidia,tegra210-nvdec.yaml:109:1: [warning] too many blank lines (2 > 1) (empty-lines)

dtschema/dtc warnings/errors:

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/patch/1524104

This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

Please check and re-submit.

maintainer
#3 lore raw

Re: [PATCH v4 1/3] dt-bindings: Add YAML bindings for NVDEC

In reply to Mikko Perttunen
Quoted 96 lines · Mikko Perttunen

Add YAML device tree bindings for NVDEC, now in a more appropriate place compared to the old textual Host1x bindings.

---
v4:
* Fix incorrect compatibility string in 'if' condition v3:
* Drop host1x bindings
* Change read2 to read-1 in interconnect names v2:
* Fix issues pointed out in v1
* Add T194 nvidia,instance property

---
 .../gpu/host1x/nvidia,tegra210-nvdec.yaml     | 109 ++++++++++++++++++
 MAINTAINERS                                   |   1 +
 2 files changed, 110 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpu/host1x/nvidia,tegra210-nvdec.yaml
Documentation/devicetree/bindings/gpu/host1x/nvidia,tegra210-nvdec.yaml new file +71 -0
new file mode 100644
index 000000000000..33d01c7dc759
@@ -0,0 +1,109 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/gpu/host1x/nvidia,tegra210-nvdec.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: Device tree binding for NVIDIA Tegra NVDEC
+
+description: |
+  NVDEC is the hardware video decoder present on NVIDIA Tegra210
+  and newer chips. It is located on the Host1x bus and typically
+  programmed through Host1x channels.
+
+maintainers:
+  - Thierry Reding <[email protected]>
+  - Mikko Perttunen <[email protected]>
+
+properties:
+  $nodename:
+    pattern: "^nvdec@[0-9a-f]*$"
+
+  compatible:
+    enum:
+      - nvidia,tegra210-nvdec
+      - nvidia,tegra186-nvdec
+      - nvidia,tegra194-nvdec
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  clock-names:
+    items:
+      - const: nvdec
+
+  resets:
+    maxItems: 1
+
+  reset-names:
+    items:
+      - const: nvdec
+
+  power-domains:
+    maxItems: 1
+
+  iommus:
+    maxItems: 1
+
+  interconnects:
+    items:
+      - description: DMA read memory client
+      - description: DMA read 2 memory client
+      - description: DMA write memory client
+
+  interconnect-names:
+    items:
+      - const: dma-mem
+      - const: read-1
+      - const: write
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - resets
+  - reset-names
+  - power-domains
+

Documentation/devicetree/bindings/gpu/host1x/nvidia,tegra210-nvdec.yaml line 81

Quoted 10 lines
Documentation/devicetree/bindings/gpu/host1x/nvidia,tegra210-nvdec.yaml new file +10 -0
+if:
+  properties:
+    compatible:
+      contains:
+        const: nvidia,tegra194-nvdec
+then:
+  properties:
+    nvidia,instance:
+      items:
+        - description: 0 for NVDEC0, or 1 for NVDEC1

I still don't understand what this is needed for. What is the difference between the instances? There must be some reason you care. We should describe that difference, not some made up index.

I'm not suggesting using the base address either. That's fragile too.

Documentation/devicetree/bindings/gpu/host1x/nvidia,tegra210-nvdec.yaml line 83

Quoted 2 lines
Documentation/devicetree/bindings/gpu/host1x/nvidia,tegra210-nvdec.yaml new file +2 -0
+
+additionalProperties: true

'true' here is not allowed unless the schema is not complete and intended to be included in a complete schema or unconditionally applied (i.e. 'select: true'). This case is neither. As pointed out previously, 'unevaluatedProperties' is what you'd want here.

However, I looked into supporting defining properties in if/then/else schemas as you have done and I don't think we will support that soon. It's problematic because we can't validate the schema under the if/then completely. The reason is properties under if/then schemas don't have to be complete as we expect a top level definition that is complete (e.g. vendor properties must have 'description'). To solve this, we'd have to only apply meta-schema checks if the property doesn't appear at the top level. That's more complicated than I care to implement ATM.

Rob

#4 lore raw

Re: [PATCH v4 1/3] dt-bindings: Add YAML bindings for NVDEC

Quoted 112 lines · Rob Herring
Quoted 96 lines · Mikko Perttunen

Add YAML device tree bindings for NVDEC, now in a more appropriate place compared to the old textual Host1x bindings.

---
v4:
* Fix incorrect compatibility string in 'if' condition v3:
* Drop host1x bindings
* Change read2 to read-1 in interconnect names v2:
* Fix issues pointed out in v1
* Add T194 nvidia,instance property

---
  .../gpu/host1x/nvidia,tegra210-nvdec.yaml     | 109 ++++++++++++++++++
  MAINTAINERS                                   |   1 +
  2 files changed, 110 insertions(+)

create mode 100644 Documentation/devicetree/bindings/gpu/host1x/nvidia,tegra210-nvdec.yaml

Documentation/devicetree/bindings/gpu/host1x/nvidia,tegra210-nvdec.yaml new file +71 -0
new file mode 100644
index 000000000000..33d01c7dc759
@@ -0,0 +1,109 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/gpu/host1x/nvidia,tegra210-nvdec.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: Device tree binding for NVIDIA Tegra NVDEC
+
+description: |
+  NVDEC is the hardware video decoder present on NVIDIA Tegra210
+  and newer chips. It is located on the Host1x bus and typically
+  programmed through Host1x channels.
+
+maintainers:
+  - Thierry Reding <[email protected]>
+  - Mikko Perttunen <[email protected]>
+
+properties:
+  $nodename:
+    pattern: "^nvdec@[0-9a-f]*$"
+
+  compatible:
+    enum:
+      - nvidia,tegra210-nvdec
+      - nvidia,tegra186-nvdec
+      - nvidia,tegra194-nvdec
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  clock-names:
+    items:
+      - const: nvdec
+
+  resets:
+    maxItems: 1
+
+  reset-names:
+    items:
+      - const: nvdec
+
+  power-domains:
+    maxItems: 1
+
+  iommus:
+    maxItems: 1
+
+  interconnects:
+    items:
+      - description: DMA read memory client
+      - description: DMA read 2 memory client
+      - description: DMA write memory client
+
+  interconnect-names:
+    items:
+      - const: dma-mem
+      - const: read-1
+      - const: write
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - resets
+  - reset-names
+  - power-domains
+

Documentation/devicetree/bindings/gpu/host1x/nvidia,tegra210-nvdec.yaml line 81

Quoted 10 lines
Documentation/devicetree/bindings/gpu/host1x/nvidia,tegra210-nvdec.yaml new file +10 -0
+if:
+  properties:
+    compatible:
+      contains:
+        const: nvidia,tegra194-nvdec
+then:
+  properties:
+    nvidia,instance:
+      items:
+        - description: 0 for NVDEC0, or 1 for NVDEC1

I still don't understand what this is needed for. What is the difference between the instances? There must be some reason you care. We should describe that difference, not some made up index.

Quoted 1 line

I'm not suggesting using the base address either. That's fragile too.

This device is on the Host1x bus. On that bus, each device has an identifier baked into hardware called 'class' that is used when accessing devices through some mechanisms (host1x channels). As such, when probing the device we need to specify the class of the device to the host1x driver so it knows how to talk to it. Those class numbers are fixed so we have hardcoded them in the driver, but now that we have two NVDECs, we need to distinguish between them so that we can specify the correct class for each instance to the host1x driver.

Quoted 9 lines

Documentation/devicetree/bindings/gpu/host1x/nvidia,tegra210-nvdec.yaml line 83

Quoted 3 lines
Documentation/devicetree/bindings/gpu/host1x/nvidia,tegra210-nvdec.yaml new file +2 -0
+
+additionalProperties: true

'true' here is not allowed unless the schema is not complete and intended to be included in a complete schema or unconditionally applied (i.e. 'select: true'). This case is neither. As pointed out previously, 'unevaluatedProperties' is what you'd want here.

Quoted 8 lines

However, I looked into supporting defining properties in if/then/else schemas as you have done and I don't think we will support that soon. It's problematic because we can't validate the schema under the if/then completely. The reason is properties under if/then schemas don't have to be complete as we expect a top level definition that is complete (e.g. vendor properties must have 'description'). To solve this, we'd have to only apply meta-schema checks if the property doesn't appear at the top level. That's more complicated than I care to implement ATM.

I see two paths here: either keep 'additionalProperties: true' or remove it and have this binding trigger validation failures. Which one do you suggest or is there some third option?

Thanks,
Mikko

Quoted 3 lines

Rob

maintainer
#5 lore raw

Re: [PATCH v4 1/3] dt-bindings: Add YAML bindings for NVDEC

Quoted 116 lines · Mikko Perttunen
Quoted 112 lines · Rob Herring
Quoted 96 lines · Mikko Perttunen

Add YAML device tree bindings for NVDEC, now in a more appropriate place compared to the old textual Host1x bindings.

---
v4:
* Fix incorrect compatibility string in 'if' condition v3:
* Drop host1x bindings
* Change read2 to read-1 in interconnect names v2:
* Fix issues pointed out in v1
* Add T194 nvidia,instance property

---
  .../gpu/host1x/nvidia,tegra210-nvdec.yaml     | 109 ++++++++++++++++++
  MAINTAINERS                                   |   1 +
  2 files changed, 110 insertions(+)

create mode 100644 Documentation/devicetree/bindings/gpu/host1x/nvidia,tegra210-nvdec.yaml

Documentation/devicetree/bindings/gpu/host1x/nvidia,tegra210-nvdec.yaml new file +71 -0
new file mode 100644
index 000000000000..33d01c7dc759
@@ -0,0 +1,109 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/gpu/host1x/nvidia,tegra210-nvdec.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: Device tree binding for NVIDIA Tegra NVDEC
+
+description: |
+  NVDEC is the hardware video decoder present on NVIDIA Tegra210
+  and newer chips. It is located on the Host1x bus and typically
+  programmed through Host1x channels.
+
+maintainers:
+  - Thierry Reding <[email protected]>
+  - Mikko Perttunen <[email protected]>
+
+properties:
+  $nodename:
+    pattern: "^nvdec@[0-9a-f]*$"
+
+  compatible:
+    enum:
+      - nvidia,tegra210-nvdec
+      - nvidia,tegra186-nvdec
+      - nvidia,tegra194-nvdec
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  clock-names:
+    items:
+      - const: nvdec
+
+  resets:
+    maxItems: 1
+
+  reset-names:
+    items:
+      - const: nvdec
+
+  power-domains:
+    maxItems: 1
+
+  iommus:
+    maxItems: 1
+
+  interconnects:
+    items:
+      - description: DMA read memory client
+      - description: DMA read 2 memory client
+      - description: DMA write memory client
+
+  interconnect-names:
+    items:
+      - const: dma-mem
+      - const: read-1
+      - const: write
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - resets
+  - reset-names
+  - power-domains
+

Documentation/devicetree/bindings/gpu/host1x/nvidia,tegra210-nvdec.yaml line 81

Quoted 10 lines
Documentation/devicetree/bindings/gpu/host1x/nvidia,tegra210-nvdec.yaml new file +10 -0
+if:
+  properties:
+    compatible:
+      contains:
+        const: nvidia,tegra194-nvdec
+then:
+  properties:
+    nvidia,instance:
+      items:
+        - description: 0 for NVDEC0, or 1 for NVDEC1

I still don't understand what this is needed for. What is the difference between the instances? There must be some reason you care. We should describe that difference, not some made up index.

Quoted 1 line

I'm not suggesting using the base address either. That's fragile too.

Quoted 8 lines

This device is on the Host1x bus. On that bus, each device has an identifier baked into hardware called 'class' that is used when accessing devices through some mechanisms (host1x channels). As such, when probing the device we need to specify the class of the device to the host1x driver so it knows how to talk to it. Those class numbers are fixed so we have hardcoded them in the driver, but now that we have two NVDECs, we need to distinguish between them so that we can specify the correct class for each instance to the host1x driver.

Then why don't you have a property like 'nvidia,host1x-class' containing the class number?

Quoted 16 lines
Quoted 7 lines

Documentation/devicetree/bindings/gpu/host1x/nvidia,tegra210-nvdec.yaml line 83

Quoted 1 line
Documentation/devicetree/bindings/gpu/host1x/nvidia,tegra210-nvdec.yaml new file +1 -0
+additionalProperties: true

'true' here is not allowed unless the schema is not complete and intended to be included in a complete schema or unconditionally applied (i.e. 'select: true'). This case is neither. As pointed out previously, 'unevaluatedProperties' is what you'd want here.

Quoted 8 lines

However, I looked into supporting defining properties in if/then/else schemas as you have done and I don't think we will support that soon. It's problematic because we can't validate the schema under the if/then completely. The reason is properties under if/then schemas don't have to be complete as we expect a top level definition that is complete (e.g. vendor properties must have 'description'). To solve this, we'd have to only apply meta-schema checks if the property doesn't appear at the top level. That's more complicated than I care to implement ATM.

Quoted 3 lines

I see two paths here: either keep 'additionalProperties: true' or remove it and have this binding trigger validation failures. Which one do you suggest or is there some third option?

Define the property at the top level, then restrict it in the if/then schema:

if:
properties:
compatible:
not:
contains:
const: nvidia,tegra194-nvdec
then:
properties:
nvidia,instance: false

(Or 'not: {required: [ nvidia,instance ]}' would work here, too)

With that, 'additionalProperties: false' will work.

Rob

author maintainer
#6 lore raw

PATCH v4 2/3 arm64: tegra: Add NVDEC to Tegra186/194 device trees

In reply to Mikko Perttunen

Add a device tree node for NVDEC on Tegra186, and device tree nodes for NVDEC and NVDEC1 on Tegra194.

---
v4:
* Add dma-coherent markers
v3:
* Change read2 to read-1
v2:
* Add NVDECSRD1 memory client
* Add also to T194 (both NVDEC0/1)

---
 arch/arm64/boot/dts/nvidia/tegra186.dtsi | 16 ++++++++++
 arch/arm64/boot/dts/nvidia/tegra194.dtsi | 38 ++++++++++++++++++++++++
 2 files changed, 54 insertions(+)
arch/arm64/boot/dts/nvidia/tegra186.dtsi +16 -0
index d02f6bf3e2ca..4f2f21242b2c 100644
@@ -1342,6 +1342,22 @@ dsib: dsi@15400000 {
 			power-domains = <&bpmp TEGRA186_POWER_DOMAIN_DISP>;
 		};
 
+		nvdec@15480000 {
+			compatible = "nvidia,tegra186-nvdec";
+			reg = <0x15480000 0x40000>;
+			clocks = <&bpmp TEGRA186_CLK_NVDEC>;
+			clock-names = "nvdec";
+			resets = <&bpmp TEGRA186_RESET_NVDEC>;
+			reset-names = "nvdec";
+
+			power-domains = <&bpmp TEGRA186_POWER_DOMAIN_NVDEC>;
+			interconnects = <&mc TEGRA186_MEMORY_CLIENT_NVDECSRD &emc>,
+					<&mc TEGRA186_MEMORY_CLIENT_NVDECSRD1 &emc>,
+					<&mc TEGRA186_MEMORY_CLIENT_NVDECSWR &emc>;
+			interconnect-names = "dma-mem", "read-1", "write";
+			iommus = <&smmu TEGRA186_SID_NVDEC>;
+		};
+
 		sor0: sor@15540000 {
 			compatible = "nvidia,tegra186-sor";
 			reg = <0x15540000 0x10000>;
arch/arm64/boot/dts/nvidia/tegra194.dtsi +38 -0
index 5ba7a4519b95..0e9713814583 100644
@@ -1412,6 +1412,25 @@ host1x@13e00000 {
 			interconnect-names = "dma-mem";
 			iommus = <&smmu TEGRA194_SID_HOST1X>;
 
+			nvdec@15140000 {
+				compatible = "nvidia,tegra194-nvdec";
+				reg = <0x15140000 0x00040000>;
+				clocks = <&bpmp TEGRA194_CLK_NVDEC1>;
+				clock-names = "nvdec";
+				resets = <&bpmp TEGRA194_RESET_NVDEC1>;
+				reset-names = "nvdec";
+
+				power-domains = <&bpmp TEGRA194_POWER_DOMAIN_NVDECB>;
+				interconnects = <&mc TEGRA194_MEMORY_CLIENT_NVDEC1SRD &emc>,
+						<&mc TEGRA194_MEMORY_CLIENT_NVDEC1SRD1 &emc>,
+						<&mc TEGRA194_MEMORY_CLIENT_NVDEC1SWR &emc>;
+				interconnect-names = "dma-mem", "read-1", "write";
+				iommus = <&smmu TEGRA194_SID_NVDEC1>;
+				dma-coherent;
+
+				nvidia,instance = <1>;
+			};
+
 			display-hub@15200000 {
 				compatible = "nvidia,tegra194-display";
 				reg = <0x15200000 0x00040000>;
@@ -1525,6 +1544,25 @@ vic@15340000 {
 				iommus = <&smmu TEGRA194_SID_VIC>;
 			};
 
+			nvdec@15480000 {
+				compatible = "nvidia,tegra194-nvdec";
+				reg = <0x15480000 0x00040000>;
+				clocks = <&bpmp TEGRA194_CLK_NVDEC>;
+				clock-names = "nvdec";
+				resets = <&bpmp TEGRA194_RESET_NVDEC>;
+				reset-names = "nvdec";
+
+				power-domains = <&bpmp TEGRA194_POWER_DOMAIN_NVDECA>;
+				interconnects = <&mc TEGRA194_MEMORY_CLIENT_NVDECSRD &emc>,
+						<&mc TEGRA194_MEMORY_CLIENT_NVDECSRD1 &emc>,
+						<&mc TEGRA194_MEMORY_CLIENT_NVDECSWR &emc>;
+				interconnect-names = "dma-mem", "read-1", "write";
+				iommus = <&smmu TEGRA194_SID_NVDEC>;
+				dma-coherent;
+
+				nvidia,instance = <0>;
+			};
+
 			dpaux0: dpaux@155c0000 {
 				compatible = "nvidia,tegra194-dpaux";
 				reg = <0x155c0000 0x10000>;
Signature · 1 line
2.32.0
author maintainer
#7 lore raw

PATCH v4 3/3 drm/tegra: Add NVDEC driver

In reply to Mikko Perttunen

Add support for booting and using NVDEC on Tegra210, Tegra186 and Tegra194 to the Host1x and TegraDRM drivers. Booting in secure mode is not currently supported.

---
v3:
* Change num_instances to unsigned int
* Remove unnecessary '= 0' initializer
* Populate num_instances data
* Fix instance number check
v2:
* Use devm_platform_get_and_ioremap_resource
* Remove reset handling, done by power domain code
* Assume runtime PM is enabled

---
 drivers/gpu/drm/tegra/Makefile |   3 +-
 drivers/gpu/drm/tegra/drm.c    |   4 +
 drivers/gpu/drm/tegra/drm.h    |   1 +
 drivers/gpu/drm/tegra/nvdec.c  | 474 +++++++++++++++++++++++++++++++++
 drivers/gpu/host1x/dev.c       |  18 ++
 include/linux/host1x.h         |   2 +
 6 files changed, 501 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/tegra/nvdec.c
drivers/gpu/drm/tegra/Makefile +2 -1
index 5d2039f0c734..b248c631f790 100644
@@ -24,7 +24,8 @@ tegra-drm-y := \
 	gr2d.o \
 	gr3d.o \
 	falcon.o \
-	vic.o
+	vic.o \
+	nvdec.o
 
 tegra-drm-y += trace.o
 
drivers/gpu/drm/tegra/drm.c +4 -0
index b20fd0833661..5f5afd7ba37e 100644
@@ -1337,15 +1337,18 @@ static const struct of_device_id host1x_drm_subdevs[] = {
 	{ .compatible = "nvidia,tegra210-sor", },
 	{ .compatible = "nvidia,tegra210-sor1", },
 	{ .compatible = "nvidia,tegra210-vic", },
+	{ .compatible = "nvidia,tegra210-nvdec", },
 	{ .compatible = "nvidia,tegra186-display", },
 	{ .compatible = "nvidia,tegra186-dc", },
 	{ .compatible = "nvidia,tegra186-sor", },
 	{ .compatible = "nvidia,tegra186-sor1", },
 	{ .compatible = "nvidia,tegra186-vic", },
+	{ .compatible = "nvidia,tegra186-nvdec", },
 	{ .compatible = "nvidia,tegra194-display", },
 	{ .compatible = "nvidia,tegra194-dc", },
 	{ .compatible = "nvidia,tegra194-sor", },
 	{ .compatible = "nvidia,tegra194-vic", },
+	{ .compatible = "nvidia,tegra194-nvdec", },
 	{ /* sentinel */ }
 };
 
@@ -1369,6 +1372,7 @@ static struct platform_driver * const drivers[] = {
 	&tegra_gr2d_driver,
 	&tegra_gr3d_driver,
 	&tegra_vic_driver,
+	&tegra_nvdec_driver,
 };
 
 static int __init host1x_drm_init(void)
drivers/gpu/drm/tegra/drm.h +1 -0
index 8b28327c931c..fc0a19554eac 100644
@@ -202,5 +202,6 @@ extern struct platform_driver tegra_sor_driver;
 extern struct platform_driver tegra_gr2d_driver;
 extern struct platform_driver tegra_gr3d_driver;
 extern struct platform_driver tegra_vic_driver;
+extern struct platform_driver tegra_nvdec_driver;
 
 #endif /* HOST1X_DRM_H */
drivers/gpu/drm/tegra/nvdec.c new file +474 -0

474 lines not on this page · raw message

drivers/gpu/host1x/dev.c +18 -0
index fbb6447b8659..e2ddf3fcaa9a 100644
@@ -132,6 +132,12 @@ static const struct host1x_sid_entry tegra186_sid_table[] = {
 		.offset = 0x30,
 		.limit = 0x34
 	},
+	{
+		/* NVDEC */
+		.base = 0x1b00,
+		.offset = 0x30,
+		.limit = 0x34
+	},
 };
 
 static const struct host1x_info host1x06_info = {
@@ -156,6 +162,18 @@ static const struct host1x_sid_entry tegra194_sid_table[] = {
 		.offset = 0x30,
 		.limit = 0x34
 	},
+	{
+		/* NVDEC */
+		.base = 0x1b00,
+		.offset = 0x30,
+		.limit = 0x34
+	},
+	{
+		/* NVDEC1 */
+		.base = 0x1bc0,
+		.offset = 0x30,
+		.limit = 0x34
+	},
 };
 
 static const struct host1x_info host1x07_info = {
include/linux/host1x.h +2 -0
index 9b6784708f2e..d7d415bcf78b 100644
@@ -15,6 +15,8 @@ enum host1x_class {
 	HOST1X_CLASS_GR2D_SB = 0x52,
 	HOST1X_CLASS_VIC = 0x5D,
 	HOST1X_CLASS_GR3D = 0x60,
+	HOST1X_CLASS_NVDEC = 0xF0,
+	HOST1X_CLASS_NVDEC1 = 0xF5,
 };
 
 struct host1x;
Signature · 1 line
2.32.0