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 again. I decided not to split it given the fact
that I moved things around a little bit and addressed several different
issues which impacted other patches, perhaps the next iteration if needed
will be focused on a subset of patches. The clock patch has been acked,
the ADC patches almost as well, so we expect the series to go through
the MFD tree now.
Thanks,
Miquèl
Changes in v2:
* Added various R-by/A-by tags.
* Various typos & style fixes.
[Bindings]
* Included the missing ti,am654-tscadc compatible.
* Reworded the compatible lines as requested by Jonathan.
* Reworded the bindings content a little bit as advised by Rob (subnodes
being objects, MFD descriptions provided once, status and unused
labels removed).
[SPDX changes]
* Mentioned that the license macro and the license text matched.
* Also added an SPDX tag in the MFD header.
[MFD header]
* Used the BIT(), GENMASK() and PREP_FIELD() macros when relevant.
[MFD driver]
* Did not reordered the variables declared on the probe stack as advised
by Jonathan.
* Added missing of_node_put() calls.
* Moved the patch changing the place where the main structure is
allocated to directly precede the patch using this change.
* Fixed the driver data wiring (bug happening between ex patches 16 and
28).
* Added a commit just to explain the reordering of the register writes
during initialization/resume.
* Explained the check about 'use_tsc' in the commit message.
* Added a link to the TRM in a commit message referencing it.
* Removed the use of the ti,tracks property, used a constant value
instead.
* Dropped the error check when retrieving the "wrong" DT property
(coordiante-readouts) which is unused.
Miquel Raynal (46):
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: Ensure a balanced number of node get/put
mfd: ti_am335x_tscadc: Get rid of useless gotos
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: Move the driver structure allocation earlier
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: Reorder the initialization steps
mfd: ti_am335x_tscadc: Gather the ctrl register logic in one place
mfd: ti_am335x_tscadc: Replace the header license text with SPDX tag
mfd: ti_am335x_tscadc: Fix header spacing
mfd: ti_am335x_tscadc: Use BIT() and GENMASK() when relevant in the
header
mfd: ti_am335x_tscadc: Use FIELD_PREP() when relevant in the header
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: Wait the idle state to avoid stalls
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: 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 | 70 +++++
.../input/touchscreen/ti,am3359-tsc.yaml | 76 ++++++
.../bindings/input/touchscreen/ti-tsc-adc.txt | 91 -------
.../bindings/mfd/ti,am3359-tscadc.yaml | 84 ++++++
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 | 242 ++++++++++--------
include/dt-bindings/clock/am4.h | 1 +
include/linux/mfd/ti_am335x_tscadc.h | 127 ++++-----
13 files changed, 609 insertions(+), 348 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
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 | 79 +++++++++++++++++++
1 file changed, 79 insertions(+)
create mode 100644 Documentation/devicetree/bindings/mfd/ti,am3359-tscadc.yaml
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 | 76 +++++++++++++++++++
1 file changed, 76 insertions(+)
create mode 100644 Documentation/devicetree/bindings/input/touchscreen/ti,am3359-tsc.yaml
@@ -0,0 +1,76 @@+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)+%YAML1.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 until 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:+-|+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>;+};
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>
Acked-by: Jonathan Cameron <redacted>
---
.../bindings/iio/adc/ti,am3359-adc.yaml | 68 +++++++++++++++++++
1 file changed, 68 insertions(+)
create mode 100644 Documentation/devicetree/bindings/iio/adc/ti,am3359-adc.yaml
@@ -0,0 +1,68 @@+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)+%YAML1.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 until 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:+-|+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>;+};
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>
---
Documentation/devicetree/bindings/mfd/ti,am3359-tscadc.yaml | 5 +++++
1 file changed, 5 insertions(+)
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>
Acked-by: Jonathan Cameron <redacted>
---
Documentation/devicetree/bindings/iio/adc/ti,am3359-adc.yaml | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
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 <redacted>
Acked-by: Rob Herring <robh@kernel.org>
---
.../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
@@ -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>;- };- }
Drop the text license and replace it with an equivalent SPDX license tag
identifier which also matches the MODULE_LICENSE(GPL) macro.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Jonathan Cameron <redacted>
---
drivers/mfd/ti_am335x_tscadc.c | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
@@ -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");gotoret;-}else+}else{tscadc->irq=err;+}res=platform_get_resource(pdev,IORESOURCE_MEM,0);tscadc->tscadc_base=devm_ioremap_resource(&pdev->dev,res);
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 | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
@@ -175,7 +175,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");-gotoret;+returnerr;}else{tscadc->irq=err;}
of_node_put() should be called after a successful of_get_child_by_name().
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
drivers/mfd/ti_am335x_tscadc.c | 4 ++++
1 file changed, 4 insertions(+)
@@ -134,6 +134,7 @@ 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",&tsc_wires);of_property_read_u32(node,"ti,coordiante-readouts",&readouts);+of_node_put(node);node=of_get_child_by_name(pdev->dev.of_node,"adc");of_property_for_each_u32(node,"ti,adc-channels",prop,cur,val){
@@ -141,10 +142,13 @@ static int ti_tscadc_probe(struct platform_device *pdev)if(val>7){dev_err(&pdev->dev," PIN numbers are 0..7 (not %d)\n",val);+of_node_put(node);return-EINVAL;}}+of_node_put(node);+total_channels=tsc_wires+adc_channels;if(total_channels>8){dev_err(&pdev->dev,"Number of i/p channels more than 8\n");
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>
Reviewed-by: Jonathan Cameron <redacted>
---
drivers/mfd/ti_am335x_tscadc.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
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(-)
@@ -208,7 +208,7 @@ static int ti_tscadc_probe(struct platform_device *pdev)*ThisfrequencyisvalidsinceTSC_ADC_SScontrollerdesign*assumestheOCPclockisatleast6xfasterthantheADCclock.*/-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);
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 <redacted>
---
drivers/mfd/ti_am335x_tscadc.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
@@ -122,7 +122,6 @@ static int ti_tscadc_probe(struct platform_device *pdev)const__be32*cur;u32val;interr,ctrl;-intclock_rate;inttsc_wires=0,adc_channels=0,total_channels;intreadouts=0;
@@ -214,11 +213,8 @@ static int ti_tscadc_probe(struct platform_device *pdev)err=PTR_ERR(clk);gotoerr_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 */
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(-)
@@ -125,6 +125,13 @@ static int ti_tscadc_probe(struct platform_device *pdev)inttsc_wires=0,adc_channels=0,total_channels;intreadouts=0;+/* 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;
@@ -164,13 +171,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");
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>
Acked-by: Jonathan Cameron <redacted>
---
drivers/mfd/ti_am335x_tscadc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Jonathan Cameron <redacted>
---
drivers/mfd/ti_am335x_tscadc.c | 25 +++++++++++++++++++------
include/linux/mfd/ti_am335x_tscadc.h | 9 +++++++++
2 files changed, 28 insertions(+), 6 deletions(-)
@@ -137,6 +137,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);
@@ -214,7 +216,7 @@ static int ti_tscadc_probe(struct platform_device *pdev)gotoerr_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 */
@@ -243,8 +245,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);}
@@ -253,8 +255,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);}
@@ -340,8 +342,19 @@ static int __maybe_unused tscadc_resume(struct device *dev)staticSIMPLE_DEV_PM_OPS(tscadc_pm_ops,tscadc_suspend,tscadc_resume);+staticconststructti_tscadc_datatscdata={+.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,+};+staticconststructof_device_idti_tscadc_dt_ids[]={-{.compatible="ti,am3359-tscadc",},+{+.compatible="ti,am3359-tscadc",+.data=&tscdata,+},{}};MODULE_DEVICE_TABLE(of,ti_tscadc_dt_ids);
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(-)
@@ -177,10 +177,7 @@ struct ti_tscadc_dev {phys_addr_ttscadc_phys_base;conststructti_tscadc_data*data;intirq;-intused_cells;/* 1-2 */inttsc_wires;-inttsc_cell;/* -1 if not used */-intadc_cell;/* -1 if not used */structmfd_cellcells[TSCADC_CELLS];u32reg_se_cache;booladc_waiting;
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 | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
@@ -223,16 +223,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;elsectrl|=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);
@@ -323,8 +323,10 @@ static int __maybe_unused tscadc_resume(struct device *dev)ctrl|=CNTRLREG_5WIRE|CNTRLREG_TSCENB;elsectrl|=CNTRLREG_4WIRE|CNTRLREG_TSCENB;-tscadc_idle_config(tscadc);}++tscadc_idle_config(tscadc);+ctrl|=CNTRLREG_TSCSSENB;regmap_write(tscadc->regmap,REG_CTRL,ctrl);
TI AM335X TRM [1] states that most of the configuration should be set in
the control register in the first place, before actually enabling the
hardware with the subsystem enable bit.
So far only half of the configuration was made in the first step (before
enabling the "subsystem"), which does not make really sense. Also, the
probe and the resume patch were acting differently. Let's harmonize all
this by following these steps:
1/ Configure the CLKDIV register
2/ Configure the CTRL register
3/ Configure the idle configuration
4/ Really enable the device by rewriting the CTRL register with the
subsystem enable bit set.
[1] https://www.ti.com/lit/pdf/spruh73
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
drivers/mfd/ti_am335x_tscadc.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
@@ -221,8 +221,6 @@ static int ti_tscadc_probe(struct platform_device *pdev)/* Set the control register bits */ctrl=CNTRLREG_STEPCONFIGWRT|CNTRLREG_STEPID;-regmap_write(tscadc->regmap,REG_CTRL,ctrl);-if(tsc_wires>0){tscadc->tsc_wires=tsc_wires;if(tsc_wires==5)
@@ -230,6 +228,7 @@ static int ti_tscadc_probe(struct platform_device *pdev)elsectrl|=CNTRLREG_4WIRE|CNTRLREG_TSCENB;}+regmap_write(tscadc->regmap,REG_CTRL,ctrl);tscadc_idle_config(tscadc);
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 | 33 ++++++++--------------------
include/linux/mfd/ti_am335x_tscadc.h | 2 +-
2 files changed, 10 insertions(+), 25 deletions(-)
@@ -121,7 +121,7 @@ static int ti_tscadc_probe(struct platform_device *pdev)structproperty*prop;const__be32*cur;u32val;-interr,ctrl;+interr;inttsc_wires=0,adc_channels=0,cell_idx=0,total_channels;intreadouts=0;
@@ -220,21 +220,20 @@ 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;+tscadc->ctrl=CNTRLREG_STEPCONFIGWRT|CNTRLREG_STEPID;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;}-regmap_write(tscadc->regmap,REG_CTRL,ctrl);+regmap_write(tscadc->regmap,REG_CTRL,tscadc->ctrl);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){
Drop the text license and replace it with an equivalent SPDX license tag
identifier.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
include/linux/mfd/ti_am335x_tscadc.h | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
Use the FIELD_PREP() macro when relevant. Sometimes reorder the lines to
be able to use the relevant bitmask.
Mind the s/%d/%ld/ change in a log due to the type change following the
use of FIELD_PREP() in the header.
Suggested-by: Jonathan Cameron <redacted>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
drivers/iio/adc/ti_am335x_adc.c | 2 +-
include/linux/mfd/ti_am335x_tscadc.h | 31 ++++++++++++++--------------
2 files changed, 17 insertions(+), 16 deletions(-)
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>
Acked-by: Jonathan Cameron <redacted>
---
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(-)
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(-)
@@ -220,13 +220,13 @@ 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;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;}regmap_write(tscadc->regmap,REG_CTRL,tscadc->ctrl);
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>
Reviewed-by: Jonathan Cameron <redacted>
---
drivers/mfd/ti_am335x_tscadc.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
@@ -122,7 +122,7 @@ static int ti_tscadc_probe(struct platform_device *pdev)const__be32*cur;u32val;interr;-inttsc_wires=0,adc_channels=0,cell_idx=0,total_channels;+inttscmag_wires=0,adc_channels=0,cell_idx=0,total_channels;intreadouts=0;/* Allocate memory for device */
@@ -140,7 +140,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);of_node_put(node);
@@ -157,7 +157,7 @@ static int ti_tscadc_probe(struct platform_device *pdev)of_node_put(node);-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;
@@ -221,9 +221,9 @@ static int ti_tscadc_probe(struct platform_device *pdev)/* Set the control register bits */tscadc->ctrl=CNTRLREG_TSC_STEPCONFIGWRT|CNTRLREG_STEPID;-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;elsetscadc->ctrl|=CNTRLREG_TSC_4WIRE;
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 correct this comment.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Jonathan Cameron <redacted>
---
drivers/mfd/ti_am335x_tscadc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@@ -211,7 +211,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);gotoerr_disable_clk;}
Just checking the number of wires will soon not be enough, add a boolean
to indicated the actual use or not of the touchscreen.
Certain checks only make sense when there is a touchscreen wired. Make
this checks explicitly depend on the presence 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(-)
@@ -120,6 +120,7 @@ static int ti_tscadc_probe(struct platform_device *pdev)structmfd_cell*cell;structproperty*prop;const__be32*cur;+booluse_tsc=false;u32val;interr;inttscmag_wires=0,adc_channels=0,cell_idx=0,total_channels;
@@ -143,6 +144,8 @@ static int ti_tscadc_probe(struct platform_device *pdev)of_property_read_u32(node,"ti,wires",&tscmag_wires);of_property_read_u32(node,"ti,coordiante-readouts",&readouts);of_node_put(node);+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){
@@ -168,7 +171,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;}
@@ -221,7 +224,7 @@ static int ti_tscadc_probe(struct platform_device *pdev)/* Set the control register bits */tscadc->ctrl=CNTRLREG_TSC_STEPCONFIGWRT|CNTRLREG_STEPID;-if(tscmag_wires>0){+if(use_tsc){tscadc->ctrl|=CNTRLREG_TSC_ENB;if(tscmag_wires==5)tscadc->ctrl|=CNTRLREG_TSC_5WIRE;
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>
Reviewed-by: Jonathan Cameron <redacted>
---
drivers/mfd/ti_am335x_tscadc.c | 37 +++++++++++++++++-----------
include/linux/mfd/ti_am335x_tscadc.h | 1 +
2 files changed, 23 insertions(+), 15 deletions(-)
@@ -140,12 +141,14 @@ 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);-of_node_put(node);-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);+of_node_put(node);+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){
@@ -223,13 +226,16 @@ 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;-if(use_tsc){-tscadc->ctrl|=CNTRLREG_TSC_ENB;-if(tscmag_wires==5)-tscadc->ctrl|=CNTRLREG_TSC_5WIRE;-else-tscadc->ctrl|=CNTRLREG_TSC_4WIRE;+tscadc->ctrl=CNTRLREG_STEPID;+if(tscadc->data->has_tsc){+tscadc->ctrl|=CNTRLREG_TSC_STEPCONFIGWRT;+if(use_tsc){+tscadc->ctrl|=CNTRLREG_TSC_ENB;+if(tscmag_wires==5)+tscadc->ctrl|=CNTRLREG_TSC_5WIRE;+else+tscadc->ctrl|=CNTRLREG_TSC_4WIRE;+}}regmap_write(tscadc->regmap,REG_CTRL,tscadc->ctrl);
@@ -325,6 +331,7 @@ static int __maybe_unused tscadc_resume(struct device *dev)staticSIMPLE_DEV_PM_OPS(tscadc_pm_ops,tscadc_suspend,tscadc_resume);staticconststructti_tscadc_datatscdata={+.has_tsc=true,.name_tscmag="TI-am335x-tsc",.compat_tscmag="ti,am3359-tsc",.name_adc="TI-am335x-adc",
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 | 2 ++
1 file changed, 2 insertions(+)
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.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
drivers/mfd/ti_am335x_tscadc.c | 41 ++++++++++++++++++++++++----
include/linux/mfd/ti_am335x_tscadc.h | 9 +++++-
2 files changed, 43 insertions(+), 7 deletions(-)
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(-)
At least on a am4372, 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>
Acked-by: Jonathan Cameron <redacted>
---
drivers/iio/adc/ti_am335x_adc.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
Drop the text license and replace it with an equivalent SPDX license tag
identifier which also matches the MODULE_LICENSE("GPL").
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Jonathan Cameron <redacted>
---
drivers/iio/adc/ti_am335x_adc.c | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
@@ -256,6 +254,7 @@ static int tiadc_start_dma(struct iio_dev *indio_dev)structdma_async_tx_descriptor*desc;dma->current_period=0;/* We start to fill period 0 */+/**Makethefifothreshasthemultipleoftotalnumberof*channelsenabled,somakesurethatcyclicDMAperiod
@@ -265,9 +264,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);
@@ -303,9 +303,9 @@ static int tiadc_buffer_preenable(struct iio_dev *indio_dev)if(ret)returnret;-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);
@@ -335,8 +335,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)
@@ -352,8 +353,9 @@ static int tiadc_buffer_predisable(struct iio_dev *indio_dev)structtiadc_dma*dma=&adc_dev->dma;intfifo1count,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;
@@ -487,9 +487,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)
@@ -501,6 +500,7 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,gotoerr_unlock;}}+map_val=adc_dev->channel_step[chan->scan_index];/*
@@ -518,13 +518,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);
@@ -565,6 +566,7 @@ static int tiadc_request_dma(struct platform_device *pdev,gotoerr;return0;+err:dma_release_channel(dma->chan);return-ENOMEM;
@@ -614,7 +616,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;}
@@ -636,12 +638,11 @@ static int tiadc_probe(struct platform_device *pdev)returnerr;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)gotoerr_free_channels;
@@ -692,8 +693,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);return0;}
@@ -706,12 +706,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);return0;}
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 <redacted>
---
drivers/iio/adc/ti_am335x_adc.c | 47 +++++++++++++++++++--------------
1 file changed, 27 insertions(+), 20 deletions(-)
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 <redacted>
---
drivers/iio/adc/ti_am335x_adc.c | 2 +-
include/linux/mfd/ti_am335x_tscadc.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
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>
Acked-by: Jonathan Cameron <redacted>
---
drivers/iio/adc/ti_am335x_adc.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
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 <redacted>
---
drivers/iio/adc/ti_am335x_adc.c | 1 +
1 file changed, 1 insertion(+)
Back in 2014 a property got misspelled "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(-)
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(-)
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(+)
Hello,
Miquel Raynal [off-list ref] wrote on Thu, 2 Sep 2021
23:51:43 +0200:
quoted hunk
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(-)
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 | 2 ++
1 file changed, 2 insertions(+)
From: Rob Herring <robh@kernel.org> Date: 2021-09-03 16:05:51
On Thu, 02 Sep 2021 23:51:00 +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 | 79 +++++++++++++++++++
1 file changed, 79 insertions(+)
create mode 100644 Documentation/devicetree/bindings/mfd/ti,am3359-tscadc.yaml
From: Rob Herring <robh@kernel.org> Date: 2021-09-03 16:06:34
On Thu, 02 Sep 2021 23:51:01 +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 | 76 +++++++++++++++++++
1 file changed, 76 insertions(+)
create mode 100644 Documentation/devicetree/bindings/input/touchscreen/ti,am3359-tsc.yaml
From: Rob Herring <robh@kernel.org> Date: 2021-09-03 16:07:07
On Thu, 02 Sep 2021 23:51:02 +0200, Miquel Raynal 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>
Acked-by: Jonathan Cameron <redacted>
---
.../bindings/iio/adc/ti,am3359-adc.yaml | 68 +++++++++++++++++++
1 file changed, 68 insertions(+)
create mode 100644 Documentation/devicetree/bindings/iio/adc/ti,am3359-adc.yaml
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>
Looks good now
Reviewed-by: Jonathan Cameron <redacted>
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>
You addressed my comment on v1 in that thread so I'm fine with this.
Reviewed-by: Jonathan Cameron <redacted>
@@ -0,0 +1,76 @@+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)+%YAML1.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 until 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:+-|+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>;+};
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>
This makes sense given the changes in the precursors from v1.
FWIW
Reviewed-by: Jonathan Cameron <redacted>
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>
of_node_put() should be called after a successful of_get_child_by_name().
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
I suppose you 'could' move this to the front of the series as a fix, but
it's probably not critical so fine to keep it here.
Reviewed-by: Jonathan Cameron <redacted>
@@ -134,6 +134,7 @@ 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",&tsc_wires);of_property_read_u32(node,"ti,coordiante-readouts",&readouts);+of_node_put(node);node=of_get_child_by_name(pdev->dev.of_node,"adc");of_property_for_each_u32(node,"ti,adc-channels",prop,cur,val){
@@ -141,10 +142,13 @@ static int ti_tscadc_probe(struct platform_device *pdev)if(val>7){dev_err(&pdev->dev," PIN numbers are 0..7 (not %d)\n",val);+of_node_put(node);return-EINVAL;}}+of_node_put(node);+total_channels=tsc_wires+adc_channels;if(total_channels>8){dev_err(&pdev->dev,"Number of i/p channels more than 8\n");
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>
@@ -125,6 +125,13 @@ static int ti_tscadc_probe(struct platform_device *pdev)inttsc_wires=0,adc_channels=0,total_channels;intreadouts=0;+/* 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;
@@ -164,13 +171,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");
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>
Makes sense and nice to get rid of these.
Reviewed-by: Jonathan Cameron <redacted>
@@ -177,10 +177,7 @@ struct ti_tscadc_dev {phys_addr_ttscadc_phys_base;conststructti_tscadc_data*data;intirq;-intused_cells;/* 1-2 */inttsc_wires;-inttsc_cell;/* -1 if not used */-intadc_cell;/* -1 if not used */structmfd_cellcells[TSCADC_CELLS];u32reg_se_cache;booladc_waiting;
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>
With the earlier reorganization this now obviously only doing what you say.
Thanks for tidying that up.
Reviewed-by: Jonathan Cameron <redacted>
@@ -223,16 +223,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;elsectrl|=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);
@@ -323,8 +323,10 @@ static int __maybe_unused tscadc_resume(struct device *dev)ctrl|=CNTRLREG_5WIRE|CNTRLREG_TSCENB;elsectrl|=CNTRLREG_4WIRE|CNTRLREG_TSCENB;-tscadc_idle_config(tscadc);}++tscadc_idle_config(tscadc);+ctrl|=CNTRLREG_TSCSSENB;regmap_write(tscadc->regmap,REG_CTRL,ctrl);
TI AM335X TRM [1] states that most of the configuration should be set in
the control register in the first place, before actually enabling the
hardware with the subsystem enable bit.
So far only half of the configuration was made in the first step (before
enabling the "subsystem"), which does not make really sense. Also, the
probe and the resume patch were acting differently. Let's harmonize all
this by following these steps:
1/ Configure the CLKDIV register
2/ Configure the CTRL register
3/ Configure the idle configuration
4/ Really enable the device by rewriting the CTRL register with the
subsystem enable bit set.
[1] https://www.ti.com/lit/pdf/spruh73
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
This tidies up the other patches which is good. Now I haven't checked the new
order against the datasheet but it now does things as you describe so I'm assuming
that's fine.
Reviewed-by: Jonathan Cameron <redacted>
@@ -221,8 +221,6 @@ static int ti_tscadc_probe(struct platform_device *pdev)/* Set the control register bits */ctrl=CNTRLREG_STEPCONFIGWRT|CNTRLREG_STEPID;-regmap_write(tscadc->regmap,REG_CTRL,ctrl);-if(tsc_wires>0){tscadc->tsc_wires=tsc_wires;if(tsc_wires==5)
@@ -230,6 +228,7 @@ static int ti_tscadc_probe(struct platform_device *pdev)elsectrl|=CNTRLREG_4WIRE|CNTRLREG_TSCENB;}+regmap_write(tscadc->regmap,REG_CTRL,ctrl);tscadc_idle_config(tscadc);
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>
@@ -121,7 +121,7 @@ static int ti_tscadc_probe(struct platform_device *pdev)structproperty*prop;const__be32*cur;u32val;-interr,ctrl;+interr;inttsc_wires=0,adc_channels=0,cell_idx=0,total_channels;intreadouts=0;
@@ -220,21 +220,20 @@ 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;+tscadc->ctrl=CNTRLREG_STEPCONFIGWRT|CNTRLREG_STEPID;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;}-regmap_write(tscadc->regmap,REG_CTRL,ctrl);+regmap_write(tscadc->regmap,REG_CTRL,tscadc->ctrl);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){
Convert masks to GENMASK() and regular shifts to BIT() in
ti_am335x_tscadc.h header.
Suggested-by: Jonathan Cameron <redacted>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Might be better two squash this and next patch together. I wrote a bunch
of 'use FIELD_PREP() here' comments before realising you've done that separately.
Still, for what is here looks good.
Reviewed-by: Jonathan Cameron <redacted>
Use the FIELD_PREP() macro when relevant. Sometimes reorder the lines to
be able to use the relevant bitmask.
Mind the s/%d/%ld/ change in a log due to the type change following the
use of FIELD_PREP() in the header.
Suggested-by: Jonathan Cameron <redacted>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
What you have here is fine, but I would take it a step further and push the
FIELD_PREP() calls directly inline in the code. There is little advantage
beyond saving a few characters in
STEPENB(3)
rather than
FIELD_PREP(STEPENB_MASK, 3)
If you don't want to go that far this is still an improvement so
Reviewed-by: Jonathan Cameron <redacted>
My inclination with these is to drop the macro entirely and
just use FIELD_PREP(STEPENB_MASK, xxx) inline directly.
There is no loss of clarity in doing so and it gets you to a state
where you only have one macro per field which is nice for checking
purposes.
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>
Given all I suggested last time was things you've done in earlier patches now
this LGTM
Reviewed-by: Jonathan Cameron <redacted>
@@ -220,13 +220,13 @@ 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;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;}regmap_write(tscadc->regmap,REG_CTRL,tscadc->ctrl);
Just checking the number of wires will soon not be enough, add a boolean
to indicated the actual use or not of the touchscreen.
Certain checks only make sense when there is a touchscreen wired. Make
this checks explicitly depend on the presence of the touchscreen.
@@ -120,6 +120,7 @@ static int ti_tscadc_probe(struct platform_device *pdev)structmfd_cell*cell;structproperty*prop;const__be32*cur;+booluse_tsc=false;u32val;interr;inttscmag_wires=0,adc_channels=0,cell_idx=0,total_channels;
@@ -143,6 +144,8 @@ static int ti_tscadc_probe(struct platform_device *pdev)of_property_read_u32(node,"ti,wires",&tscmag_wires);of_property_read_u32(node,"ti,coordiante-readouts",&readouts);of_node_put(node);+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){
@@ -168,7 +171,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;}
@@ -221,7 +224,7 @@ static int ti_tscadc_probe(struct platform_device *pdev)/* Set the control register bits */tscadc->ctrl=CNTRLREG_TSC_STEPCONFIGWRT|CNTRLREG_STEPID;-if(tscmag_wires>0){+if(use_tsc){tscadc->ctrl|=CNTRLREG_TSC_ENB;if(tscmag_wires==5)tscadc->ctrl|=CNTRLREG_TSC_5WIRE;
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 | 2 ++
1 file changed, 2 insertions(+)
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.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
I'm being lazy and not datasheet diving but otherwise looks good.
The HZ unit patch is in mm, but Linus hasn't merged it yet. May well be
in whatever tree this goes into post merge window though.
Reviewed-by: Jonathan Cameron <redacted>
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>
Looks good now.
Reviewed-by: Jonathan Cameron <redacted>
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 | 2 ++
1 file changed, 2 insertions(+)
From: Rob Herring <robh@kernel.org> Date: 2021-09-07 19:04:49
On Thu, 02 Sep 2021 23:51:04 +0200, Miquel Raynal 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>
---
Documentation/devicetree/bindings/mfd/ti,am3359-tscadc.yaml | 5 +++++
1 file changed, 5 insertions(+)
From: Rob Herring <robh@kernel.org> Date: 2021-09-07 19:05:24
On Thu, 02 Sep 2021 23:51:05 +0200, Miquel Raynal 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>
Acked-by: Jonathan Cameron <redacted>
---
Documentation/devicetree/bindings/iio/adc/ti,am3359-adc.yaml | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
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.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
I'm being lazy and not datasheet diving but otherwise looks good.
The HZ unit patch is in mm, but Linus hasn't merged it yet. May well be
in whatever tree this goes into post merge window though.
I'll rebase the series and add the use of the HZ_PER_MHZ macro :)
Thanks,
Miquèl