4205 views|5 replies

7171

Posts

195

Resources
The OP
 

Chapter 6 of "Detailed Explanation and Practice of Atomic Embedded Linux Driver Development" Pinctrl and GPIO Subsystem Learning and Combination Examples [Copy link]

The Linux kernel provides pinctrl and gpio subsystems for GPIO drivers

Pinctrl Subsystem

Linux drivers emphasize driver separation and layering. The Linux kernel introduces the pinctrl subsystem for pin configuration and the GPIO subsystem for gpio configuration.

Pinctrl subsystem work content

1Get the pin information in the device book

2Set the pin multiplexing function according to the obtained pin information

3. Set the electrical characteristics of the beer according to the obtained Pin information: pull-up and pull-down speed

The driver file is in

How to add pinctrl node template

1 Create the corresponding node

Pinctrl_test:testgrp{

//Specific pin information

}

2Add fsl,pin attributes

Pinctrl_test:testgrp{

fsl,pins = <

//Pin configuration information used by the device

>

};

Look at the gpio_led code

The GPIO subsystem is used to initialize GPIO and provide corresponding API functions

Get the GPIO number function of_get_named_gpio

GPIO request function gpio_request

GPIO output setting function gpio_direction_output

GPIO input setting function gpio_direction_input

Get GPIO pin value function gpio_get_value

Set GPIO output value gpio_set_value

Led driver analysis

1 Get the device node gpio_led

gpioled.nd = of_find_node_by_path("/gpioled");

2 Get the gpio property of the device tree to get the LED number used by the LED

gpioled.led_gpio = of_get_named_gpio(gpioled.nd, "led-gpio", 0);

3Set the level

gpio_direction_output(gpioled.led_gpio, 1);

Then register the device character driver, create and delete the device

Test code

This post is from Embedded System

Latest reply

Support the original poster, thank you for your hard work, thank you for sharing the technical content of embedded Linux driver development, I hope you will continue to work hard   Details Published on 2024-10-1 12:28

725

Posts

4

Resources
2
 

Support the original poster, thank you for your hard work, thank you for sharing the technical content of embedded Linux driver development, I hope you will continue to work hard

This post is from Embedded System
 
 

6027

Posts

6

Resources
3
 

Thanks to the host for sharing the technical content of embedded Linux driver development

This post is from Embedded System
 
Personal signature

在爱好的道路上不断前进,在生活的迷雾中播撒光引

 
 

55

Posts

0

Resources
4
 

A rare good thing, thank you for sharing, I will spend some time to study it next

This post is from Embedded System
 
 
 

8

Posts

0

Resources
5
 

Thanks to the OP for sharing the embedded technology content. I support the OP.

This post is from Embedded System
 
 
 

413

Posts

0

Resources
6
 

Support the original poster, thank you for your hard work, thank you for sharing the technical content of embedded Linux driver development, I hope you will continue to work hard

This post is from Embedded System
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list