100s芯片内置的硬件定时器,配置了相关寄存器后,一直不触发中断,是哪里的问题,各位大佬帮忙看看,下面是部分驱动代码:
static irqreturn_t timer_handler(int irq, void *dev_id)
{
printk("%s %d %s\n",__FILE__,__LINE__,__FUNCTION__);
writel(readl(TIMER_IRQ_ST_Register)|(1<<1), TIMER_IRQ_ST_Register);//清pending
return IRQ_HANDLED;
}
static ssize_t hw_timer_write(struct file *file, const char __user *buf, size_t count, loff_t * ppos)
{
int val;
copy_from_user(&val, buf, count); // copy_to_user();
writel(val, TIMER1_INTVAL_Rigster);//12000为定时1ms
// printk("%x\n",readl(TIMER0_INTVAL_Rigster));
// printk("%x\n",readl(TIMER0_CNTVAL_Rigster));
/*24M,Single mode,2 precale*/
writel(0x94, TIMER1_CTRL_Rister);
writel(readl(TIMER1_CTRL_Rister)|(1<<1), TIMER1_CTRL_Rister);
while((readl(TIMER1_CTRL_Rister)>>1)&1);
writel(readl(TIMER1_CTRL_Rister)|(1<<0), TIMER1_CTRL_Rister);//使能定时器
}
static struct file_operations hw_timer_fops = {
.owner = THIS_MODULE, /* 这是一个宏,推向编译模块时自动创建的__this_module变量 */
.open = hw_timer_open,
.write = hw_timer_write,
.read = hw_timer_read,
};
int major;
int init_timer_module(void)
{
int ret;
major = register_chrdev(0, "hw_timer", &hw_timer_fops);
hwtimerdrv_cls = class_create(THIS_MODULE, "hw_timer");
hwtimercls_device = device_create(hwtimerdrv_cls, NULL, MKDEV(major, 0), NULL, "timer0"); /* /dev/buttons */
TIMER_IRQ_EN_Register = (volatile unsigned long *)ioremap(TIMER_BASE+TIMER_IRQ_EN_REG,4);
TIMER_IRQ_ST_Register = (volatile unsigned long *)ioremap(TIMER_BASE+TIMER_IRQ_ST_REG,4);
TIMER1_CTRL_Rister = (volatile unsigned long *)ioremap(TIMER_BASE+TIMER_CTL_REG(1),4);
TIMER1_INTVAL_Rigster = (volatile unsigned long *)ioremap(TIMER_BASE+TIMER_INTVAL_REG(1),4);
TIMER1_CNTVAL_Rigster = (volatile unsigned long *)ioremap(TIMER_BASE+TIMER_CNTVAL_REG(1),4);
// writel(1200000, TIMER0_INTVAL_Rigster);//
writel(readl(TIMER_IRQ_EN_Register)|(1<<1), TIMER_IRQ_EN_Register);//使能定时器1中断
/*申请中断*/
if (request_irq(14, (irq_handler_t )timer_handler, 0,"sunxi_timer1", NULL))
{
printk("irq request failure\n");
return -1;
}
return 0;
}
离线
目前增加寄存器配置,使能了INC_EN寄存器使能中断号,情况是中断有响应,但是一直提示没有中断执行程序似得,这个问题是出在哪里?各位大佬帮忙看看;
irq 0, desc: c0420cc0, depth: 1, count: 0, unhandled: 0
->handle_irq(): c005a7fc, handle_bad_irq+0x0/0x210
->irq_data.chip(): c0428958, 0xc0428958
->action(): (null) ==> 看着是没有action,但是上面是在申请中断的是有中断处理函数的
IRQ_NOPROBE set
IRQ_NOREQUEST set
irq 0, desc: c0420cc0, depth: 1, count: 0, unhandled: 0
->handle_irq(): c005a7fc, handle_bad_irq+0x0/0x210
->irq_data.chip(): c0428958, 0xc0428958
->action(): (null)
IRQ_NOPROBE set
IRQ_NOREQUEST set
irq 0, desc: c0420cc0, depth: 1, count: 0, unhandled: 0
->handle_irq(): c005a7fc, handle_bad_irq+0x0/0x210
->irq_data.chip(): c0428958, 0xc0428958
->action(): (null)
离线
你用timer2哇,我记得linux下面timer0是做clockevent,timer1是做clocksource吧,也就timer2没有用到了,我感觉是被修改了
离线
更换了timer2也是一样的情况,我参考tina\lichee\linux-3.10\drivers\clocksource\sunxi_timer.c文件重新写了一版,中断可以正常触发了,但是导致系统reboot不能正常生效了,好奇怪,这个bug我再看看。
离线
参考sunxi_timer.c写的驱动将timer1更换为timer2,不能重启的现象消失了,很有可能是你说的timer1被系统占用了,导致不能重启,具体细节未知。
最近编辑记录 jkl (2023-05-23 11:00:22)
离线