In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Most people do not understand the knowledge points of this "cubieboard uboot GPIO driver case Analysis" article, so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "cubieboard uboot GPIO driver case Analysis" article.
Uboot's GPIO is quite simple, which is a three-tier structure. Respectively are: 1, the top interface layer, which only defines the general interface, and is not responsible for the implementation, the implementation is based on the specific chip to achieve.
2. In the middle interface implementation layer, the GPIO of the specific board is used to implement the interface of the top layer.
3. The implementation layer of the bottom specific chip GPIO.
Now make a specific analysis:
Top interface layer
Int gpio_request (unsigned gpio, const char * label); / / apply for GPIO resources
Int gpio_free (unsigned gpio); / / release the requested GPIO resources
Int gpio_direction_input (unsigned gpio); / / set GPIO to input mode
Int gpio_direction_output (unsigned gpio, int value); / / set GPIO to output mode
Int gpio_get_value (unsigned gpio); / / get the value of GPIO
Int gpio_set_value (unsigned gpio, int value); / / set the value of GPIO
Note: unsigned gpio is a logical number, although it has a certain relationship with the actual physical GPIO address, but it is not the actual physical GPIO address.
Intermediate interface implementation layer:
Use the GPIO of the specific chip to realize its top-level interface
Int gpio_request (unsigned gpio, const char * label)
{
Return 0
}
Int gpio_free (unsigned gpio)
{
Return 0
}
Int gpio_direction_input (unsigned gpio)
{
Sunxi_gpio_set_cfgpin (gpio, SUNXI_GPIO_INPUT)
Return sunxi_gpio_input (gpio)
}
Int gpio_direction_output (unsigned gpio, int value)
{
Sunxi_gpio_set_cfgpin (gpio, SUNXI_GPIO_OUTPUT)
Return sunxi_gpio_output (gpio, value)
}
Int gpio_get_value (unsigned gpio)
{
Return sunxi_gpio_input (gpio)
}
Int gpio_set_value (unsigned gpio, int value)
{
Return sunxi_gpio_output (gpio, value)
}
The implementation layer of the underlying specific chip GPIO:
In the implementation, it uses a little trick, its purpose is to put the physical register of GPIO into the structure, thus translating the physical address operation into the data structure operation.
The implementation is as follows:
Cast the SUNXI_PIO_BASE to a sunxi_gpio_reg * pointer.
# define SUNXI_PIO_BASE 0x01c20800
Struct sunxi_gpio {
U32 cfg [4]
U32 dat
U32 drv [2]
U32 pull [2]
}
Struct sunxi_gpio_int {
U32 cfg [3]
U32 ctl
U32 sta
U32 deb
}
Struct sunxi_gpio_reg {
Struct sunxi_gpio gpio_bank [9]
U8 res [0xbc]
Struct sunxi_gpio_int gpio_int
}
The idea that we implement the GPIO operation of a specific chip is:
Use the logical symbol unsigned gpio to manipulate the relevant registers through the SUNXI_PIO_BASE cast to the pointer of the sunxi_gpio_reg * pointer.
However, if the logical symbol unsigned gpio is to be converted to a pointer of the sunxi_gpio_reg * pointer by SUNXI_PIO_BASE to manipulate the related registers, we must solve the problem of how to find the specified register among the many registers and find the specified related bits on the register.
That is, offset in gpio---- > bank- > bank
This mapping relationship is related to the specific chip.
The above is about the content of this article "cubieboard uboot GPIO driver case Analysis". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more related knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.