Re: [PATCH 2/2] dt-bindings: timer: imx: gpt: Add pin group bindings for input capture

From: Steve Longerbeam
Date: Mon Oct 28 2019 - 19:59:47 EST

Hi Rob,

Thanks for reviewing.

On 10/27/19 2:21 PM, Rob Herring wrote:
On Tue, Oct 15, 2019 at 06:05:44PM -0700, Steve Longerbeam wrote:
Add pin group bindings to support input capture function of the i.MX

Signed-off-by: Steve Longerbeam <slongerbeam@xxxxxxxxx>
.../devicetree/bindings/timer/fsl,imxgpt.txt | 28 +++++++++++++++++++
1 file changed, 28 insertions(+)

diff --git a/Documentation/devicetree/bindings/timer/fsl,imxgpt.txt b/Documentation/devicetree/bindings/timer/fsl,imxgpt.txt
index 5d8fd5b52598..32797b7b0d02 100644
--- a/Documentation/devicetree/bindings/timer/fsl,imxgpt.txt
+++ b/Documentation/devicetree/bindings/timer/fsl,imxgpt.txt
@@ -33,6 +33,13 @@ Required properties:
an entry for each entry in clock-names.
- clock-names : must include "ipg" entry first, then "per" entry.
+Optional properties:
+- pinctrl-0: For the i.MX GPT to support the Input Capture function,
+ the input capture channel pin groups must be listed here.
+- pinctrl-names: must be "default".
gpt1: timer@10003000 {
@@ -43,3 +50,24 @@ gpt1: timer@10003000 {
<&clks IMX27_CLK_PER1_GATE>;
clock-names = "ipg", "per";
+Example with input capture channel 0 support:
+pinctrl_gpt_input_capture0: gptinputcapture0grp {
+ fsl,pins = <
+ >;
+gpt: gpt@2098000 {


I don't really think this merits another example though.


But for version 2 of this patch-set I'd like to run some ideas by you.

Because in this version I did not make any attempt to create a generic timer capture framework. I just exported a couple imx-specific functions to request and free a timer input capture channel in the imx-gpt driver.

So for version 2 I am thinking about a simple framework that other SoC timers with timer input capture support can make use of.

To begin with I don't see that timer input capture warrants the definition of a new device. At least for imx, timer input capture is just one function of the imx GPT, where the other is Output Compare which is used for the system timer. I think that is likely the case for most all SoC timers, that is, input capture and output compare are tightly interwoven functions of general purpose timers.

So I'm thinking there needs to be an additional #input-capture-cells property that defines how many input capture channels the timer contains, where a channel refers to a single input signal edge that can capture the timer counter. The imx GPT has two input capture channels (2 separate input signals).

For example, on imx:

gpt: timer@2098000 {
compatible = "fsl,imx6q-gpt", "fsl,imx31-gpt";
/* ... */
#input-capture-cells = <1>;
pinctrl-names = "default", "icap1";
pinctrl-0 = <&pinctrl_gpt_input_capture0>;
pinctrl-1 = <&pinctrl_gpt_input_capture1>;

A device that is a listener/consumer of an timer capture event would then refer to a timer capture channel:

some-device {
/* ... */
timer-input-capture = <&gpt 0>;

Is this a sound approach? Let me know what you think.