linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ARM: dts: vf610-zii-dev-rev-b: add hi8435 device
@ 2017-05-22 13:10 Nikita Yushchenko
  2017-05-22 16:20 ` Stefan Agner
  2017-05-25  7:00 ` Shawn Guo
  0 siblings, 2 replies; 11+ messages in thread
From: Nikita Yushchenko @ 2017-05-22 13:10 UTC (permalink / raw)
  To: Shawn Guo, Sascha Hauer, Stefan Agner, Rob Herring, Mark Rutland,
	Russell King
  Cc: linux-arm-kernel, devicetree, linux-kernel, Jonathan Cameron,
	Chris Healy, Jeff White, Nikita Yushchenko

ZII dev board rev B has a Holt Hi8435 connected to dspi2.
Add it to device tree.

ZII dev board rev C does not have that, so use rev-b dts file,
not common dtsi file.

Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
---
 arch/arm/boot/dts/vf610-zii-dev-rev-b.dts | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/arch/arm/boot/dts/vf610-zii-dev-rev-b.dts b/arch/arm/boot/dts/vf610-zii-dev-rev-b.dts
index 37f95427616f..f433465c3a7c 100644
--- a/arch/arm/boot/dts/vf610-zii-dev-rev-b.dts
+++ b/arch/arm/boot/dts/vf610-zii-dev-rev-b.dts
@@ -348,6 +348,25 @@
 	};
 };
 
+&edma1 {
+	status = "okay";
+};
+
+&dspi2 {
+	bus-num = <1>;
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_dspi2>;
+	status = "okay";
+	spi-num-chipselects = <2>;
+
+	hi8435@1 {
+		compatible = "holt,hi8435";
+		reg = <1>;
+		spi-max-frequency = <20000000>;
+		gpios = <&gpio5 3 0>;
+	};
+};
+
 &i2c0 {
 	clock-frequency = <100000>;
 	pinctrl-names = "default";
-- 
2.11.0

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

* Re: [PATCH] ARM: dts: vf610-zii-dev-rev-b: add hi8435 device
  2017-05-22 13:10 [PATCH] ARM: dts: vf610-zii-dev-rev-b: add hi8435 device Nikita Yushchenko
@ 2017-05-22 16:20 ` Stefan Agner
  2017-05-22 16:29   ` Nikita Yushchenko
  2017-05-25  7:00 ` Shawn Guo
  1 sibling, 1 reply; 11+ messages in thread
From: Stefan Agner @ 2017-05-22 16:20 UTC (permalink / raw)
  To: Nikita Yushchenko
  Cc: Shawn Guo, Sascha Hauer, Rob Herring, Mark Rutland, Russell King,
	linux-arm-kernel, devicetree, linux-kernel, Jonathan Cameron,
	Chris Healy, Jeff White

On 2017-05-22 06:10, Nikita Yushchenko wrote:
> ZII dev board rev B has a Holt Hi8435 connected to dspi2.
> Add it to device tree.
> 
> ZII dev board rev C does not have that, so use rev-b dts file,
> not common dtsi file.
> 
> Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
> ---
>  arch/arm/boot/dts/vf610-zii-dev-rev-b.dts | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/vf610-zii-dev-rev-b.dts
> b/arch/arm/boot/dts/vf610-zii-dev-rev-b.dts
> index 37f95427616f..f433465c3a7c 100644
> --- a/arch/arm/boot/dts/vf610-zii-dev-rev-b.dts
> +++ b/arch/arm/boot/dts/vf610-zii-dev-rev-b.dts
> @@ -348,6 +348,25 @@
>  	};
>  };
>  
> +&edma1 {
> +	status = "okay";
> +};
> +
> +&dspi2 {
> +	bus-num = <1>;
> +	pinctrl-names = "default";
> +	pinctrl-0 = <&pinctrl_dspi2>;
> +	status = "okay";
> +	spi-num-chipselects = <2>;
> +
> +	hi8435@1 {
> +		compatible = "holt,hi8435";
> +		reg = <1>;
> +		spi-max-frequency = <20000000>;
> +		gpios = <&gpio5 3 0>;

Nit: GPIO_ACTIVE_HIGH instead of 0?

--
Stefan

> +	};
> +};
> +
>  &i2c0 {
>  	clock-frequency = <100000>;
>  	pinctrl-names = "default";

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

* Re: [PATCH] ARM: dts: vf610-zii-dev-rev-b: add hi8435 device
  2017-05-22 16:20 ` Stefan Agner
@ 2017-05-22 16:29   ` Nikita Yushchenko
  2017-05-22 18:21     ` Andrew Lunn
  0 siblings, 1 reply; 11+ messages in thread
From: Nikita Yushchenko @ 2017-05-22 16:29 UTC (permalink / raw)
  To: Stefan Agner
  Cc: Shawn Guo, Sascha Hauer, Rob Herring, Mark Rutland, Russell King,
	linux-arm-kernel, devicetree, linux-kernel, Jonathan Cameron,
	Chris Healy, Jeff White, Vladimir Barinov

>> +	hi8435@1 {
>> +		compatible = "holt,hi8435";
>> +		reg = <1>;
>> +		spi-max-frequency = <20000000>;
>> +		gpios = <&gpio5 3 0>;
> 
> Nit: GPIO_ACTIVE_HIGH instead of 0?

Gray area here.

Chip's reset input is active LOW.

However, hi8435 driver historically was coded using inverted values
passed to gpiolib calls.  And there are setups in the wild with device
trees containing GPIO_ACTIVE_HIGH that I'd prefer not breaking.

To solve, I submitted a patch on hi8435 driver that changes to _raw()
gpio calls (thus making it independent of what is written in device
tree), and want [future] device trees not to contain explicitly written
gpio polarity.

Far not ideal but better than device trees explicitly stating
GPIO_ACTIVE_HIGH while it is active low.

Nikita

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

* Re: [PATCH] ARM: dts: vf610-zii-dev-rev-b: add hi8435 device
  2017-05-22 16:29   ` Nikita Yushchenko
@ 2017-05-22 18:21     ` Andrew Lunn
  2017-05-23  6:02       ` Nikita Yushchenko
  0 siblings, 1 reply; 11+ messages in thread
From: Andrew Lunn @ 2017-05-22 18:21 UTC (permalink / raw)
  To: Nikita Yushchenko
  Cc: Stefan Agner, Mark Rutland, devicetree, Jeff White, Russell King,
	linux-kernel, Rob Herring, Jonathan Cameron, Sascha Hauer,
	Vladimir Barinov, Shawn Guo, linux-arm-kernel, Chris Healy

On Mon, May 22, 2017 at 07:29:14PM +0300, Nikita Yushchenko wrote:
> >> +	hi8435@1 {
> >> +		compatible = "holt,hi8435";
> >> +		reg = <1>;
> >> +		spi-max-frequency = <20000000>;
> >> +		gpios = <&gpio5 3 0>;
> > 
> > Nit: GPIO_ACTIVE_HIGH instead of 0?
> 
> Gray area here.
> 
> Chip's reset input is active LOW.

Nikita

There second issue here is that you are going to be getting newbies
looking at .dts files and submitting patches to replace the 0 with
GPIO_ACTIVE_HIGH in all files, just like they submit patches fixing
checkpatch warnings. 

> However, hi8435 driver historically was coded using inverted values
> passed to gpiolib calls.  And there are setups in the wild with device
> trees containing GPIO_ACTIVE_HIGH that I'd prefer not breaking.
> 
> To solve, I submitted a patch on hi8435 driver that changes to _raw()
> gpio calls (thus making it independent of what is written in device
> tree), and want [future] device trees not to contain explicitly written
> gpio polarity.

So maybe add another #define, GPIO_ACTIVE_IGNORED, to make it clear
that it does not matter what value you put there, it is ignored.

     Andrew

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

* Re: [PATCH] ARM: dts: vf610-zii-dev-rev-b: add hi8435 device
  2017-05-22 18:21     ` Andrew Lunn
@ 2017-05-23  6:02       ` Nikita Yushchenko
  2017-05-25  7:19         ` Shawn Guo
  0 siblings, 1 reply; 11+ messages in thread
From: Nikita Yushchenko @ 2017-05-23  6:02 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Stefan Agner, Mark Rutland, devicetree, Jeff White, Russell King,
	linux-kernel, Rob Herring, Jonathan Cameron, Sascha Hauer,
	Vladimir Barinov, Shawn Guo, linux-arm-kernel, Chris Healy

>> However, hi8435 driver historically was coded using inverted values
>> passed to gpiolib calls.  And there are setups in the wild with device
>> trees containing GPIO_ACTIVE_HIGH that I'd prefer not breaking.
>>
>> To solve, I submitted a patch on hi8435 driver that changes to _raw()
>> gpio calls (thus making it independent of what is written in device
>> tree), and want [future] device trees not to contain explicitly written
>> gpio polarity.
> 
> So maybe add another #define, GPIO_ACTIVE_IGNORED, to make it clear
> that it does not matter what value you put there, it is ignored.

"Crap origin" here is that in vast majority of cases, polarity is
per-chip, not per-chip-use, knowledge. And proper location for per-chip
knowledge is chip's driver.  Moving this knowledge to per-chip-use
location in device trees only provides a source for errors, with little
gain.

Vladimir Barinov mentions possibility that signal can be inverted by
board between gpio provider and chip's pin ...   but do we have at least
one practical case of this?  And if we even do, it's quite uncommon, and
something special should be required in device tree for these special
cases and not for "normal" cases.

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

* Re: [PATCH] ARM: dts: vf610-zii-dev-rev-b: add hi8435 device
  2017-05-22 13:10 [PATCH] ARM: dts: vf610-zii-dev-rev-b: add hi8435 device Nikita Yushchenko
  2017-05-22 16:20 ` Stefan Agner
@ 2017-05-25  7:00 ` Shawn Guo
  2017-05-25  8:06   ` Nikita Yushchenko
  1 sibling, 1 reply; 11+ messages in thread
From: Shawn Guo @ 2017-05-25  7:00 UTC (permalink / raw)
  To: Nikita Yushchenko
  Cc: Sascha Hauer, Stefan Agner, Rob Herring, Mark Rutland,
	Russell King, linux-arm-kernel, devicetree, linux-kernel,
	Jonathan Cameron, Chris Healy, Jeff White

On Mon, May 22, 2017 at 04:10:10PM +0300, Nikita Yushchenko wrote:
> ZII dev board rev B has a Holt Hi8435 connected to dspi2.
> Add it to device tree.
> 
> ZII dev board rev C does not have that, so use rev-b dts file,
> not common dtsi file.
> 
> Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
> ---
>  arch/arm/boot/dts/vf610-zii-dev-rev-b.dts | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/vf610-zii-dev-rev-b.dts b/arch/arm/boot/dts/vf610-zii-dev-rev-b.dts
> index 37f95427616f..f433465c3a7c 100644
> --- a/arch/arm/boot/dts/vf610-zii-dev-rev-b.dts
> +++ b/arch/arm/boot/dts/vf610-zii-dev-rev-b.dts
> @@ -348,6 +348,25 @@
>  	};
>  };
>  
> +&edma1 {
> +	status = "okay";
> +};
> +
> +&dspi2 {

Please keep these labelled nodes sort alphabetically.

> +	bus-num = <1>;
> +	pinctrl-names = "default";
> +	pinctrl-0 = <&pinctrl_dspi2>;
> +	status = "okay";

We usually have 'status' line at the bottom of property list.

> +	spi-num-chipselects = <2>;
> +
> +	hi8435@1 {

Node name should be something generic, while label can be specific
model name.  The following form might be better.

	hi8435: sensor@1

Shawn

> +		compatible = "holt,hi8435";
> +		reg = <1>;
> +		spi-max-frequency = <20000000>;
> +		gpios = <&gpio5 3 0>;
> +	};
> +};
> +
>  &i2c0 {
>  	clock-frequency = <100000>;
>  	pinctrl-names = "default";
> -- 
> 2.11.0
> 

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

* Re: [PATCH] ARM: dts: vf610-zii-dev-rev-b: add hi8435 device
  2017-05-23  6:02       ` Nikita Yushchenko
@ 2017-05-25  7:19         ` Shawn Guo
  2017-05-25  8:03           ` Nikita Yushchenko
  0 siblings, 1 reply; 11+ messages in thread
From: Shawn Guo @ 2017-05-25  7:19 UTC (permalink / raw)
  To: Nikita Yushchenko
  Cc: Andrew Lunn, Stefan Agner, Mark Rutland, devicetree, Jeff White,
	Russell King, linux-kernel, Rob Herring, Jonathan Cameron,
	Sascha Hauer, Vladimir Barinov, linux-arm-kernel, Chris Healy

On Tue, May 23, 2017 at 09:02:27AM +0300, Nikita Yushchenko wrote:
> >> However, hi8435 driver historically was coded using inverted values
> >> passed to gpiolib calls.  And there are setups in the wild with device
> >> trees containing GPIO_ACTIVE_HIGH that I'd prefer not breaking.
> >>
> >> To solve, I submitted a patch on hi8435 driver that changes to _raw()
> >> gpio calls (thus making it independent of what is written in device
> >> tree), and want [future] device trees not to contain explicitly written
> >> gpio polarity.
> > 
> > So maybe add another #define, GPIO_ACTIVE_IGNORED, to make it clear
> > that it does not matter what value you put there, it is ignored.
> 
> "Crap origin" here is that in vast majority of cases, polarity is
> per-chip, not per-chip-use, knowledge. And proper location for per-chip
> knowledge is chip's driver.  Moving this knowledge to per-chip-use
> location in device trees only provides a source for errors, with little
> gain.
> 
> Vladimir Barinov mentions possibility that signal can be inverted by
> board between gpio provider and chip's pin ...   but do we have at least
> one practical case of this?  And if we even do, it's quite uncommon, and
> something special should be required in device tree for these special
> cases and not for "normal" cases.

I disagree.  Not for hi8435, but I have seen quite some board designs
invert GPIOs before getting them into board level components.  That's
why we should define those xxx-gpios properties on board level DTS,
where polarity can be chosen per board design.

Shawn

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

* Re: [PATCH] ARM: dts: vf610-zii-dev-rev-b: add hi8435 device
  2017-05-25  7:19         ` Shawn Guo
@ 2017-05-25  8:03           ` Nikita Yushchenko
  2017-05-28 15:09             ` Jonathan Cameron
  0 siblings, 1 reply; 11+ messages in thread
From: Nikita Yushchenko @ 2017-05-25  8:03 UTC (permalink / raw)
  To: Shawn Guo
  Cc: Andrew Lunn, Stefan Agner, Mark Rutland, devicetree, Jeff White,
	Russell King, linux-kernel, Rob Herring, Jonathan Cameron,
	Sascha Hauer, Vladimir Barinov, linux-arm-kernel, Chris Healy

>> "Crap origin" here is that in vast majority of cases, polarity is
>> per-chip, not per-chip-use, knowledge. And proper location for per-chip
>> knowledge is chip's driver.  Moving this knowledge to per-chip-use
>> location in device trees only provides a source for errors, with little
>> gain.
>>
>> Vladimir Barinov mentions possibility that signal can be inverted by
>> board between gpio provider and chip's pin ...   but do we have at least
>> one practical case of this?  And if we even do, it's quite uncommon, and
>> something special should be required in device tree for these special
>> cases and not for "normal" cases.
> 
> I disagree.  Not for hi8435, but I have seen quite some board designs
> invert GPIOs before getting them into board level components.  That's
> why we should define those xxx-gpios properties on board level DTS,
> where polarity can be chosen per board design.

Even if such, still board specific knowledge is "is gpio as-is or
inverted", but knowledge if chip expects signal to be active low or
active high, remains chip-specific.

I'm thinking of proposing new flags in gpio binding, say
GPIO_NATIVE_POLARITY / GPIO_INVERTED_POLARITY,  that could be used
instead of GPIO_ACTIVE_HIGH / GPIO_ACTIVE_LOW, and leave knowledge about
signal polarity to chip's driver, while still allow to describe
inversion of needed.

Nikita

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

* Re: [PATCH] ARM: dts: vf610-zii-dev-rev-b: add hi8435 device
  2017-05-25  7:00 ` Shawn Guo
@ 2017-05-25  8:06   ` Nikita Yushchenko
  2017-05-25  8:20     ` Shawn Guo
  0 siblings, 1 reply; 11+ messages in thread
From: Nikita Yushchenko @ 2017-05-25  8:06 UTC (permalink / raw)
  To: Shawn Guo
  Cc: Sascha Hauer, Stefan Agner, Rob Herring, Mark Rutland,
	Russell King, linux-arm-kernel, devicetree, linux-kernel,
	Jonathan Cameron, Chris Healy, Jeff White

>> +&edma1 {
>> +	status = "okay";
>> +};
>> +
>> +&dspi2 {
> 
> Please keep these labelled nodes sort alphabetically.

Ok

>> +	bus-num = <1>;
>> +	pinctrl-names = "default";
>> +	pinctrl-0 = <&pinctrl_dspi2>;
>> +	status = "okay";
> 
> We usually have 'status' line at the bottom of property list.

Ok

>> +	spi-num-chipselects = <2>;
>> +
>> +	hi8435@1 {
> 
> Node name should be something generic, while label can be specific
> model name.  The following form might be better.
> 
> 	hi8435: sensor@1

Ok

Although the same file, in lines nearby, has m25p128@0 and at93c46d@1.

Anyway let's delay this a bit, up to the reset polarity description
thing in hi8435 is resolved.

Nikita

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

* Re: [PATCH] ARM: dts: vf610-zii-dev-rev-b: add hi8435 device
  2017-05-25  8:06   ` Nikita Yushchenko
@ 2017-05-25  8:20     ` Shawn Guo
  0 siblings, 0 replies; 11+ messages in thread
From: Shawn Guo @ 2017-05-25  8:20 UTC (permalink / raw)
  To: Nikita Yushchenko
  Cc: Sascha Hauer, Stefan Agner, Rob Herring, Mark Rutland,
	Russell King, linux-arm-kernel, devicetree, linux-kernel,
	Jonathan Cameron, Chris Healy, Jeff White

On Thu, May 25, 2017 at 11:06:47AM +0300, Nikita Yushchenko wrote:
> >> +&edma1 {
> >> +	status = "okay";
> >> +};
> >> +
> >> +&dspi2 {
> > 
> > Please keep these labelled nodes sort alphabetically.
> 
> Ok
> 
> >> +	bus-num = <1>;
> >> +	pinctrl-names = "default";
> >> +	pinctrl-0 = <&pinctrl_dspi2>;
> >> +	status = "okay";
> > 
> > We usually have 'status' line at the bottom of property list.
> 
> Ok
> 
> >> +	spi-num-chipselects = <2>;
> >> +
> >> +	hi8435@1 {
> > 
> > Node name should be something generic, while label can be specific
> > model name.  The following form might be better.
> > 
> > 	hi8435: sensor@1
> 
> Ok
> 
> Although the same file, in lines nearby, has m25p128@0 and at93c46d@1.

It seems that I need more eyes to help review.

Shawn

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

* Re: [PATCH] ARM: dts: vf610-zii-dev-rev-b: add hi8435 device
  2017-05-25  8:03           ` Nikita Yushchenko
@ 2017-05-28 15:09             ` Jonathan Cameron
  0 siblings, 0 replies; 11+ messages in thread
From: Jonathan Cameron @ 2017-05-28 15:09 UTC (permalink / raw)
  To: Nikita Yushchenko
  Cc: Shawn Guo, Andrew Lunn, Stefan Agner, Mark Rutland, devicetree,
	Jeff White, Russell King, linux-kernel, Rob Herring,
	Sascha Hauer, Vladimir Barinov, linux-arm-kernel, Chris Healy

On Thu, 25 May 2017 11:03:20 +0300
Nikita Yushchenko <nikita.yoush@cogentembedded.com> wrote:

> >> "Crap origin" here is that in vast majority of cases, polarity is
> >> per-chip, not per-chip-use, knowledge. And proper location for per-chip
> >> knowledge is chip's driver.  Moving this knowledge to per-chip-use
> >> location in device trees only provides a source for errors, with little
> >> gain.
> >>
> >> Vladimir Barinov mentions possibility that signal can be inverted by
> >> board between gpio provider and chip's pin ...   but do we have at least
> >> one practical case of this?  And if we even do, it's quite uncommon, and
> >> something special should be required in device tree for these special
> >> cases and not for "normal" cases.  
> > 
> > I disagree.  Not for hi8435, but I have seen quite some board designs
> > invert GPIOs before getting them into board level components.  That's
> > why we should define those xxx-gpios properties on board level DTS,
> > where polarity can be chosen per board design.  
> 
> Even if such, still board specific knowledge is "is gpio as-is or
> inverted", but knowledge if chip expects signal to be active low or
> active high, remains chip-specific.
> 
> I'm thinking of proposing new flags in gpio binding, say
> GPIO_NATIVE_POLARITY / GPIO_INVERTED_POLARITY,  that could be used
> instead of GPIO_ACTIVE_HIGH / GPIO_ACTIVE_LOW, and leave knowledge about
> signal polarity to chip's driver, while still allow to describe
> inversion of needed.
Whilst I'm not certain on the precise approach (I'd be tempted by
heavy handed explicit representation of the inverting component) it
seems like this needs more thought.  I'm going to revert my
rather premature applying of the initial change for now.

Jonathan
> 
> Nikita

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

end of thread, other threads:[~2017-05-28 15:09 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-22 13:10 [PATCH] ARM: dts: vf610-zii-dev-rev-b: add hi8435 device Nikita Yushchenko
2017-05-22 16:20 ` Stefan Agner
2017-05-22 16:29   ` Nikita Yushchenko
2017-05-22 18:21     ` Andrew Lunn
2017-05-23  6:02       ` Nikita Yushchenko
2017-05-25  7:19         ` Shawn Guo
2017-05-25  8:03           ` Nikita Yushchenko
2017-05-28 15:09             ` Jonathan Cameron
2017-05-25  7:00 ` Shawn Guo
2017-05-25  8:06   ` Nikita Yushchenko
2017-05-25  8:20     ` Shawn Guo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).