0

I'm creating a kernel driver for SPI controlled display, which is meant to be working with Raspberry PI. I'm not sure about a one thing that I see sometimes in device tree overlays created by other people - pinctrl properties.

The display is controlled through SPI - as mentioned above - but it also has 3 additional control lines: BUSY, RST and DC. In order to has a possibility of controlling these lines, besides the spi overlay my DTS has to include another one, which clearly is: gpio.

fragment@0 {
    target = <&spi0>;
    __overlay__ {
        #address-cells = <1>;
        #size-cells = <0>;

        status = "okay";

        spidev@0 {
            status = "disabled";
        };

        epd0: epd@0 {
            compatible = "waveshare,epd";
            reg = <0>;

            pinctrl-names = "default";
            pinctrl-0 = <&epd_pins>;

            spi-max-frequency = <1000000>;

            width = <128>;
            height = <296>;

            dc-gpios = <&gpio 16 0>;
            reset-gpios = <&gpio 20 0>;
            busy-gpios = <&gpio 21 0>;

            status = "okay";
        };
    };
};

fragment@1 {
    target = <&gpio>;
    __overlay__ {
        epd_pins: epd_pins {
            brcm,pins = <16 20 21>; /* DC RST BUSY */
            brcm,function = <1 1 0>; /* out out in */
        };
    };
};

That DTS works perfectly fine and I didn't expect any troubles. But there is one thing I'm not sure about:

pinctrl-names = "default";
pinctrl-0 = <&epd_pins>;

I've seen lines like that in other's DTs with gpio overlays, but not always; sometimes they are, sometimes they're not. If I comment out these two lines, it seems like nothing changes, and my driver still works as it should.

I have two questions:

  1. What is the purpose of those pinctrl lines? I'm aware of pin controller subsystem, but I'm asking strictly in context of my DT.
  2. Why do I need to declare the gpio overlay? I can set IN or OUT function directly from my driver code and my gpio numbers are defined in spi overlay (dc-gpios, reset-gpios, busy-gpios).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.