Linux 内核设备驱动之GPIO驱动之GPIO 管脚添加

本文详细介绍了在CONFIG_OF_GPIO配置下,通过intof_gpiochip_add函数实现GPIO芯片的添加过程,包括节点设置、别名定义及扫描等步骤,并概述了移除流程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在配置CONFIG_OF_GPIO下作用:
 

int of_gpiochip_add(struct gpio_chip *chip) {  int status;

 if ((!chip->of_node) && (chip->parent))   chip->of_node = chip->parent->of_node;

 if (!chip->of_node)   return 0;

 if (!chip->of_xlate) {   chip->of_gpio_n_cells = 2;   chip->of_xlate = of_gpio_simple_xlate;  }

 if (chip->of_gpio_n_cells > MAX_PHANDLE_ARGS)   return -EINVAL;

 status = of_gpiochip_add_pin_range(chip);  if (status)   return status;

 /* If the chip defines names itself, these take precedence */  if (!chip->names)   of_gpiochip_set_names(chip);

 of_node_get(chip->of_node);

 return of_gpiochip_scan_gpios(chip); }

void of_gpiochip_remove(struct gpio_chip *chip) {  gpiochip_remove_pin_ranges(chip);  of_node_put(chip->of_node); }

 
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值