Add support for Qualcomm TSCSS hardware
Subsystems (6)
cover Add support for Qualcomm TSCSS hardware
This series introduces support for the Qualcomm Timestamp Counter Subsystem (TSCSS) hardware, a time synchronization subsystem present on Qualcomm Lemans, Monaco and QDU1000 SoCs.
TSCSS is composed of two main hardware blocks:
- Timestamp Counter (TSC): a free-running hardware counter that provides continuous timekeeping for the SoC, and is functional with a GCC TSC AHB config clock and a global counter clock. The TSC counter resolution and supported functionalities vary across SoC variants.
- Event Timestamp Unit (ETU): an optional block that captures TSC counter timestamps against external hardware events. Each ETU slice binds a slice identifier to an external event selector, and the ETU additionally requires its own clock, pinctrl along with either a per-slice interrupt (QDU1000) or a single summary interrupt across all ETU slices (Lemans and Monaco).
+------------------------------------------------+ +------------------+
| Global clock controller - TSC AHB/CNTR/ETU CLK | | EVENT_IN[0:15] |
+------------------------------------------------+ +------------------+
| |
v v
+----------------------------------------------------------------------+
| Timestamp Counter Subsystem (TSCSS) |
| |
| +----------------------------------------------+ |
| +------------+ | Event Timestamp Unit (ETU) | |
| | Timestamp | | 0x01C90000-0x01C9FFFF | |
| | Counter | | +------------------------------------------+ | |
| | (TSC) | | | ETU Slices | | |
| | | | | [Slice 0] [Slice 1] [...] [Slice 15] | | |
| | 0x1C80000 | | | 0x1C90000 0x1C91000 0x1C9F000 | | |
| +------------+ | | | | |
| | +-----------+------------------------------+ | |
| +-------------|--------------------+-----------+ |
| | | |
+---------------------------------|--------------------|---------------+
| |
v v
+----------------------------------------+
| per-slice IRQ (OR) summary IRQ |
| (QDU1000) (Lemans) |
+----------------------------------------+
|
v
+-----------------------------+
| Interrupt Controller |
+-----------------------------+The address offsets shown in the diagram above are specific to Qualcomm Lemans SoC.
This series currently covers only the TSC block driver functionality; ETU driver support will follow in a later series.
---
Imran Shaik (6):
dt-bindings: ptp: Document the TSCSS on Qualcomm Lemans and Monaco SoCs
dt-bindings: ptp: Document TSCSS hardware on Qualcomm QDU1000 SoC
ptp: qcom: Add PTP driver for the Qualcomm TSC hardware
arm64: defconfig: Enable Qualcomm TSC driver
arm64: dts: qcom: lemans: Add support for TSCSS node
arm64: dts: qcom: qdu1000: Add support for TSCSS node
.../devicetree/bindings/ptp/qcom,lemans-tscss.yaml | 198 ++++++++++ .../bindings/ptp/qcom,qdu1000-tscss.yaml | 187 ++++++++++ arch/arm64/boot/dts/qcom/lemans.dtsi | 11 + arch/arm64/boot/dts/qcom/qdu1000.dtsi | 11 + arch/arm64/configs/defconfig | 1 + drivers/ptp/Kconfig | 10 + drivers/ptp/Makefile | 1 + drivers/ptp/ptp_qcom_tsc.c | 413 +++++++++++++++++++++ 8 files changed, 832 insertions(+)
---
base-commit: c5e32e86ca02b003f86e095d379b38148999293d
change-id: 20260705-tscss-441d844c1ee7
Best regards,
Signature · 1 line
Imran Shaik <[email protected]>
PATCH 1/6 dt-bindings: ptp: Document the TSCSS on Qualcomm Lemans and Monaco SoCs
Add Devicetree bindings for the Timestamp Counter Subsystem (TSCSS) found on Qualcomm Lemans and Monaco SoCs.
TSCSS is a time synchronization subsystem composed of two main blocks:
Timestamp Counter (TSC) and Event Timestamp Unit (ETU). The TSC block provides a continuously running counter used for timekeeping, while the ETU captures timestamps for external hardware event triggers.
--- .../devicetree/bindings/ptp/qcom,lemans-tscss.yaml | 198 +++++++++++++++++++++ 1 file changed, 198 insertions(+)
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +198 -0
@@ -0,0 +1,198 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/ptp/qcom,lemans-tscss.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Timestamp Counter Subsystem (TSCSS) on Qualcomm Lemans and Monaco SoCs + +maintainers: + - Imran Shaik <[email protected]> + - Taniya Das <[email protected]> + +description: | + Qualcomm TSCSS is a time synchronization subsystem composed of two main + blocks - the Time Stamp Counter (TSC) and the Event Timestamp Unit (ETU). + + The TSC block is a timestamp generator that maintains a running counter used + for system timekeeping, and is functional with just the AHB and counter + clocks. + The ETU block is optional and captures TSC timestamps for external + hardware events, each ETU slice binding a slice identifier to an external + event selector. Support for the ETU block requires the additional ETU + clock along with the summary interrupt and slice subnodes. + +properties: + compatible: + oneOf: + - const: qcom,lemans-tscss + - items: + - const: qcom,monaco-tscss + - const: qcom,lemans-tscss + + reg: + maxItems: 1 + + reg-names: + items: + - const: tsc + + clocks: + minItems: 2 + items: + - description: TSC AHB configuration clock. + - description: TSC global counter clock. + - description: TSC ETU clock. + + clock-names: + minItems: 2 + items: + - const: ahb + - const: cntr + - const: etu + + interrupts: + description: Summary interrupt raised based on external event for any of the ETU slices. + maxItems: 1 + + interrupt-names: + items: + - const: etu_summary + + assigned-clocks: true + assigned-clock-rates: true + + "#address-cells": + const: 2 + + "#size-cells": + const: 2 + + ranges: true + +patternProperties: + "^etu-slice@[0-9a-f]+$": + type: object + description: ETU slice configuration + properties: + reg: + maxItems: 1 + + pinctrl-0: true + + pinctrl-names: + items: + - const: default + + qcom,etu-event-sel: + description: Event selection value for this slice. + $ref: /schemas/types.yaml#/definitions/uint32 + + qcom,etu-slice: + description: ETU slice identifier. + $ref: /schemas/types.yaml#/definitions/uint32 + + required: + - reg + - qcom,etu-event-sel + - qcom,etu-slice + - pinctrl-0 + - pinctrl-names + unevaluatedProperties: false + +required: + - compatible + - reg + - reg-names + - clocks + - clock-names + +allOf: + - if: + properties: + clock-names: + contains: + const: etu + then: + properties: + clocks: + minItems: 3 + clock-names: + minItems: 3 + required: + - interrupts + - interrupt-names + - "#address-cells" + - "#size-cells" + - ranges + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/clock/qcom,sa8775p-gcc.h> + + soc { + #address-cells = <2>; + #size-cells = <2>; + + tscss@1c80000 { + compatible = "qcom,lemans-tscss"; + reg = <0x0 0x01c80000 0x0 0x2000>; + reg-names = "tsc"; + + clocks = <&gcc GCC_TSCSS_AHB_CLK>, + <&gcc GCC_TSCSS_GLOBAL_CNTR_CLK>; + clock-names = "ahb", "cntr"; + + assigned-clocks = <&gcc GCC_TSCSS_GLOBAL_CNTR_CLK>; + assigned-clock-rates = <15625000>; + }; + }; + + - | + #include <dt-bindings/clock/qcom,sa8775p-gcc.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + + soc { + #address-cells = <2>; + #size-cells = <2>; + + tscss@1c80000 { + compatible = "qcom,lemans-tscss"; + reg = <0x0 0x01c80000 0x0 0x2000>; + reg-names = "tsc"; + #address-cells = <2>; + #size-cells = <2>; + ranges; + + clocks = <&gcc GCC_TSCSS_AHB_CLK>, + <&gcc GCC_TSCSS_GLOBAL_CNTR_CLK>, + <&gcc GCC_TSCSS_ETU_CLK>; + clock-names = "ahb", "cntr", "etu"; + + assigned-clocks = <&gcc GCC_TSCSS_GLOBAL_CNTR_CLK>, + <&gcc GCC_TSCSS_ETU_CLK>; + assigned-clock-rates = <15625000>, <15625000>; + + interrupts = <GIC_SPI 604 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "etu_summary"; + + etu-slice@1c91000 { + reg = <0x0 0x01c91000 0x0 0x1000>; + pinctrl-0 = <&cci_timer0>; + pinctrl-names = "default"; + qcom,etu-event-sel = <1>; + qcom,etu-slice = <1>; + }; + + etu-slice@1c92000 { + reg = <0x0 0x01c92000 0x0 0x1000>; + pinctrl-0 = <&cci_timer1>; + pinctrl-names = "default"; + qcom,etu-event-sel = <2>; + qcom,etu-slice = <2>; + }; + }; + }; +...
Signature · 1 line
2.34.1
Re: [PATCH 1/6] dt-bindings: ptp: Document the TSCSS on Qualcomm Lemans and Monaco SoCs
Quoted 39 lines · Imran Shaik
Add Devicetree bindings for the Timestamp Counter Subsystem (TSCSS) found on Qualcomm Lemans and Monaco SoCs.
TSCSS is a time synchronization subsystem composed of two main blocks:
Timestamp Counter (TSC) and Event Timestamp Unit (ETU). The TSC block provides a continuously running counter used for timekeeping, while the ETU captures timestamps for external hardware event triggers.Co-developed-by Taniya Das <[email protected]>Signed-off-by Taniya Das <[email protected]>Signed-off-by Imran Shaik <[email protected]>--- .../devicetree/bindings/ptp/qcom,lemans-tscss.yaml | 198 +++++++++++++++++++++ 1 file changed, 198 insertions(+)Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +18
-0@@ -0,0 +1,198 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/ptp/qcom,lemans-tscss.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Timestamp Counter Subsystem (TSCSS) on Qualcomm Lemans and Monaco SoCs + +maintainers: + - Imran Shaik <[email protected]> + - Taniya Das <[email protected]> + +description: | + Qualcomm TSCSS is a time synchronization subsystem composed of two main + blocks - the Time Stamp Counter (TSC) and the Event Timestamp Unit (ETU). + + The TSC block is a timestamp generator that maintains a running counter used + for system timekeeping, and is functional with just the AHB and counter
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml line 28
Quoted 10 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +10
-0+ clocks. + The ETU block is optional and captures TSC timestamps for external + hardware events, each ETU slice binding a slice identifier to an external + event selector. Support for the ETU block requires the additional ETU + clock along with the summary interrupt and slice subnodes. + +properties: + compatible: + oneOf: + - const: qcom,lemans-tscss
There is no such SoC upstream.
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml line 30
Quoted 2 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +2
-0+ - items: + - const: qcom,monaco-tscss
Neither this one.
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml line 38
Quoted 8 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +8
-0+ - const: qcom,lemans-tscss + + reg: + maxItems: 1 + + reg-names: + items: + - const: tsc
Drop names, not really useful.
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml line 48
Quoted 11 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +10
-0+ + clocks: + minItems: 2 + items: + - description: TSC AHB configuration clock. + - description: TSC global counter clock. + - description: TSC ETU clock. + + clock-names: + minItems: 2
Why is this flexible?
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml line 55
Quoted 7 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +7
-0+ items: + - const: ahb + - const: cntr + - const: etu + + interrupts: + description: Summary interrupt raised based on external event for any of the ETU slices.
Please follow Linux coding style.
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml line 63
Quoted 8 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +8
-0+ maxItems: 1 + + interrupt-names: + items: + - const: etu_summary + + assigned-clocks: true + assigned-clock-rates: true
Drop. From where did you take it?
Quoted 12 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +12
-0+ + "#address-cells": + const: 2 + + "#size-cells": + const: 2 + + ranges: true + +patternProperties: + "^etu-slice@[0-9a-f]+$": + type: object
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml line 85
Quoted 10 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +10
-0+ description: ETU slice configuration + properties: + reg: + maxItems: 1 + + pinctrl-0: true + + pinctrl-names: + items: + - const: default
Heh? Which code do you copy?
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml line 92
Quoted 7 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +7
-0+ + qcom,etu-event-sel: + description: Event selection value for this slice. + $ref: /schemas/types.yaml#/definitions/uint32 + + qcom,etu-slice: + description: ETU slice identifier.
You do not get identifiers. Please read writing bindings.
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml line 101
Quoted 9 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +9
-0+ $ref: /schemas/types.yaml#/definitions/uint32 + + required: + - reg + - qcom,etu-event-sel + - qcom,etu-slice + - pinctrl-0 + - pinctrl-names + unevaluatedProperties: false
Please read writing bindings.
Quoted 4 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +4
-0+ +required: + - compatible + - reg
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml line 115
Quoted 10 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +10
-0+ - reg-names + - clocks + - clock-names + +allOf: + - if: + properties: + clock-names: + contains: + const: etu
etu is third clock, what is the point of it?
Quoted 4 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +4
-0+ then: + properties: + clocks: + minItems: 3
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml line 129
Quoted 10 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +10
-0+ clock-names: + minItems: 3 + required: + - interrupts + - interrupt-names + - "#address-cells" + - "#size-cells" + - ranges + +unevaluatedProperties: false
Please read writing bindings.
Quoted 22 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +22
-0+ +examples: + - | + #include <dt-bindings/clock/qcom,sa8775p-gcc.h> + + soc { + #address-cells = <2>; + #size-cells = <2>; + + tscss@1c80000 { + compatible = "qcom,lemans-tscss"; + reg = <0x0 0x01c80000 0x0 0x2000>; + reg-names = "tsc"; + + clocks = <&gcc GCC_TSCSS_AHB_CLK>, + <&gcc GCC_TSCSS_GLOBAL_CNTR_CLK>; + clock-names = "ahb", "cntr"; + + assigned-clocks = <&gcc GCC_TSCSS_GLOBAL_CNTR_CLK>; + assigned-clock-rates = <15625000>; + }; + };
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml line 161
Quoted 10 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +10
-0+ + - | + #include <dt-bindings/clock/qcom,sa8775p-gcc.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + + soc { + #address-cells = <2>; + #size-cells = <2>; + + tscss@1c80000 {
This is the same node as previous.
I don't understand this DTS.
Node names should be generic. See also an explanation and list of examples (not exhaustive) in DT specification:
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendation
If you cannot find a name matching your device, please check in kernel sources for similar cases or you can grow the spec (via pull request to DT spec repo).
Best regards,
Krzysztof
Re: [PATCH 1/6] dt-bindings: ptp: Document the TSCSS on Qualcomm Lemans and Monaco SoCs
Quoted 54 lines · Krzysztof Kozlowski
Quoted 39 lines · Imran Shaik
Add Devicetree bindings for the Timestamp Counter Subsystem (TSCSS) found on Qualcomm Lemans and Monaco SoCs.
TSCSS is a time synchronization subsystem composed of two main blocks:
Timestamp Counter (TSC) and Event Timestamp Unit (ETU). The TSC block provides a continuously running counter used for timekeeping, while the ETU captures timestamps for external hardware event triggers.Co-developed-by Taniya Das <[email protected]>Signed-off-by Taniya Das <[email protected]>Signed-off-by Imran Shaik <[email protected]>--- .../devicetree/bindings/ptp/qcom,lemans-tscss.yaml | 198 +++++++++++++++++++++ 1 file changed, 198 insertions(+)Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +18
-0@@ -0,0 +1,198 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/ptp/qcom,lemans-tscss.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Timestamp Counter Subsystem (TSCSS) on Qualcomm Lemans and Monaco SoCs + +maintainers: + - Imran Shaik <[email protected]> + - Taniya Das <[email protected]> + +description: | + Qualcomm TSCSS is a time synchronization subsystem composed of two main + blocks - the Time Stamp Counter (TSC) and the Event Timestamp Unit (ETU). + + The TSC block is a timestamp generator that maintains a running counter used + for system timekeeping, and is functional with just the AHB and counterDocumentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml line 28
Quoted 10 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +10
-0+ clocks. + The ETU block is optional and captures TSC timestamps for external + hardware events, each ETU slice binding a slice identifier to an external + event selector. Support for the ETU block requires the additional ETU + clock along with the summary interrupt and slice subnodes. + +properties: + compatible: + oneOf: + - const: qcom,lemans-tscssThere is no such SoC upstream.
Quoted 5 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml line 30
Quoted 2 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +2
-0+ - items: + - const: qcom,monaco-tscssNeither this one.
Apologies for the late response.
Sure, will update the SoC names to sa8775p and qcs8300 respectively.
Quoted 12 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml line 38
Quoted 9 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +8
-0+ - const: qcom,lemans-tscss + + reg: + maxItems: 1 + + reg-names: + items: + - const: tscDrop names, not really useful.
Sure, will drop in the next version.
Quoted 12 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml line 48
Quoted 11 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +10
-0+ + clocks: + minItems: 2 + items: + - description: TSC AHB configuration clock. + - description: TSC global counter clock. + - description: TSC ETU clock. + + clock-names: + minItems: 2
Quoted 2 lines
Why is this flexible?
Actually, the TSC block can standalone work without the ETU support as well. This ETU clock is require only when we add the ETU slice sub nodes. Hence, keeping the minItems to 2, excluding the ETU clock.
Quoted 10 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml line 55
Quoted 7 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +7
-0+ items: + - const: ahb + - const: cntr + - const: etu + + interrupts: + description: Summary interrupt raised based on external event for any of the ETU slices.Please follow Linux coding style.
Sure, will update.
Quoted 11 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml line 63
Quoted 8 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +8
-0+ maxItems: 1 + + interrupt-names: + items: + - const: etu_summary + + assigned-clocks: true + assigned-clock-rates: trueDrop. From where did you take it?
Actually, we need these properties to be present in the DTS to take care of the clock rate requirements.
Please suggest on how to handle such requirements.
Quoted 16 lines
Quoted 16 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +16
-0+ + "#address-cells": + const: 2 + + "#size-cells": + const: 2 + + ranges: true + +patternProperties: + "^etu-slice@[0-9a-f]+$": + type: object + description: ETU slice configuration + properties: + reg: + maxItems: 1
Quoted 9 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml line 85
Quoted 6 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +6
-0+ + pinctrl-0: true + + pinctrl-names: + items: + - const: defaultHeh? Which code do you copy?
Each ETU slice has its own external event pin config, so kept pinctrl-0 and pinctrl-names on the slice subnode. Please suggest if you prefer otherwise.
Quoted 10 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml line 92
Quoted 7 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +7
-0+ + qcom,etu-event-sel: + description: Event selection value for this slice. + $ref: /schemas/types.yaml#/definitions/uint32 + + qcom,etu-slice: + description: ETU slice identifier.You do not get identifiers. Please read writing bindings.
In general, any ETU slice can function with any ETU event sel, and this might not be 1-1 always. Also, these ETU slices can be configured by the vendors based on the requirements of the GPIOs on the board. Hence, this etu-slice identifier will provide the flexibility to configure accordingly.
Quoted 10 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml line 101
Quoted 9 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +9
-0+ $ref: /schemas/types.yaml#/definitions/uint32 + + required: + - reg + - qcom,etu-event-sel + - qcom,etu-slice + - pinctrl-0 + - pinctrl-names + unevaluatedProperties: false
Quoted 2 lines
Please read writing bindings.
Sure, will drop this and use additionalProperties.
Quoted 8 lines
Quoted 8 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +8
-0+ +required: + - compatible + - reg + - reg-names + - clocks + - clock-names +
Quoted 9 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml line 115
Quoted 6 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +6
-0+allOf: + - if: + properties: + clock-names: + contains: + const: etuetu is third clock, what is the point of it?
As mentioned above the TSC clock can be functional individually. If we need the ETU sub block to be functional, then we need the ETU clock. To make the sub node properties mandatory, we are using the ETU clock to distinguish.
Quoted 8 lines
Quoted 8 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +8
-0+ then: + properties: + clocks: + minItems: 3 + clock-names: + minItems: 3 + required: + - interrupts
Quoted 8 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml line 129
Quoted 6 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +6
-0+ - interrupt-names + - "#address-cells" + - "#size-cells" + - ranges + +unevaluatedProperties: falsePlease read writing bindings.
Sure, will drop this and use additionalProperties.
Quoted 35 lines
Quoted 22 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +22
-0+ +examples: + - | + #include <dt-bindings/clock/qcom,sa8775p-gcc.h> + + soc { + #address-cells = <2>; + #size-cells = <2>; + + tscss@1c80000 { + compatible = "qcom,lemans-tscss"; + reg = <0x0 0x01c80000 0x0 0x2000>; + reg-names = "tsc"; + + clocks = <&gcc GCC_TSCSS_AHB_CLK>, + <&gcc GCC_TSCSS_GLOBAL_CNTR_CLK>; + clock-names = "ahb", "cntr"; + + assigned-clocks = <&gcc GCC_TSCSS_GLOBAL_CNTR_CLK>; + assigned-clock-rates = <15625000>; + }; + };Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml line 161
Quoted 10 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +10
-0+ + - | + #include <dt-bindings/clock/qcom,sa8775p-gcc.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + + soc { + #address-cells = <2>; + #size-cells = <2>; + + tscss@1c80000 {This is the same node as previous.
Quoted 2 lines
I don't understand this DTS.
I kept two different examples with and without ETU slice sub nodes, as TSC standalone block can be functional.
Quoted 8 lines
Node names should be generic. See also an explanation and list of examples (not exhaustive) in DT specification:
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendation
If you cannot find a name matching your device, please check in kernel sources for similar cases or you can grow the spec (via pull request to DT spec repo).
The recommended DT generic names, doesn't have the node names related to PTP/PHC. I found that other existing DTS nodes has the ptp/ptp-timer/phc naming convention used.
Please confirm if we can use the "ptp" name. Accordingly, I can raise the PR to DT spec repo as well.
Thanks,
Imran
Re: [PATCH 1/6] dt-bindings: ptp: Document the TSCSS on Qualcomm Lemans and Monaco SoCs
Quoted 11 lines · Imran Shaik
Quoted 11 lines
Quoted 10 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +9
-0+ clocks: + minItems: 2 + items: + - description: TSC AHB configuration clock. + - description: TSC global counter clock. + - description: TSC ETU clock. + + clock-names: + minItems: 2
Quoted 6 lines
Quoted 2 lines
Why is this flexible?
Actually, the TSC block can standalone work without the ETU support as well. This ETU clock is require only when we add the ETU slice sub nodes. Hence, keeping the minItems to 2, excluding the ETU clock.
Hardware either has them or not. Whether they are necessary to prepared/enabled is independent thing and job for the driver.
Quoted 26 lines
Quoted 11 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml line 55
Quoted 8 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +7
-0+ items: + - const: ahb + - const: cntr + - const: etu + + interrupts: + description: Summary interrupt raised based on external event for any of the ETU slices.Please follow Linux coding style.
Sure, will update.
Quoted 11 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml line 63
Quoted 8 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +8
-0+ maxItems: 1 + + interrupt-names: + items: + - const: etu_summary + + assigned-clocks: true + assigned-clock-rates: trueDrop. From where did you take it?
Quoted 4 lines
Actually, we need these properties to be present in the DTS to take care of the clock rate requirements.
Please suggest on how to handle such requirements.
Why does this binding has to be different than ALL other bindings in the kernel? I am not talking about DTS now.
Quoted 27 lines
Quoted 17 lines
Quoted 17 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +16
-0+ + "#address-cells": + const: 2 + + "#size-cells": + const: 2 + + ranges: true + +patternProperties: + "^etu-slice@[0-9a-f]+$": + type: object + description: ETU slice configuration + properties: + reg: + maxItems: 1Quoted 9 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml line 85
Quoted 6 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +6
-0+ + pinctrl-0: true + + pinctrl-names: + items: + - const: defaultHeh? Which code do you copy?
Quoted 3 lines
Each ETU slice has its own external event pin config, so kept pinctrl-0 and pinctrl-names on the slice subnode. Please suggest if you prefer otherwise.
No, from where did you get this code? Why are you sending bindings which are different then all other bindings?
Quoted 12 lines
Quoted 11 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml line 92
Quoted 8 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +7
-0+ + qcom,etu-event-sel: + description: Event selection value for this slice. + $ref: /schemas/types.yaml#/definitions/uint32 + + qcom,etu-slice: + description: ETU slice identifier.You do not get identifiers. Please read writing bindings.
Quoted 5 lines
In general, any ETU slice can function with any ETU event sel, and this might not be 1-1 always. Also, these ETU slices can be configured by the vendors based on the requirements of the GPIOs on the board. Hence, this etu-slice identifier will provide the flexibility to configure accordingly.
'reg' defines which ETU slice is this, no?
Best regards,
Krzysztof
Re: [PATCH 1/6] dt-bindings: ptp: Document the TSCSS on Qualcomm Lemans and Monaco SoCs
Quoted 15 lines · Krzysztof Kozlowski
Quoted 14 lines · Imran Shaik
Quoted 13 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml line 48
Quoted 10 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +9
-0+ clocks: + minItems: 2 + items: + - description: TSC AHB configuration clock. + - description: TSC global counter clock. + - description: TSC ETU clock. + + clock-names: + minItems: 2Why is this flexible?
Quoted 7 lines
Quoted 3 lines
Actually, the TSC block can standalone work without the ETU support as well. This ETU clock is require only when we add the ETU slice sub nodes. Hence, keeping the minItems to 2, excluding the ETU clock.
Hardware either has them or not. Whether they are necessary to prepared/enabled is independent thing and job for the driver.
Sure, will drop that flexible logic.
Quoted 27 lines
Quoted 27 lines
Quoted 10 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml line 55
Quoted 9 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +7
-0+ items: + - const: ahb + - const: cntr + - const: etu + + interrupts: + description: Summary interrupt raised based on external event for any of the ETU slices.Quoted 2 lines
Please follow Linux coding style.
Sure, will update.
Quoted 11 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml line 63
Quoted 8 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +8
-0+ maxItems: 1 + + interrupt-names: + items: + - const: etu_summary + + assigned-clocks: true + assigned-clock-rates: trueDrop. From where did you take it?
Quoted 8 lines
Quoted 4 lines
Actually, we need these properties to be present in the DTS to take care of the clock rate requirements.
Please suggest on how to handle such requirements.
Why does this binding has to be different than ALL other bindings in the kernel? I am not talking about DTS now.
Sure, will check and drop.
Quoted 27 lines
Quoted 27 lines
Quoted 26 lines
Quoted 13 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +12
-0+ + "#address-cells": + const: 2 + + "#size-cells": + const: 2 + + ranges: true + +patternProperties: + "^etu-slice@[0-9a-f]+$": + type: objectDocumentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml line 85
Quoted 10 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +10
-0+ description: ETU slice configuration + properties: + reg: + maxItems: 1 + + pinctrl-0: true + + pinctrl-names: + items: + - const: defaultHeh? Which code do you copy?
Quoted 7 lines
Quoted 3 lines
Each ETU slice has its own external event pin config, so kept pinctrl-0 and pinctrl-names on the slice subnode. Please suggest if you prefer otherwise.
No, from where did you get this code? Why are you sending bindings which are different then all other bindings?
I was referring to the example in [1] when adding the pinctrl properties under the etu-slice sub node.
[1] - Documentation/devicetree/bindings/media/samsung,exynos4212-fimc-is.yaml
On checking further, I found that our etu-slice sub node deviates from that example, since we don't have a compatible string for the sub node.
Please let me know if we should move the pinctrl properties under the tscss node with per-slice names, or instead keep them under the etu-slice sub node and add a compatible there.
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml line 92
Quoted 9 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +7
-0+ + qcom,etu-event-sel: + description: Event selection value for this slice. + $ref: /schemas/types.yaml#/definitions/uint32 + + qcom,etu-slice: + description: ETU slice identifier.You do not get identifiers. Please read writing bindings.
Quoted 8 lines
Quoted 5 lines
In general, any ETU slice can function with any ETU event sel, and this might not be 1-1 always. Also, these ETU slices can be configured by the vendors based on the requirements of the GPIOs on the board. Hence, this etu-slice identifier will provide the flexibility to configure accordingly.
'reg' defines which ETU slice is this, no?
Yes, will drop qcom,etu-slice property.
Quoted 3 lines
Best regards,
Krzysztof
Re: [PATCH 1/6] dt-bindings: ptp: Document the TSCSS on Qualcomm Lemans and Monaco SoCs
Quoted 18 lines · Imran Shaik
Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
Quoted 4 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +4
-0+ +patternProperties: + "^etu-slice@[0-9a-f]+$": + type: objectDocumentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml line 85
Quoted 10 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +10
-0+ description: ETU slice configuration + properties: + reg: + maxItems: 1 + + pinctrl-0: true + + pinctrl-names: + items: + - const: defaultHeh? Which code do you copy?
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Each ETU slice has its own external event pin config, so kept pinctrl-0 and pinctrl-names on the slice subnode. Please suggest if you prefer otherwise.
Just drop both pinctrl properties, because you should not need them. You define them only if they are different than default.
Quoted 10 lines
Quoted 4 lines
No, from where did you get this code? Why are you sending bindings which are different then all other bindings?
I was referring to the example in [1] when adding the pinctrl properties under the etu-slice sub node.
[1] -
Documentation/devicetree/bindings/media/samsung,exynos4212-fimc-is.yaml
That's like 13 years old device binding, so unfortunately likely antipattern.
Quoted 7 lines
On checking further, I found that our etu-slice sub node deviates from that example, since we don't have a compatible string for the sub node.
Please let me know if we should move the pinctrl properties under the tscss node with per-slice names, or instead keep them under the etu-slice sub node and add a compatible there.
etu-slice does not feel like device at all unfortunately. I see only address space, so one resource, which might be enough but lack of description for the subnode is not helping. I have doubts that separate subnodes should be there in the first place, but if they stay, describe the child node fully - what sort of device it is. Just because there is independent timestamping counter does not make it separate device, just like independent interrupt in GIC is not itself an independent device.
Best regards,
Krzysztof
Re: [PATCH 1/6] dt-bindings: ptp: Document the TSCSS on Qualcomm Lemans and Monaco SoCs
Quoted 19 lines · Krzysztof Kozlowski
Quoted 18 lines · Imran Shaik
Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
Quoted 4 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +4
-0+ +patternProperties: + "^etu-slice@[0-9a-f]+$": + type: objectDocumentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml line 85
Quoted 10 lines
Documentation/devicetree/bindings/ptp/qcom,lemans-tscss.yaml new file +10
-0+ description: ETU slice configuration + properties: + reg: + maxItems: 1 + + pinctrl-0: true + + pinctrl-names: + items: + - const: defaultHeh? Which code do you copy?
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Each ETU slice has its own external event pin config, so kept pinctrl-0 and pinctrl-names on the slice subnode. Please suggest if you prefer otherwise.
Just drop both pinctrl properties, because you should not need them. You define them only if they are different than default.
Thanks for the feedback, will drop this in next series.
Quoted 24 lines
Quoted 10 lines
Quoted 4 lines
No, from where did you get this code? Why are you sending bindings which are different then all other bindings?
I was referring to the example in [1] when adding the pinctrl properties under the etu-slice sub node.
[1] -
Documentation/devicetree/bindings/media/samsung,exynos4212-fimc-is.yamlThat's like 13 years old device binding, so unfortunately likely antipattern.
Quoted 7 lines
On checking further, I found that our etu-slice sub node deviates from that example, since we don't have a compatible string for the sub node.
Please let me know if we should move the pinctrl properties under the tscss node with per-slice names, or instead keep them under the etu-slice sub node and add a compatible there.
Quoted 8 lines
etu-slice does not feel like device at all unfortunately. I see only address space, so one resource, which might be enough but lack of description for the subnode is not helping. I have doubts that separate subnodes should be there in the first place, but if they stay, describe the child node fully - what sort of device it is. Just because there is independent timestamping counter does not make it separate device, just like independent interrupt in GIC is not itself an independent device.
The ETU is an independent hardware block within TSCSS that captures/ snapshots the TSC timestamp in response to an external hardware event trigger, for each slice individually. Hence the subnodes approach was followed and will capture these details in the description as well.
If we drop the subnodes and add everything into the parent TSCSS node instead, then all the arrays here must stay index aligned as per slice mapping. Example DTS node looks like this (QDU1000, 3 slices):
ptp@1da0000 {
compatible = "qcom,qdu1000-tscss";
reg = <0x0 0x01da0000 0x0 0x2000>,
<0x0 0x01db0000 0x0 0x10000>;
reg-names = "tsc", "etu";
...
interrupts = <GIC_SPI 329 IRQ_TYPE_EDGE_RISING>,
<GIC_SPI 333 IRQ_TYPE_EDGE_RISING>,
<GIC_SPI 334 IRQ_TYPE_EDGE_RISING>;
interrupt-names = "slice1", "slice5", "slice6";
pinctrl-0 = <&tod_pps>;
pinctrl-1 = <&gps_pps>;
pinctrl-2 = <&hardsync_pps>;
pinctrl-names = "slice1", "slice5", "slice6";
qcom,etu-slice = <1 5 6>;
qcom,etu-event-sel = <1 3 2>;
};Please help suggest which approach to follow here. Accordingly, I will update the bindings in next series.
Thanks,
Imran
Re: [PATCH 1/6] dt-bindings: ptp: Document the TSCSS on Qualcomm Lemans and Monaco SoCs
Quoted 18 lines · Imran Shaik
Quoted 9 lines
Quoted 8 lines
On checking further, I found that our etu-slice sub node deviates from that example, since we don't have a compatible string for the sub node.
Please let me know if we should move the pinctrl properties under the tscss node with per-slice names, or instead keep them under the etu-slice sub node and add a compatible there.
Quoted 8 lines
etu-slice does not feel like device at all unfortunately. I see only address space, so one resource, which might be enough but lack of description for the subnode is not helping. I have doubts that separate subnodes should be there in the first place, but if they stay, describe the child node fully - what sort of device it is. Just because there is independent timestamping counter does not make it separate device, just like independent interrupt in GIC is not itself an independent device.
Quoted 1 line
The ETU is an independent hardware block within TSCSS that captures/
How is it independent? I see no resources, except address space. A channel of some device does not mean it is a separate device.
Quoted 21 lines
snapshots the TSC timestamp in response to an external hardware event trigger, for each slice individually. Hence the subnodes approach was followed and will capture these details in the description as well.
If we drop the subnodes and add everything into the parent TSCSS node instead, then all the arrays here must stay index aligned as per slice mapping. Example DTS node looks like this (QDU1000, 3 slices):
ptp@1da0000 { compatible = "qcom,qdu1000-tscss"; reg = <0x0 0x01da0000 0x0 0x2000>, <0x0 0x01db0000 0x0 0x10000>; reg-names = "tsc", "etu"; ... interrupts = <GIC_SPI 329 IRQ_TYPE_EDGE_RISING>, <GIC_SPI 333 IRQ_TYPE_EDGE_RISING>, <GIC_SPI 334 IRQ_TYPE_EDGE_RISING>; interrupt-names = "slice1", "slice5", "slice6";
Quoted 7 lines
pinctrl-0 = <&tod_pps>; pinctrl-1 = <&gps_pps>; pinctrl-2 = <&hardsync_pps>; pinctrl-names = "slice1", "slice5", "slice6"; qcom,etu-slice = <1 5 6>; qcom,etu-event-sel = <1 3 2>;
Why this is not continuous? The slices are all fixed in the hardware. I don't get why do you list some of them.
Best regards,
Krzysztof
Re: [PATCH 1/6] dt-bindings: ptp: Document the TSCSS on Qualcomm Lemans and Monaco SoCs
Quoted 19 lines · Krzysztof Kozlowski
Quoted 18 lines · Imran Shaik
Quoted 17 lines
Quoted 8 lines
On checking further, I found that our etu-slice sub node deviates from that example, since we don't have a compatible string for the sub node.
Please let me know if we should move the pinctrl properties under the tscss node with per-slice names, or instead keep them under the etu-slice sub node and add a compatible there.
etu-slice does not feel like device at all unfortunately. I see only address space, so one resource, which might be enough but lack of description for the subnode is not helping. I have doubts that separate subnodes should be there in the first place, but if they stay, describe the child node fully - what sort of device it is. Just because there is independent timestamping counter does not make it separate device, just like independent interrupt in GIC is not itself an independent device.
Quoted 5 lines
Quoted 1 line
The ETU is an independent hardware block within TSCSS that captures/
How is it independent? I see no resources, except address space. A channel of some device does not mean it is a separate device.
Sure, got it.
Quoted 27 lines
Quoted 27 lines
snapshots the TSC timestamp in response to an external hardware event trigger, for each slice individually. Hence the subnodes approach was followed and will capture these details in the description as well.
If we drop the subnodes and add everything into the parent TSCSS node instead, then all the arrays here must stay index aligned as per slice mapping. Example DTS node looks like this (QDU1000, 3 slices):
ptp@1da0000 { compatible = "qcom,qdu1000-tscss"; reg = <0x0 0x01da0000 0x0 0x2000>, <0x0 0x01db0000 0x0 0x10000>; reg-names = "tsc", "etu"; ... interrupts = <GIC_SPI 329 IRQ_TYPE_EDGE_RISING>, <GIC_SPI 333 IRQ_TYPE_EDGE_RISING>, <GIC_SPI 334 IRQ_TYPE_EDGE_RISING>; interrupt-names = "slice1", "slice5", "slice6"; pinctrl-0 = <&tod_pps>; pinctrl-1 = <&gps_pps>; pinctrl-2 = <&hardsync_pps>; pinctrl-names = "slice1", "slice5", "slice6";
Quoted 6 lines
Quoted 2 lines
qcom,etu-slice = <1 5 6>; qcom,etu-event-sel = <1 3 2>;Why this is not continuous? The slices are all fixed in the hardware. I don't get why do you list some of them.
The slices are fixed and contiguous in hardware (e.g. QDU1000 has 16 ETU slices, 0-15), and accordingly will describe the bindings. But based on vendor/target board requirements, the slice configuration can use all 16 or only a few, and might not be continuous.
If the board requirement is to get the external hardware event sourced via certain GPIOs based on the availability, then accordingly, the ETU slice and respective event sel needs to be configured. In the example, slice 1, 5 and 6 are used to route TOD PPS, GPS PPS and hardsync PPS pins respectively on QDU1000 SoC, and the remaining slices are not used.
Thanks,
Imran
PATCH 2/6 dt-bindings: ptp: Document TSCSS hardware on Qualcomm QDU1000 SoC
In reply to Imran ShaikAdd Devicetree bindings for the Timestamp Counter Subsystem (TSCSS) found on Qualcomm QDU1000 SoC.
TSCSS is a time synchronization subsystem composed of two main blocks:
Timestamp Counter (TSC) and Event Timestamp Unit (ETU). The TSC block provides a continuously running counter used for timekeeping, while the ETU captures timestamps for external hardware event triggers.
--- .../bindings/ptp/qcom,qdu1000-tscss.yaml | 187 +++++++++++++++++++++ 1 file changed, 187 insertions(+)
Documentation/devicetree/bindings/ptp/qcom,qdu1000-tscss.yaml new file +187 -0
@@ -0,0 +1,187 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/ptp/qcom,qdu1000-tscss.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Timestamp Counter Subsystem (TSCSS) on Qualcomm QDU1000 SoC + +maintainers: + - Imran Shaik <[email protected]> + - Taniya Das <[email protected]> + +description: | + Qualcomm TSCSS is a time synchronization subsystem composed of two main + blocks - the Time Stamp Counter (TSC) and the Event Timestamp Unit (ETU). + + The TSC block is a timestamp generator that maintains a running counter used + for system timekeeping, and is functional with just the AHB and counter + clocks. + The ETU block is optional and captures TSC timestamps for external + hardware events, each ETU slice binding a slice identifier to an external + event selector. Support for the ETU block requires the additional ETU + clock along with the per slice interrupt and slice subnodes. + +properties: + compatible: + const: qcom,qdu1000-tscss + + reg: + maxItems: 1 + + reg-names: + items: + - const: tsc + + clocks: + minItems: 2 + items: + - description: TSC AHB configuration clock. + - description: TSC global counter clock. + - description: TSC ETU clock. + + clock-names: + minItems: 2 + items: + - const: ahb + - const: cntr + - const: etu + + assigned-clocks: true + assigned-clock-rates: true + + "#address-cells": + const: 2 + + "#size-cells": + const: 2 + + ranges: true + +patternProperties: + "^etu-slice@[0-9a-f]+$": + type: object + description: ETU slice configuration + properties: + reg: + maxItems: 1 + + pinctrl-0: true + + pinctrl-names: + items: + - const: default + + interrupts: + description: Per slice interrupt generated by ETU based on external event trigger. + maxItems: 1 + + qcom,etu-event-sel: + description: Event selection value for this slice. + $ref: /schemas/types.yaml#/definitions/uint32 + + qcom,etu-slice: + description: ETU slice identifier. + $ref: /schemas/types.yaml#/definitions/uint32 + + required: + - reg + - interrupts + - qcom,etu-event-sel + - qcom,etu-slice + - pinctrl-0 + - pinctrl-names + unevaluatedProperties: false + +required: + - compatible + - reg + - reg-names + - clocks + - clock-names + +allOf: + - if: + properties: + clock-names: + contains: + const: etu + then: + properties: + clocks: + minItems: 3 + clock-names: + minItems: 3 + required: + - "#address-cells" + - "#size-cells" + - ranges + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/clock/qcom,qdu1000-gcc.h> + + soc { + #address-cells = <2>; + #size-cells = <2>; + + tscss@1da0000 { + compatible = "qcom,qdu1000-tscss"; + reg = <0x0 0x01da0000 0x0 0x2000>; + reg-names = "tsc"; + + clocks = <&gcc GCC_TSC_CFG_AHB_CLK>, + <&gcc GCC_TSC_CNTR_CLK>; + clock-names = "ahb", "cntr"; + assigned-clocks = <&gcc GCC_TSC_CNTR_CLK>; + assigned-clock-rates = <500000000>; + }; + }; + + - | + #include <dt-bindings/clock/qcom,qdu1000-gcc.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + + soc { + #address-cells = <2>; + #size-cells = <2>; + + tscss@1da0000 { + compatible = "qcom,qdu1000-tscss"; + reg = <0x0 0x01da0000 0x0 0x2000>; + reg-names = "tsc"; + #address-cells = <2>; + #size-cells = <2>; + ranges; + + clocks = <&gcc GCC_TSC_CFG_AHB_CLK>, + <&gcc GCC_TSC_CNTR_CLK>, + <&gcc GCC_TSC_ETU_CLK>; + clock-names = "ahb", "cntr", "etu"; + + assigned-clocks = <&gcc GCC_TSC_CNTR_CLK>, + <&gcc GCC_TSC_ETU_CLK>; + assigned-clock-rates = <500000000>, <500000000>; + + etu-slice@1db1000 { + reg = <0x0 0x01db1000 0x0 0x1000>; + interrupts = <GIC_SPI 329 IRQ_TYPE_EDGE_RISING>; + pinctrl-0 = <&cci_timer0>; + pinctrl-names = "default"; + qcom,etu-event-sel = <1>; + qcom,etu-slice = <1>; + }; + + etu-slice@1db2000 { + reg = <0x0 0x01db2000 0x0 0x1000>; + interrupts = <GIC_SPI 330 IRQ_TYPE_EDGE_RISING>; + pinctrl-0 = <&cci_timer1>; + pinctrl-names = "default"; + qcom,etu-event-sel = <2>; + qcom,etu-slice = <2>; + }; + }; + }; +...
Signature · 1 line
2.34.1
Re: [PATCH 2/6] dt-bindings: ptp: Document TSCSS hardware on Qualcomm QDU1000 SoC
Quoted 38 lines · Imran Shaik
Add Devicetree bindings for the Timestamp Counter Subsystem (TSCSS) found on Qualcomm QDU1000 SoC.
TSCSS is a time synchronization subsystem composed of two main blocks:
Timestamp Counter (TSC) and Event Timestamp Unit (ETU). The TSC block provides a continuously running counter used for timekeeping, while the ETU captures timestamps for external hardware event triggers.Co-developed-by Taniya Das <[email protected]>Signed-off-by Taniya Das <[email protected]>Signed-off-by Imran Shaik <[email protected]>--- .../bindings/ptp/qcom,qdu1000-tscss.yaml | 187 +++++++++++++++++++++ 1 file changed, 187 insertions(+)Documentation/devicetree/bindings/ptp/qcom,qdu1000-tscss.yaml new file +17
-0@@ -0,0 +1,187 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/ptp/qcom,qdu1000-tscss.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Timestamp Counter Subsystem (TSCSS) on Qualcomm QDU1000 SoC + +maintainers: + - Imran Shaik <[email protected]> + - Taniya Das <[email protected]> + +description: | + Qualcomm TSCSS is a time synchronization subsystem composed of two main + blocks - the Time Stamp Counter (TSC) and the Event Timestamp Unit (ETU). + + The TSC block is a timestamp generator that maintains a running counter used
Documentation/devicetree/bindings/ptp/qcom,qdu1000-tscss.yaml line 27
Quoted 10 lines
Documentation/devicetree/bindings/ptp/qcom,qdu1000-tscss.yaml new file +10
-0+ for system timekeeping, and is functional with just the AHB and counter + clocks. + The ETU block is optional and captures TSC timestamps for external + hardware events, each ETU slice binding a slice identifier to an external + event selector. Support for the ETU block requires the additional ETU + clock along with the per slice interrupt and slice subnodes. + +properties: + compatible: + const: qcom,qdu1000-tscss
Why do you create a new file with exactly the same binding?
Anyway, all comments apply.
Best regards,
Krzysztof
Re: [PATCH 2/6] dt-bindings: ptp: Document TSCSS hardware on Qualcomm QDU1000 SoC
Quoted 43 lines · Krzysztof Kozlowski
Quoted 42 lines · Imran Shaik
Add Devicetree bindings for the Timestamp Counter Subsystem (TSCSS) found on Qualcomm QDU1000 SoC.
TSCSS is a time synchronization subsystem composed of two main blocks:
Timestamp Counter (TSC) and Event Timestamp Unit (ETU). The TSC block provides a continuously running counter used for timekeeping, while the ETU captures timestamps for external hardware event triggers.Co-developed-by Taniya Das <[email protected]>Signed-off-by Taniya Das <[email protected]>Signed-off-by Imran Shaik <[email protected]>--- .../bindings/ptp/qcom,qdu1000-tscss.yaml | 187 +++++++++++++++++++++ 1 file changed, 187 insertions(+)Documentation/devicetree/bindings/ptp/qcom,qdu1000-tscss.yaml new file +21
-0@@ -0,0 +1,187 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/ptp/qcom,qdu1000-tscss.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Timestamp Counter Subsystem (TSCSS) on Qualcomm QDU1000 SoC + +maintainers: + - Imran Shaik <[email protected]> + - Taniya Das <[email protected]> + +description: | + Qualcomm TSCSS is a time synchronization subsystem composed of two main + blocks - the Time Stamp Counter (TSC) and the Event Timestamp Unit (ETU). + + The TSC block is a timestamp generator that maintains a running counter used + for system timekeeping, and is functional with just the AHB and counter + clocks. + The ETU block is optional and captures TSC timestamps for external + hardware events, each ETU slice binding a slice identifier to an external
Quoted 9 lines
Documentation/devicetree/bindings/ptp/qcom,qdu1000-tscss.yaml line 27
Quoted 6 lines
Documentation/devicetree/bindings/ptp/qcom,qdu1000-tscss.yaml new file +6
-0+ event selector. Support for the ETU block requires the additional ETU + clock along with the per slice interrupt and slice subnodes. + +properties: + compatible: + const: qcom,qdu1000-tscssWhy do you create a new file with exactly the same binding?
The QDU1000 SoC TSCSS has the per ETU slice IRQ lines. Where as in Lemans/Monaco, it is summary IRQ line for all the ETU slices. Hence, kept two different bindings for both the SoCs.
Quoted 2 lines
Anyway, all comments apply.
Sure, will take care of those comments here as well.
Thanks,
Imran
[email protected]
AI reviewRe: [PATCH 2/6] dt-bindings: ptp: Document TSCSS hardware on Qualcomm QDU1000 SoC
In reply to Imran ShaikThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] The DT binding schema fails to forbid ETU slice subnodes and related address properties when the…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The DT binding schema fails to forbid ETU slice subnodes and related address properties when the ETU clock is missing. --
--- Patch [2]: [PATCH 2/6] dt-bindings: ptp: Document TSCSS hardware on Qualcomm QDU1000 SoC --- commit fa3eee253cb3594f0f82d586d18506452f967b6b
Author: Imran Shaik <[email protected]>
dt-bindings: ptp: Document TSCSS hardware on Qualcomm QDU1000 SoC
This commit adds Devicetree bindings for the Timestamp Counter Subsystem (TSCSS) found on the Qualcomm QDU1000 SoC. It defines the required properties for the core TSC block as well as the optional Event Timestamp Unit (ETU) block and its slice subnodes.
Quoted 4 lines
Documentation/devicetree/bindings/ptp/qcom,qdu1000-tscss.yaml new file +0
-0
[ ... ]
Quoted 6 lines
Documentation/devicetree/bindings/ptp/qcom,qdu1000-tscss.yaml new file +6
-0+allOf: + - if: + properties: + clock-names: + contains: + const: etu
Documentation/devicetree/bindings/ptp/qcom,qdu1000-tscss.yaml line 118
Quoted 10 lines
Documentation/devicetree/bindings/ptp/qcom,qdu1000-tscss.yaml new file +10
-0+ then: + properties: + clocks: + minItems: 3 + clock-names: + minItems: 3 + required: + - "#address-cells" + - "#size-cells" + - ranges
[Severity: Low]
Does this conditional block need an 'else' clause to forbid the ETU slice subnodes and related address properties when the ETU clock is missing?
The commit message notes that support for the ETU block requires the ETU clock along with the slice subnodes. Without an 'else' block explicitly setting '#address-cells', 'ranges', and 'patternProperties:
"^etu-slice@[0-9a-f]+$"' to false, a device tree could configure ETU slices while omitting the required ETU clock and still incorrectly pass schema validation.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
PATCH 3/6 ptp: qcom: Add PTP driver for the Qualcomm TSC hardware
In reply to Imran ShaikAdd a PTP Hardware Clock driver for the Qualcomm Timestamp Counter (TSC) hardware found on Qualcomm Lemans and QDU1000 SoCs. The TSC is a free running hardware counter used for time synchronization, clocked by an AHB configuration clock and a global counter clock, with the counter resolution varying across SoCs.
--- drivers/ptp/Kconfig | 10 ++ drivers/ptp/Makefile | 1 + drivers/ptp/ptp_qcom_tsc.c | 413 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 424 insertions(+)
drivers/ptp/Kconfig +10 -0
@@ -263,4 +263,14 @@ config PTP_NETC_V4_TIMER synchronization. It also supports periodic output signal (e.g. PPS) and external trigger timestamping. +config PTP_QCOM_TSC + tristate "Qualcomm TSC as PTP clock" + depends on COMMON_CLK && PTP_1588_CLOCK + help + This driver adds support for using the Qualcomm Timestamp Counter + Subsystem (TSCSS) as a PTP clock. + + To compile this driver as a module, choose M here: the module + will be called ptp_qcom_tsc. + endmenu
drivers/ptp/Makefile +1 -0
@@ -22,3 +22,4 @@ obj-$(CONFIG_PTP_1588_CLOCK_OCP) += ptp_ocp.o obj-$(CONFIG_PTP_DFL_TOD) += ptp_dfl_tod.o obj-$(CONFIG_PTP_S390) += ptp_s390.o obj-$(CONFIG_PTP_NETC_V4_TIMER) += ptp_netc.o +obj-$(CONFIG_PTP_QCOM_TSC) += ptp_qcom_tsc.o
drivers/ptp/ptp_qcom_tsc.c new file +413 -0
413 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH 3/6] ptp: qcom: Add PTP driver for the Qualcomm TSC hardware
Quoted 20 lines · Imran Shaik
Add a PTP Hardware Clock driver for the Qualcomm Timestamp Counter (TSC) hardware found on Qualcomm Lemans and QDU1000 SoCs. The TSC is a free running hardware counter used for time synchronization, clocked by an AHB configuration clock and a global counter clock, with the counter resolution varying across SoCs.
Co-developed-by Taniya Das <[email protected]>Signed-off-by Taniya Das <[email protected]>Signed-off-by Imran Shaik <[email protected]>--- drivers/ptp/Kconfig | 10 ++ drivers/ptp/Makefile | 1 + drivers/ptp/ptp_qcom_tsc.c | 413 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 424 insertions(+)drivers/ptp/Kconfig +0
-0
drivers/ptp/Kconfig config PTP_NETC_V4_TIMER · line 267
Quoted 5 lines
drivers/ptp/Kconfig +2
-0@@ -263,4 +263,14 @@ config PTP_NETC_V4_TIMER synchronization. It also supports periodic output signal (e.g. PPS) and external trigger timestamping. +config PTP_QCOM_TSC + tristate "Qualcomm TSC as PTP clock"
Missing depensd on ARCH_QCOM
Quoted 9 lines
drivers/ptp/Kconfig +8
-0+ depends on COMMON_CLK && PTP_1588_CLOCK + help + This driver adds support for using the Qualcomm Timestamp Counter + Subsystem (TSCSS) as a PTP clock. + + To compile this driver as a module, choose M here: the module + will be called ptp_qcom_tsc. + endmenu
...
drivers/ptp/Kconfig
Quoted 9 lines
drivers/ptp/Kconfig +9
-0+ +static const struct of_device_id qcom_tsc_of_match[] = { + { .compatible = "qcom,lemans-tscss", .data = &qcom_tsc_lemans }, + { .compatible = "qcom,qdu1000-tscss", .data = &qcom_tsc_qdu1000 }, + { } +}; +MODULE_DEVICE_TABLE(of, qcom_tsc_of_match); + +static void qcom_ptp_tsc_remove(struct platform_device *pdev)
Completely broken order of ID table, remove() and probe(). Remove ALWAYS follows probe. Table is next to them. Please look at other drivers.
Quoted 51 lines
drivers/ptp/Kconfig +51
-0+{ + struct qcom_tsc *tsc = platform_get_drvdata(pdev); + + if (tsc && tsc->ptp) { + ptp_clock_unregister(tsc->ptp); + tsc->ptp = NULL; + } +} + +static int qcom_ptp_tsc_probe(struct platform_device *pdev) +{ + const struct qcom_tsc_soc_data *soc; + struct qcom_tsc *tsc; + struct resource *r_mem; + int ret; + + soc = of_device_get_match_data(&pdev->dev); + if (!soc) + return -ENODEV; + + tsc = devm_kzalloc(&pdev->dev, sizeof(*tsc), GFP_KERNEL); + if (!tsc) + return -ENOMEM; + + tsc->dev = &pdev->dev; + tsc->soc = soc; + + ret = devm_mutex_init(&pdev->dev, &tsc->lock); + if (ret) + return ret; + + r_mem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "tsc"); + if (!r_mem) { + dev_err(&pdev->dev, "no IO resource defined\n"); + return -ENXIO; + } + + tsc->base = devm_ioremap_resource(&pdev->dev, r_mem); + if (IS_ERR(tsc->base)) + return PTR_ERR(tsc->base); + + tsc->ahb_clk = devm_clk_get_enabled(&pdev->dev, "ahb"); + if (IS_ERR(tsc->ahb_clk)) + return PTR_ERR(tsc->ahb_clk); + + tsc->cntr_clk = devm_clk_get_enabled(&pdev->dev, "cntr"); + if (IS_ERR(tsc->cntr_clk)) + return PTR_ERR(tsc->cntr_clk); + + /* ETU clock is optional, only required when the ETU block is used */ + tsc->etu_clk = devm_clk_get_optional_enabled(&pdev->dev, "etu");
drivers/ptp/Kconfig
Quoted 10 lines
drivers/ptp/Kconfig +10
-0+ if (IS_ERR(tsc->etu_clk)) + return PTR_ERR(tsc->etu_clk); + + tsc->ptp_info = qcom_ptp_info; + + tsc->ptp = ptp_clock_register(&tsc->ptp_info, &pdev->dev); + if (IS_ERR(tsc->ptp)) { + ret = PTR_ERR(tsc->ptp); + dev_err(&pdev->dev, "Failed to register ptp clock\n"); + return ret;
Why aren't you using dev_err_probe?
Quoted 10 lines
drivers/ptp/Kconfig +9
-0+ } + + platform_set_drvdata(pdev, tsc); + + return 0; +} + +static struct platform_driver qcom_ptp_tsc_driver = { + .probe = qcom_ptp_tsc_probe,
drivers/ptp/Kconfig
Quoted 10 lines
drivers/ptp/Kconfig +10
-0+ .remove = qcom_ptp_tsc_remove, + .driver = { + .name = "qcom_ptp_tsc", + .of_match_table = qcom_tsc_of_match, + }, +}; +module_platform_driver(qcom_ptp_tsc_driver); + +MODULE_DESCRIPTION("PTP QCOM TSC driver"); +MODULE_LICENSE("GPL");
Best regards,
Krzysztof
Re: [PATCH 3/6] ptp: qcom: Add PTP driver for the Qualcomm TSC hardware
Quoted 24 lines · Krzysztof Kozlowski
Quoted 23 lines · Imran Shaik
Add a PTP Hardware Clock driver for the Qualcomm Timestamp Counter (TSC) hardware found on Qualcomm Lemans and QDU1000 SoCs. The TSC is a free running hardware counter used for time synchronization, clocked by an AHB configuration clock and a global counter clock, with the counter resolution varying across SoCs.
Co-developed-by Taniya Das <[email protected]>Signed-off-by Taniya Das <[email protected]>Signed-off-by Imran Shaik <[email protected]>--- drivers/ptp/Kconfig | 10 ++ drivers/ptp/Makefile | 1 + drivers/ptp/ptp_qcom_tsc.c | 413 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 424 insertions(+)drivers/ptp/Kconfig +0
-0@@ -263,4 +263,14 @@ config PTP_NETC_V4_TIMER synchronization. It also supports periodic output signal (e.g. PPS) and external trigger timestamping.
Quoted 5 lines
drivers/ptp/Kconfig config PTP_NETC_V4_TIMER · line 267
Quoted 2 lines
drivers/ptp/Kconfig +2
-0+config PTP_QCOM_TSC + tristate "Qualcomm TSC as PTP clock"Missing depensd on
ARCH_QCOM
Will fix it in the next series.
Quoted 12 lines
Quoted 9 lines
drivers/ptp/Kconfig +8
-0+ depends on COMMON_CLK && PTP_1588_CLOCK + help + This driver adds support for using the Qualcomm Timestamp Counter + Subsystem (TSCSS) as a PTP clock. + + To compile this driver as a module, choose M here: the module + will be called ptp_qcom_tsc. + endmenu...
Quoted 13 lines
drivers/ptp/Kconfig
Quoted 9 lines
drivers/ptp/Kconfig +9
-0+ +static const struct of_device_id qcom_tsc_of_match[] = { + { .compatible = "qcom,lemans-tscss", .data = &qcom_tsc_lemans }, + { .compatible = "qcom,qdu1000-tscss", .data = &qcom_tsc_qdu1000 }, + { } +}; +MODULE_DEVICE_TABLE(of, qcom_tsc_of_match); + +static void qcom_ptp_tsc_remove(struct platform_device *pdev)Completely broken order of ID table,
remove()andprobe(). Remove ALWAYS follows probe. Table is next to them. Please look at other drivers.
Sure, will correct the order in the next series.
Quoted 55 lines
Quoted 55 lines
drivers/ptp/Kconfig +55
-0+{ + struct qcom_tsc *tsc = platform_get_drvdata(pdev); + + if (tsc && tsc->ptp) { + ptp_clock_unregister(tsc->ptp); + tsc->ptp = NULL; + } +} + +static int qcom_ptp_tsc_probe(struct platform_device *pdev) +{ + const struct qcom_tsc_soc_data *soc; + struct qcom_tsc *tsc; + struct resource *r_mem; + int ret; + + soc = of_device_get_match_data(&pdev->dev); + if (!soc) + return -ENODEV; + + tsc = devm_kzalloc(&pdev->dev, sizeof(*tsc), GFP_KERNEL); + if (!tsc) + return -ENOMEM; + + tsc->dev = &pdev->dev; + tsc->soc = soc; + + ret = devm_mutex_init(&pdev->dev, &tsc->lock); + if (ret) + return ret; + + r_mem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "tsc"); + if (!r_mem) { + dev_err(&pdev->dev, "no IO resource defined\n"); + return -ENXIO; + } + + tsc->base = devm_ioremap_resource(&pdev->dev, r_mem); + if (IS_ERR(tsc->base)) + return PTR_ERR(tsc->base); + + tsc->ahb_clk = devm_clk_get_enabled(&pdev->dev, "ahb"); + if (IS_ERR(tsc->ahb_clk)) + return PTR_ERR(tsc->ahb_clk); + + tsc->cntr_clk = devm_clk_get_enabled(&pdev->dev, "cntr"); + if (IS_ERR(tsc->cntr_clk)) + return PTR_ERR(tsc->cntr_clk); + + /* ETU clock is optional, only required when the ETU block is used */ + tsc->etu_clk = devm_clk_get_optional_enabled(&pdev->dev, "etu"); + if (IS_ERR(tsc->etu_clk)) + return PTR_ERR(tsc->etu_clk); + + tsc->ptp_info = qcom_ptp_info;
Quoted 9 lines
drivers/ptp/Kconfig
Quoted 6 lines
drivers/ptp/Kconfig +6
-0+ + tsc->ptp = ptp_clock_register(&tsc->ptp_info, &pdev->dev); + if (IS_ERR(tsc->ptp)) { + ret = PTR_ERR(tsc->ptp); + dev_err(&pdev->dev, "Failed to register ptp clock\n"); + return ret;Why aren't you using
dev_err_probe?
Sure, will use the dev_err_probe in the next series.
Thanks,
Imran
Quoted 24 lines
Quoted 10 lines
drivers/ptp/Kconfig +9
-0+ } + + platform_set_drvdata(pdev, tsc); + + return 0; +} + +static struct platform_driver qcom_ptp_tsc_driver = { + .probe = qcom_ptp_tsc_probe,drivers/ptp/Kconfig
Quoted 10 lines
drivers/ptp/Kconfig +10
-0+ .remove = qcom_ptp_tsc_remove, + .driver = { + .name = "qcom_ptp_tsc", + .of_match_table = qcom_tsc_of_match, + }, +}; +module_platform_driver(qcom_ptp_tsc_driver); + +MODULE_DESCRIPTION("PTP QCOM TSC driver"); +MODULE_LICENSE("GPL");Best regards,
Krzysztof
Jakub Kicinski
maintainerRe: [PATCH 3/6] ptp: qcom: Add PTP driver for the Qualcomm TSC hardware
In reply to Imran Shaikdrivers/ptp/ptp_qcom_tsc.c line 128
Quoted 12 lines · On Mon, 27 Jul 2026 19:40:59 +0530 Imran Shaik wrote:
drivers/ptp/ptp_qcom_tsc.c new file +12
-0+static inline void qcom_tsc_split_ts (struct qcom_tsc *tsc,struct timespec64 ts,u32 *hi,u32 *lo) +{ +if (tsc->soc->rollover) { + *hi = ts.tv_sec; + *lo = ts.tv_nsec; + }else { +u64 ns =timespec64_to_ns (&ts); + + *lo =lower_32_bits (ns); + *hi =upper_32_bits (ns); + } +}
Are you sure the compiler doesn't inline this trivial function with 2 callers even without the inline keyword. Compilers seem to inline as much as possible these days.
Re: [PATCH 3/6] ptp: qcom: Add PTP driver for the Qualcomm TSC hardware
Quoted 17 lines · Jakub Kicinski
drivers/ptp/ptp_qcom_tsc.c line 128
Quoted 12 lines · On Mon, 27 Jul 2026 19:40:59 +0530 Imran Shaik wrote:
drivers/ptp/ptp_qcom_tsc.c new file +12
-0+static inline void qcom_tsc_split_ts (struct qcom_tsc *tsc,struct timespec64 ts,u32 *hi,u32 *lo) +{ +if (tsc->soc->rollover) { + *hi = ts.tv_sec; + *lo = ts.tv_nsec; + }else { +u64 ns =timespec64_to_ns (&ts); + + *lo =lower_32_bits (ns); + *hi =upper_32_bits (ns); + } +}Are you sure the compiler doesn't inline this trivial function with 2 callers even without the inline keyword. Compilers seem to inline as much as possible these days.
Sure, will drop the inline keyword in the next series.
Thanks,
Imran
[email protected]
AI reviewRe: [PATCH 3/6] ptp: qcom: Add PTP driver for the Qualcomm TSC hardware
In reply to Imran ShaikThank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider: - [High] The `adjfine` implementation improperly applies a one-shot phase shift and fails to clear…
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
- [High] The adjfine implementation improperly applies a one-shot phase shift and fails to clear adjustments on zero, rather than configuring continuous frequency modification.
- [High] The hardware fallback path for adjtime physically stops the hardware counter, causing lost ticks and non-deterministic negative phase drift.
- [High] Sequential 32-bit reads of the 64-bit hardware counter lack a retry loop, exposing severe backwards time jumps during rollover.
- [High] The adjfine drift calculation silently drops small negative adjustments by computing a period of zero.
- [Medium] The PULSE_WIDTH_MASK configuration in qcom_tsc_settime() is corrupted by a missing bitwise clear before applying FIELD_PREP.
--
--- Patch [3]: [PATCH 3/6] ptp: qcom: Add PTP driver for the Qualcomm TSC hardware --- commit df14ad1f19420dd656de996ed9674c4b2511975f
Author: Imran Shaik <[email protected]>
ptp: qcom: Add PTP driver for the Qualcomm TSC hardware
Add a PTP Hardware Clock driver for the Qualcomm Timestamp Counter (TSC) hardware found on Qualcomm Lemans and QDU1000 SoCs. The TSC is a free running hardware counter used for time synchronization, clocked by an AHB configuration clock and a global counter clock.
Quoted 5 lines
drivers/ptp/ptp_qcom_tsc.c new file +0
-0
[ ... ]
drivers/ptp/ptp_qcom_tsc.c line 91
Quoted 10 lines
drivers/ptp/ptp_qcom_tsc.c new file +10
-0+static int qcom_tsc_read_time (struct qcom_tsc *tsc,struct timespec64 *ts) +{ +const struct qcom_tsc_regs *regs = tsc->soc->reg_layout; +u32 hi, lo; + +if (!qcom_tsc_is_enabled (tsc)) +return -EINVAL ; + + hi =readl_relaxed (tsc->base + regs->read_cntcv_hi); + lo =readl_relaxed (tsc->base + regs->read_cntcv_lo);
[Severity: High]
Does this sequential read risk returning backward time jumps during rollover?
If the lower 32-bit register rolls over between reading the upper and lower registers, could this return a stale upper half combined with a wrapped lower half? Is a retry loop needed here to ensure consistency?
Quoted 12 lines
drivers/ptp/ptp_qcom_tsc.c new file +12
-0+ +if (tsc->soc->rollover) { + ts->tv_sec = hi; + ts->tv_nsec = lo; + }else { +u64 ns = ((u64 )hi <<NSEC_SHIFT ) | lo; + + *ts =ns_to_timespec64 (ns); + } + +return 0 ; +}
[ ... ]
Quoted 18 lines
drivers/ptp/ptp_qcom_tsc.c new file +18
-0+static int qcom_tsc_update_offset (struct qcom_tsc *tsc,const struct timespec64 ts) +{ +const struct qcom_tsc_regs *regs = tsc->soc->reg_layout; +struct timespec64 tod; +u32 regval, hi, lo; +int ret; + +if (tsc->soc->offset_correction) { +qcom_tsc_split_ts (tsc, ts, &hi, &lo); + +writel_relaxed (lo, tsc->base + regs->offset_lo); +writel_relaxed (hi, tsc->base + regs->offset_hi); + +return 0 ; + } + +/* +* No hardware offset correction support: disable and reload the
drivers/ptp/ptp_qcom_tsc.c line 174
Quoted 10 lines
drivers/ptp/ptp_qcom_tsc.c new file +10
-0+* counter with the corrected time, as recommended by the hardware +* design team. +*/ + ret =qcom_tsc_read_time (tsc, &tod); +if (ret) +return ret; + + regval =readl_relaxed (tsc->base + regs->control_cntcr); + regval &= ~BIT (0 ); +writel_relaxed (regval, tsc->base + regs->control_cntcr);
[Severity: High]
Does disabling the counter during the update permanently lose hardware ticks?
When the software update occurs on SoCs without hardware offset correction, the time elapsed between reading the time and disabling the counter seems to be permanently dropped. Could this introduce negative drift and jitter on each call to adjtime?
Quoted 3 lines
drivers/ptp/ptp_qcom_tsc.c new file +3
-0+ +return qcom_tsc_update_counter (tsc,timespec64_add (tod, ts)); +}
[ ... ]
Quoted 11 lines
drivers/ptp/ptp_qcom_tsc.c new file +11
-0+static int qcom_tsc_settime (struct ptp_clock_info *ptp,const struct timespec64 *ts) +{ + struct qcom_tsc *tsc = container_of(ptp, struct qcom_tsc, ptp_info); +const struct qcom_tsc_regs *regs = tsc->soc->reg_layout; +struct timespec64 tod; +u32 regval; +int ret; + +mutex_lock (&tsc->lock); + +if (qcom_tsc_is_enabled (tsc)) {
drivers/ptp/ptp_qcom_tsc.c line 199
Quoted 10 lines
drivers/ptp/ptp_qcom_tsc.c new file +10
-0+qcom_tsc_read_time (tsc, &tod); + ret =qcom_tsc_update_offset (tsc,timespec64_sub (*ts, tod)); +mutex_unlock (&tsc->lock); +return ret; + } + +/* Configure and enable the TSC counter */ + regval =readl_relaxed (tsc->base + regs->control_cntcr); + regval |=FIELD_PREP (PULSE_WIDTH_MASK , tsc->soc->pulse_width); +writel_relaxed (regval, tsc->base + regs->control_cntcr);
[Severity: Medium]
Should the PULSE_WIDTH_MASK bits be cleared before applying the bitwise OR?
If there are previous bits set in this field, could the bitwise OR without a preceding bitwise clear leave those bits set and corrupt the pulse width configuration?
Quoted 9 lines
drivers/ptp/ptp_qcom_tsc.c new file +9
-0+ +if (tsc->soc->rollover) +writel_relaxed (ROLLOVER_VAL , tsc->base + regs->rollover_val); + + ret =qcom_tsc_update_counter (tsc, *ts); +mutex_unlock (&tsc->lock); + +return ret; +}
[ ... ]
Quoted 6 lines
drivers/ptp/ptp_qcom_tsc.c new file +6
-0+static int qcom_tsc_drift_correction (struct qcom_tsc *tsc,long scaled_ppm) +{ +const struct qcom_tsc_soc_data *soc = tsc->soc; +const struct qcom_tsc_regs *regs = soc->reg_layout; +long ppb =scaled_ppm_to_ppb (scaled_ppm); +u64 period, incval =0 ;
drivers/ptp/ptp_qcom_tsc.c line 237
Quoted 10 lines
drivers/ptp/ptp_qcom_tsc.c new file +10
-0+u32 regval =0 , subperiod; + +if (ppb <0 ) { + ppb = -ppb; + regval &= ~DRIFT_JUMP_SWALLOW ; + + period =div_u64 (ppb, soc->cntr_res); +if (period >=DRIFT_MAX_RES ) + period =DRIFT_MAX_RES ; + }else {
[Severity: High]
Does this calculation silently drop small negative adjustments?
When ppb is less than zero and its absolute value is smaller than soc->cntr_res, div_u64 will evaluate to 0.
Since the negative branch lacks the fallback to period = 1 that the positive branch has, does this result in a period of 0 being written to hardware for fine-grained negative frequency adjustments?
Quoted 22 lines
drivers/ptp/ptp_qcom_tsc.c new file +22
-0+ regval |=DRIFT_JUMP_SWALLOW ; + + period =div_u64 (ppb, soc->cntr_res); +if (period >=DRIFT_MAX_RES ) { + period =DRIFT_MAX_RES ; + incval = soc->cntr_res *2 ; + }else if (ppb < soc->cntr_res) { + incval = soc->cntr_res + ppb; + period =1 ; + }else { + incval = soc->cntr_res *2 ; + } + } + + subperiod = soc->pulse_width *2 ; + regval |=FIELD_PREP (DRIFT_SUBPERIOD_MASK , subperiod); + regval |=FIELD_PREP (DRIFT_PERIOD_MASK , period); + +/* Update jump/swallow, period, subperiod */ +writel_relaxed (regval, tsc->base + regs->drift_correct_duration); + +writel_relaxed (incval, tsc->base + regs->drift_correct_incr_val);
drivers/ptp/ptp_qcom_tsc.c line 269
Quoted 10 lines
drivers/ptp/ptp_qcom_tsc.c new file +10
-0+ +/* Trigger the drift correction */ + regval =readl_relaxed (tsc->base + regs->drift_correct_cmd); + regval |=BIT (0 ); +writel_relaxed (regval, tsc->base + regs->drift_correct_cmd); + +return readl_poll_timeout (tsc->base + regs->drift_correct_cmd, regval, + !(regval &BIT (1 )),DRIFT_INTERVAL_US , +DRIFT_TIMEOUT_US (period, subperiod, soc->cntr_res)); +}
[Severity: High]
Does this trigger a one-shot phase shift instead of continuous drift correction?
The ptp daemon expects adjfine to configure a continuous hardware clock rate adjustment. Since this block triggers a correction and polls for completion, does the hardware just return to its nominal rate afterwards?
Will the ptp synchronization servo fail to stabilize if the frequency is not actually adjusted continuously?
drivers/ptp/ptp_qcom_tsc.c line 277
Quoted 8 lines
drivers/ptp/ptp_qcom_tsc.c new file +8
-0+ +static int qcom_tsc_adjfine (struct ptp_clock_info *ptp,long scaled_ppm) +{ + struct qcom_tsc *tsc = container_of(ptp, struct qcom_tsc, ptp_info); +int ret; + +if (scaled_ppm ==0 ) +return 0 ;
[Severity: High]
Does an early exit on zero scaled_ppm leave the hardware at its previous rate?
When the ptp daemon attempts to clear adjustments by passing 0, returning early prevents any hardware commands from halting ongoing adjustments. Should this reset the hardware to its nominal frequency before returning?
Quoted 7 lines
drivers/ptp/ptp_qcom_tsc.c new file +7
-0+ +mutex_lock (&tsc->lock); + ret =qcom_tsc_drift_correction (tsc, scaled_ppm); +mutex_unlock (&tsc->lock); + +return ret; +}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
PATCH 4/6 arm64: defconfig: Enable Qualcomm TSC driver
In reply to Imran ShaikEnable PTP_QCOM_TSC as a module to support the Timestamp Counter (TSC) synchronization functionality on Qualcomm Lemans, Monaco and QDU1000 platforms.
--- arch/arm64/configs/defconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm64/configs/defconfig +1 -0
@@ -683,6 +683,7 @@ CONFIG_SPI_SPIDEV=m CONFIG_SPMI=y CONFIG_SPMI_APPLE=m CONFIG_SPMI_MTK_PMIF=m +CONFIG_PTP_QCOM_TSC=m CONFIG_PINCTRL_APPLE_GPIO=m CONFIG_PINCTRL_DA9062=m CONFIG_PINCTRL_MAX77620=y
Signature · 1 line
2.34.1
PATCH 5/6 arm64: dts: qcom: lemans: Add support for TSCSS node
In reply to Imran ShaikAdd Timestamp Counter Subsystem (TSCSS) node support on Qualcomm Lemans SoCs.
--- arch/arm64/boot/dts/qcom/lemans.dtsi | 11 +++++++++++ 1 file changed, 11 insertions(+)
arch/arm64/boot/dts/qcom/lemans.dtsi +11 -0
@@ -3023,6 +3023,17 @@ pcie1_phy: phy@1c14000 { status = "disabled"; }; + tscss@1c80000 { + compatible = "qcom,lemans-tscss"; + reg = <0x0 0x01c80000 0x0 0x2000>; + reg-names = "tsc"; + clocks = <&gcc GCC_TSCSS_AHB_CLK>, + <&gcc GCC_TSCSS_GLOBAL_CNTR_CLK>; + clock-names = "ahb", "cntr"; + assigned-clocks = <&gcc GCC_TSCSS_GLOBAL_CNTR_CLK>; + assigned-clock-rates = <15625000>; + }; + ufs_mem_hc: ufshc@1d84000 { compatible = "qcom,sa8775p-ufshc", "qcom,ufshc", "jedec,ufs-2.0"; reg = <0x0 0x01d84000 0x0 0x3000>;
Signature · 1 line
2.34.1
Re: [PATCH 5/6] arm64: dts: qcom: lemans: Add support for TSCSS node
Quoted 15 lines · Imran Shaik
Add Timestamp Counter Subsystem (TSCSS) node support on Qualcomm Lemans SoCs.
Signed-off-by Imran Shaik <[email protected]>--- arch/arm64/boot/dts/qcom/lemans.dtsi | 11 +++++++++++ 1 file changed, 11 insertions(+)arch/arm64/boot/dts/qcom/lemans.dtsi +0
-0@@ -3023,6 +3023,17 @@ pcie1_phy: phy@1c14000 { status = "disabled"; };
arch/arm64/boot/dts/qcom/lemans.dtsi pcie1_phy: phy@1c14000 { · line 3034
Quoted 10 lines
arch/arm64/boot/dts/qcom/lemans.dtsi +9
-0+ tscss@1c80000 { + compatible = "qcom,lemans-tscss"; + reg = <0x0 0x01c80000 0x0 0x2000>; + reg-names = "tsc"; + clocks = <&gcc GCC_TSCSS_AHB_CLK>, + <&gcc GCC_TSCSS_GLOBAL_CNTR_CLK>; + clock-names = "ahb", "cntr"; + assigned-clocks = <&gcc GCC_TSCSS_GLOBAL_CNTR_CLK>; + assigned-clock-rates = <15625000>;
I'm guessing this will only ever require a single rate - do we need power-domains pointing to one of the RPMHPDs and a required-opps reference to match?
Konrad
Re: [PATCH 5/6] arm64: dts: qcom: lemans: Add support for TSCSS node
Quoted 17 lines · Konrad Dybcio
Quoted 16 lines · Imran Shaik
Add Timestamp Counter Subsystem (TSCSS) node support on Qualcomm Lemans SoCs.
Signed-off-by Imran Shaik <[email protected]>--- arch/arm64/boot/dts/qcom/lemans.dtsi | 11 +++++++++++ 1 file changed, 11 insertions(+)arch/arm64/boot/dts/qcom/lemans.dtsi +0
-0@@ -3023,6 +3023,17 @@ pcie1_phy: phy@1c14000 { status = "disabled"; };
Quoted 14 lines
arch/arm64/boot/dts/qcom/lemans.dtsi pcie1_phy: phy@1c14000 { · line 3034
Quoted 9 lines
arch/arm64/boot/dts/qcom/lemans.dtsi +9
-0+ tscss@1c80000 { + compatible = "qcom,lemans-tscss"; + reg = <0x0 0x01c80000 0x0 0x2000>; + reg-names = "tsc"; + clocks = <&gcc GCC_TSCSS_AHB_CLK>, + <&gcc GCC_TSCSS_GLOBAL_CNTR_CLK>; + clock-names = "ahb", "cntr"; + assigned-clocks = <&gcc GCC_TSCSS_GLOBAL_CNTR_CLK>; + assigned-clock-rates = <15625000>;I'm guessing this will only ever require a single rate - do we need power-domains pointing to one of the RPMHPDs and a required-opps reference to match?
The power-domains/required-opps are not really required here, as this clock's rate is at the lowest corner on the CX rail, which is always kept ON.
Thanks,
Imran
Re: [PATCH 5/6] arm64: dts: qcom: lemans: Add support for TSCSS node
Quoted 34 lines · Imran Shaik
Quoted 21 lines · Konrad Dybcio
Quoted 20 lines · Imran Shaik
Add Timestamp Counter Subsystem (TSCSS) node support on Qualcomm Lemans SoCs.
Signed-off-by Imran Shaik <[email protected]>---
arch/arm64/boot/dts/qcom/lemans.dtsi| 11 +++++++++++1 file changed, 11 insertions(+)arch/arm64/boot/dts/qcom/lemans.dtsi +4
-0@@ -3023,6 +3023,17 @@ pcie1_phy: phy@1c14000 { status = "disabled"; }; + tscss@1c80000 { + compatible = "qcom,lemans-tscss"; + reg = <0x0 0x01c80000 0x0 0x2000>; + reg-names = "tsc"; + clocks = <&gcc GCC_TSCSS_AHB_CLK>,Quoted 9 lines
arch/arm64/boot/dts/qcom/lemans.dtsi pcie1_phy: phy@1c14000 { · line 3034
Quoted 4 lines
arch/arm64/boot/dts/qcom/lemans.dtsi +4
-0+ <&gcc GCC_TSCSS_GLOBAL_CNTR_CLK>; + clock-names = "ahb", "cntr"; + assigned-clocks = <&gcc GCC_TSCSS_GLOBAL_CNTR_CLK>; + assigned-clock-rates = <15625000>;I'm guessing this will only ever require a single rate - do we need power-domains pointing to one of the RPMHPDs and a required-opps reference to match?
Quoted 3 lines
The power-domains/required-opps are not really required here, as this clock's rate is at the lowest corner on the CX rail, which is always kept ON.
The clock plan calls for SVS_L1, the RPMHPD node also defines SVS, LOW_SVS and MIN_SVS below it
Konrad
[email protected]
AI reviewRe: [PATCH 5/6] arm64: dts: qcom: lemans: Add support for TSCSS node
In reply to Imran ShaikThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] The Devicetree compatible string for the TSCSS node uses the internal SoC codename 'lemans' rather…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The Devicetree compatible string for the TSCSS node uses the internal SoC codename 'lemans' rather than the official part number 'sa8775p'. --
--- Patch [5]: [PATCH 5/6] arm64: dts: qcom: lemans: Add support for TSCSS node --- commit 534c460b6703617b947d74b06656ce6dd2f6d6c4
Author: Imran Shaik <[email protected]>
arm64: dts: qcom: lemans: Add support for TSCSS node
This commit adds Timestamp Counter Subsystem (TSCSS) node support on Qualcomm Lemans SoCs.
Quoted 3 lines
arch/arm64/boot/dts/qcom/lemans.dtsi +0
-0
[ ... ]
arch/arm64/boot/dts/qcom/lemans.dtsi pcie1_phy: phy@1c14000 { · line 3027
Quoted 6 lines
arch/arm64/boot/dts/qcom/lemans.dtsi +2
-0@@ -3023,6 +3023,17 @@ pcie1_phy: phy@1c14000 { status = "disabled"; }; + tscss@1c80000 { + compatible = "qcom,lemans-tscss";
[Severity: Low]
This isn't a bug, but would it be better to use the official commercial part number "qcom,sa8775p-tscss" for this compatible string rather than the internal SoC codename "lemans"?
Other IP blocks in this file appear to use the "qcom,sa8775p-*" pattern. For example, the UFS host controller just below this node uses "qcom,sa8775p-ufshc". Staying consistent with the part number helps maintain the Devicetree ABI standards.
Quoted 2 lines
arch/arm64/boot/dts/qcom/lemans.dtsi +2
-0+ reg = <0x0 0x01c80000 0x0 0x2000>; + reg-names = "tsc";
[ ... ]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
PATCH 6/6 arm64: dts: qcom: qdu1000: Add support for TSCSS node
In reply to Imran ShaikAdd Timestamp Counter Subsystem (TSCSS) node support on Qualcomm QDU1000 SoCs.
--- arch/arm64/boot/dts/qcom/qdu1000.dtsi | 11 +++++++++++ 1 file changed, 11 insertions(+)
arch/arm64/boot/dts/qcom/qdu1000.dtsi +11 -0
@@ -876,6 +876,17 @@ system_noc: interconnect@1640000 { #interconnect-cells = <2>; }; + tscss@1da0000 { + compatible = "qcom,qdu1000-tscss"; + reg = <0x0 0x01da0000 0x0 0x2000>; + reg-names = "tsc"; + clocks = <&gcc GCC_TSC_CFG_AHB_CLK>, + <&gcc GCC_TSC_CNTR_CLK>; + clock-names = "ahb", "cntr"; + assigned-clocks = <&gcc GCC_TSC_CNTR_CLK>; + assigned-clock-rates = <500000000>; + }; + tcsr_mutex: hwlock@1f40000 { compatible = "qcom,tcsr-mutex"; reg = <0x0 0x1f40000 0x0 0x20000>;
Signature · 1 line
2.34.1
Re: [PATCH 6/6] arm64: dts: qcom: qdu1000: Add support for TSCSS node
Quoted 13 lines · Imran Shaik
Add Timestamp Counter Subsystem (TSCSS) node support on Qualcomm QDU1000 SoCs.
Signed-off-by Imran Shaik <[email protected]>--- arch/arm64/boot/dts/qcom/qdu1000.dtsi | 11 +++++++++++ 1 file changed, 11 insertions(+)arch/arm64/boot/dts/qcom/qdu1000.dtsi +0
-0
arch/arm64/boot/dts/qcom/qdu1000.dtsi system_noc: interconnect@1640000 { · line 879
Quoted 4 lines
arch/arm64/boot/dts/qcom/qdu1000.dtsi +1
-0@@ -876,6 +876,17 @@ system_noc: interconnect@1640000 { #interconnect-cells = <2>; }; + tscss@1da0000 {
Node names should be generic. See also an explanation and list of examples (not exhaustive) in DT specification:
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendation
If you cannot find a name matching your device, please check in kernel sources for similar cases or you can grow the spec (via pull request to DT spec repo).
Best regards,
Krzysztof