RK3588 在uboot 和kernel下对GPIO的配置

        由于项目的原因在kernel初始化GPIO已不能满足需求,所以在uboot 时就必须初始化好GPIO,本想着uboot 跟kernel一样dts中直接配置就完成了,结果却不行,大概看了下uboot 下的pinctrl源码发现只对bank,pin,mux,conf 有进行解析,没看到对direction 和value有解析。因此我在uboot 配置GPIO时采用了代码和dts的组合。如有可以直接使用dts 完成的请留言告诉。

一、查找GPIO的寄存器地址

        为什么首先要查找寄存器地址呢,因为我们必须对我们修改进行确认,通过寄存器的地址我们能明确知道我们的修改是否成功。

        GPIO复用

GPIO功能

二、在dts中配置GPIO的复用和上,下拉。

gpio_func_init: gpio_func_init{

        u-boot,dm-pre-reloc;

        compatible = "regulator-fixed";

        pinctrl-names = "default";

        pinctrl-0 = <&init_gpio_func>;

        status = "okay";

        regulator-always-on;

};

&pinctrl{

        gpio_func_pins{

                init_gpio_func:init-gpio-func{

                        u-boot,dm-spl;

                        rockchip,pins=

                        <3, RK_PA3 0  &pcfg_pull_up>

                        <2, RK_PA3 0  &pcfg_pull_up>

                };

        };

};

三、在代码中实现相应管脚的输入,输出及电平的配置

#define FUNC_GPIO_BANK0    0
#define FUNC_GPIO_BANK1    32
#define FUNC_GPIO_BANK2    64
#define FUNC_GPIO_BANK3    96
#define FUNC_GPIO_BANK4    128
#define FUNC_PA0           0
#define FUNC_PA1           1
#define FUNC_PA2           2
#define FUNC_PA3           3
#define FUNC_PA4           4
#define FUNC_PA5           5
#define FUNC_PA6           6
#define FUNC_PA7           7
#define FUNC_PB0           8
#define FUNC_PB1           9
#define FUNC_PB2           10
#define FUNC_PB3           11
#define FUNC_PB4           12
#define FUNC_PB5           13
#define FUNC_PB6           14
#define FUNC_PB7           15
#define FUNC_PC0           16
#define FUNC_PC1           17
#define FUNC_PC2           18
#define FUNC_PC3           19
#define FUNC_PC4           20
#define FUNC_PC5           21
#define FUNC_PC6           22
#define FUNC_PC7           23
#define FUNC_PD0           24
#define FUNC_PD1           25
#define FUNC_PD2           26
#define FUNC_PD3           27
#define FUNC_PD4           28
#define FUNC_PD5           29
#define FUNC_PD6           30
#define FUNC_PD7           31

static void func_gpio_init(void)
{
    gpio_request(FUNC_GPIO_BANK2|FUNC_PA3,"FUNC_GPIO2_PA3");
    gpio_direction_output(FUNC_GPIO_BANK2|FUNC_PA3,0);

    gpio_request(FUNC_GPIO_BANK3|FUNC_PA3,"FUNC_GPIO3_PA3");
    gpio_direction_output(FUNC_GPIO_BANK3|FUNC_PA3,0);
}

  • 9
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

dreamliweiming

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值