文档详情

Linux菜鸟关于gpio驱动的问题.doc

发布:2017-12-16约4.69千字共6页下载文档
文本预览下载声明
Linux菜鸟关于gpio驱动的问题 请问各位大侠: ? ?? ?小弟我刚学Linux驱动开发,自己尝试着写了一个gpio驱动,功能就是简单控制GPIO的输出电平 ? ?? ?随内核一起编译后下载到目标板运行,打印显示驱动加载成功,但在[size=6][color=DarkOrange] /dev[/color][/size]下没有生成相应的设备节点 ? ?? ?不知道是什么原因,希望各位高人能指导一下,内核版本为 驱动源码如下: #include linux/module.h #include linux/init.h #include linux/slab.h #include linux/highmem.h #include linux/pagemap.h #include asm/arch/gpio.h #include asm/arch/at91_pio.h #include asm/arch/hardware.h #define GPIO_MAJOR 220 #undef DEBUG_GPIO /* */ /* * GPIO read . */ static ssize_t gpio_rd (struct file *file, char *buf, size_t count, loff_t *offset) { ? ? ? ? return count; } /* * GPIO Write . */ static ssize_t gpio_wr(struct file *file, char *buf, size_t count, loff_t *offset) { ? ? ? ? return count; } static int gpio_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) { ? ? ? ? int io_status; ? ? ? ? switch (cmd) ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ???? ? ? ? case 0: ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? *(long *)(AT91_PIOC+PIO_CODR)? ? ? ???|= (113); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? ? ? ? ? case 1: ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? *(long *)(AT91_PIOC+PIO_SODR) |= (113); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? break;? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? case 2: ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? io_status = *(long *)(AT91_PIOC+PIO_PDSR); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? ? ? ? ? default: ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? break; ? ? ? ? ? ? ? ? } ? ? ? ? return io_status; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? } /* * Open the GPIO device */ static int gpio_open(struct inode *inode, struct file *file) { ? ? ? ? //AT91_PMC |= 1AT91RM9200_ID_PIOC; ? ? ? ? *(long *)(AT91_PIOC+PIO_OER)|= (113); ? ? ? ? *(long *)(AT91_PIOC+PIO_PUDR) |= (113); ? ? ? ? return 0; } /* * Close the GPIO device */ static int gpio_close(struct inode *inode, struct file *file) { ? ? ? ? ? ? ? ? return 0; } /* */ static struct file_operations gpio_fops = { ? ? ? ? .owner? ? ? ? ? ? ? ? = THIS_MOD
显示全部
相似文档