以pmu act8846的引脚为例,它需要用到pmic_vsel、pwr_hold两个脚,需要在pinctrl里配置保证它能作为gpio来使用,pmic_vsel硬件上默认为低电平状态,所以pinctrl需要配置pcfg_pull_down,pwr_hold为高电平状态,需要配置成pcfg_pull_up
/DTS/
act8846: act8846@5a {
compatible = "active-semi,act8846";
gpios =<&gpio7 14 GPIO_ACTIVE_LOW>,<&gpio0 6 GPIO_ACTIVE_HIGH>;
pinctrl-names = "default";
pinctrl-0 = <&pmic_vsel>, <&pwr_hold>;
}
act8846 {
pmic_vsel: pmic-vsel {
rockchip,pins = <7 14 RK_FUNC_GPIO &pcfg_pull_down>;
};
pwr_hold: pwr-hold {
rockchip,pins = <0 6 RK_FUNC_GPIO &pcfg_pull_up>;
};
vsel1_gpio: vsel1-gpio {
rockchip,pins = <RK_GPIO0 0 RK_FUNC_GPIO &pcfg_pull_down>;
};
};
接下来在uboot的.c文件来解析和拉高这两个引脚,因为上面DTS这两个脚是配置成双gpio的写法,gpios =<&gpio7 14 GPIO_ACTIVE_LOW>,<&gpio0 6 GPIO_ACTIVE_HIGH>; 所以在request引脚的时候,记得区分gpio_request_by_name第三个参数0是用于pmic_vsel,1是用于pwr_hold,gpio_request_by_name(dev, "gpios", 0,&gpio, GPIOD_IS_OUT);最后的一个参数GPIOD_IS_OUT是表示此引脚用于输出,如果想配成输入脚,把最后的参数改为GPIOD_IS_IN即可,最后dm_gpio_set_value来设置这个引脚的电平。
/C/
+++ b/drivers/power/pmic/act8846.c
[url=home.php?mod=space&uid=1999721]@@[/url] -12,6 +12,8 @@
#include <linux/libfdt.h>
#include <power/act8846_pmic.h>
#include <power/pmic.h>
+#include <asm/gpio.h>
+#include <dm/device.h>
int ret;
struct gpio_desc gpio;
ret = gpio_request_by_name(dev, "gpios", 0,&gpio, GPIOD_IS_OUT)
if (ret && ret != -ENOENT) {
dev_err(dev, "Cannot get vsel GPIO: %d\n", ret);
}else{
printf("%s>>>>parse pmic vsel gpio success\n",__func__);
if(dm_gpio_is_valid(&gpio))
dm_gpio_set_value(&gpio,0);
}
ret = gpio_request_by_name(dev, "gpios", 1,&gpio, GPIOD_IS_OUT)
if (ret && ret != -ENOENT) {
dev_err(dev, "Cannot get hold GPIO: %d\n", ret);
}else{
printf("%s>>>>parse pmic hold gpio success\n",__func__);
if(dm_gpio_is_valid(&gpio))
dm_gpio_set_value(&gpio,1);
}
regulators_node = dev_read_subnode(dev, "regulators");
if (!ofnode_valid(regulators_node)) {
原作者:朱景星tr