linux-integrity.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/7] Clean up TPM compatibles
@ 2022-09-30 16:51 Alexander Steffen
  2022-09-30 16:51 ` [PATCH 1/7] dt-bindings: tpm: Introduce trivial-tpms.yaml Alexander Steffen
                   ` (4 more replies)
  0 siblings, 5 replies; 16+ messages in thread
From: Alexander Steffen @ 2022-09-30 16:51 UTC (permalink / raw)
  To: robh+dt, devicetree, jarkko, linux-integrity
  Cc: Alexander Steffen, Johannes.Holland, benoit.houyere, amirmizi6, peter

Not all TPM compatibles were documented correctly so far. Some were not
documented at all, others missed some properties, most of them did not use the
latest YAML format. But by design most TPMs are very similar, so this allows to
document them in a single trivial-tpms.yaml, similar to how
trivial-devices.yaml documents simple I2C and SPI devices. This fixes all the
documentation issues and ensures that dtbs_check can be used in the future to
detect incorrect configurations automatically.

Alexander Steffen (7):
  dt-bindings: tpm: Introduce trivial-tpms.yaml
  dt-bindings: tpm: Improve documentation of compatibles
  dt-bindings: tpm: Add previously undocumented properties
  dt-bindings: tpm: Merge existing trivial TPMs to YAML
  dt-bindings: tpm: Document previously undocumented compatibles
  dt-bindings: tpm: Add fallbacks for all TCG-compliant TPM variants
  tpm: Add missing compatibles to drivers

 .../bindings/security/tpm/google,cr50.txt     |  19 ---
 .../bindings/security/tpm/tpm-i2c.txt         |  26 ----
 .../bindings/security/tpm/tpm_tis_mmio.txt    |  25 ----
 .../bindings/security/tpm/tpm_tis_spi.txt     |  23 ----
 .../bindings/security/tpm/trivial-tpms.yaml   | 118 ++++++++++++++++++
 .../devicetree/bindings/trivial-devices.yaml  |  16 ---
 drivers/char/tpm/tpm_tis_i2c.c                |   2 +
 drivers/char/tpm/tpm_tis_spi_main.c           |   1 +
 8 files changed, 121 insertions(+), 109 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/security/tpm/google,cr50.txt
 delete mode 100644 Documentation/devicetree/bindings/security/tpm/tpm-i2c.txt
 delete mode 100644 Documentation/devicetree/bindings/security/tpm/tpm_tis_mmio.txt
 delete mode 100644 Documentation/devicetree/bindings/security/tpm/tpm_tis_spi.txt
 create mode 100644 Documentation/devicetree/bindings/security/tpm/trivial-tpms.yaml

-- 
2.25.1


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

* [PATCH 1/7] dt-bindings: tpm: Introduce trivial-tpms.yaml
  2022-09-30 16:51 [PATCH 0/7] Clean up TPM compatibles Alexander Steffen
@ 2022-09-30 16:51 ` Alexander Steffen
  2022-09-30 22:15   ` Rob Herring
  2022-09-30 16:51 ` [PATCH 2/7] dt-bindings: tpm: Improve documentation of compatibles Alexander Steffen
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 16+ messages in thread
From: Alexander Steffen @ 2022-09-30 16:51 UTC (permalink / raw)
  To: robh+dt, devicetree, jarkko, linux-integrity
  Cc: Alexander Steffen, Johannes.Holland, benoit.houyere, amirmizi6, peter

Most TPM devices are very similar and only need a few common properties
to describe them. However, they may use more properties than other
trivial I2C or SPI devices, e.g. powered-while-suspended. Therefore,
move them to their own trivial-tpms.yaml.

Signed-off-by: Alexander Steffen <Alexander.Steffen@infineon.com>
---
 .../bindings/security/tpm/trivial-tpms.yaml   | 54 +++++++++++++++++++
 .../devicetree/bindings/trivial-devices.yaml  | 16 ------
 2 files changed, 54 insertions(+), 16 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/security/tpm/trivial-tpms.yaml

diff --git a/Documentation/devicetree/bindings/security/tpm/trivial-tpms.yaml b/Documentation/devicetree/bindings/security/tpm/trivial-tpms.yaml
new file mode 100644
index 000000000000..fadd4ca96554
--- /dev/null
+++ b/Documentation/devicetree/bindings/security/tpm/trivial-tpms.yaml
@@ -0,0 +1,54 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/security/tpm/trivial-tpms.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Trivial TPM devices that have simple device tree bindings
+
+maintainers:
+  - linux-integrity@vger.kernel.org
+
+description: |
+  This is a list of trivial TPM devices that share the same properties and
+  therefore have simple device tree bindings.
+
+  If a device needs more specific bindings, such as properties to
+  describe some aspect of it, there needs to be a specific binding
+  document for it just like any other devices.
+
+properties:
+  reg:
+    maxItems: 1
+  interrupts:
+    maxItems: 1
+
+  spi-max-frequency: true
+
+  compatible:
+    contains:
+      enum:
+          # i2c trusted platform module (TPM)
+        - atmel,at97sc3204t
+          # Infineon SLB9635 (Soft-) I2C TPM (old protocol, max 100khz)
+        - infineon,slb9635tt
+          # Infineon SLB9645 I2C TPM (new protocol, max 400khz)
+        - infineon,slb9645tt
+          # Infineon SLB9673 I2C TPM 2.0
+        - infineon,slb9673
+          # i2c trusted platform module (TPM)
+        - nuvoton,npct501
+          # i2c trusted platform module (TPM2)
+        - nuvoton,npct601
+          # Socionext SynQuacer TPM MMIO module
+        - socionext,synquacer-tpm-mmio
+          # i2c trusted platform module (TPM)
+        - winbond,wpct301
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+...
diff --git a/Documentation/devicetree/bindings/trivial-devices.yaml b/Documentation/devicetree/bindings/trivial-devices.yaml
index 61746755c107..1cc7f82c0822 100644
--- a/Documentation/devicetree/bindings/trivial-devices.yaml
+++ b/Documentation/devicetree/bindings/trivial-devices.yaml
@@ -47,8 +47,6 @@ properties:
           - ams,iaq-core
             # i2c serial eeprom (24cxx)
           - at,24c08
-            # i2c trusted platform module (TPM)
-          - atmel,at97sc3204t
             # ATSHA204 - i2c h/w symmetric crypto module
           - atmel,atsha204
             # ATSHA204A - i2c h/w symmetric crypto module
@@ -135,12 +133,6 @@ properties:
           - infineon,ir38164
             # Infineon IR38263 Voltage Regulator
           - infineon,ir38263
-            # Infineon SLB9635 (Soft-) I2C TPM (old protocol, max 100khz)
-          - infineon,slb9635tt
-            # Infineon SLB9645 I2C TPM (new protocol, max 400khz)
-          - infineon,slb9645tt
-            # Infineon SLB9673 I2C TPM 2.0
-          - infineon,slb9673
             # Infineon TLV493D-A1B6 I2C 3D Magnetic Sensor
           - infineon,tlv493d-a1b6
             # Infineon Multi-phase Digital VR Controller xdpe11280
@@ -289,10 +281,6 @@ properties:
           - national,lm85
             # I2C ±0.33°C Accurate, 12-Bit + Sign Temperature Sensor and Thermal Window Comparator
           - national,lm92
-            # i2c trusted platform module (TPM)
-          - nuvoton,npct501
-            # i2c trusted platform module (TPM2)
-          - nuvoton,npct601
             # Nuvoton Temperature Sensor
           - nuvoton,w83773g
             # OKI ML86V7667 video decoder
@@ -327,8 +315,6 @@ properties:
           - silabs,si7020
             # Skyworks SKY81452: Six-Channel White LED Driver with Touch Panel Bias Supply
           - skyworks,sky81452
-            # Socionext SynQuacer TPM MMIO module
-          - socionext,synquacer-tpm-mmio
             # SparkFun Qwiic Joystick (COM-15168) with i2c interface
           - sparkfun,qwiic-joystick
             # i2c serial eeprom (24cxx)
@@ -383,8 +369,6 @@ properties:
           - winbond,w83793
             # Vicor Corporation Digital Supervisor
           - vicor,pli1209bc
-            # i2c trusted platform module (TPM)
-          - winbond,wpct301
 
 required:
   - compatible
-- 
2.25.1


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

* [PATCH 2/7] dt-bindings: tpm: Improve documentation of compatibles
  2022-09-30 16:51 [PATCH 0/7] Clean up TPM compatibles Alexander Steffen
  2022-09-30 16:51 ` [PATCH 1/7] dt-bindings: tpm: Introduce trivial-tpms.yaml Alexander Steffen
@ 2022-09-30 16:51 ` Alexander Steffen
  2022-09-30 22:05   ` Rob Herring
  2022-09-30 16:51 ` [PATCH 3/7] dt-bindings: tpm: Add previously undocumented properties Alexander Steffen
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 16+ messages in thread
From: Alexander Steffen @ 2022-09-30 16:51 UTC (permalink / raw)
  To: robh+dt, devicetree, jarkko, linux-integrity
  Cc: Alexander Steffen, Johannes.Holland, benoit.houyere, amirmizi6, peter

Add missing information:
* Device name, for discoverability
* Interface, to distinguish otherwise similar devices
* TPM version, so that outdated devices can be deprecated in the future

Signed-off-by: Alexander Steffen <Alexander.Steffen@infineon.com>
---
 .../bindings/security/tpm/trivial-tpms.yaml        | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/Documentation/devicetree/bindings/security/tpm/trivial-tpms.yaml b/Documentation/devicetree/bindings/security/tpm/trivial-tpms.yaml
index fadd4ca96554..2092341c6491 100644
--- a/Documentation/devicetree/bindings/security/tpm/trivial-tpms.yaml
+++ b/Documentation/devicetree/bindings/security/tpm/trivial-tpms.yaml
@@ -28,21 +28,21 @@ properties:
   compatible:
     contains:
       enum:
-          # i2c trusted platform module (TPM)
+          # Atmel AT97SC3204T I2C TPM 1.2
         - atmel,at97sc3204t
-          # Infineon SLB9635 (Soft-) I2C TPM (old protocol, max 100khz)
+          # Infineon SLB9635 I2C TPM 1.2 (old protocol, max 100khz)
         - infineon,slb9635tt
-          # Infineon SLB9645 I2C TPM (new protocol, max 400khz)
+          # Infineon SLB9645 I2C TPM 1.2 (new protocol, max 400khz)
         - infineon,slb9645tt
           # Infineon SLB9673 I2C TPM 2.0
         - infineon,slb9673
-          # i2c trusted platform module (TPM)
+          # Nuvoton NPCT501 I2C TPM 1.2
         - nuvoton,npct501
-          # i2c trusted platform module (TPM2)
+          # Nuvoton NPCT601 I2C TPM 2.0
         - nuvoton,npct601
-          # Socionext SynQuacer TPM MMIO module
+          # Socionext SynQuacer MMIO TPM
         - socionext,synquacer-tpm-mmio
-          # i2c trusted platform module (TPM)
+          # Winbond WPCT301 I2C TPM 1.2
         - winbond,wpct301
 
 required:
-- 
2.25.1


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

* [PATCH 3/7] dt-bindings: tpm: Add previously undocumented properties
  2022-09-30 16:51 [PATCH 0/7] Clean up TPM compatibles Alexander Steffen
  2022-09-30 16:51 ` [PATCH 1/7] dt-bindings: tpm: Introduce trivial-tpms.yaml Alexander Steffen
  2022-09-30 16:51 ` [PATCH 2/7] dt-bindings: tpm: Improve documentation of compatibles Alexander Steffen
@ 2022-09-30 16:51 ` Alexander Steffen
  2022-09-30 22:20   ` Rob Herring
  2022-09-30 16:51 ` [PATCH 4/7] dt-bindings: tpm: Merge existing trivial TPMs to YAML Alexander Steffen
  2022-09-30 22:09 ` [PATCH 0/7] Clean up TPM compatibles Rob Herring
  4 siblings, 1 reply; 16+ messages in thread
From: Alexander Steffen @ 2022-09-30 16:51 UTC (permalink / raw)
  To: robh+dt, devicetree, jarkko, linux-integrity
  Cc: Alexander Steffen, Johannes.Holland, benoit.houyere, amirmizi6, peter

TPM devices may use some more properties than previously allowed by
trivial-devices.yaml. Document those in trivial-tpms.yaml.

Signed-off-by: Alexander Steffen <Alexander.Steffen@infineon.com>
---
 .../bindings/security/tpm/trivial-tpms.yaml      | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/Documentation/devicetree/bindings/security/tpm/trivial-tpms.yaml b/Documentation/devicetree/bindings/security/tpm/trivial-tpms.yaml
index 2092341c6491..a9e2dd17b1ca 100644
--- a/Documentation/devicetree/bindings/security/tpm/trivial-tpms.yaml
+++ b/Documentation/devicetree/bindings/security/tpm/trivial-tpms.yaml
@@ -25,6 +25,22 @@ properties:
 
   spi-max-frequency: true
 
+  linux,sml-base:
+    $ref: /schemas/types.yaml#/definitions/uint64
+    description: |
+      64-bit base address of the reserved memory allocated for the firmware
+      event log
+
+  linux,sml-size:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: size of the memory allocated for the firmware event log
+
+  powered-while-suspended:
+    $ref: /schemas/types.yaml#/definitions/flag
+    description: |
+      Present when the TPM is left powered on between suspend and resume
+      (makes the suspend/resume callbacks do nothing).
+
   compatible:
     contains:
       enum:
-- 
2.25.1


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

* [PATCH 4/7] dt-bindings: tpm: Merge existing trivial TPMs to YAML
  2022-09-30 16:51 [PATCH 0/7] Clean up TPM compatibles Alexander Steffen
                   ` (2 preceding siblings ...)
  2022-09-30 16:51 ` [PATCH 3/7] dt-bindings: tpm: Add previously undocumented properties Alexander Steffen
@ 2022-09-30 16:51 ` Alexander Steffen
  2022-09-30 22:05   ` Rob Herring
  2022-09-30 22:09 ` [PATCH 0/7] Clean up TPM compatibles Rob Herring
  4 siblings, 1 reply; 16+ messages in thread
From: Alexander Steffen @ 2022-09-30 16:51 UTC (permalink / raw)
  To: robh+dt, devicetree, jarkko, linux-integrity
  Cc: Alexander Steffen, Johannes.Holland, benoit.houyere, amirmizi6, peter

Several of the existing text files describe trivial TPMs, that fit
perfectly into the new trivial-tpms.yaml. Move them there.

Signed-off-by: Alexander Steffen <Alexander.Steffen@infineon.com>
---
 .../bindings/security/tpm/google,cr50.txt     | 19 ----------
 .../bindings/security/tpm/tpm-i2c.txt         | 26 --------------
 .../bindings/security/tpm/tpm_tis_mmio.txt    | 25 -------------
 .../bindings/security/tpm/tpm_tis_spi.txt     | 23 ------------
 .../bindings/security/tpm/trivial-tpms.yaml   | 36 +++++++++++++++++++
 5 files changed, 36 insertions(+), 93 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/security/tpm/google,cr50.txt
 delete mode 100644 Documentation/devicetree/bindings/security/tpm/tpm-i2c.txt
 delete mode 100644 Documentation/devicetree/bindings/security/tpm/tpm_tis_mmio.txt
 delete mode 100644 Documentation/devicetree/bindings/security/tpm/tpm_tis_spi.txt

diff --git a/Documentation/devicetree/bindings/security/tpm/google,cr50.txt b/Documentation/devicetree/bindings/security/tpm/google,cr50.txt
deleted file mode 100644
index cd69c2efdd37..000000000000
--- a/Documentation/devicetree/bindings/security/tpm/google,cr50.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-* H1 Secure Microcontroller with Cr50 Firmware on SPI Bus.
-
-H1 Secure Microcontroller running Cr50 firmware provides several
-functions, including TPM-like functionality. It communicates over
-SPI using the FIFO protocol described in the PTP Spec, section 6.
-
-Required properties:
-- compatible: Should be "google,cr50".
-- spi-max-frequency: Maximum SPI frequency.
-
-Example:
-
-&spi0 {
-	tpm@0 {
-		compatible = "google,cr50";
-		reg = <0>;
-		spi-max-frequency = <800000>;
-	};
-};
diff --git a/Documentation/devicetree/bindings/security/tpm/tpm-i2c.txt b/Documentation/devicetree/bindings/security/tpm/tpm-i2c.txt
deleted file mode 100644
index a65d7b71e81a..000000000000
--- a/Documentation/devicetree/bindings/security/tpm/tpm-i2c.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-* Device Tree Bindings for I2C based Trusted Platform Module(TPM)
-
-Required properties:
-
-- compatible     : 'manufacturer,model', eg. nuvoton,npct650
-- label          : human readable string describing the device, eg. "tpm"
-- linux,sml-base : 64-bit base address of the reserved memory allocated for
-                   the firmware event log
-- linux,sml-size : size of the memory allocated for the firmware event log
-
-Optional properties:
-
-- powered-while-suspended: present when the TPM is left powered on between
-                           suspend and resume (makes the suspend/resume
-                           callbacks do nothing).
-
-Example (for OpenPower Systems with Nuvoton TPM 2.0 on I2C)
-----------------------------------------------------------
-
-tpm@57 {
-	reg = <0x57>;
-	label = "tpm";
-	compatible = "nuvoton,npct650", "nuvoton,npct601";
-	linux,sml-base = <0x7f 0xfd450000>;
-	linux,sml-size = <0x10000>;
-};
diff --git a/Documentation/devicetree/bindings/security/tpm/tpm_tis_mmio.txt b/Documentation/devicetree/bindings/security/tpm/tpm_tis_mmio.txt
deleted file mode 100644
index 7c6304426da1..000000000000
--- a/Documentation/devicetree/bindings/security/tpm/tpm_tis_mmio.txt
+++ /dev/null
@@ -1,25 +0,0 @@
-Trusted Computing Group MMIO Trusted Platform Module
-
-The TCG defines multi vendor standard for accessing a TPM chip, this
-is the standard protocol defined to access the TPM via MMIO. Typically
-this interface will be implemented over Intel's LPC bus.
-
-Refer to the 'TCG PC Client Specific TPM Interface Specification (TIS)' TCG
-publication for the specification.
-
-Required properties:
-
-- compatible: should contain a string below for the chip, followed by
-              "tcg,tpm-tis-mmio". Valid chip strings are:
-	          * "atmel,at97sc3204"
-- reg: The location of the MMIO registers, should be at least 0x5000 bytes
-- interrupts: An optional interrupt indicating command completion.
-
-Example:
-
-	tpm_tis@90000 {
-				compatible = "atmel,at97sc3204", "tcg,tpm-tis-mmio";
-				reg = <0x90000 0x5000>;
-				interrupt-parent = <&EIC0>;
-				interrupts = <1 2>;
-	};
diff --git a/Documentation/devicetree/bindings/security/tpm/tpm_tis_spi.txt b/Documentation/devicetree/bindings/security/tpm/tpm_tis_spi.txt
deleted file mode 100644
index b800667da92b..000000000000
--- a/Documentation/devicetree/bindings/security/tpm/tpm_tis_spi.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-Required properties:
-- compatible: should be one of the following
-    "st,st33htpm-spi"
-    "infineon,slb9670"
-    "tcg,tpm_tis-spi"
-- spi-max-frequency: Maximum SPI frequency (depends on TPMs).
-
-Optional SoC Specific Properties:
-- pinctrl-names: Contains only one value - "default".
-- pintctrl-0: Specifies the pin control groups used for this controller.
-
-Example (for ARM-based BeagleBoard xM with TPM_TIS on SPI4):
-
-&mcspi4 {
-
-
-        tpm_tis@0 {
-
-                compatible = "tcg,tpm_tis-spi";
-
-                spi-max-frequency = <10000000>;
-        };
-};
diff --git a/Documentation/devicetree/bindings/security/tpm/trivial-tpms.yaml b/Documentation/devicetree/bindings/security/tpm/trivial-tpms.yaml
index a9e2dd17b1ca..1fd7f38b7b6d 100644
--- a/Documentation/devicetree/bindings/security/tpm/trivial-tpms.yaml
+++ b/Documentation/devicetree/bindings/security/tpm/trivial-tpms.yaml
@@ -44,20 +44,34 @@ properties:
   compatible:
     contains:
       enum:
+          # Atmel AT97SC3204 LPC TPM 1.2
+        - atmel,at97sc3204
           # Atmel AT97SC3204T I2C TPM 1.2
         - atmel,at97sc3204t
+          # Google Titan H1/Cr50 I2C/SPI TPM 2.0
+        - google,cr50
           # Infineon SLB9635 I2C TPM 1.2 (old protocol, max 100khz)
         - infineon,slb9635tt
           # Infineon SLB9645 I2C TPM 1.2 (new protocol, max 400khz)
         - infineon,slb9645tt
+          # Infineon SLB9670 SPI TPM 2.0
+        - infineon,slb9670
           # Infineon SLB9673 I2C TPM 2.0
         - infineon,slb9673
           # Nuvoton NPCT501 I2C TPM 1.2
         - nuvoton,npct501
           # Nuvoton NPCT601 I2C TPM 2.0
         - nuvoton,npct601
+          # Nuvoton NPCT650 I2C TPM 2.0
+        - nuvoton,npct650
           # Socionext SynQuacer MMIO TPM
         - socionext,synquacer-tpm-mmio
+          # STMicroelectronics ST33TPHF2xSPI TPM 2.0
+        - st,st33htpm-spi
+          # TCG TIS-compliant MMIO TPM (generic fallback)
+        - tcg,tpm-tis-mmio
+          # TCG TIS-compliant SPI TPM (generic fallback)
+        - tcg,tpm_tis-spi
           # Winbond WPCT301 I2C TPM 1.2
         - winbond,wpct301
 
@@ -67,4 +81,26 @@ required:
 
 additionalProperties: false
 
+examples:
+  - |
+    tpm@0 {
+      compatible = "google,cr50";
+      reg = <0>;
+      spi-max-frequency = <800000>;
+    };
+  - |
+    tpm@57 {
+      compatible = "nuvoton,npct601";
+      reg = <0x57>;
+      linux,sml-base = <0x7f 0xfd450000>;
+      linux,sml-size = <0x10000>;
+    };
+  - |
+    tpm_tis@90000 {
+      compatible = "atmel,at97sc3204";
+      reg = <0x90000 0x5000>;
+      interrupt-parent = <&EIC0>;
+      interrupts = <1 2>;
+    };
+
 ...
-- 
2.25.1


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

* Re: [PATCH 4/7] dt-bindings: tpm: Merge existing trivial TPMs to YAML
  2022-09-30 16:51 ` [PATCH 4/7] dt-bindings: tpm: Merge existing trivial TPMs to YAML Alexander Steffen
@ 2022-09-30 22:05   ` Rob Herring
  2022-10-04 17:38     ` Alexander Steffen
  0 siblings, 1 reply; 16+ messages in thread
From: Rob Herring @ 2022-09-30 22:05 UTC (permalink / raw)
  To: Alexander Steffen
  Cc: peter, amirmizi6, jarkko, linux-integrity, robh+dt,
	Johannes.Holland, benoit.houyere, devicetree

On Fri, 30 Sep 2022 18:51:13 +0200, Alexander Steffen wrote:
> Several of the existing text files describe trivial TPMs, that fit
> perfectly into the new trivial-tpms.yaml. Move them there.
> 
> Signed-off-by: Alexander Steffen <Alexander.Steffen@infineon.com>
> ---
>  .../bindings/security/tpm/google,cr50.txt     | 19 ----------
>  .../bindings/security/tpm/tpm-i2c.txt         | 26 --------------
>  .../bindings/security/tpm/tpm_tis_mmio.txt    | 25 -------------
>  .../bindings/security/tpm/tpm_tis_spi.txt     | 23 ------------
>  .../bindings/security/tpm/trivial-tpms.yaml   | 36 +++++++++++++++++++
>  5 files changed, 36 insertions(+), 93 deletions(-)
>  delete mode 100644 Documentation/devicetree/bindings/security/tpm/google,cr50.txt
>  delete mode 100644 Documentation/devicetree/bindings/security/tpm/tpm-i2c.txt
>  delete mode 100644 Documentation/devicetree/bindings/security/tpm/tpm_tis_mmio.txt
>  delete mode 100644 Documentation/devicetree/bindings/security/tpm/tpm_tis_spi.txt
> 

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:

dtschema/dtc warnings/errors:
Documentation/devicetree/bindings/security/tpm/trivial-tpms.example.dts:20.11-21: Warning (reg_format): /example-0/tpm@0:reg: property has invalid length (4 bytes) (#address-cells == 1, #size-cells == 1)
Documentation/devicetree/bindings/security/tpm/trivial-tpms.example.dts:42.11-24: Warning (reg_format): /example-1/tpm@57:reg: property has invalid length (4 bytes) (#address-cells == 1, #size-cells == 1)
Documentation/devicetree/bindings/security/tpm/trivial-tpms.example.dtb: Warning (pci_device_reg): Failed prerequisite 'reg_format'
Documentation/devicetree/bindings/security/tpm/trivial-tpms.example.dtb: Warning (pci_device_bus_num): Failed prerequisite 'reg_format'
Documentation/devicetree/bindings/security/tpm/trivial-tpms.example.dtb: Warning (simple_bus_reg): Failed prerequisite 'reg_format'
Documentation/devicetree/bindings/security/tpm/trivial-tpms.example.dtb: Warning (i2c_bus_reg): Failed prerequisite 'reg_format'
Documentation/devicetree/bindings/security/tpm/trivial-tpms.example.dtb: Warning (spi_bus_reg): Failed prerequisite 'reg_format'

doc reference errors (make refcheckdocs):

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

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.


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

* Re: [PATCH 2/7] dt-bindings: tpm: Improve documentation of compatibles
  2022-09-30 16:51 ` [PATCH 2/7] dt-bindings: tpm: Improve documentation of compatibles Alexander Steffen
@ 2022-09-30 22:05   ` Rob Herring
  2022-10-04 17:37     ` Alexander Steffen
  0 siblings, 1 reply; 16+ messages in thread
From: Rob Herring @ 2022-09-30 22:05 UTC (permalink / raw)
  To: Alexander Steffen
  Cc: benoit.houyere, robh+dt, devicetree, amirmizi6, jarkko, peter,
	Johannes.Holland, linux-integrity

On Fri, 30 Sep 2022 18:51:11 +0200, Alexander Steffen wrote:
> Add missing information:
> * Device name, for discoverability
> * Interface, to distinguish otherwise similar devices
> * TPM version, so that outdated devices can be deprecated in the future
> 
> Signed-off-by: Alexander Steffen <Alexander.Steffen@infineon.com>
> ---
>  .../bindings/security/tpm/trivial-tpms.yaml        | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 

Running 'make dtbs_check' with the schema in this patch gives the
following warnings. Consider if they are expected or the schema is
incorrect. These may not be new warnings.

Note that it is not yet a requirement to have 0 warnings for dtbs_check.
This will change in the future.

Full log is available here: https://patchwork.ozlabs.org/patch/


tpm@20: 'powered-while-suspended' does not match any of the regexes: 'pinctrl-[0-9]+'
	arch/arm/boot/dts/rk3288-veyron-brain.dtb
	arch/arm/boot/dts/rk3288-veyron-fievel.dtb
	arch/arm/boot/dts/rk3288-veyron-jaq.dtb
	arch/arm/boot/dts/rk3288-veyron-jerry.dtb
	arch/arm/boot/dts/rk3288-veyron-mickey.dtb
	arch/arm/boot/dts/rk3288-veyron-mighty.dtb
	arch/arm/boot/dts/rk3288-veyron-minnie.dtb
	arch/arm/boot/dts/rk3288-veyron-pinky.dtb
	arch/arm/boot/dts/rk3288-veyron-speedy.dtb
	arch/arm/boot/dts/rk3288-veyron-tiger.dtb
	arch/arm64/boot/dts/mediatek/mt8173-elm-hana-rev7.dtb
	arch/arm64/boot/dts/mediatek/mt8173-elm-hana.dtb
	arch/arm64/boot/dts/mediatek/mt8173-elm.dtb
	arch/arm64/boot/dts/rockchip/rk3399-gru-kevin.dtb


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

* Re: [PATCH 0/7] Clean up TPM compatibles
  2022-09-30 16:51 [PATCH 0/7] Clean up TPM compatibles Alexander Steffen
                   ` (3 preceding siblings ...)
  2022-09-30 16:51 ` [PATCH 4/7] dt-bindings: tpm: Merge existing trivial TPMs to YAML Alexander Steffen
@ 2022-09-30 22:09 ` Rob Herring
  4 siblings, 0 replies; 16+ messages in thread
From: Rob Herring @ 2022-09-30 22:09 UTC (permalink / raw)
  To: Alexander Steffen, Joel Stanley
  Cc: devicetree, jarkko, linux-integrity, Johannes.Holland,
	benoit.houyere, amirmizi6, peter

+Joel

On Fri, Sep 30, 2022 at 12:03 PM Alexander Steffen
<Alexander.Steffen@infineon.com> wrote:
>
> Not all TPM compatibles were documented correctly so far. Some were not
> documented at all, others missed some properties, most of them did not use the
> latest YAML format. But by design most TPMs are very similar, so this allows to
> document them in a single trivial-tpms.yaml, similar to how
> trivial-devices.yaml documents simple I2C and SPI devices. This fixes all the
> documentation issues and ensures that dtbs_check can be used in the future to
> detect incorrect configurations automatically.
>
> Alexander Steffen (7):
>   dt-bindings: tpm: Introduce trivial-tpms.yaml
>   dt-bindings: tpm: Improve documentation of compatibles
>   dt-bindings: tpm: Add previously undocumented properties
>   dt-bindings: tpm: Merge existing trivial TPMs to YAML
>   dt-bindings: tpm: Document previously undocumented compatibles
>   dt-bindings: tpm: Add fallbacks for all TCG-compliant TPM variants
>   tpm: Add missing compatibles to drivers
>
>  .../bindings/security/tpm/google,cr50.txt     |  19 ---
>  .../bindings/security/tpm/tpm-i2c.txt         |  26 ----
>  .../bindings/security/tpm/tpm_tis_mmio.txt    |  25 ----
>  .../bindings/security/tpm/tpm_tis_spi.txt     |  23 ----
>  .../bindings/security/tpm/trivial-tpms.yaml   | 118 ++++++++++++++++++
>  .../devicetree/bindings/trivial-devices.yaml  |  16 ---
>  drivers/char/tpm/tpm_tis_i2c.c                |   2 +
>  drivers/char/tpm/tpm_tis_spi_main.c           |   1 +
>  8 files changed, 121 insertions(+), 109 deletions(-)
>  delete mode 100644 Documentation/devicetree/bindings/security/tpm/google,cr50.txt
>  delete mode 100644 Documentation/devicetree/bindings/security/tpm/tpm-i2c.txt
>  delete mode 100644 Documentation/devicetree/bindings/security/tpm/tpm_tis_mmio.txt
>  delete mode 100644 Documentation/devicetree/bindings/security/tpm/tpm_tis_spi.txt
>  create mode 100644 Documentation/devicetree/bindings/security/tpm/trivial-tpms.yaml

Thanks, but please coordinate your work with this[1].

Rob

[1] https://lore.kernel.org/all/20220928043957.2636877-1-joel@jms.id.au/

>

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

* Re: [PATCH 1/7] dt-bindings: tpm: Introduce trivial-tpms.yaml
  2022-09-30 16:51 ` [PATCH 1/7] dt-bindings: tpm: Introduce trivial-tpms.yaml Alexander Steffen
@ 2022-09-30 22:15   ` Rob Herring
  2022-10-04 17:41     ` Alexander Steffen
  0 siblings, 1 reply; 16+ messages in thread
From: Rob Herring @ 2022-09-30 22:15 UTC (permalink / raw)
  To: Alexander Steffen
  Cc: devicetree, jarkko, linux-integrity, Johannes.Holland,
	benoit.houyere, amirmizi6, peter

On Fri, Sep 30, 2022 at 12:03 PM Alexander Steffen
<Alexander.Steffen@infineon.com> wrote:
>
> Most TPM devices are very similar and only need a few common properties
> to describe them. However, they may use more properties than other
> trivial I2C or SPI devices, e.g. powered-while-suspended. Therefore,
> move them to their own trivial-tpms.yaml.
>
> Signed-off-by: Alexander Steffen <Alexander.Steffen@infineon.com>
> ---
>  .../bindings/security/tpm/trivial-tpms.yaml   | 54 +++++++++++++++++++
>  .../devicetree/bindings/trivial-devices.yaml  | 16 ------
>  2 files changed, 54 insertions(+), 16 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/security/tpm/trivial-tpms.yaml
>
> diff --git a/Documentation/devicetree/bindings/security/tpm/trivial-tpms.yaml b/Documentation/devicetree/bindings/security/tpm/trivial-tpms.yaml
> new file mode 100644
> index 000000000000..fadd4ca96554
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/security/tpm/trivial-tpms.yaml
> @@ -0,0 +1,54 @@
> +# SPDX-License-Identifier: GPL-2.0
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/security/tpm/trivial-tpms.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Trivial TPM devices that have simple device tree bindings
> +
> +maintainers:
> +  - linux-integrity@vger.kernel.org
> +
> +description: |
> +  This is a list of trivial TPM devices that share the same properties and
> +  therefore have simple device tree bindings.
> +
> +  If a device needs more specific bindings, such as properties to
> +  describe some aspect of it, there needs to be a specific binding
> +  document for it just like any other devices.
> +
> +properties:
> +  reg:
> +    maxItems: 1

blank line

> +  interrupts:
> +    maxItems: 1
> +
> +  spi-max-frequency: true

The SPI based devices need to reference spi-peripheral-props.yaml. So
I think these are going to need to be split up by bus some.

> +
> +  compatible:

compatible goes first by convention.

> +    contains:

'contains' can not be used here. That allows any other compatible
strings to be present. It's got to be exact lists of what are valid
combinations.

> +      enum:
> +          # i2c trusted platform module (TPM)
> +        - atmel,at97sc3204t
> +          # Infineon SLB9635 (Soft-) I2C TPM (old protocol, max 100khz)
> +        - infineon,slb9635tt
> +          # Infineon SLB9645 I2C TPM (new protocol, max 400khz)
> +        - infineon,slb9645tt
> +          # Infineon SLB9673 I2C TPM 2.0
> +        - infineon,slb9673
> +          # i2c trusted platform module (TPM)
> +        - nuvoton,npct501
> +          # i2c trusted platform module (TPM2)
> +        - nuvoton,npct601
> +          # Socionext SynQuacer TPM MMIO module
> +        - socionext,synquacer-tpm-mmio
> +          # i2c trusted platform module (TPM)
> +        - winbond,wpct301
> +
> +required:
> +  - compatible
> +  - reg
> +
> +additionalProperties: false
> +
> +...
> diff --git a/Documentation/devicetree/bindings/trivial-devices.yaml b/Documentation/devicetree/bindings/trivial-devices.yaml
> index 61746755c107..1cc7f82c0822 100644
> --- a/Documentation/devicetree/bindings/trivial-devices.yaml
> +++ b/Documentation/devicetree/bindings/trivial-devices.yaml
> @@ -47,8 +47,6 @@ properties:
>            - ams,iaq-core
>              # i2c serial eeprom (24cxx)
>            - at,24c08
> -            # i2c trusted platform module (TPM)
> -          - atmel,at97sc3204t
>              # ATSHA204 - i2c h/w symmetric crypto module
>            - atmel,atsha204
>              # ATSHA204A - i2c h/w symmetric crypto module
> @@ -135,12 +133,6 @@ properties:
>            - infineon,ir38164
>              # Infineon IR38263 Voltage Regulator
>            - infineon,ir38263
> -            # Infineon SLB9635 (Soft-) I2C TPM (old protocol, max 100khz)
> -          - infineon,slb9635tt
> -            # Infineon SLB9645 I2C TPM (new protocol, max 400khz)
> -          - infineon,slb9645tt
> -            # Infineon SLB9673 I2C TPM 2.0
> -          - infineon,slb9673
>              # Infineon TLV493D-A1B6 I2C 3D Magnetic Sensor
>            - infineon,tlv493d-a1b6
>              # Infineon Multi-phase Digital VR Controller xdpe11280
> @@ -289,10 +281,6 @@ properties:
>            - national,lm85
>              # I2C ±0.33°C Accurate, 12-Bit + Sign Temperature Sensor and Thermal Window Comparator
>            - national,lm92
> -            # i2c trusted platform module (TPM)
> -          - nuvoton,npct501
> -            # i2c trusted platform module (TPM2)
> -          - nuvoton,npct601
>              # Nuvoton Temperature Sensor
>            - nuvoton,w83773g
>              # OKI ML86V7667 video decoder
> @@ -327,8 +315,6 @@ properties:
>            - silabs,si7020
>              # Skyworks SKY81452: Six-Channel White LED Driver with Touch Panel Bias Supply
>            - skyworks,sky81452
> -            # Socionext SynQuacer TPM MMIO module
> -          - socionext,synquacer-tpm-mmio
>              # SparkFun Qwiic Joystick (COM-15168) with i2c interface
>            - sparkfun,qwiic-joystick
>              # i2c serial eeprom (24cxx)
> @@ -383,8 +369,6 @@ properties:
>            - winbond,w83793
>              # Vicor Corporation Digital Supervisor
>            - vicor,pli1209bc
> -            # i2c trusted platform module (TPM)
> -          - winbond,wpct301
>
>  required:
>    - compatible
> --
> 2.25.1
>

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

* Re: [PATCH 3/7] dt-bindings: tpm: Add previously undocumented properties
  2022-09-30 16:51 ` [PATCH 3/7] dt-bindings: tpm: Add previously undocumented properties Alexander Steffen
@ 2022-09-30 22:20   ` Rob Herring
  2022-10-04 17:43     ` Alexander Steffen
  0 siblings, 1 reply; 16+ messages in thread
From: Rob Herring @ 2022-09-30 22:20 UTC (permalink / raw)
  To: Alexander Steffen
  Cc: devicetree, jarkko, linux-integrity, Johannes.Holland,
	benoit.houyere, amirmizi6, peter

On Fri, Sep 30, 2022 at 12:02 PM Alexander Steffen
<Alexander.Steffen@infineon.com> wrote:
>
> TPM devices may use some more properties than previously allowed by
> trivial-devices.yaml. Document those in trivial-tpms.yaml.
>
> Signed-off-by: Alexander Steffen <Alexander.Steffen@infineon.com>
> ---
>  .../bindings/security/tpm/trivial-tpms.yaml      | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)

Adding these here means we would need to duplicate them for any device
with its own schema file. You need a common TPM property schema which
the specific TPM device schemas can reference.

>
> diff --git a/Documentation/devicetree/bindings/security/tpm/trivial-tpms.yaml b/Documentation/devicetree/bindings/security/tpm/trivial-tpms.yaml
> index 2092341c6491..a9e2dd17b1ca 100644
> --- a/Documentation/devicetree/bindings/security/tpm/trivial-tpms.yaml
> +++ b/Documentation/devicetree/bindings/security/tpm/trivial-tpms.yaml
> @@ -25,6 +25,22 @@ properties:
>
>    spi-max-frequency: true
>
> +  linux,sml-base:
> +    $ref: /schemas/types.yaml#/definitions/uint64
> +    description: |
> +      64-bit base address of the reserved memory allocated for the firmware
> +      event log
> +
> +  linux,sml-size:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: size of the memory allocated for the firmware event log
> +
> +  powered-while-suspended:
> +    $ref: /schemas/types.yaml#/definitions/flag
> +    description: |
> +      Present when the TPM is left powered on between suspend and resume
> +      (makes the suspend/resume callbacks do nothing).
> +
>    compatible:
>      contains:
>        enum:
> --
> 2.25.1
>

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

* Re: [PATCH 2/7] dt-bindings: tpm: Improve documentation of compatibles
  2022-09-30 22:05   ` Rob Herring
@ 2022-10-04 17:37     ` Alexander Steffen
  0 siblings, 0 replies; 16+ messages in thread
From: Alexander Steffen @ 2022-10-04 17:37 UTC (permalink / raw)
  To: Rob Herring
  Cc: benoit.houyere, robh+dt, devicetree, amirmizi6, jarkko, peter,
	Johannes.Holland, linux-integrity

On 01.10.22 00:05, Rob Herring wrote:
> On Fri, 30 Sep 2022 18:51:11 +0200, Alexander Steffen wrote:
>> Add missing information:
>> * Device name, for discoverability
>> * Interface, to distinguish otherwise similar devices
>> * TPM version, so that outdated devices can be deprecated in the future
>>
>> Signed-off-by: Alexander Steffen <Alexander.Steffen@infineon.com>
>> ---
>>   .../bindings/security/tpm/trivial-tpms.yaml        | 14 +++++++-------
>>   1 file changed, 7 insertions(+), 7 deletions(-)
>>
> 
> Running 'make dtbs_check' with the schema in this patch gives the
> following warnings. Consider if they are expected or the schema is
> incorrect. These may not be new warnings.
> 
> Note that it is not yet a requirement to have 0 warnings for dtbs_check.
> This will change in the future.
> 
> Full log is available here: https://patchwork.ozlabs.org/patch/
> 
> 
> tpm@20: 'powered-while-suspended' does not match any of the regexes: 'pinctrl-[0-9]+'
>          arch/arm/boot/dts/rk3288-veyron-brain.dtb
>          arch/arm/boot/dts/rk3288-veyron-fievel.dtb
>          arch/arm/boot/dts/rk3288-veyron-jaq.dtb
>          arch/arm/boot/dts/rk3288-veyron-jerry.dtb
>          arch/arm/boot/dts/rk3288-veyron-mickey.dtb
>          arch/arm/boot/dts/rk3288-veyron-mighty.dtb
>          arch/arm/boot/dts/rk3288-veyron-minnie.dtb
>          arch/arm/boot/dts/rk3288-veyron-pinky.dtb
>          arch/arm/boot/dts/rk3288-veyron-speedy.dtb
>          arch/arm/boot/dts/rk3288-veyron-tiger.dtb
>          arch/arm64/boot/dts/mediatek/mt8173-elm-hana-rev7.dtb
>          arch/arm64/boot/dts/mediatek/mt8173-elm-hana.dtb
>          arch/arm64/boot/dts/mediatek/mt8173-elm.dtb
>          arch/arm64/boot/dts/rockchip/rk3399-gru-kevin.dtb

This is fixed by PATCH 3/7. Not sure it is worth changing the order, 
since the intention of the first two patches was just to convert the 
existing data, without making any functional changes.

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

* Re: [PATCH 4/7] dt-bindings: tpm: Merge existing trivial TPMs to YAML
  2022-09-30 22:05   ` Rob Herring
@ 2022-10-04 17:38     ` Alexander Steffen
  2022-11-01 12:03       ` Rob Herring
  0 siblings, 1 reply; 16+ messages in thread
From: Alexander Steffen @ 2022-10-04 17:38 UTC (permalink / raw)
  To: Rob Herring
  Cc: peter, amirmizi6, jarkko, linux-integrity, robh+dt,
	Johannes.Holland, benoit.houyere, devicetree

On 01.10.22 00:05, Rob Herring wrote:
> On Fri, 30 Sep 2022 18:51:13 +0200, Alexander Steffen wrote:
>> Several of the existing text files describe trivial TPMs, that fit
>> perfectly into the new trivial-tpms.yaml. Move them there.
>>
>> Signed-off-by: Alexander Steffen <Alexander.Steffen@infineon.com>
>> ---
>>   .../bindings/security/tpm/google,cr50.txt     | 19 ----------
>>   .../bindings/security/tpm/tpm-i2c.txt         | 26 --------------
>>   .../bindings/security/tpm/tpm_tis_mmio.txt    | 25 -------------
>>   .../bindings/security/tpm/tpm_tis_spi.txt     | 23 ------------
>>   .../bindings/security/tpm/trivial-tpms.yaml   | 36 +++++++++++++++++++
>>   5 files changed, 36 insertions(+), 93 deletions(-)
>>   delete mode 100644 Documentation/devicetree/bindings/security/tpm/google,cr50.txt
>>   delete mode 100644 Documentation/devicetree/bindings/security/tpm/tpm-i2c.txt
>>   delete mode 100644 Documentation/devicetree/bindings/security/tpm/tpm_tis_mmio.txt
>>   delete mode 100644 Documentation/devicetree/bindings/security/tpm/tpm_tis_spi.txt
>>
> 
> 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:
> 
> dtschema/dtc warnings/errors:
> Documentation/devicetree/bindings/security/tpm/trivial-tpms.example.dts:20.11-21: Warning (reg_format): /example-0/tpm@0:reg: property has invalid length (4 bytes) (#address-cells == 1, #size-cells == 1)
> Documentation/devicetree/bindings/security/tpm/trivial-tpms.example.dts:42.11-24: Warning (reg_format): /example-1/tpm@57:reg: property has invalid length (4 bytes) (#address-cells == 1, #size-cells == 1)
> Documentation/devicetree/bindings/security/tpm/trivial-tpms.example.dtb: Warning (pci_device_reg): Failed prerequisite 'reg_format'
> Documentation/devicetree/bindings/security/tpm/trivial-tpms.example.dtb: Warning (pci_device_bus_num): Failed prerequisite 'reg_format'
> Documentation/devicetree/bindings/security/tpm/trivial-tpms.example.dtb: Warning (simple_bus_reg): Failed prerequisite 'reg_format'
> Documentation/devicetree/bindings/security/tpm/trivial-tpms.example.dtb: Warning (i2c_bus_reg): Failed prerequisite 'reg_format'
> Documentation/devicetree/bindings/security/tpm/trivial-tpms.example.dtb: Warning (spi_bus_reg): Failed prerequisite 'reg_format'
> 
> doc reference errors (make refcheckdocs):
> 
> See https://patchwork.ozlabs.org/patch/
> 
> 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.

Any idea what is wrong here with reg_format? I just copied the existing 
examples, so something was broken there before.

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

* Re: [PATCH 1/7] dt-bindings: tpm: Introduce trivial-tpms.yaml
  2022-09-30 22:15   ` Rob Herring
@ 2022-10-04 17:41     ` Alexander Steffen
  2022-11-01 12:17       ` Rob Herring
  0 siblings, 1 reply; 16+ messages in thread
From: Alexander Steffen @ 2022-10-04 17:41 UTC (permalink / raw)
  To: Rob Herring
  Cc: devicetree, jarkko, linux-integrity, Johannes.Holland,
	benoit.houyere, amirmizi6, peter

On 01.10.22 00:15, Rob Herring wrote:
> On Fri, Sep 30, 2022 at 12:03 PM Alexander Steffen
> <Alexander.Steffen@infineon.com> wrote:
>>
>> Most TPM devices are very similar and only need a few common properties
>> to describe them. However, they may use more properties than other
>> trivial I2C or SPI devices, e.g. powered-while-suspended. Therefore,
>> move them to their own trivial-tpms.yaml.
>>
>> Signed-off-by: Alexander Steffen <Alexander.Steffen@infineon.com>
>> ---
>>   .../bindings/security/tpm/trivial-tpms.yaml   | 54 +++++++++++++++++++
>>   .../devicetree/bindings/trivial-devices.yaml  | 16 ------
>>   2 files changed, 54 insertions(+), 16 deletions(-)
>>   create mode 100644 Documentation/devicetree/bindings/security/tpm/trivial-tpms.yaml
>>
>> diff --git a/Documentation/devicetree/bindings/security/tpm/trivial-tpms.yaml b/Documentation/devicetree/bindings/security/tpm/trivial-tpms.yaml
>> new file mode 100644
>> index 000000000000..fadd4ca96554
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/security/tpm/trivial-tpms.yaml
>> @@ -0,0 +1,54 @@
>> +# SPDX-License-Identifier: GPL-2.0
>> +%YAML 1.2
>> +---
>> +$id: http://devicetree.org/schemas/security/tpm/trivial-tpms.yaml#
>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>> +
>> +title: Trivial TPM devices that have simple device tree bindings
>> +
>> +maintainers:
>> +  - linux-integrity@vger.kernel.org
>> +
>> +description: |
>> +  This is a list of trivial TPM devices that share the same properties and
>> +  therefore have simple device tree bindings.
>> +
>> +  If a device needs more specific bindings, such as properties to
>> +  describe some aspect of it, there needs to be a specific binding
>> +  document for it just like any other devices.
>> +
>> +properties:
>> +  reg:
>> +    maxItems: 1
> 
> blank line
> 
>> +  interrupts:
>> +    maxItems: 1
>> +
>> +  spi-max-frequency: true
> 
> The SPI based devices need to reference spi-peripheral-props.yaml. So
> I think these are going to need to be split up by bus some.
> 
>> +
>> +  compatible:
> 
> compatible goes first by convention.

I had copied all three from trivial-devices.yaml ;-)

The style fixes are easy. But do you really think I should split 
trivial-tpms.yaml into i2c-tpms.yaml, spi-tpms.yaml, etc.? After all, 
trivial-devices.yaml also contains a mix of I2C and SPI devices.

Also, what about devices like "google,cr50", that support both I2C and 
SPI? Can they appear in two YAML files at the same time?

>> +    contains:
> 
> 'contains' can not be used here. That allows any other compatible
> strings to be present. It's got to be exact lists of what are valid
> combinations.

So what exactly are valid combinations then? If I look at what is in 
use, I find three possible combinations:

arch/arm/boot/dts/am335x-moxa-uc-2100-common.dtsi: compatible = 
"tcg,tpm_tis-spi"
arch/arm/boot/dts/imx6dl-eckelmann-ci4x10.dts: compatible = 
"infineon,slb9670", "tcg,tpm_tis-spi";
arch/arm64/boot/dts/freescale/imx8mq-kontron-pitx-imx8m.dts: compatible 
= "infineon,slb9670";

It is either a generic identifier or a specific device or both. Is it 
correct to allow all three variants? If so, how to specify that as YAML, 
ideally without duplicating any of the identifiers?

>> +      enum:
>> +          # i2c trusted platform module (TPM)
>> +        - atmel,at97sc3204t
>> +          # Infineon SLB9635 (Soft-) I2C TPM (old protocol, max 100khz)
>> +        - infineon,slb9635tt
>> +          # Infineon SLB9645 I2C TPM (new protocol, max 400khz)
>> +        - infineon,slb9645tt
>> +          # Infineon SLB9673 I2C TPM 2.0
>> +        - infineon,slb9673
>> +          # i2c trusted platform module (TPM)
>> +        - nuvoton,npct501
>> +          # i2c trusted platform module (TPM2)
>> +        - nuvoton,npct601
>> +          # Socionext SynQuacer TPM MMIO module
>> +        - socionext,synquacer-tpm-mmio
>> +          # i2c trusted platform module (TPM)
>> +        - winbond,wpct301
>> +
>> +required:
>> +  - compatible
>> +  - reg
>> +
>> +additionalProperties: false
>> +
>> +...
>> diff --git a/Documentation/devicetree/bindings/trivial-devices.yaml b/Documentation/devicetree/bindings/trivial-devices.yaml
>> index 61746755c107..1cc7f82c0822 100644
>> --- a/Documentation/devicetree/bindings/trivial-devices.yaml
>> +++ b/Documentation/devicetree/bindings/trivial-devices.yaml
>> @@ -47,8 +47,6 @@ properties:
>>             - ams,iaq-core
>>               # i2c serial eeprom (24cxx)
>>             - at,24c08
>> -            # i2c trusted platform module (TPM)
>> -          - atmel,at97sc3204t
>>               # ATSHA204 - i2c h/w symmetric crypto module
>>             - atmel,atsha204
>>               # ATSHA204A - i2c h/w symmetric crypto module
>> @@ -135,12 +133,6 @@ properties:
>>             - infineon,ir38164
>>               # Infineon IR38263 Voltage Regulator
>>             - infineon,ir38263
>> -            # Infineon SLB9635 (Soft-) I2C TPM (old protocol, max 100khz)
>> -          - infineon,slb9635tt
>> -            # Infineon SLB9645 I2C TPM (new protocol, max 400khz)
>> -          - infineon,slb9645tt
>> -            # Infineon SLB9673 I2C TPM 2.0
>> -          - infineon,slb9673
>>               # Infineon TLV493D-A1B6 I2C 3D Magnetic Sensor
>>             - infineon,tlv493d-a1b6
>>               # Infineon Multi-phase Digital VR Controller xdpe11280
>> @@ -289,10 +281,6 @@ properties:
>>             - national,lm85
>>               # I2C ±0.33°C Accurate, 12-Bit + Sign Temperature Sensor and Thermal Window Comparator
>>             - national,lm92
>> -            # i2c trusted platform module (TPM)
>> -          - nuvoton,npct501
>> -            # i2c trusted platform module (TPM2)
>> -          - nuvoton,npct601
>>               # Nuvoton Temperature Sensor
>>             - nuvoton,w83773g
>>               # OKI ML86V7667 video decoder
>> @@ -327,8 +315,6 @@ properties:
>>             - silabs,si7020
>>               # Skyworks SKY81452: Six-Channel White LED Driver with Touch Panel Bias Supply
>>             - skyworks,sky81452
>> -            # Socionext SynQuacer TPM MMIO module
>> -          - socionext,synquacer-tpm-mmio
>>               # SparkFun Qwiic Joystick (COM-15168) with i2c interface
>>             - sparkfun,qwiic-joystick
>>               # i2c serial eeprom (24cxx)
>> @@ -383,8 +369,6 @@ properties:
>>             - winbond,w83793
>>               # Vicor Corporation Digital Supervisor
>>             - vicor,pli1209bc
>> -            # i2c trusted platform module (TPM)
>> -          - winbond,wpct301
>>
>>   required:
>>     - compatible
>> --
>> 2.25.1
>>

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

* Re: [PATCH 3/7] dt-bindings: tpm: Add previously undocumented properties
  2022-09-30 22:20   ` Rob Herring
@ 2022-10-04 17:43     ` Alexander Steffen
  0 siblings, 0 replies; 16+ messages in thread
From: Alexander Steffen @ 2022-10-04 17:43 UTC (permalink / raw)
  To: Rob Herring
  Cc: devicetree, jarkko, linux-integrity, Johannes.Holland,
	benoit.houyere, amirmizi6, peter

On 01.10.22 00:20, Rob Herring wrote:
> On Fri, Sep 30, 2022 at 12:02 PM Alexander Steffen
> <Alexander.Steffen@infineon.com> wrote:
>>
>> TPM devices may use some more properties than previously allowed by
>> trivial-devices.yaml. Document those in trivial-tpms.yaml.
>>
>> Signed-off-by: Alexander Steffen <Alexander.Steffen@infineon.com>
>> ---
>>   .../bindings/security/tpm/trivial-tpms.yaml      | 16 ++++++++++++++++
>>   1 file changed, 16 insertions(+)
> 
> Adding these here means we would need to duplicate them for any device
> with its own schema file. You need a common TPM property schema which
> the specific TPM device schemas can reference.

Good point, I'll create one.

>>
>> diff --git a/Documentation/devicetree/bindings/security/tpm/trivial-tpms.yaml b/Documentation/devicetree/bindings/security/tpm/trivial-tpms.yaml
>> index 2092341c6491..a9e2dd17b1ca 100644
>> --- a/Documentation/devicetree/bindings/security/tpm/trivial-tpms.yaml
>> +++ b/Documentation/devicetree/bindings/security/tpm/trivial-tpms.yaml
>> @@ -25,6 +25,22 @@ properties:
>>
>>     spi-max-frequency: true
>>
>> +  linux,sml-base:
>> +    $ref: /schemas/types.yaml#/definitions/uint64
>> +    description: |
>> +      64-bit base address of the reserved memory allocated for the firmware
>> +      event log
>> +
>> +  linux,sml-size:
>> +    $ref: /schemas/types.yaml#/definitions/uint32
>> +    description: size of the memory allocated for the firmware event log
>> +
>> +  powered-while-suspended:
>> +    $ref: /schemas/types.yaml#/definitions/flag
>> +    description: |
>> +      Present when the TPM is left powered on between suspend and resume
>> +      (makes the suspend/resume callbacks do nothing).
>> +
>>     compatible:
>>       contains:
>>         enum:
>> --
>> 2.25.1
>>

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

* Re: [PATCH 4/7] dt-bindings: tpm: Merge existing trivial TPMs to YAML
  2022-10-04 17:38     ` Alexander Steffen
@ 2022-11-01 12:03       ` Rob Herring
  0 siblings, 0 replies; 16+ messages in thread
From: Rob Herring @ 2022-11-01 12:03 UTC (permalink / raw)
  To: Alexander Steffen
  Cc: peter, amirmizi6, jarkko, linux-integrity, Johannes.Holland,
	benoit.houyere, devicetree

On Tue, Oct 04, 2022 at 07:38:00PM +0200, Alexander Steffen wrote:
> On 01.10.22 00:05, Rob Herring wrote:
> > On Fri, 30 Sep 2022 18:51:13 +0200, Alexander Steffen wrote:
> > > Several of the existing text files describe trivial TPMs, that fit
> > > perfectly into the new trivial-tpms.yaml. Move them there.
> > > 
> > > Signed-off-by: Alexander Steffen <Alexander.Steffen@infineon.com>
> > > ---
> > >   .../bindings/security/tpm/google,cr50.txt     | 19 ----------
> > >   .../bindings/security/tpm/tpm-i2c.txt         | 26 --------------
> > >   .../bindings/security/tpm/tpm_tis_mmio.txt    | 25 -------------
> > >   .../bindings/security/tpm/tpm_tis_spi.txt     | 23 ------------
> > >   .../bindings/security/tpm/trivial-tpms.yaml   | 36 +++++++++++++++++++
> > >   5 files changed, 36 insertions(+), 93 deletions(-)
> > >   delete mode 100644 Documentation/devicetree/bindings/security/tpm/google,cr50.txt
> > >   delete mode 100644 Documentation/devicetree/bindings/security/tpm/tpm-i2c.txt
> > >   delete mode 100644 Documentation/devicetree/bindings/security/tpm/tpm_tis_mmio.txt
> > >   delete mode 100644 Documentation/devicetree/bindings/security/tpm/tpm_tis_spi.txt
> > > 
> > 
> > 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:
> > 
> > dtschema/dtc warnings/errors:
> > Documentation/devicetree/bindings/security/tpm/trivial-tpms.example.dts:20.11-21: Warning (reg_format): /example-0/tpm@0:reg: property has invalid length (4 bytes) (#address-cells == 1, #size-cells == 1)
> > Documentation/devicetree/bindings/security/tpm/trivial-tpms.example.dts:42.11-24: Warning (reg_format): /example-1/tpm@57:reg: property has invalid length (4 bytes) (#address-cells == 1, #size-cells == 1)
> > Documentation/devicetree/bindings/security/tpm/trivial-tpms.example.dtb: Warning (pci_device_reg): Failed prerequisite 'reg_format'
> > Documentation/devicetree/bindings/security/tpm/trivial-tpms.example.dtb: Warning (pci_device_bus_num): Failed prerequisite 'reg_format'
> > Documentation/devicetree/bindings/security/tpm/trivial-tpms.example.dtb: Warning (simple_bus_reg): Failed prerequisite 'reg_format'
> > Documentation/devicetree/bindings/security/tpm/trivial-tpms.example.dtb: Warning (i2c_bus_reg): Failed prerequisite 'reg_format'
> > Documentation/devicetree/bindings/security/tpm/trivial-tpms.example.dtb: Warning (spi_bus_reg): Failed prerequisite 'reg_format'
> > 
> > doc reference errors (make refcheckdocs):
> > 
> > See https://patchwork.ozlabs.org/patch/
> > 
> > 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.
> 
> Any idea what is wrong here with reg_format? I just copied the existing
> examples, so something was broken there before.

The default bus is 1 address cell and 1 size cell. If you need something 
different, like I2C or SPI, you need to define the bus node in the 
example. This is explained in example-schema.yaml.

Rob

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

* Re: [PATCH 1/7] dt-bindings: tpm: Introduce trivial-tpms.yaml
  2022-10-04 17:41     ` Alexander Steffen
@ 2022-11-01 12:17       ` Rob Herring
  0 siblings, 0 replies; 16+ messages in thread
From: Rob Herring @ 2022-11-01 12:17 UTC (permalink / raw)
  To: Alexander Steffen
  Cc: devicetree, jarkko, linux-integrity, Johannes.Holland,
	benoit.houyere, amirmizi6, peter

On Tue, Oct 04, 2022 at 07:41:36PM +0200, Alexander Steffen wrote:
> On 01.10.22 00:15, Rob Herring wrote:
> > On Fri, Sep 30, 2022 at 12:03 PM Alexander Steffen
> > <Alexander.Steffen@infineon.com> wrote:
> > > 
> > > Most TPM devices are very similar and only need a few common properties
> > > to describe them. However, they may use more properties than other
> > > trivial I2C or SPI devices, e.g. powered-while-suspended. Therefore,
> > > move them to their own trivial-tpms.yaml.
> > > 
> > > Signed-off-by: Alexander Steffen <Alexander.Steffen@infineon.com>
> > > ---
> > >   .../bindings/security/tpm/trivial-tpms.yaml   | 54 +++++++++++++++++++
> > >   .../devicetree/bindings/trivial-devices.yaml  | 16 ------
> > >   2 files changed, 54 insertions(+), 16 deletions(-)
> > >   create mode 100644 Documentation/devicetree/bindings/security/tpm/trivial-tpms.yaml
> > > 
> > > diff --git a/Documentation/devicetree/bindings/security/tpm/trivial-tpms.yaml b/Documentation/devicetree/bindings/security/tpm/trivial-tpms.yaml
> > > new file mode 100644
> > > index 000000000000..fadd4ca96554
> > > --- /dev/null
> > > +++ b/Documentation/devicetree/bindings/security/tpm/trivial-tpms.yaml
> > > @@ -0,0 +1,54 @@
> > > +# SPDX-License-Identifier: GPL-2.0
> > > +%YAML 1.2
> > > +---
> > > +$id: http://devicetree.org/schemas/security/tpm/trivial-tpms.yaml#
> > > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > > +
> > > +title: Trivial TPM devices that have simple device tree bindings
> > > +
> > > +maintainers:
> > > +  - linux-integrity@vger.kernel.org
> > > +
> > > +description: |
> > > +  This is a list of trivial TPM devices that share the same properties and
> > > +  therefore have simple device tree bindings.
> > > +
> > > +  If a device needs more specific bindings, such as properties to
> > > +  describe some aspect of it, there needs to be a specific binding
> > > +  document for it just like any other devices.
> > > +
> > > +properties:
> > > +  reg:
> > > +    maxItems: 1
> > 
> > blank line
> > 
> > > +  interrupts:
> > > +    maxItems: 1
> > > +
> > > +  spi-max-frequency: true
> > 
> > The SPI based devices need to reference spi-peripheral-props.yaml. So
> > I think these are going to need to be split up by bus some.
> > 
> > > +
> > > +  compatible:
> > 
> > compatible goes first by convention.
> 
> I had copied all three from trivial-devices.yaml ;-)
> 
> The style fixes are easy. But do you really think I should split
> trivial-tpms.yaml into i2c-tpms.yaml, spi-tpms.yaml, etc.? After all,
> trivial-devices.yaml also contains a mix of I2C and SPI devices.

Well, you can leave them mixed. It just means that SPI bus properties 
would be allowed in I2C devices. That's okay, but if we can avoid it we 
should.

> Also, what about devices like "google,cr50", that support both I2C and SPI?
> Can they appear in two YAML files at the same time?

No, it can't. It can be a single schema for both, but perhaps a separate 
schema doc from the rest.

> 
> > > +    contains:
> > 
> > 'contains' can not be used here. That allows any other compatible
> > strings to be present. It's got to be exact lists of what are valid
> > combinations.
> 
> So what exactly are valid combinations then? If I look at what is in use, I
> find three possible combinations:
> 
> arch/arm/boot/dts/am335x-moxa-uc-2100-common.dtsi: compatible =
> "tcg,tpm_tis-spi"
> arch/arm/boot/dts/imx6dl-eckelmann-ci4x10.dts: compatible =
> "infineon,slb9670", "tcg,tpm_tis-spi";
> arch/arm64/boot/dts/freescale/imx8mq-kontron-pitx-imx8m.dts: compatible =
> "infineon,slb9670";
> 
> It is either a generic identifier or a specific device or both. Is it
> correct to allow all three variants? If so, how to specify that as YAML,
> ideally without duplicating any of the identifiers?

At a minimum you need an 'items' entry for each length of compatible 
entries and generally an entry for each fallback. So you will have to 
have some duplication.

In cases like imx8mq-kontron-pitx-imx8m.dts, the dts should be fixed 
adding "tcg,tpm_tis-spi". If all the users were just "infineon,slb9670", 
then we'd leave it. So define the schema with what matches existing 
users, but fix users when inconsistent. 

Rob

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

end of thread, other threads:[~2022-11-01 12:17 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-30 16:51 [PATCH 0/7] Clean up TPM compatibles Alexander Steffen
2022-09-30 16:51 ` [PATCH 1/7] dt-bindings: tpm: Introduce trivial-tpms.yaml Alexander Steffen
2022-09-30 22:15   ` Rob Herring
2022-10-04 17:41     ` Alexander Steffen
2022-11-01 12:17       ` Rob Herring
2022-09-30 16:51 ` [PATCH 2/7] dt-bindings: tpm: Improve documentation of compatibles Alexander Steffen
2022-09-30 22:05   ` Rob Herring
2022-10-04 17:37     ` Alexander Steffen
2022-09-30 16:51 ` [PATCH 3/7] dt-bindings: tpm: Add previously undocumented properties Alexander Steffen
2022-09-30 22:20   ` Rob Herring
2022-10-04 17:43     ` Alexander Steffen
2022-09-30 16:51 ` [PATCH 4/7] dt-bindings: tpm: Merge existing trivial TPMs to YAML Alexander Steffen
2022-09-30 22:05   ` Rob Herring
2022-10-04 17:38     ` Alexander Steffen
2022-11-01 12:03       ` Rob Herring
2022-09-30 22:09 ` [PATCH 0/7] Clean up TPM compatibles Rob Herring

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).