public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH 1/2] dt-bindings: iio: afe: current-sense-amplifier: Add io-channel-cells
@ 2025-09-03 11:36 Primoz Fiser
  2025-09-03 11:37 ` [PATCH 2/2] arm64: dts: freescale: imx93-phyboard-nash: Current sense via iio-hwmon Primoz Fiser
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Primoz Fiser @ 2025-09-03 11:36 UTC (permalink / raw)
  To: Peter Rosin, Jonathan Cameron, David Lechner, Nuno Sa,
	Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam
  Cc: linux-iio, devicetree, linux-kernel, imx, linux-arm-kernel,
	upstream

The current-sense-amplifier is an IIO provider thus can be referenced by
IIO consumers (via "io-channels" property in consumer device node). Such
provider is required to describe number of cells used in phandle lookup
with "io-channel-cells" property, otherwise the following kernel error
is present:

  OF: /iio-hwmon: could not get #io-channel-cells for /current-sense

Also fixes the following dtbs_check warning:

  current-sense: '#io-channel-cells' does not match any of the regexes:
  'pinctrl-[0-9]+' from schema $id:
  http://devicetree.org/schemas/iio/afe/current-sense-amplifier.yaml#

Fixes: fbac26b9ad21 ("dt-bindings:iio:afe:current-sense-amplifier: txt to yaml conversion.")
Signed-off-by: Primoz Fiser <primoz.fiser@norik.com>
---
 .../devicetree/bindings/iio/afe/current-sense-amplifier.yaml  | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/iio/afe/current-sense-amplifier.yaml b/Documentation/devicetree/bindings/iio/afe/current-sense-amplifier.yaml
index 527501c1d695..bcf4ddcfd13b 100644
--- a/Documentation/devicetree/bindings/iio/afe/current-sense-amplifier.yaml
+++ b/Documentation/devicetree/bindings/iio/afe/current-sense-amplifier.yaml
@@ -24,6 +24,9 @@ properties:
     description: |
       Channel node of a voltage io-channel.
 
+  "#io-channel-cells":
+    const: 0
+
   sense-resistor-micro-ohms:
     description: The sense resistance.
 
@@ -46,6 +49,7 @@ examples:
   - |
     sysi {
         compatible = "current-sense-amplifier";
+        #io-channel-cells = <0>;
         io-channels = <&tiadc 0>;
 
         sense-resistor-micro-ohms = <20000>;
-- 
2.34.1



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

* [PATCH 2/2] arm64: dts: freescale: imx93-phyboard-nash: Current sense via iio-hwmon
  2025-09-03 11:36 [PATCH 1/2] dt-bindings: iio: afe: current-sense-amplifier: Add io-channel-cells Primoz Fiser
@ 2025-09-03 11:37 ` Primoz Fiser
  2025-09-04  9:16 ` [PATCH 1/2] dt-bindings: iio: afe: current-sense-amplifier: Add io-channel-cells Krzysztof Kozlowski
  2025-09-04  9:17 ` Krzysztof Kozlowski
  2 siblings, 0 replies; 7+ messages in thread
From: Primoz Fiser @ 2025-09-03 11:37 UTC (permalink / raw)
  To: Peter Rosin, Jonathan Cameron, David Lechner, Nuno Sa,
	Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam
  Cc: linux-iio, devicetree, linux-kernel, imx, linux-arm-kernel,
	upstream

Commit 21179eae56de ("arm64: dts: freescale: imx93-phyboard-nash: Add
current sense amplifier") added information about the current sensing
circuitry found on the board. Now, lets provide current sense reading
also via IIO-hwmon subsystem. This way, SoM current can be read directly
via sysfs property more conveniently for the customers. No need for them
to manually apply scaling factor calculations anymore.

Signed-off-by: Primoz Fiser <primoz.fiser@norik.com>
---
 arch/arm64/boot/dts/freescale/imx93-phyboard-nash.dts | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/freescale/imx93-phyboard-nash.dts b/arch/arm64/boot/dts/freescale/imx93-phyboard-nash.dts
index 71a0e9f270af..d05645f25bba 100644
--- a/arch/arm64/boot/dts/freescale/imx93-phyboard-nash.dts
+++ b/arch/arm64/boot/dts/freescale/imx93-phyboard-nash.dts
@@ -27,8 +27,9 @@ chosen {
 		stdout-path = &lpuart1;
 	};
 
-	current-sense {
+	curr_sens: current-sense {
 		compatible = "current-sense-amplifier";
+		#io-channel-cells = <0>;
 		io-channels = <&adc1 1>;
 		sense-gain-div = <2>;
 		sense-gain-mult = <50>;
@@ -44,6 +45,11 @@ flexcan1_tc: can-phy0 {
 		standby-gpios = <&gpio4 16 GPIO_ACTIVE_HIGH>;
 	};
 
+	iio-hwmon {
+		compatible = "iio-hwmon";
+		io-channels = <&curr_sens 0>;
+	};
+
 	reg_usdhc2_vmmc: regulator-usdhc2 {
 		compatible = "regulator-fixed";
 		gpio = <&gpio3 7 GPIO_ACTIVE_HIGH>;
-- 
2.34.1



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

* Re: [PATCH 1/2] dt-bindings: iio: afe: current-sense-amplifier: Add io-channel-cells
  2025-09-03 11:36 [PATCH 1/2] dt-bindings: iio: afe: current-sense-amplifier: Add io-channel-cells Primoz Fiser
  2025-09-03 11:37 ` [PATCH 2/2] arm64: dts: freescale: imx93-phyboard-nash: Current sense via iio-hwmon Primoz Fiser
@ 2025-09-04  9:16 ` Krzysztof Kozlowski
  2025-09-04  9:17 ` Krzysztof Kozlowski
  2 siblings, 0 replies; 7+ messages in thread
From: Krzysztof Kozlowski @ 2025-09-04  9:16 UTC (permalink / raw)
  To: Primoz Fiser
  Cc: Peter Rosin, Jonathan Cameron, David Lechner, Nuno Sa,
	Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	linux-iio, devicetree, linux-kernel, imx, linux-arm-kernel,
	upstream

On Wed, Sep 03, 2025 at 01:36:59PM +0200, Primoz Fiser wrote:
> The current-sense-amplifier is an IIO provider thus can be referenced by
> IIO consumers (via "io-channels" property in consumer device node). Such
> provider is required to describe number of cells used in phandle lookup
> with "io-channel-cells" property, otherwise the following kernel error
> is present:
> 
>   OF: /iio-hwmon: could not get #io-channel-cells for /current-sense
> 
> Also fixes the following dtbs_check warning:
> 
>   current-sense: '#io-channel-cells' does not match any of the regexes:
>   'pinctrl-[0-9]+' from schema $id:
>   http://devicetree.org/schemas/iio/afe/current-sense-amplifier.yaml#

Which DTS has this warning? You did not include Makefile target and
quick look told me there is no such...

> 
> Fixes: fbac26b9ad21 ("dt-bindings:iio:afe:current-sense-amplifier: txt to yaml conversion.")
> Signed-off-by: Primoz Fiser <primoz.fiser@norik.com>

Best regards,
Krzysztof



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

* Re: [PATCH 1/2] dt-bindings: iio: afe: current-sense-amplifier: Add io-channel-cells
  2025-09-03 11:36 [PATCH 1/2] dt-bindings: iio: afe: current-sense-amplifier: Add io-channel-cells Primoz Fiser
  2025-09-03 11:37 ` [PATCH 2/2] arm64: dts: freescale: imx93-phyboard-nash: Current sense via iio-hwmon Primoz Fiser
  2025-09-04  9:16 ` [PATCH 1/2] dt-bindings: iio: afe: current-sense-amplifier: Add io-channel-cells Krzysztof Kozlowski
@ 2025-09-04  9:17 ` Krzysztof Kozlowski
  2025-09-04 10:15   ` Primoz Fiser
  2 siblings, 1 reply; 7+ messages in thread
From: Krzysztof Kozlowski @ 2025-09-04  9:17 UTC (permalink / raw)
  To: Primoz Fiser
  Cc: Peter Rosin, Jonathan Cameron, David Lechner, Nuno Sa,
	Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	linux-iio, devicetree, linux-kernel, imx, linux-arm-kernel,
	upstream

On Wed, Sep 03, 2025 at 01:36:59PM +0200, Primoz Fiser wrote:
> The current-sense-amplifier is an IIO provider thus can be referenced by
> IIO consumers (via "io-channels" property in consumer device node). Such
> provider is required to describe number of cells used in phandle lookup
> with "io-channel-cells" property, otherwise the following kernel error
> is present:
> 
>   OF: /iio-hwmon: could not get #io-channel-cells for /current-sense

Also, how can I reproduce this error? Do you paste here real errors or
just some invented ones from some out of tree code (hint: such would not
be relevant).

> 
> Also fixes the following dtbs_check warning:
> 
>   current-sense: '#io-channel-cells' does not match any of the regexes:
>   'pinctrl-[0-9]+' from schema $id:
>   http://devicetree.org/schemas/iio/afe/current-sense-amplifier.yaml#

Best regards,
Krzysztof



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

* Re: [PATCH 1/2] dt-bindings: iio: afe: current-sense-amplifier: Add io-channel-cells
  2025-09-04  9:17 ` Krzysztof Kozlowski
@ 2025-09-04 10:15   ` Primoz Fiser
  2025-09-04 10:44     ` Krzysztof Kozlowski
  0 siblings, 1 reply; 7+ messages in thread
From: Primoz Fiser @ 2025-09-04 10:15 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Peter Rosin, Jonathan Cameron, David Lechner, Nuno Sa,
	Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	linux-iio, devicetree, linux-kernel, imx, linux-arm-kernel,
	upstream

Hi Krzysztof,

On 4. 09. 25 11:17, Krzysztof Kozlowski wrote:
> On Wed, Sep 03, 2025 at 01:36:59PM +0200, Primoz Fiser wrote:
>> The current-sense-amplifier is an IIO provider thus can be referenced by
>> IIO consumers (via "io-channels" property in consumer device node). Such
>> provider is required to describe number of cells used in phandle lookup
>> with "io-channel-cells" property, otherwise the following kernel error
>> is present:
>>
>>    OF: /iio-hwmon: could not get #io-channel-cells for /current-sense
> 
> Also, how can I reproduce this error? Do you paste here real errors or
> just some invented ones from some out of tree code (hint: such would not
> be relevant).

I get this error if I apply patch #2 without patch #1. See [1] for more 
details.

BR,
Primoz


[1] 
https://lore.kernel.org/all/20250903113700.3079626-1-primoz.fiser@norik.com/

> 
>>
>> Also fixes the following dtbs_check warning:
>>
>>    current-sense: '#io-channel-cells' does not match any of the regexes:
>>    'pinctrl-[0-9]+' from schema $id:
>>    http://devicetree.org/schemas/iio/afe/current-sense-amplifier.yaml#
> 
> Best regards,
> Krzysztof
> 



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

* Re: [PATCH 1/2] dt-bindings: iio: afe: current-sense-amplifier: Add io-channel-cells
  2025-09-04 10:15   ` Primoz Fiser
@ 2025-09-04 10:44     ` Krzysztof Kozlowski
  2025-09-04 11:20       ` Peter Rosin
  0 siblings, 1 reply; 7+ messages in thread
From: Krzysztof Kozlowski @ 2025-09-04 10:44 UTC (permalink / raw)
  To: Primoz Fiser
  Cc: Peter Rosin, Jonathan Cameron, David Lechner, Nuno Sa,
	Andy Shevchenko, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	linux-iio, devicetree, linux-kernel, imx, linux-arm-kernel,
	upstream

On 04/09/2025 12:15, Primoz Fiser wrote:
> Hi Krzysztof,
> 
> On 4. 09. 25 11:17, Krzysztof Kozlowski wrote:
>> On Wed, Sep 03, 2025 at 01:36:59PM +0200, Primoz Fiser wrote:
>>> The current-sense-amplifier is an IIO provider thus can be referenced by
>>> IIO consumers (via "io-channels" property in consumer device node). Such
>>> provider is required to describe number of cells used in phandle lookup
>>> with "io-channel-cells" property, otherwise the following kernel error
>>> is present:
>>>
>>>    OF: /iio-hwmon: could not get #io-channel-cells for /current-sense
>>
>> Also, how can I reproduce this error? Do you paste here real errors or
>> just some invented ones from some out of tree code (hint: such would not
>> be relevant).
> 
> I get this error if I apply patch #2 without patch #1. See [1] for more 
> details.
Then your warning is not relevant here.

You said in your commit there is a bug, expressed with that warning, so
you make this commit. Turns out there is no bug, so all the reasons for
this commit are gone.

Rephrase the commit msg to describe accurate reasons WHY you are doing
this. Drop non-existing warnings and any misleading fixes tag, since
there is no bug being fixed.
Best regards,
Krzysztof


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

* Re: [PATCH 1/2] dt-bindings: iio: afe: current-sense-amplifier: Add io-channel-cells
  2025-09-04 10:44     ` Krzysztof Kozlowski
@ 2025-09-04 11:20       ` Peter Rosin
  0 siblings, 0 replies; 7+ messages in thread
From: Peter Rosin @ 2025-09-04 11:20 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Primoz Fiser
  Cc: Jonathan Cameron, David Lechner, Nuno Sa, Andy Shevchenko,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam, linux-iio,
	devicetree, linux-kernel, imx, linux-arm-kernel, upstream

Hi!

2025-09-04 at 12:44, Krzysztof Kozlowski wrote:
> On 04/09/2025 12:15, Primoz Fiser wrote:
>> Hi Krzysztof,
>>
>> On 4. 09. 25 11:17, Krzysztof Kozlowski wrote:
>>> On Wed, Sep 03, 2025 at 01:36:59PM +0200, Primoz Fiser wrote:
>>>> The current-sense-amplifier is an IIO provider thus can be referenced by
>>>> IIO consumers (via "io-channels" property in consumer device node). Such
>>>> provider is required to describe number of cells used in phandle lookup
>>>> with "io-channel-cells" property, otherwise the following kernel error
>>>> is present:
>>>>
>>>>    OF: /iio-hwmon: could not get #io-channel-cells for /current-sense
>>>
>>> Also, how can I reproduce this error? Do you paste here real errors or
>>> just some invented ones from some out of tree code (hint: such would not
>>> be relevant).
>>
>> I get this error if I apply patch #2 without patch #1. See [1] for more 
>> details.
> Then your warning is not relevant here.
> 
> You said in your commit there is a bug, expressed with that warning, so
> you make this commit. Turns out there is no bug, so all the reasons for
> this commit are gone.
> 
> Rephrase the commit msg to describe accurate reasons WHY you are doing
> this. Drop non-existing warnings and any misleading fixes tag, since
> there is no bug being fixed.

If it's a bug in the conversion or not could be debated. With the old
txt binding it was allowed to add #io-channel-cells, after the yaml
conversion it is no longer allowed to do so. It has always been the
intention that there is an option to add an #io-channel-cells property,
so you could of course claim that the bug was also present in the txt
binding. However, when the txt binding was written, that fact was
implied from the generic iio-bindings.txt which had this in it:

==IIO providers==

Required properties:
#io-channel-cells: Number of cells in an IIO specifier; Typically 0 for nodes
		   with a single IIO output and 1 for nodes with multiple
		   IIO outputs.

So, I claim that the conversion commit is at fault, since it locked
things down (additionalProperties: false) with unintended consequences.

For reference, see commit
f1f99fcbf997 ("dt-bindings: iio: afe: voltage-divider: Add io-channel-cells")
which unfortunately locks the cell count to 1 which is bogus as 0 is
the natural cell count for all the bindings backed by the rescaler
driver. They all have only one output.

Cheers,
Peter


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

end of thread, other threads:[~2025-09-04 12:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-03 11:36 [PATCH 1/2] dt-bindings: iio: afe: current-sense-amplifier: Add io-channel-cells Primoz Fiser
2025-09-03 11:37 ` [PATCH 2/2] arm64: dts: freescale: imx93-phyboard-nash: Current sense via iio-hwmon Primoz Fiser
2025-09-04  9:16 ` [PATCH 1/2] dt-bindings: iio: afe: current-sense-amplifier: Add io-channel-cells Krzysztof Kozlowski
2025-09-04  9:17 ` Krzysztof Kozlowski
2025-09-04 10:15   ` Primoz Fiser
2025-09-04 10:44     ` Krzysztof Kozlowski
2025-09-04 11:20       ` Peter Rosin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox