Linux设备驱动开发(5.4.58)-2-LED-CTRL

官方的io配置文档pinout.xyz

关于r3b的物理地址

官方说明

重点是:
If there is no kernel driver available, and a program needs to access a peripheral address directly with mmap, it needs to know where in the virtual memory map the peripheral bus segment has been placed. This varies according to which model of Raspberry Pi is being used, so there are three helper function available to provide platform independence. Note: please use these functions rather than hardcoded values, as this will ensure future compatibility.

unsigned bcm_host_get_peripheral_address()

This returns the ARM-side physical address where peripherals are mapped. This is 0x20000000 on the Pi Zero, Pi Zero W, and the first generation of the Raspberry Pi and Compute Module, and 0x3f000000 on the Pi 2, Pi 3 and Compute Module 3.

所以,r3b的IO基址装载在物理地址0x3F000000处。

再参考下图:
在这里插入图片描述1、VC CPU总线地址
2、ARM物理地址
3、ARM虚拟地址。

1、2之间通过VC/ARM MMU进行映射。
2、3之间通过ARM MMU来映射。

规格书上写的都是1。
内核操作的是2。
ioremap之后得到的应该是3。

比如现在要操作GPIO,IO在VC CPU总线上的基址是0x7E000000,在物理地址上的基址是0x3F000000。

我们看规格书:
在这里插入图片描述GPFSEL0寄存器VC CPU总线地址是0x7E200000,相对基址偏移0x00200000,那么ARM物理地址也是偏移这么多,其ARM物理地址是0x3f200000。
同理,GPSET0的ARM物理地址是0x3f20001C。

用mmap函数或者ioremap函数将这两个ARM物理地址映射成虚拟地址,就等同于直接操作GPIO硬件地址了。

关于r3b的gpio控制寄存器

我们计划控制gpio4。

关注三个寄存器,即复用,set,clear。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值