Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DT overlay support #382

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,72 @@ This code changes the default CPU governor from _fantasy_ to _ondemand_, and tun

For additional discussion, see https://github.com/linux-sunxi/meta-sunxi/issues/25

Custom boot environment & devicetree overlay suppport
=====================================================

The layer provide a basic custom enviroment for linux mainline that enables:

- Custom boot argument to be passed to the kernel.
- Basic devicetree overlay support.

By default this features are disabled and have to be activated including this the bitbake configuration (e.g. local.conf):

```
DISTRO_FEATURES:append = " sunxi-env"
```

This feature instruct the layer to deploy the file ``` /boot/sunxienv.txt ``` that is loaded during boot customize kernel boot command line.

DT Overlay support
------------------

To enable overlays the following line must be activated in bitbake configuration (e.g. local.conf):

```
SUNXI_OVERLAYS_ENABLE:append = " <space separeted list with the desired overlay names without .dts>"
```

The layer includes a common set for DT overalys organized by family. The list can be found in the
following path ```meta-sunxi/recipes-bs/sunxi-overlays/files/<socfamily>/<dts file>```

Once activated the following content will be added to yout image in the boot partition:
```
/boot/dtbo/*.dbto (all compiled overlays selected in SUNXI_OVERLAYS_ENABLE)
/boot/sunxienv.txt (uboot config file with the full list of devicetree overlays)
```

```/boot/sunxienv.txt``` can be modified after the build to activate or deactive the overlays on boot to provide
runtime flexibility or for debugging. A ```.dbto``` file can be also loaded at runtime
if the kernel supports it via sysfs interface using ```cat [dbto file] > /sys/kernel/config/device-tree/overlays/```


Adding custom DT overlays
-------------------------
It is possible to add custom overlay/s via a ```bbappend``` recipe.

```
recipies-bsp
- sunxi-overlays
- sunxi-overlays%.bbappend
- files
- <custom.dts>

Inside the .bbappend the following metadata is requried:

```
FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
SRC_URI:${SOC_FAMILY}:append = " file://<custom.dts>"
```

Don't forget to add the custom overlay in your image or local configuration:

```
SUNXI_OVERLAYS_ENABLED:append = " <custom>"
```







5 changes: 5 additions & 0 deletions conf/machine/include/sunxi.inc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ SUNXI_BOOT_SPACE ?= "40"
IMAGE_BOOT_FILES ?= "${KERNEL_IMAGETYPE} boot.scr"
# ship fex file for sunxi kernel, devicetree file for mainline kernel
IMAGE_BOOT_FILES += "${@bb.utils.contains('PREFERRED_PROVIDER_virtual/kernel', 'linux-sunxi', '${SUNXI_FEX_FILE}', '${KERNEL_DEVICETREE}', d)}"

IMAGE_BOOT_FILES:append = " ${@bb.utils.contains('DISTRO_FEATURES', 'sunxi-env', 'sunxienv.txt', '', d)}"
IMAGE_BOOT_FILES:append = " ${@ '' if (d.getVar('SUNXI_OVERLAYS_ENABLE') or "").strip() == "" else 'devicetree/*.dtbo;dtbo/'}"


WKS_FILES ?= "sunxi-sdcard-image.wks.in"
WKS_FILE_DEPENDS ?= "virtual/kernel u-boot"
# in case of sunxi kernel, sunxi-board-fex must be built prior wic image assembly
Expand Down
3 changes: 3 additions & 0 deletions conf/machine/include/sunxi64.inc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ addtask do_fix_device_tree_location after do_write_wks_template before do_image_

SUNXI_BOOT_SPACE ?= "40"
IMAGE_BOOT_FILES ?= "${KERNEL_IMAGETYPE} boot.scr ${KERNEL_DEVICETREE}"
IMAGE_BOOT_FILES:append = " ${@bb.utils.contains('DISTRO_FEATURES', 'sunxi-env', 'sunxienv.txt', '', d)}"
IMAGE_BOOT_FILES:append = " ${@ '' if (d.getVar('SUNXI_OVERLAYS_ENABLE') or "").strip() == "" else 'devicetree/*.dtbo;dtbo/'}"


WKS_FILES ?= "sunxi-sdcard-image.wks.in"
WKS_FILE_DEPENDS ?= "virtual/kernel u-boot"
20 changes: 20 additions & 0 deletions recipes-bsp/sunxi-overlays/files/sun50i-h616/h616-i2c0.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/dts-v1/;
/plugin/;

/ {
compatible = "allwinner,sun50i-h616";

fragment@0 {
target-path = "/aliases";
__overlay__ {
i2c0 = "/soc/i2c@5002000";
};
};

fragment@1 {
target = <&i2c0>;
__overlay__ {
status = "okay";
};
};
};
20 changes: 20 additions & 0 deletions recipes-bsp/sunxi-overlays/files/sun50i-h616/h616-i2c1.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/dts-v1/;
/plugin/;

/ {
compatible = "allwinner,sun50i-h616";

fragment@0 {
target-path = "/aliases";
__overlay__ {
i2c1 = "/soc/i2c@5002400";
};
};

fragment@1 {
target = <&i2c1>;
__overlay__ {
status = "okay";
};
};
};
20 changes: 20 additions & 0 deletions recipes-bsp/sunxi-overlays/files/sun50i-h616/h616-i2c2.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/dts-v1/;
/plugin/;

/ {
compatible = "allwinner,sun50i-h616";

fragment@0 {
target-path = "/aliases";
__overlay__ {
i2c2 = "/soc/i2c@5002800";
};
};

fragment@1 {
target = <&i2c2>;
__overlay__ {
status = "okay";
};
};
};
22 changes: 22 additions & 0 deletions recipes-bsp/sunxi-overlays/files/sun50i-h616/h616-uart1.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/dts-v1/;
/plugin/;

/ {
compatible = "allwinner,sun50i-h616";

fragment@0 {
target-path = "/aliases";
__overlay__ {
serial1 = "/soc/serial@5000400";
};
};

fragment@1 {
target = <&uart1>;
__overlay__ {
pinctrl-names = "default";
pinctrl-0 = <&uart1_pins>;
status = "okay";
};
};
};
32 changes: 32 additions & 0 deletions recipes-bsp/sunxi-overlays/files/sun50i-h616/h616-uart2.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/dts-v1/;
/plugin/;

/ {
compatible = "allwinner,sun50i-h616";

fragment@0 {
target-path = "/aliases";
__overlay__ {
serial2 = "/soc/serial@5000800";
};
};

fragment@1 {
target = <&pio>;
__overlay__ {
uart2_rts_cts: uart2_rts_cts {
pins = "PD21", "PD22";
function = "uart2";
};
};
};

fragment@2 {
target = <&uart2>;
__overlay__ {
pinctrl-names = "default";
pinctrl-0 = <&uart2_pins>;
status = "okay";
};
};
};
20 changes: 20 additions & 0 deletions recipes-bsp/sunxi-overlays/files/sun50i/h5-i2c0.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/dts-v1/;
/plugin/;

/ {
compatible = "allwinner,sun50i-h5";

fragment@0 {
target-path = "/aliases";
__overlay__ {
i2c0 = "/soc/i2c@01c2ac00";
};
};

fragment@1 {
target = <&i2c0>;
__overlay__ {
status = "okay";
};
};
};
20 changes: 20 additions & 0 deletions recipes-bsp/sunxi-overlays/files/sun50i/h5-i2c1.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/dts-v1/;
/plugin/;

/ {
compatible = "allwinner,sun50i-h5";

fragment@0 {
target-path = "/aliases";
__overlay__ {
i2c1 = "/soc/i2c@01c2b000";
};
};

fragment@1 {
target = <&i2c1>;
__overlay__ {
status = "okay";
};
};
};
20 changes: 20 additions & 0 deletions recipes-bsp/sunxi-overlays/files/sun50i/h5-i2c2.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/dts-v1/;
/plugin/;

/ {
compatible = "allwinner,sun50i-h5";

fragment@0 {
target-path = "/aliases";
__overlay__ {
i2c2 = "/soc/i2c@01c2b400";
};
};

fragment@1 {
target = <&i2c2>;
__overlay__ {
status = "okay";
};
};
};
22 changes: 22 additions & 0 deletions recipes-bsp/sunxi-overlays/files/sun50i/h5-uart1.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/dts-v1/;
/plugin/;

/ {
compatible = "allwinner,sun50i-h5";

fragment@0 {
target-path = "/aliases";
__overlay__ {
serial1 = "/soc/serial@01c28400";
};
};

fragment@1 {
target = <&uart1>;
__overlay__ {
pinctrl-names = "default";
pinctrl-0 = <&uart1_pins>;
status = "okay";
};
};
};
32 changes: 32 additions & 0 deletions recipes-bsp/sunxi-overlays/files/sun50i/h5-uart2.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/dts-v1/;
/plugin/;

/ {
compatible = "allwinner,sun50i-h5";

fragment@0 {
target-path = "/aliases";
__overlay__ {
serial2 = "/soc/serial@01c28800";
};
};

fragment@1 {
target = <&pio>;
__overlay__ {
uart2_rts_cts: uart2_rts_cts {
pins = "PA2", "PA3";
function = "uart2";
};
};
};

fragment@2 {
target = <&uart2>;
__overlay__ {
pinctrl-names = "default";
pinctrl-0 = <&uart2_pins>;
status = "okay";
};
};
};
32 changes: 32 additions & 0 deletions recipes-bsp/sunxi-overlays/files/sun50i/h5-uart3.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/dts-v1/;
/plugin/;

/ {
compatible = "allwinner,sun50i-h5";

fragment@0 {
target-path = "/aliases";
__overlay__ {
serial3 = "/soc/serial@01c28c00";
};
};

fragment@1 {
target = <&pio>;
__overlay__ {
uart3_rts_cts: uart3_rts_cts {
pins = "PA15", "PA16";
function = "uart3";
};
};
};

fragment@2 {
target = <&uart3>;
__overlay__ {
pinctrl-names = "default";
pinctrl-0 = <&uart3_pins>;
status = "okay";
};
};
};
27 changes: 27 additions & 0 deletions recipes-bsp/sunxi-overlays/files/sun50i/h5-usbhost0.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/dts-v1/;
/plugin/;

/ {
compatible = "allwinner,sun50i-h5";

fragment@0 {
target = <&ehci0>;
__overlay__ {
status = "okay";
};
};

fragment@1 {
target = <&ohci0>;
__overlay__ {
status = "okay";
};
};

fragment@2 {
target = <&usbphy>;
__overlay__ {
status = "okay";
};
};
};
Loading