Linux pinctrl子系统

  • Post author:
  • Post category:linux


一、pinctrl子系统介绍

在许多soc内部都包含有pin控制器,通过pin控制器的寄存器,我们可以配置一个或者一组引脚的功能和特性。在软件方面,为了统一各soc厂商的pin脚管理,Linux内核提供了pinctrl子系统。pinctrl子系统提供的功能有如下三点:(1)管理系统中所有的可以控制的pin,在系统初始化的时候,枚举所有可以控制的pin,并标识这些pin。(2)管理这些pin的复用(Multiplexing)。对于SOC而言,其引脚除了配置成普通的GPIO之外,若干个引脚还可以组成一个pin group,行程特定的功能。pin control subsystem要管理所有的pin group。(3)配置这些pin的特性。例如使能或关闭引脚上的pull-up、pull-down电阻,配置引脚的driver strength。

二、函数介绍

主要API:devm_pinctrl_get、devm_pinctrl_lookup_state、pinctrl_select_state

/*
 struct devm_pinctrl_get() - Resource managed pinctrl_get()
 @dev:the device to obtain the handle for
 If there is a need to explicitly destroy the returned struct pinctrl, the returned struct pinctrl.
 devm_pinctrl_put() should be used, rather than plain pinctrl_put().
 */
struct pinctrl devm_pinctrl_get(struct device dev);//1.根据设备获取pin操作句柄

/*
 pinctrl_lookup_state() - retrieves a state handle from a pinctrl handle
 @p: the pinctrl handle to retrive the state from
 @name: the state to retrive
 */
struct pinctrl_state pinctrl_lookup_state(struct pinctrl p, const char name);//2.获取这个pin对应的pin_state

/*
 pinctrl_select_state() - select/activate/program a pinctrl state to HW
 @p: the pinctrl handle for the device that requests configuration
 @state: the state handle to select/activate/program
 */
int pinctrl_select_state(struct pinctrl p, struct pinctrl_state *state);//3.设置引脚为state

三、pinctrl子系统与DTS的关系

3.1.pinctrl的dts文件分析

device-node-na



版权声明:本文为m0_49328056原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。