【海思应用篇】-(4)GPIO内核配置

xclshwd 2020-08-31 08:41:19 3960
【海思应用篇】-(4)GPIO内核配置

海思每个芯片都有好多组的GPIO芯片,有时候我们发现明明有好多组设备,但是在设备/dev下找不到那么多,这是可以通过设备树映射出设备的节点。

~ # ls -l /dev/gp*
crw-------    1 root     root      254,   0 Jan  1  1970 /dev/gpiochip0
crw-------    1 root     root      254,   1 Jan  1  1970 /dev/gpiochip1
crw-------    1 root     root      254,  10 Jan  1  1970 /dev/gpiochip10
crw-------    1 root     root      254,  11 Jan  1  1970 /dev/gpiochip11
crw-------    1 root     root      254,  12 Jan  1  1970 /dev/gpiochip12
crw-------    1 root     root      254,  13 Jan  1  1970 /dev/gpiochip13
crw-------    1 root     root      254,  14 Jan  1  1970 /dev/gpiochip14
crw-------    1 root     root      254,  15 Jan  1  1970 /dev/gpiochip15
crw-------    1 root     root      254,  16 Jan  1  1970 /dev/gpiochip16
crw-------    1 root     root      254,  17 Jan  1  1970 /dev/gpiochip17
crw-------    1 root     root      254,  18 Jan  1  1970 /dev/gpiochip18
crw-------    1 root     root      254,  19 Jan  1  1970 /dev/gpiochip19
crw-------    1 root     root      254,   2 Jan  1  1970 /dev/gpiochip2
crw-------    1 root     root      254,  20 Jan  1  1970 /dev/gpiochip20
crw-------    1 root     root      254,  21 Jan  1  1970 /dev/gpiochip21
crw-------    1 root     root      254,  22 Jan  1  1970 /dev/gpiochip22
crw-------    1 root     root      254,  23 Jan  1  1970 /dev/gpiochip23
crw-------    1 root     root      254,  24 Jan  1  1970 /dev/gpiochip24
crw-------    1 root     root      254,  25 Jan  1  1970 /dev/gpiochip25
crw-------    1 root     root      254,   3 Jan  1  1970 /dev/gpiochip3
crw-------    1 root     root      254,   4 Jan  1  1970 /dev/gpiochip4
crw-------    1 root     root      254,   5 Jan  1  1970 /dev/gpiochip5
crw-------    1 root     root      254,   6 Jan  1  1970 /dev/gpiochip6
crw-------    1 root     root      254,   7 Jan  1  1970 /dev/gpiochip7
crw-------    1 root     root      254,   8 Jan  1  1970 /dev/gpiochip8
crw-------    1 root     root      254,   2 Jan  1  1970 /dev/gpiochip2
crw-------    1 root     root      254,  20 Jan  1  1970 /dev/gpiochip20
crw-------    1 root     root      254,  21 Jan  1  1970 /dev/gpiochip21
crw-------    1 root     root      254,  22 Jan  1  1970 /dev/gpiochip22
crw-------    1 root     root      254,  23 Jan  1  1970 /dev/gpiochip23
crw-------    1 root     root      254,  24 Jan  1  1970 /dev/gpiochip24
crw-------    1 root     root      254,  25 Jan  1  1970 /dev/gpiochip25
crw-------    1 root     root      254,   3 Jan  1  1970 /dev/gpiochip3
crw-------    1 root     root      254,   4 Jan  1  1970 /dev/gpiochip4
crw-------    1 root     root      254,   5 Jan  1  1970 /dev/gpiochip5
crw-------    1 root     root      254,   6 Jan  1  1970 /dev/gpiochip6
crw-------    1 root     root      254,   7 Jan  1  1970 /dev/gpiochip7
crw-------    1 root     root      254,   8 Jan  1  1970 /dev/gpiochip8
crw-------    1 root     root      254,   9 Jan  1  1970 /dev/gpiochip9
1.内核配置
1.1 hi3531dv200.dtsi添加
gpio_chip0: gpio_chip@11090000 {
                compatible = "arm,pl061", "arm,primecell";
                reg = <0x11090000 0x1000>;
                interrupts = <GIC_SPI 64 IRQ_TYPE_LEVEL_HIGH>;
                #gpio-cells = <2>;
                clocks = <&clock HI3531DV200_FIXED_50M>;
                clock-names = "apb_pclk";
                status = "disabled";
            };

            gpio_chip1: gpio_chip@11091000 {
                compatible = "arm,pl061", "arm,primecell";
                reg = <0x11091000 0x1000>;
                interrupts = <GIC_SPI 65 IRQ_TYPE_LEVEL_HIGH>;
                #gpio-cells = <2>;
                clocks = <&clock HI3531DV200_FIXED_50M>;
                clock-names = "apb_pclk";
                status = "disabled";
            };

            gpio_chip2: gpio_chip@11092000 {
                compatible = "arm,pl061", "arm,primecell";
                reg = <0x11092000 0x1000>;
                interrupts = <GIC_SPI 66 IRQ_TYPE_LEVEL_HIGH>;
                #gpio-cells = <2>;
                clocks = <&clock HI3531DV200_FIXED_50M>;
                clock-names = "apb_pclk";
                status = "disabled";
            };

            gpio_chip3: gpio_chip@11093000 {
                compatible = "arm,pl061", "arm,primecell";
                reg = <0x11093000 0x1000>;
                interrupts = <GIC_SPI 67 IRQ_TYPE_LEVEL_HIGH>;
                #gpio-cells = <2>;
                clocks = <&clock HI3531DV200_FIXED_50M>;
                clock-names = "apb_pclk";
                status = "disabled";
            };
    。。。。。
gpio_chip24: gpio_chip@110A8000 {
                compatible = "arm,pl061", "arm,primecell";
                reg = <0x110A8000 0x1000>;
                interrupts = <GIC_SPI 88 IRQ_TYPE_LEVEL_HIGH>;
                #gpio-cells = <2>;
                clocks = <&clock HI3531DV200_FIXED_50M>;
                clock-names = "apb_pclk";
                status = "disabled";
            };

            gpio_chip25: gpio_chip@110A9000 {
                compatible = "arm,pl061", "arm,primecell";
                reg = <0x110A9000 0x1000>;
                interrupts = <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>;
                #gpio-cells = <2>;
                clocks = <&clock HI3531DV200_FIXED_50M>;
                clock-names = "apb_pclk";
                status = "disabled";
            };
1.2 hi3531dv200-demb.dts 使能状态
aliases {
        serial0 = &uart0;

        serial1 = &uart1;
        serial2 = &uart2;
        serial3 = &uart3;
        serial4 = &uart4;

        i2c0 = &i2c_bus0;
        i2c1 = &i2c_bus1;

        spi0 = &spi_bus0;

        gpio0 = &gpio_chip0;
        gpio1 = &gpio_chip1;
        gpio2 = &gpio_chip2;
        gpio3 = &gpio_chip3;
        gpio4 = &gpio_chip4;
        gpio5 = &gpio_chip5;
        gpio6 = &gpio_chip6;
        gpio7 = &gpio_chip7;
        gpio8 = &gpio_chip8;
        gpio9 = &gpio_chip9;
        gpio10 = &gpio_chip10;
        gpio11 = &gpio_chip11;
        gpio12 = &gpio_chip12;
        gpio13 = &gpio_chip13;
        gpio14 = &gpio_chip14;
        gpio15 = &gpio_chip15;
        gpio16 = &gpio_chip16;
        gpio17 = &gpio_chip17;
        gpio18 = &gpio_chip18;
        gpio19 = &gpio_chip19;
        gpio20 = &gpio_chip20;
        gpio21 = &gpio_chip21;
        gpio22 = &gpio_chip22;
        gpio23 = &gpio_chip23;
        gpio24 = &gpio_chip24;
        gpio25 = &gpio_chip25;
    };
3.编译内核

重新编译内核,烧录 就会在设备节点生成各个gpio节点,就可以操作相应的gpio。

声明:本文内容由易百纳平台入驻作者撰写,文章观点仅代表作者本人,不代表易百纳立场。如有内容侵权或者其他问题,请联系本站进行删除。
xclshwd
红包 点赞 收藏 评论 打赏
评论
0个
内容存在敏感词
手气红包
    易百纳技术社区暂无数据
相关专栏
置顶时间设置
结束时间
删除原因
  • 广告/SPAM
  • 恶意灌水
  • 违规内容
  • 文不对题
  • 重复发帖
打赏作者
易百纳技术社区
xclshwd
您的支持将鼓励我继续创作!
打赏金额:
¥1易百纳技术社区
¥5易百纳技术社区
¥10易百纳技术社区
¥50易百纳技术社区
¥100易百纳技术社区
支付方式:
微信支付
支付宝支付
易百纳技术社区微信支付
易百纳技术社区
打赏成功!

感谢您的打赏,如若您也想被打赏,可前往 发表专栏 哦~

举报反馈

举报类型

  • 内容涉黄/赌/毒
  • 内容侵权/抄袭
  • 政治相关
  • 涉嫌广告
  • 侮辱谩骂
  • 其他

详细说明

审核成功

发布时间设置
发布时间:
是否关联周任务-专栏模块

审核失败

失败原因
备注
拼手气红包 红包规则
祝福语
恭喜发财,大吉大利!
红包金额
红包最小金额不能低于5元
红包数量
红包数量范围10~50个
余额支付
当前余额:
可前往问答、专栏板块获取收益 去获取
取 消 确 定

小包子的红包

恭喜发财,大吉大利

已领取20/40,共1.6元 红包规则

    易百纳技术社区