如何在设备树中添加led

我在设备树中添加了以下代码

leds {
		compatible = "gpio-leds";
		status_led {
			gpios = <&gpio_aon TEGRA234_MAIN_GPIO(CC, 1) GPIO_ACTIVE_LOW>;
			linux,default-trigger = "default-on";
		};
	};

编译时报错

Error: /home/user/EC5000/Linux_for_Tegra/source/hardware/nvidia/t23x/nv-public/tegra234-p3768-0000+p3767-0000.dts:22.25-26 syntax error
FATAL ERROR: Unable to parse input tree

请问正确的方式是什么

附上完整文件:

// SPDX-License-Identifier: GPL-2.0
/dts-v1/;

#include <dt-bindings/input/linux-event-codes.h>
#include <dt-bindings/input/gpio-keys.h>

#include "tegra234-p3767-0000.dtsi"
#include "tegra234-p3768-0000.dtsi"

/ {
	compatible = "nvidia,p3768-0000+p3767-0000", "nvidia,p3767-0000", "nvidia,tegra234";
	model = "NVIDIA Jetson Orin NX Engineering Reference Developer Kit";

	aliases {
		serial1 = &uarta;
		serial2 = &uarte;
	};

	leds {
		compatible = "gpio-leds";
		status_led {
			gpios = <&gpio_aon TEGRA234_MAIN_GPIO(CC, 1) GPIO_ACTIVE_LOW>;
			linux,default-trigger = "default-on";
		};
	};

	bus@0 {
		serial@3100000 {
			compatible = "nvidia,tegra194-hsuart";
			reset-names = "serial";
			status = "okay";
		};

		serial@3140000 {
			compatible = "nvidia,tegra194-hsuart";
			reset-names = "serial";
			status = "okay";
		};

		pwm@32a0000 {
			assigned-clocks = <&bpmp TEGRA234_CLK_PWM3>;
			assigned-clock-parents = <&bpmp TEGRA234_CLK_PLLP_OUT0>;
			status = "okay";
		};

		hda@3510000 {
			nvidia,model = "NVIDIA Jetson Orin NX HDA";
			status = "okay";
		};

		padctl@3520000 {
			status = "okay";
		};
	};

	gpio-keys {
		compatible = "gpio-keys";

		key-force-recovery {
			label = "Force Recovery";
			gpios = <&gpio TEGRA234_MAIN_GPIO(G, 0) GPIO_ACTIVE_LOW>;
			linux,input-type = <EV_KEY>;
			linux,code = <BTN_1>;
		};

		key-power {
			label = "Power";
			gpios = <&gpio_aon TEGRA234_AON_GPIO(EE, 4) GPIO_ACTIVE_LOW>;
			linux,input-type = <EV_KEY>;
			linux,code = <KEY_POWER>;
			wakeup-event-action = <EV_ACT_ASSERTED>;
			wakeup-source;
		};

		key-suspend {
			label = "Suspend";
			gpios = <&gpio TEGRA234_MAIN_GPIO(G, 2) GPIO_ACTIVE_LOW>;
			linux,input-type = <EV_KEY>;
			linux,code = <KEY_SLEEP>;
		};
	};

	pwm-fan {
		cooling-levels = <0 88 187 255>;
	};

	vdd_3v3_pcie: regulator-vdd-3v3-pcie {
		compatible = "regulator-fixed";
		regulator-name = "VDD_3V3_PCIE";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		gpio = <&gpio_aon TEGRA234_AON_GPIO(AA, 5) GPIO_ACTIVE_HIGH>;
		enable-active-high;
	};

	thermal-zones {
		tj-thermal {
			cooling-maps {
				map-active-0 {
					cooling-device = <&fan 0 1>;
					trip = <&tj_trip_active0>;
				};

				map-active-1 {
					cooling-device = <&fan 1 2>;
					trip = <&tj_trip_active1>;
				};

				map-active-2 {
					cooling-device = <&fan 2 3>;
					trip = <&tj_trip_active2>;
				};
			};
		};
	};
};

你怎麼編譯的?

還有AON_GPIO和MAIN_GPIO是不一樣的東西
你應該要用TEGRA234_AON_GPIO 不是TEGRA234_MAIN_GPIO
沒有TEGRA234_MAIN_GPIO(CC, 1)這根pin

我改成TEGRA234_AON_GPIO之后可以编译通过了,但是设备运行时没有生效
我修改了Linux_for_Tegra\source\hardware\nvidia\t23x\nv-public\tegra234-p3768-0000+p3767-0000.dts
我在source目录执行make dtbs,然后把nvidia-oot/device-tree/platform/generic-dts/dtbs/tegra234-p3768-0000+p3767-0000-nv.dtb文件写入到A_kernel-dtb和B_kernel-dtb分区
同时把这个dtb文件复制到了rootfs/boot/目录
重启后并没有生效
在/sys/class/leds目录没有设备,在/proc/device-tree目录也没有leds节点

你是rel-36/JetPack 6的話要重燒A_cpu-bootloader/B_cpu-bootloader才會生效
device tree預設是從bootloader partitoin讀的

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.