diff mbox

ARM: dts: vf610-zii-dev-rev-b: add hi8435 device

Message ID 20170522131010.3537-1-nikita.yoush@cogentembedded.com (mailing list archive)
State New, archived
Headers show

Commit Message

Nikita Yushchenko May 22, 2017, 1:10 p.m. UTC
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(+)

Comments

Stefan Agner May 22, 2017, 4:20 p.m. UTC | #1
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";
Nikita Yushchenko May 22, 2017, 4:29 p.m. UTC | #2
>> +	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
Andrew Lunn May 22, 2017, 6:21 p.m. UTC | #3
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
Nikita Yushchenko May 23, 2017, 6:02 a.m. UTC | #4
>> 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.
Shawn Guo May 25, 2017, 7 a.m. UTC | #5
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
>
Shawn Guo May 25, 2017, 7:19 a.m. UTC | #6
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
Nikita Yushchenko May 25, 2017, 8:03 a.m. UTC | #7
>> "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
Nikita Yushchenko May 25, 2017, 8:06 a.m. UTC | #8
>> +&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
Shawn Guo May 25, 2017, 8:20 a.m. UTC | #9
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
Jonathan Cameron May 28, 2017, 3:09 p.m. UTC | #10
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
diff mbox

Patch

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";