Jump to content

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 comment
Share on other sites

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 comment
Share on other sites

29 minutes ago, sgjava said:

How would a do an overlay for just the NanoPi Duo?


GPIOs are shared but also used differently. It would be best to find some universal solution. Overlay is optional in any case so it's irrelevant on which board will be loaded ...  @5kft @martinayotte what do you think how to drive this thing?

Link to comment
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 comment
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 comment
Share on other sites

4 minutes ago, sgjava said:

but my question was how do I do this for Duo using overlay

For Allwinners SoC, you simply add new overlay to existing patch located there :

 

https://github.com/armbian/build/blob/master/patch/kernel/sunxi-dev/general-sunxi-overlays.patch

 

You need to add DTS, but also add entry into the Makefile.

Link to comment
Share on other sites

@martinayotteI finally got my VM cranking and build pulled down. Looking around based on what you said wouldn't something duo specific be better off in something like ./patch/kernel/sunxi-dev/board-h2plus-nanopi-duo-add-device.patch? I still need to look at Makefile, but this should only impact Duo.

Link to comment
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 comment
Share on other sites

@martinayotte do you have an example for /boot/armbianEnv.txt gpio-line-names? This is generated board specific, correct? How would I do it that way for Duo? I'll try my grep-fu and google-fu in the meantime. I assume you are talking about loading the overlay from armbianEnv.txt i.e. https://docs.armbian.com/User-Guide_Allwinner_overlays

Link to comment
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 comment
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 comment
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 comment
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...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines