新手上路
- 积分
- 24
- 金钱
- 24
- 注册时间
- 2020-2-4
- 在线时间
- 6 小时
|
1金钱
static int MyTimerInit(void)
{
int rtv;
struct resource* ptimer_src;
uint32_t reg_val;
uint32_t cr_reg_val = 0;
uint32_t array[3];
printk("key-timer addr = %x \r\n",keybeep_st.ptimernode);
rtv = of_property_read_u32_array(keybeep_st.ptimernode,"reg",array,2);
if(rtv == 0)
{
printk("ptimernode reg %x %x \r\n", array[0], array[1]);
}
ptimer_src = request_mem_region(array[0],4*5,"BeepTimer");
if(ptimer_src == NULL)
{
printk("epit1 is busy\r\n");
return -EINVAL;
}
EPIT_CR = ioremap(array[0],4);
EPIT_SR = ioremap(array[0]+4,4);
EPIT_LR = ioremap(array[0]+8,4);
EPIT_CMPR = ioremap(array[0]+12,4);
EPIT_CNR = ioremap(array[0]+16,4);
printk("1 epit1.CR = %x \r\n",epit1.CR);
cr_reg_val = (1<<24) | (65<<4) | ( 1 <<3 ) | (1<<2) | (1<<1);
writel(cr_reg_val,epit1.CR);
printk("2\r\n");
writel(1000000,epit1.LR);
printk("3\r\n");
writel(0,epit1.CMPR);
printk("4\r\n");
//获取中断号
keybeep_st.timerirq_num = irq_of_parse_and_map(keybeep_st.ptimernode,0);
printk("5\r\n");
if(keybeep_st.timerirq_num > 0)
{
rtv = request_irq(keybeep_st.timerirq_num,handle_Timer1Irq,IRQF_TRIGGER_NONE,"EPIT1",&keybeep_st);
printk("timer1: irqnum=%d\r\n",keybeep_st.timerirq_num);
}
else
{
return -EINVAL;
}
cr_reg_val = readl(EPIT_CR);
printk("epit1.CR %x \r\n",cr_reg_val);
cr_reg_val |= 1;
writel(cr_reg_val,epit1.CR);
return 0;
}
可以确定array[0] = 0x20D4000 或是 0x20D0000均会出现死机。
|
|