I.MX6Q (TQIMX6Q/TQE9) study notes--The new BSP key, LED

Source: Internet
Author: User

After the previous migration, the kernel can already mount the root filesystem on tqimx6q, and then start porting all kinds of device drivers, this article first to transplant the keys and LEDs. The reason to start with the keys and LEDs is that the drivers for both devices are the simplest.

Key-driven porting

View the schematic of the tqimx6q that the Development Board has 5 keys, which, in addition to the reset key, there is a power button, this power key and other keys are somewhat different, so this article porting the remaining three keys (the Power key is handled when porting the Power management module). By reading the schematic diagram, K1, K2, K3 respectively connected to gpio1_28, Gpio4_5 and Gpio1_30, based on the Gpio-keys driver module of the kernel, you can write DTS as follows:

Gpio-keys {compatible = "Gpio-keys"; home {label = "home Button"; Gpios = <&gpio1 "1>;linux,code = <102>;} ; Enter {label = "enter Button"; Gpios = <&gpio4 5 1>;linux,code = <28>;}; ESC {label = "esc button"; Gpios = <&gpio1 1>;linux,code = <1>;};};
led Drive porting

Similarly, the view tqimx6q schematic shows that tqimx6q led4, Led5, Led6 respectively received gpio3_21, gpio3_22 and gpio3_23, the other LEDs are power-related, can not be controlled by Gpio. Kernel-based gpio-leds driver, you can write DTS as follows:

gpio-leds {compatible = "gpio-leds"; led4 {label = "led4"; gpios = <&gpio3 0>;d efault-state = "Off";}; Led5 {label = "Led5"; gpios = <&gpio3 0>;d efault-state = "Off";}; Led6 {label = "Led6"; gpios = <&gpio3 0>;d efault-state = "Off";};};
test Method

After adding the above modifications to DTS, recompile DTS and start the kernel with the newly obtained DTB. The keys can be tested with the Hexdump command:

Hexdump/dev/input/event0
As you can see from the kernel boot log, the input device node created by the Gpio-keys driver is event0, so use hexdump to test if the key is valid. After executing the above instructions, press tqimx6q on the K1, K2, K3,hexdump will print out a row of numbers, it means that the key driver has been transplanted successfully, the effect is as follows:

@tqimx6q #hexdump/dev/input/event0 0000000 000c 0000 398c 0005 0001 0066 0001 00000000010 000c 0000 398c 0005 0000 0000 0 000 00000000020 000c 0000 f56e 0007 0001 0066 0000 00000000030 000c 0000 f56e 0007 0000 0000 0000 00000000040 000d 0000 5d C5 0005 0001 001c 0001 00000000050 000d 0000 5dc5 0005 0000 0000 0000 00000000060 000d 0000 ba4d 0008 0001 001c 0000 00000 000070 000d 0000 ba4d 0008 0000 0000 0000 00000000080 000e 0000 e45c 0006 0001 0001 0001 00000000090 000e 0000 e45c 0006 0 0000 0000 000000000a0 000e 0000 c9fb 0009 0001 0001 0000 000000000b0 000e 0000 c9fb 0009 0000 0000 0000 0000

After the LED driver migration is completed, the LED-related control node will be created into the/sys/class/leds directory, after the CD switch to the directory will find a corresponding directory: Led4, Led5, LED6, the following instructions can be lit by the corresponding LED lights:

Echo 1 >/sys/class/leds/led4/brightness
The specified LED lights can be turned off by the following instructions:

echo 0 >/sys/class/leds/led4/birghtness
wherein, brightness is the led4 directory next file node, you can control the brightness of led4 through this node, because the LED used in this article is not PWM control brightness, so long as the 0,led light is not lit.

At this point, the key and the LED are transplanted well. The mistake is welcome to point out, have any question can leave a message to discuss.




This article Girlkoo

This article link: http://blog.csdn.net/girlkoo/article/details/45565357

I.MX6Q (TQIMX6Q/TQE9) study notes--The new BSP key, LED

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.