2021-01-06 11:39:44

by Ralf Schlatterbeck

[permalink] [raw]
Subject: [PATCH 0/1] auxdisplay: Add I2C gpio expander example

The Hitachi HD44780 is often used together with a PCF8574 based I2C
I/O expander. It was non-obvious to me that the existing parallel
connected version of the auxdisplay driver can already handle this
configuration with appropriate device tree magic. This patch documents
the necessary incantations in an example.

That this is not only non-obvious to me is documented by at least two
I2C kernel implementations for the display out there.

Thanks to Geert Uytterhoeven for pointing out how this is done.
Thanks to Miguel Ojeda for extensively commenting on my previous patch.

.../bindings/auxdisplay/hit,hd44780.yaml | 31 ++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)

Ralf
--
Ralf Schlatterbeck Tel: +43/2243/26465-16
Open Source Consulting www: http://www.runtux.com
Reichergasse 131, A-3411 Weidling email: [email protected]


2021-01-06 11:43:28

by Ralf Schlatterbeck

[permalink] [raw]
Subject: [PATCH 1/1] auxdisplay: Add I2C gpio expander example

The hd44780 displays are often used with pcf8574 based I/O expanders.
Add example to documentation.

Signed-off-by: Ralf Schlatterbeck <[email protected]>
---
.../bindings/auxdisplay/hit,hd44780.yaml | 31 ++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/auxdisplay/hit,hd44780.yaml b/Documentation/devicetree/bindings/auxdisplay/hit,hd44780.yaml
index 9222b06e93a0..0ec2ce7b1df1 100644
--- a/Documentation/devicetree/bindings/auxdisplay/hit,hd44780.yaml
+++ b/Documentation/devicetree/bindings/auxdisplay/hit,hd44780.yaml
@@ -12,7 +12,10 @@ maintainers:
description:
The Hitachi HD44780 Character LCD Controller is commonly used on character
LCDs that can display one or more lines of text. It exposes an M6800 bus
- interface, which can be used in either 4-bit or 8-bit mode.
+ interface, which can be used in either 4-bit or 8-bit mode. By using a
+ GPIO expander it is possible to use the driver with one of the popular I2C
+ expander boards based on the PCF8574 available for these displays. For
+ an example see below.

properties:
compatible:
@@ -94,3 +97,29 @@ examples:
display-height-chars = <2>;
display-width-chars = <16>;
};
+ - |
+ #include <dt-bindings/gpio/gpio.h>
+ i2c@2000 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ pcf8574: pcf8574@27 {
+ compatible = "nxp,pcf8574";
+ reg = <0x27>;
+ gpio-controller;
+ #gpio-cells = <2>;
+ };
+ };
+ hd44780 {
+ compatible = "hit,hd44780";
+ display-height-chars = <2>;
+ display-width-chars = <16>;
+ data-gpios = <&pcf8574 4 0>,
+ <&pcf8574 5 0>,
+ <&pcf8574 6 0>,
+ <&pcf8574 7 0>;
+ enable-gpios = <&pcf8574 2 0>;
+ rs-gpios = <&pcf8574 0 0>;
+ rw-gpios = <&pcf8574 1 0>;
+ backlight-gpios = <&pcf8574 3 0>;
+ };
--
2.20.1

2021-01-06 12:15:36

by Miguel Ojeda

[permalink] [raw]
Subject: Re: [PATCH 0/1] auxdisplay: Add I2C gpio expander example

On Wed, Jan 6, 2021 at 12:37 PM Ralf Schlatterbeck <[email protected]> wrote:
>
> The Hitachi HD44780 is often used together with a PCF8574 based I2C
> I/O expander. It was non-obvious to me that the existing parallel
> connected version of the auxdisplay driver can already handle this
> configuration with appropriate device tree magic. This patch documents
> the necessary incantations in an example.
>
> That this is not only non-obvious to me is documented by at least two
> I2C kernel implementations for the display out there.
>
> Thanks to Geert Uytterhoeven for pointing out how this is done.
> Thanks to Miguel Ojeda for extensively commenting on my previous patch.

You're welcome!

A couple tips:
- Normally, you will want to use scripts/get_maintainer.pl to know
to whom send a given change. In this case, I am Cc'ing Rob, Geert and
the devicetree mailing list which were missing.
- Also, for single patches, typically you would want to send the
patch without a cover letter. If you want to put comments that
shouldn't go into the commit, you can write them just below the "---"
line.

Thank you for contributing to the kernel and welcome!

Cheers,
Miguel

2021-01-06 12:17:42

by Miguel Ojeda

[permalink] [raw]
Subject: Re: [PATCH 0/1] auxdisplay: Add I2C gpio expander example

On Wed, Jan 6, 2021 at 1:12 PM Miguel Ojeda
<[email protected]> wrote:
>
> - Normally, you will want to use scripts/get_maintainer.pl to know
> to whom send a given change. In this case, I am Cc'ing Rob, Geert and
> the devicetree mailing list which were missing.

(Actually Cc'ing Rob.)

Cheers,
Miguel

2021-01-06 12:22:36

by Miguel Ojeda

[permalink] [raw]
Subject: Re: [PATCH 1/1] auxdisplay: Add I2C gpio expander example

On Wed, Jan 6, 2021 at 12:39 PM Ralf Schlatterbeck <[email protected]> wrote:
>
> The hd44780 displays are often used with pcf8574 based I/O expanders.
> Add example to documentation.
>
> Signed-off-by: Ralf Schlatterbeck <[email protected]>

Since Geert suggested it, it is customary to write Suggested-by: Geert
Uytterhoeven <[email protected]> above your signature.

Rob, if you are taking this on your tree:

Acked-by: Miguel Ojeda <[email protected]>

Otherwise, I will pick it up.

Cheers,
Miguel

2021-05-12 16:21:50

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH 1/1] auxdisplay: Add I2C gpio expander example

Hi Miguel,

On Wed, Jan 6, 2021 at 1:18 PM Miguel Ojeda
<[email protected]> wrote:
> On Wed, Jan 6, 2021 at 12:39 PM Ralf Schlatterbeck <[email protected]> wrote:
> > The hd44780 displays are often used with pcf8574 based I/O expanders.
> > Add example to documentation.
> >
> > Signed-off-by: Ralf Schlatterbeck <[email protected]>

> Rob, if you are taking this on your tree:
>
> Acked-by: Miguel Ojeda <[email protected]>
>
> Otherwise, I will pick it up.

Seems like so far no one has picked this up?

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

2021-05-12 17:53:56

by Miguel Ojeda

[permalink] [raw]
Subject: Re: [PATCH 1/1] auxdisplay: Add I2C gpio expander example

On Wed, May 12, 2021 at 5:32 PM Geert Uytterhoeven <[email protected]> wrote:
>
> Seems like so far no one has picked this up?

Queuing it then.

Cheers,
Miguel

2021-05-18 13:22:01

by Rob Herring (Arm)

[permalink] [raw]
Subject: Re: [PATCH 1/1] auxdisplay: Add I2C gpio expander example

On Wed, May 12, 2021 at 05:49:02PM +0200, Miguel Ojeda wrote:
> On Wed, May 12, 2021 at 5:32 PM Geert Uytterhoeven <[email protected]> wrote:
> >
> > Seems like so far no one has picked this up?

Because DT patchwork never saw it.

>
> Queuing it then.

Now it warns in linux-next:

Documentation/devicetree/bindings/auxdisplay/hit,hd44780.example.dts:52.18-62.11: Warning (unit_address_vs_reg): /example-1/i2c@2000: node has a unit name, but no reg or ranges property

2021-05-19 19:25:29

by Ralf Schlatterbeck

[permalink] [raw]
Subject: Re: [PATCH 1/1] auxdisplay: Add I2C gpio expander example

On Mon, May 17, 2021 at 10:20:35AM -0500, Rob Herring wrote:
> Now it warns in linux-next:
>
> Documentation/devicetree/bindings/auxdisplay/hit,hd44780.example.dts:52.18-62.11: Warning (unit_address_vs_reg): /example-1/i2c@2000: node has a unit name, but no reg or ranges property

[I'm the author of that patch]
Can someone point me to the documentation of how to check a single
example against the dt schemata? I think I had that figured out how to
run the dt-checks over the whole tree in january but didn't bother with
warnings since the whole devtree was riddled with warnings at the time.
Docs on how to quickly check for warnings/errors would help me a lot. My
naive usage of dt-validate on an example yields a traceback, I've opened
a report on github because I think that even with gross mis-usage the
tool shouldn't traceback...

Thanks for your help and pointers.
Ralf
--
Dr. Ralf Schlatterbeck Tel: +43/2243/26465-16
Open Source Consulting www: http://www.runtux.com
Reichergasse 131, A-3411 Weidling email: [email protected]

2021-05-19 19:27:39

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH 1/1] auxdisplay: Add I2C gpio expander example

Hi Ralf,

On Wed, May 19, 2021 at 11:00 AM Ralf Schlatterbeck <[email protected]> wrote:
> On Mon, May 17, 2021 at 10:20:35AM -0500, Rob Herring wrote:
> > Now it warns in linux-next:
> >
> > Documentation/devicetree/bindings/auxdisplay/hit,hd44780.example.dts:52.18-62.11: Warning (unit_address_vs_reg): /example-1/i2c@2000: node has a unit name, but no reg or ranges property
>
> [I'm the author of that patch]
> Can someone point me to the documentation of how to check a single
> example against the dt schemata? I think I had that figured out how to
> run the dt-checks over the whole tree in january but didn't bother with
> warnings since the whole devtree was riddled with warnings at the time.

It's much better in v5.13-rc2.

> Docs on how to quickly check for warnings/errors would help me a lot. My
> naive usage of dt-validate on an example yields a traceback, I've opened
> a report on github because I think that even with gross mis-usage the
> tool shouldn't traceback...

make dt_binding_check
DT_SCHEMA_FILES=Documentation/devicetree/bindings/auxdisplay/hit,hd44780.yaml

That still runs some checks on all files, unless you apply
https://lore.kernel.org/linux-devicetree/[email protected]/
first

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

2021-05-19 19:33:00

by Ralf Schlatterbeck

[permalink] [raw]
Subject: Re: [PATCH 1/1] auxdisplay: Add I2C gpio expander example

The hd44780 displays are often used with pcf8574 based I/O expanders.
Add example to documentation.

Signed-off-by: Ralf Schlatterbeck <[email protected]>
---
Updated Patch, thanks to Geert Uytterhoeven for his tip on how to
reproduce the warning. I've removed the address from the i2c stanza
which fixes it. Let me know if I should re-post the patch in a separate
thread.

.../bindings/auxdisplay/hit,hd44780.yaml | 31 ++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/auxdisplay/hit,hd44780.yaml b/Documentation/devicetree/bindings/auxdisplay/hit,hd44780.yaml
index 9222b06e93a0..fde07e4b119d 100644
--- a/Documentation/devicetree/bindings/auxdisplay/hit,hd44780.yaml
+++ b/Documentation/devicetree/bindings/auxdisplay/hit,hd44780.yaml
@@ -12,7 +12,10 @@ maintainers:
description:
The Hitachi HD44780 Character LCD Controller is commonly used on character
LCDs that can display one or more lines of text. It exposes an M6800 bus
- interface, which can be used in either 4-bit or 8-bit mode.
+ interface, which can be used in either 4-bit or 8-bit mode. By using a
+ GPIO expander it is possible to use the driver with one of the popular I2C
+ expander boards based on the PCF8574 available for these displays. For
+ an example see below.

properties:
compatible:
@@ -94,3 +97,29 @@ examples:
display-height-chars = <2>;
display-width-chars = <16>;
};
+ - |
+ #include <dt-bindings/gpio/gpio.h>
+ i2c {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ pcf8574: pcf8574@27 {
+ compatible = "nxp,pcf8574";
+ reg = <0x27>;
+ gpio-controller;
+ #gpio-cells = <2>;
+ };
+ };
+ hd44780 {
+ compatible = "hit,hd44780";
+ display-height-chars = <2>;
+ display-width-chars = <16>;
+ data-gpios = <&pcf8574 4 0>,
+ <&pcf8574 5 0>,
+ <&pcf8574 6 0>,
+ <&pcf8574 7 0>;
+ enable-gpios = <&pcf8574 2 0>;
+ rs-gpios = <&pcf8574 0 0>;
+ rw-gpios = <&pcf8574 1 0>;
+ backlight-gpios = <&pcf8574 3 0>;
+ };
--
2.20.1

2021-06-09 16:32:56

by Ralf Schlatterbeck

[permalink] [raw]
Subject: Re: [PATCH 1/1] auxdisplay: Add I2C gpio expander example

On Wed, Jun 09, 2021 at 03:55:10PM +0200, Miguel Ojeda wrote:
> Hi Ralf, Rob,
>
> On Wed, May 19, 2021 at 1:54 PM Ralf Schlatterbeck <[email protected]> wrote:
> >
> > The hd44780 displays are often used with pcf8574 based I/O expanders.
> > Add example to documentation.
> >
> > Signed-off-by: Ralf Schlatterbeck <[email protected]>
>
> I have queued this one into -next, adding the `Suggested-by` tag.

Thanks!

Ralf
--
Dr. Ralf Schlatterbeck Tel: +43/2243/26465-16
Open Source Consulting www: http://www.runtux.com
Reichergasse 131, A-3411 Weidling email: [email protected]

2021-06-09 18:45:32

by Miguel Ojeda

[permalink] [raw]
Subject: Re: [PATCH 1/1] auxdisplay: Add I2C gpio expander example

Hi Ralf, Rob,

On Wed, May 19, 2021 at 1:54 PM Ralf Schlatterbeck <[email protected]> wrote:
>
> The hd44780 displays are often used with pcf8574 based I/O expanders.
> Add example to documentation.
>
> Signed-off-by: Ralf Schlatterbeck <[email protected]>

I have queued this one into -next, adding the `Suggested-by` tag.

Cheers,
Miguel