LINUX子系统之pinctrl子系统(一)

简单介绍

像以前我们在开发单片机的时候就经常涉及到引脚的配置,如果更换了pin脚就需要重新配置下引脚,规范点的做法就是将引脚用宏定义定义,当需要某个引脚时只需要修改宏定义即可,不用全局更换,在Linux中引入了pinctrl子系统,**pinctrl子系统的作用就是负责引脚的复用(用作什么功能)、配置(open drain等)和引脚的枚举命名(支持哪些引脚)其定义主要由function(用作什么功能,IIC(要不要上拉?)?UART?)和group(用哪几组引脚?PINA1和PINA2?)组成.**在设备树中我们使用pinctrl节点的节点称为client.
图1
如上图黄色方框的部分为pinctrl子系统的一个节点,红色方框为它的client,也就是使用它的设备,可以看出pinctrl节点中有function和groups,对于不同的IC厂,使用的语法不一样但是对于内涵还是一致的,对于右边的client引用了该节点,且在不同的状态下对应了不同的pinctrl节点,即不同状态下对应不用的工作模式。

主要数据结构介绍

如图1所示,根据Linux中面向对象的特点,**会将pincontroller抽象出一个pinctrl_dev结构体,将device抽象出device结构体,这个device结构体里面肯定会有一个pinctrl成员和pinctrl_dev挂钩。**那么该如何去构造出这个pinctrl_dev?答案就是设置,分配,设置,注册一个pinctrl_desc结构体

/**
 * struct pinctrl_desc - pin controller descriptor, register this to pin
 * control subsystem
 * @name: name for the pin controller
 * @pins: an array of pin descriptors describing all the pins handled by
 *	this pin controller
 * @npins: number of descriptors in the array, usually just ARRAY_SIZE()
 *	of the pins field above
 * @pctlops: pin control operation vtable, to support global concepts like
 *	grouping of pins, this is optional.
 * @pmxops: pinmux operations vtable, if you support pinmuxing in your driver
 * @confops: pin config operations vtable, if you support pin configuration in
 *	your driver
 * @owner: module providing the pin controller, used for refcounting
 * @num_custom_params: Number of driver-specific custom parameters to be parsed
 *	from the hardware description
 * @custom_params: List of driver_specific custom parameters to be parsed from
 *	the hardware description
 * @custom_conf_items: Information how to print @params in debugfs, must be
 *	the same size as the @custom_params, i.e. @num_custom_params
 */
struct pinctrl_desc {
   
	const char *name;
	const struct pinctrl_pin_desc *pins;
	unsigned int npins;
	const struct pinctrl_ops *pctlops;
	const struct pinmux_ops *pmxops;
	const struct pinconf_ops *confops;
	struct module *owner;
#ifdef CONFIG_GENERIC_PINCONF
	unsigned int num_custom_params;
	const struct pinconf_generic_params *custom_params;
	const struct pin_config_item 
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值