当前位置:网站首页>Rk3566 add LED

Rk3566 add LED

2022-07-05 13:47:00 Matchstick MCU

Designed on the motherboard 5 individual LED, among 2 A green led For operation indication , One rgb The light is indicated by status , Used separately 5 individual GPIO Mouth control LED, All are high-level lights .

linux The system already comes with it leds-gpio The driver , Just enable the driver in the kernel .

LED Drive enable  

General kernel has been enabled LED Support for GPIO connected LEDs:

stay DTS Add to file LED Description of :

	leds{
		compatible = "gpio-leds";
		
		user1_led: user1 {
			label = "user1"; 
			gpios = <&gpio2 RK_PB1 GPIO_ACTIVE_HIGH>; 
			linux,default-trigger = "heartbeat"; 
			default-state = "on"; 
		}; 
		user2_led: user2 {
			label = "user2"; 
			gpios = <&gpio2 RK_PB2 GPIO_ACTIVE_HIGH>; 
			default-state = "off"; 
		}; 
		blue_led: blue {
			label = "blue"; 
			gpios = <&gpio4 RK_PC0 GPIO_ACTIVE_HIGH>; 
			default-state = "off"; 
		};
		green_led: green {
			label = "green"; 
			gpios = <&gpio1 RK_PB0 GPIO_ACTIVE_HIGH>; 
			default-state = "off"; 
		};
		red_led: red {
			label = "red"; 
			gpios = <&gpio1 RK_PB1 GPIO_ACTIVE_HIGH>; 
			default-state = "off"; 
		};
	};

This description is added under the root node . 

debugging

modify DTS Post compiled kernel , take boot.img Burn into the motherboard , After the motherboard starts , Enter into /sys/class/leds/ View under directory led Whether to add successfully :

[[email protected]:/]# cd /sys/class/leds/
[[email protected]:/sys/class/leds]# ls
blue  green  mmc0::  red  user1  user2

5 individual led It has been added successfully .

towards led Under the lamp name brightness Write non 0 or 0 Value , Corresponding led It will light up 、 destroy .

[[email protected]:/sys/class/leds]# echo 1 > user1/brightness 
[[email protected]:/sys/class/leds]# echo 0 > user1/brightness 

Problems encountered

The first revision DTS After the boot.img Burn into the motherboard , Enter into /sys/class/leds/ Under the table of contents , I don't see the added led, Check the boot log :

[[email protected]:/]# dmesg | grep leds
[    1.318922] leds-gpio: probe of leds failed with error -16

Show leds-gpio Detection failure , Repeated testing dts file , No errors found .

see gpio usage :

gpiochip2: GPIOs 64-95, parent: platform/fe750000.gpio, gpio2:
 gpio-73  (                    |xgpio-pin           ) out lo    

Find out xgpio-pin And user1 Defined gpio The conflict .

lookup dts The document is about gpio-73 Related description :

	WORKLED {
		compatible = "9tripod,xgpio";
		pinctrl-names = "default";
		def_val=<0>;
		pinctrl-0 = <&io2_b1>;
		gpio = <&gpio2 9 GPIO_ACTIVE_HIGH>;
	};

WORKLED Used this GPIO, Delete this description , Compile the kernel again , take boot.img Burn into the motherboard ,led It was added successfully .

remaining problems

although user1 The default trigger is configured as heartbeat, however user1 It doesn't go out automatically , There may be some heartbeat Some functions of are not configured well .

原网站

版权声明
本文为[Matchstick MCU]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/186/202207051337008378.html