All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/40] TI AM437X ADC1
@ 2021-08-25 15:24 Miquel Raynal
  2021-08-25 15:24 ` [PATCH 01/40] clk: ti: am43xx: Add clkctrl data for am43xx ADC1 Miquel Raynal
                   ` (39 more replies)
  0 siblings, 40 replies; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:24 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal

Hello,

This is a (fairly big) series bringing support of AM437X ADC1.
On TI AM33XX SoCs family there is an ADC that can also be connected to a
touchscreen. This hardware has been extended and is present on certain
SoCs from the AM437X family. In particular, the touchscreen has been
replaced by a magnetic card reader. In both cases, the representation is
an MFD device with two children:
- on AM33XX: the touchscreen controller and the ADC
- on AM437X: the magnetic card reader and the ADC

This series really targets small and atomic changes so that the overall
review is eased, even though it leads to a lot of rather small patches.
Here are the steps:
* Supporting the missing clock
* Translating a single text file containing the description for the
  MFD, the touchscreen and the ADC into three independent yaml files.
* Cleaning/preparing the MFD driver.
* Supporting ADC1 in the MFD driver.
* Cleaning/preparing of the ADC driver.
* Supporting ADC1 in the ADC driver.
* Updating various device trees.

Here is the full series, I can split it if the various maintainers
prefer. The clk patch can be merged alone, the MFD and the ADC changes
unfortunately are interdependent so, reviewed, the MFD maintainers will
have to create an immutable tag after applying so that ADC maintainers
can merge it. For now, this is open for reviews :) !

Thanks,
Miquèl

Miquel Raynal (40):
  clk: ti: am43xx: Add clkctrl data for am43xx ADC1
  dt-bindings: mfd: ti,am3359-tscadc: Add a yaml description for this
    MFD
  dt-bindings: touchscreen: ti,am3359-tsc: New yaml description
  dt-bindings: iio: adc: ti,am3359-adc: New yaml description
  dt-bindings: touchscreen: ti,am3359-tsc: Remove deprecated text file
  dt-bindings: mfd: ti,am3359-tscadc: Describe am4372 MFD compatible
  dt-bindings: iio: adc: ti,am3359-adc: Describe am4372 ADC compatible
  mfd: ti_am335x_tscadc: Replace license text with SPDX tag
  mfd: ti_am335x_tscadc: Fix style
  mfd: ti_am335x_tscadc: Drop extra spacing when declaring stack
    variables
  mfd: ti_am335x_tscadc: Get rid of useless gotos
  mfd: ti_am335x_tscadc: Move the driver structure allocation earlier
  mfd: ti_am335x_tscadc: Reword the comment explaining the dividers
  mfd: ti_am335x_tscadc: Don't search the tree for our clock
  mfd: ti_am335x_tscadc: Simplify divisor calculation
  mfd: ti_am335x_tscadc: Use driver data
  mfd: ti_am335x_tscadc: Mimic the probe from resume()
  mfd: ti_am335x_tscadc: Drop useless variables from the driver
    structure
  mfd: ti_am335x_tscadc: Always provide an idle configuration
  mfd: ti_am335x_tscadc: Gather the ctrl register logic at one place
  mfd: ti_am335x_tscadc: Rename the subsystem enable macro
  mfd: ti_am335x_tscadc: Add TSC prefix in certain macros
  mfd: ti_am335x_tscadc: Rename a variable
  mfd: ti_am335x_tscadc: Fix an error message
  mfd: ti_am335x_tscadc: Add a boolean to clarify the presence of a
    touchscreen
  mfd: ti_am335x_tscadc: Introduce has_tsc
  mfd: ti_am335x_tscadc: Move control register configuration
  mfd: ti_am335x_tscadc: Add ADC1/magnetic reader support
  mfd: ti_am335x_tscadc: Support the correctly spelled DT property
  iio: adc: ti_am335x_adc: Replace license text with SPDX tag
  iio: adc: ti_am335x_adc: Fix style
  iio: adc: ti_am335x_adc: Get rid of useless gotos
  iio: adc: ti_am335x_adc: Gather the checks on the delays
  iio: adc: ti_am335x_adc: Add a unit to the timeout delay
  iio: adc: ti_am335x_adc: Wait the idle state to avoid stalls
  iio: adc: ti_am335x_adc: Add the scale information
  iio: adc: ti_am335x_adc: Add the am437x compatible
  ARM: dts: am437x-cm-t43: Use a correctly spelled DT property
  ARM: dts: am43xx: Describe the magnetic reader/ADC1 hardware module
  ARM: dts: am437x-gp-evm: enable ADC1

 .../bindings/iio/adc/ti,am3359-adc.yaml       |  83 +++++++
 .../input/touchscreen/ti,am3359-tsc.yaml      |  89 +++++++
 .../bindings/input/touchscreen/ti-tsc-adc.txt |  91 -------
 .../bindings/mfd/ti,am3359-tscadc.yaml        |  80 ++++++
 arch/arm/boot/dts/am437x-cm-t43.dts           |   2 +-
 arch/arm/boot/dts/am437x-gp-evm.dts           |   8 +
 arch/arm/boot/dts/am437x-l4.dtsi              |  31 ++-
 arch/arm/boot/dts/am43xx-clocks.dtsi          |   7 +
 drivers/clk/ti/clk-43xx.c                     |   1 +
 drivers/iio/adc/ti_am335x_adc.c               | 217 +++++++++-------
 drivers/mfd/ti_am335x_tscadc.c                | 232 ++++++++++--------
 include/dt-bindings/clock/am4.h               |   1 +
 include/linux/mfd/ti_am335x_tscadc.h          |  42 ++--
 13 files changed, 582 insertions(+), 302 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/iio/adc/ti,am3359-adc.yaml
 create mode 100644 Documentation/devicetree/bindings/input/touchscreen/ti,am3359-tsc.yaml
 delete mode 100644 Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt
 create mode 100644 Documentation/devicetree/bindings/mfd/ti,am3359-tscadc.yaml

-- 
2.27.0


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

* [PATCH 01/40] clk: ti: am43xx: Add clkctrl data for am43xx ADC1
  2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
@ 2021-08-25 15:24 ` Miquel Raynal
  2021-08-25 15:24 ` [PATCH 02/40] dt-bindings: mfd: ti,am3359-tscadc: Add a yaml description for this MFD Miquel Raynal
                   ` (38 subsequent siblings)
  39 siblings, 0 replies; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:24 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal, Jason Reeder

Declare ADC1 clkctrl which feeds the magnetic-reader/ADC1 hardware
module.

Co-developed-by: Jason Reeder <jreeder@ti.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Jason Reeder <jreeder@ti.com>
---
 drivers/clk/ti/clk-43xx.c       | 1 +
 include/dt-bindings/clock/am4.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/clk/ti/clk-43xx.c b/drivers/clk/ti/clk-43xx.c
index 46c0add99570..6e97a541cfd3 100644
--- a/drivers/clk/ti/clk-43xx.c
+++ b/drivers/clk/ti/clk-43xx.c
@@ -116,6 +116,7 @@ static const struct omap_clkctrl_reg_data am4_l3s_clkctrl_regs[] __initconst = {
 	{ AM4_L3S_VPFE0_CLKCTRL, NULL, CLKF_SW_SUP, "l3_gclk" },
 	{ AM4_L3S_VPFE1_CLKCTRL, NULL, CLKF_SW_SUP, "l3_gclk" },
 	{ AM4_L3S_GPMC_CLKCTRL, NULL, CLKF_SW_SUP, "l3s_gclk" },
+	{ AM4_L3S_ADC1_CLKCTRL, NULL, CLKF_SW_SUP, "l3s_gclk" },
 	{ AM4_L3S_MCASP0_CLKCTRL, NULL, CLKF_SW_SUP, "mcasp0_fck" },
 	{ AM4_L3S_MCASP1_CLKCTRL, NULL, CLKF_SW_SUP, "mcasp1_fck" },
 	{ AM4_L3S_MMC3_CLKCTRL, NULL, CLKF_SW_SUP, "mmc_clk" },
diff --git a/include/dt-bindings/clock/am4.h b/include/dt-bindings/clock/am4.h
index d961e7cb3682..4be6c5961f34 100644
--- a/include/dt-bindings/clock/am4.h
+++ b/include/dt-bindings/clock/am4.h
@@ -158,6 +158,7 @@
 #define AM4_L3S_VPFE0_CLKCTRL	AM4_L3S_CLKCTRL_INDEX(0x68)
 #define AM4_L3S_VPFE1_CLKCTRL	AM4_L3S_CLKCTRL_INDEX(0x70)
 #define AM4_L3S_GPMC_CLKCTRL	AM4_L3S_CLKCTRL_INDEX(0x220)
+#define AM4_L3S_ADC1_CLKCTRL	AM4_L3S_CLKCTRL_INDEX(0x230)
 #define AM4_L3S_MCASP0_CLKCTRL	AM4_L3S_CLKCTRL_INDEX(0x238)
 #define AM4_L3S_MCASP1_CLKCTRL	AM4_L3S_CLKCTRL_INDEX(0x240)
 #define AM4_L3S_MMC3_CLKCTRL	AM4_L3S_CLKCTRL_INDEX(0x248)
-- 
2.27.0


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

* [PATCH 02/40] dt-bindings: mfd: ti,am3359-tscadc: Add a yaml description for this MFD
  2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
  2021-08-25 15:24 ` [PATCH 01/40] clk: ti: am43xx: Add clkctrl data for am43xx ADC1 Miquel Raynal
@ 2021-08-25 15:24 ` Miquel Raynal
  2021-08-30 12:47   ` Jonathan Cameron
  2021-08-31 19:33   ` Rob Herring
  2021-08-25 15:24 ` [PATCH 03/40] dt-bindings: touchscreen: ti,am3359-tsc: New yaml description Miquel Raynal
                   ` (37 subsequent siblings)
  39 siblings, 2 replies; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:24 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal

There is a very light description of this MFD in a text file dedicated
to a touchscreen controller (which is one of the two children of the
MFD). Here is now a complete yaml description.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 .../bindings/mfd/ti,am3359-tscadc.yaml        | 75 +++++++++++++++++++
 1 file changed, 75 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/ti,am3359-tscadc.yaml

diff --git a/Documentation/devicetree/bindings/mfd/ti,am3359-tscadc.yaml b/Documentation/devicetree/bindings/mfd/ti,am3359-tscadc.yaml
new file mode 100644
index 000000000000..96b329508d8a
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/ti,am3359-tscadc.yaml
@@ -0,0 +1,75 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/ti,am3359-tscadc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: TI AM3359 Touchscreen controller/ADC
+
+maintainers:
+  - Miquel Raynal <miquel.raynal@bootlin.com>
+
+properties:
+  compatible:
+    const: ti,am3359-tscadc
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+  clock-names:
+    const: fck
+
+  dmas:
+    items:
+      - description: DMA controller phandle and request line for FIFO0
+      - description: DMA controller phandle and request line for FIFO1
+
+  dma-names:
+    items:
+      - const: fifo0
+      - const: fifo1
+
+patternProperties:
+  "^adc$":
+    description: ADC
+
+  "^tsc$":
+    description: Touchscreen controller
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+  - dmas
+  - dma-names
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+
+    tscadc: tscadc@0 {
+        compatible = "ti,am3359-tscadc";
+        reg = <0x0 0x1000>;
+        interrupts = <GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>;
+        clocks = <&adc_tsc_fck>;
+        clock-names = "fck";
+        dmas = <&edma 53 0>, <&edma 57 0>;
+        dma-names = "fifo0", "fifo1";
+        status = "disabled";
+
+        tsc {
+        };
+
+        adc {
+        };
+    };
-- 
2.27.0


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

* [PATCH 03/40] dt-bindings: touchscreen: ti,am3359-tsc: New yaml description
  2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
  2021-08-25 15:24 ` [PATCH 01/40] clk: ti: am43xx: Add clkctrl data for am43xx ADC1 Miquel Raynal
  2021-08-25 15:24 ` [PATCH 02/40] dt-bindings: mfd: ti,am3359-tscadc: Add a yaml description for this MFD Miquel Raynal
@ 2021-08-25 15:24 ` Miquel Raynal
  2021-08-30 13:36   ` Jonathan Cameron
  2021-08-31 19:37   ` Rob Herring
  2021-08-25 15:24 ` [PATCH 04/40] dt-bindings: iio: adc: ti,am3359-adc: " Miquel Raynal
                   ` (36 subsequent siblings)
  39 siblings, 2 replies; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:24 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal

This touchscreen controller is already described in a text file:
Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt

After introducing a proper description of the MFD, this is the second
step. The file cannot be removed yet as it also contains an ADC
description.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 .../input/touchscreen/ti,am3359-tsc.yaml      | 89 +++++++++++++++++++
 1 file changed, 89 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/touchscreen/ti,am3359-tsc.yaml

diff --git a/Documentation/devicetree/bindings/input/touchscreen/ti,am3359-tsc.yaml b/Documentation/devicetree/bindings/input/touchscreen/ti,am3359-tsc.yaml
new file mode 100644
index 000000000000..2d4ce6d04f53
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/touchscreen/ti,am3359-tsc.yaml
@@ -0,0 +1,89 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/input/touchscreen/ti,am3359-tsc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: TI AM3359 Touchscreen controller
+
+maintainers:
+  - Miquel Raynal <miquel.raynal@bootlin.com>
+
+properties:
+  compatible:
+    const: ti,am3359-tsc
+
+  ti,wires:
+    description: Wires refer to application modes i.e. 4/5/8 wire touchscreen
+      support on the platform.
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [4, 5, 8]
+
+  ti,x-plate-resistance:
+    description: X plate resistance
+    $ref: /schemas/types.yaml#/definitions/uint32
+
+  ti,coordinate-readouts:
+    description: The sequencer supports a total of 16 programmable steps. Each
+      step is used to read a single coordinate. A single readout is enough but
+      multiple reads can increase the quality. A value of 5 means, 5 reads for
+      X, 5 for Y and 2 for Z (always). This utilises 12 of the 16 software steps
+      available. The remaining 4 can be used by the ADC.
+    $ref: /schemas/types.yaml#/definitions/uint32
+    minimum: 1
+    maximum: 6
+
+  ti,wire-config:
+    description: Different boards could have a different order for connecting
+      wires on touchscreen. We need to provide an 8-bit number where the
+      first four bits represent the analog lines and the next 4 bits represent
+      positive/negative terminal on that input line. Notations to represent the
+      input lines and terminals respectively are as follows, AIN0 = 0, AIN1 = 1
+      and so on untill AIN7 = 7. XP = 0, XN = 1, YP = 2, YN = 3.
+    $ref: /schemas/types.yaml#/definitions/uint32-array
+    minItems: 4
+    maxItems: 8
+
+  ti,charge-delay:
+    description: Length of touch screen charge delay step in terms of ADC clock
+      cycles. Charge delay value should be large in order to avoid false pen-up
+      events. This value effects the overall sampling speed, hence need to be
+      kept as low as possible, while avoiding false pen-up event. Start from a
+      lower value, say 0x400, and increase value until false pen-up events are
+      avoided. The pen-up detection happens immediately after the charge step,
+      so this does in fact function as a hardware knob for adjusting the amount
+      of "settling time".
+    $ref: /schemas/types.yaml#/definitions/uint32
+
+required:
+  - compatible
+  - ti,wires
+  - ti,x-plate-resistance
+  - ti,coordinate-readouts
+  - ti,wire-config
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+
+    tscadc: tscadc@0 {
+        compatible = "ti,am3359-tscadc";
+        reg = <0x0 0x1000>;
+        interrupts = <GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>;
+        clocks = <&adc_tsc_fck>;
+        clock-names = "fck";
+        status = "disabled";
+        dmas = <&edma 53 0>, <&edma 57 0>;
+        dma-names = "fifo0", "fifo1";
+
+        tsc {
+            compatible = "ti,am3359-tsc";
+            ti,wires = <4>;
+            ti,x-plate-resistance = <200>;
+            ti,coordinate-readouts = <5>;
+            ti,wire-config = <0x00 0x11 0x22 0x33>;
+            ti,charge-delay = <0x400>;
+        };
+    };
-- 
2.27.0


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

* [PATCH 04/40] dt-bindings: iio: adc: ti,am3359-adc: New yaml description
  2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
                   ` (2 preceding siblings ...)
  2021-08-25 15:24 ` [PATCH 03/40] dt-bindings: touchscreen: ti,am3359-tsc: New yaml description Miquel Raynal
@ 2021-08-25 15:24 ` Miquel Raynal
  2021-08-30 12:31   ` Jonathan Cameron
  2021-08-25 15:24 ` [PATCH 05/40] dt-bindings: touchscreen: ti,am3359-tsc: Remove deprecated text file Miquel Raynal
                   ` (35 subsequent siblings)
  39 siblings, 1 reply; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:24 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal

This ADC was already described in a text file also containing an MFD
description an a touchscreen description:
Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt
Let's add a proper description for this hardware.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 .../bindings/iio/adc/ti,am3359-adc.yaml       | 81 +++++++++++++++++++
 1 file changed, 81 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/adc/ti,am3359-adc.yaml

diff --git a/Documentation/devicetree/bindings/iio/adc/ti,am3359-adc.yaml b/Documentation/devicetree/bindings/iio/adc/ti,am3359-adc.yaml
new file mode 100644
index 000000000000..85d9d642dc67
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/adc/ti,am3359-adc.yaml
@@ -0,0 +1,81 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/adc/ti,am3359-adc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: TI AM3359 ADC
+
+maintainers:
+  - Miquel Raynal <miquel.raynal@bootlin.com>
+
+properties:
+  compatible:
+    const: ti,am3359-adc
+
+  '#io-channel-cells':
+    const: 1
+
+  ti,adc-channels:
+    description: List of analog inputs available for ADC. AIN0 = 0, AIN1 = 1 and
+      so on untill AIN7 = 7.
+    $ref: /schemas/types.yaml#/definitions/uint32-array
+    minItems: 1
+    maxItems: 8
+
+  ti,chan-step-opendelay:
+    description: List of open delays for each channel of ADC in the order of
+      ti,adc-channels. The value corresponds to the number of ADC clock cycles
+      to wait after applying the step configuration registers and before sending
+      the start of ADC conversion. Maximum value is 0x3FFFF.
+    $ref: /schemas/types.yaml#/definitions/uint32-array
+    minItems: 1
+    maxItems: 8
+
+  ti,chan-step-sampledelay:
+    description: List of sample delays for each channel of ADC in the order of
+      ti,adc-channels. The value corresponds to the number of ADC clock cycles
+      to sample (to hold start of conversion high). Maximum value is 0xFF.
+    $ref: /schemas/types.yaml#/definitions/uint32-array
+    minItems: 1
+    maxItems: 8
+
+  ti,chan-step-avg:
+    description: Number of averages to be performed for each channel of ADC. If
+      average is 16 (this is also the maximum) then input is sampled 16 times
+      and averaged to get more accurate value. This increases the time taken by
+      ADC to generate a sample. Maximum value is 16.
+    $ref: /schemas/types.yaml#/definitions/uint32-array
+    minItems: 1
+    maxItems: 8
+
+required:
+  - compatible
+  - '#io-channel-cells'
+  - ti,adc-channels
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+
+    tscadc: tscadc@0 {
+        compatible = "ti,am3359-tscadc";
+        reg = <0x0 0x1000>;
+        interrupts = <GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>;
+        clocks = <&adc_tsc_fck>;
+        clock-names = "fck";
+        status = "disabled";
+        dmas = <&edma 53 0>, <&edma 57 0>;
+        dma-names = "fifo0", "fifo1";
+
+        adc {
+            compatible = "ti,am3359-adc";
+            #io-channel-cells = <1>;
+            ti,adc-channels = <4 5 6 7>;
+            ti,chan-step-opendelay = <0x098 0x3ffff 0x098 0x0>;
+            ti,chan-step-sampledelay = <0xff 0x0 0xf 0x0>;
+            ti,chan-step-avg = <16 2 4 8>;
+        };
+    };
-- 
2.27.0


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

* [PATCH 05/40] dt-bindings: touchscreen: ti,am3359-tsc: Remove deprecated text file
  2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
                   ` (3 preceding siblings ...)
  2021-08-25 15:24 ` [PATCH 04/40] dt-bindings: iio: adc: ti,am3359-adc: " Miquel Raynal
@ 2021-08-25 15:24 ` Miquel Raynal
  2021-08-30 12:39   ` Jonathan Cameron
  2021-08-31 19:38   ` Rob Herring
  2021-08-25 15:24 ` [PATCH 06/40] dt-bindings: mfd: ti,am3359-tscadc: Describe am4372 MFD compatible Miquel Raynal
                   ` (34 subsequent siblings)
  39 siblings, 2 replies; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:24 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal

Now that the three hardware peaces described in this file have been
translated in yaml in 3 dedicated files (MFD, touchscreen controller and
ADC) it is time to remove this text file.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 .../bindings/input/touchscreen/ti-tsc-adc.txt | 91 -------------------
 1 file changed, 91 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt

diff --git a/Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt b/Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt
deleted file mode 100644
index aad5e34965eb..000000000000
--- a/Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt
+++ /dev/null
@@ -1,91 +0,0 @@
-* TI - TSC ADC (Touschscreen and analog digital converter)
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-Required properties:
-- mfd
-	compatible: Should be
-		"ti,am3359-tscadc" for AM335x/AM437x SoCs
-		"ti,am654-tscadc", "ti,am3359-tscadc" for AM654 SoCs
-- child "tsc"
-	compatible: Should be "ti,am3359-tsc".
-	ti,wires: Wires refer to application modes i.e. 4/5/8 wire touchscreen
-		  support on the platform.
-	ti,x-plate-resistance: X plate resistance
-	ti,coordinate-readouts: The sequencer supports a total of 16
-				programmable steps each step is used to
-				read a single coordinate. A single
-                                readout is enough but multiple reads can
-				increase the quality.
-				A value of 5 means, 5 reads for X, 5 for
-				Y and 2 for Z (always). This utilises 12
-				of the 16 software steps available. The
-				remaining 4 can be used by the ADC.
-	ti,wire-config: Different boards could have a different order for
-			connecting wires on touchscreen. We need to provide an
-			8 bit number where in the 1st four bits represent the
-			analog lines and the next 4 bits represent positive/
-			negative terminal on that input line. Notations to
-			represent the input lines and terminals resoectively
-			is as follows:
-			AIN0 = 0, AIN1 = 1 and so on till AIN7 = 7.
-			XP  = 0, XN = 1, YP = 2, YN = 3.
-- child "adc"
-	compatible: Should be
-		    "ti,am3359-adc" for AM335x/AM437x SoCs
-		    "ti,am654-adc", "ti,am3359-adc" for AM654 SoCs
-	ti,adc-channels: List of analog inputs available for ADC.
-			 AIN0 = 0, AIN1 = 1 and so on till AIN7 = 7.
-
-Optional properties:
-- child "tsc"
-	ti,charge-delay: Length of touch screen charge delay step in terms of
-			 ADC clock cycles. Charge delay value should be large
-			 in order to avoid false pen-up events. This value
-			 effects the overall sampling speed, hence need to be
-			 kept as low as possible, while avoiding false pen-up
-			 event. Start from a lower value, say 0x400, and
-			 increase value until false pen-up events are avoided.
-			 The pen-up detection happens immediately after the
-			 charge step, so this does in fact function as a
-			 hardware knob for adjusting the amount of "settling
-			 time".
-
-- child "adc"
-	ti,chan-step-opendelay: List of open delays for each channel of
-				ADC in the order of ti,adc-channels. The
-				value corresponds to the number of ADC
-				clock cycles to wait after applying the
-				step configuration registers and before
-				sending the start of ADC conversion.
-				Maximum value is 0x3FFFF.
-       ti,chan-step-sampledelay: List of sample delays for each channel
-				  of ADC in the order of ti,adc-channels.
-				  The value corresponds to the number of
-				  ADC clock cycles to sample (to hold
-				  start of conversion high).
-				  Maximum value is 0xFF.
-       ti,chan-step-avg: Number of averages to be performed for each
-			  channel of ADC. If average is 16 then input
-			  is sampled 16 times and averaged to get more
-			  accurate value. This increases the time taken
-			  by ADC to generate a sample. Valid range is 0
-			  average to 16 averages. Maximum value is 16.
-
-Example:
-	tscadc: tscadc@44e0d000 {
-		compatible = "ti,am3359-tscadc";
-		tsc {
-			ti,wires = <4>;
-			ti,x-plate-resistance = <200>;
-			ti,coordiante-readouts = <5>;
-			ti,wire-config = <0x00 0x11 0x22 0x33>;
-			ti,charge-delay = <0x400>;
-		};
-
-		adc {
-			ti,adc-channels = <4 5 6 7>;
-			ti,chan-step-opendelay = <0x098 0x3ffff 0x098 0x0>;
-			ti,chan-step-sampledelay = <0xff 0x0 0xf 0x0>;
-			ti,chan-step-avg = <16 2 4 8>;
-		};
-	}
-- 
2.27.0


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

* [PATCH 06/40] dt-bindings: mfd: ti,am3359-tscadc: Describe am4372 MFD compatible
  2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
                   ` (4 preceding siblings ...)
  2021-08-25 15:24 ` [PATCH 05/40] dt-bindings: touchscreen: ti,am3359-tsc: Remove deprecated text file Miquel Raynal
@ 2021-08-25 15:24 ` Miquel Raynal
  2021-08-30 12:34   ` Jonathan Cameron
  2021-08-25 15:24 ` [PATCH 07/40] dt-bindings: iio: adc: ti,am3359-adc: Describe am4372 ADC compatible Miquel Raynal
                   ` (33 subsequent siblings)
  39 siblings, 1 reply; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:24 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal

A more recent version of the am3359 ADC/Touchscreen controller is
available on certain SoCs of the am437x family. This IP has evolved a
little bit and deserves its own compatible.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 .../devicetree/bindings/mfd/ti,am3359-tscadc.yaml          | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/mfd/ti,am3359-tscadc.yaml b/Documentation/devicetree/bindings/mfd/ti,am3359-tscadc.yaml
index 96b329508d8a..2240299dcf2f 100644
--- a/Documentation/devicetree/bindings/mfd/ti,am3359-tscadc.yaml
+++ b/Documentation/devicetree/bindings/mfd/ti,am3359-tscadc.yaml
@@ -11,7 +11,9 @@ maintainers:
 
 properties:
   compatible:
-    const: ti,am3359-tscadc
+    oneOf:
+      - const: ti,am3359-tscadc
+      - const: ti,am4372-magadc
 
   reg:
     maxItems: 1
@@ -42,6 +44,9 @@ patternProperties:
   "^tsc$":
     description: Touchscreen controller
 
+  "^mag$":
+    description: Magnetic reader
+
 required:
   - compatible
   - reg
-- 
2.27.0


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

* [PATCH 07/40] dt-bindings: iio: adc: ti,am3359-adc: Describe am4372 ADC compatible
  2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
                   ` (5 preceding siblings ...)
  2021-08-25 15:24 ` [PATCH 06/40] dt-bindings: mfd: ti,am3359-tscadc: Describe am4372 MFD compatible Miquel Raynal
@ 2021-08-25 15:24 ` Miquel Raynal
  2021-08-30 12:35   ` Jonathan Cameron
  2021-08-25 15:24 ` [PATCH 08/40] mfd: ti_am335x_tscadc: Replace license text with SPDX tag Miquel Raynal
                   ` (32 subsequent siblings)
  39 siblings, 1 reply; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:24 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal

A more recent version of the am3359 ADC is available on certain SoCs of
the am437x family. This IP has evolved a little bit and deserves its own
compatible.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 Documentation/devicetree/bindings/iio/adc/ti,am3359-adc.yaml | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/iio/adc/ti,am3359-adc.yaml b/Documentation/devicetree/bindings/iio/adc/ti,am3359-adc.yaml
index 85d9d642dc67..34743371ee18 100644
--- a/Documentation/devicetree/bindings/iio/adc/ti,am3359-adc.yaml
+++ b/Documentation/devicetree/bindings/iio/adc/ti,am3359-adc.yaml
@@ -11,7 +11,9 @@ maintainers:
 
 properties:
   compatible:
-    const: ti,am3359-adc
+    oneOf:
+      - const: ti,am3359-adc
+      - const: ti,am4372-adc
 
   '#io-channel-cells':
     const: 1
-- 
2.27.0


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

* [PATCH 08/40] mfd: ti_am335x_tscadc: Replace license text with SPDX tag
  2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
                   ` (6 preceding siblings ...)
  2021-08-25 15:24 ` [PATCH 07/40] dt-bindings: iio: adc: ti,am3359-adc: Describe am4372 ADC compatible Miquel Raynal
@ 2021-08-25 15:24 ` Miquel Raynal
  2021-08-30 12:38   ` Jonathan Cameron
  2021-08-25 15:24 ` [PATCH 09/40] mfd: ti_am335x_tscadc: Fix style Miquel Raynal
                   ` (31 subsequent siblings)
  39 siblings, 1 reply; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:24 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal

Drop the text license and replace it with an equivalent SPDX license tag
identifier.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mfd/ti_am335x_tscadc.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
index 0e6e25308190..45262ca7734a 100644
--- a/drivers/mfd/ti_am335x_tscadc.c
+++ b/drivers/mfd/ti_am335x_tscadc.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-only
 /*
  * TI Touch Screen / ADC MFD driver
  *
  * Copyright (C) 2012 Texas Instruments Incorporated - https://www.ti.com/
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation version 2.
- *
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
- * kind, whether express or implied; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
  */
 
 #include <linux/module.h>
-- 
2.27.0


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

* [PATCH 09/40] mfd: ti_am335x_tscadc: Fix style
  2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
                   ` (7 preceding siblings ...)
  2021-08-25 15:24 ` [PATCH 08/40] mfd: ti_am335x_tscadc: Replace license text with SPDX tag Miquel Raynal
@ 2021-08-25 15:24 ` Miquel Raynal
  2021-08-30 12:49   ` Jonathan Cameron
  2021-08-25 15:24 ` [PATCH 10/40] mfd: ti_am335x_tscadc: Drop extra spacing when declaring stack variables Miquel Raynal
                   ` (30 subsequent siblings)
  39 siblings, 1 reply; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:24 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal

These are mostly deffects reported by checkpatch.pl.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mfd/ti_am335x_tscadc.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
index 45262ca7734a..540c6dcef541 100644
--- a/drivers/mfd/ti_am335x_tscadc.c
+++ b/drivers/mfd/ti_am335x_tscadc.c
@@ -140,15 +140,17 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 		adc_channels++;
 		if (val > 7) {
 			dev_err(&pdev->dev, " PIN numbers are 0..7 (not %d)\n",
-					val);
+				val);
 			return -EINVAL;
 		}
 	}
+
 	total_channels = tsc_wires + adc_channels;
 	if (total_channels > 8) {
 		dev_err(&pdev->dev, "Number of i/p channels more than 8\n");
 		return -EINVAL;
 	}
+
 	if (total_channels == 0) {
 		dev_err(&pdev->dev, "Need atleast one channel.\n");
 		return -EINVAL;
@@ -170,8 +172,9 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 	if (err < 0) {
 		dev_err(&pdev->dev, "no irq ID is specified.\n");
 		goto ret;
-	} else
+	} else {
 		tscadc->irq = err;
+	}
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	tscadc->tscadc_base = devm_ioremap_resource(&pdev->dev, res);
@@ -180,7 +183,8 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 
 	tscadc->tscadc_phys_base = res->start;
 	tscadc->regmap = devm_regmap_init_mmio(&pdev->dev,
-			tscadc->tscadc_base, &tscadc_regmap_config);
+					       tscadc->tscadc_base,
+					       &tscadc_regmap_config);
 	if (IS_ERR(tscadc->regmap)) {
 		dev_err(&pdev->dev, "regmap init failed\n");
 		err = PTR_ERR(tscadc->regmap);
-- 
2.27.0


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

* [PATCH 10/40] mfd: ti_am335x_tscadc: Drop extra spacing when declaring stack variables
  2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
                   ` (8 preceding siblings ...)
  2021-08-25 15:24 ` [PATCH 09/40] mfd: ti_am335x_tscadc: Fix style Miquel Raynal
@ 2021-08-25 15:24 ` Miquel Raynal
  2021-08-30 12:52   ` Jonathan Cameron
  2021-08-25 15:24 ` [PATCH 11/40] mfd: ti_am335x_tscadc: Get rid of useless gotos Miquel Raynal
                   ` (29 subsequent siblings)
  39 siblings, 1 reply; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:24 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal

Many variables will be updated (renamed, dropped, added) in the upcoming
changes, so let's simplify the style to avoid messing with spaces over
and over again.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mfd/ti_am335x_tscadc.c | 28 +++++++++++++---------------
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
index 540c6dcef541..f0824732badf 100644
--- a/drivers/mfd/ti_am335x_tscadc.c
+++ b/drivers/mfd/ti_am335x_tscadc.c
@@ -113,18 +113,16 @@ static void tscadc_idle_config(struct ti_tscadc_dev *tscadc)
 
 static	int ti_tscadc_probe(struct platform_device *pdev)
 {
-	struct ti_tscadc_dev	*tscadc;
-	struct resource		*res;
-	struct clk		*clk;
-	struct device_node	*node;
-	struct mfd_cell		*cell;
-	struct property         *prop;
-	const __be32            *cur;
-	u32			val;
-	int			err, ctrl;
-	int			clock_rate;
-	int			tsc_wires = 0, adc_channels = 0, total_channels;
-	int			readouts = 0;
+	struct ti_tscadc_dev *tscadc;
+	struct device_node *node;
+	struct property *prop;
+	struct mfd_cell *cell;
+	struct resource *res;
+	const __be32 *cur;
+	struct clk *clk;
+	u32 val;
+	int tsc_wires = 0, adc_channels = 0, readouts = 0;
+	int total_channels, clock_rate, ctrl, err;
 
 	if (!pdev->dev.of_node) {
 		dev_err(&pdev->dev, "Could not find valid DT data.\n");
@@ -278,7 +276,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 
 static int ti_tscadc_remove(struct platform_device *pdev)
 {
-	struct ti_tscadc_dev	*tscadc = platform_get_drvdata(pdev);
+	struct ti_tscadc_dev *tscadc = platform_get_drvdata(pdev);
 
 	regmap_write(tscadc->regmap, REG_SE, 0x00);
 
@@ -297,7 +295,7 @@ static int __maybe_unused ti_tscadc_can_wakeup(struct device *dev, void *data)
 
 static int __maybe_unused tscadc_suspend(struct device *dev)
 {
-	struct ti_tscadc_dev	*tscadc = dev_get_drvdata(dev);
+	struct ti_tscadc_dev *tscadc = dev_get_drvdata(dev);
 
 	regmap_write(tscadc->regmap, REG_SE, 0x00);
 	if (device_for_each_child(dev, NULL, ti_tscadc_can_wakeup)) {
@@ -315,7 +313,7 @@ static int __maybe_unused tscadc_suspend(struct device *dev)
 
 static int __maybe_unused tscadc_resume(struct device *dev)
 {
-	struct ti_tscadc_dev	*tscadc = dev_get_drvdata(dev);
+	struct ti_tscadc_dev *tscadc = dev_get_drvdata(dev);
 	u32 ctrl;
 
 	pm_runtime_get_sync(dev);
-- 
2.27.0


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

* [PATCH 11/40] mfd: ti_am335x_tscadc: Get rid of useless gotos
  2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
                   ` (9 preceding siblings ...)
  2021-08-25 15:24 ` [PATCH 10/40] mfd: ti_am335x_tscadc: Drop extra spacing when declaring stack variables Miquel Raynal
@ 2021-08-25 15:24 ` Miquel Raynal
  2021-08-30 13:39   ` Jonathan Cameron
  2021-08-25 15:24 ` [PATCH 12/40] mfd: ti_am335x_tscadc: Move the driver structure allocation earlier Miquel Raynal
                   ` (28 subsequent siblings)
  39 siblings, 1 reply; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:24 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal

Gotos jumping to a return statement are not really useful, drop them.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mfd/ti_am335x_tscadc.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
index f0824732badf..8e86b766b619 100644
--- a/drivers/mfd/ti_am335x_tscadc.c
+++ b/drivers/mfd/ti_am335x_tscadc.c
@@ -169,7 +169,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 	err = platform_get_irq(pdev, 0);
 	if (err < 0) {
 		dev_err(&pdev->dev, "no irq ID is specified.\n");
-		goto ret;
+		return err;
 	} else {
 		tscadc->irq = err;
 	}
@@ -185,8 +185,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 					       &tscadc_regmap_config);
 	if (IS_ERR(tscadc->regmap)) {
 		dev_err(&pdev->dev, "regmap init failed\n");
-		err = PTR_ERR(tscadc->regmap);
-		goto ret;
+		return PTR_ERR(tscadc->regmap);
 	}
 
 	spin_lock_init(&tscadc->reg_lock);
@@ -270,7 +269,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 err_disable_clk:
 	pm_runtime_put_sync(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
-ret:
+
 	return err;
 }
 
-- 
2.27.0


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

* [PATCH 12/40] mfd: ti_am335x_tscadc: Move the driver structure allocation earlier
  2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
                   ` (10 preceding siblings ...)
  2021-08-25 15:24 ` [PATCH 11/40] mfd: ti_am335x_tscadc: Get rid of useless gotos Miquel Raynal
@ 2021-08-25 15:24 ` Miquel Raynal
  2021-08-30 14:25   ` Jonathan Cameron
  2021-08-25 15:24 ` [PATCH 13/40] mfd: ti_am335x_tscadc: Reword the comment explaining the dividers Miquel Raynal
                   ` (27 subsequent siblings)
  39 siblings, 1 reply; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:24 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal

Allocating the driver structure should be done earlier in the probe so
that we can used its members from the beginning.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mfd/ti_am335x_tscadc.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
index 8e86b766b619..0fef35e1e64b 100644
--- a/drivers/mfd/ti_am335x_tscadc.c
+++ b/drivers/mfd/ti_am335x_tscadc.c
@@ -124,6 +124,13 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 	int tsc_wires = 0, adc_channels = 0, readouts = 0;
 	int total_channels, clock_rate, ctrl, err;
 
+	/* Allocate memory for device */
+	tscadc = devm_kzalloc(&pdev->dev, sizeof(*tscadc), GFP_KERNEL);
+	if (!tscadc)
+		return -ENOMEM;
+
+	tscadc->dev = &pdev->dev;
+
 	if (!pdev->dev.of_node) {
 		dev_err(&pdev->dev, "Could not find valid DT data.\n");
 		return -EINVAL;
@@ -159,13 +166,6 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	/* Allocate memory for device */
-	tscadc = devm_kzalloc(&pdev->dev, sizeof(*tscadc), GFP_KERNEL);
-	if (!tscadc)
-		return -ENOMEM;
-
-	tscadc->dev = &pdev->dev;
-
 	err = platform_get_irq(pdev, 0);
 	if (err < 0) {
 		dev_err(&pdev->dev, "no irq ID is specified.\n");
-- 
2.27.0


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

* [PATCH 13/40] mfd: ti_am335x_tscadc: Reword the comment explaining the dividers
  2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
                   ` (11 preceding siblings ...)
  2021-08-25 15:24 ` [PATCH 12/40] mfd: ti_am335x_tscadc: Move the driver structure allocation earlier Miquel Raynal
@ 2021-08-25 15:24 ` Miquel Raynal
  2021-08-30 13:43   ` Jonathan Cameron
  2021-08-25 15:24 ` [PATCH 14/40] mfd: ti_am335x_tscadc: Don't search the tree for our clock Miquel Raynal
                   ` (26 subsequent siblings)
  39 siblings, 1 reply; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:24 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal

The comment misses the main information which is that we assume that a
sample takes 15 ADC clock cycles to be generated. Let's take the
occasion to rework a little bit this comment.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mfd/ti_am335x_tscadc.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
index 0fef35e1e64b..3afe22680973 100644
--- a/drivers/mfd/ti_am335x_tscadc.c
+++ b/drivers/mfd/ti_am335x_tscadc.c
@@ -195,12 +195,12 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 	pm_runtime_get_sync(&pdev->dev);
 
 	/*
-	 * The TSC_ADC_Subsystem has 2 clock domains
-	 * OCP_CLK and ADC_CLK.
-	 * The ADC clock is expected to run at target of 3MHz,
-	 * and expected to capture 12-bit data at a rate of 200 KSPS.
-	 * The TSC_ADC_SS controller design assumes the OCP clock is
-	 * at least 6x faster than the ADC clock.
+	 * The TSC_ADC_Subsystem has 2 clock domains: OCP_CLK and ADC_CLK.
+	 * ADCs produce a 12-bit sample every 15 ADC_CLK cycles.
+	 * am33xx ADCs expect to capture 200ksps.
+	 * We need the ADC clocks to run at 3MHz.
+	 * This frequency is valid since TSC_ADC_SS controller design
+	 * assumes the OCP clock is at least 6x faster than the ADC clock.
 	 */
 	clk = devm_clk_get(&pdev->dev, "adc_tsc_fck");
 	if (IS_ERR(clk)) {
-- 
2.27.0


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

* [PATCH 14/40] mfd: ti_am335x_tscadc: Don't search the tree for our clock
  2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
                   ` (12 preceding siblings ...)
  2021-08-25 15:24 ` [PATCH 13/40] mfd: ti_am335x_tscadc: Reword the comment explaining the dividers Miquel Raynal
@ 2021-08-25 15:24 ` Miquel Raynal
  2021-08-25 15:24 ` [PATCH 15/40] mfd: ti_am335x_tscadc: Simplify divisor calculation Miquel Raynal
                   ` (25 subsequent siblings)
  39 siblings, 0 replies; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:24 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal

There is a single clock available in our node, which is named
"fck". The clock handler then points to adc_tsc_fck but no need to point
directly to it and do a full tree search.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mfd/ti_am335x_tscadc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
index 3afe22680973..d27f8917272d 100644
--- a/drivers/mfd/ti_am335x_tscadc.c
+++ b/drivers/mfd/ti_am335x_tscadc.c
@@ -202,7 +202,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 	 * This frequency is valid since TSC_ADC_SS controller design
 	 * assumes the OCP clock is at least 6x faster than the ADC clock.
 	 */
-	clk = devm_clk_get(&pdev->dev, "adc_tsc_fck");
+	clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(clk)) {
 		dev_err(&pdev->dev, "failed to get TSC fck\n");
 		err = PTR_ERR(clk);
-- 
2.27.0


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

* [PATCH 15/40] mfd: ti_am335x_tscadc: Simplify divisor calculation
  2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
                   ` (13 preceding siblings ...)
  2021-08-25 15:24 ` [PATCH 14/40] mfd: ti_am335x_tscadc: Don't search the tree for our clock Miquel Raynal
@ 2021-08-25 15:24 ` Miquel Raynal
  2021-08-30 13:47   ` Jonathan Cameron
  2021-08-25 15:24 ` [PATCH 16/40] mfd: ti_am335x_tscadc: Use driver data Miquel Raynal
                   ` (24 subsequent siblings)
  39 siblings, 1 reply; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:24 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal

Let's rewrite this on a single line, it does not hurt the readability
and saves a useless temporary variable.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mfd/ti_am335x_tscadc.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
index d27f8917272d..3231ccbbad02 100644
--- a/drivers/mfd/ti_am335x_tscadc.c
+++ b/drivers/mfd/ti_am335x_tscadc.c
@@ -122,7 +122,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 	struct clk *clk;
 	u32 val;
 	int tsc_wires = 0, adc_channels = 0, readouts = 0;
-	int total_channels, clock_rate, ctrl, err;
+	int total_channels, ctrl, err;
 
 	/* Allocate memory for device */
 	tscadc = devm_kzalloc(&pdev->dev, sizeof(*tscadc), GFP_KERNEL);
@@ -208,11 +208,8 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 		err = PTR_ERR(clk);
 		goto err_disable_clk;
 	}
-	clock_rate = clk_get_rate(clk);
-	tscadc->clk_div = clock_rate / ADC_CLK;
 
-	/* TSCADC_CLKDIV needs to be configured to the value minus 1 */
-	tscadc->clk_div--;
+	tscadc->clk_div = (clk_get_rate(clk) / ADC_CLK) - 1;
 	regmap_write(tscadc->regmap, REG_CLKDIV, tscadc->clk_div);
 
 	/* Set the control register bits */
-- 
2.27.0


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

* [PATCH 16/40] mfd: ti_am335x_tscadc: Use driver data
  2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
                   ` (14 preceding siblings ...)
  2021-08-25 15:24 ` [PATCH 15/40] mfd: ti_am335x_tscadc: Simplify divisor calculation Miquel Raynal
@ 2021-08-25 15:24 ` Miquel Raynal
  2021-08-30 14:46   ` Jonathan Cameron
  2021-08-25 15:24 ` [PATCH 17/40] mfd: ti_am335x_tscadc: Mimic the probe from resume() Miquel Raynal
                   ` (23 subsequent siblings)
  39 siblings, 1 reply; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:24 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal, Jason Reeder

So far every sub-cell parameter in this driver was hardcoded: cell name,
cell compatible, specific clock name and desired clock frequency.

As we are about to introduce support for ADC1/magnetic reader, we need a
bit of flexibility. Let's add a driver data structure which will contain
these information.

Co-developed-by: Jason Reeder <jreeder@ti.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Jason Reeder <jreeder@ti.com>
---
 drivers/mfd/ti_am335x_tscadc.c       | 20 +++++++++++++++-----
 include/linux/mfd/ti_am335x_tscadc.h |  9 +++++++++
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
index 3231ccbbad02..0cea44b4bd1a 100644
--- a/drivers/mfd/ti_am335x_tscadc.c
+++ b/drivers/mfd/ti_am335x_tscadc.c
@@ -136,6 +136,8 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
+	tscadc->data = of_device_get_match_data(&pdev->dev);
+
 	node = of_get_child_by_name(pdev->dev.of_node, "tsc");
 	of_property_read_u32(node, "ti,wires", &tsc_wires);
 	of_property_read_u32(node, "ti,coordiante-readouts", &readouts);
@@ -209,7 +211,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 		goto err_disable_clk;
 	}
 
-	tscadc->clk_div = (clk_get_rate(clk) / ADC_CLK) - 1;
+	tscadc->clk_div = (clk_get_rate(clk) / tscadc->data->target_clk_rate) - 1;
 	regmap_write(tscadc->regmap, REG_CLKDIV, tscadc->clk_div);
 
 	/* Set the control register bits */
@@ -238,8 +240,8 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 	if (tsc_wires > 0) {
 		tscadc->tsc_cell = tscadc->used_cells;
 		cell = &tscadc->cells[tscadc->used_cells++];
-		cell->name = "TI-am335x-tsc";
-		cell->of_compatible = "ti,am3359-tsc";
+		cell->name = tscadc->data->name_tscmag;
+		cell->of_compatible = tscadc->data->compat_tscmag;
 		cell->platform_data = &tscadc;
 		cell->pdata_size = sizeof(tscadc);
 	}
@@ -248,8 +250,8 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 	if (adc_channels > 0) {
 		tscadc->adc_cell = tscadc->used_cells;
 		cell = &tscadc->cells[tscadc->used_cells++];
-		cell->name = "TI-am335x-adc";
-		cell->of_compatible = "ti,am3359-adc";
+		cell->name = tscadc->data->name_adc;
+		cell->of_compatible = tscadc->data->compat_adc;
 		cell->platform_data = &tscadc;
 		cell->pdata_size = sizeof(tscadc);
 	}
@@ -335,6 +337,14 @@ static int __maybe_unused tscadc_resume(struct device *dev)
 
 static SIMPLE_DEV_PM_OPS(tscadc_pm_ops, tscadc_suspend, tscadc_resume);
 
+static const struct ti_tscadc_data tscdata = {
+	.name_tscmag = "TI-am335x-tsc",
+	.compat_tscmag = "ti,am3359-tsc",
+	.name_adc = "TI-am335x-adc",
+	.compat_adc = "ti,am3359-adc",
+	.target_clk_rate = ADC_CLK,
+};
+
 static const struct of_device_id ti_tscadc_dt_ids[] = {
 	{ .compatible = "ti,am3359-tscadc", },
 	{ }
diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h
index ffc091b77633..0f581c15d95a 100644
--- a/include/linux/mfd/ti_am335x_tscadc.h
+++ b/include/linux/mfd/ti_am335x_tscadc.h
@@ -162,11 +162,20 @@
 
 #define TSCADC_CELLS		2
 
+struct ti_tscadc_data {
+	char *name_tscmag;
+	char *compat_tscmag;
+	char *name_adc;
+	char *compat_adc;
+	unsigned int target_clk_rate;
+};
+
 struct ti_tscadc_dev {
 	struct device *dev;
 	struct regmap *regmap;
 	void __iomem *tscadc_base;
 	phys_addr_t tscadc_phys_base;
+	const struct ti_tscadc_data *data;
 	int irq;
 	int used_cells;	/* 1-2 */
 	int tsc_wires;
-- 
2.27.0


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

* [PATCH 17/40] mfd: ti_am335x_tscadc: Mimic the probe from resume()
  2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
                   ` (15 preceding siblings ...)
  2021-08-25 15:24 ` [PATCH 16/40] mfd: ti_am335x_tscadc: Use driver data Miquel Raynal
@ 2021-08-25 15:24 ` Miquel Raynal
  2021-08-25 15:24 ` [PATCH 18/40] mfd: ti_am335x_tscadc: Drop useless variables from the driver structure Miquel Raynal
                   ` (22 subsequent siblings)
  39 siblings, 0 replies; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:24 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal

Use the number of touchscreen wires (tsc_wires) instead of the flag
indicating a touchscreen cell (tsc_cell) to mimic the logic from the
probe.

Besides keeping a certain harmony in the driver, the main benefit is
that we are going to simplify the number of entries in the main MFD
structure and tsc_cell can now be removed more easily.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mfd/ti_am335x_tscadc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
index 0cea44b4bd1a..c25c7f5c101b 100644
--- a/drivers/mfd/ti_am335x_tscadc.c
+++ b/drivers/mfd/ti_am335x_tscadc.c
@@ -320,7 +320,7 @@ static int __maybe_unused tscadc_resume(struct device *dev)
 	ctrl = CNTRLREG_STEPCONFIGWRT |	CNTRLREG_STEPID;
 	regmap_write(tscadc->regmap, REG_CTRL, ctrl);
 
-	if (tscadc->tsc_cell != -1) {
+	if (tscadc->tsc_wires > 0) {
 		if (tscadc->tsc_wires == 5)
 			ctrl |= CNTRLREG_5WIRE | CNTRLREG_TSCENB;
 		else
-- 
2.27.0


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

* [PATCH 18/40] mfd: ti_am335x_tscadc: Drop useless variables from the driver structure
  2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
                   ` (16 preceding siblings ...)
  2021-08-25 15:24 ` [PATCH 17/40] mfd: ti_am335x_tscadc: Mimic the probe from resume() Miquel Raynal
@ 2021-08-25 15:24 ` Miquel Raynal
  2021-08-25 15:24 ` [PATCH 19/40] mfd: ti_am335x_tscadc: Always provide an idle configuration Miquel Raynal
                   ` (21 subsequent siblings)
  39 siblings, 0 replies; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:24 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal

Keeping the count of tsc_cells and adc_cells is completely redundant, we
can derive this information from other variables. Plus, these variables
are not used anywhere else now. Let's get rid of them.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mfd/ti_am335x_tscadc.c       | 15 ++++-----------
 include/linux/mfd/ti_am335x_tscadc.h |  3 ---
 2 files changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
index c25c7f5c101b..258199be4c6a 100644
--- a/drivers/mfd/ti_am335x_tscadc.c
+++ b/drivers/mfd/ti_am335x_tscadc.c
@@ -121,7 +121,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 	const __be32 *cur;
 	struct clk *clk;
 	u32 val;
-	int tsc_wires = 0, adc_channels = 0, readouts = 0;
+	int tsc_wires = 0, adc_channels = 0, readouts = 0, cell_idx = 0;
 	int total_channels, ctrl, err;
 
 	/* Allocate memory for device */
@@ -232,14 +232,9 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 	ctrl |= CNTRLREG_TSCSSENB;
 	regmap_write(tscadc->regmap, REG_CTRL, ctrl);
 
-	tscadc->used_cells = 0;
-	tscadc->tsc_cell = -1;
-	tscadc->adc_cell = -1;
-
 	/* TSC Cell */
 	if (tsc_wires > 0) {
-		tscadc->tsc_cell = tscadc->used_cells;
-		cell = &tscadc->cells[tscadc->used_cells++];
+		cell = &tscadc->cells[cell_idx++];
 		cell->name = tscadc->data->name_tscmag;
 		cell->of_compatible = tscadc->data->compat_tscmag;
 		cell->platform_data = &tscadc;
@@ -248,8 +243,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 
 	/* ADC Cell */
 	if (adc_channels > 0) {
-		tscadc->adc_cell = tscadc->used_cells;
-		cell = &tscadc->cells[tscadc->used_cells++];
+		cell = &tscadc->cells[cell_idx++];
 		cell->name = tscadc->data->name_adc;
 		cell->of_compatible = tscadc->data->compat_adc;
 		cell->platform_data = &tscadc;
@@ -257,8 +251,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 	}
 
 	err = mfd_add_devices(&pdev->dev, PLATFORM_DEVID_AUTO,
-			      tscadc->cells, tscadc->used_cells, NULL,
-			      0, NULL);
+			      tscadc->cells, cell_idx, NULL, 0, NULL);
 	if (err < 0)
 		goto err_disable_clk;
 
diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h
index 0f581c15d95a..e734fb97dff8 100644
--- a/include/linux/mfd/ti_am335x_tscadc.h
+++ b/include/linux/mfd/ti_am335x_tscadc.h
@@ -177,10 +177,7 @@ struct ti_tscadc_dev {
 	phys_addr_t tscadc_phys_base;
 	const struct ti_tscadc_data *data;
 	int irq;
-	int used_cells;	/* 1-2 */
 	int tsc_wires;
-	int tsc_cell;	/* -1 if not used */
-	int adc_cell;	/* -1 if not used */
 	struct mfd_cell cells[TSCADC_CELLS];
 	u32 reg_se_cache;
 	bool adc_waiting;
-- 
2.27.0


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

* [PATCH 19/40] mfd: ti_am335x_tscadc: Always provide an idle configuration
  2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
                   ` (17 preceding siblings ...)
  2021-08-25 15:24 ` [PATCH 18/40] mfd: ti_am335x_tscadc: Drop useless variables from the driver structure Miquel Raynal
@ 2021-08-25 15:24 ` Miquel Raynal
  2021-08-30 14:49   ` Jonathan Cameron
  2021-08-25 15:24 ` [PATCH 20/40] mfd: ti_am335x_tscadc: Gather the ctrl register logic at one place Miquel Raynal
                   ` (20 subsequent siblings)
  39 siblings, 1 reply; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:24 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal

The idle register is valid no matter if the touchscreen is used or not,
let's always configure it.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mfd/ti_am335x_tscadc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
index 258199be4c6a..7071344ad18e 100644
--- a/drivers/mfd/ti_am335x_tscadc.c
+++ b/drivers/mfd/ti_am335x_tscadc.c
@@ -218,16 +218,16 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 	ctrl = CNTRLREG_STEPCONFIGWRT |	CNTRLREG_STEPID;
 	regmap_write(tscadc->regmap, REG_CTRL, ctrl);
 
-	/* Set register bits for Idle Config Mode */
 	if (tsc_wires > 0) {
 		tscadc->tsc_wires = tsc_wires;
 		if (tsc_wires == 5)
 			ctrl |= CNTRLREG_5WIRE | CNTRLREG_TSCENB;
 		else
 			ctrl |= CNTRLREG_4WIRE | CNTRLREG_TSCENB;
-		tscadc_idle_config(tscadc);
 	}
 
+	tscadc_idle_config(tscadc);
+
 	/* Enable the TSC module enable bit */
 	ctrl |= CNTRLREG_TSCSSENB;
 	regmap_write(tscadc->regmap, REG_CTRL, ctrl);
@@ -318,12 +318,12 @@ static int __maybe_unused tscadc_resume(struct device *dev)
 			ctrl |= CNTRLREG_5WIRE | CNTRLREG_TSCENB;
 		else
 			ctrl |= CNTRLREG_4WIRE | CNTRLREG_TSCENB;
-		tscadc_idle_config(tscadc);
 	}
 	ctrl |= CNTRLREG_TSCSSENB;
 	regmap_write(tscadc->regmap, REG_CTRL, ctrl);
 
 	regmap_write(tscadc->regmap, REG_CLKDIV, tscadc->clk_div);
+	tscadc_idle_config(tscadc);
 
 	return 0;
 }
-- 
2.27.0


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

* [PATCH 20/40] mfd: ti_am335x_tscadc: Gather the ctrl register logic at one place
  2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
                   ` (18 preceding siblings ...)
  2021-08-25 15:24 ` [PATCH 19/40] mfd: ti_am335x_tscadc: Always provide an idle configuration Miquel Raynal
@ 2021-08-25 15:24 ` Miquel Raynal
  2021-08-30 13:56   ` Jonathan Cameron
  2021-08-25 15:24 ` [PATCH 21/40] mfd: ti_am335x_tscadc: Rename the subsystem enable macro Miquel Raynal
                   ` (19 subsequent siblings)
  39 siblings, 1 reply; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:24 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal

Instead of deriving in the probe and in the resume path the value of the
ctrl register, let's do it only once in the probe, save the value of
this register in the driver's structure and use it from the resume
callback.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mfd/ti_am335x_tscadc.c       | 31 ++++++++--------------------
 include/linux/mfd/ti_am335x_tscadc.h |  2 +-
 2 files changed, 10 insertions(+), 23 deletions(-)

diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
index 7071344ad18e..d661e8ae66c9 100644
--- a/drivers/mfd/ti_am335x_tscadc.c
+++ b/drivers/mfd/ti_am335x_tscadc.c
@@ -122,7 +122,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 	struct clk *clk;
 	u32 val;
 	int tsc_wires = 0, adc_channels = 0, readouts = 0, cell_idx = 0;
-	int total_channels, ctrl, err;
+	int total_channels, err;
 
 	/* Allocate memory for device */
 	tscadc = devm_kzalloc(&pdev->dev, sizeof(*tscadc), GFP_KERNEL);
@@ -215,22 +215,21 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 	regmap_write(tscadc->regmap, REG_CLKDIV, tscadc->clk_div);
 
 	/* Set the control register bits */
-	ctrl = CNTRLREG_STEPCONFIGWRT |	CNTRLREG_STEPID;
-	regmap_write(tscadc->regmap, REG_CTRL, ctrl);
+	tscadc->ctrl = CNTRLREG_STEPCONFIGWRT | CNTRLREG_STEPID;
+	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl);
 
 	if (tsc_wires > 0) {
-		tscadc->tsc_wires = tsc_wires;
+		tscadc->ctrl |= CNTRLREG_TSCENB;
 		if (tsc_wires == 5)
-			ctrl |= CNTRLREG_5WIRE | CNTRLREG_TSCENB;
+			tscadc->ctrl |= CNTRLREG_5WIRE;
 		else
-			ctrl |= CNTRLREG_4WIRE | CNTRLREG_TSCENB;
+			tscadc->ctrl |= CNTRLREG_4WIRE;
 	}
 
 	tscadc_idle_config(tscadc);
 
 	/* Enable the TSC module enable bit */
-	ctrl |= CNTRLREG_TSCSSENB;
-	regmap_write(tscadc->regmap, REG_CTRL, ctrl);
+	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl | CNTRLREG_TSCSSENB);
 
 	/* TSC Cell */
 	if (tsc_wires > 0) {
@@ -305,25 +304,13 @@ static int __maybe_unused tscadc_suspend(struct device *dev)
 static int __maybe_unused tscadc_resume(struct device *dev)
 {
 	struct ti_tscadc_dev *tscadc = dev_get_drvdata(dev);
-	u32 ctrl;
 
 	pm_runtime_get_sync(dev);
 
-	/* context restore */
-	ctrl = CNTRLREG_STEPCONFIGWRT |	CNTRLREG_STEPID;
-	regmap_write(tscadc->regmap, REG_CTRL, ctrl);
-
-	if (tscadc->tsc_wires > 0) {
-		if (tscadc->tsc_wires == 5)
-			ctrl |= CNTRLREG_5WIRE | CNTRLREG_TSCENB;
-		else
-			ctrl |= CNTRLREG_4WIRE | CNTRLREG_TSCENB;
-	}
-	ctrl |= CNTRLREG_TSCSSENB;
-	regmap_write(tscadc->regmap, REG_CTRL, ctrl);
-
 	regmap_write(tscadc->regmap, REG_CLKDIV, tscadc->clk_div);
+	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl);
 	tscadc_idle_config(tscadc);
+	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl | CNTRLREG_TSCSSENB);
 
 	return 0;
 }
diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h
index e734fb97dff8..02963b6ebbac 100644
--- a/include/linux/mfd/ti_am335x_tscadc.h
+++ b/include/linux/mfd/ti_am335x_tscadc.h
@@ -177,8 +177,8 @@ struct ti_tscadc_dev {
 	phys_addr_t tscadc_phys_base;
 	const struct ti_tscadc_data *data;
 	int irq;
-	int tsc_wires;
 	struct mfd_cell cells[TSCADC_CELLS];
+	u32 ctrl;
 	u32 reg_se_cache;
 	bool adc_waiting;
 	bool adc_in_use;
-- 
2.27.0


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

* [PATCH 21/40] mfd: ti_am335x_tscadc: Rename the subsystem enable macro
  2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
                   ` (19 preceding siblings ...)
  2021-08-25 15:24 ` [PATCH 20/40] mfd: ti_am335x_tscadc: Gather the ctrl register logic at one place Miquel Raynal
@ 2021-08-25 15:24 ` Miquel Raynal
  2021-08-30 14:50   ` Jonathan Cameron
  2021-08-25 15:25 ` [PATCH 22/40] mfd: ti_am335x_tscadc: Add TSC prefix in certain macros Miquel Raynal
                   ` (18 subsequent siblings)
  39 siblings, 1 reply; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:24 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal

This bit is common to all devices (ADC, Touchscreen, Magnetic reader) so
make it clear that it can be used from any location by operating a
mechanical rename:
s/CNTRLREG_TSCSSENB/CNTRLREG_SSENB/

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/iio/adc/ti_am335x_adc.c      | 6 +++---
 drivers/mfd/ti_am335x_tscadc.c       | 6 +++---
 include/linux/mfd/ti_am335x_tscadc.h | 2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
index 855cc2d64ac8..f748d49f10f4 100644
--- a/drivers/iio/adc/ti_am335x_adc.c
+++ b/drivers/iio/adc/ti_am335x_adc.c
@@ -184,7 +184,7 @@ static irqreturn_t tiadc_irq_h(int irq, void *private)
 	if (status & IRQENB_FIFO1OVRRUN) {
 		/* FIFO Overrun. Clear flag. Disable/Enable ADC to recover */
 		config = tiadc_readl(adc_dev, REG_CTRL);
-		config &= ~(CNTRLREG_TSCSSENB);
+		config &= ~(CNTRLREG_SSENB);
 		tiadc_writel(adc_dev, REG_CTRL, config);
 		tiadc_writel(adc_dev, REG_IRQSTATUS, IRQENB_FIFO1OVRRUN
 				| IRQENB_FIFO1UNDRFLW | IRQENB_FIFO1THRES);
@@ -197,7 +197,7 @@ static irqreturn_t tiadc_irq_h(int irq, void *private)
 			adc_fsm = tiadc_readl(adc_dev, REG_ADCFSM);
 		} while (adc_fsm != 0x10 && count++ < 100);
 
-		tiadc_writel(adc_dev, REG_CTRL, (config | CNTRLREG_TSCSSENB));
+		tiadc_writel(adc_dev, REG_CTRL, (config | CNTRLREG_SSENB));
 		return IRQ_HANDLED;
 	} else if (status & IRQENB_FIFO1THRES) {
 		/* Disable irq and wake worker thread */
@@ -671,7 +671,7 @@ static int __maybe_unused tiadc_suspend(struct device *dev)
 	unsigned int idle;
 
 	idle = tiadc_readl(adc_dev, REG_CTRL);
-	idle &= ~(CNTRLREG_TSCSSENB);
+	idle &= ~(CNTRLREG_SSENB);
 	tiadc_writel(adc_dev, REG_CTRL, (idle |
 			CNTRLREG_POWERDOWN));
 
diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
index d661e8ae66c9..dd303523f9a3 100644
--- a/drivers/mfd/ti_am335x_tscadc.c
+++ b/drivers/mfd/ti_am335x_tscadc.c
@@ -229,7 +229,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 	tscadc_idle_config(tscadc);
 
 	/* Enable the TSC module enable bit */
-	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl | CNTRLREG_TSCSSENB);
+	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl | CNTRLREG_SSENB);
 
 	/* TSC Cell */
 	if (tsc_wires > 0) {
@@ -293,7 +293,7 @@ static int __maybe_unused tscadc_suspend(struct device *dev)
 
 		regmap_read(tscadc->regmap, REG_CTRL, &ctrl);
 		ctrl &= ~(CNTRLREG_POWERDOWN);
-		ctrl |= CNTRLREG_TSCSSENB;
+		ctrl |= CNTRLREG_SSENB;
 		regmap_write(tscadc->regmap, REG_CTRL, ctrl);
 	}
 	pm_runtime_put_sync(dev);
@@ -310,7 +310,7 @@ static int __maybe_unused tscadc_resume(struct device *dev)
 	regmap_write(tscadc->regmap, REG_CLKDIV, tscadc->clk_div);
 	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl);
 	tscadc_idle_config(tscadc);
-	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl | CNTRLREG_TSCSSENB);
+	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl | CNTRLREG_SSENB);
 
 	return 0;
 }
diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h
index 02963b6ebbac..a900fae8354c 100644
--- a/include/linux/mfd/ti_am335x_tscadc.h
+++ b/include/linux/mfd/ti_am335x_tscadc.h
@@ -118,7 +118,7 @@
 #define CHARGEDLY_OPENDLY	CHARGEDLY_OPEN(0x400)
 
 /* Control register */
-#define CNTRLREG_TSCSSENB	BIT(0)
+#define CNTRLREG_SSENB		BIT(0)
 #define CNTRLREG_STEPID		BIT(1)
 #define CNTRLREG_STEPCONFIGWRT	BIT(2)
 #define CNTRLREG_POWERDOWN	BIT(4)
-- 
2.27.0


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

* [PATCH 22/40] mfd: ti_am335x_tscadc: Add TSC prefix in certain macros
  2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
                   ` (20 preceding siblings ...)
  2021-08-25 15:24 ` [PATCH 21/40] mfd: ti_am335x_tscadc: Rename the subsystem enable macro Miquel Raynal
@ 2021-08-25 15:25 ` Miquel Raynal
  2021-08-30 14:52   ` Jonathan Cameron
  2021-08-25 15:25 ` [PATCH 23/40] mfd: ti_am335x_tscadc: Rename a variable Miquel Raynal
                   ` (17 subsequent siblings)
  39 siblings, 1 reply; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:25 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal

While the register list (and names) between ADC0 and ADC1 are pretty
close, the bits inside changed a little bit. To avoid any future
confusion, let's add the TSC prefix when some bits are in a register
that is common to both revisions of the ADC, but are specific to the
am33xx hardware.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mfd/ti_am335x_tscadc.c       | 10 +++++-----
 include/linux/mfd/ti_am335x_tscadc.h | 16 ++++++++--------
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
index dd303523f9a3..02477ce827d0 100644
--- a/drivers/mfd/ti_am335x_tscadc.c
+++ b/drivers/mfd/ti_am335x_tscadc.c
@@ -215,15 +215,15 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 	regmap_write(tscadc->regmap, REG_CLKDIV, tscadc->clk_div);
 
 	/* Set the control register bits */
-	tscadc->ctrl = CNTRLREG_STEPCONFIGWRT | CNTRLREG_STEPID;
+	tscadc->ctrl = CNTRLREG_TSC_STEPCONFIGWRT | CNTRLREG_STEPID;
 	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl);
 
 	if (tsc_wires > 0) {
-		tscadc->ctrl |= CNTRLREG_TSCENB;
+		tscadc->ctrl |= CNTRLREG_TSC_ENB;
 		if (tsc_wires == 5)
-			tscadc->ctrl |= CNTRLREG_5WIRE;
+			tscadc->ctrl |= CNTRLREG_TSC_5WIRE;
 		else
-			tscadc->ctrl |= CNTRLREG_4WIRE;
+			tscadc->ctrl |= CNTRLREG_TSC_4WIRE;
 	}
 
 	tscadc_idle_config(tscadc);
@@ -322,7 +322,7 @@ static const struct ti_tscadc_data tscdata = {
 	.compat_tscmag = "ti,am3359-tsc",
 	.name_adc = "TI-am335x-adc",
 	.compat_adc = "ti,am3359-adc",
-	.target_clk_rate = ADC_CLK,
+	.target_clk_rate = TSC_ADC_CLK,
 };
 
 static const struct of_device_id ti_tscadc_dt_ids[] = {
diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h
index a900fae8354c..d5e2ff8dc84a 100644
--- a/include/linux/mfd/ti_am335x_tscadc.h
+++ b/include/linux/mfd/ti_am335x_tscadc.h
@@ -120,14 +120,14 @@
 /* Control register */
 #define CNTRLREG_SSENB		BIT(0)
 #define CNTRLREG_STEPID		BIT(1)
-#define CNTRLREG_STEPCONFIGWRT	BIT(2)
+#define CNTRLREG_TSC_STEPCONFIGWRT BIT(2)
 #define CNTRLREG_POWERDOWN	BIT(4)
-#define CNTRLREG_AFE_CTRL_MASK	(3 << 5)
-#define CNTRLREG_AFE_CTRL(val)	((val) << 5)
-#define CNTRLREG_4WIRE		CNTRLREG_AFE_CTRL(1)
-#define CNTRLREG_5WIRE		CNTRLREG_AFE_CTRL(2)
-#define CNTRLREG_8WIRE		CNTRLREG_AFE_CTRL(3)
-#define CNTRLREG_TSCENB		BIT(7)
+#define CNTRLREG_TSC_AFE_CTRL_MASK (3 << 5)
+#define CNTRLREG_TSC_AFE_CTRL(val) ((val) << 5)
+#define CNTRLREG_TSC_4WIRE	CNTRLREG_TSC_AFE_CTRL(1)
+#define CNTRLREG_TSC_5WIRE	CNTRLREG_TSC_AFE_CTRL(2)
+#define CNTRLREG_TSC_8WIRE	CNTRLREG_TSC_AFE_CTRL(3)
+#define CNTRLREG_TSC_ENB	BIT(7)
 
 /* FIFO READ Register */
 #define FIFOREAD_DATA_MASK (0xfff << 0)
@@ -141,7 +141,7 @@
 #define SEQ_STATUS BIT(5)
 #define CHARGE_STEP		0x11
 
-#define ADC_CLK			3000000
+#define TSC_ADC_CLK		3000000
 #define TOTAL_STEPS		16
 #define TOTAL_CHANNELS		8
 #define FIFO1_THRESHOLD		19
-- 
2.27.0


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

* [PATCH 23/40] mfd: ti_am335x_tscadc: Rename a variable
  2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
                   ` (21 preceding siblings ...)
  2021-08-25 15:25 ` [PATCH 22/40] mfd: ti_am335x_tscadc: Add TSC prefix in certain macros Miquel Raynal
@ 2021-08-25 15:25 ` Miquel Raynal
  2021-08-30 14:53   ` Jonathan Cameron
  2021-08-25 15:25 ` [PATCH 24/40] mfd: ti_am335x_tscadc: Fix an error message Miquel Raynal
                   ` (16 subsequent siblings)
  39 siblings, 1 reply; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:25 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal

We need to retrieve the number of wires used by the "secondary" device
(the touchscreen or the magnetic reader). Let's rename tsc_wires to
become tscmag_wires to clarify the fact that this variable can be used
in both situations.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mfd/ti_am335x_tscadc.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
index 02477ce827d0..047426a74a2e 100644
--- a/drivers/mfd/ti_am335x_tscadc.c
+++ b/drivers/mfd/ti_am335x_tscadc.c
@@ -121,7 +121,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 	const __be32 *cur;
 	struct clk *clk;
 	u32 val;
-	int tsc_wires = 0, adc_channels = 0, readouts = 0, cell_idx = 0;
+	int tscmag_wires = 0, adc_channels = 0, readouts = 0, cell_idx = 0;
 	int total_channels, err;
 
 	/* Allocate memory for device */
@@ -139,7 +139,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 	tscadc->data = of_device_get_match_data(&pdev->dev);
 
 	node = of_get_child_by_name(pdev->dev.of_node, "tsc");
-	of_property_read_u32(node, "ti,wires", &tsc_wires);
+	of_property_read_u32(node, "ti,wires", &tscmag_wires);
 	of_property_read_u32(node, "ti,coordiante-readouts", &readouts);
 
 	node = of_get_child_by_name(pdev->dev.of_node, "adc");
@@ -152,7 +152,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 		}
 	}
 
-	total_channels = tsc_wires + adc_channels;
+	total_channels = tscmag_wires + adc_channels;
 	if (total_channels > 8) {
 		dev_err(&pdev->dev, "Number of i/p channels more than 8\n");
 		return -EINVAL;
@@ -218,9 +218,9 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 	tscadc->ctrl = CNTRLREG_TSC_STEPCONFIGWRT | CNTRLREG_STEPID;
 	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl);
 
-	if (tsc_wires > 0) {
+	if (tscmag_wires > 0) {
 		tscadc->ctrl |= CNTRLREG_TSC_ENB;
-		if (tsc_wires == 5)
+		if (tscmag_wires == 5)
 			tscadc->ctrl |= CNTRLREG_TSC_5WIRE;
 		else
 			tscadc->ctrl |= CNTRLREG_TSC_4WIRE;
@@ -232,7 +232,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl | CNTRLREG_SSENB);
 
 	/* TSC Cell */
-	if (tsc_wires > 0) {
+	if (tscmag_wires > 0) {
 		cell = &tscadc->cells[cell_idx++];
 		cell->name = tscadc->data->name_tscmag;
 		cell->of_compatible = tscadc->data->compat_tscmag;
-- 
2.27.0


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

* [PATCH 24/40] mfd: ti_am335x_tscadc: Fix an error message
  2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
                   ` (22 preceding siblings ...)
  2021-08-25 15:25 ` [PATCH 23/40] mfd: ti_am335x_tscadc: Rename a variable Miquel Raynal
@ 2021-08-25 15:25 ` Miquel Raynal
  2021-08-30 13:58   ` Jonathan Cameron
  2021-08-25 15:25 ` [PATCH 25/40] mfd: ti_am335x_tscadc: Add a boolean to clarify the presence of a touchscreen Miquel Raynal
                   ` (15 subsequent siblings)
  39 siblings, 1 reply; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:25 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal

The error message if we cannot retrieve the clock tells us that the
touchscreen controller clock was unavailable. This is wrong, this is the
"main" clock for the hardware block, it is not specific to the
touchscreen and won't change when we will introduce ADC1/magnetic reader
support so let's corret this comment.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mfd/ti_am335x_tscadc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
index 047426a74a2e..2f934fd2154a 100644
--- a/drivers/mfd/ti_am335x_tscadc.c
+++ b/drivers/mfd/ti_am335x_tscadc.c
@@ -206,7 +206,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 	 */
 	clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(clk)) {
-		dev_err(&pdev->dev, "failed to get TSC fck\n");
+		dev_err(&pdev->dev, "failed to get fck\n");
 		err = PTR_ERR(clk);
 		goto err_disable_clk;
 	}
-- 
2.27.0


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

* [PATCH 25/40] mfd: ti_am335x_tscadc: Add a boolean to clarify the presence of a touchscreen
  2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
                   ` (23 preceding siblings ...)
  2021-08-25 15:25 ` [PATCH 24/40] mfd: ti_am335x_tscadc: Fix an error message Miquel Raynal
@ 2021-08-25 15:25 ` Miquel Raynal
  2021-08-30 13:59   ` Jonathan Cameron
  2021-08-25 15:25 ` [PATCH 26/40] mfd: ti_am335x_tscadc: Introduce has_tsc Miquel Raynal
                   ` (14 subsequent siblings)
  39 siblings, 1 reply; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:25 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal

Just checking the number of wires will soon not be enough, add a boolean
to indicated the actual use or not of the touchscreen.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mfd/ti_am335x_tscadc.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
index 2f934fd2154a..30f53cdb41f8 100644
--- a/drivers/mfd/ti_am335x_tscadc.c
+++ b/drivers/mfd/ti_am335x_tscadc.c
@@ -121,6 +121,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 	const __be32 *cur;
 	struct clk *clk;
 	u32 val;
+	bool use_tsc = false;
 	int tscmag_wires = 0, adc_channels = 0, readouts = 0, cell_idx = 0;
 	int total_channels, err;
 
@@ -141,6 +142,8 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 	node = of_get_child_by_name(pdev->dev.of_node, "tsc");
 	of_property_read_u32(node, "ti,wires", &tscmag_wires);
 	of_property_read_u32(node, "ti,coordiante-readouts", &readouts);
+	if (tscmag_wires)
+		use_tsc = true;
 
 	node = of_get_child_by_name(pdev->dev.of_node, "adc");
 	of_property_for_each_u32(node, "ti,adc-channels", prop, cur, val) {
@@ -163,7 +166,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	if (readouts * 2 + 2 + adc_channels > 16) {
+	if (use_tsc && (readouts * 2 + 2 + adc_channels > 16)) {
 		dev_err(&pdev->dev, "Too many step configurations requested\n");
 		return -EINVAL;
 	}
@@ -218,7 +221,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 	tscadc->ctrl = CNTRLREG_TSC_STEPCONFIGWRT | CNTRLREG_STEPID;
 	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl);
 
-	if (tscmag_wires > 0) {
+	if (use_tsc) {
 		tscadc->ctrl |= CNTRLREG_TSC_ENB;
 		if (tscmag_wires == 5)
 			tscadc->ctrl |= CNTRLREG_TSC_5WIRE;
-- 
2.27.0


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

* [PATCH 26/40] mfd: ti_am335x_tscadc: Introduce has_tsc
  2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
                   ` (24 preceding siblings ...)
  2021-08-25 15:25 ` [PATCH 25/40] mfd: ti_am335x_tscadc: Add a boolean to clarify the presence of a touchscreen Miquel Raynal
@ 2021-08-25 15:25 ` Miquel Raynal
  2021-08-30 14:02   ` Jonathan Cameron
  2021-08-25 15:25 ` [PATCH 27/40] mfd: ti_am335x_tscadc: Move control register configuration Miquel Raynal
                   ` (13 subsequent siblings)
  39 siblings, 1 reply; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:25 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal

One way of knowing which hardware we are dealing with is to check its
compatible. When this must be done at several places, it's best to use a
proper boolean for that. ->has_tsc indicates if there is a touchscreen
controller available (meaning it's a am33xx-like ADC) or not but does
not indicate if it is actually used (that is the purpose of the use_tsc
boolean in the probe).

Introducing this boolean helps making a difference in the code between
what is generic to both types of ADCs and what is specific to the am33xx
hardware before introducing support for the am437x hardware.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mfd/ti_am335x_tscadc.c       | 37 +++++++++++++++++-----------
 include/linux/mfd/ti_am335x_tscadc.h |  1 +
 2 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
index 30f53cdb41f8..a40091830cea 100644
--- a/drivers/mfd/ti_am335x_tscadc.c
+++ b/drivers/mfd/ti_am335x_tscadc.c
@@ -105,8 +105,9 @@ static void tscadc_idle_config(struct ti_tscadc_dev *tscadc)
 {
 	unsigned int idleconfig;
 
-	idleconfig = STEPCONFIG_YNN | STEPCONFIG_INM_ADCREFM |
-			STEPCONFIG_INP_ADCREFM | STEPCONFIG_YPN;
+	idleconfig = STEPCONFIG_INM_ADCREFM | STEPCONFIG_INP_ADCREFM;
+	if (tscadc->data->has_tsc)
+		idleconfig |= STEPCONFIG_YNN | STEPCONFIG_YPN;
 
 	regmap_write(tscadc->regmap, REG_IDLECONFIG, idleconfig);
 }
@@ -139,11 +140,13 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 
 	tscadc->data = of_device_get_match_data(&pdev->dev);
 
-	node = of_get_child_by_name(pdev->dev.of_node, "tsc");
-	of_property_read_u32(node, "ti,wires", &tscmag_wires);
-	of_property_read_u32(node, "ti,coordiante-readouts", &readouts);
-	if (tscmag_wires)
-		use_tsc = true;
+	if (tscadc->data->has_tsc) {
+		node = of_get_child_by_name(pdev->dev.of_node, "tsc");
+		of_property_read_u32(node, "ti,wires", &tscmag_wires);
+		of_property_read_u32(node, "ti,coordiante-readouts", &readouts);
+		if (tscmag_wires)
+			use_tsc = true;
+	}
 
 	node = of_get_child_by_name(pdev->dev.of_node, "adc");
 	of_property_for_each_u32(node, "ti,adc-channels", prop, cur, val) {
@@ -218,15 +221,18 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 	regmap_write(tscadc->regmap, REG_CLKDIV, tscadc->clk_div);
 
 	/* Set the control register bits */
-	tscadc->ctrl = CNTRLREG_TSC_STEPCONFIGWRT | CNTRLREG_STEPID;
-	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl);
+	tscadc->ctrl = CNTRLREG_STEPID;
+	if (tscadc->data->has_tsc) {
+		tscadc->ctrl |= CNTRLREG_TSC_STEPCONFIGWRT;
+		regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl);
+		if (use_tsc) {
+			tscadc->ctrl |= CNTRLREG_TSC_ENB;
+			if (tscmag_wires == 5)
+				tscadc->ctrl |= CNTRLREG_TSC_5WIRE;
+			else
+				tscadc->ctrl |= CNTRLREG_TSC_4WIRE;
+		}
 
-	if (use_tsc) {
-		tscadc->ctrl |= CNTRLREG_TSC_ENB;
-		if (tscmag_wires == 5)
-			tscadc->ctrl |= CNTRLREG_TSC_5WIRE;
-		else
-			tscadc->ctrl |= CNTRLREG_TSC_4WIRE;
 	}
 
 	tscadc_idle_config(tscadc);
@@ -321,6 +327,7 @@ static int __maybe_unused tscadc_resume(struct device *dev)
 static SIMPLE_DEV_PM_OPS(tscadc_pm_ops, tscadc_suspend, tscadc_resume);
 
 static const struct ti_tscadc_data tscdata = {
+	.has_tsc = true,
 	.name_tscmag = "TI-am335x-tsc",
 	.compat_tscmag = "ti,am3359-tsc",
 	.name_adc = "TI-am335x-adc",
diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h
index d5e2ff8dc84a..082b2af94263 100644
--- a/include/linux/mfd/ti_am335x_tscadc.h
+++ b/include/linux/mfd/ti_am335x_tscadc.h
@@ -163,6 +163,7 @@
 #define TSCADC_CELLS		2
 
 struct ti_tscadc_data {
+	bool has_tsc;
 	char *name_tscmag;
 	char *compat_tscmag;
 	char *name_adc;
-- 
2.27.0


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

* [PATCH 27/40] mfd: ti_am335x_tscadc: Move control register configuration
  2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
                   ` (25 preceding siblings ...)
  2021-08-25 15:25 ` [PATCH 26/40] mfd: ti_am335x_tscadc: Introduce has_tsc Miquel Raynal
@ 2021-08-25 15:25 ` Miquel Raynal
  2021-08-30 14:03   ` Jonathan Cameron
  2021-08-25 15:25 ` [PATCH 28/40] mfd: ti_am335x_tscadc: Add ADC1/magnetic reader support Miquel Raynal
                   ` (12 subsequent siblings)
  39 siblings, 1 reply; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:25 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal

The datasheet states that most of the configuration should be set in the
control register in the first place, before actually enabling the
hardware. So far only half of the configuration was made in the first
step, which does not make really sense and would complicating the code
when introducing support for the am437x hardware.

Let's move that register write a bit below to enclose more configuration.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mfd/ti_am335x_tscadc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
index a40091830cea..1a30610dc65f 100644
--- a/drivers/mfd/ti_am335x_tscadc.c
+++ b/drivers/mfd/ti_am335x_tscadc.c
@@ -224,7 +224,6 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 	tscadc->ctrl = CNTRLREG_STEPID;
 	if (tscadc->data->has_tsc) {
 		tscadc->ctrl |= CNTRLREG_TSC_STEPCONFIGWRT;
-		regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl);
 		if (use_tsc) {
 			tscadc->ctrl |= CNTRLREG_TSC_ENB;
 			if (tscmag_wires == 5)
@@ -235,6 +234,8 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 
 	}
 
+	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl);
+
 	tscadc_idle_config(tscadc);
 
 	/* Enable the TSC module enable bit */
-- 
2.27.0


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

* [PATCH 28/40] mfd: ti_am335x_tscadc: Add ADC1/magnetic reader support
  2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
                   ` (26 preceding siblings ...)
  2021-08-25 15:25 ` [PATCH 27/40] mfd: ti_am335x_tscadc: Move control register configuration Miquel Raynal
@ 2021-08-25 15:25 ` Miquel Raynal
  2021-08-30 14:10   ` Jonathan Cameron
  2021-09-01 19:26   ` Grygorii Strashko
  2021-08-25 15:25 ` [PATCH 29/40] mfd: ti_am335x_tscadc: Support the correctly spelled DT property Miquel Raynal
                   ` (11 subsequent siblings)
  39 siblings, 2 replies; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:25 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal, Jason Reeder

Introduce a new compatible that has another set of driver data,
targeting am437x SoCs with a magnetic reader instead of the
touchscreen and a more featureful set of registers.

Co-developed-by: Jason Reeder <jreeder@ti.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Jason Reeder <jreeder@ti.com>
---
 drivers/mfd/ti_am335x_tscadc.c       | 43 ++++++++++++++++++++++------
 include/linux/mfd/ti_am335x_tscadc.h |  9 +++++-
 2 files changed, 43 insertions(+), 9 deletions(-)

diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
index 1a30610dc65f..f4f6b9db4d2a 100644
--- a/drivers/mfd/ti_am335x_tscadc.c
+++ b/drivers/mfd/ti_am335x_tscadc.c
@@ -122,9 +122,9 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 	const __be32 *cur;
 	struct clk *clk;
 	u32 val;
-	bool use_tsc = false;
+	bool use_tsc = false, use_mag = false;
 	int tscmag_wires = 0, adc_channels = 0, readouts = 0, cell_idx = 0;
-	int total_channels, err;
+	int mag_tracks = 0, total_channels, err;
 
 	/* Allocate memory for device */
 	tscadc = devm_kzalloc(&pdev->dev, sizeof(*tscadc), GFP_KERNEL);
@@ -146,6 +146,12 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 		of_property_read_u32(node, "ti,coordiante-readouts", &readouts);
 		if (tscmag_wires)
 			use_tsc = true;
+	} else {
+		node = of_get_child_by_name(pdev->dev.of_node, "mag");
+		of_property_read_u32(node, "ti,tracks", &mag_tracks);
+		tscmag_wires = mag_tracks * 2;
+		if (tscmag_wires)
+			use_mag = true;
 	}
 
 	node = of_get_child_by_name(pdev->dev.of_node, "adc");
@@ -206,8 +212,9 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 	 * The TSC_ADC_Subsystem has 2 clock domains: OCP_CLK and ADC_CLK.
 	 * ADCs produce a 12-bit sample every 15 ADC_CLK cycles.
 	 * am33xx ADCs expect to capture 200ksps.
-	 * We need the ADC clocks to run at 3MHz.
-	 * This frequency is valid since TSC_ADC_SS controller design
+	 * am47xx ADCs expect to capture 867ksps.
+	 * We need ADC clocks respectively running at 3MHz and 13MHz.
+	 * These frequencies are valid since TSC_ADC_SS controller design
 	 * assumes the OCP clock is at least 6x faster than the ADC clock.
 	 */
 	clk = devm_clk_get(&pdev->dev, NULL);
@@ -231,7 +238,9 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 			else
 				tscadc->ctrl |= CNTRLREG_TSC_4WIRE;
 		}
-
+	} else {
+		tscadc->ctrl |= CNTRLREG_MAG_PREAMP_PWRDOWN |
+				CNTRLREG_MAG_PREAMP_BYPASS;
 	}
 
 	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl);
@@ -241,7 +250,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 	/* Enable the TSC module enable bit */
 	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl | CNTRLREG_SSENB);
 
-	/* TSC Cell */
+	/* TSC or MAG Cell */
 	if (tscmag_wires > 0) {
 		cell = &tscadc->cells[cell_idx++];
 		cell->name = tscadc->data->name_tscmag;
@@ -329,6 +338,7 @@ static SIMPLE_DEV_PM_OPS(tscadc_pm_ops, tscadc_suspend, tscadc_resume);
 
 static const struct ti_tscadc_data tscdata = {
 	.has_tsc = true,
+	.has_mag = false,
 	.name_tscmag = "TI-am335x-tsc",
 	.compat_tscmag = "ti,am3359-tsc",
 	.name_adc = "TI-am335x-adc",
@@ -336,8 +346,25 @@ static const struct ti_tscadc_data tscdata = {
 	.target_clk_rate = TSC_ADC_CLK,
 };
 
+static const struct ti_tscadc_data magdata = {
+	.has_tsc = false,
+	.has_mag = true,
+	.name_tscmag = "TI-am43xx-mag",
+	.compat_tscmag = "ti,am4372-mag",
+	.name_adc = "TI-am43xx-adc",
+	.compat_adc = "ti,am4372-adc",
+	.target_clk_rate = MAG_ADC_CLK,
+};
+
 static const struct of_device_id ti_tscadc_dt_ids[] = {
-	{ .compatible = "ti,am3359-tscadc", },
+	{
+		.compatible = "ti,am3359-tscadc",
+		.data = &tscdata,
+	},
+	{
+		.compatible = "ti,am4372-magadc",
+		.data = &magdata,
+	},
 	{ }
 };
 MODULE_DEVICE_TABLE(of, ti_tscadc_dt_ids);
@@ -355,6 +382,6 @@ static struct platform_driver ti_tscadc_driver = {
 
 module_platform_driver(ti_tscadc_driver);
 
-MODULE_DESCRIPTION("TI touchscreen / ADC MFD controller driver");
+MODULE_DESCRIPTION("TI touchscreen/magnetic reader/ADC MFD controller driver");
 MODULE_AUTHOR("Rachna Patil <rachna@ti.com>");
 MODULE_LICENSE("GPL");
diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h
index 082b2af94263..31b22ec567e7 100644
--- a/include/linux/mfd/ti_am335x_tscadc.h
+++ b/include/linux/mfd/ti_am335x_tscadc.h
@@ -129,6 +129,11 @@
 #define CNTRLREG_TSC_8WIRE	CNTRLREG_TSC_AFE_CTRL(3)
 #define CNTRLREG_TSC_ENB	BIT(7)
 
+/*Control registers bitfields  for MAGADC IP */
+#define CNTRLREG_MAGADCENB      BIT(0)
+#define CNTRLREG_MAG_PREAMP_PWRDOWN BIT(5)
+#define CNTRLREG_MAG_PREAMP_BYPASS  BIT(6)
+
 /* FIFO READ Register */
 #define FIFOREAD_DATA_MASK (0xfff << 0)
 #define FIFOREAD_CHNLID_MASK (0xf << 16)
@@ -141,7 +146,8 @@
 #define SEQ_STATUS BIT(5)
 #define CHARGE_STEP		0x11
 
-#define TSC_ADC_CLK		3000000
+#define TSC_ADC_CLK		3000000 /* 3 MHz */
+#define MAG_ADC_CLK		13000000 /* 13 MHz */
 #define TOTAL_STEPS		16
 #define TOTAL_CHANNELS		8
 #define FIFO1_THRESHOLD		19
@@ -164,6 +170,7 @@
 
 struct ti_tscadc_data {
 	bool has_tsc;
+	bool has_mag;
 	char *name_tscmag;
 	char *compat_tscmag;
 	char *name_adc;
-- 
2.27.0


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

* [PATCH 29/40] mfd: ti_am335x_tscadc: Support the correctly spelled DT property
  2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
                   ` (27 preceding siblings ...)
  2021-08-25 15:25 ` [PATCH 28/40] mfd: ti_am335x_tscadc: Add ADC1/magnetic reader support Miquel Raynal
@ 2021-08-25 15:25 ` Miquel Raynal
  2021-08-30 14:11   ` Jonathan Cameron
  2021-08-25 15:25 ` [PATCH 30/40] iio: adc: ti_am335x_adc: Replace license text with SPDX tag Miquel Raynal
                   ` (10 subsequent siblings)
  39 siblings, 1 reply; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:25 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal

There was in the past a typo in the coordinate readouts property. The
bindings have been updated, the touchscreen driver as well and now
supports both. However, the MFD driver that is in charge of verifying
the validity of the property only checks the bogus one. Add support for
the correctly spelled DT property.

Fixes: c9aeb249bf72 ("Input: ti_am335x_tsc - fix spelling mistake in TSC/ADC DT binding")
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mfd/ti_am335x_tscadc.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
index f4f6b9db4d2a..0bd260edc9ad 100644
--- a/drivers/mfd/ti_am335x_tscadc.c
+++ b/drivers/mfd/ti_am335x_tscadc.c
@@ -143,7 +143,13 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
 	if (tscadc->data->has_tsc) {
 		node = of_get_child_by_name(pdev->dev.of_node, "tsc");
 		of_property_read_u32(node, "ti,wires", &tscmag_wires);
-		of_property_read_u32(node, "ti,coordiante-readouts", &readouts);
+		err = of_property_read_u32(node, "ti,coordinate-readouts",
+					   &readouts);
+		if (err < 0) {
+			err = of_property_read_u32(node, "ti,coordiante-readouts",
+						   &readouts);
+		}
+
 		if (tscmag_wires)
 			use_tsc = true;
 	} else {
-- 
2.27.0


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

* [PATCH 30/40] iio: adc: ti_am335x_adc: Replace license text with SPDX tag
  2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
                   ` (28 preceding siblings ...)
  2021-08-25 15:25 ` [PATCH 29/40] mfd: ti_am335x_tscadc: Support the correctly spelled DT property Miquel Raynal
@ 2021-08-25 15:25 ` Miquel Raynal
  2021-08-30 14:12   ` Jonathan Cameron
  2021-08-25 15:25 ` [PATCH 31/40] iio: adc: ti_am335x_adc: Fix style Miquel Raynal
                   ` (9 subsequent siblings)
  39 siblings, 1 reply; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:25 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal

Drop the text license and replace it with an equivalent SPDX license tag
identifier.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/iio/adc/ti_am335x_adc.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
index f748d49f10f4..a5da1fedbc5c 100644
--- a/drivers/iio/adc/ti_am335x_adc.c
+++ b/drivers/iio/adc/ti_am335x_adc.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-only
 /*
  * TI ADC MFD driver
  *
  * Copyright (C) 2012 Texas Instruments Incorporated - https://www.ti.com/
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation version 2.
- *
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
- * kind, whether express or implied; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
  */
 
 #include <linux/kernel.h>
-- 
2.27.0


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

* [PATCH 31/40] iio: adc: ti_am335x_adc: Fix style
  2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
                   ` (29 preceding siblings ...)
  2021-08-25 15:25 ` [PATCH 30/40] iio: adc: ti_am335x_adc: Replace license text with SPDX tag Miquel Raynal
@ 2021-08-25 15:25 ` Miquel Raynal
  2021-08-30 14:16   ` Jonathan Cameron
  2021-08-25 15:25 ` [PATCH 32/40] iio: adc: ti_am335x_adc: Get rid of useless gotos Miquel Raynal
                   ` (8 subsequent siblings)
  39 siblings, 1 reply; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:25 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal

These warnings are reported by checkpatch.pl essentially.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/iio/adc/ti_am335x_adc.c | 104 ++++++++++++++++----------------
 1 file changed, 52 insertions(+), 52 deletions(-)

diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
index a5da1fedbc5c..dd2200d2f214 100644
--- a/drivers/iio/adc/ti_am335x_adc.c
+++ b/drivers/iio/adc/ti_am335x_adc.c
@@ -57,7 +57,7 @@ static unsigned int tiadc_readl(struct tiadc_device *adc, unsigned int reg)
 }
 
 static void tiadc_writel(struct tiadc_device *adc, unsigned int reg,
-					unsigned int val)
+			 unsigned int val)
 {
 	writel(val, adc->mfd_tscadc->tscadc_base + reg);
 }
@@ -72,7 +72,7 @@ static u32 get_adc_step_mask(struct tiadc_device *adc_dev)
 }
 
 static u32 get_adc_chan_step_mask(struct tiadc_device *adc_dev,
-		struct iio_chan_spec const *chan)
+				  struct iio_chan_spec const *chan)
 {
 	int i;
 
@@ -110,8 +110,6 @@ static void tiadc_step_config(struct iio_dev *indio_dev)
 	 * Channel would represent which analog input
 	 * needs to be given to ADC to digitalize data.
 	 */
-
-
 	for (i = 0; i < adc_dev->channels; i++) {
 		int chan;
 
@@ -124,9 +122,8 @@ static void tiadc_step_config(struct iio_dev *indio_dev)
 		}
 
 		if (adc_dev->step_avg[i])
-			stepconfig =
-			STEPCONFIG_AVG(ffs(adc_dev->step_avg[i]) - 1) |
-			STEPCONFIG_FIFO1;
+			stepconfig = STEPCONFIG_AVG(ffs(adc_dev->step_avg[i]) - 1) |
+				     STEPCONFIG_FIFO1;
 		else
 			stepconfig = STEPCONFIG_FIFO1;
 
@@ -134,10 +131,9 @@ static void tiadc_step_config(struct iio_dev *indio_dev)
 			stepconfig |= STEPCONFIG_MODE_SWCNT;
 
 		tiadc_writel(adc_dev, REG_STEPCONFIG(steps),
-				stepconfig | STEPCONFIG_INP(chan) |
-				STEPCONFIG_INM_ADCREFM |
-				STEPCONFIG_RFP_VREFP |
-				STEPCONFIG_RFM_VREFN);
+			     stepconfig | STEPCONFIG_INP(chan) |
+			     STEPCONFIG_INM_ADCREFM | STEPCONFIG_RFP_VREFP |
+			     STEPCONFIG_RFM_VREFN);
 
 		if (adc_dev->open_delay[i] > STEPDELAY_OPEN_MASK) {
 			dev_warn(dev, "chan %d open delay truncating to 0x3FFFF\n",
@@ -152,8 +148,8 @@ static void tiadc_step_config(struct iio_dev *indio_dev)
 		}
 
 		tiadc_writel(adc_dev, REG_STEPDELAY(steps),
-				STEPDELAY_OPEN(adc_dev->open_delay[i]) |
-				STEPDELAY_SAMPLE(adc_dev->sample_delay[i]));
+			     STEPDELAY_OPEN(adc_dev->open_delay[i]) |
+			     STEPDELAY_SAMPLE(adc_dev->sample_delay[i]));
 
 		adc_dev->channel_step[i] = steps;
 		steps++;
@@ -178,10 +174,12 @@ static irqreturn_t tiadc_irq_h(int irq, void *private)
 		config = tiadc_readl(adc_dev, REG_CTRL);
 		config &= ~(CNTRLREG_SSENB);
 		tiadc_writel(adc_dev, REG_CTRL, config);
-		tiadc_writel(adc_dev, REG_IRQSTATUS, IRQENB_FIFO1OVRRUN
-				| IRQENB_FIFO1UNDRFLW | IRQENB_FIFO1THRES);
+		tiadc_writel(adc_dev, REG_IRQSTATUS,
+			     IRQENB_FIFO1OVRRUN | IRQENB_FIFO1UNDRFLW |
+			     IRQENB_FIFO1THRES);
 
-		/* wait for idle state.
+		/*
+		 * Wait for the idle state.
 		 * ADC needs to finish the current conversion
 		 * before disabling the module
 		 */
@@ -209,11 +207,11 @@ static irqreturn_t tiadc_worker_h(int irq, void *private)
 
 	fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT);
 	for (k = 0; k < fifo1count; k = k + i) {
-		for (i = 0; i < (indio_dev->scan_bytes)/2; i++) {
+		for (i = 0; i < (indio_dev->scan_bytes / 2); i++) {
 			read = tiadc_readl(adc_dev, REG_FIFO1);
 			data[i] = read & FIFOREAD_DATA_MASK;
 		}
-		iio_push_to_buffers(indio_dev, (u8 *) data);
+		iio_push_to_buffers(indio_dev, (u8 *)data);
 	}
 
 	tiadc_writel(adc_dev, REG_IRQSTATUS, IRQENB_FIFO1THRES);
@@ -246,6 +244,7 @@ static int tiadc_start_dma(struct iio_dev *indio_dev)
 	struct dma_async_tx_descriptor *desc;
 
 	dma->current_period = 0; /* We start to fill period 0 */
+
 	/*
 	 * Make the fifo thresh as the multiple of total number of
 	 * channels enabled, so make sure that cyclic DMA period
@@ -255,9 +254,10 @@ static int tiadc_start_dma(struct iio_dev *indio_dev)
 	 */
 	dma->fifo_thresh = rounddown(FIFO1_THRESHOLD + 1,
 				     adc_dev->total_ch_enabled) - 1;
+
 	/* Make sure that period length is multiple of fifo thresh level */
 	dma->period_size = rounddown(DMA_BUFFER_SIZE / 2,
-				    (dma->fifo_thresh + 1) * sizeof(u16));
+				     (dma->fifo_thresh + 1) * sizeof(u16));
 
 	dma->conf.src_maxburst = dma->fifo_thresh + 1;
 	dmaengine_slave_config(dma->chan, &dma->conf);
@@ -288,9 +288,9 @@ static int tiadc_buffer_preenable(struct iio_dev *indio_dev)
 	struct tiadc_device *adc_dev = iio_priv(indio_dev);
 	int i, fifo1count;
 
-	tiadc_writel(adc_dev, REG_IRQCLR, (IRQENB_FIFO1THRES |
-				IRQENB_FIFO1OVRRUN |
-				IRQENB_FIFO1UNDRFLW));
+	tiadc_writel(adc_dev, REG_IRQCLR,
+		     IRQENB_FIFO1THRES | IRQENB_FIFO1OVRRUN |
+		     IRQENB_FIFO1UNDRFLW);
 
 	/* Flush FIFO. Needed in corner cases in simultaneous tsc/adc use */
 	fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT);
@@ -320,8 +320,9 @@ static int tiadc_buffer_postenable(struct iio_dev *indio_dev)
 
 	am335x_tsc_se_set_cache(adc_dev->mfd_tscadc, enb);
 
-	tiadc_writel(adc_dev,  REG_IRQSTATUS, IRQENB_FIFO1THRES
-				| IRQENB_FIFO1OVRRUN | IRQENB_FIFO1UNDRFLW);
+	tiadc_writel(adc_dev, REG_IRQSTATUS,
+		     IRQENB_FIFO1THRES | IRQENB_FIFO1OVRRUN |
+		     IRQENB_FIFO1UNDRFLW);
 
 	irq_enable = IRQENB_FIFO1OVRRUN;
 	if (!dma->chan)
@@ -337,8 +338,9 @@ static int tiadc_buffer_predisable(struct iio_dev *indio_dev)
 	struct tiadc_dma *dma = &adc_dev->dma;
 	int fifo1count, i;
 
-	tiadc_writel(adc_dev, REG_IRQCLR, (IRQENB_FIFO1THRES |
-				IRQENB_FIFO1OVRRUN | IRQENB_FIFO1UNDRFLW));
+	tiadc_writel(adc_dev, REG_IRQCLR,
+		     IRQENB_FIFO1THRES | IRQENB_FIFO1OVRRUN |
+		     IRQENB_FIFO1UNDRFLW);
 	am335x_tsc_se_clr(adc_dev->mfd_tscadc, adc_dev->buffer_en_ch_steps);
 	adc_dev->buffer_en_ch_steps = 0;
 	adc_dev->total_ch_enabled = 0;
@@ -370,12 +372,11 @@ static const struct iio_buffer_setup_ops tiadc_buffer_setup_ops = {
 };
 
 static int tiadc_iio_buffered_hardware_setup(struct device *dev,
-	struct iio_dev *indio_dev,
-	irqreturn_t (*pollfunc_bh)(int irq, void *p),
-	irqreturn_t (*pollfunc_th)(int irq, void *p),
-	int irq,
-	unsigned long flags,
-	const struct iio_buffer_setup_ops *setup_ops)
+					     struct iio_dev *indio_dev,
+					     irqreturn_t (*pollfunc_bh)(int irq, void *p),
+					     irqreturn_t (*pollfunc_th)(int irq, void *p),
+					     int irq, unsigned long flags,
+					     const struct iio_buffer_setup_ops *setup_ops)
 {
 	int ret;
 
@@ -386,7 +387,7 @@ static int tiadc_iio_buffered_hardware_setup(struct device *dev,
 		return ret;
 
 	return devm_request_threaded_irq(dev, irq, pollfunc_th, pollfunc_bh,
-				flags, indio_dev->name, indio_dev);
+					 flags, indio_dev->name, indio_dev);
 }
 
 static const char * const chan_name_ain[] = {
@@ -411,12 +412,11 @@ static int tiadc_channel_init(struct device *dev, struct iio_dev *indio_dev,
 	indio_dev->num_channels = channels;
 	chan_array = devm_kcalloc(dev, channels, sizeof(*chan_array),
 				  GFP_KERNEL);
-	if (chan_array == NULL)
+	if (!chan_array)
 		return -ENOMEM;
 
 	chan = chan_array;
 	for (i = 0; i < channels; i++, chan++) {
-
 		chan->type = IIO_VOLTAGE;
 		chan->indexed = 1;
 		chan->channel = adc_dev->channel_line[i];
@@ -434,8 +434,8 @@ static int tiadc_channel_init(struct device *dev, struct iio_dev *indio_dev,
 }
 
 static int tiadc_read_raw(struct iio_dev *indio_dev,
-		struct iio_chan_spec const *chan,
-		int *val, int *val2, long mask)
+			  struct iio_chan_spec const *chan, int *val, int *val2,
+			  long mask)
 {
 	struct tiadc_device *adc_dev = iio_priv(indio_dev);
 	int ret = IIO_VAL_INT;
@@ -459,9 +459,8 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
 
 	am335x_tsc_se_set_once(adc_dev->mfd_tscadc, step_en);
 
-	timeout = jiffies + msecs_to_jiffies
-				(IDLE_TIMEOUT * adc_dev->channels);
 	/* Wait for Fifo threshold interrupt */
+	timeout = jiffies + msecs_to_jiffies(IDLE_TIMEOUT * adc_dev->channels);
 	while (1) {
 		fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT);
 		if (fifo1count)
@@ -473,6 +472,7 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
 			goto err_unlock;
 		}
 	}
+
 	map_val = adc_dev->channel_step[chan->scan_index];
 
 	/*
@@ -490,13 +490,14 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
 		if (stepid == map_val) {
 			read = read & FIFOREAD_DATA_MASK;
 			found = true;
-			*val = (u16) read;
+			*val = (u16)read;
 		}
 	}
+
 	am335x_tsc_se_adc_done(adc_dev->mfd_tscadc);
 
 	if (!found)
-		ret =  -EBUSY;
+		ret = -EBUSY;
 
 err_unlock:
 	mutex_unlock(&adc_dev->fifo1_lock);
@@ -537,6 +538,7 @@ static int tiadc_request_dma(struct platform_device *pdev,
 		goto err;
 
 	return 0;
+
 err:
 	dma_release_channel(dma->chan);
 	return -ENOMEM;
@@ -586,7 +588,7 @@ static int tiadc_probe(struct platform_device *pdev)
 	}
 
 	indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*adc_dev));
-	if (indio_dev == NULL) {
+	if (!indio_dev) {
 		dev_err(&pdev->dev, "failed to allocate iio device\n");
 		return -ENOMEM;
 	}
@@ -608,12 +610,11 @@ static int tiadc_probe(struct platform_device *pdev)
 		return err;
 
 	err = tiadc_iio_buffered_hardware_setup(&pdev->dev, indio_dev,
-		&tiadc_worker_h,
-		&tiadc_irq_h,
-		adc_dev->mfd_tscadc->irq,
-		IRQF_SHARED,
-		&tiadc_buffer_setup_ops);
-
+						&tiadc_worker_h,
+						&tiadc_irq_h,
+						adc_dev->mfd_tscadc->irq,
+						IRQF_SHARED,
+						&tiadc_buffer_setup_ops);
 	if (err)
 		goto err_free_channels;
 
@@ -664,8 +665,7 @@ static int __maybe_unused tiadc_suspend(struct device *dev)
 
 	idle = tiadc_readl(adc_dev, REG_CTRL);
 	idle &= ~(CNTRLREG_SSENB);
-	tiadc_writel(adc_dev, REG_CTRL, (idle |
-			CNTRLREG_POWERDOWN));
+	tiadc_writel(adc_dev, REG_CTRL, idle | CNTRLREG_POWERDOWN);
 
 	return 0;
 }
@@ -678,12 +678,12 @@ static int __maybe_unused tiadc_resume(struct device *dev)
 
 	/* Make sure ADC is powered up */
 	restore = tiadc_readl(adc_dev, REG_CTRL);
-	restore &= ~(CNTRLREG_POWERDOWN);
+	restore &= ~CNTRLREG_POWERDOWN;
 	tiadc_writel(adc_dev, REG_CTRL, restore);
 
 	tiadc_step_config(indio_dev);
 	am335x_tsc_se_set_cache(adc_dev->mfd_tscadc,
-			adc_dev->buffer_en_ch_steps);
+				adc_dev->buffer_en_ch_steps);
 	return 0;
 }
 
-- 
2.27.0


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

* [PATCH 32/40] iio: adc: ti_am335x_adc: Get rid of useless gotos
  2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
                   ` (30 preceding siblings ...)
  2021-08-25 15:25 ` [PATCH 31/40] iio: adc: ti_am335x_adc: Fix style Miquel Raynal
@ 2021-08-25 15:25 ` Miquel Raynal
  2021-08-30 14:18   ` Jonathan Cameron
  2021-08-25 15:25 ` [PATCH 33/40] iio: adc: ti_am335x_adc: Gather the checks on the delays Miquel Raynal
                   ` (7 subsequent siblings)
  39 siblings, 1 reply; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:25 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal

Gotos jumping to a return statement are not really useful, drop them.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/iio/adc/ti_am335x_adc.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
index dd2200d2f214..00bbf557e86c 100644
--- a/drivers/iio/adc/ti_am335x_adc.c
+++ b/drivers/iio/adc/ti_am335x_adc.c
@@ -616,11 +616,11 @@ static int tiadc_probe(struct platform_device *pdev)
 						IRQF_SHARED,
 						&tiadc_buffer_setup_ops);
 	if (err)
-		goto err_free_channels;
+		return err;
 
 	err = iio_device_register(indio_dev);
 	if (err)
-		goto err_buffer_unregister;
+		return err;
 
 	platform_set_drvdata(pdev, indio_dev);
 
@@ -632,8 +632,7 @@ static int tiadc_probe(struct platform_device *pdev)
 
 err_dma:
 	iio_device_unregister(indio_dev);
-err_buffer_unregister:
-err_free_channels:
+
 	return err;
 }
 
-- 
2.27.0


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

* [PATCH 33/40] iio: adc: ti_am335x_adc: Gather the checks on the delays
  2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
                   ` (31 preceding siblings ...)
  2021-08-25 15:25 ` [PATCH 32/40] iio: adc: ti_am335x_adc: Get rid of useless gotos Miquel Raynal
@ 2021-08-25 15:25 ` Miquel Raynal
  2021-08-30 14:19   ` Jonathan Cameron
  2021-08-25 15:25 ` [PATCH 34/40] iio: adc: ti_am335x_adc: Add a unit to the timeout delay Miquel Raynal
                   ` (6 subsequent siblings)
  39 siblings, 1 reply; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:25 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal

Move the checks over the delays provided in the device tree to the
location where these values are read to clarify where they come from.

There are no functional changes besides the device structure used to
display the warnings: let's use the ADC instead of the MFD device.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/iio/adc/ti_am335x_adc.c | 47 +++++++++++++++++++--------------
 1 file changed, 27 insertions(+), 20 deletions(-)

diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
index 00bbf557e86c..4eaf5b031707 100644
--- a/drivers/iio/adc/ti_am335x_adc.c
+++ b/drivers/iio/adc/ti_am335x_adc.c
@@ -97,7 +97,6 @@ static u32 get_adc_step_bit(struct tiadc_device *adc_dev, int chan)
 static void tiadc_step_config(struct iio_dev *indio_dev)
 {
 	struct tiadc_device *adc_dev = iio_priv(indio_dev);
-	struct device *dev = adc_dev->mfd_tscadc->dev;
 	unsigned int stepconfig;
 	int i, steps = 0;
 
@@ -115,12 +114,6 @@ static void tiadc_step_config(struct iio_dev *indio_dev)
 
 		chan = adc_dev->channel_line[i];
 
-		if (adc_dev->step_avg[i] > STEPCONFIG_AVG_16) {
-			dev_warn(dev, "chan %d step_avg truncating to %d\n",
-				 chan, STEPCONFIG_AVG_16);
-			adc_dev->step_avg[i] = STEPCONFIG_AVG_16;
-		}
-
 		if (adc_dev->step_avg[i])
 			stepconfig = STEPCONFIG_AVG(ffs(adc_dev->step_avg[i]) - 1) |
 				     STEPCONFIG_FIFO1;
@@ -135,18 +128,6 @@ static void tiadc_step_config(struct iio_dev *indio_dev)
 			     STEPCONFIG_INM_ADCREFM | STEPCONFIG_RFP_VREFP |
 			     STEPCONFIG_RFM_VREFN);
 
-		if (adc_dev->open_delay[i] > STEPDELAY_OPEN_MASK) {
-			dev_warn(dev, "chan %d open delay truncating to 0x3FFFF\n",
-				 chan);
-			adc_dev->open_delay[i] = STEPDELAY_OPEN_MASK;
-		}
-
-		if (adc_dev->sample_delay[i] > 0xFF) {
-			dev_warn(dev, "chan %d sample delay truncating to 0xFF\n",
-				 chan);
-			adc_dev->sample_delay[i] = 0xFF;
-		}
-
 		tiadc_writel(adc_dev, REG_STEPDELAY(steps),
 			     STEPDELAY_OPEN(adc_dev->open_delay[i]) |
 			     STEPDELAY_SAMPLE(adc_dev->sample_delay[i]));
@@ -552,6 +533,7 @@ static int tiadc_parse_dt(struct platform_device *pdev,
 	const __be32 *cur;
 	int channels = 0;
 	u32 val;
+	int i;
 
 	of_property_for_each_u32(node, "ti,adc-channels", prop, cur, val) {
 		adc_dev->channel_line[channels] = val;
@@ -564,6 +546,8 @@ static int tiadc_parse_dt(struct platform_device *pdev,
 		channels++;
 	}
 
+	adc_dev->channels = channels;
+
 	of_property_read_u32_array(node, "ti,chan-step-avg",
 				   adc_dev->step_avg, channels);
 	of_property_read_u32_array(node, "ti,chan-step-opendelay",
@@ -571,7 +555,30 @@ static int tiadc_parse_dt(struct platform_device *pdev,
 	of_property_read_u32_array(node, "ti,chan-step-sampledelay",
 				   adc_dev->sample_delay, channels);
 
-	adc_dev->channels = channels;
+	for (i = 0; i < adc_dev->channels; i++) {
+		int chan;
+
+		chan = adc_dev->channel_line[i];
+
+		if (adc_dev->step_avg[i] > STEPCONFIG_AVG_16) {
+			dev_warn(&pdev->dev, "chan %d step_avg truncating to %d\n",
+				 chan, STEPCONFIG_AVG_16);
+			adc_dev->step_avg[i] = STEPCONFIG_AVG_16;
+		}
+
+		if (adc_dev->open_delay[i] > STEPDELAY_OPEN_MASK) {
+			dev_warn(&pdev->dev, "chan %d open delay truncating to 0x3FFFF\n",
+				 chan);
+			adc_dev->open_delay[i] = STEPDELAY_OPEN_MASK;
+		}
+
+		if (adc_dev->sample_delay[i] > 0xFF) {
+			dev_warn(&pdev->dev, "chan %d sample delay truncating to 0xFF\n",
+				 chan);
+			adc_dev->sample_delay[i] = 0xFF;
+		}
+	}
+
 	return 0;
 }
 
-- 
2.27.0


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

* [PATCH 34/40] iio: adc: ti_am335x_adc: Add a unit to the timeout delay
  2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
                   ` (32 preceding siblings ...)
  2021-08-25 15:25 ` [PATCH 33/40] iio: adc: ti_am335x_adc: Gather the checks on the delays Miquel Raynal
@ 2021-08-25 15:25 ` Miquel Raynal
  2021-08-30 14:20   ` Jonathan Cameron
  2021-08-25 15:25 ` [PATCH 35/40] iio: adc: ti_am335x_adc: Wait the idle state to avoid stalls Miquel Raynal
                   ` (5 subsequent siblings)
  39 siblings, 1 reply; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:25 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal

The lack of unit in the macro name kind of tricked me when I was
troubleshooting an issue. Physical constants should always get a unit.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/iio/adc/ti_am335x_adc.c      | 2 +-
 include/linux/mfd/ti_am335x_tscadc.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
index 4eaf5b031707..ebf6326af60d 100644
--- a/drivers/iio/adc/ti_am335x_adc.c
+++ b/drivers/iio/adc/ti_am335x_adc.c
@@ -441,7 +441,7 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
 	am335x_tsc_se_set_once(adc_dev->mfd_tscadc, step_en);
 
 	/* Wait for Fifo threshold interrupt */
-	timeout = jiffies + msecs_to_jiffies(IDLE_TIMEOUT * adc_dev->channels);
+	timeout = jiffies + msecs_to_jiffies(IDLE_TIMEOUT_MS * adc_dev->channels);
 	while (1) {
 		fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT);
 		if (fifo1count)
diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h
index 31b22ec567e7..177ab2499200 100644
--- a/include/linux/mfd/ti_am335x_tscadc.h
+++ b/include/linux/mfd/ti_am335x_tscadc.h
@@ -164,7 +164,7 @@
  *
  * max processing time: 266431 * 308ns = 83ms(approx)
  */
-#define IDLE_TIMEOUT 83 /* milliseconds */
+#define IDLE_TIMEOUT_MS 83 /* milliseconds */
 
 #define TSCADC_CELLS		2
 
-- 
2.27.0


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

* [PATCH 35/40] iio: adc: ti_am335x_adc: Wait the idle state to avoid stalls
  2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
                   ` (33 preceding siblings ...)
  2021-08-25 15:25 ` [PATCH 34/40] iio: adc: ti_am335x_adc: Add a unit to the timeout delay Miquel Raynal
@ 2021-08-25 15:25 ` Miquel Raynal
  2021-08-30 14:22   ` Jonathan Cameron
  2021-08-25 15:25 ` [PATCH 36/40] iio: adc: ti_am335x_adc: Add the scale information Miquel Raynal
                   ` (4 subsequent siblings)
  39 siblings, 1 reply; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:25 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal

A simple:
$ cat /sys/bus/iio/devices/iio\:deviceX/in_voltage*_raw
can stall forever. It seems that it comes from the fact that the
internal state machine does not have enough time to return to its idle
state in this situation before receiving another request, leading to an
internal stall.

Add a tiadc_wait_idle() helper to ensure no new conversion is requested
while the FSM is still busy.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/iio/adc/ti_am335x_adc.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
index ebf6326af60d..d4619fd6fd54 100644
--- a/drivers/iio/adc/ti_am335x_adc.c
+++ b/drivers/iio/adc/ti_am335x_adc.c
@@ -17,6 +17,7 @@
 #include <linux/of_device.h>
 #include <linux/iio/machine.h>
 #include <linux/iio/driver.h>
+#include <linux/iopoll.h>
 
 #include <linux/mfd/ti_am335x_tscadc.h>
 #include <linux/iio/buffer.h>
@@ -94,6 +95,15 @@ static u32 get_adc_step_bit(struct tiadc_device *adc_dev, int chan)
 	return 1 << adc_dev->channel_step[chan];
 }
 
+static int tiadc_wait_idle(struct tiadc_device *adc_dev)
+{
+	u32 val;
+
+	return readl_poll_timeout(adc_dev->mfd_tscadc->tscadc_base + REG_ADCFSM,
+				  val, !(val & SEQ_STATUS), 10,
+				  IDLE_TIMEOUT_MS * 1000 * adc_dev->channels);
+}
+
 static void tiadc_step_config(struct iio_dev *indio_dev)
 {
 	struct tiadc_device *adc_dev = iio_priv(indio_dev);
@@ -268,6 +278,11 @@ static int tiadc_buffer_preenable(struct iio_dev *indio_dev)
 {
 	struct tiadc_device *adc_dev = iio_priv(indio_dev);
 	int i, fifo1count;
+	int ret;
+
+	ret = tiadc_wait_idle(adc_dev);
+	if (ret)
+		return ret;
 
 	tiadc_writel(adc_dev, REG_IRQCLR,
 		     IRQENB_FIFO1THRES | IRQENB_FIFO1OVRRUN |
@@ -419,12 +434,12 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
 			  long mask)
 {
 	struct tiadc_device *adc_dev = iio_priv(indio_dev);
-	int ret = IIO_VAL_INT;
 	int i, map_val;
 	unsigned int fifo1count, read, stepid;
 	bool found = false;
 	u32 step_en;
 	unsigned long timeout;
+	int ret;
 
 	if (iio_buffer_enabled(indio_dev))
 		return -EBUSY;
@@ -434,6 +449,11 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
 		return -EINVAL;
 
 	mutex_lock(&adc_dev->fifo1_lock);
+
+	ret = tiadc_wait_idle(adc_dev);
+	if (ret)
+		goto err_unlock;
+
 	fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT);
 	while (fifo1count--)
 		tiadc_readl(adc_dev, REG_FIFO1);
@@ -482,7 +502,7 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
 
 err_unlock:
 	mutex_unlock(&adc_dev->fifo1_lock);
-	return ret;
+	return ret ? ret : IIO_VAL_INT;
 }
 
 static const struct iio_info tiadc_info = {
-- 
2.27.0


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

* [PATCH 36/40] iio: adc: ti_am335x_adc: Add the scale information
  2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
                   ` (34 preceding siblings ...)
  2021-08-25 15:25 ` [PATCH 35/40] iio: adc: ti_am335x_adc: Wait the idle state to avoid stalls Miquel Raynal
@ 2021-08-25 15:25 ` Miquel Raynal
  2021-08-30 14:23   ` Jonathan Cameron
  2021-08-25 15:25 ` [PATCH 37/40] iio: adc: ti_am335x_adc: Add the am437x compatible Miquel Raynal
                   ` (3 subsequent siblings)
  39 siblings, 1 reply; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:25 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal

Without the scale, the values returned to the user are just a picture of
the input voltage against the full scale range of the ADC. We need to
provide the actual conversion factor to get milli-Volts values.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/iio/adc/ti_am335x_adc.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
index d4619fd6fd54..f644898b47dd 100644
--- a/drivers/iio/adc/ti_am335x_adc.c
+++ b/drivers/iio/adc/ti_am335x_adc.c
@@ -417,6 +417,7 @@ static int tiadc_channel_init(struct device *dev, struct iio_dev *indio_dev,
 		chan->indexed = 1;
 		chan->channel = adc_dev->channel_line[i];
 		chan->info_mask_separate = BIT(IIO_CHAN_INFO_RAW);
+		chan->info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE);
 		chan->datasheet_name = chan_name_ain[chan->channel];
 		chan->scan_index = i;
 		chan->scan_type.sign = 'u';
@@ -441,6 +442,23 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
 	unsigned long timeout;
 	int ret;
 
+	switch (mask) {
+	case IIO_CHAN_INFO_RAW:
+		break;
+	case IIO_CHAN_INFO_SCALE:
+		switch (chan->type) {
+		case IIO_VOLTAGE:
+			*val = 1800;
+			*val2 = chan->scan_type.realbits;
+			return IIO_VAL_FRACTIONAL_LOG2;
+		default:
+			return -EINVAL;
+		}
+		break;
+	default:
+		return -EINVAL;
+	}
+
 	if (iio_buffer_enabled(indio_dev))
 		return -EBUSY;
 
-- 
2.27.0


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

* [PATCH 37/40] iio: adc: ti_am335x_adc: Add the am437x compatible
  2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
                   ` (35 preceding siblings ...)
  2021-08-25 15:25 ` [PATCH 36/40] iio: adc: ti_am335x_adc: Add the scale information Miquel Raynal
@ 2021-08-25 15:25 ` Miquel Raynal
  2021-08-30 14:24   ` Jonathan Cameron
  2021-08-25 15:25 ` [PATCH 38/40] ARM: dts: am437x-cm-t43: Use a correctly spelled DT property Miquel Raynal
                   ` (2 subsequent siblings)
  39 siblings, 1 reply; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:25 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal

This driver supports both the legacy controller (am33xx) and the
extended one (am437x), so let's add a new compatible.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/iio/adc/ti_am335x_adc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
index f644898b47dd..ad79236e2bce 100644
--- a/drivers/iio/adc/ti_am335x_adc.c
+++ b/drivers/iio/adc/ti_am335x_adc.c
@@ -735,6 +735,7 @@ static SIMPLE_DEV_PM_OPS(tiadc_pm_ops, tiadc_suspend, tiadc_resume);
 
 static const struct of_device_id ti_adc_dt_ids[] = {
 	{ .compatible = "ti,am3359-adc", },
+	{ .compatible = "ti,am4372-adc", },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, ti_adc_dt_ids);
-- 
2.27.0


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

* [PATCH 38/40] ARM: dts: am437x-cm-t43: Use a correctly spelled DT property
  2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
                   ` (36 preceding siblings ...)
  2021-08-25 15:25 ` [PATCH 37/40] iio: adc: ti_am335x_adc: Add the am437x compatible Miquel Raynal
@ 2021-08-25 15:25 ` Miquel Raynal
  2021-08-25 15:25 ` [PATCH 39/40] ARM: dts: am43xx: Describe the magnetic reader/ADC1 hardware module Miquel Raynal
  2021-08-25 15:25 ` [PATCH 40/40] ARM: dts: am437x-gp-evm: enable ADC1 Miquel Raynal
  39 siblings, 0 replies; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:25 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal

Back in 2014 a property got mispelled "ti,coordiante-readouts" instead
of "ti,coordinate-readouts".

The year after it got fixed but both are still supported, although this
is not a reason to continue using this old deprecated property.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 arch/arm/boot/dts/am437x-cm-t43.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/am437x-cm-t43.dts b/arch/arm/boot/dts/am437x-cm-t43.dts
index a83f46ed0c9a..c06cf9373812 100644
--- a/arch/arm/boot/dts/am437x-cm-t43.dts
+++ b/arch/arm/boot/dts/am437x-cm-t43.dts
@@ -399,7 +399,7 @@ &tscadc {
 	tsc {
 		ti,wires = <4>;
 		ti,x-plate-resistance = <200>;
-		ti,coordiante-readouts = <5>;
+		ti,coordinate-readouts = <5>;
 		ti,wire-config = <0x00 0x11 0x22 0x33>;
 	};
 
-- 
2.27.0


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

* [PATCH 39/40] ARM: dts: am43xx: Describe the magnetic reader/ADC1 hardware module
  2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
                   ` (37 preceding siblings ...)
  2021-08-25 15:25 ` [PATCH 38/40] ARM: dts: am437x-cm-t43: Use a correctly spelled DT property Miquel Raynal
@ 2021-08-25 15:25 ` Miquel Raynal
  2021-08-25 15:25 ` [PATCH 40/40] ARM: dts: am437x-gp-evm: enable ADC1 Miquel Raynal
  39 siblings, 0 replies; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:25 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal

This hardware module is close to the am33xx ADC module but instead of
featuring a touchscreen it has a magnetic reader capability.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 arch/arm/boot/dts/am437x-l4.dtsi     | 31 ++++++++++++++++++++++++++--
 arch/arm/boot/dts/am43xx-clocks.dtsi |  7 +++++++
 2 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/am437x-l4.dtsi b/arch/arm/boot/dts/am437x-l4.dtsi
index 40ef3973f2a9..cc01b4e83955 100644
--- a/arch/arm/boot/dts/am437x-l4.dtsi
+++ b/arch/arm/boot/dts/am437x-l4.dtsi
@@ -2378,11 +2378,38 @@ hdq: hdq@0 {
 		};
 
 		target-module@4c000 {			/* 0x4834c000, ap 114 72.0 */
-			compatible = "ti,sysc";
-			status = "disabled";
+			compatible = "ti,sysc-omap4", "ti,sysc";
+			reg = <0x4c000 0x4>,
+			      <0x4c010 0x4>;
+			reg-names = "rev", "sysc";
+			ti,sysc-sidle = <SYSC_IDLE_FORCE>,
+					<SYSC_IDLE_NO>,
+					<SYSC_IDLE_SMART>;
+			clocks = <&l3s_clkctrl AM4_L3S_ADC1_CLKCTRL 0>;
+			clock-names = "fck";
 			#address-cells = <1>;
 			#size-cells = <1>;
 			ranges = <0x0 0x4c000 0x2000>;
+
+			magadc: magadc@0 {
+				compatible = "ti,am4372-magadc";
+				reg = <0x0 0x2000>;
+				interrupts = <GIC_SPI 115 IRQ_TYPE_LEVEL_HIGH>;
+				clocks = <&adc_mag_fck>;
+				clock-names = "fck";
+				dmas = <&edma 54 0>, <&edma 55 0>;;
+				dma-names = "fifo0", "fifo1";
+				status = "disabled";
+
+				mag {
+					compatible = "ti,am4372-mag";
+				};
+
+				adc {
+					#io-channel-cells = <1>;
+					compatible ="ti,am4372-adc";
+				};
+			};
 		};
 
 		target-module@80000 {			/* 0x48380000, ap 123 42.0 */
diff --git a/arch/arm/boot/dts/am43xx-clocks.dtsi b/arch/arm/boot/dts/am43xx-clocks.dtsi
index 314fc5975acb..66e892fa3398 100644
--- a/arch/arm/boot/dts/am43xx-clocks.dtsi
+++ b/arch/arm/boot/dts/am43xx-clocks.dtsi
@@ -444,6 +444,13 @@ wdt1_fck: wdt1_fck@422c {
 		reg = <0x422c>;
 	};
 
+	adc_mag_fck: adc_mag_fck@424c {
+		#clock-cells = <0>;
+		compatible = "ti,mux-clock";
+		clocks = <&sys_clkin_ck>, <&dpll_per_m2_ck>;
+		reg = <0x424c>;
+	};
+
 	l3_gclk: l3_gclk {
 		#clock-cells = <0>;
 		compatible = "fixed-factor-clock";
-- 
2.27.0


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

* [PATCH 40/40] ARM: dts: am437x-gp-evm: enable ADC1
  2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
                   ` (38 preceding siblings ...)
  2021-08-25 15:25 ` [PATCH 39/40] ARM: dts: am43xx: Describe the magnetic reader/ADC1 hardware module Miquel Raynal
@ 2021-08-25 15:25 ` Miquel Raynal
  39 siblings, 0 replies; 88+ messages in thread
From: Miquel Raynal @ 2021-08-25 15:25 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Miquel Raynal

ADC0 and ADC1 pins are available on external connector J22.

Enable ADC1 which was missing.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 arch/arm/boot/dts/am437x-gp-evm.dts | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/boot/dts/am437x-gp-evm.dts b/arch/arm/boot/dts/am437x-gp-evm.dts
index a383d5c035f9..a611d3899209 100644
--- a/arch/arm/boot/dts/am437x-gp-evm.dts
+++ b/arch/arm/boot/dts/am437x-gp-evm.dts
@@ -775,6 +775,14 @@ adc {
 	};
 };
 
+&magadc {
+	status = "okay";
+
+	adc {
+		ti,adc-channels = <0 1 2 3 4 5 6 7>;
+	};
+};
+
 &ecap0 {
 	status = "disabled";
 	pinctrl-names = "default";
-- 
2.27.0


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

* Re: [PATCH 04/40] dt-bindings: iio: adc: ti,am3359-adc: New yaml description
  2021-08-25 15:24 ` [PATCH 04/40] dt-bindings: iio: adc: ti,am3359-adc: " Miquel Raynal
@ 2021-08-30 12:31   ` Jonathan Cameron
  0 siblings, 0 replies; 88+ messages in thread
From: Jonathan Cameron @ 2021-08-30 12:31 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk

On Wed, 25 Aug 2021 17:24:42 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> This ADC was already described in a text file also containing an MFD
> description an a touchscreen description:
> Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt
> Let's add a proper description for this hardware.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>

Hi Miquel,

We'd do this different today, but this seems to be an accurate conversion
of what we have.  I'll assume this series may well go via mfd, so

Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> ---
>  .../bindings/iio/adc/ti,am3359-adc.yaml       | 81 +++++++++++++++++++
>  1 file changed, 81 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/iio/adc/ti,am3359-adc.yaml
> 
> diff --git a/Documentation/devicetree/bindings/iio/adc/ti,am3359-adc.yaml b/Documentation/devicetree/bindings/iio/adc/ti,am3359-adc.yaml
> new file mode 100644
> index 000000000000..85d9d642dc67
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/iio/adc/ti,am3359-adc.yaml
> @@ -0,0 +1,81 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/iio/adc/ti,am3359-adc.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: TI AM3359 ADC
> +
> +maintainers:
> +  - Miquel Raynal <miquel.raynal@bootlin.com>
> +
> +properties:
> +  compatible:
> +    const: ti,am3359-adc
> +
> +  '#io-channel-cells':
> +    const: 1
> +
> +  ti,adc-channels:
> +    description: List of analog inputs available for ADC. AIN0 = 0, AIN1 = 1 and
> +      so on untill AIN7 = 7.
> +    $ref: /schemas/types.yaml#/definitions/uint32-array
> +    minItems: 1
> +    maxItems: 8
> +
> +  ti,chan-step-opendelay:
> +    description: List of open delays for each channel of ADC in the order of
> +      ti,adc-channels. The value corresponds to the number of ADC clock cycles
> +      to wait after applying the step configuration registers and before sending
> +      the start of ADC conversion. Maximum value is 0x3FFFF.
> +    $ref: /schemas/types.yaml#/definitions/uint32-array
> +    minItems: 1
> +    maxItems: 8
> +
> +  ti,chan-step-sampledelay:
> +    description: List of sample delays for each channel of ADC in the order of
> +      ti,adc-channels. The value corresponds to the number of ADC clock cycles
> +      to sample (to hold start of conversion high). Maximum value is 0xFF.
> +    $ref: /schemas/types.yaml#/definitions/uint32-array
> +    minItems: 1
> +    maxItems: 8
> +
> +  ti,chan-step-avg:
> +    description: Number of averages to be performed for each channel of ADC. If
> +      average is 16 (this is also the maximum) then input is sampled 16 times
> +      and averaged to get more accurate value. This increases the time taken by
> +      ADC to generate a sample. Maximum value is 16.
> +    $ref: /schemas/types.yaml#/definitions/uint32-array
> +    minItems: 1
> +    maxItems: 8
> +
> +required:
> +  - compatible
> +  - '#io-channel-cells'
> +  - ti,adc-channels
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +    #include <dt-bindings/interrupt-controller/arm-gic.h>
> +
> +    tscadc: tscadc@0 {
> +        compatible = "ti,am3359-tscadc";
> +        reg = <0x0 0x1000>;
> +        interrupts = <GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>;
> +        clocks = <&adc_tsc_fck>;
> +        clock-names = "fck";
> +        status = "disabled";
> +        dmas = <&edma 53 0>, <&edma 57 0>;
> +        dma-names = "fifo0", "fifo1";
> +
> +        adc {
> +            compatible = "ti,am3359-adc";
> +            #io-channel-cells = <1>;
> +            ti,adc-channels = <4 5 6 7>;
> +            ti,chan-step-opendelay = <0x098 0x3ffff 0x098 0x0>;
> +            ti,chan-step-sampledelay = <0xff 0x0 0xf 0x0>;
> +            ti,chan-step-avg = <16 2 4 8>;
> +        };
> +    };


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

* Re: [PATCH 06/40] dt-bindings: mfd: ti,am3359-tscadc: Describe am4372 MFD compatible
  2021-08-25 15:24 ` [PATCH 06/40] dt-bindings: mfd: ti,am3359-tscadc: Describe am4372 MFD compatible Miquel Raynal
@ 2021-08-30 12:34   ` Jonathan Cameron
  0 siblings, 0 replies; 88+ messages in thread
From: Jonathan Cameron @ 2021-08-30 12:34 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk

On Wed, 25 Aug 2021 17:24:44 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> A more recent version of the am3359 ADC/Touchscreen controller is
> available on certain SoCs of the am437x family. This IP has evolved a
> little bit and deserves its own compatible.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> ---
>  .../devicetree/bindings/mfd/ti,am3359-tscadc.yaml          | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/mfd/ti,am3359-tscadc.yaml b/Documentation/devicetree/bindings/mfd/ti,am3359-tscadc.yaml
> index 96b329508d8a..2240299dcf2f 100644
> --- a/Documentation/devicetree/bindings/mfd/ti,am3359-tscadc.yaml
> +++ b/Documentation/devicetree/bindings/mfd/ti,am3359-tscadc.yaml
> @@ -11,7 +11,9 @@ maintainers:
>  
>  properties:
>    compatible:
> -    const: ti,am3359-tscadc
> +    oneOf:
> +      - const: ti,am3359-tscadc
> +      - const: ti,am4372-magadc
       enum:
         - ti,am3359-tscadc
         - ti,am4372-magadc

is a little bit cleaner and means the same thing.
>  
>    reg:
>      maxItems: 1
> @@ -42,6 +44,9 @@ patternProperties:
>    "^tsc$":
>      description: Touchscreen controller
>  
> +  "^mag$":
> +    description: Magnetic reader
> +
>  required:
>    - compatible
>    - reg


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

* Re: [PATCH 07/40] dt-bindings: iio: adc: ti,am3359-adc: Describe am4372 ADC compatible
  2021-08-25 15:24 ` [PATCH 07/40] dt-bindings: iio: adc: ti,am3359-adc: Describe am4372 ADC compatible Miquel Raynal
@ 2021-08-30 12:35   ` Jonathan Cameron
  0 siblings, 0 replies; 88+ messages in thread
From: Jonathan Cameron @ 2021-08-30 12:35 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk

On Wed, 25 Aug 2021 17:24:45 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> A more recent version of the am3359 ADC is available on certain SoCs of
> the am437x family. This IP has evolved a little bit and deserves its own
> compatible.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> ---
>  Documentation/devicetree/bindings/iio/adc/ti,am3359-adc.yaml | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/iio/adc/ti,am3359-adc.yaml b/Documentation/devicetree/bindings/iio/adc/ti,am3359-adc.yaml
> index 85d9d642dc67..34743371ee18 100644
> --- a/Documentation/devicetree/bindings/iio/adc/ti,am3359-adc.yaml
> +++ b/Documentation/devicetree/bindings/iio/adc/ti,am3359-adc.yaml
> @@ -11,7 +11,9 @@ maintainers:
>  
>  properties:
>    compatible:
> -    const: ti,am3359-adc
> +    oneOf:
> +      - const: ti,am3359-adc
> +      - const: ti,am4372-adc

enum

With that change
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

>  
>    '#io-channel-cells':
>      const: 1


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

* Re: [PATCH 08/40] mfd: ti_am335x_tscadc: Replace license text with SPDX tag
  2021-08-25 15:24 ` [PATCH 08/40] mfd: ti_am335x_tscadc: Replace license text with SPDX tag Miquel Raynal
@ 2021-08-30 12:38   ` Jonathan Cameron
  0 siblings, 0 replies; 88+ messages in thread
From: Jonathan Cameron @ 2021-08-30 12:38 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk

On Wed, 25 Aug 2021 17:24:46 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> Drop the text license and replace it with an equivalent SPDX license tag
> identifier.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Matches with the MODULE_LICENSE(GPL) so make sense to me.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

I wonder how this one managed to escape being updated before?  Ah well..

> ---
>  drivers/mfd/ti_am335x_tscadc.c | 10 +---------
>  1 file changed, 1 insertion(+), 9 deletions(-)
> 
> diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
> index 0e6e25308190..45262ca7734a 100644
> --- a/drivers/mfd/ti_am335x_tscadc.c
> +++ b/drivers/mfd/ti_am335x_tscadc.c
> @@ -1,16 +1,8 @@
> +// SPDX-License-Identifier: GPL-2.0-only
>  /*
>   * TI Touch Screen / ADC MFD driver
>   *
>   * Copyright (C) 2012 Texas Instruments Incorporated - https://www.ti.com/
> - *
> - * This program is free software; you can redistribute it and/or
> - * modify it under the terms of the GNU General Public License as
> - * published by the Free Software Foundation version 2.
> - *
> - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
> - * kind, whether express or implied; without even the implied warranty
> - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> - * GNU General Public License for more details.
>   */
>  
>  #include <linux/module.h>


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

* Re: [PATCH 05/40] dt-bindings: touchscreen: ti,am3359-tsc: Remove deprecated text file
  2021-08-25 15:24 ` [PATCH 05/40] dt-bindings: touchscreen: ti,am3359-tsc: Remove deprecated text file Miquel Raynal
@ 2021-08-30 12:39   ` Jonathan Cameron
  2021-08-31 19:38   ` Rob Herring
  1 sibling, 0 replies; 88+ messages in thread
From: Jonathan Cameron @ 2021-08-30 12:39 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk

On Wed, 25 Aug 2021 17:24:43 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> Now that the three hardware peaces described in this file have been
> translated in yaml in 3 dedicated files (MFD, touchscreen controller and
> ADC) it is time to remove this text file.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>

Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Nice to have another one of these go away :)
> ---
>  .../bindings/input/touchscreen/ti-tsc-adc.txt | 91 -------------------
>  1 file changed, 91 deletions(-)
>  delete mode 100644 Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt
> 
> diff --git a/Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt b/Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt
> deleted file mode 100644
> index aad5e34965eb..000000000000
> --- a/Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt
> +++ /dev/null
> @@ -1,91 +0,0 @@
> -* TI - TSC ADC (Touschscreen and analog digital converter)
> -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> -
> -Required properties:
> -- mfd
> -	compatible: Should be
> -		"ti,am3359-tscadc" for AM335x/AM437x SoCs
> -		"ti,am654-tscadc", "ti,am3359-tscadc" for AM654 SoCs
> -- child "tsc"
> -	compatible: Should be "ti,am3359-tsc".
> -	ti,wires: Wires refer to application modes i.e. 4/5/8 wire touchscreen
> -		  support on the platform.
> -	ti,x-plate-resistance: X plate resistance
> -	ti,coordinate-readouts: The sequencer supports a total of 16
> -				programmable steps each step is used to
> -				read a single coordinate. A single
> -                                readout is enough but multiple reads can
> -				increase the quality.
> -				A value of 5 means, 5 reads for X, 5 for
> -				Y and 2 for Z (always). This utilises 12
> -				of the 16 software steps available. The
> -				remaining 4 can be used by the ADC.
> -	ti,wire-config: Different boards could have a different order for
> -			connecting wires on touchscreen. We need to provide an
> -			8 bit number where in the 1st four bits represent the
> -			analog lines and the next 4 bits represent positive/
> -			negative terminal on that input line. Notations to
> -			represent the input lines and terminals resoectively
> -			is as follows:
> -			AIN0 = 0, AIN1 = 1 and so on till AIN7 = 7.
> -			XP  = 0, XN = 1, YP = 2, YN = 3.
> -- child "adc"
> -	compatible: Should be
> -		    "ti,am3359-adc" for AM335x/AM437x SoCs
> -		    "ti,am654-adc", "ti,am3359-adc" for AM654 SoCs
> -	ti,adc-channels: List of analog inputs available for ADC.
> -			 AIN0 = 0, AIN1 = 1 and so on till AIN7 = 7.
> -
> -Optional properties:
> -- child "tsc"
> -	ti,charge-delay: Length of touch screen charge delay step in terms of
> -			 ADC clock cycles. Charge delay value should be large
> -			 in order to avoid false pen-up events. This value
> -			 effects the overall sampling speed, hence need to be
> -			 kept as low as possible, while avoiding false pen-up
> -			 event. Start from a lower value, say 0x400, and
> -			 increase value until false pen-up events are avoided.
> -			 The pen-up detection happens immediately after the
> -			 charge step, so this does in fact function as a
> -			 hardware knob for adjusting the amount of "settling
> -			 time".
> -
> -- child "adc"
> -	ti,chan-step-opendelay: List of open delays for each channel of
> -				ADC in the order of ti,adc-channels. The
> -				value corresponds to the number of ADC
> -				clock cycles to wait after applying the
> -				step configuration registers and before
> -				sending the start of ADC conversion.
> -				Maximum value is 0x3FFFF.
> -       ti,chan-step-sampledelay: List of sample delays for each channel
> -				  of ADC in the order of ti,adc-channels.
> -				  The value corresponds to the number of
> -				  ADC clock cycles to sample (to hold
> -				  start of conversion high).
> -				  Maximum value is 0xFF.
> -       ti,chan-step-avg: Number of averages to be performed for each
> -			  channel of ADC. If average is 16 then input
> -			  is sampled 16 times and averaged to get more
> -			  accurate value. This increases the time taken
> -			  by ADC to generate a sample. Valid range is 0
> -			  average to 16 averages. Maximum value is 16.
> -
> -Example:
> -	tscadc: tscadc@44e0d000 {
> -		compatible = "ti,am3359-tscadc";
> -		tsc {
> -			ti,wires = <4>;
> -			ti,x-plate-resistance = <200>;
> -			ti,coordiante-readouts = <5>;
> -			ti,wire-config = <0x00 0x11 0x22 0x33>;
> -			ti,charge-delay = <0x400>;
> -		};
> -
> -		adc {
> -			ti,adc-channels = <4 5 6 7>;
> -			ti,chan-step-opendelay = <0x098 0x3ffff 0x098 0x0>;
> -			ti,chan-step-sampledelay = <0xff 0x0 0xf 0x0>;
> -			ti,chan-step-avg = <16 2 4 8>;
> -		};
> -	}


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

* Re: [PATCH 02/40] dt-bindings: mfd: ti,am3359-tscadc: Add a yaml description for this MFD
  2021-08-25 15:24 ` [PATCH 02/40] dt-bindings: mfd: ti,am3359-tscadc: Add a yaml description for this MFD Miquel Raynal
@ 2021-08-30 12:47   ` Jonathan Cameron
  2021-09-02 17:35     ` Miquel Raynal
  2021-08-31 19:33   ` Rob Herring
  1 sibling, 1 reply; 88+ messages in thread
From: Jonathan Cameron @ 2021-08-30 12:47 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk

On Wed, 25 Aug 2021 17:24:40 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> There is a very light description of this MFD in a text file dedicated
> to a touchscreen controller (which is one of the two children of the
> MFD). Here is now a complete yaml description.

Make sure to call out places where you are filling in gaps in the
txt file description.  Looks like we forgot to keep that up to date as the driver
evolved. oops.

> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> ---
>  .../bindings/mfd/ti,am3359-tscadc.yaml        | 75 +++++++++++++++++++
>  1 file changed, 75 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/mfd/ti,am3359-tscadc.yaml
> 
> diff --git a/Documentation/devicetree/bindings/mfd/ti,am3359-tscadc.yaml b/Documentation/devicetree/bindings/mfd/ti,am3359-tscadc.yaml
> new file mode 100644
> index 000000000000..96b329508d8a
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mfd/ti,am3359-tscadc.yaml
> @@ -0,0 +1,75 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/mfd/ti,am3359-tscadc.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: TI AM3359 Touchscreen controller/ADC
> +
> +maintainers:
> +  - Miquel Raynal <miquel.raynal@bootlin.com>
> +
> +properties:
> +  compatible:
> +    const: ti,am3359-tscadc

text documents the more specific ti,am654-tscadc as well.
Something like

   properties:
     compatible:
       oneof:
         - const: ti,am3359-tscadc
         - items:
             - const: ti,am654-tscadc
             - const: ti,am3359-tscadc

Note this superceeds my comment on later patches about changing to enum when
introducing the new compatible. Ah well.

example for this would be something like
Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.yam;

> +
> +  reg:
> +    maxItems: 1
> +
> +  interrupts:
> +    maxItems: 1
> +
> +  clocks:
> +    maxItems: 1
> +
> +  clock-names:
> +    const: fck
> +
> +  dmas:
> +    items:
> +      - description: DMA controller phandle and request line for FIFO0
> +      - description: DMA controller phandle and request line for FIFO1
> +
> +  dma-names:
> +    items:
> +      - const: fifo0
> +      - const: fifo1
> +
> +patternProperties:
> +  "^adc$":
> +    description: ADC
> +
> +  "^tsc$":
> +    description: Touchscreen controller
> +
> +required:
> +  - compatible
> +  - reg
> +  - interrupts
> +  - clocks
> +  - clock-names
> +  - dmas
> +  - dma-names
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +    #include <dt-bindings/interrupt-controller/arm-gic.h>
> +
> +    tscadc: tscadc@0 {
> +        compatible = "ti,am3359-tscadc";
> +        reg = <0x0 0x1000>;
> +        interrupts = <GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>;
> +        clocks = <&adc_tsc_fck>;
> +        clock-names = "fck";
> +        dmas = <&edma 53 0>, <&edma 57 0>;
> +        dma-names = "fifo0", "fifo1";
> +        status = "disabled";
> +
> +        tsc {
> +        };
> +
> +        adc {
> +        };
> +    };


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

* Re: [PATCH 09/40] mfd: ti_am335x_tscadc: Fix style
  2021-08-25 15:24 ` [PATCH 09/40] mfd: ti_am335x_tscadc: Fix style Miquel Raynal
@ 2021-08-30 12:49   ` Jonathan Cameron
  0 siblings, 0 replies; 88+ messages in thread
From: Jonathan Cameron @ 2021-08-30 12:49 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk

On Wed, 25 Aug 2021 17:24:47 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> These are mostly deffects reported by checkpatch.pl.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>

look sensible to me.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> ---
>  drivers/mfd/ti_am335x_tscadc.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
> index 45262ca7734a..540c6dcef541 100644
> --- a/drivers/mfd/ti_am335x_tscadc.c
> +++ b/drivers/mfd/ti_am335x_tscadc.c
> @@ -140,15 +140,17 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  		adc_channels++;
>  		if (val > 7) {
>  			dev_err(&pdev->dev, " PIN numbers are 0..7 (not %d)\n",
> -					val);
> +				val);
>  			return -EINVAL;
>  		}
>  	}
> +
>  	total_channels = tsc_wires + adc_channels;
>  	if (total_channels > 8) {
>  		dev_err(&pdev->dev, "Number of i/p channels more than 8\n");
>  		return -EINVAL;
>  	}
> +
>  	if (total_channels == 0) {
>  		dev_err(&pdev->dev, "Need atleast one channel.\n");
>  		return -EINVAL;
> @@ -170,8 +172,9 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  	if (err < 0) {
>  		dev_err(&pdev->dev, "no irq ID is specified.\n");
>  		goto ret;
> -	} else
> +	} else {
>  		tscadc->irq = err;
> +	}
>  
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	tscadc->tscadc_base = devm_ioremap_resource(&pdev->dev, res);
> @@ -180,7 +183,8 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  
>  	tscadc->tscadc_phys_base = res->start;
>  	tscadc->regmap = devm_regmap_init_mmio(&pdev->dev,
> -			tscadc->tscadc_base, &tscadc_regmap_config);
> +					       tscadc->tscadc_base,
> +					       &tscadc_regmap_config);
>  	if (IS_ERR(tscadc->regmap)) {
>  		dev_err(&pdev->dev, "regmap init failed\n");
>  		err = PTR_ERR(tscadc->regmap);


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

* Re: [PATCH 10/40] mfd: ti_am335x_tscadc: Drop extra spacing when declaring stack variables
  2021-08-25 15:24 ` [PATCH 10/40] mfd: ti_am335x_tscadc: Drop extra spacing when declaring stack variables Miquel Raynal
@ 2021-08-30 12:52   ` Jonathan Cameron
  0 siblings, 0 replies; 88+ messages in thread
From: Jonathan Cameron @ 2021-08-30 12:52 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk

On Wed, 25 Aug 2021 17:24:48 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> Many variables will be updated (renamed, dropped, added) in the upcoming
> changes, so let's simplify the style to avoid messing with spaces over
> and over again.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
I agree with dropping the spaces, but not so much with reordering the elements.
Whilst it obviously doesn't make any difference to padding etc, it does
require more thought that I'd want to expend reviewing a patch like this
to establish whether there was a semantic meaning to the original order that
we are disrupting.

Jonathan


> ---
>  drivers/mfd/ti_am335x_tscadc.c | 28 +++++++++++++---------------
>  1 file changed, 13 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
> index 540c6dcef541..f0824732badf 100644
> --- a/drivers/mfd/ti_am335x_tscadc.c
> +++ b/drivers/mfd/ti_am335x_tscadc.c
> @@ -113,18 +113,16 @@ static void tscadc_idle_config(struct ti_tscadc_dev *tscadc)
>  
>  static	int ti_tscadc_probe(struct platform_device *pdev)
>  {
> -	struct ti_tscadc_dev	*tscadc;
> -	struct resource		*res;
> -	struct clk		*clk;
> -	struct device_node	*node;
> -	struct mfd_cell		*cell;
> -	struct property         *prop;
> -	const __be32            *cur;
> -	u32			val;
> -	int			err, ctrl;
> -	int			clock_rate;
> -	int			tsc_wires = 0, adc_channels = 0, total_channels;
> -	int			readouts = 0;
> +	struct ti_tscadc_dev *tscadc;
> +	struct device_node *node;
> +	struct property *prop;
> +	struct mfd_cell *cell;
> +	struct resource *res;
> +	const __be32 *cur;
> +	struct clk *clk;
> +	u32 val;
> +	int tsc_wires = 0, adc_channels = 0, readouts = 0;
> +	int total_channels, clock_rate, ctrl, err;
>  
>  	if (!pdev->dev.of_node) {
>  		dev_err(&pdev->dev, "Could not find valid DT data.\n");
> @@ -278,7 +276,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  
>  static int ti_tscadc_remove(struct platform_device *pdev)
>  {
> -	struct ti_tscadc_dev	*tscadc = platform_get_drvdata(pdev);
> +	struct ti_tscadc_dev *tscadc = platform_get_drvdata(pdev);
>  
>  	regmap_write(tscadc->regmap, REG_SE, 0x00);
>  
> @@ -297,7 +295,7 @@ static int __maybe_unused ti_tscadc_can_wakeup(struct device *dev, void *data)
>  
>  static int __maybe_unused tscadc_suspend(struct device *dev)
>  {
> -	struct ti_tscadc_dev	*tscadc = dev_get_drvdata(dev);
> +	struct ti_tscadc_dev *tscadc = dev_get_drvdata(dev);
>  
>  	regmap_write(tscadc->regmap, REG_SE, 0x00);
>  	if (device_for_each_child(dev, NULL, ti_tscadc_can_wakeup)) {
> @@ -315,7 +313,7 @@ static int __maybe_unused tscadc_suspend(struct device *dev)
>  
>  static int __maybe_unused tscadc_resume(struct device *dev)
>  {
> -	struct ti_tscadc_dev	*tscadc = dev_get_drvdata(dev);
> +	struct ti_tscadc_dev *tscadc = dev_get_drvdata(dev);
>  	u32 ctrl;
>  
>  	pm_runtime_get_sync(dev);


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

* Re: [PATCH 03/40] dt-bindings: touchscreen: ti,am3359-tsc: New yaml description
  2021-08-25 15:24 ` [PATCH 03/40] dt-bindings: touchscreen: ti,am3359-tsc: New yaml description Miquel Raynal
@ 2021-08-30 13:36   ` Jonathan Cameron
  2021-09-02 17:45     ` Miquel Raynal
  2021-08-31 19:37   ` Rob Herring
  1 sibling, 1 reply; 88+ messages in thread
From: Jonathan Cameron @ 2021-08-30 13:36 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk

On Wed, 25 Aug 2021 17:24:41 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> This touchscreen controller is already described in a text file:
> Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt
> 
> After introducing a proper description of the MFD, this is the second
> step. The file cannot be removed yet as it also contains an ADC
> description.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> ---
>  .../input/touchscreen/ti,am3359-tsc.yaml      | 89 +++++++++++++++++++
>  1 file changed, 89 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/input/touchscreen/ti,am3359-tsc.yaml
> 
> diff --git a/Documentation/devicetree/bindings/input/touchscreen/ti,am3359-tsc.yaml b/Documentation/devicetree/bindings/input/touchscreen/ti,am3359-tsc.yaml
> new file mode 100644
> index 000000000000..2d4ce6d04f53
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/input/touchscreen/ti,am3359-tsc.yaml
> @@ -0,0 +1,89 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/input/touchscreen/ti,am3359-tsc.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: TI AM3359 Touchscreen controller
> +
> +maintainers:
> +  - Miquel Raynal <miquel.raynal@bootlin.com>
> +
> +properties:
> +  compatible:
> +    const: ti,am3359-tsc
> +
> +  ti,wires:
> +    description: Wires refer to application modes i.e. 4/5/8 wire touchscreen
> +      support on the platform.
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    enum: [4, 5, 8]
> +
> +  ti,x-plate-resistance:
> +    description: X plate resistance
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +
> +  ti,coordinate-readouts:
> +    description: The sequencer supports a total of 16 programmable steps. Each
> +      step is used to read a single coordinate. A single readout is enough but
> +      multiple reads can increase the quality. A value of 5 means, 5 reads for
> +      X, 5 for Y and 2 for Z (always). This utilises 12 of the 16 software steps
> +      available. The remaining 4 can be used by the ADC.
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    minimum: 1
> +    maximum: 6
> +
> +  ti,wire-config:
> +    description: Different boards could have a different order for connecting
> +      wires on touchscreen. We need to provide an 8-bit number where the
> +      first four bits represent the analog lines and the next 4 bits represent
> +      positive/negative terminal on that input line. Notations to represent the
> +      input lines and terminals respectively are as follows, AIN0 = 0, AIN1 = 1
> +      and so on untill AIN7 = 7. XP = 0, XN = 1, YP = 2, YN = 3.
> +    $ref: /schemas/types.yaml#/definitions/uint32-array
> +    minItems: 4
> +    maxItems: 8
> +
> +  ti,charge-delay:
> +    description: Length of touch screen charge delay step in terms of ADC clock
> +      cycles. Charge delay value should be large in order to avoid false pen-up
> +      events. This value effects the overall sampling speed, hence need to be
> +      kept as low as possible, while avoiding false pen-up event. Start from a
> +      lower value, say 0x400, and increase value until false pen-up events are
> +      avoided. The pen-up detection happens immediately after the charge step,
> +      so this does in fact function as a hardware knob for adjusting the amount
> +      of "settling time".
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +
> +required:
> +  - compatible
> +  - ti,wires

Are these all required?  Seems like the driver will work fine without some
of them and isn't doing appropriate error checking for their presence..

> +  - ti,x-plate-resistance
> +  - ti,coordinate-readouts
> +  - ti,wire-config
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +    #include <dt-bindings/interrupt-controller/arm-gic.h>
> +
> +    tscadc: tscadc@0 {
> +        compatible = "ti,am3359-tscadc";
> +        reg = <0x0 0x1000>;
> +        interrupts = <GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>;
> +        clocks = <&adc_tsc_fck>;
> +        clock-names = "fck";
> +        status = "disabled";
> +        dmas = <&edma 53 0>, <&edma 57 0>;
> +        dma-names = "fifo0", "fifo1";
> +
> +        tsc {
> +            compatible = "ti,am3359-tsc";
> +            ti,wires = <4>;
> +            ti,x-plate-resistance = <200>;
> +            ti,coordinate-readouts = <5>;
> +            ti,wire-config = <0x00 0x11 0x22 0x33>;
> +            ti,charge-delay = <0x400>;
> +        };
> +    };


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

* Re: [PATCH 11/40] mfd: ti_am335x_tscadc: Get rid of useless gotos
  2021-08-25 15:24 ` [PATCH 11/40] mfd: ti_am335x_tscadc: Get rid of useless gotos Miquel Raynal
@ 2021-08-30 13:39   ` Jonathan Cameron
  0 siblings, 0 replies; 88+ messages in thread
From: Jonathan Cameron @ 2021-08-30 13:39 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk

On Wed, 25 Aug 2021 17:24:49 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> Gotos jumping to a return statement are not really useful, drop them.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>

Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

As a side note, I'm not seeing the expected calls to of_put_node() for
the child nodes.  So we are leaking some stuff on those calls.

Fixing that might make this patch no longer correct.

> ---
>  drivers/mfd/ti_am335x_tscadc.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
> index f0824732badf..8e86b766b619 100644
> --- a/drivers/mfd/ti_am335x_tscadc.c
> +++ b/drivers/mfd/ti_am335x_tscadc.c
> @@ -169,7 +169,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  	err = platform_get_irq(pdev, 0);
>  	if (err < 0) {
>  		dev_err(&pdev->dev, "no irq ID is specified.\n");
> -		goto ret;
> +		return err;
>  	} else {
>  		tscadc->irq = err;
>  	}
> @@ -185,8 +185,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  					       &tscadc_regmap_config);
>  	if (IS_ERR(tscadc->regmap)) {
>  		dev_err(&pdev->dev, "regmap init failed\n");
> -		err = PTR_ERR(tscadc->regmap);
> -		goto ret;
> +		return PTR_ERR(tscadc->regmap);
>  	}
>  
>  	spin_lock_init(&tscadc->reg_lock);
> @@ -270,7 +269,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  err_disable_clk:
>  	pm_runtime_put_sync(&pdev->dev);
>  	pm_runtime_disable(&pdev->dev);
> -ret:
> +
>  	return err;
>  }
>  


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

* Re: [PATCH 13/40] mfd: ti_am335x_tscadc: Reword the comment explaining the dividers
  2021-08-25 15:24 ` [PATCH 13/40] mfd: ti_am335x_tscadc: Reword the comment explaining the dividers Miquel Raynal
@ 2021-08-30 13:43   ` Jonathan Cameron
  0 siblings, 0 replies; 88+ messages in thread
From: Jonathan Cameron @ 2021-08-30 13:43 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk

On Wed, 25 Aug 2021 17:24:51 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> The comment misses the main information which is that we assume that a
> sample takes 15 ADC clock cycles to be generated. Let's take the
> occasion to rework a little bit this comment.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Fair enough. It does seem a little clearer to me after your rewording.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> ---
>  drivers/mfd/ti_am335x_tscadc.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
> index 0fef35e1e64b..3afe22680973 100644
> --- a/drivers/mfd/ti_am335x_tscadc.c
> +++ b/drivers/mfd/ti_am335x_tscadc.c
> @@ -195,12 +195,12 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  	pm_runtime_get_sync(&pdev->dev);
>  
>  	/*
> -	 * The TSC_ADC_Subsystem has 2 clock domains
> -	 * OCP_CLK and ADC_CLK.
> -	 * The ADC clock is expected to run at target of 3MHz,
> -	 * and expected to capture 12-bit data at a rate of 200 KSPS.
> -	 * The TSC_ADC_SS controller design assumes the OCP clock is
> -	 * at least 6x faster than the ADC clock.
> +	 * The TSC_ADC_Subsystem has 2 clock domains: OCP_CLK and ADC_CLK.
> +	 * ADCs produce a 12-bit sample every 15 ADC_CLK cycles.
> +	 * am33xx ADCs expect to capture 200ksps.
> +	 * We need the ADC clocks to run at 3MHz.
> +	 * This frequency is valid since TSC_ADC_SS controller design
> +	 * assumes the OCP clock is at least 6x faster than the ADC clock.
>  	 */
>  	clk = devm_clk_get(&pdev->dev, "adc_tsc_fck");
>  	if (IS_ERR(clk)) {


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

* Re: [PATCH 15/40] mfd: ti_am335x_tscadc: Simplify divisor calculation
  2021-08-25 15:24 ` [PATCH 15/40] mfd: ti_am335x_tscadc: Simplify divisor calculation Miquel Raynal
@ 2021-08-30 13:47   ` Jonathan Cameron
  0 siblings, 0 replies; 88+ messages in thread
From: Jonathan Cameron @ 2021-08-30 13:47 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk

On Wed, 25 Aug 2021 17:24:53 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> Let's rewrite this on a single line, it does not hurt the readability
> and saves a useless temporary variable.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> ---
>  drivers/mfd/ti_am335x_tscadc.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
> index d27f8917272d..3231ccbbad02 100644
> --- a/drivers/mfd/ti_am335x_tscadc.c
> +++ b/drivers/mfd/ti_am335x_tscadc.c
> @@ -122,7 +122,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  	struct clk *clk;
>  	u32 val;
>  	int tsc_wires = 0, adc_channels = 0, readouts = 0;
> -	int total_channels, clock_rate, ctrl, err;
> +	int total_channels, ctrl, err;
>  
>  	/* Allocate memory for device */
>  	tscadc = devm_kzalloc(&pdev->dev, sizeof(*tscadc), GFP_KERNEL);
> @@ -208,11 +208,8 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  		err = PTR_ERR(clk);
>  		goto err_disable_clk;
>  	}
> -	clock_rate = clk_get_rate(clk);
> -	tscadc->clk_div = clock_rate / ADC_CLK;
>  
> -	/* TSCADC_CLKDIV needs to be configured to the value minus 1 */
> -	tscadc->clk_div--;
> +	tscadc->clk_div = (clk_get_rate(clk) / ADC_CLK) - 1;
>  	regmap_write(tscadc->regmap, REG_CLKDIV, tscadc->clk_div);
>  
>  	/* Set the control register bits */


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

* Re: [PATCH 20/40] mfd: ti_am335x_tscadc: Gather the ctrl register logic at one place
  2021-08-25 15:24 ` [PATCH 20/40] mfd: ti_am335x_tscadc: Gather the ctrl register logic at one place Miquel Raynal
@ 2021-08-30 13:56   ` Jonathan Cameron
  2021-09-02 19:42     ` Miquel Raynal
  0 siblings, 1 reply; 88+ messages in thread
From: Jonathan Cameron @ 2021-08-30 13:56 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk

On Wed, 25 Aug 2021 17:24:58 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> Instead of deriving in the probe and in the resume path the value of the
> ctrl register, let's do it only once in the probe, save the value of
> this register in the driver's structure and use it from the resume
> callback.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
A few minor things inline.

J

> ---
>  drivers/mfd/ti_am335x_tscadc.c       | 31 ++++++++--------------------
>  include/linux/mfd/ti_am335x_tscadc.h |  2 +-
>  2 files changed, 10 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
> index 7071344ad18e..d661e8ae66c9 100644
> --- a/drivers/mfd/ti_am335x_tscadc.c
> +++ b/drivers/mfd/ti_am335x_tscadc.c
> @@ -122,7 +122,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  	struct clk *clk;
>  	u32 val;
>  	int tsc_wires = 0, adc_channels = 0, readouts = 0, cell_idx = 0;
> -	int total_channels, ctrl, err;
> +	int total_channels, err;
>  
>  	/* Allocate memory for device */
>  	tscadc = devm_kzalloc(&pdev->dev, sizeof(*tscadc), GFP_KERNEL);
> @@ -215,22 +215,21 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  	regmap_write(tscadc->regmap, REG_CLKDIV, tscadc->clk_div);
>  
>  	/* Set the control register bits */
> -	ctrl = CNTRLREG_STEPCONFIGWRT |	CNTRLREG_STEPID;
> -	regmap_write(tscadc->regmap, REG_CTRL, ctrl);
> +	tscadc->ctrl = CNTRLREG_STEPCONFIGWRT | CNTRLREG_STEPID;
> +	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl);
>  
>  	if (tsc_wires > 0) {
> -		tscadc->tsc_wires = tsc_wires;
> +		tscadc->ctrl |= CNTRLREG_TSCENB;
>  		if (tsc_wires == 5)
> -			ctrl |= CNTRLREG_5WIRE | CNTRLREG_TSCENB;
> +			tscadc->ctrl |= CNTRLREG_5WIRE;
>  		else
> -			ctrl |= CNTRLREG_4WIRE | CNTRLREG_TSCENB;
> +			tscadc->ctrl |= CNTRLREG_4WIRE;
>  	}
>  
>  	tscadc_idle_config(tscadc);
>  
>  	/* Enable the TSC module enable bit */
> -	ctrl |= CNTRLREG_TSCSSENB;
> -	regmap_write(tscadc->regmap, REG_CTRL, ctrl);
> +	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl | CNTRLREG_TSCSSENB);
>  
>  	/* TSC Cell */
>  	if (tsc_wires > 0) {
> @@ -305,25 +304,13 @@ static int __maybe_unused tscadc_suspend(struct device *dev)
>  static int __maybe_unused tscadc_resume(struct device *dev)
>  {
>  	struct ti_tscadc_dev *tscadc = dev_get_drvdata(dev);
> -	u32 ctrl;
>  
>  	pm_runtime_get_sync(dev);
>  
> -	/* context restore */
> -	ctrl = CNTRLREG_STEPCONFIGWRT |	CNTRLREG_STEPID;
> -	regmap_write(tscadc->regmap, REG_CTRL, ctrl);
> -
> -	if (tscadc->tsc_wires > 0) {
> -		if (tscadc->tsc_wires == 5)
> -			ctrl |= CNTRLREG_5WIRE | CNTRLREG_TSCENB;
> -		else
> -			ctrl |= CNTRLREG_4WIRE | CNTRLREG_TSCENB;
> -	}
> -	ctrl |= CNTRLREG_TSCSSENB;
> -	regmap_write(tscadc->regmap, REG_CTRL, ctrl);
> -
>  	regmap_write(tscadc->regmap, REG_CLKDIV, tscadc->clk_div);
> +	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl);

Patch description should mention why this ordering change is here.

>  	tscadc_idle_config(tscadc);
> +	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl | CNTRLREG_TSCSSENB);

As the value of tscadc->ctrl is not the same as REG_CTRL this is a bit non obvious.

You might be better off keeping them in sync, but masking that bit out and then resetting
it as appropriate.

>  
>  	return 0;
>  }
> diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h
> index e734fb97dff8..02963b6ebbac 100644
> --- a/include/linux/mfd/ti_am335x_tscadc.h
> +++ b/include/linux/mfd/ti_am335x_tscadc.h
> @@ -177,8 +177,8 @@ struct ti_tscadc_dev {
>  	phys_addr_t tscadc_phys_base;
>  	const struct ti_tscadc_data *data;
>  	int irq;
> -	int tsc_wires;
>  	struct mfd_cell cells[TSCADC_CELLS];
> +	u32 ctrl;
>  	u32 reg_se_cache;
>  	bool adc_waiting;
>  	bool adc_in_use;


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

* Re: [PATCH 24/40] mfd: ti_am335x_tscadc: Fix an error message
  2021-08-25 15:25 ` [PATCH 24/40] mfd: ti_am335x_tscadc: Fix an error message Miquel Raynal
@ 2021-08-30 13:58   ` Jonathan Cameron
  0 siblings, 0 replies; 88+ messages in thread
From: Jonathan Cameron @ 2021-08-30 13:58 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk

On Wed, 25 Aug 2021 17:25:02 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> The error message if we cannot retrieve the clock tells us that the
> touchscreen controller clock was unavailable. This is wrong, this is the
> "main" clock for the hardware block, it is not specific to the
> touchscreen and won't change when we will introduce ADC1/magnetic reader
> support so let's corret this comment.

correct

> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> ---
>  drivers/mfd/ti_am335x_tscadc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
> index 047426a74a2e..2f934fd2154a 100644
> --- a/drivers/mfd/ti_am335x_tscadc.c
> +++ b/drivers/mfd/ti_am335x_tscadc.c
> @@ -206,7 +206,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  	 */
>  	clk = devm_clk_get(&pdev->dev, NULL);
>  	if (IS_ERR(clk)) {
> -		dev_err(&pdev->dev, "failed to get TSC fck\n");
> +		dev_err(&pdev->dev, "failed to get fck\n");
>  		err = PTR_ERR(clk);
>  		goto err_disable_clk;
>  	}


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

* Re: [PATCH 25/40] mfd: ti_am335x_tscadc: Add a boolean to clarify the presence of a touchscreen
  2021-08-25 15:25 ` [PATCH 25/40] mfd: ti_am335x_tscadc: Add a boolean to clarify the presence of a touchscreen Miquel Raynal
@ 2021-08-30 13:59   ` Jonathan Cameron
  0 siblings, 0 replies; 88+ messages in thread
From: Jonathan Cameron @ 2021-08-30 13:59 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk

On Wed, 25 Aug 2021 17:25:03 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> Just checking the number of wires will soon not be enough, add a boolean
> to indicated the actual use or not of the touchscreen.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> ---
>  drivers/mfd/ti_am335x_tscadc.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
> index 2f934fd2154a..30f53cdb41f8 100644
> --- a/drivers/mfd/ti_am335x_tscadc.c
> +++ b/drivers/mfd/ti_am335x_tscadc.c
> @@ -121,6 +121,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  	const __be32 *cur;
>  	struct clk *clk;
>  	u32 val;
> +	bool use_tsc = false;
>  	int tscmag_wires = 0, adc_channels = 0, readouts = 0, cell_idx = 0;
>  	int total_channels, err;
>  
> @@ -141,6 +142,8 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  	node = of_get_child_by_name(pdev->dev.of_node, "tsc");
>  	of_property_read_u32(node, "ti,wires", &tscmag_wires);
>  	of_property_read_u32(node, "ti,coordiante-readouts", &readouts);
> +	if (tscmag_wires)
> +		use_tsc = true;
>  
>  	node = of_get_child_by_name(pdev->dev.of_node, "adc");
>  	of_property_for_each_u32(node, "ti,adc-channels", prop, cur, val) {
> @@ -163,7 +166,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  		return -EINVAL;
>  	}
>  
> -	if (readouts * 2 + 2 + adc_channels > 16) {
> +	if (use_tsc && (readouts * 2 + 2 + adc_channels > 16)) {

This one is adding a check that wasn't there before.  The description should
mention why it will now be necessary and isn't a bug...

>  		dev_err(&pdev->dev, "Too many step configurations requested\n");
>  		return -EINVAL;
>  	}
> @@ -218,7 +221,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  	tscadc->ctrl = CNTRLREG_TSC_STEPCONFIGWRT | CNTRLREG_STEPID;
>  	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl);
>  
> -	if (tscmag_wires > 0) {
> +	if (use_tsc) {
>  		tscadc->ctrl |= CNTRLREG_TSC_ENB;
>  		if (tscmag_wires == 5)
>  			tscadc->ctrl |= CNTRLREG_TSC_5WIRE;


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

* Re: [PATCH 26/40] mfd: ti_am335x_tscadc: Introduce has_tsc
  2021-08-25 15:25 ` [PATCH 26/40] mfd: ti_am335x_tscadc: Introduce has_tsc Miquel Raynal
@ 2021-08-30 14:02   ` Jonathan Cameron
  0 siblings, 0 replies; 88+ messages in thread
From: Jonathan Cameron @ 2021-08-30 14:02 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk

On Wed, 25 Aug 2021 17:25:04 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> One way of knowing which hardware we are dealing with is to check its
> compatible. When this must be done at several places, it's best to use a
> proper boolean for that. ->has_tsc indicates if there is a touchscreen
> controller available (meaning it's a am33xx-like ADC) or not but does
> not indicate if it is actually used (that is the purpose of the use_tsc
> boolean in the probe).
> 
> Introducing this boolean helps making a difference in the code between
> what is generic to both types of ADCs and what is specific to the am33xx
> hardware before introducing support for the am437x hardware.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Seems sensible to me.
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> ---
>  drivers/mfd/ti_am335x_tscadc.c       | 37 +++++++++++++++++-----------
>  include/linux/mfd/ti_am335x_tscadc.h |  1 +
>  2 files changed, 23 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
> index 30f53cdb41f8..a40091830cea 100644
> --- a/drivers/mfd/ti_am335x_tscadc.c
> +++ b/drivers/mfd/ti_am335x_tscadc.c
> @@ -105,8 +105,9 @@ static void tscadc_idle_config(struct ti_tscadc_dev *tscadc)
>  {
>  	unsigned int idleconfig;
>  
> -	idleconfig = STEPCONFIG_YNN | STEPCONFIG_INM_ADCREFM |
> -			STEPCONFIG_INP_ADCREFM | STEPCONFIG_YPN;
> +	idleconfig = STEPCONFIG_INM_ADCREFM | STEPCONFIG_INP_ADCREFM;
> +	if (tscadc->data->has_tsc)
> +		idleconfig |= STEPCONFIG_YNN | STEPCONFIG_YPN;
>  
>  	regmap_write(tscadc->regmap, REG_IDLECONFIG, idleconfig);
>  }
> @@ -139,11 +140,13 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  
>  	tscadc->data = of_device_get_match_data(&pdev->dev);
>  
> -	node = of_get_child_by_name(pdev->dev.of_node, "tsc");
> -	of_property_read_u32(node, "ti,wires", &tscmag_wires);
> -	of_property_read_u32(node, "ti,coordiante-readouts", &readouts);
> -	if (tscmag_wires)
> -		use_tsc = true;
> +	if (tscadc->data->has_tsc) {
> +		node = of_get_child_by_name(pdev->dev.of_node, "tsc");
> +		of_property_read_u32(node, "ti,wires", &tscmag_wires);
> +		of_property_read_u32(node, "ti,coordiante-readouts", &readouts);
> +		if (tscmag_wires)
> +			use_tsc = true;
> +	}
>  
>  	node = of_get_child_by_name(pdev->dev.of_node, "adc");
>  	of_property_for_each_u32(node, "ti,adc-channels", prop, cur, val) {
> @@ -218,15 +221,18 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  	regmap_write(tscadc->regmap, REG_CLKDIV, tscadc->clk_div);
>  
>  	/* Set the control register bits */
> -	tscadc->ctrl = CNTRLREG_TSC_STEPCONFIGWRT | CNTRLREG_STEPID;
> -	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl);
> +	tscadc->ctrl = CNTRLREG_STEPID;
> +	if (tscadc->data->has_tsc) {
> +		tscadc->ctrl |= CNTRLREG_TSC_STEPCONFIGWRT;
> +		regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl);
> +		if (use_tsc) {
> +			tscadc->ctrl |= CNTRLREG_TSC_ENB;
> +			if (tscmag_wires == 5)
> +				tscadc->ctrl |= CNTRLREG_TSC_5WIRE;
> +			else
> +				tscadc->ctrl |= CNTRLREG_TSC_4WIRE;
> +		}
>  
> -	if (use_tsc) {
> -		tscadc->ctrl |= CNTRLREG_TSC_ENB;
> -		if (tscmag_wires == 5)
> -			tscadc->ctrl |= CNTRLREG_TSC_5WIRE;
> -		else
> -			tscadc->ctrl |= CNTRLREG_TSC_4WIRE;
>  	}
>  
>  	tscadc_idle_config(tscadc);
> @@ -321,6 +327,7 @@ static int __maybe_unused tscadc_resume(struct device *dev)
>  static SIMPLE_DEV_PM_OPS(tscadc_pm_ops, tscadc_suspend, tscadc_resume);
>  
>  static const struct ti_tscadc_data tscdata = {
> +	.has_tsc = true,
>  	.name_tscmag = "TI-am335x-tsc",
>  	.compat_tscmag = "ti,am3359-tsc",
>  	.name_adc = "TI-am335x-adc",
> diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h
> index d5e2ff8dc84a..082b2af94263 100644
> --- a/include/linux/mfd/ti_am335x_tscadc.h
> +++ b/include/linux/mfd/ti_am335x_tscadc.h
> @@ -163,6 +163,7 @@
>  #define TSCADC_CELLS		2
>  
>  struct ti_tscadc_data {
> +	bool has_tsc;
>  	char *name_tscmag;
>  	char *compat_tscmag;
>  	char *name_adc;


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

* Re: [PATCH 27/40] mfd: ti_am335x_tscadc: Move control register configuration
  2021-08-25 15:25 ` [PATCH 27/40] mfd: ti_am335x_tscadc: Move control register configuration Miquel Raynal
@ 2021-08-30 14:03   ` Jonathan Cameron
  0 siblings, 0 replies; 88+ messages in thread
From: Jonathan Cameron @ 2021-08-30 14:03 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk

On Wed, 25 Aug 2021 17:25:05 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> The datasheet states that most of the configuration should be set in the
> control register in the first place, before actually enabling the
> hardware.

Reference always good. 

> So far only half of the configuration was made in the first
> step, which does not make really sense and would complicating the code
> when introducing support for the am437x hardware.
> 
> Let's move that register write a bit below to enclose more configuration.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Looks fine to me otherwise.

> ---
>  drivers/mfd/ti_am335x_tscadc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
> index a40091830cea..1a30610dc65f 100644
> --- a/drivers/mfd/ti_am335x_tscadc.c
> +++ b/drivers/mfd/ti_am335x_tscadc.c
> @@ -224,7 +224,6 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  	tscadc->ctrl = CNTRLREG_STEPID;
>  	if (tscadc->data->has_tsc) {
>  		tscadc->ctrl |= CNTRLREG_TSC_STEPCONFIGWRT;
> -		regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl);
>  		if (use_tsc) {
>  			tscadc->ctrl |= CNTRLREG_TSC_ENB;
>  			if (tscmag_wires == 5)
> @@ -235,6 +234,8 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  
>  	}
>  
> +	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl);
> +
>  	tscadc_idle_config(tscadc);
>  
>  	/* Enable the TSC module enable bit */


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

* Re: [PATCH 28/40] mfd: ti_am335x_tscadc: Add ADC1/magnetic reader support
  2021-08-25 15:25 ` [PATCH 28/40] mfd: ti_am335x_tscadc: Add ADC1/magnetic reader support Miquel Raynal
@ 2021-08-30 14:10   ` Jonathan Cameron
  2021-09-02 18:31     ` Miquel Raynal
  2021-09-02 20:03     ` Miquel Raynal
  2021-09-01 19:26   ` Grygorii Strashko
  1 sibling, 2 replies; 88+ messages in thread
From: Jonathan Cameron @ 2021-08-30 14:10 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk, Jason Reeder

On Wed, 25 Aug 2021 17:25:06 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> Introduce a new compatible that has another set of driver data,
> targeting am437x SoCs with a magnetic reader instead of the
> touchscreen and a more featureful set of registers.
> 
> Co-developed-by: Jason Reeder <jreeder@ti.com>
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> Signed-off-by: Jason Reeder <jreeder@ti.com>
There is one bit in here that I think should have been back in patch 16 but
maybe I'm missing something.

Jonathan

> ---
>  drivers/mfd/ti_am335x_tscadc.c       | 43 ++++++++++++++++++++++------
>  include/linux/mfd/ti_am335x_tscadc.h |  9 +++++-
>  2 files changed, 43 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
> index 1a30610dc65f..f4f6b9db4d2a 100644
> --- a/drivers/mfd/ti_am335x_tscadc.c
> +++ b/drivers/mfd/ti_am335x_tscadc.c
> @@ -122,9 +122,9 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  	const __be32 *cur;
>  	struct clk *clk;
>  	u32 val;
> -	bool use_tsc = false;
> +	bool use_tsc = false, use_mag = false;
>  	int tscmag_wires = 0, adc_channels = 0, readouts = 0, cell_idx = 0;
> -	int total_channels, err;
> +	int mag_tracks = 0, total_channels, err;
>  
>  	/* Allocate memory for device */
>  	tscadc = devm_kzalloc(&pdev->dev, sizeof(*tscadc), GFP_KERNEL);
> @@ -146,6 +146,12 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  		of_property_read_u32(node, "ti,coordiante-readouts", &readouts);
>  		if (tscmag_wires)
>  			use_tsc = true;
> +	} else {
> +		node = of_get_child_by_name(pdev->dev.of_node, "mag");
> +		of_property_read_u32(node, "ti,tracks", &mag_tracks);
> +		tscmag_wires = mag_tracks * 2;
> +		if (tscmag_wires)
> +			use_mag = true;
>  	}
>  
>  	node = of_get_child_by_name(pdev->dev.of_node, "adc");
> @@ -206,8 +212,9 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  	 * The TSC_ADC_Subsystem has 2 clock domains: OCP_CLK and ADC_CLK.
>  	 * ADCs produce a 12-bit sample every 15 ADC_CLK cycles.
>  	 * am33xx ADCs expect to capture 200ksps.
> -	 * We need the ADC clocks to run at 3MHz.
> -	 * This frequency is valid since TSC_ADC_SS controller design
> +	 * am47xx ADCs expect to capture 867ksps.
> +	 * We need ADC clocks respectively running at 3MHz and 13MHz.
> +	 * These frequencies are valid since TSC_ADC_SS controller design
>  	 * assumes the OCP clock is at least 6x faster than the ADC clock.
>  	 */
>  	clk = devm_clk_get(&pdev->dev, NULL);
> @@ -231,7 +238,9 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  			else
>  				tscadc->ctrl |= CNTRLREG_TSC_4WIRE;
>  		}
> -
> +	} else {
> +		tscadc->ctrl |= CNTRLREG_MAG_PREAMP_PWRDOWN |
> +				CNTRLREG_MAG_PREAMP_BYPASS;
>  	}
>  
>  	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl);
> @@ -241,7 +250,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  	/* Enable the TSC module enable bit */
>  	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl | CNTRLREG_SSENB);
>  
> -	/* TSC Cell */
> +	/* TSC or MAG Cell */
>  	if (tscmag_wires > 0) {
>  		cell = &tscadc->cells[cell_idx++];
>  		cell->name = tscadc->data->name_tscmag;
> @@ -329,6 +338,7 @@ static SIMPLE_DEV_PM_OPS(tscadc_pm_ops, tscadc_suspend, tscadc_resume);
>  
>  static const struct ti_tscadc_data tscdata = {
>  	.has_tsc = true,
> +	.has_mag = false,
>  	.name_tscmag = "TI-am335x-tsc",
>  	.compat_tscmag = "ti,am3359-tsc",
>  	.name_adc = "TI-am335x-adc",
> @@ -336,8 +346,25 @@ static const struct ti_tscadc_data tscdata = {
>  	.target_clk_rate = TSC_ADC_CLK,
>  };
>  
> +static const struct ti_tscadc_data magdata = {
> +	.has_tsc = false,
> +	.has_mag = true,
> +	.name_tscmag = "TI-am43xx-mag",
> +	.compat_tscmag = "ti,am4372-mag",
> +	.name_adc = "TI-am43xx-adc",
> +	.compat_adc = "ti,am4372-adc",
> +	.target_clk_rate = MAG_ADC_CLK,
> +};
> +
>  static const struct of_device_id ti_tscadc_dt_ids[] = {
> -	{ .compatible = "ti,am3359-tscadc", },
> +	{
> +		.compatible = "ti,am3359-tscadc",
> +		.data = &tscdata,
Interesting to see match data added here and not before.
Given you don't have any code in here that seems to have
changed to use the match data, was it buggy before or is this still
not used?

> +	},
> +	{
> +		.compatible = "ti,am4372-magadc",
> +		.data = &magdata,
> +	},
>  	{ }
>  };
>  MODULE_DEVICE_TABLE(of, ti_tscadc_dt_ids);
> @@ -355,6 +382,6 @@ static struct platform_driver ti_tscadc_driver = {
>  
>  module_platform_driver(ti_tscadc_driver);
>  
> -MODULE_DESCRIPTION("TI touchscreen / ADC MFD controller driver");
> +MODULE_DESCRIPTION("TI touchscreen/magnetic reader/ADC MFD controller driver");
>  MODULE_AUTHOR("Rachna Patil <rachna@ti.com>");
>  MODULE_LICENSE("GPL");
> diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h
> index 082b2af94263..31b22ec567e7 100644
> --- a/include/linux/mfd/ti_am335x_tscadc.h
> +++ b/include/linux/mfd/ti_am335x_tscadc.h
> @@ -129,6 +129,11 @@
>  #define CNTRLREG_TSC_8WIRE	CNTRLREG_TSC_AFE_CTRL(3)
>  #define CNTRLREG_TSC_ENB	BIT(7)
>  
> +/*Control registers bitfields  for MAGADC IP */
> +#define CNTRLREG_MAGADCENB      BIT(0)
> +#define CNTRLREG_MAG_PREAMP_PWRDOWN BIT(5)
> +#define CNTRLREG_MAG_PREAMP_BYPASS  BIT(6)
> +
>  /* FIFO READ Register */
>  #define FIFOREAD_DATA_MASK (0xfff << 0)
>  #define FIFOREAD_CHNLID_MASK (0xf << 16)
> @@ -141,7 +146,8 @@
>  #define SEQ_STATUS BIT(5)
>  #define CHARGE_STEP		0x11
>  
> -#define TSC_ADC_CLK		3000000
> +#define TSC_ADC_CLK		3000000 /* 3 MHz */
> +#define MAG_ADC_CLK		13000000 /* 13 MHz */

Not sure on current status, but there is a proposed series floating
about that adds HZ_PER_MEGAHZ or something like that which would make
it easier to spot if these have right number of zeros.

>  #define TOTAL_STEPS		16
>  #define TOTAL_CHANNELS		8
>  #define FIFO1_THRESHOLD		19
> @@ -164,6 +170,7 @@
>  
>  struct ti_tscadc_data {
>  	bool has_tsc;
> +	bool has_mag;
>  	char *name_tscmag;
>  	char *compat_tscmag;
>  	char *name_adc;


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

* Re: [PATCH 29/40] mfd: ti_am335x_tscadc: Support the correctly spelled DT property
  2021-08-25 15:25 ` [PATCH 29/40] mfd: ti_am335x_tscadc: Support the correctly spelled DT property Miquel Raynal
@ 2021-08-30 14:11   ` Jonathan Cameron
  0 siblings, 0 replies; 88+ messages in thread
From: Jonathan Cameron @ 2021-08-30 14:11 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk

On Wed, 25 Aug 2021 17:25:07 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> There was in the past a typo in the coordinate readouts property. The
> bindings have been updated, the touchscreen driver as well and now
> supports both. However, the MFD driver that is in charge of verifying
> the validity of the property only checks the bogus one. Add support for
> the correctly spelled DT property.
> 
> Fixes: c9aeb249bf72 ("Input: ti_am335x_tsc - fix spelling mistake in TSC/ADC DT binding")
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Ouch.

> ---
>  drivers/mfd/ti_am335x_tscadc.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
> index f4f6b9db4d2a..0bd260edc9ad 100644
> --- a/drivers/mfd/ti_am335x_tscadc.c
> +++ b/drivers/mfd/ti_am335x_tscadc.c
> @@ -143,7 +143,13 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  	if (tscadc->data->has_tsc) {
>  		node = of_get_child_by_name(pdev->dev.of_node, "tsc");
>  		of_property_read_u32(node, "ti,wires", &tscmag_wires);
> -		of_property_read_u32(node, "ti,coordiante-readouts", &readouts);
> +		err = of_property_read_u32(node, "ti,coordinate-readouts",
> +					   &readouts);
> +		if (err < 0) {
> +			err = of_property_read_u32(node, "ti,coordiante-readouts",
> +						   &readouts);

I'm going to guess this will trigger not used warnings for err.  

> +		}
> +
>  		if (tscmag_wires)
>  			use_tsc = true;
>  	} else {


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

* Re: [PATCH 30/40] iio: adc: ti_am335x_adc: Replace license text with SPDX tag
  2021-08-25 15:25 ` [PATCH 30/40] iio: adc: ti_am335x_adc: Replace license text with SPDX tag Miquel Raynal
@ 2021-08-30 14:12   ` Jonathan Cameron
  0 siblings, 0 replies; 88+ messages in thread
From: Jonathan Cameron @ 2021-08-30 14:12 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk

On Wed, 25 Aug 2021 17:25:08 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> Drop the text license and replace it with an equivalent SPDX license tag
> identifier.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> ---
>  drivers/iio/adc/ti_am335x_adc.c | 10 +---------
>  1 file changed, 1 insertion(+), 9 deletions(-)
> 
> diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
> index f748d49f10f4..a5da1fedbc5c 100644
> --- a/drivers/iio/adc/ti_am335x_adc.c
> +++ b/drivers/iio/adc/ti_am335x_adc.c
> @@ -1,16 +1,8 @@
> +// SPDX-License-Identifier: GPL-2.0-only
>  /*
>   * TI ADC MFD driver
>   *
>   * Copyright (C) 2012 Texas Instruments Incorporated - https://www.ti.com/
> - *
> - * This program is free software; you can redistribute it and/or
> - * modify it under the terms of the GNU General Public License as
> - * published by the Free Software Foundation version 2.
> - *
> - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
> - * kind, whether express or implied; without even the implied warranty
> - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> - * GNU General Public License for more details.
>   */
>  
>  #include <linux/kernel.h>


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

* Re: [PATCH 31/40] iio: adc: ti_am335x_adc: Fix style
  2021-08-25 15:25 ` [PATCH 31/40] iio: adc: ti_am335x_adc: Fix style Miquel Raynal
@ 2021-08-30 14:16   ` Jonathan Cameron
  0 siblings, 0 replies; 88+ messages in thread
From: Jonathan Cameron @ 2021-08-30 14:16 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk

On Wed, 25 Aug 2021 17:25:09 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> These warnings are reported by checkpatch.pl essentially.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
A few trivial comments inline, but otherwise lgtm

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> ---
>  drivers/iio/adc/ti_am335x_adc.c | 104 ++++++++++++++++----------------
>  1 file changed, 52 insertions(+), 52 deletions(-)
> 
> diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
> index a5da1fedbc5c..dd2200d2f214 100644
> --- a/drivers/iio/adc/ti_am335x_adc.c
> +++ b/drivers/iio/adc/ti_am335x_adc.c
> @@ -57,7 +57,7 @@ static unsigned int tiadc_readl(struct tiadc_device *adc, unsigned int reg)
>  }
>  
>  static void tiadc_writel(struct tiadc_device *adc, unsigned int reg,
> -					unsigned int val)
> +			 unsigned int val)
>  {
>  	writel(val, adc->mfd_tscadc->tscadc_base + reg);
>  }
> @@ -72,7 +72,7 @@ static u32 get_adc_step_mask(struct tiadc_device *adc_dev)
>  }
>  
>  static u32 get_adc_chan_step_mask(struct tiadc_device *adc_dev,
> -		struct iio_chan_spec const *chan)
> +				  struct iio_chan_spec const *chan)
>  {
>  	int i;
>  
> @@ -110,8 +110,6 @@ static void tiadc_step_config(struct iio_dev *indio_dev)
>  	 * Channel would represent which analog input
>  	 * needs to be given to ADC to digitalize data.
>  	 */
> -
> -
>  	for (i = 0; i < adc_dev->channels; i++) {
>  		int chan;
>  
> @@ -124,9 +122,8 @@ static void tiadc_step_config(struct iio_dev *indio_dev)
>  		}
>  
>  		if (adc_dev->step_avg[i])
> -			stepconfig =
> -			STEPCONFIG_AVG(ffs(adc_dev->step_avg[i]) - 1) |
> -			STEPCONFIG_FIFO1;
> +			stepconfig = STEPCONFIG_AVG(ffs(adc_dev->step_avg[i]) - 1) |
> +				     STEPCONFIG_FIFO1;
>  		else
>  			stepconfig = STEPCONFIG_FIFO1;
>  
> @@ -134,10 +131,9 @@ static void tiadc_step_config(struct iio_dev *indio_dev)
>  			stepconfig |= STEPCONFIG_MODE_SWCNT;
>  
>  		tiadc_writel(adc_dev, REG_STEPCONFIG(steps),
> -				stepconfig | STEPCONFIG_INP(chan) |
> -				STEPCONFIG_INM_ADCREFM |
> -				STEPCONFIG_RFP_VREFP |
> -				STEPCONFIG_RFM_VREFN);
> +			     stepconfig | STEPCONFIG_INP(chan) |
> +			     STEPCONFIG_INM_ADCREFM | STEPCONFIG_RFP_VREFP |
> +			     STEPCONFIG_RFM_VREFN);
>  
>  		if (adc_dev->open_delay[i] > STEPDELAY_OPEN_MASK) {
>  			dev_warn(dev, "chan %d open delay truncating to 0x3FFFF\n",
> @@ -152,8 +148,8 @@ static void tiadc_step_config(struct iio_dev *indio_dev)
>  		}
>  
>  		tiadc_writel(adc_dev, REG_STEPDELAY(steps),
> -				STEPDELAY_OPEN(adc_dev->open_delay[i]) |
> -				STEPDELAY_SAMPLE(adc_dev->sample_delay[i]));
> +			     STEPDELAY_OPEN(adc_dev->open_delay[i]) |
> +			     STEPDELAY_SAMPLE(adc_dev->sample_delay[i]));
>  
>  		adc_dev->channel_step[i] = steps;
>  		steps++;
> @@ -178,10 +174,12 @@ static irqreturn_t tiadc_irq_h(int irq, void *private)
>  		config = tiadc_readl(adc_dev, REG_CTRL);
>  		config &= ~(CNTRLREG_SSENB);
>  		tiadc_writel(adc_dev, REG_CTRL, config);
> -		tiadc_writel(adc_dev, REG_IRQSTATUS, IRQENB_FIFO1OVRRUN
> -				| IRQENB_FIFO1UNDRFLW | IRQENB_FIFO1THRES);
> +		tiadc_writel(adc_dev, REG_IRQSTATUS,
> +			     IRQENB_FIFO1OVRRUN | IRQENB_FIFO1UNDRFLW |
> +			     IRQENB_FIFO1THRES);
>  
> -		/* wait for idle state.
> +		/*
> +		 * Wait for the idle state.
>  		 * ADC needs to finish the current conversion
>  		 * before disabling the module
>  		 */
> @@ -209,11 +207,11 @@ static irqreturn_t tiadc_worker_h(int irq, void *private)
>  
>  	fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT);
>  	for (k = 0; k < fifo1count; k = k + i) {
> -		for (i = 0; i < (indio_dev->scan_bytes)/2; i++) {
> +		for (i = 0; i < (indio_dev->scan_bytes / 2); i++) {

Do we need those internal brackets at all?

>  			read = tiadc_readl(adc_dev, REG_FIFO1);
>  			data[i] = read & FIFOREAD_DATA_MASK;
>  		}
> -		iio_push_to_buffers(indio_dev, (u8 *) data);
> +		iio_push_to_buffers(indio_dev, (u8 *)data);
>  	}
>  
>  	tiadc_writel(adc_dev, REG_IRQSTATUS, IRQENB_FIFO1THRES);
> @@ -246,6 +244,7 @@ static int tiadc_start_dma(struct iio_dev *indio_dev)
>  	struct dma_async_tx_descriptor *desc;
>  
>  	dma->current_period = 0; /* We start to fill period 0 */
> +
>  	/*
>  	 * Make the fifo thresh as the multiple of total number of
>  	 * channels enabled, so make sure that cyclic DMA period
> @@ -255,9 +254,10 @@ static int tiadc_start_dma(struct iio_dev *indio_dev)
>  	 */
>  	dma->fifo_thresh = rounddown(FIFO1_THRESHOLD + 1,
>  				     adc_dev->total_ch_enabled) - 1;
> +
>  	/* Make sure that period length is multiple of fifo thresh level */
>  	dma->period_size = rounddown(DMA_BUFFER_SIZE / 2,
> -				    (dma->fifo_thresh + 1) * sizeof(u16));
> +				     (dma->fifo_thresh + 1) * sizeof(u16));
>  
>  	dma->conf.src_maxburst = dma->fifo_thresh + 1;
>  	dmaengine_slave_config(dma->chan, &dma->conf);
> @@ -288,9 +288,9 @@ static int tiadc_buffer_preenable(struct iio_dev *indio_dev)
>  	struct tiadc_device *adc_dev = iio_priv(indio_dev);
>  	int i, fifo1count;
>  
> -	tiadc_writel(adc_dev, REG_IRQCLR, (IRQENB_FIFO1THRES |
> -				IRQENB_FIFO1OVRRUN |
> -				IRQENB_FIFO1UNDRFLW));
> +	tiadc_writel(adc_dev, REG_IRQCLR,
> +		     IRQENB_FIFO1THRES | IRQENB_FIFO1OVRRUN |
> +		     IRQENB_FIFO1UNDRFLW);
>  
>  	/* Flush FIFO. Needed in corner cases in simultaneous tsc/adc use */
>  	fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT);
> @@ -320,8 +320,9 @@ static int tiadc_buffer_postenable(struct iio_dev *indio_dev)
>  
>  	am335x_tsc_se_set_cache(adc_dev->mfd_tscadc, enb);
>  
> -	tiadc_writel(adc_dev,  REG_IRQSTATUS, IRQENB_FIFO1THRES
> -				| IRQENB_FIFO1OVRRUN | IRQENB_FIFO1UNDRFLW);
> +	tiadc_writel(adc_dev, REG_IRQSTATUS,
> +		     IRQENB_FIFO1THRES | IRQENB_FIFO1OVRRUN |
> +		     IRQENB_FIFO1UNDRFLW);
>  
>  	irq_enable = IRQENB_FIFO1OVRRUN;
>  	if (!dma->chan)
> @@ -337,8 +338,9 @@ static int tiadc_buffer_predisable(struct iio_dev *indio_dev)
>  	struct tiadc_dma *dma = &adc_dev->dma;
>  	int fifo1count, i;
>  
> -	tiadc_writel(adc_dev, REG_IRQCLR, (IRQENB_FIFO1THRES |
> -				IRQENB_FIFO1OVRRUN | IRQENB_FIFO1UNDRFLW));
> +	tiadc_writel(adc_dev, REG_IRQCLR,
> +		     IRQENB_FIFO1THRES | IRQENB_FIFO1OVRRUN |
> +		     IRQENB_FIFO1UNDRFLW);
>  	am335x_tsc_se_clr(adc_dev->mfd_tscadc, adc_dev->buffer_en_ch_steps);
>  	adc_dev->buffer_en_ch_steps = 0;
>  	adc_dev->total_ch_enabled = 0;
> @@ -370,12 +372,11 @@ static const struct iio_buffer_setup_ops tiadc_buffer_setup_ops = {
>  };
>  
>  static int tiadc_iio_buffered_hardware_setup(struct device *dev,
> -	struct iio_dev *indio_dev,
> -	irqreturn_t (*pollfunc_bh)(int irq, void *p),
> -	irqreturn_t (*pollfunc_th)(int irq, void *p),
> -	int irq,
> -	unsigned long flags,
> -	const struct iio_buffer_setup_ops *setup_ops)
> +					     struct iio_dev *indio_dev,

I would consider this particular form fine to keep line lengths down.
It's not very important now we have some more slack up to 100 chars though.

> +					     irqreturn_t (*pollfunc_bh)(int irq, void *p),
> +					     irqreturn_t (*pollfunc_th)(int irq, void *p),
> +					     int irq, unsigned long flags,
> +					     const struct iio_buffer_setup_ops *setup_ops)
>  {
>  	int ret;
>  
> @@ -386,7 +387,7 @@ static int tiadc_iio_buffered_hardware_setup(struct device *dev,
>  		return ret;
>  
>  	return devm_request_threaded_irq(dev, irq, pollfunc_th, pollfunc_bh,
> -				flags, indio_dev->name, indio_dev);
> +					 flags, indio_dev->name, indio_dev);
>  }
>  
>  static const char * const chan_name_ain[] = {
> @@ -411,12 +412,11 @@ static int tiadc_channel_init(struct device *dev, struct iio_dev *indio_dev,
>  	indio_dev->num_channels = channels;
>  	chan_array = devm_kcalloc(dev, channels, sizeof(*chan_array),
>  				  GFP_KERNEL);
> -	if (chan_array == NULL)
> +	if (!chan_array)
>  		return -ENOMEM;
>  
>  	chan = chan_array;
>  	for (i = 0; i < channels; i++, chan++) {
> -
>  		chan->type = IIO_VOLTAGE;
>  		chan->indexed = 1;
>  		chan->channel = adc_dev->channel_line[i];
> @@ -434,8 +434,8 @@ static int tiadc_channel_init(struct device *dev, struct iio_dev *indio_dev,
>  }
>  
>  static int tiadc_read_raw(struct iio_dev *indio_dev,
> -		struct iio_chan_spec const *chan,
> -		int *val, int *val2, long mask)
> +			  struct iio_chan_spec const *chan, int *val, int *val2,
> +			  long mask)
>  {
>  	struct tiadc_device *adc_dev = iio_priv(indio_dev);
>  	int ret = IIO_VAL_INT;
> @@ -459,9 +459,8 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
>  
>  	am335x_tsc_se_set_once(adc_dev->mfd_tscadc, step_en);
>  
> -	timeout = jiffies + msecs_to_jiffies
> -				(IDLE_TIMEOUT * adc_dev->channels);
>  	/* Wait for Fifo threshold interrupt */
> +	timeout = jiffies + msecs_to_jiffies(IDLE_TIMEOUT * adc_dev->channels);
>  	while (1) {
>  		fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT);
>  		if (fifo1count)
> @@ -473,6 +472,7 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
>  			goto err_unlock;
>  		}
>  	}
> +
>  	map_val = adc_dev->channel_step[chan->scan_index];
>  
>  	/*
> @@ -490,13 +490,14 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
>  		if (stepid == map_val) {
>  			read = read & FIFOREAD_DATA_MASK;
>  			found = true;
> -			*val = (u16) read;
> +			*val = (u16)read;
>  		}
>  	}
> +
>  	am335x_tsc_se_adc_done(adc_dev->mfd_tscadc);
>  
>  	if (!found)
> -		ret =  -EBUSY;
> +		ret = -EBUSY;
>  
>  err_unlock:
>  	mutex_unlock(&adc_dev->fifo1_lock);
> @@ -537,6 +538,7 @@ static int tiadc_request_dma(struct platform_device *pdev,
>  		goto err;
>  
>  	return 0;
> +
>  err:
>  	dma_release_channel(dma->chan);
>  	return -ENOMEM;
> @@ -586,7 +588,7 @@ static int tiadc_probe(struct platform_device *pdev)
>  	}
>  
>  	indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*adc_dev));
> -	if (indio_dev == NULL) {
> +	if (!indio_dev) {
>  		dev_err(&pdev->dev, "failed to allocate iio device\n");
>  		return -ENOMEM;
>  	}
> @@ -608,12 +610,11 @@ static int tiadc_probe(struct platform_device *pdev)
>  		return err;
>  
>  	err = tiadc_iio_buffered_hardware_setup(&pdev->dev, indio_dev,
> -		&tiadc_worker_h,
> -		&tiadc_irq_h,
> -		adc_dev->mfd_tscadc->irq,
> -		IRQF_SHARED,
> -		&tiadc_buffer_setup_ops);
> -
> +						&tiadc_worker_h,
> +						&tiadc_irq_h,
> +						adc_dev->mfd_tscadc->irq,
> +						IRQF_SHARED,
> +						&tiadc_buffer_setup_ops);
>  	if (err)
>  		goto err_free_channels;
>  
> @@ -664,8 +665,7 @@ static int __maybe_unused tiadc_suspend(struct device *dev)
>  
>  	idle = tiadc_readl(adc_dev, REG_CTRL);
>  	idle &= ~(CNTRLREG_SSENB);
> -	tiadc_writel(adc_dev, REG_CTRL, (idle |
> -			CNTRLREG_POWERDOWN));
> +	tiadc_writel(adc_dev, REG_CTRL, idle | CNTRLREG_POWERDOWN);
>  
>  	return 0;
>  }
> @@ -678,12 +678,12 @@ static int __maybe_unused tiadc_resume(struct device *dev)
>  
>  	/* Make sure ADC is powered up */
>  	restore = tiadc_readl(adc_dev, REG_CTRL);
> -	restore &= ~(CNTRLREG_POWERDOWN);
> +	restore &= ~CNTRLREG_POWERDOWN;
>  	tiadc_writel(adc_dev, REG_CTRL, restore);
>  
>  	tiadc_step_config(indio_dev);
>  	am335x_tsc_se_set_cache(adc_dev->mfd_tscadc,
> -			adc_dev->buffer_en_ch_steps);
> +				adc_dev->buffer_en_ch_steps);
>  	return 0;
>  }
>  


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

* Re: [PATCH 32/40] iio: adc: ti_am335x_adc: Get rid of useless gotos
  2021-08-25 15:25 ` [PATCH 32/40] iio: adc: ti_am335x_adc: Get rid of useless gotos Miquel Raynal
@ 2021-08-30 14:18   ` Jonathan Cameron
  0 siblings, 0 replies; 88+ messages in thread
From: Jonathan Cameron @ 2021-08-30 14:18 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk

On Wed, 25 Aug 2021 17:25:10 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> Gotos jumping to a return statement are not really useful, drop them.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> ---
>  drivers/iio/adc/ti_am335x_adc.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
> index dd2200d2f214..00bbf557e86c 100644
> --- a/drivers/iio/adc/ti_am335x_adc.c
> +++ b/drivers/iio/adc/ti_am335x_adc.c
> @@ -616,11 +616,11 @@ static int tiadc_probe(struct platform_device *pdev)
>  						IRQF_SHARED,
>  						&tiadc_buffer_setup_ops);
>  	if (err)
> -		goto err_free_channels;
> +		return err;
>  
>  	err = iio_device_register(indio_dev);
>  	if (err)
> -		goto err_buffer_unregister;
> +		return err;
>  
>  	platform_set_drvdata(pdev, indio_dev);
>  
> @@ -632,8 +632,7 @@ static int tiadc_probe(struct platform_device *pdev)
>  
>  err_dma:
>  	iio_device_unregister(indio_dev);
> -err_buffer_unregister:
> -err_free_channels:
> +
>  	return err;
>  }
>  


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

* Re: [PATCH 33/40] iio: adc: ti_am335x_adc: Gather the checks on the delays
  2021-08-25 15:25 ` [PATCH 33/40] iio: adc: ti_am335x_adc: Gather the checks on the delays Miquel Raynal
@ 2021-08-30 14:19   ` Jonathan Cameron
  0 siblings, 0 replies; 88+ messages in thread
From: Jonathan Cameron @ 2021-08-30 14:19 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk

On Wed, 25 Aug 2021 17:25:11 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> Move the checks over the delays provided in the device tree to the
> location where these values are read to clarify where they come from.
> 
> There are no functional changes besides the device structure used to
> display the warnings: let's use the ADC instead of the MFD device.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> ---
>  drivers/iio/adc/ti_am335x_adc.c | 47 +++++++++++++++++++--------------
>  1 file changed, 27 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
> index 00bbf557e86c..4eaf5b031707 100644
> --- a/drivers/iio/adc/ti_am335x_adc.c
> +++ b/drivers/iio/adc/ti_am335x_adc.c
> @@ -97,7 +97,6 @@ static u32 get_adc_step_bit(struct tiadc_device *adc_dev, int chan)
>  static void tiadc_step_config(struct iio_dev *indio_dev)
>  {
>  	struct tiadc_device *adc_dev = iio_priv(indio_dev);
> -	struct device *dev = adc_dev->mfd_tscadc->dev;
>  	unsigned int stepconfig;
>  	int i, steps = 0;
>  
> @@ -115,12 +114,6 @@ static void tiadc_step_config(struct iio_dev *indio_dev)
>  
>  		chan = adc_dev->channel_line[i];
>  
> -		if (adc_dev->step_avg[i] > STEPCONFIG_AVG_16) {
> -			dev_warn(dev, "chan %d step_avg truncating to %d\n",
> -				 chan, STEPCONFIG_AVG_16);
> -			adc_dev->step_avg[i] = STEPCONFIG_AVG_16;
> -		}
> -
>  		if (adc_dev->step_avg[i])
>  			stepconfig = STEPCONFIG_AVG(ffs(adc_dev->step_avg[i]) - 1) |
>  				     STEPCONFIG_FIFO1;
> @@ -135,18 +128,6 @@ static void tiadc_step_config(struct iio_dev *indio_dev)
>  			     STEPCONFIG_INM_ADCREFM | STEPCONFIG_RFP_VREFP |
>  			     STEPCONFIG_RFM_VREFN);
>  
> -		if (adc_dev->open_delay[i] > STEPDELAY_OPEN_MASK) {
> -			dev_warn(dev, "chan %d open delay truncating to 0x3FFFF\n",
> -				 chan);
> -			adc_dev->open_delay[i] = STEPDELAY_OPEN_MASK;
> -		}
> -
> -		if (adc_dev->sample_delay[i] > 0xFF) {
> -			dev_warn(dev, "chan %d sample delay truncating to 0xFF\n",
> -				 chan);
> -			adc_dev->sample_delay[i] = 0xFF;
> -		}
> -
>  		tiadc_writel(adc_dev, REG_STEPDELAY(steps),
>  			     STEPDELAY_OPEN(adc_dev->open_delay[i]) |
>  			     STEPDELAY_SAMPLE(adc_dev->sample_delay[i]));
> @@ -552,6 +533,7 @@ static int tiadc_parse_dt(struct platform_device *pdev,
>  	const __be32 *cur;
>  	int channels = 0;
>  	u32 val;
> +	int i;
>  
>  	of_property_for_each_u32(node, "ti,adc-channels", prop, cur, val) {
>  		adc_dev->channel_line[channels] = val;
> @@ -564,6 +546,8 @@ static int tiadc_parse_dt(struct platform_device *pdev,
>  		channels++;
>  	}
>  
> +	adc_dev->channels = channels;
> +
>  	of_property_read_u32_array(node, "ti,chan-step-avg",
>  				   adc_dev->step_avg, channels);
>  	of_property_read_u32_array(node, "ti,chan-step-opendelay",
> @@ -571,7 +555,30 @@ static int tiadc_parse_dt(struct platform_device *pdev,
>  	of_property_read_u32_array(node, "ti,chan-step-sampledelay",
>  				   adc_dev->sample_delay, channels);
>  
> -	adc_dev->channels = channels;
> +	for (i = 0; i < adc_dev->channels; i++) {
> +		int chan;
> +
> +		chan = adc_dev->channel_line[i];
> +
> +		if (adc_dev->step_avg[i] > STEPCONFIG_AVG_16) {
> +			dev_warn(&pdev->dev, "chan %d step_avg truncating to %d\n",
> +				 chan, STEPCONFIG_AVG_16);
> +			adc_dev->step_avg[i] = STEPCONFIG_AVG_16;
> +		}
> +
> +		if (adc_dev->open_delay[i] > STEPDELAY_OPEN_MASK) {
> +			dev_warn(&pdev->dev, "chan %d open delay truncating to 0x3FFFF\n",
> +				 chan);
> +			adc_dev->open_delay[i] = STEPDELAY_OPEN_MASK;
> +		}
> +
> +		if (adc_dev->sample_delay[i] > 0xFF) {
> +			dev_warn(&pdev->dev, "chan %d sample delay truncating to 0xFF\n",
> +				 chan);
> +			adc_dev->sample_delay[i] = 0xFF;
> +		}
> +	}
> +
>  	return 0;
>  }
>  


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

* Re: [PATCH 34/40] iio: adc: ti_am335x_adc: Add a unit to the timeout delay
  2021-08-25 15:25 ` [PATCH 34/40] iio: adc: ti_am335x_adc: Add a unit to the timeout delay Miquel Raynal
@ 2021-08-30 14:20   ` Jonathan Cameron
  0 siblings, 0 replies; 88+ messages in thread
From: Jonathan Cameron @ 2021-08-30 14:20 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk

On Wed, 25 Aug 2021 17:25:12 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> The lack of unit in the macro name kind of tricked me when I was
> troubleshooting an issue. Physical constants should always get a unit.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>

Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> ---
>  drivers/iio/adc/ti_am335x_adc.c      | 2 +-
>  include/linux/mfd/ti_am335x_tscadc.h | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
> index 4eaf5b031707..ebf6326af60d 100644
> --- a/drivers/iio/adc/ti_am335x_adc.c
> +++ b/drivers/iio/adc/ti_am335x_adc.c
> @@ -441,7 +441,7 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
>  	am335x_tsc_se_set_once(adc_dev->mfd_tscadc, step_en);
>  
>  	/* Wait for Fifo threshold interrupt */
> -	timeout = jiffies + msecs_to_jiffies(IDLE_TIMEOUT * adc_dev->channels);
> +	timeout = jiffies + msecs_to_jiffies(IDLE_TIMEOUT_MS * adc_dev->channels);
>  	while (1) {
>  		fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT);
>  		if (fifo1count)
> diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h
> index 31b22ec567e7..177ab2499200 100644
> --- a/include/linux/mfd/ti_am335x_tscadc.h
> +++ b/include/linux/mfd/ti_am335x_tscadc.h
> @@ -164,7 +164,7 @@
>   *
>   * max processing time: 266431 * 308ns = 83ms(approx)
>   */
> -#define IDLE_TIMEOUT 83 /* milliseconds */
> +#define IDLE_TIMEOUT_MS 83 /* milliseconds */
>  
>  #define TSCADC_CELLS		2
>  


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

* Re: [PATCH 35/40] iio: adc: ti_am335x_adc: Wait the idle state to avoid stalls
  2021-08-25 15:25 ` [PATCH 35/40] iio: adc: ti_am335x_adc: Wait the idle state to avoid stalls Miquel Raynal
@ 2021-08-30 14:22   ` Jonathan Cameron
  0 siblings, 0 replies; 88+ messages in thread
From: Jonathan Cameron @ 2021-08-30 14:22 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk

On Wed, 25 Aug 2021 17:25:13 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> A simple:
> $ cat /sys/bus/iio/devices/iio\:deviceX/in_voltage*_raw
> can stall forever. It seems that it comes from the fact that the
> internal state machine does not have enough time to return to its idle
> state in this situation before receiving another request, leading to an
> internal stall.

Interesting and non obvious... Good work figuring that out.

> 
> Add a tiadc_wait_idle() helper to ensure no new conversion is requested
> while the FSM is still busy.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>

Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> ---
>  drivers/iio/adc/ti_am335x_adc.c | 24 ++++++++++++++++++++++--
>  1 file changed, 22 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
> index ebf6326af60d..d4619fd6fd54 100644
> --- a/drivers/iio/adc/ti_am335x_adc.c
> +++ b/drivers/iio/adc/ti_am335x_adc.c
> @@ -17,6 +17,7 @@
>  #include <linux/of_device.h>
>  #include <linux/iio/machine.h>
>  #include <linux/iio/driver.h>
> +#include <linux/iopoll.h>
>  
>  #include <linux/mfd/ti_am335x_tscadc.h>
>  #include <linux/iio/buffer.h>
> @@ -94,6 +95,15 @@ static u32 get_adc_step_bit(struct tiadc_device *adc_dev, int chan)
>  	return 1 << adc_dev->channel_step[chan];
>  }
>  
> +static int tiadc_wait_idle(struct tiadc_device *adc_dev)
> +{
> +	u32 val;
> +
> +	return readl_poll_timeout(adc_dev->mfd_tscadc->tscadc_base + REG_ADCFSM,
> +				  val, !(val & SEQ_STATUS), 10,
> +				  IDLE_TIMEOUT_MS * 1000 * adc_dev->channels);
> +}
> +
>  static void tiadc_step_config(struct iio_dev *indio_dev)
>  {
>  	struct tiadc_device *adc_dev = iio_priv(indio_dev);
> @@ -268,6 +278,11 @@ static int tiadc_buffer_preenable(struct iio_dev *indio_dev)
>  {
>  	struct tiadc_device *adc_dev = iio_priv(indio_dev);
>  	int i, fifo1count;
> +	int ret;
> +
> +	ret = tiadc_wait_idle(adc_dev);
> +	if (ret)
> +		return ret;
>  
>  	tiadc_writel(adc_dev, REG_IRQCLR,
>  		     IRQENB_FIFO1THRES | IRQENB_FIFO1OVRRUN |
> @@ -419,12 +434,12 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
>  			  long mask)
>  {
>  	struct tiadc_device *adc_dev = iio_priv(indio_dev);
> -	int ret = IIO_VAL_INT;
>  	int i, map_val;
>  	unsigned int fifo1count, read, stepid;
>  	bool found = false;
>  	u32 step_en;
>  	unsigned long timeout;
> +	int ret;
>  
>  	if (iio_buffer_enabled(indio_dev))
>  		return -EBUSY;
> @@ -434,6 +449,11 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
>  		return -EINVAL;
>  
>  	mutex_lock(&adc_dev->fifo1_lock);
> +
> +	ret = tiadc_wait_idle(adc_dev);
> +	if (ret)
> +		goto err_unlock;
> +
>  	fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT);
>  	while (fifo1count--)
>  		tiadc_readl(adc_dev, REG_FIFO1);
> @@ -482,7 +502,7 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
>  
>  err_unlock:
>  	mutex_unlock(&adc_dev->fifo1_lock);
> -	return ret;
> +	return ret ? ret : IIO_VAL_INT;
>  }
>  
>  static const struct iio_info tiadc_info = {


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

* Re: [PATCH 36/40] iio: adc: ti_am335x_adc: Add the scale information
  2021-08-25 15:25 ` [PATCH 36/40] iio: adc: ti_am335x_adc: Add the scale information Miquel Raynal
@ 2021-08-30 14:23   ` Jonathan Cameron
  0 siblings, 0 replies; 88+ messages in thread
From: Jonathan Cameron @ 2021-08-30 14:23 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk

On Wed, 25 Aug 2021 17:25:14 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> Without the scale, the values returned to the user are just a picture of
> the input voltage against the full scale range of the ADC. We need to
> provide the actual conversion factor to get milli-Volts values.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Odd no one did this before, but such is life ;)

Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> ---
>  drivers/iio/adc/ti_am335x_adc.c | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
> index d4619fd6fd54..f644898b47dd 100644
> --- a/drivers/iio/adc/ti_am335x_adc.c
> +++ b/drivers/iio/adc/ti_am335x_adc.c
> @@ -417,6 +417,7 @@ static int tiadc_channel_init(struct device *dev, struct iio_dev *indio_dev,
>  		chan->indexed = 1;
>  		chan->channel = adc_dev->channel_line[i];
>  		chan->info_mask_separate = BIT(IIO_CHAN_INFO_RAW);
> +		chan->info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE);
>  		chan->datasheet_name = chan_name_ain[chan->channel];
>  		chan->scan_index = i;
>  		chan->scan_type.sign = 'u';
> @@ -441,6 +442,23 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
>  	unsigned long timeout;
>  	int ret;
>  
> +	switch (mask) {
> +	case IIO_CHAN_INFO_RAW:
> +		break;
> +	case IIO_CHAN_INFO_SCALE:
> +		switch (chan->type) {
> +		case IIO_VOLTAGE:
> +			*val = 1800;
> +			*val2 = chan->scan_type.realbits;
> +			return IIO_VAL_FRACTIONAL_LOG2;
> +		default:
> +			return -EINVAL;
> +		}
> +		break;
> +	default:
> +		return -EINVAL;
> +	}
> +
>  	if (iio_buffer_enabled(indio_dev))
>  		return -EBUSY;
>  


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

* Re: [PATCH 37/40] iio: adc: ti_am335x_adc: Add the am437x compatible
  2021-08-25 15:25 ` [PATCH 37/40] iio: adc: ti_am335x_adc: Add the am437x compatible Miquel Raynal
@ 2021-08-30 14:24   ` Jonathan Cameron
  0 siblings, 0 replies; 88+ messages in thread
From: Jonathan Cameron @ 2021-08-30 14:24 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk

On Wed, 25 Aug 2021 17:25:15 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> This driver supports both the legacy controller (am33xx) and the
> extended one (am437x), so let's add a new compatible.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> ---
>  drivers/iio/adc/ti_am335x_adc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
> index f644898b47dd..ad79236e2bce 100644
> --- a/drivers/iio/adc/ti_am335x_adc.c
> +++ b/drivers/iio/adc/ti_am335x_adc.c
> @@ -735,6 +735,7 @@ static SIMPLE_DEV_PM_OPS(tiadc_pm_ops, tiadc_suspend, tiadc_resume);
>  
>  static const struct of_device_id ti_adc_dt_ids[] = {
>  	{ .compatible = "ti,am3359-adc", },
> +	{ .compatible = "ti,am4372-adc", },
>  	{ }
>  };
>  MODULE_DEVICE_TABLE(of, ti_adc_dt_ids);


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

* Re: [PATCH 12/40] mfd: ti_am335x_tscadc: Move the driver structure allocation earlier
  2021-08-25 15:24 ` [PATCH 12/40] mfd: ti_am335x_tscadc: Move the driver structure allocation earlier Miquel Raynal
@ 2021-08-30 14:25   ` Jonathan Cameron
  0 siblings, 0 replies; 88+ messages in thread
From: Jonathan Cameron @ 2021-08-30 14:25 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk

On Wed, 25 Aug 2021 17:24:50 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> Allocating the driver structure should be done earlier in the probe so
> that we can used its members from the beginning.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
No problem with this, but I would expect either this patch or the one
immediately after it to actually take advantage of this being
available earlier in probe().
As things stand it's not clear to a reviewer that this is actually
a useful bit of refactoring.

> ---
>  drivers/mfd/ti_am335x_tscadc.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
> index 8e86b766b619..0fef35e1e64b 100644
> --- a/drivers/mfd/ti_am335x_tscadc.c
> +++ b/drivers/mfd/ti_am335x_tscadc.c
> @@ -124,6 +124,13 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  	int tsc_wires = 0, adc_channels = 0, readouts = 0;
>  	int total_channels, clock_rate, ctrl, err;
>  
> +	/* Allocate memory for device */
> +	tscadc = devm_kzalloc(&pdev->dev, sizeof(*tscadc), GFP_KERNEL);
> +	if (!tscadc)
> +		return -ENOMEM;
> +
> +	tscadc->dev = &pdev->dev;
> +
>  	if (!pdev->dev.of_node) {
>  		dev_err(&pdev->dev, "Could not find valid DT data.\n");
>  		return -EINVAL;
> @@ -159,13 +166,6 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  		return -EINVAL;
>  	}
>  
> -	/* Allocate memory for device */
> -	tscadc = devm_kzalloc(&pdev->dev, sizeof(*tscadc), GFP_KERNEL);
> -	if (!tscadc)
> -		return -ENOMEM;
> -
> -	tscadc->dev = &pdev->dev;
> -
>  	err = platform_get_irq(pdev, 0);
>  	if (err < 0) {
>  		dev_err(&pdev->dev, "no irq ID is specified.\n");


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

* Re: [PATCH 16/40] mfd: ti_am335x_tscadc: Use driver data
  2021-08-25 15:24 ` [PATCH 16/40] mfd: ti_am335x_tscadc: Use driver data Miquel Raynal
@ 2021-08-30 14:46   ` Jonathan Cameron
  0 siblings, 0 replies; 88+ messages in thread
From: Jonathan Cameron @ 2021-08-30 14:46 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk, Jason Reeder

On Wed, 25 Aug 2021 17:24:54 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> So far every sub-cell parameter in this driver was hardcoded: cell name,
> cell compatible, specific clock name and desired clock frequency.
> 
> As we are about to introduce support for ADC1/magnetic reader, we need a
> bit of flexibility. Let's add a driver data structure which will contain
> these information.
> 
> Co-developed-by: Jason Reeder <jreeder@ti.com>
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> Signed-off-by: Jason Reeder <jreeder@ti.com>
> ---
>  drivers/mfd/ti_am335x_tscadc.c       | 20 +++++++++++++++-----
>  include/linux/mfd/ti_am335x_tscadc.h |  9 +++++++++
>  2 files changed, 24 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
> index 3231ccbbad02..0cea44b4bd1a 100644
> --- a/drivers/mfd/ti_am335x_tscadc.c
> +++ b/drivers/mfd/ti_am335x_tscadc.c
> @@ -136,6 +136,8 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  		return -EINVAL;
>  	}
>  
> +	tscadc->data = of_device_get_match_data(&pdev->dev);

As mentioned in later patch, I can't see that you actually wired this up here.
match_data doesn't seem to be set.

Otherwise looks fine to me.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>



> +
>  	node = of_get_child_by_name(pdev->dev.of_node, "tsc");
>  	of_property_read_u32(node, "ti,wires", &tsc_wires);
>  	of_property_read_u32(node, "ti,coordiante-readouts", &readouts);
> @@ -209,7 +211,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  		goto err_disable_clk;
>  	}
>  
> -	tscadc->clk_div = (clk_get_rate(clk) / ADC_CLK) - 1;
> +	tscadc->clk_div = (clk_get_rate(clk) / tscadc->data->target_clk_rate) - 1;
>  	regmap_write(tscadc->regmap, REG_CLKDIV, tscadc->clk_div);
>  
>  	/* Set the control register bits */
> @@ -238,8 +240,8 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  	if (tsc_wires > 0) {
>  		tscadc->tsc_cell = tscadc->used_cells;
>  		cell = &tscadc->cells[tscadc->used_cells++];
> -		cell->name = "TI-am335x-tsc";
> -		cell->of_compatible = "ti,am3359-tsc";
> +		cell->name = tscadc->data->name_tscmag;
> +		cell->of_compatible = tscadc->data->compat_tscmag;
>  		cell->platform_data = &tscadc;
>  		cell->pdata_size = sizeof(tscadc);
>  	}
> @@ -248,8 +250,8 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  	if (adc_channels > 0) {
>  		tscadc->adc_cell = tscadc->used_cells;
>  		cell = &tscadc->cells[tscadc->used_cells++];
> -		cell->name = "TI-am335x-adc";
> -		cell->of_compatible = "ti,am3359-adc";
> +		cell->name = tscadc->data->name_adc;
> +		cell->of_compatible = tscadc->data->compat_adc;
>  		cell->platform_data = &tscadc;
>  		cell->pdata_size = sizeof(tscadc);
>  	}
> @@ -335,6 +337,14 @@ static int __maybe_unused tscadc_resume(struct device *dev)
>  
>  static SIMPLE_DEV_PM_OPS(tscadc_pm_ops, tscadc_suspend, tscadc_resume);
>  
> +static const struct ti_tscadc_data tscdata = {
> +	.name_tscmag = "TI-am335x-tsc",
> +	.compat_tscmag = "ti,am3359-tsc",
> +	.name_adc = "TI-am335x-adc",
> +	.compat_adc = "ti,am3359-adc",
> +	.target_clk_rate = ADC_CLK,
> +};
> +
>  static const struct of_device_id ti_tscadc_dt_ids[] = {
>  	{ .compatible = "ti,am3359-tscadc", },
>  	{ }
> diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h
> index ffc091b77633..0f581c15d95a 100644
> --- a/include/linux/mfd/ti_am335x_tscadc.h
> +++ b/include/linux/mfd/ti_am335x_tscadc.h
> @@ -162,11 +162,20 @@
>  
>  #define TSCADC_CELLS		2
>  
> +struct ti_tscadc_data {
> +	char *name_tscmag;
> +	char *compat_tscmag;
> +	char *name_adc;
> +	char *compat_adc;
> +	unsigned int target_clk_rate;
> +};
> +
>  struct ti_tscadc_dev {
>  	struct device *dev;
>  	struct regmap *regmap;
>  	void __iomem *tscadc_base;
>  	phys_addr_t tscadc_phys_base;
> +	const struct ti_tscadc_data *data;
>  	int irq;
>  	int used_cells;	/* 1-2 */
>  	int tsc_wires;


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

* Re: [PATCH 19/40] mfd: ti_am335x_tscadc: Always provide an idle configuration
  2021-08-25 15:24 ` [PATCH 19/40] mfd: ti_am335x_tscadc: Always provide an idle configuration Miquel Raynal
@ 2021-08-30 14:49   ` Jonathan Cameron
  0 siblings, 0 replies; 88+ messages in thread
From: Jonathan Cameron @ 2021-08-30 14:49 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk

On Wed, 25 Aug 2021 17:24:57 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> The idle register is valid no matter if the touchscreen is used or not,
> let's always configure it.
Probably want a statement in here about the reordering that occurred in resume.

J

> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> ---
>  drivers/mfd/ti_am335x_tscadc.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
> index 258199be4c6a..7071344ad18e 100644
> --- a/drivers/mfd/ti_am335x_tscadc.c
> +++ b/drivers/mfd/ti_am335x_tscadc.c
> @@ -218,16 +218,16 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  	ctrl = CNTRLREG_STEPCONFIGWRT |	CNTRLREG_STEPID;
>  	regmap_write(tscadc->regmap, REG_CTRL, ctrl);
>  
> -	/* Set register bits for Idle Config Mode */
>  	if (tsc_wires > 0) {
>  		tscadc->tsc_wires = tsc_wires;
>  		if (tsc_wires == 5)
>  			ctrl |= CNTRLREG_5WIRE | CNTRLREG_TSCENB;
>  		else
>  			ctrl |= CNTRLREG_4WIRE | CNTRLREG_TSCENB;
> -		tscadc_idle_config(tscadc);
>  	}
>  
> +	tscadc_idle_config(tscadc);
> +
>  	/* Enable the TSC module enable bit */
>  	ctrl |= CNTRLREG_TSCSSENB;
>  	regmap_write(tscadc->regmap, REG_CTRL, ctrl);
> @@ -318,12 +318,12 @@ static int __maybe_unused tscadc_resume(struct device *dev)
>  			ctrl |= CNTRLREG_5WIRE | CNTRLREG_TSCENB;
>  		else
>  			ctrl |= CNTRLREG_4WIRE | CNTRLREG_TSCENB;
> -		tscadc_idle_config(tscadc);
>  	}
>  	ctrl |= CNTRLREG_TSCSSENB;
>  	regmap_write(tscadc->regmap, REG_CTRL, ctrl);
>  
>  	regmap_write(tscadc->regmap, REG_CLKDIV, tscadc->clk_div);
> +	tscadc_idle_config(tscadc);
>  
>  	return 0;
>  }


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

* Re: [PATCH 21/40] mfd: ti_am335x_tscadc: Rename the subsystem enable macro
  2021-08-25 15:24 ` [PATCH 21/40] mfd: ti_am335x_tscadc: Rename the subsystem enable macro Miquel Raynal
@ 2021-08-30 14:50   ` Jonathan Cameron
  0 siblings, 0 replies; 88+ messages in thread
From: Jonathan Cameron @ 2021-08-30 14:50 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk

On Wed, 25 Aug 2021 17:24:59 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> This bit is common to all devices (ADC, Touchscreen, Magnetic reader) so
> make it clear that it can be used from any location by operating a
> mechanical rename:
> s/CNTRLREG_TSCSSENB/CNTRLREG_SSENB/
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
I don't feel strongly either way on this one but if you feel it's a good idea fair enough.

Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> ---
>  drivers/iio/adc/ti_am335x_adc.c      | 6 +++---
>  drivers/mfd/ti_am335x_tscadc.c       | 6 +++---
>  include/linux/mfd/ti_am335x_tscadc.h | 2 +-
>  3 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
> index 855cc2d64ac8..f748d49f10f4 100644
> --- a/drivers/iio/adc/ti_am335x_adc.c
> +++ b/drivers/iio/adc/ti_am335x_adc.c
> @@ -184,7 +184,7 @@ static irqreturn_t tiadc_irq_h(int irq, void *private)
>  	if (status & IRQENB_FIFO1OVRRUN) {
>  		/* FIFO Overrun. Clear flag. Disable/Enable ADC to recover */
>  		config = tiadc_readl(adc_dev, REG_CTRL);
> -		config &= ~(CNTRLREG_TSCSSENB);
> +		config &= ~(CNTRLREG_SSENB);
>  		tiadc_writel(adc_dev, REG_CTRL, config);
>  		tiadc_writel(adc_dev, REG_IRQSTATUS, IRQENB_FIFO1OVRRUN
>  				| IRQENB_FIFO1UNDRFLW | IRQENB_FIFO1THRES);
> @@ -197,7 +197,7 @@ static irqreturn_t tiadc_irq_h(int irq, void *private)
>  			adc_fsm = tiadc_readl(adc_dev, REG_ADCFSM);
>  		} while (adc_fsm != 0x10 && count++ < 100);
>  
> -		tiadc_writel(adc_dev, REG_CTRL, (config | CNTRLREG_TSCSSENB));
> +		tiadc_writel(adc_dev, REG_CTRL, (config | CNTRLREG_SSENB));
>  		return IRQ_HANDLED;
>  	} else if (status & IRQENB_FIFO1THRES) {
>  		/* Disable irq and wake worker thread */
> @@ -671,7 +671,7 @@ static int __maybe_unused tiadc_suspend(struct device *dev)
>  	unsigned int idle;
>  
>  	idle = tiadc_readl(adc_dev, REG_CTRL);
> -	idle &= ~(CNTRLREG_TSCSSENB);
> +	idle &= ~(CNTRLREG_SSENB);
>  	tiadc_writel(adc_dev, REG_CTRL, (idle |
>  			CNTRLREG_POWERDOWN));
>  
> diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
> index d661e8ae66c9..dd303523f9a3 100644
> --- a/drivers/mfd/ti_am335x_tscadc.c
> +++ b/drivers/mfd/ti_am335x_tscadc.c
> @@ -229,7 +229,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  	tscadc_idle_config(tscadc);
>  
>  	/* Enable the TSC module enable bit */
> -	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl | CNTRLREG_TSCSSENB);
> +	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl | CNTRLREG_SSENB);
>  
>  	/* TSC Cell */
>  	if (tsc_wires > 0) {
> @@ -293,7 +293,7 @@ static int __maybe_unused tscadc_suspend(struct device *dev)
>  
>  		regmap_read(tscadc->regmap, REG_CTRL, &ctrl);
>  		ctrl &= ~(CNTRLREG_POWERDOWN);
> -		ctrl |= CNTRLREG_TSCSSENB;
> +		ctrl |= CNTRLREG_SSENB;
>  		regmap_write(tscadc->regmap, REG_CTRL, ctrl);
>  	}
>  	pm_runtime_put_sync(dev);
> @@ -310,7 +310,7 @@ static int __maybe_unused tscadc_resume(struct device *dev)
>  	regmap_write(tscadc->regmap, REG_CLKDIV, tscadc->clk_div);
>  	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl);
>  	tscadc_idle_config(tscadc);
> -	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl | CNTRLREG_TSCSSENB);
> +	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl | CNTRLREG_SSENB);
>  
>  	return 0;
>  }
> diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h
> index 02963b6ebbac..a900fae8354c 100644
> --- a/include/linux/mfd/ti_am335x_tscadc.h
> +++ b/include/linux/mfd/ti_am335x_tscadc.h
> @@ -118,7 +118,7 @@
>  #define CHARGEDLY_OPENDLY	CHARGEDLY_OPEN(0x400)
>  
>  /* Control register */
> -#define CNTRLREG_TSCSSENB	BIT(0)
> +#define CNTRLREG_SSENB		BIT(0)
>  #define CNTRLREG_STEPID		BIT(1)
>  #define CNTRLREG_STEPCONFIGWRT	BIT(2)
>  #define CNTRLREG_POWERDOWN	BIT(4)


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

* Re: [PATCH 22/40] mfd: ti_am335x_tscadc: Add TSC prefix in certain macros
  2021-08-25 15:25 ` [PATCH 22/40] mfd: ti_am335x_tscadc: Add TSC prefix in certain macros Miquel Raynal
@ 2021-08-30 14:52   ` Jonathan Cameron
  0 siblings, 0 replies; 88+ messages in thread
From: Jonathan Cameron @ 2021-08-30 14:52 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk

On Wed, 25 Aug 2021 17:25:00 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> While the register list (and names) between ADC0 and ADC1 are pretty
> close, the bits inside changed a little bit. To avoid any future
> confusion, let's add the TSC prefix when some bits are in a register
> that is common to both revisions of the ADC, but are specific to the
> am33xx hardware.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
A few things inline that aren't strictly related to this patch, but might be
nice to tidy up whilst you are here.

Jonathan

> ---
>  drivers/mfd/ti_am335x_tscadc.c       | 10 +++++-----
>  include/linux/mfd/ti_am335x_tscadc.h | 16 ++++++++--------
>  2 files changed, 13 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
> index dd303523f9a3..02477ce827d0 100644
> --- a/drivers/mfd/ti_am335x_tscadc.c
> +++ b/drivers/mfd/ti_am335x_tscadc.c
> @@ -215,15 +215,15 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  	regmap_write(tscadc->regmap, REG_CLKDIV, tscadc->clk_div);
>  
>  	/* Set the control register bits */
> -	tscadc->ctrl = CNTRLREG_STEPCONFIGWRT | CNTRLREG_STEPID;
> +	tscadc->ctrl = CNTRLREG_TSC_STEPCONFIGWRT | CNTRLREG_STEPID;
>  	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl);
>  
>  	if (tsc_wires > 0) {
> -		tscadc->ctrl |= CNTRLREG_TSCENB;
> +		tscadc->ctrl |= CNTRLREG_TSC_ENB;
>  		if (tsc_wires == 5)
> -			tscadc->ctrl |= CNTRLREG_5WIRE;
> +			tscadc->ctrl |= CNTRLREG_TSC_5WIRE;
>  		else
> -			tscadc->ctrl |= CNTRLREG_4WIRE;
> +			tscadc->ctrl |= CNTRLREG_TSC_4WIRE;
>  	}
>  
>  	tscadc_idle_config(tscadc);
> @@ -322,7 +322,7 @@ static const struct ti_tscadc_data tscdata = {
>  	.compat_tscmag = "ti,am3359-tsc",
>  	.name_adc = "TI-am335x-adc",
>  	.compat_adc = "ti,am3359-adc",
> -	.target_clk_rate = ADC_CLK,
> +	.target_clk_rate = TSC_ADC_CLK,
>  };
>  
>  static const struct of_device_id ti_tscadc_dt_ids[] = {
> diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h
> index a900fae8354c..d5e2ff8dc84a 100644
> --- a/include/linux/mfd/ti_am335x_tscadc.h
> +++ b/include/linux/mfd/ti_am335x_tscadc.h
> @@ -120,14 +120,14 @@
>  /* Control register */
>  #define CNTRLREG_SSENB		BIT(0)
>  #define CNTRLREG_STEPID		BIT(1)
> -#define CNTRLREG_STEPCONFIGWRT	BIT(2)
> +#define CNTRLREG_TSC_STEPCONFIGWRT BIT(2)
>  #define CNTRLREG_POWERDOWN	BIT(4)
> -#define CNTRLREG_AFE_CTRL_MASK	(3 << 5)
> -#define CNTRLREG_AFE_CTRL(val)	((val) << 5)
> -#define CNTRLREG_4WIRE		CNTRLREG_AFE_CTRL(1)
> -#define CNTRLREG_5WIRE		CNTRLREG_AFE_CTRL(2)
> -#define CNTRLREG_8WIRE		CNTRLREG_AFE_CTRL(3)
> -#define CNTRLREG_TSCENB		BIT(7)
> +#define CNTRLREG_TSC_AFE_CTRL_MASK (3 << 5)

Nicer to use GENMASK for masks.

> +#define CNTRLREG_TSC_AFE_CTRL(val) ((val) << 5)

If you are going to touch this, perhaps a good time to move to
FIELD_PREP().

> +#define CNTRLREG_TSC_4WIRE	CNTRLREG_TSC_AFE_CTRL(1)
> +#define CNTRLREG_TSC_5WIRE	CNTRLREG_TSC_AFE_CTRL(2)
> +#define CNTRLREG_TSC_8WIRE	CNTRLREG_TSC_AFE_CTRL(3)
> +#define CNTRLREG_TSC_ENB	BIT(7)
>  
>  /* FIFO READ Register */
>  #define FIFOREAD_DATA_MASK (0xfff << 0)
> @@ -141,7 +141,7 @@
>  #define SEQ_STATUS BIT(5)
>  #define CHARGE_STEP		0x11
>  
> -#define ADC_CLK			3000000
> +#define TSC_ADC_CLK		3000000
>  #define TOTAL_STEPS		16
>  #define TOTAL_CHANNELS		8
>  #define FIFO1_THRESHOLD		19


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

* Re: [PATCH 23/40] mfd: ti_am335x_tscadc: Rename a variable
  2021-08-25 15:25 ` [PATCH 23/40] mfd: ti_am335x_tscadc: Rename a variable Miquel Raynal
@ 2021-08-30 14:53   ` Jonathan Cameron
  0 siblings, 0 replies; 88+ messages in thread
From: Jonathan Cameron @ 2021-08-30 14:53 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk

On Wed, 25 Aug 2021 17:25:01 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> We need to retrieve the number of wires used by the "secondary" device
> (the touchscreen or the magnetic reader). Let's rename tsc_wires to
> become tscmag_wires to clarify the fact that this variable can be used
> in both situations.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Seems sensible.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

> ---
>  drivers/mfd/ti_am335x_tscadc.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
> index 02477ce827d0..047426a74a2e 100644
> --- a/drivers/mfd/ti_am335x_tscadc.c
> +++ b/drivers/mfd/ti_am335x_tscadc.c
> @@ -121,7 +121,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  	const __be32 *cur;
>  	struct clk *clk;
>  	u32 val;
> -	int tsc_wires = 0, adc_channels = 0, readouts = 0, cell_idx = 0;
> +	int tscmag_wires = 0, adc_channels = 0, readouts = 0, cell_idx = 0;
>  	int total_channels, err;
>  
>  	/* Allocate memory for device */
> @@ -139,7 +139,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  	tscadc->data = of_device_get_match_data(&pdev->dev);
>  
>  	node = of_get_child_by_name(pdev->dev.of_node, "tsc");
> -	of_property_read_u32(node, "ti,wires", &tsc_wires);
> +	of_property_read_u32(node, "ti,wires", &tscmag_wires);
>  	of_property_read_u32(node, "ti,coordiante-readouts", &readouts);
>  
>  	node = of_get_child_by_name(pdev->dev.of_node, "adc");
> @@ -152,7 +152,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  		}
>  	}
>  
> -	total_channels = tsc_wires + adc_channels;
> +	total_channels = tscmag_wires + adc_channels;
>  	if (total_channels > 8) {
>  		dev_err(&pdev->dev, "Number of i/p channels more than 8\n");
>  		return -EINVAL;
> @@ -218,9 +218,9 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  	tscadc->ctrl = CNTRLREG_TSC_STEPCONFIGWRT | CNTRLREG_STEPID;
>  	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl);
>  
> -	if (tsc_wires > 0) {
> +	if (tscmag_wires > 0) {
>  		tscadc->ctrl |= CNTRLREG_TSC_ENB;
> -		if (tsc_wires == 5)
> +		if (tscmag_wires == 5)
>  			tscadc->ctrl |= CNTRLREG_TSC_5WIRE;
>  		else
>  			tscadc->ctrl |= CNTRLREG_TSC_4WIRE;
> @@ -232,7 +232,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl | CNTRLREG_SSENB);
>  
>  	/* TSC Cell */
> -	if (tsc_wires > 0) {
> +	if (tscmag_wires > 0) {
>  		cell = &tscadc->cells[cell_idx++];
>  		cell->name = tscadc->data->name_tscmag;
>  		cell->of_compatible = tscadc->data->compat_tscmag;


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

* Re: [PATCH 02/40] dt-bindings: mfd: ti,am3359-tscadc: Add a yaml description for this MFD
  2021-08-25 15:24 ` [PATCH 02/40] dt-bindings: mfd: ti,am3359-tscadc: Add a yaml description for this MFD Miquel Raynal
  2021-08-30 12:47   ` Jonathan Cameron
@ 2021-08-31 19:33   ` Rob Herring
  1 sibling, 0 replies; 88+ messages in thread
From: Rob Herring @ 2021-08-31 19:33 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk

On Wed, Aug 25, 2021 at 05:24:40PM +0200, Miquel Raynal wrote:
> There is a very light description of this MFD in a text file dedicated
> to a touchscreen controller (which is one of the two children of the
> MFD). Here is now a complete yaml description.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> ---
>  .../bindings/mfd/ti,am3359-tscadc.yaml        | 75 +++++++++++++++++++
>  1 file changed, 75 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/mfd/ti,am3359-tscadc.yaml
> 
> diff --git a/Documentation/devicetree/bindings/mfd/ti,am3359-tscadc.yaml b/Documentation/devicetree/bindings/mfd/ti,am3359-tscadc.yaml
> new file mode 100644
> index 000000000000..96b329508d8a
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mfd/ti,am3359-tscadc.yaml
> @@ -0,0 +1,75 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/mfd/ti,am3359-tscadc.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: TI AM3359 Touchscreen controller/ADC
> +
> +maintainers:
> +  - Miquel Raynal <miquel.raynal@bootlin.com>
> +
> +properties:
> +  compatible:
> +    const: ti,am3359-tscadc
> +
> +  reg:
> +    maxItems: 1
> +
> +  interrupts:
> +    maxItems: 1
> +
> +  clocks:
> +    maxItems: 1
> +
> +  clock-names:
> +    const: fck
> +
> +  dmas:
> +    items:
> +      - description: DMA controller phandle and request line for FIFO0
> +      - description: DMA controller phandle and request line for FIFO1
> +
> +  dma-names:
> +    items:
> +      - const: fifo0
> +      - const: fifo1
> +
> +patternProperties:
> +  "^adc$":
> +    description: ADC
> +
> +  "^tsc$":
> +    description: Touchscreen controller

These are fixed strings, so move to 'properties'. They also need 'type: 
object' to indicate they are nodes.

> +
> +required:
> +  - compatible
> +  - reg
> +  - interrupts
> +  - clocks
> +  - clock-names
> +  - dmas
> +  - dma-names
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +    #include <dt-bindings/interrupt-controller/arm-gic.h>
> +
> +    tscadc: tscadc@0 {
> +        compatible = "ti,am3359-tscadc";
> +        reg = <0x0 0x1000>;
> +        interrupts = <GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>;
> +        clocks = <&adc_tsc_fck>;
> +        clock-names = "fck";
> +        dmas = <&edma 53 0>, <&edma 57 0>;
> +        dma-names = "fifo0", "fifo1";
> +        status = "disabled";

Don't show 'status' in examples. It disables some checks.

> +
> +        tsc {
> +        };
> +
> +        adc {
> +        };
> +    };
> -- 
> 2.27.0
> 
> 

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

* Re: [PATCH 03/40] dt-bindings: touchscreen: ti,am3359-tsc: New yaml description
  2021-08-25 15:24 ` [PATCH 03/40] dt-bindings: touchscreen: ti,am3359-tsc: New yaml description Miquel Raynal
  2021-08-30 13:36   ` Jonathan Cameron
@ 2021-08-31 19:37   ` Rob Herring
  2021-09-01  7:42     ` Miquel Raynal
  1 sibling, 1 reply; 88+ messages in thread
From: Rob Herring @ 2021-08-31 19:37 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk

On Wed, Aug 25, 2021 at 05:24:41PM +0200, Miquel Raynal wrote:
> This touchscreen controller is already described in a text file:
> Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt
> 
> After introducing a proper description of the MFD, this is the second
> step. The file cannot be removed yet as it also contains an ADC
> description.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> ---
>  .../input/touchscreen/ti,am3359-tsc.yaml      | 89 +++++++++++++++++++
>  1 file changed, 89 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/input/touchscreen/ti,am3359-tsc.yaml
> 
> diff --git a/Documentation/devicetree/bindings/input/touchscreen/ti,am3359-tsc.yaml b/Documentation/devicetree/bindings/input/touchscreen/ti,am3359-tsc.yaml
> new file mode 100644
> index 000000000000..2d4ce6d04f53
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/input/touchscreen/ti,am3359-tsc.yaml
> @@ -0,0 +1,89 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/input/touchscreen/ti,am3359-tsc.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: TI AM3359 Touchscreen controller
> +
> +maintainers:
> +  - Miquel Raynal <miquel.raynal@bootlin.com>
> +
> +properties:
> +  compatible:
> +    const: ti,am3359-tsc
> +
> +  ti,wires:
> +    description: Wires refer to application modes i.e. 4/5/8 wire touchscreen
> +      support on the platform.
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    enum: [4, 5, 8]
> +
> +  ti,x-plate-resistance:
> +    description: X plate resistance
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +
> +  ti,coordinate-readouts:
> +    description: The sequencer supports a total of 16 programmable steps. Each
> +      step is used to read a single coordinate. A single readout is enough but
> +      multiple reads can increase the quality. A value of 5 means, 5 reads for
> +      X, 5 for Y and 2 for Z (always). This utilises 12 of the 16 software steps
> +      available. The remaining 4 can be used by the ADC.
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    minimum: 1
> +    maximum: 6
> +
> +  ti,wire-config:
> +    description: Different boards could have a different order for connecting
> +      wires on touchscreen. We need to provide an 8-bit number where the
> +      first four bits represent the analog lines and the next 4 bits represent
> +      positive/negative terminal on that input line. Notations to represent the
> +      input lines and terminals respectively are as follows, AIN0 = 0, AIN1 = 1
> +      and so on untill AIN7 = 7. XP = 0, XN = 1, YP = 2, YN = 3.
> +    $ref: /schemas/types.yaml#/definitions/uint32-array
> +    minItems: 4
> +    maxItems: 8
> +
> +  ti,charge-delay:
> +    description: Length of touch screen charge delay step in terms of ADC clock
> +      cycles. Charge delay value should be large in order to avoid false pen-up
> +      events. This value effects the overall sampling speed, hence need to be
> +      kept as low as possible, while avoiding false pen-up event. Start from a
> +      lower value, say 0x400, and increase value until false pen-up events are
> +      avoided. The pen-up detection happens immediately after the charge step,
> +      so this does in fact function as a hardware knob for adjusting the amount
> +      of "settling time".
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +
> +required:
> +  - compatible
> +  - ti,wires
> +  - ti,x-plate-resistance
> +  - ti,coordinate-readouts
> +  - ti,wire-config
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +    #include <dt-bindings/interrupt-controller/arm-gic.h>

I prefer that MFDs have just 1 complete example in the MFD schema. 

> +
> +    tscadc: tscadc@0 {

Drop unused labels.

> +        compatible = "ti,am3359-tscadc";
> +        reg = <0x0 0x1000>;
> +        interrupts = <GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>;
> +        clocks = <&adc_tsc_fck>;
> +        clock-names = "fck";
> +        status = "disabled";

status, again.

> +        dmas = <&edma 53 0>, <&edma 57 0>;
> +        dma-names = "fifo0", "fifo1";
> +
> +        tsc {
> +            compatible = "ti,am3359-tsc";
> +            ti,wires = <4>;
> +            ti,x-plate-resistance = <200>;
> +            ti,coordinate-readouts = <5>;
> +            ti,wire-config = <0x00 0x11 0x22 0x33>;
> +            ti,charge-delay = <0x400>;
> +        };
> +    };
> -- 
> 2.27.0
> 
> 

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

* Re: [PATCH 05/40] dt-bindings: touchscreen: ti,am3359-tsc: Remove deprecated text file
  2021-08-25 15:24 ` [PATCH 05/40] dt-bindings: touchscreen: ti,am3359-tsc: Remove deprecated text file Miquel Raynal
  2021-08-30 12:39   ` Jonathan Cameron
@ 2021-08-31 19:38   ` Rob Herring
  1 sibling, 0 replies; 88+ messages in thread
From: Rob Herring @ 2021-08-31 19:38 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Stephen Boyd, Tony Lindgren, bcousson, Jonathan Cameron,
	Lee Jones, Lars-Peter Clausen, Tero Kristo, Michael Turquette,
	linux-iio, linux-input, linux-clk, Thomas Petazzoni, linux-omap,
	Rob Herring, devicetree, Peter Meerwald-Stadler,
	Ryan J . Barnett

On Wed, 25 Aug 2021 17:24:43 +0200, Miquel Raynal wrote:
> Now that the three hardware peaces described in this file have been
> translated in yaml in 3 dedicated files (MFD, touchscreen controller and
> ADC) it is time to remove this text file.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> ---
>  .../bindings/input/touchscreen/ti-tsc-adc.txt | 91 -------------------
>  1 file changed, 91 deletions(-)
>  delete mode 100644 Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt
> 

Acked-by: Rob Herring <robh@kernel.org>

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

* Re: [PATCH 03/40] dt-bindings: touchscreen: ti,am3359-tsc: New yaml description
  2021-08-31 19:37   ` Rob Herring
@ 2021-09-01  7:42     ` Miquel Raynal
  0 siblings, 0 replies; 88+ messages in thread
From: Miquel Raynal @ 2021-09-01  7:42 UTC (permalink / raw)
  To: Rob Herring
  Cc: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk

Hi Rob,

> > +examples:
> > +  - |
> > +    #include <dt-bindings/interrupt-controller/arm-gic.h>  
> 
> I prefer that MFDs have just 1 complete example in the MFD schema. 

Just to be on the same line, you ask me to drop the all the lines from

	tscadc:

up to

	dma-names = ...;

and keep only the tsc node, right?

I guess I should do the same in the ADC binding then.

> 
> > +
> > +    tscadc: tscadc@0 {  
> 
> Drop unused labels.
> 
> > +        compatible = "ti,am3359-tscadc";
> > +        reg = <0x0 0x1000>;
> > +        interrupts = <GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>;
> > +        clocks = <&adc_tsc_fck>;
> > +        clock-names = "fck";
> > +        status = "disabled";  
> 
> status, again.
> 
> > +        dmas = <&edma 53 0>, <&edma 57 0>;
> > +        dma-names = "fifo0", "fifo1";
> > +
> > +        tsc {
> > +            compatible = "ti,am3359-tsc";
> > +            ti,wires = <4>;
> > +            ti,x-plate-resistance = <200>;
> > +            ti,coordinate-readouts = <5>;
> > +            ti,wire-config = <0x00 0x11 0x22 0x33>;
> > +            ti,charge-delay = <0x400>;
> > +        };
> > +    };
> > -- 
> > 2.27.0
> > 
> >   

Thanks,
Miquèl

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

* Re: [PATCH 28/40] mfd: ti_am335x_tscadc: Add ADC1/magnetic reader support
  2021-08-25 15:25 ` [PATCH 28/40] mfd: ti_am335x_tscadc: Add ADC1/magnetic reader support Miquel Raynal
  2021-08-30 14:10   ` Jonathan Cameron
@ 2021-09-01 19:26   ` Grygorii Strashko
  2021-09-02  6:47     ` Miquel Raynal
  1 sibling, 1 reply; 88+ messages in thread
From: Grygorii Strashko @ 2021-09-01 19:26 UTC (permalink / raw)
  To: Miquel Raynal, Jonathan Cameron, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Rob Herring, Lee Jones, bcousson,
	Tony Lindgren, Michael Turquette, Stephen Boyd
  Cc: Thomas Petazzoni, Ryan J . Barnett, linux-iio, devicetree,
	linux-input, linux-omap, linux-clk, Jason Reeder



On 25/08/2021 18:25, Miquel Raynal wrote:
> Introduce a new compatible that has another set of driver data,
> targeting am437x SoCs with a magnetic reader instead of the
> touchscreen and a more featureful set of registers.
> 
> Co-developed-by: Jason Reeder <jreeder@ti.com>
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> Signed-off-by: Jason Reeder <jreeder@ti.com>
> ---
>   drivers/mfd/ti_am335x_tscadc.c       | 43 ++++++++++++++++++++++------
>   include/linux/mfd/ti_am335x_tscadc.h |  9 +++++-
>   2 files changed, 43 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
> index 1a30610dc65f..f4f6b9db4d2a 100644
> --- a/drivers/mfd/ti_am335x_tscadc.c
> +++ b/drivers/mfd/ti_am335x_tscadc.c
> @@ -122,9 +122,9 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>   	const __be32 *cur;
>   	struct clk *clk;
>   	u32 val;
> -	bool use_tsc = false;
> +	bool use_tsc = false, use_mag = false;
>   	int tscmag_wires = 0, adc_channels = 0, readouts = 0, cell_idx = 0;
> -	int total_channels, err;
> +	int mag_tracks = 0, total_channels, err;
>   
>   	/* Allocate memory for device */
>   	tscadc = devm_kzalloc(&pdev->dev, sizeof(*tscadc), GFP_KERNEL);
> @@ -146,6 +146,12 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>   		of_property_read_u32(node, "ti,coordiante-readouts", &readouts);
>   		if (tscmag_wires)
>   			use_tsc = true;
> +	} else {
> +		node = of_get_child_by_name(pdev->dev.of_node, "mag");
> +		of_property_read_u32(node, "ti,tracks", &mag_tracks);

"ti,tracks" seems undocumented?

[....]

-- 
Best regards,
grygorii

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

* Re: [PATCH 28/40] mfd: ti_am335x_tscadc: Add ADC1/magnetic reader support
  2021-09-01 19:26   ` Grygorii Strashko
@ 2021-09-02  6:47     ` Miquel Raynal
  2021-09-02  9:57       ` Grygorii Strashko
  0 siblings, 1 reply; 88+ messages in thread
From: Miquel Raynal @ 2021-09-02  6:47 UTC (permalink / raw)
  To: Grygorii Strashko
  Cc: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk, Jason Reeder

Hi Grygorii,

Grygorii Strashko <grygorii.strashko@ti.com> wrote on Wed, 1 Sep 2021
22:26:25 +0300:

> On 25/08/2021 18:25, Miquel Raynal wrote:
> > Introduce a new compatible that has another set of driver data,
> > targeting am437x SoCs with a magnetic reader instead of the
> > touchscreen and a more featureful set of registers.
> > 
> > Co-developed-by: Jason Reeder <jreeder@ti.com>
> > Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> > Signed-off-by: Jason Reeder <jreeder@ti.com>
> > ---
> >   drivers/mfd/ti_am335x_tscadc.c       | 43 ++++++++++++++++++++++------
> >   include/linux/mfd/ti_am335x_tscadc.h |  9 +++++-
> >   2 files changed, 43 insertions(+), 9 deletions(-)
> > 
> > diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
> > index 1a30610dc65f..f4f6b9db4d2a 100644
> > --- a/drivers/mfd/ti_am335x_tscadc.c
> > +++ b/drivers/mfd/ti_am335x_tscadc.c
> > @@ -122,9 +122,9 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
> >   	const __be32 *cur;
> >   	struct clk *clk;
> >   	u32 val;
> > -	bool use_tsc = false;
> > +	bool use_tsc = false, use_mag = false;
> >   	int tscmag_wires = 0, adc_channels = 0, readouts = 0, cell_idx = 0;
> > -	int total_channels, err;
> > +	int mag_tracks = 0, total_channels, err;  
> >   >   	/* Allocate memory for device */  
> >   	tscadc = devm_kzalloc(&pdev->dev, sizeof(*tscadc), GFP_KERNEL);
> > @@ -146,6 +146,12 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
> >   		of_property_read_u32(node, "ti,coordiante-readouts", &readouts);
> >   		if (tscmag_wires)
> >   			use_tsc = true;
> > +	} else {
> > +		node = of_get_child_by_name(pdev->dev.of_node, "mag");
> > +		of_property_read_u32(node, "ti,tracks", &mag_tracks);  
> 
> "ti,tracks" seems undocumented?

Well that's true and almost on purpose, I am not focusing on the
magnetic reader feature, it is not supported, I don't have one, I don't
plan to add support for it. But in the driver I need to know how many
"tracks" are unavailable for the ADC in order to implement the entire
logic (this block comes from TI and the naming from Jason Reeder).

I am not comfortable writing a binding file for a device that I won't
use, it's the best way to miss something and have stable broken
bindings in the future. So I assumed it was not a big deal to have this
property in the code, which may be updated/removed/enhanced later if
needed without having to mess with the code too much. What do you think?

Thanks,
Miquèl

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

* Re: [PATCH 28/40] mfd: ti_am335x_tscadc: Add ADC1/magnetic reader support
  2021-09-02  6:47     ` Miquel Raynal
@ 2021-09-02  9:57       ` Grygorii Strashko
  0 siblings, 0 replies; 88+ messages in thread
From: Grygorii Strashko @ 2021-09-02  9:57 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Jonathan Cameron, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Lee Jones, bcousson, Tony Lindgren,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk, Jason Reeder



On 02/09/2021 09:47, Miquel Raynal wrote:
> Hi Grygorii,
> 
> Grygorii Strashko <grygorii.strashko@ti.com> wrote on Wed, 1 Sep 2021
> 22:26:25 +0300:
> 
>> On 25/08/2021 18:25, Miquel Raynal wrote:
>>> Introduce a new compatible that has another set of driver data,
>>> targeting am437x SoCs with a magnetic reader instead of the
>>> touchscreen and a more featureful set of registers.
>>>
>>> Co-developed-by: Jason Reeder <jreeder@ti.com>
>>> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
>>> Signed-off-by: Jason Reeder <jreeder@ti.com>
>>> ---
>>>    drivers/mfd/ti_am335x_tscadc.c       | 43 ++++++++++++++++++++++------
>>>    include/linux/mfd/ti_am335x_tscadc.h |  9 +++++-
>>>    2 files changed, 43 insertions(+), 9 deletions(-)
>>>
>>> diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
>>> index 1a30610dc65f..f4f6b9db4d2a 100644
>>> --- a/drivers/mfd/ti_am335x_tscadc.c
>>> +++ b/drivers/mfd/ti_am335x_tscadc.c
>>> @@ -122,9 +122,9 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>>>    	const __be32 *cur;
>>>    	struct clk *clk;
>>>    	u32 val;
>>> -	bool use_tsc = false;
>>> +	bool use_tsc = false, use_mag = false;
>>>    	int tscmag_wires = 0, adc_channels = 0, readouts = 0, cell_idx = 0;
>>> -	int total_channels, err;
>>> +	int mag_tracks = 0, total_channels, err;
>>>    >   	/* Allocate memory for device */
>>>    	tscadc = devm_kzalloc(&pdev->dev, sizeof(*tscadc), GFP_KERNEL);
>>> @@ -146,6 +146,12 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>>>    		of_property_read_u32(node, "ti,coordiante-readouts", &readouts);
>>>    		if (tscmag_wires)
>>>    			use_tsc = true;
>>> +	} else {
>>> +		node = of_get_child_by_name(pdev->dev.of_node, "mag");
>>> +		of_property_read_u32(node, "ti,tracks", &mag_tracks);
>>
>> "ti,tracks" seems undocumented?
> 
> Well that's true and almost on purpose, I am not focusing on the
> magnetic reader feature, it is not supported, I don't have one, I don't
> plan to add support for it. But in the driver I need to know how many
> "tracks" are unavailable for the ADC in order to implement the entire
> logic (this block comes from TI and the naming from Jason Reeder).
> 
> I am not comfortable writing a binding file for a device that I won't
> use, it's the best way to miss something and have stable broken
> bindings in the future. So I assumed it was not a big deal to have this
> property in the code, which may be updated/removed/enhanced later if
> needed without having to mess with the code too much. What do you think?

Sry, it's not ok.
You need to (a) add binding or (b) w/a it in some way -
like drop it and use const value instead, for example.

-- 
Best regards,
grygorii

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

* Re: [PATCH 02/40] dt-bindings: mfd: ti,am3359-tscadc: Add a yaml description for this MFD
  2021-08-30 12:47   ` Jonathan Cameron
@ 2021-09-02 17:35     ` Miquel Raynal
  0 siblings, 0 replies; 88+ messages in thread
From: Miquel Raynal @ 2021-09-02 17:35 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk

Hi Jonathan,

Jonathan Cameron <jic23@kernel.org> wrote on Mon, 30 Aug 2021 13:47:14
+0100:

> On Wed, 25 Aug 2021 17:24:40 +0200
> Miquel Raynal <miquel.raynal@bootlin.com> wrote:
> 
> > There is a very light description of this MFD in a text file dedicated
> > to a touchscreen controller (which is one of the two children of the
> > MFD). Here is now a complete yaml description.  
> 
> Make sure to call out places where you are filling in gaps in the
> txt file description.  Looks like we forgot to keep that up to date as the driver
> evolved. oops.

Right, I always forget these links, will update them.

> 
> > 
> > Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> > ---
> >  .../bindings/mfd/ti,am3359-tscadc.yaml        | 75 +++++++++++++++++++
> >  1 file changed, 75 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/mfd/ti,am3359-tscadc.yaml
> > 
> > diff --git a/Documentation/devicetree/bindings/mfd/ti,am3359-tscadc.yaml b/Documentation/devicetree/bindings/mfd/ti,am3359-tscadc.yaml
> > new file mode 100644
> > index 000000000000..96b329508d8a
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/mfd/ti,am3359-tscadc.yaml
> > @@ -0,0 +1,75 @@
> > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/mfd/ti,am3359-tscadc.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: TI AM3359 Touchscreen controller/ADC
> > +
> > +maintainers:
> > +  - Miquel Raynal <miquel.raynal@bootlin.com>
> > +
> > +properties:
> > +  compatible:
> > +    const: ti,am3359-tscadc  
> 
> text documents the more specific ti,am654-tscadc as well.

Oops, I saw it and then forgot. Thanks for checking!

> Something like
> 
>    properties:
>      compatible:
>        oneof:
>          - const: ti,am3359-tscadc
>          - items:
>              - const: ti,am654-tscadc
>              - const: ti,am3359-tscadc
> 
> Note this superceeds my comment on later patches about changing to enum when
> introducing the new compatible. Ah well.

No problem (and thanks for the 50+ reviews btw ;) )

Thanks,
Miquèl

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

* Re: [PATCH 03/40] dt-bindings: touchscreen: ti,am3359-tsc: New yaml description
  2021-08-30 13:36   ` Jonathan Cameron
@ 2021-09-02 17:45     ` Miquel Raynal
  2021-09-05 11:58       ` Jonathan Cameron
  0 siblings, 1 reply; 88+ messages in thread
From: Miquel Raynal @ 2021-09-02 17:45 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk

Hi Jonathan,

Jonathan Cameron <jic23@kernel.org> wrote on Mon, 30 Aug 2021 14:36:10
+0100:

> On Wed, 25 Aug 2021 17:24:41 +0200
> Miquel Raynal <miquel.raynal@bootlin.com> wrote:
> 
> > This touchscreen controller is already described in a text file:
> > Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt
> > 
> > After introducing a proper description of the MFD, this is the second
> > step. The file cannot be removed yet as it also contains an ADC
> > description.
> > 
> > Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> > ---
> >  .../input/touchscreen/ti,am3359-tsc.yaml      | 89 +++++++++++++++++++
> >  1 file changed, 89 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/input/touchscreen/ti,am3359-tsc.yaml
> > 
> > diff --git a/Documentation/devicetree/bindings/input/touchscreen/ti,am3359-tsc.yaml b/Documentation/devicetree/bindings/input/touchscreen/ti,am3359-tsc.yaml
> > new file mode 100644
> > index 000000000000..2d4ce6d04f53
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/input/touchscreen/ti,am3359-tsc.yaml
> > @@ -0,0 +1,89 @@
> > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/input/touchscreen/ti,am3359-tsc.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: TI AM3359 Touchscreen controller
> > +
> > +maintainers:
> > +  - Miquel Raynal <miquel.raynal@bootlin.com>
> > +
> > +properties:
> > +  compatible:
> > +    const: ti,am3359-tsc
> > +
> > +  ti,wires:
> > +    description: Wires refer to application modes i.e. 4/5/8 wire touchscreen
> > +      support on the platform.
> > +    $ref: /schemas/types.yaml#/definitions/uint32
> > +    enum: [4, 5, 8]
> > +
> > +  ti,x-plate-resistance:
> > +    description: X plate resistance
> > +    $ref: /schemas/types.yaml#/definitions/uint32
> > +
> > +  ti,coordinate-readouts:
> > +    description: The sequencer supports a total of 16 programmable steps. Each
> > +      step is used to read a single coordinate. A single readout is enough but
> > +      multiple reads can increase the quality. A value of 5 means, 5 reads for
> > +      X, 5 for Y and 2 for Z (always). This utilises 12 of the 16 software steps
> > +      available. The remaining 4 can be used by the ADC.
> > +    $ref: /schemas/types.yaml#/definitions/uint32
> > +    minimum: 1
> > +    maximum: 6
> > +
> > +  ti,wire-config:
> > +    description: Different boards could have a different order for connecting
> > +      wires on touchscreen. We need to provide an 8-bit number where the
> > +      first four bits represent the analog lines and the next 4 bits represent
> > +      positive/negative terminal on that input line. Notations to represent the
> > +      input lines and terminals respectively are as follows, AIN0 = 0, AIN1 = 1
> > +      and so on untill AIN7 = 7. XP = 0, XN = 1, YP = 2, YN = 3.
> > +    $ref: /schemas/types.yaml#/definitions/uint32-array
> > +    minItems: 4
> > +    maxItems: 8
> > +
> > +  ti,charge-delay:
> > +    description: Length of touch screen charge delay step in terms of ADC clock
> > +      cycles. Charge delay value should be large in order to avoid false pen-up
> > +      events. This value effects the overall sampling speed, hence need to be
> > +      kept as low as possible, while avoiding false pen-up event. Start from a
> > +      lower value, say 0x400, and increase value until false pen-up events are
> > +      avoided. The pen-up detection happens immediately after the charge step,
> > +      so this does in fact function as a hardware knob for adjusting the amount
> > +      of "settling time".
> > +    $ref: /schemas/types.yaml#/definitions/uint32
> > +
> > +required:
> > +  - compatible
> > +  - ti,wires  
> 
> Are these all required?  Seems like the driver will work fine without some
> of them and isn't doing appropriate error checking for their presence..

Well, I don't have a touchscreen so I can't actually verify that it
works without these properties. The logic here is to simply translate
the .txt file and the .txt file states that these properties are
mandatory. But of course if people have one and can test, it would be
good to either add the proper checks to the driver or drop these
properties from the required list. But as far as I am concerned, it is
too risky to do this kind of blind change in a binding file...

Thanks,
Miquèl

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

* Re: [PATCH 28/40] mfd: ti_am335x_tscadc: Add ADC1/magnetic reader support
  2021-08-30 14:10   ` Jonathan Cameron
@ 2021-09-02 18:31     ` Miquel Raynal
  2021-09-02 20:03     ` Miquel Raynal
  1 sibling, 0 replies; 88+ messages in thread
From: Miquel Raynal @ 2021-09-02 18:31 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk, Jason Reeder

Hi Jonathan,

Jonathan Cameron <jic23@kernel.org> wrote on Mon, 30 Aug 2021 15:10:10
+0100:

> On Wed, 25 Aug 2021 17:25:06 +0200
> Miquel Raynal <miquel.raynal@bootlin.com> wrote:
> 
> > Introduce a new compatible that has another set of driver data,
> > targeting am437x SoCs with a magnetic reader instead of the
> > touchscreen and a more featureful set of registers.
> > 
> > Co-developed-by: Jason Reeder <jreeder@ti.com>
> > Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> > Signed-off-by: Jason Reeder <jreeder@ti.com>  
> There is one bit in here that I think should have been back in patch 16 but
> maybe I'm missing something.

Good catch, indeed I should have wired the compatible with the driver
data since patch 16. I will fix this.

Thanks,
Miquèl

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

* Re: [PATCH 20/40] mfd: ti_am335x_tscadc: Gather the ctrl register logic at one place
  2021-08-30 13:56   ` Jonathan Cameron
@ 2021-09-02 19:42     ` Miquel Raynal
  2021-09-05 11:13       ` Jonathan Cameron
  0 siblings, 1 reply; 88+ messages in thread
From: Miquel Raynal @ 2021-09-02 19:42 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk

Hi Jonathan,

Jonathan Cameron <jic23@kernel.org> wrote on Mon, 30 Aug 2021 14:56:08
+0100:

> On Wed, 25 Aug 2021 17:24:58 +0200
> Miquel Raynal <miquel.raynal@bootlin.com> wrote:
> 
> > Instead of deriving in the probe and in the resume path the value of the
> > ctrl register, let's do it only once in the probe, save the value of
> > this register in the driver's structure and use it from the resume
> > callback.
> > 
> > Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>  
> A few minor things inline.
> 
> J
> 
> > ---
> >  drivers/mfd/ti_am335x_tscadc.c       | 31 ++++++++--------------------
> >  include/linux/mfd/ti_am335x_tscadc.h |  2 +-
> >  2 files changed, 10 insertions(+), 23 deletions(-)
> > 
> > diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
> > index 7071344ad18e..d661e8ae66c9 100644
> > --- a/drivers/mfd/ti_am335x_tscadc.c
> > +++ b/drivers/mfd/ti_am335x_tscadc.c
> > @@ -122,7 +122,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
> >  	struct clk *clk;
> >  	u32 val;
> >  	int tsc_wires = 0, adc_channels = 0, readouts = 0, cell_idx = 0;
> > -	int total_channels, ctrl, err;
> > +	int total_channels, err;
> >  
> >  	/* Allocate memory for device */
> >  	tscadc = devm_kzalloc(&pdev->dev, sizeof(*tscadc), GFP_KERNEL);
> > @@ -215,22 +215,21 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
> >  	regmap_write(tscadc->regmap, REG_CLKDIV, tscadc->clk_div);
> >  
> >  	/* Set the control register bits */
> > -	ctrl = CNTRLREG_STEPCONFIGWRT |	CNTRLREG_STEPID;
> > -	regmap_write(tscadc->regmap, REG_CTRL, ctrl);
> > +	tscadc->ctrl = CNTRLREG_STEPCONFIGWRT | CNTRLREG_STEPID;
> > +	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl);
> >  
> >  	if (tsc_wires > 0) {
> > -		tscadc->tsc_wires = tsc_wires;
> > +		tscadc->ctrl |= CNTRLREG_TSCENB;
> >  		if (tsc_wires == 5)
> > -			ctrl |= CNTRLREG_5WIRE | CNTRLREG_TSCENB;
> > +			tscadc->ctrl |= CNTRLREG_5WIRE;
> >  		else
> > -			ctrl |= CNTRLREG_4WIRE | CNTRLREG_TSCENB;
> > +			tscadc->ctrl |= CNTRLREG_4WIRE;
> >  	}
> >  
> >  	tscadc_idle_config(tscadc);
> >  
> >  	/* Enable the TSC module enable bit */
> > -	ctrl |= CNTRLREG_TSCSSENB;
> > -	regmap_write(tscadc->regmap, REG_CTRL, ctrl);
> > +	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl | CNTRLREG_TSCSSENB);
> >  
> >  	/* TSC Cell */
> >  	if (tsc_wires > 0) {
> > @@ -305,25 +304,13 @@ static int __maybe_unused tscadc_suspend(struct device *dev)
> >  static int __maybe_unused tscadc_resume(struct device *dev)
> >  {
> >  	struct ti_tscadc_dev *tscadc = dev_get_drvdata(dev);
> > -	u32 ctrl;
> >  
> >  	pm_runtime_get_sync(dev);
> >  
> > -	/* context restore */
> > -	ctrl = CNTRLREG_STEPCONFIGWRT |	CNTRLREG_STEPID;
> > -	regmap_write(tscadc->regmap, REG_CTRL, ctrl);
> > -
> > -	if (tscadc->tsc_wires > 0) {
> > -		if (tscadc->tsc_wires == 5)
> > -			ctrl |= CNTRLREG_5WIRE | CNTRLREG_TSCENB;
> > -		else
> > -			ctrl |= CNTRLREG_4WIRE | CNTRLREG_TSCENB;
> > -	}
> > -	ctrl |= CNTRLREG_TSCSSENB;
> > -	regmap_write(tscadc->regmap, REG_CTRL, ctrl);
> > -
> >  	regmap_write(tscadc->regmap, REG_CLKDIV, tscadc->clk_div);
> > +	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl);  
> 
> Patch description should mention why this ordering change is here.

I actually moved the patch that reorders things earlier so that the
reviewer is not bothered by the order changes later on.

> 
> >  	tscadc_idle_config(tscadc);
> > +	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl | CNTRLREG_TSCSSENB);  
> 
> As the value of tscadc->ctrl is not the same as REG_CTRL this is a bit non obvious.
> 
> You might be better off keeping them in sync, but masking that bit out and then resetting
> it as appropriate.

I honestly find more readable doing:

ctrl = flags;
writel(ctrl);
writel(ctrl | en_bit);

than

ctrl = flags;
writel(ctrl & ~en_bit);
writel(ctrl);

because the second version emphasis the fact that we reset the en_bit
(which is wrong, the point of this first write is to actually write all
the configuration but not the en_bit yet) while the first version
clearly shows that the second write includes an additional "enable bit".

Thanks,
Miquèl

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

* Re: [PATCH 28/40] mfd: ti_am335x_tscadc: Add ADC1/magnetic reader support
  2021-08-30 14:10   ` Jonathan Cameron
  2021-09-02 18:31     ` Miquel Raynal
@ 2021-09-02 20:03     ` Miquel Raynal
  1 sibling, 0 replies; 88+ messages in thread
From: Miquel Raynal @ 2021-09-02 20:03 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk, Jason Reeder

Hi Jonathan,


> > +static const struct ti_tscadc_data magdata = {
> > +	.has_tsc = false,
> > +	.has_mag = true,
> > +	.name_tscmag = "TI-am43xx-mag",
> > +	.compat_tscmag = "ti,am4372-mag",
> > +	.name_adc = "TI-am43xx-adc",
> > +	.compat_adc = "ti,am4372-adc",
> > +	.target_clk_rate = MAG_ADC_CLK,
> > +};
> > +
> >  static const struct of_device_id ti_tscadc_dt_ids[] = {
> > -	{ .compatible = "ti,am3359-tscadc", },
> > +	{
> > +		.compatible = "ti,am3359-tscadc",
> > +		.data = &tscdata,  
> Interesting to see match data added here and not before.
> Given you don't have any code in here that seems to have
> changed to use the match data, was it buggy before or is this still
> not used?

As said earlier, it was buggy before. It is now fixed.

> 
> > +	},
> > +	{
> > +		.compatible = "ti,am4372-magadc",
> > +		.data = &magdata,
> > +	},
> >  	{ }
> >  };
> >  MODULE_DEVICE_TABLE(of, ti_tscadc_dt_ids);
> > @@ -355,6 +382,6 @@ static struct platform_driver ti_tscadc_driver = {
> >  
> >  module_platform_driver(ti_tscadc_driver);
> >  
> > -MODULE_DESCRIPTION("TI touchscreen / ADC MFD controller driver");
> > +MODULE_DESCRIPTION("TI touchscreen/magnetic reader/ADC MFD controller driver");
> >  MODULE_AUTHOR("Rachna Patil <rachna@ti.com>");
> >  MODULE_LICENSE("GPL");
> > diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h
> > index 082b2af94263..31b22ec567e7 100644
> > --- a/include/linux/mfd/ti_am335x_tscadc.h
> > +++ b/include/linux/mfd/ti_am335x_tscadc.h
> > @@ -129,6 +129,11 @@
> >  #define CNTRLREG_TSC_8WIRE	CNTRLREG_TSC_AFE_CTRL(3)
> >  #define CNTRLREG_TSC_ENB	BIT(7)
> >  
> > +/*Control registers bitfields  for MAGADC IP */
> > +#define CNTRLREG_MAGADCENB      BIT(0)
> > +#define CNTRLREG_MAG_PREAMP_PWRDOWN BIT(5)
> > +#define CNTRLREG_MAG_PREAMP_BYPASS  BIT(6)
> > +
> >  /* FIFO READ Register */
> >  #define FIFOREAD_DATA_MASK (0xfff << 0)
> >  #define FIFOREAD_CHNLID_MASK (0xf << 16)
> > @@ -141,7 +146,8 @@
> >  #define SEQ_STATUS BIT(5)
> >  #define CHARGE_STEP		0x11
> >  
> > -#define TSC_ADC_CLK		3000000
> > +#define TSC_ADC_CLK		3000000 /* 3 MHz */
> > +#define MAG_ADC_CLK		13000000 /* 13 MHz */  
> 
> Not sure on current status, but there is a proposed series floating
> about that adds HZ_PER_MEGAHZ or something like that which would make
> it easier to spot if these have right number of zeros.

Would be nice indeed, but it looks like it's not yet mainline :/

Thanks,
Miquèl

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

* Re: [PATCH 20/40] mfd: ti_am335x_tscadc: Gather the ctrl register logic at one place
  2021-09-02 19:42     ` Miquel Raynal
@ 2021-09-05 11:13       ` Jonathan Cameron
  0 siblings, 0 replies; 88+ messages in thread
From: Jonathan Cameron @ 2021-09-05 11:13 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk

On Thu, 2 Sep 2021 21:42:47 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> Hi Jonathan,
> 
> Jonathan Cameron <jic23@kernel.org> wrote on Mon, 30 Aug 2021 14:56:08
> +0100:
> 
> > On Wed, 25 Aug 2021 17:24:58 +0200
> > Miquel Raynal <miquel.raynal@bootlin.com> wrote:
> >   
> > > Instead of deriving in the probe and in the resume path the value of the
> > > ctrl register, let's do it only once in the probe, save the value of
> > > this register in the driver's structure and use it from the resume
> > > callback.
> > > 
> > > Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>    
> > A few minor things inline.
> > 
> > J
> >   
> > > ---
> > >  drivers/mfd/ti_am335x_tscadc.c       | 31 ++++++++--------------------
> > >  include/linux/mfd/ti_am335x_tscadc.h |  2 +-
> > >  2 files changed, 10 insertions(+), 23 deletions(-)
> > > 
> > > diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
> > > index 7071344ad18e..d661e8ae66c9 100644
> > > --- a/drivers/mfd/ti_am335x_tscadc.c
> > > +++ b/drivers/mfd/ti_am335x_tscadc.c
> > > @@ -122,7 +122,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
> > >  	struct clk *clk;
> > >  	u32 val;
> > >  	int tsc_wires = 0, adc_channels = 0, readouts = 0, cell_idx = 0;
> > > -	int total_channels, ctrl, err;
> > > +	int total_channels, err;
> > >  
> > >  	/* Allocate memory for device */
> > >  	tscadc = devm_kzalloc(&pdev->dev, sizeof(*tscadc), GFP_KERNEL);
> > > @@ -215,22 +215,21 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
> > >  	regmap_write(tscadc->regmap, REG_CLKDIV, tscadc->clk_div);
> > >  
> > >  	/* Set the control register bits */
> > > -	ctrl = CNTRLREG_STEPCONFIGWRT |	CNTRLREG_STEPID;
> > > -	regmap_write(tscadc->regmap, REG_CTRL, ctrl);
> > > +	tscadc->ctrl = CNTRLREG_STEPCONFIGWRT | CNTRLREG_STEPID;
> > > +	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl);
> > >  
> > >  	if (tsc_wires > 0) {
> > > -		tscadc->tsc_wires = tsc_wires;
> > > +		tscadc->ctrl |= CNTRLREG_TSCENB;
> > >  		if (tsc_wires == 5)
> > > -			ctrl |= CNTRLREG_5WIRE | CNTRLREG_TSCENB;
> > > +			tscadc->ctrl |= CNTRLREG_5WIRE;
> > >  		else
> > > -			ctrl |= CNTRLREG_4WIRE | CNTRLREG_TSCENB;
> > > +			tscadc->ctrl |= CNTRLREG_4WIRE;
> > >  	}
> > >  
> > >  	tscadc_idle_config(tscadc);
> > >  
> > >  	/* Enable the TSC module enable bit */
> > > -	ctrl |= CNTRLREG_TSCSSENB;
> > > -	regmap_write(tscadc->regmap, REG_CTRL, ctrl);
> > > +	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl | CNTRLREG_TSCSSENB);
> > >  
> > >  	/* TSC Cell */
> > >  	if (tsc_wires > 0) {
> > > @@ -305,25 +304,13 @@ static int __maybe_unused tscadc_suspend(struct device *dev)
> > >  static int __maybe_unused tscadc_resume(struct device *dev)
> > >  {
> > >  	struct ti_tscadc_dev *tscadc = dev_get_drvdata(dev);
> > > -	u32 ctrl;
> > >  
> > >  	pm_runtime_get_sync(dev);
> > >  
> > > -	/* context restore */
> > > -	ctrl = CNTRLREG_STEPCONFIGWRT |	CNTRLREG_STEPID;
> > > -	regmap_write(tscadc->regmap, REG_CTRL, ctrl);
> > > -
> > > -	if (tscadc->tsc_wires > 0) {
> > > -		if (tscadc->tsc_wires == 5)
> > > -			ctrl |= CNTRLREG_5WIRE | CNTRLREG_TSCENB;
> > > -		else
> > > -			ctrl |= CNTRLREG_4WIRE | CNTRLREG_TSCENB;
> > > -	}
> > > -	ctrl |= CNTRLREG_TSCSSENB;
> > > -	regmap_write(tscadc->regmap, REG_CTRL, ctrl);
> > > -
> > >  	regmap_write(tscadc->regmap, REG_CLKDIV, tscadc->clk_div);
> > > +	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl);    
> > 
> > Patch description should mention why this ordering change is here.  
> 
> I actually moved the patch that reorders things earlier so that the
> reviewer is not bothered by the order changes later on.
> 
> >   
> > >  	tscadc_idle_config(tscadc);
> > > +	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl | CNTRLREG_TSCSSENB);    
> > 
> > As the value of tscadc->ctrl is not the same as REG_CTRL this is a bit non obvious.
> > 
> > You might be better off keeping them in sync, but masking that bit out and then resetting
> > it as appropriate.  
> 
> I honestly find more readable doing:
> 
> ctrl = flags;
> writel(ctrl);
> writel(ctrl | en_bit);
> 
> than
> 
> ctrl = flags;
> writel(ctrl & ~en_bit);
> writel(ctrl);
> 
> because the second version emphasis the fact that we reset the en_bit
> (which is wrong, the point of this first write is to actually write all
> the configuration but not the en_bit yet) while the first version
> clearly shows that the second write includes an additional "enable bit".

Fair enough.  Perhaps it's worth throwing in a comment though if you happen
to be respining to say tcsadc->ctrl isn't actually the contents of
the register, but rather of 'most' of it.

Jonathan

> 
> Thanks,
> Miquèl


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

* Re: [PATCH 03/40] dt-bindings: touchscreen: ti,am3359-tsc: New yaml description
  2021-09-02 17:45     ` Miquel Raynal
@ 2021-09-05 11:58       ` Jonathan Cameron
  0 siblings, 0 replies; 88+ messages in thread
From: Jonathan Cameron @ 2021-09-05 11:58 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Lee Jones, bcousson, Tony Lindgren, Tero Kristo,
	Michael Turquette, Stephen Boyd, Thomas Petazzoni,
	Ryan J . Barnett, linux-iio, devicetree, linux-input, linux-omap,
	linux-clk

On Thu, 2 Sep 2021 19:45:36 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> Hi Jonathan,
> 
> Jonathan Cameron <jic23@kernel.org> wrote on Mon, 30 Aug 2021 14:36:10
> +0100:
> 
> > On Wed, 25 Aug 2021 17:24:41 +0200
> > Miquel Raynal <miquel.raynal@bootlin.com> wrote:
> >   
> > > This touchscreen controller is already described in a text file:
> > > Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt
> > > 
> > > After introducing a proper description of the MFD, this is the second
> > > step. The file cannot be removed yet as it also contains an ADC
> > > description.
> > > 
> > > Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> > > ---
> > >  .../input/touchscreen/ti,am3359-tsc.yaml      | 89 +++++++++++++++++++
> > >  1 file changed, 89 insertions(+)
> > >  create mode 100644 Documentation/devicetree/bindings/input/touchscreen/ti,am3359-tsc.yaml
> > > 
> > > diff --git a/Documentation/devicetree/bindings/input/touchscreen/ti,am3359-tsc.yaml b/Documentation/devicetree/bindings/input/touchscreen/ti,am3359-tsc.yaml
> > > new file mode 100644
> > > index 000000000000..2d4ce6d04f53
> > > --- /dev/null
> > > +++ b/Documentation/devicetree/bindings/input/touchscreen/ti,am3359-tsc.yaml
> > > @@ -0,0 +1,89 @@
> > > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> > > +%YAML 1.2
> > > +---
> > > +$id: http://devicetree.org/schemas/input/touchscreen/ti,am3359-tsc.yaml#
> > > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > > +
> > > +title: TI AM3359 Touchscreen controller
> > > +
> > > +maintainers:
> > > +  - Miquel Raynal <miquel.raynal@bootlin.com>
> > > +
> > > +properties:
> > > +  compatible:
> > > +    const: ti,am3359-tsc
> > > +
> > > +  ti,wires:
> > > +    description: Wires refer to application modes i.e. 4/5/8 wire touchscreen
> > > +      support on the platform.
> > > +    $ref: /schemas/types.yaml#/definitions/uint32
> > > +    enum: [4, 5, 8]
> > > +
> > > +  ti,x-plate-resistance:
> > > +    description: X plate resistance
> > > +    $ref: /schemas/types.yaml#/definitions/uint32
> > > +
> > > +  ti,coordinate-readouts:
> > > +    description: The sequencer supports a total of 16 programmable steps. Each
> > > +      step is used to read a single coordinate. A single readout is enough but
> > > +      multiple reads can increase the quality. A value of 5 means, 5 reads for
> > > +      X, 5 for Y and 2 for Z (always). This utilises 12 of the 16 software steps
> > > +      available. The remaining 4 can be used by the ADC.
> > > +    $ref: /schemas/types.yaml#/definitions/uint32
> > > +    minimum: 1
> > > +    maximum: 6
> > > +
> > > +  ti,wire-config:
> > > +    description: Different boards could have a different order for connecting
> > > +      wires on touchscreen. We need to provide an 8-bit number where the
> > > +      first four bits represent the analog lines and the next 4 bits represent
> > > +      positive/negative terminal on that input line. Notations to represent the
> > > +      input lines and terminals respectively are as follows, AIN0 = 0, AIN1 = 1
> > > +      and so on untill AIN7 = 7. XP = 0, XN = 1, YP = 2, YN = 3.
> > > +    $ref: /schemas/types.yaml#/definitions/uint32-array
> > > +    minItems: 4
> > > +    maxItems: 8
> > > +
> > > +  ti,charge-delay:
> > > +    description: Length of touch screen charge delay step in terms of ADC clock
> > > +      cycles. Charge delay value should be large in order to avoid false pen-up
> > > +      events. This value effects the overall sampling speed, hence need to be
> > > +      kept as low as possible, while avoiding false pen-up event. Start from a
> > > +      lower value, say 0x400, and increase value until false pen-up events are
> > > +      avoided. The pen-up detection happens immediately after the charge step,
> > > +      so this does in fact function as a hardware knob for adjusting the amount
> > > +      of "settling time".
> > > +    $ref: /schemas/types.yaml#/definitions/uint32
> > > +
> > > +required:
> > > +  - compatible
> > > +  - ti,wires    
> > 
> > Are these all required?  Seems like the driver will work fine without some
> > of them and isn't doing appropriate error checking for their presence..  
> 
> Well, I don't have a touchscreen so I can't actually verify that it
> works without these properties. The logic here is to simply translate
> the .txt file and the .txt file states that these properties are
> mandatory. But of course if people have one and can test, it would be
> good to either add the proper checks to the driver or drop these
> properties from the required list. But as far as I am concerned, it is
> too risky to do this kind of blind change in a binding file...

Fair enough!
> 
> Thanks,
> Miquèl


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

end of thread, other threads:[~2021-09-05 11:55 UTC | newest]

Thread overview: 88+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-25 15:24 [PATCH 00/40] TI AM437X ADC1 Miquel Raynal
2021-08-25 15:24 ` [PATCH 01/40] clk: ti: am43xx: Add clkctrl data for am43xx ADC1 Miquel Raynal
2021-08-25 15:24 ` [PATCH 02/40] dt-bindings: mfd: ti,am3359-tscadc: Add a yaml description for this MFD Miquel Raynal
2021-08-30 12:47   ` Jonathan Cameron
2021-09-02 17:35     ` Miquel Raynal
2021-08-31 19:33   ` Rob Herring
2021-08-25 15:24 ` [PATCH 03/40] dt-bindings: touchscreen: ti,am3359-tsc: New yaml description Miquel Raynal
2021-08-30 13:36   ` Jonathan Cameron
2021-09-02 17:45     ` Miquel Raynal
2021-09-05 11:58       ` Jonathan Cameron
2021-08-31 19:37   ` Rob Herring
2021-09-01  7:42     ` Miquel Raynal
2021-08-25 15:24 ` [PATCH 04/40] dt-bindings: iio: adc: ti,am3359-adc: " Miquel Raynal
2021-08-30 12:31   ` Jonathan Cameron
2021-08-25 15:24 ` [PATCH 05/40] dt-bindings: touchscreen: ti,am3359-tsc: Remove deprecated text file Miquel Raynal
2021-08-30 12:39   ` Jonathan Cameron
2021-08-31 19:38   ` Rob Herring
2021-08-25 15:24 ` [PATCH 06/40] dt-bindings: mfd: ti,am3359-tscadc: Describe am4372 MFD compatible Miquel Raynal
2021-08-30 12:34   ` Jonathan Cameron
2021-08-25 15:24 ` [PATCH 07/40] dt-bindings: iio: adc: ti,am3359-adc: Describe am4372 ADC compatible Miquel Raynal
2021-08-30 12:35   ` Jonathan Cameron
2021-08-25 15:24 ` [PATCH 08/40] mfd: ti_am335x_tscadc: Replace license text with SPDX tag Miquel Raynal
2021-08-30 12:38   ` Jonathan Cameron
2021-08-25 15:24 ` [PATCH 09/40] mfd: ti_am335x_tscadc: Fix style Miquel Raynal
2021-08-30 12:49   ` Jonathan Cameron
2021-08-25 15:24 ` [PATCH 10/40] mfd: ti_am335x_tscadc: Drop extra spacing when declaring stack variables Miquel Raynal
2021-08-30 12:52   ` Jonathan Cameron
2021-08-25 15:24 ` [PATCH 11/40] mfd: ti_am335x_tscadc: Get rid of useless gotos Miquel Raynal
2021-08-30 13:39   ` Jonathan Cameron
2021-08-25 15:24 ` [PATCH 12/40] mfd: ti_am335x_tscadc: Move the driver structure allocation earlier Miquel Raynal
2021-08-30 14:25   ` Jonathan Cameron
2021-08-25 15:24 ` [PATCH 13/40] mfd: ti_am335x_tscadc: Reword the comment explaining the dividers Miquel Raynal
2021-08-30 13:43   ` Jonathan Cameron
2021-08-25 15:24 ` [PATCH 14/40] mfd: ti_am335x_tscadc: Don't search the tree for our clock Miquel Raynal
2021-08-25 15:24 ` [PATCH 15/40] mfd: ti_am335x_tscadc: Simplify divisor calculation Miquel Raynal
2021-08-30 13:47   ` Jonathan Cameron
2021-08-25 15:24 ` [PATCH 16/40] mfd: ti_am335x_tscadc: Use driver data Miquel Raynal
2021-08-30 14:46   ` Jonathan Cameron
2021-08-25 15:24 ` [PATCH 17/40] mfd: ti_am335x_tscadc: Mimic the probe from resume() Miquel Raynal
2021-08-25 15:24 ` [PATCH 18/40] mfd: ti_am335x_tscadc: Drop useless variables from the driver structure Miquel Raynal
2021-08-25 15:24 ` [PATCH 19/40] mfd: ti_am335x_tscadc: Always provide an idle configuration Miquel Raynal
2021-08-30 14:49   ` Jonathan Cameron
2021-08-25 15:24 ` [PATCH 20/40] mfd: ti_am335x_tscadc: Gather the ctrl register logic at one place Miquel Raynal
2021-08-30 13:56   ` Jonathan Cameron
2021-09-02 19:42     ` Miquel Raynal
2021-09-05 11:13       ` Jonathan Cameron
2021-08-25 15:24 ` [PATCH 21/40] mfd: ti_am335x_tscadc: Rename the subsystem enable macro Miquel Raynal
2021-08-30 14:50   ` Jonathan Cameron
2021-08-25 15:25 ` [PATCH 22/40] mfd: ti_am335x_tscadc: Add TSC prefix in certain macros Miquel Raynal
2021-08-30 14:52   ` Jonathan Cameron
2021-08-25 15:25 ` [PATCH 23/40] mfd: ti_am335x_tscadc: Rename a variable Miquel Raynal
2021-08-30 14:53   ` Jonathan Cameron
2021-08-25 15:25 ` [PATCH 24/40] mfd: ti_am335x_tscadc: Fix an error message Miquel Raynal
2021-08-30 13:58   ` Jonathan Cameron
2021-08-25 15:25 ` [PATCH 25/40] mfd: ti_am335x_tscadc: Add a boolean to clarify the presence of a touchscreen Miquel Raynal
2021-08-30 13:59   ` Jonathan Cameron
2021-08-25 15:25 ` [PATCH 26/40] mfd: ti_am335x_tscadc: Introduce has_tsc Miquel Raynal
2021-08-30 14:02   ` Jonathan Cameron
2021-08-25 15:25 ` [PATCH 27/40] mfd: ti_am335x_tscadc: Move control register configuration Miquel Raynal
2021-08-30 14:03   ` Jonathan Cameron
2021-08-25 15:25 ` [PATCH 28/40] mfd: ti_am335x_tscadc: Add ADC1/magnetic reader support Miquel Raynal
2021-08-30 14:10   ` Jonathan Cameron
2021-09-02 18:31     ` Miquel Raynal
2021-09-02 20:03     ` Miquel Raynal
2021-09-01 19:26   ` Grygorii Strashko
2021-09-02  6:47     ` Miquel Raynal
2021-09-02  9:57       ` Grygorii Strashko
2021-08-25 15:25 ` [PATCH 29/40] mfd: ti_am335x_tscadc: Support the correctly spelled DT property Miquel Raynal
2021-08-30 14:11   ` Jonathan Cameron
2021-08-25 15:25 ` [PATCH 30/40] iio: adc: ti_am335x_adc: Replace license text with SPDX tag Miquel Raynal
2021-08-30 14:12   ` Jonathan Cameron
2021-08-25 15:25 ` [PATCH 31/40] iio: adc: ti_am335x_adc: Fix style Miquel Raynal
2021-08-30 14:16   ` Jonathan Cameron
2021-08-25 15:25 ` [PATCH 32/40] iio: adc: ti_am335x_adc: Get rid of useless gotos Miquel Raynal
2021-08-30 14:18   ` Jonathan Cameron
2021-08-25 15:25 ` [PATCH 33/40] iio: adc: ti_am335x_adc: Gather the checks on the delays Miquel Raynal
2021-08-30 14:19   ` Jonathan Cameron
2021-08-25 15:25 ` [PATCH 34/40] iio: adc: ti_am335x_adc: Add a unit to the timeout delay Miquel Raynal
2021-08-30 14:20   ` Jonathan Cameron
2021-08-25 15:25 ` [PATCH 35/40] iio: adc: ti_am335x_adc: Wait the idle state to avoid stalls Miquel Raynal
2021-08-30 14:22   ` Jonathan Cameron
2021-08-25 15:25 ` [PATCH 36/40] iio: adc: ti_am335x_adc: Add the scale information Miquel Raynal
2021-08-30 14:23   ` Jonathan Cameron
2021-08-25 15:25 ` [PATCH 37/40] iio: adc: ti_am335x_adc: Add the am437x compatible Miquel Raynal
2021-08-30 14:24   ` Jonathan Cameron
2021-08-25 15:25 ` [PATCH 38/40] ARM: dts: am437x-cm-t43: Use a correctly spelled DT property Miquel Raynal
2021-08-25 15:25 ` [PATCH 39/40] ARM: dts: am43xx: Describe the magnetic reader/ADC1 hardware module Miquel Raynal
2021-08-25 15:25 ` [PATCH 40/40] ARM: dts: am437x-gp-evm: enable ADC1 Miquel Raynal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.