dts file for hd44780 LCD on BBB

I’m trying to use an hd44780 LCD with the BBB using the hd44780 kernel driver. Based on the kernel module’s documentation, I have tried to put together a .dts file for my configuration:

/dts-v1/;
/plugin/;

/ {
    compatible = "ti,beaglebone", "ti,beaglebone-black";

    /* identification */
    part-number = "hd44780";
    version = "00A0";

    /* state the resources this cape uses */
    exclusive-use =
        /* the pin header uses */
        "P8_11", /* LCD D5 */
        "P8_12", /* LCD D4 */
//        "P8_13" /* LCD LED PWM */
        "P8_14", /* LCD E */
        "P8_15", /* LCD D7 */
        "P8_16", /* LCD D6 */
        "P8_17"; /* LCD RS */

    fragment@0 {
        target = <&hd44780>;
        target-path = "/";
        __overlay__ {
            auxdisplay {
                compatible = "hit,hd44780";

                data-gpios = <&pcf8574a 44 GPIO_ACTIVE_HIGH>,
                             <&pcf8574a 45 GPIO_ACTIVE_HIGH>,
                             <&pcf8574a 46 GPIO_ACTIVE_HIGH>,
                             <&pcf8574a 47 GPIO_ACTIVE_HIGH>;
               enable-gpios = <&pcf8574a 26 GPIO_ACTIVE_HIGH>;
               rs-gpios = <&pcf8574a 27 GPIO_ACTIVE_HIGH>;
//               backlight-gpios = <&pcf8574a 23 GPIO_ACTIVE_LOW>;

                display-height-chars = <2>;
                display-width-chars = <16>;
            };
        };
    };
};

However, when I try to compile it with

dtc -O dtb -o hd44780.dtb hd44780.dts

it gives the following error:

Error: hd44780.dts:29.44-45 syntax error
FATAL ERROR: Unable to parse input tree

I’m a newbie in the device tree and can’t put together the sometimes contradicting information I find on the internet. What do I do wrong?

GPIO_ACTIVE_HIGH comes from: #include <dt-bindings/gpio/gpio.h>… by running “dtc …” on the command line these dont’ get pulled in…

Feel free to use the “Makefile” that automatically pulls these in when you add the include at the top. GitHub - beagleboard/bb.org-overlays: Device Tree Overlays for bb.org boards

Regards,

Thank you very much for the hint. I have added the include and copied the file into bb.org-overlays/src/arm. After updating dtc (and downgrading gcc to gcc-9 to make that work) I could successfully compile the dts file with make.

I have copied the compiled file hd44780.dtbo to /lib/firmware/ and added the line

uboot_overlay_addr5=hd44780.dtbo

in /boot/uEnv.txt, but now it doesn’t boot any more. I guess that means debugging by serial console …

I have googled a lot and tried out many things, but actually I don’t understand at all what is needed. Based on other GPIO fragments and a blog found on the internet, I have arrived at the following code, but it is obviously not correct:

/dts-v1/;
/plugin/;

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/pinctrl/am33xx.h>
#include <dt-bindings/board/am335x-bbw-bbb-base.h>

/ {
    compatible = "ti,beaglebone", "ti,beaglebone-black";

    /* identification */
    part-number = "hd44780";
    version = "00A0";

    fragment@0 {
        target-path="/";
        __overlay__ {
            chosen {
                overlays {
                    hd44780-00A0 = __TIMESTAMP__;
                };
            };
        };
    };

    /*
     * Free up the pins used by the cape from the pinmux helpers.
     */
    fragment@1 {
        target = <&ocp>;
        __overlay__ {
            P8_11_pinmux { status = "disabled"; };  /* P8_11: D5 */
            P8_12_pinmux { status = "disabled"; };  /* P8_12: D4 */
//            P8_13_pinmux { status = "disabled"; };  /* P8_13: LED PWM */
            P8_14_pinmux { status = "disabled"; };  /* P8_14: E */
            P8_15_pinmux { status = "disabled"; };  /* P8_15: D7 */
            P8_16_pinmux { status = "disabled"; };  /* P8_16: D6 */
            P8_17_pinmux { status = "disabled"; };  /* P8_17: RS */
        };
    };

    /*
     * Set pins as output
     */
    fragment@2 {
        target = <&ocp>;
        am33xx_pinmux: auxdisplay_pins {
            pinctrl-single,pins = <
                BONE_P8_12 (PIN_OUTPUT | MUX_MODE0) /* LCD D4 */
                BONE_P8_11 (PIN_OUTPUT | MUX_MODE0) /* LCD D5 */
                BONE_P8_16 (PIN_OUTPUT | MUX_MODE0) /* LCD D6 */
                BONE_P8_15 (PIN_OUTPUT | MUX_MODE0) /* LCD D7 */
                BONE_P8_14 (PIN_OUTPUT | MUX_MODE0) /* LCD Enable */
                BONE_P8_17 (PIN_OUTPUT | MUX_MODE0) /* LCD RS */
            >;
        };
    };

    /*
     * Device driver settings
     */
    fragment@3 {
        target = <&am33xx_pinmux>;
        target-path = "/";
        __overlay__ {
            auxdisplay: auxdisplay {
                compatible = "hit,hd44780";

                data-gpios = <&am33xx_pinmux BONE_P8_12 GPIO_ACTIVE_HIGH>,
                             <&am33xx_pinmux BONE_P8_11 GPIO_ACTIVE_HIGH>,
                             <&am33xx_pinmux BONE_P8_16 GPIO_ACTIVE_HIGH>,
                             <&am33xx_pinmux BONE_P8_15 GPIO_ACTIVE_HIGH>;
               enable-gpios = <&am33xx_pinmux BONE_P8_14 GPIO_ACTIVE_HIGH>;
               rs-gpios = <&am33xx_pinmux BONE_P8_17 GPIO_ACTIVE_HIGH>;
//               backlight-gpios = <&am33xx_pinmux BONE_P8_13 GPIO_ACTIVE_LOW>;

                display-height-chars = <2>;
                display-width-chars = <16>;
            };
        };
    };
};

Can please someone enlighten me what needs to be written in order to use the given GPIOs with the mainline hd44780 driver?