5347
- 收藏
- 点赞
- 分享
- 举报
hi3516a 按键驱动注册中断失败
驱动代码如下
[code]irqreturn_t key_intter(int irq, void *dev_id)
{
//1. 检测是否发生了按键中断 这里可以暂时不做,因为这里没有使用共享中断
//2. 清除已经发生的按键中断 这个是指硬件内部处理,按键CPU内部不需要做处理
//比如如果是网卡驱动 就要处理
//3. 打印按键值
printk(KERN_WARNING"key down!\n");
return 0;
}
void key_hw_init(void) //按键硬件初始化部分
{
int ret;
writel(0x00000000, IO_ADDRESS(0x200f0104)); //tobe gpio11_7
ret=readl(IO_ADDRESS(0x201f0400)); //direction
ret=ret&0x7f; //direction is in
writel(ret, IO_ADDRESS(0x201f0400));
ret=readl(IO_ADDRESS(0x201f0404)); //interrupt type level trigger
ret=ret|0x80; //
writel(ret, IO_ADDRESS(0x201f0404));
ret=readl(IO_ADDRESS(0x201f040c)); //low level trigger
ret=ret&0x7f; //
writel(ret, IO_ADDRESS(0x201f040c));
writel(0x80, IO_ADDRESS(0x201f041c)); //clean interrupt
ret=readl(IO_ADDRESS(0x201f0410)); //interrupt mask
ret=ret|0x80; //
writel(ret, IO_ADDRESS(0x201f0410));
printk(KERN_WARNING"init ...!\n");
//第二步: 按键中断部分相应处理 注册中断 注销等等
}
int key_open(struct inode *node, struct file *filp)
{
printk(KERN_WARNING"open ...!\n");
return 0;
}
struct file_operations key_fops =
{
.open = key_open,
};
struct miscdevice* key=NULL;
static int key_init1(void)
{
int err;
key = kzalloc(sizeof(struct miscdevice), GFP_KERNEL);
if (!key)
return -ENOMEM;
key->minor = MISC_DYNAMIC_MINOR;
key->name = "key";
key->fops = &key_fops;
err = misc_register(key);
//按键初始化 硬件初始化部分一般可一放在模块初始化部分或者open函数中 这里放在模块初始化部分
key_hw_init();
//由高电平变为低电平产生中断 IRQF_TRIGGER_FALLING
printk("matt-2\n");
//if( (err = request_irq(112,key_intter, IRQF_SHARED|IRQF_TRIGGER_LOW, "key", key)) < 0 )//注册中断处理程序 5个参数
if( (err = request_irq(112,key_intter, IRQF_TRIGGER_LOW, "key", key)) < 0 )
//if( (err = request_irq(112,key_intter, IRQF_SHARED, "key", key)) < 0 )
{
printk(KERN_WARNING"err = %d\n", err);
goto irq_err;
}
return 0;
irq_err:
misc_deregister(key);
return -1;
}
static void key_exit1(void)
{
free_irq(112, 0);//注销中断 这里irqnumber参数暂时用一个变量来表示(中断号)
misc_deregister(key);//注销一个混杂设备驱动
printk(KERN_WARNING"key up!");
}
module_init(key_init1);
module_exit(key_exit1);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("key driver");
[/code]
运行insmod以后报错:
/usr # insmod key.ko
init ...!
matt-2
err = -22
insmod: can't insert 'key.ko': Operation not permitted
/usr # cat /proc/interrupts
CPU0
35: 434786 GIC timer
39: 0 GIC RTC Alarm
40: 1525 GIC uart-pl011
51: 0 GIC hi_mci
52: 0 GIC hi_mci
53: 478 GIC ehci_hcd:usb1
54: 1 GIC ohci_hcd:usb2
57: 166 GIC gmac0
65: 0 GIC VOU Interrupt
66: 0 GIC mipi int
67: 0 GIC ISP, VIU
68: 0 GIC VPSS0
69: 1 GIC tde_osr_isr
70: 0 GIC VGS0
71: 0 GIC AIO Interrupt
72: 0 GIC VEDU_0
73: 0 GIC JPEGU_0
75: 0 GIC HEVCU_0
76: 0 GIC VDA
77: 0 GIC IVE
88: 0 GIC RTC Temperature
Err: 0
/usr # fbset -s
fbset: can't open '/dev/fb0': Operation not permitted
/usr # ifconfig eth0 192.168.1.133
/usr # ls
4g2wifi.sh hi_gpio.ko ntp_service.sh sbin
bin key.ko ppp start.sh
gpio.ko lib rtc_test testgpio
/usr # rm -rf key.ko
/usr # ls
4g2wifi.sh hi_gpio.ko ntp_service.sh sbin
bin key.ko ppp start.sh
gpio.ko lib rtc_test testgpio
/usr # chmod 777 key.ko
/usr # insmod key.ko
init ...!
matt-2
setting trigger mode 8 for irq 44 failed (gic_set_type+0x0/0xc8)
err = -22
insmod: can't insert 'key.ko': Operation not permitted
/usr # rm -rf key.ko
/usr # ls
4g2wifi.sh hi_gpio.ko ntp_service.sh sbin
bin key.ko ppp start.sh
gpio.ko lib rtc_test testgpio
/usr # chmod 777 key.ko
/usr # insmod key.ko
init ...!
matt-2
err = -22
insmod: can't insert 'key.ko': Operation not permitted
/usr # rm -rf key.ko
/usr # chmod 777 key.ko
/usr # insmod key.ko
init ...!
matt-2
err = -22
insmod: can't insert 'key.ko': Operation not permitted
/usr # rm -rf key.ko
/usr # chmod 777 key.ko
/usr # insmod key.ko
init ...!
matt-2
err = -22
insmod: can't insert 'key.ko': Operation not permitted
查看中断也没有注册上,请问哪位大侠知道原因指点一二
/usr # cat /proc/interrupts
CPU0
35: 1980675 GIC timer
39: 0 GIC RTC Alarm
40: 2147 GIC uart-pl011
51: 0 GIC hi_mci
52: 0 GIC hi_mci
53: 2178 GIC ehci_hcd:usb1
54: 1 GIC ohci_hcd:usb2
57: 670 GIC gmac0
65: 0 GIC VOU Interrupt
66: 0 GIC mipi int
67: 0 GIC ISP, VIU
68: 0 GIC VPSS0
69: 1 GIC tde_osr_isr
70: 0 GIC VGS0
71: 0 GIC AIO Interrupt
72: 0 GIC VEDU_0
73: 0 GIC JPEGU_0
75: 0 GIC HEVCU_0
76: 0 GIC VDA
77: 0 GIC IVE
88: 0 GIC RTC Temperature
[code]irqreturn_t key_intter(int irq, void *dev_id)
{
//1. 检测是否发生了按键中断 这里可以暂时不做,因为这里没有使用共享中断
//2. 清除已经发生的按键中断 这个是指硬件内部处理,按键CPU内部不需要做处理
//比如如果是网卡驱动 就要处理
//3. 打印按键值
printk(KERN_WARNING"key down!\n");
return 0;
}
void key_hw_init(void) //按键硬件初始化部分
{
int ret;
writel(0x00000000, IO_ADDRESS(0x200f0104)); //tobe gpio11_7
ret=readl(IO_ADDRESS(0x201f0400)); //direction
ret=ret&0x7f; //direction is in
writel(ret, IO_ADDRESS(0x201f0400));
ret=readl(IO_ADDRESS(0x201f0404)); //interrupt type level trigger
ret=ret|0x80; //
writel(ret, IO_ADDRESS(0x201f0404));
ret=readl(IO_ADDRESS(0x201f040c)); //low level trigger
ret=ret&0x7f; //
writel(ret, IO_ADDRESS(0x201f040c));
writel(0x80, IO_ADDRESS(0x201f041c)); //clean interrupt
ret=readl(IO_ADDRESS(0x201f0410)); //interrupt mask
ret=ret|0x80; //
writel(ret, IO_ADDRESS(0x201f0410));
printk(KERN_WARNING"init ...!\n");
//第二步: 按键中断部分相应处理 注册中断 注销等等
}
int key_open(struct inode *node, struct file *filp)
{
printk(KERN_WARNING"open ...!\n");
return 0;
}
struct file_operations key_fops =
{
.open = key_open,
};
struct miscdevice* key=NULL;
static int key_init1(void)
{
int err;
key = kzalloc(sizeof(struct miscdevice), GFP_KERNEL);
if (!key)
return -ENOMEM;
key->minor = MISC_DYNAMIC_MINOR;
key->name = "key";
key->fops = &key_fops;
err = misc_register(key);
//按键初始化 硬件初始化部分一般可一放在模块初始化部分或者open函数中 这里放在模块初始化部分
key_hw_init();
//由高电平变为低电平产生中断 IRQF_TRIGGER_FALLING
printk("matt-2\n");
//if( (err = request_irq(112,key_intter, IRQF_SHARED|IRQF_TRIGGER_LOW, "key", key)) < 0 )//注册中断处理程序 5个参数
if( (err = request_irq(112,key_intter, IRQF_TRIGGER_LOW, "key", key)) < 0 )
//if( (err = request_irq(112,key_intter, IRQF_SHARED, "key", key)) < 0 )
{
printk(KERN_WARNING"err = %d\n", err);
goto irq_err;
}
return 0;
irq_err:
misc_deregister(key);
return -1;
}
static void key_exit1(void)
{
free_irq(112, 0);//注销中断 这里irqnumber参数暂时用一个变量来表示(中断号)
misc_deregister(key);//注销一个混杂设备驱动
printk(KERN_WARNING"key up!");
}
module_init(key_init1);
module_exit(key_exit1);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("key driver");
[/code]
运行insmod以后报错:
/usr # insmod key.ko
init ...!
matt-2
err = -22
insmod: can't insert 'key.ko': Operation not permitted
/usr # cat /proc/interrupts
CPU0
35: 434786 GIC timer
39: 0 GIC RTC Alarm
40: 1525 GIC uart-pl011
51: 0 GIC hi_mci
52: 0 GIC hi_mci
53: 478 GIC ehci_hcd:usb1
54: 1 GIC ohci_hcd:usb2
57: 166 GIC gmac0
65: 0 GIC VOU Interrupt
66: 0 GIC mipi int
67: 0 GIC ISP, VIU
68: 0 GIC VPSS0
69: 1 GIC tde_osr_isr
70: 0 GIC VGS0
71: 0 GIC AIO Interrupt
72: 0 GIC VEDU_0
73: 0 GIC JPEGU_0
75: 0 GIC HEVCU_0
76: 0 GIC VDA
77: 0 GIC IVE
88: 0 GIC RTC Temperature
Err: 0
/usr # fbset -s
fbset: can't open '/dev/fb0': Operation not permitted
/usr # ifconfig eth0 192.168.1.133
/usr # ls
4g2wifi.sh hi_gpio.ko ntp_service.sh sbin
bin key.ko ppp start.sh
gpio.ko lib rtc_test testgpio
/usr # rm -rf key.ko
/usr # ls
4g2wifi.sh hi_gpio.ko ntp_service.sh sbin
bin key.ko ppp start.sh
gpio.ko lib rtc_test testgpio
/usr # chmod 777 key.ko
/usr # insmod key.ko
init ...!
matt-2
setting trigger mode 8 for irq 44 failed (gic_set_type+0x0/0xc8)
err = -22
insmod: can't insert 'key.ko': Operation not permitted
/usr # rm -rf key.ko
/usr # ls
4g2wifi.sh hi_gpio.ko ntp_service.sh sbin
bin key.ko ppp start.sh
gpio.ko lib rtc_test testgpio
/usr # chmod 777 key.ko
/usr # insmod key.ko
init ...!
matt-2
err = -22
insmod: can't insert 'key.ko': Operation not permitted
/usr # rm -rf key.ko
/usr # chmod 777 key.ko
/usr # insmod key.ko
init ...!
matt-2
err = -22
insmod: can't insert 'key.ko': Operation not permitted
/usr # rm -rf key.ko
/usr # chmod 777 key.ko
/usr # insmod key.ko
init ...!
matt-2
err = -22
insmod: can't insert 'key.ko': Operation not permitted
查看中断也没有注册上,请问哪位大侠知道原因指点一二
/usr # cat /proc/interrupts
CPU0
35: 1980675 GIC timer
39: 0 GIC RTC Alarm
40: 2147 GIC uart-pl011
51: 0 GIC hi_mci
52: 0 GIC hi_mci
53: 2178 GIC ehci_hcd:usb1
54: 1 GIC ohci_hcd:usb2
57: 670 GIC gmac0
65: 0 GIC VOU Interrupt
66: 0 GIC mipi int
67: 0 GIC ISP, VIU
68: 0 GIC VPSS0
69: 1 GIC tde_osr_isr
70: 0 GIC VGS0
71: 0 GIC AIO Interrupt
72: 0 GIC VEDU_0
73: 0 GIC JPEGU_0
75: 0 GIC HEVCU_0
76: 0 GIC VDA
77: 0 GIC IVE
88: 0 GIC RTC Temperature
我来回答
回答7个
时间排序
认可量排序
认可0
认可0
认可0
认可0
认可0
认可0
认可0
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币
Markdown 语法
- 加粗**内容**
- 斜体*内容*
- 删除线~~内容~~
- 引用> 引用内容
- 代码`代码`
- 代码块```编程语言↵代码```
- 链接[链接标题](url)
- 无序列表- 内容
- 有序列表1. 内容
- 缩进内容
- 图片![alt](url)
相关问答
-
2020-04-07 11:27:00
-
2016-02-02 16:13:17
-
2015-12-18 15:36:49
-
2020-03-18 14:14:15
-
2016-04-05 15:38:48
-
2018-12-27 10:11:50
-
2017-09-22 10:03:20
-
2015-12-07 14:49:03
-
2018-12-25 16:09:03
-
2016-12-20 11:24:59
-
2015-07-29 16:43:18
-
2016-08-31 09:16:09
-
2015-08-14 12:26:32
-
2015-12-10 15:58:29
-
2016-03-10 12:02:23
-
2020-11-11 15:41:54
-
2020-11-14 10:51:48
-
2020-07-28 09:23:51
-
2018-12-27 15:52:20
无更多相似问答 去提问
点击登录
-- 积分
-- E币
提问
—
收益
—
被采纳
—
我要提问
切换马甲
上一页
下一页
悬赏问答
-
50如何获取vpss chn的图像修改后发送至vo
-
5FPGA通过Bt1120传YUV422数据过来,vi接收不到数据——3516dv500
-
50SS928 运行PQtools 拼接 推到设备里有一半画面会异常
-
53536AV100的sample_vdec输出到CVBS显示
-
10海思板子mpp怎么在vi阶段改变视频数据尺寸
-
10HI3559AV100 多摄像头同步模式
-
9海思ss928单路摄像头vio中加入opencv处理并显示
-
10EB-RV1126-BC-191板子运行自己编码的程序
-
10求HI3519DV500_SDK_V2.0.1.1
-
5有偿求HI3516DV500 + OV5647驱动
举报反馈
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明
提醒
你的问题还没有最佳答案,是否结题,结题后将扣除20%的悬赏金
取消
确认
提醒
你的问题还没有最佳答案,是否结题,结题后将根据回答情况扣除相应悬赏金(1回答=1E币)
取消
确认