Trying to add gpio-line-names to nanopi duo


sgjava

Recommended Posts

Maybe my grep-fu is not powerful or following endless includes, but I ended up changing build/cache/sources/linux-mainline/orange-pi-5.9/arch/arm/boot/dts/sunxi-h3-h5.dtsi which seems like it would change other boards. Is there a surefire way to make the changes in the proper place for the Duo?

 

I tested the image I built and indeed this changes the dtb correctly, but will it effect orange pi, etc boards too (h3-h5 boards)? @Igor I have the changes ready to commit, but I didn't want to do something that effects multiple boards. 

Link to post
Share on other sites
Donate and support the project!

On 12/27/2020 at 6:46 PM, sgjava said:

I have the changes ready to commit, but I didn't want to do something that effects multiple boards. 

 

/arch/arm/boot/dts/sunxi-h3-h5.dtsi
This is common file for all H3 and H5 boards so it will surely affect all boards. If this is what we want, ok, otherwise rather not. Perhaps moving this to overlay?

Link to post
Share on other sites
53 minutes ago, sgjava said:

is this documented somewhere? I'll give that a try.

Do you mean how to write an overlay ?

 

Or do you mean how "gpio-line-names" is used ?

 

Here is a general example from https://elixir.bootlin.com/linux/v4.7/source/Documentation/devicetree/bindings/gpio/gpio.txt

 

gpio-controller@00000000 {
	compatible = "foo";
	reg = <0x00000000 0x1000>;
	gpio-controller;
	#gpio-cells = <2>;
	ngpios = <18>;
	gpio-line-names = "MMC-CD", "MMC-WP", "VDD eth", "RST eth", "LED R",
		"LED G", "LED B", "Col A", "Col B", "Col C", "Col D",
		"Row A", "Row B", "Row C", "Row D", "NMI button",
		"poweroff", "reset";
}

 

It is not exact syntax, since it is depending of SoC main DT, for example, on H3, the controller would be "pinctrl@1c20800" ...

Link to post
Share on other sites
1 hour ago, sgjava said:

I need to know how to do overlay.

 

Here is a quick/not-tested/incomplete overlay sources named gpio-line-names.dts :

 

/dts-v1/;
/plugin/;
/ {
	compatible = "allwinner,sun8i-h3";
	fragment@1 {
		target = <&pio>;
		__overlay__ {
			gpio-line-names = "", "", "", "", "TX", "RX", "", "", 
					"", "", "", "", "", "", "", "STATUS-LED", 
					"MUTE", "SPDIF-OUT", "", "", "", "", "", "", 
					"", "", "", "", "", "", "", "", 
					"", "", "", "", "", "", "", "", 
					"", "", "", "", "", "", "", ""; 
		};
	};
};

 

Then, compile it as DTB with this command :

dtc -O dtb -I dts -o gpio-line-names.dtbo gpio-line-names.dts

 

To try loading DTB dynamically into main tree without doing it in /boot/armbianEnv.txt, execute those commands :

 

mkdir /sys/kernel/config/device-tree/overlays/gpionames
cat gpio-line-names.dtbo > /sys/kernel/config/device-tree/overlays/gpionames/dtbo
cat /sys/kernel/config/device-tree/overlays/gpionames/status

 

The last command should provide "applied" status.

 

Then, you can test names with your own tool ...

 

Link to post
Share on other sites
16 hours ago, sgjava said:

but this should only impact Duo.

Although I've never tried, patches could be board specific using a subdirectory such as ./patch/kernel/sunxi-dev/nanopi-duo/board-h2plus-nanopi-duo-add-device.patch

 

BTW, I've tried dynamic loading of gpio-line-names.dtbo overlay, but it doesn't work, but doing it in /boot/armbianEnv.txt works.

I think it is due that gpio-lines-names property is only checked while initializing pinctrl at boot time.

Link to post
Share on other sites
3 hours ago, sgjava said:

do you have an example for /boot/armbianEnv.txt gpio-line-names?

I've manually copied my gpio-line-names.dtbo under /boot/dts/overlay/sun8i-h3-gpio-line-names.dtbo

Then, I added "overlays=gpio-line-names" in /boot/armbianEnv.txt, and rebooted ...

3 hours ago, sgjava said:

This is generated board specific, correct?

Yes, my test was for OrangePiPC+, and tested using libgpiod "gpioinfo" ...

Link to post
Share on other sites

@martinayotte OK, tried this and no luck on duo:

ls /boot/dts/overlay/
sun8i-h3-gpio-line-names.dtbo

cat /boot/armbianEnv.txt 
verbosity=1
bootlogo=false
console=serial
disp_mode=1920x1080p60
overlay_prefix=sun8i-h3
overlays=usbhost2 usbhost3
rootdev=UUID=d1e6e420-cd58-46c8-aa52-0f8cd59dabb7
rootfstype=ext4
overlays=gpio-line-names
usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u

cat sun8i-h3-gpio-line-names.dts 
/dts-v1/;
/plugin/;
/ {
	compatible = "allwinner,sun8i-h3";
	fragment@1 {
		target = <&pio>;
		__overlay__ {
			gpio-line-names = "", "", "", "", "GPIOA4 DTX", "GPIOA5 DRX", "", "", "", "",
			"", "GPIOA11 SCL", "GPIOA12 SDA", "GPIOA13 CS", "GPIOA14 CLK", "GPIOA15 MO", "GPIOA16 MI", "", "", "",
			"", "", "", "", "", "", "", "", "", "",
			"", "", "", "", "", "", "", "", "", "",
			"", "", "", "", "", "", "", "", "", "",
			"", "", "", "", "", "", "", "", "", "",
			"", "", "", "", "", "", "", "", "", "",
			"", "", "", "", "", "", "", "", "", "",
			"", "", "", "", "", "", "", "", "", "",
			"", "", "", "", "", "", "", "", "", "",
			"", "", "", "", "", "", "", "", "", "",
			"", "", "", "", "", "", "", "", "", "",
			"", "", "", "", "", "", "", "", "", "",
			"", "", "", "", "", "", "", "", "", "",
			"", "", "", "", "", "", "", "", "", "",
			"", "", "", "", "", "", "", "", "", "",
			"", "", "", "", "", "", "", "", "", "",
			"", "", "", "", "", "", "", "", "", "",
			"", "", "", "", "", "", "", "", "", "",
			"", "", "", "", "", "", "", "", "GPIOG6 TX1", "GPIOG7 RX1",
			"", "", "", "GPIOG11 IOG11";
		};
	};
};

 

I suspect it has something to do with multiple pin controllers? pinctrl@1c20800 and pinctrl@1f02c00? Also noticed Duo has compatible = "allwinner,sun8i-h3-r-pinctrl";

Link to post
Share on other sites

@martinayotteOK, I figured out the syntax for each pinctrl using phandle to identify. So next question is how do I make this part of build process, so it gets applied automatically in img?

 

Duo:

/dts-v1/;
/plugin/;
/ {
	compatible = "allwinner,sun8i-h3-pinctrl";
	fragment@0 {
		target = <0x0b>;
		__overlay__ {
			gpio-line-names = "", "", "", "", "GPIOA4 DTX", "GPIOA5 DRX", "", "", "", "",
			"", "GPIOA11 SCL", "GPIOA12 SDA", "GPIOA13 CS", "GPIOA14 CLK", "GPIOA15 MO", "GPIOA16 MI", "", "", "",
			"", "", "", "", "", "", "", "", "", "",
			"", "", "", "", "", "", "", "", "", "",
			"", "", "", "", "", "", "", "", "", "",
			"", "", "", "", "", "", "", "", "", "",
			"", "", "", "", "", "", "", "", "", "",
			"", "", "", "", "", "", "", "", "", "",
			"", "", "", "", "", "", "", "", "", "",
			"", "", "", "", "", "", "", "", "", "",
			"", "", "", "", "", "", "", "", "", "",
			"", "", "", "", "", "", "", "", "", "",
			"", "", "", "", "", "", "", "", "", "",
			"", "", "", "", "", "", "", "", "", "",
			"", "", "", "", "", "", "", "", "", "",
			"", "", "", "", "", "", "", "", "", "",
			"", "", "", "", "", "", "", "", "", "",
			"", "", "", "", "", "", "", "", "", "",
			"", "", "", "", "", "", "", "", "", "",
			"", "", "", "", "", "", "", "", "GPIOG6 TX1", "GPIOG7 RX1",
			"", "", "", "GPIOG11 IOG11";
		};
	};

        fragment@1 {
                target = <0x3b>;
                __overlay__ {
			gpio-line-names = "", "", "", "BUTTON", "", "", "", "", "", "", "", "GPIOL11 IRRX";
                };
        };
};

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...