TI中文支持网
TI专业的中文技术问题搜集分享网站

AM335x 对eqep模块进行ioremap时出错

am335x,在SDK中没有EQEP的驱动程序,由于SDK比较老,不支持设备树,并且已经做了很多修改了,移植beaglebot的eqep驱动不可行。

用ioremap的方式去访问EQEP的寄存器时出错

程序:

//地址定义

const unsigned long AM335X_EQEP_BASE_PTR[] = {
0x48300180,
0x48302180,
0x48304180,
};

const unsigned long AM335X_EQEP_REG_SIZE = 0x80;

//寄存器定义

AM335X_EQEP_Regs_t AM335X_EQEP_Regs[] = {
{0x00, 0x00000000, 4},
{0x04, 0x00000000, 4},

…..

};

//在module的init函数中进行地址映射

eqep_virt_base_ptr_g[0] = ioremap(AM335X_EQEP_BASE_PTR[0], AM335X_EQEP_REG_SIZE);

//读取寄存器的函数

int EqepGetReg(int dev_id, AM335X_EQEP_Registers_t reg_id, void *value_p)
{
int reg_size = AM335X_EQEP_Regs[reg_id].size;
unsigned long *reg_base_ptr = (unsigned long *)(eqep_virt_base_ptr_g[dev_id] + AM335X_EQEP_Regs[reg_id].offset);

*((unsigned long *)value_p) = readl(reg_base_ptr);

return 0;
}

编译是正常通过的,把ko文件放到系统里面运行,在EqepGetReg函数的readl处出错:

[ 37.330383] Unhandled fault: external abort on non-linefetch (0x1028) at 0xfa30000c
[ 37.338378] Internal error: : 1028 [#1]
[ 37.342376] Modules linked in: eqep(O+) gpio_en(O) rfcomm(O) bnep(O) bluetooth(O) wl12xx(O) wlcore(O) mac80211(O) cfg80211(O) wlcore_sdio(O) compat(O) st_magn_i2c(C) st_sensors_i2c(C) st_magn(C) st_sensors(C) industrialio_triggered_buffer(C) kfifo_buf(C)
[ 37.365936] CPU: 0 Tainted: G C O (3.2.0+ #602)
[ 37.371765] PC is at PwmssGetReg+0x80/0xa0 [eqep]
[ 37.376708] LR is at __arm_ioremap_pfn_caller+0x40/0x224
[ 37.382232] pc : [<bf1311d0>] lr : [<c001901c>] psr: 60000013
[ 37.382263] sp : c72e5e78 ip : c7ffdfc0 fp : c72e5e8c
[ 37.394226] r10: c72e4038 r9 : 00000000 r8 : c04cda80
[ 37.399688] r7 : bf133000 r6 : 00000001 r5 : c72e5e94 r4 : 00000004
[ 37.406494] r3 : 483fffff r2 : 48000000 r1 : 48300fff r0 : fa30000c
[ 37.413299] Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user
[ 37.420745] Control: 10c5387d Table: 87364019 DAC: 00000015
[ 37.426757] Process insmod (pid: 927, stack limit = 0xc72e42f0)
[ 37.432922] Stack: (0xc72e5e78 to 0xc72e6000)
[ 37.437469] 5e60: bf131494 bf13144c
[ 37.446014] 5e80: c72e5ea4 c72e5e90 bf131228 bf13115c bf133014 00000000 c72e5eb4 c72e5ea8
[ 37.454559] 5ea0: bf133018 bf131210 c72e5ef4 c72e5eb8 c000868c bf13300c c72e5ee4 bf131494
[ 37.463104] 5ec0: bf13144c 00000001 c4a95400 bf131494 bf13144c 00000001 c4a95400 00000001
[ 37.471618] 5ee0: c4a95424 c005fc6c c72e5fa4 c72e5ef8 c0061b98 c0008600 bf131458 c72e5f08
[ 37.480163] 5f00: c0008420 c005fd60 00000000 000993e8 00000054 c4a95408 c72e5f34 c72e5f28
[ 37.488708] 5f20: 00000000 00000000 00000000 00000000 00000000 00000000 c89f8000 0000153d
[ 37.497253] 5f40: c89f896c c89f8897 c89f92fc c48260c0 00000598 00000758 00000000 00000000
[ 37.505798] 5f60: 00000014 00000015 0000000c 0000000a 00000008 00000000 c71ad3c0 401da4c0
[ 37.514343] 5f80: beabbd54 00000069 00000080 c00126e8 c72e4000 00000000 00000000 c72e5fa8
[ 37.522888] 5fa0: c0012540 c0060e64 401da4c0 beabbd54 000a5040 0000153d 000993e8 00000000
[ 37.531402] 5fc0: 401da4c0 beabbd54 00000069 00000080 beabbd58 beabbd58 00000000 00000000
[ 37.539947] 5fe0: 401875a0 beabb9f0 0001daf1 401875b0 80000010 000a5040 00000000 00000000
[ 37.548492] Backtrace:[ 37.551055] [<bf131150>] (PwmssGetReg+0x0/0xa0 [eqep]) from [<bf131228>] (virt_mem_check+0x24/0x30 [eqep])
[ 37.561126] r5:bf13144c r4:bf131494
[ 37.564880] [<bf131204>] (virt_mem_check+0x0/0x30 [eqep]) from [<bf133018>] (ModuleInit+0x18/0x34 [eqep])
[ 37.574890] [<bf133000>] (ModuleInit+0x0/0x34 [eqep]) from [<c000868c>] (do_one_initcall+0x98/0x15c)
[ 37.584442] [<c00085f4>] (do_one_initcall+0x0/0x15c) from [<c0061b98>] (sys_init_module+0xd40/0x17cc)
[ 37.594085] [<c0060e58>] (sys_init_module+0x0/0x17cc) from [<c0012540>] (ret_fast_syscall+0x0/0x30)
[ 37.603515] Code: e6ff3073 f57ff04f e1c530b0 ea000002 (e5903000)[ 37.609954] —[ end trace fa5517dc1e8a8d7c ]—
[ 37.619873] SR 1: curr=1062500, delta_v=3298, calc=1065798, act=1075000, gain=22
Segmentation fault

尝试了很多办法,但都没办法绕过这个地方,求解决。。。

Jian Zhou:

eqep这部分建议参考下PWM和Ecap的驱动:

http://processors.wiki.ti.com/index.php/AM335x_PWM_Driver%27s_Guide

Yaoming Qin:

我觉得可能是kernel中,control module中对eqep相应模块的根时钟没有开,可以在arch/arm/match-omap2/下看看相应的配置文件

Xiaoheng He:

回复 Yaoming Qin:

看datasheet看到了,读取control module的时候显示eqep是关闭状态(epwmss全0)

不过向control module写入数据的时候好像根本就写不进去的样子,写入后读取都是0

Steven Liu1:

只是想提醒确认一下:是否有初始化你所使用EQEP模块的源时钟树?以及当前模块的时钟?

一般来说访问一个普通的寄存器出错,常见的问题就是忘了初始化该模块的时钟树,直接去操作模块本身了,这时候模块都没有使能,所以就挂了。

如果确认配置了,配置完了后,建议还是加个打印,确认之前的配置是生效的吧。

Xiaoheng He:

回复 Steven Liu1:

亲啊  你还不如直接告诉我  开哪几个时钟,使能哪个bit,,你这样叫我找datasheet,到头来还是找datasheet,从那几十亿个字母里面翻一两个寄存器,一点效率都没有,一点卵用都没有,搞硬件的同事连系统都没写过,也说你这句话还不如他直接接个HCTL芯片上去算了,不是我说话重了点,你觉得呢?

Dendi:

回复 Xiaoheng He:

小行 你个囗囗。。。

赞(0)
未经允许不得转载:TI中文支持网 » AM335x 对eqep模块进行ioremap时出错
分享到: 更多 (0)