How to custom mainline dtb file with vendor's specification?

I’m running Manjaro ARM 21.08 Vim2 image on a Tv box with meson-gxbb-p201.dtb. As far as I know ,there are two issues with my box:

1. Leds not defined.

ls  /sys/class/leds/

Permissions Size User Date Modified Name
lrwxrwxrwx     0 root  7 9月  11:17  input0::capslock -> ../../devices/platform/soc/c9000000.usb/usb1/1-1/1-1:1.0/0003:1C4F:0002.0001/input/input0/input0::capslock
lrwxrwxrwx     0 root  7 9月  11:17  input0::numlock -> ../../devices/platform/soc/c9000000.usb/usb1/1-1/1-1:1.0/0003:1C4F:0002.0001/input/input0/input0::numlock
lrwxrwxrwx     0 root  7 9月  11:17  input0::scrolllock -> ../../devices/platform/soc/c9000000.usb/usb1/1-1/1-1:1.0/0003:1C4F:0002.0001/input/input0/input0::scrolllock

My box has 3 leds which could be switched between green and red :

Led 1 : Green when power on and red when power off
Led 2 : Blink red when receives an ir code and off in the rest time
Led 3 : Green when connected to internet and red otherwise

The output above apparently only found my leds from keyboard. From the vendor’s android dtb file, I found the related definition :

ledlight {
	compatible = "amlogic, ledlight";
	dev_name = "ledlight";
	status = "okay";
	power_gpio_0 = < 0x60 >;
	net_gpio_0 = < 0x61 >;

	gpio_rg {
		led_name = "power_led";
		led_gpio = < 0x5f 0x0d 0x00 >;
		led_active = < 0x01 >;
		led_type = "R&G";
		linux,phandle = < 0x60 >;
		phandle = < 0x60 >;
	};

	gpio_r {
		led_name = "net_led";
		led_gpio = < 0x1c 0x5b 0x00 >;
		led_active = < 0x01 >;
		led_type = "R&G";
		linux,phandle = < 0x61 >;
		phandle = < 0x61 >;
	};
};

I’m awared that I’m supposed to define these leds in meson-gxbb-p201.dtb to make kernel find them . But I could not found a detailed tutorial. How could I apply this change to my existing dtb ?

2. Could not poweroff (reboot instead)

In another post ,I thought it could be related to bootloader but it seems to be dtb matter instead .

From vendor’s android dtb :

aml_restart {
	compatible = "aml, restart";
	sys_reset = < 0x84000009 >;
	sys_poweroff = < 0x84000008 >;
};

While in meson-gxbb-p201.dtb, I did not see similar code .

Any suggestions would be greatly appreciated , thank for this brilliant community :smiley:

Attachment

  1. The vendor’s android dtb file : (already converted to dts )
    R3300M_DTB_Extracted_From_Vendor's_Android - Pastebin.com
  2. meson-gxbb-p201.dtb file :
    meson-gxbb-p201.dtb_from_manjaro-arm-21.08 - Pastebin.com
2 Likes