- 论坛徽章:
- 0
|
本帖最后由 ywf851207 于 2011-01-11 20:25 编辑
- #define DEVICE_NAME "GPIO-Control"
- #define IOCTL_GPIO_ON 1
- #define IOCTL_GPIO_OFF 0
- static unsigned long gpio_table [] =
- {
- S3C2410_GPB5,
- S3C2410_GPB6,
- S3C2410_GPB7,
- S3C2410_GPB8,
- };
- static unsigned int gpio_cfg_table [] =
- {
- S3C2410_GPB5_OUTP,
- S3C2410_GPB6_OUTP,
- S3C2410_GPB7_OUTP,
- S3C2410_GPB8_OUTP,
- };
- static int tq2440_gpio_ioctl(
- struct inode *inode,
- struct file *file,
- unsigned int cmd,
- unsigned long arg)
- {
- if (arg > 4)
- {
- return -EINVAL;
- }
- switch(cmd)
- {
- case IOCTL_GPIO_ON:
- s3c2410_gpio_setpin(gpio_table[arg], 0);
- return 0;
- case IOCTL_GPIO_OFF:
- s3c2410_gpio_setpin(gpio_table[arg], 1);
- return 0;
- default:
- return -EINVAL;
- }
- }
- static struct file_operations dev_fops = {
- .owner = THIS_MODULE,
- .ioctl = tq2440_gpio_ioctl,
- };
- static struct miscdevice misc = {
- .minor = MISC_DYNAMIC_MINOR,
- .name = DEVICE_NAME,
- .fops = &dev_fops,
- };
- static int __init dev_init(void)
- {
- int ret;
- int i;
-
- for (i = 0; i < 4; i++)
- {
- s3c2410_gpio_cfgpin(gpio_table[i], gpio_cfg_table[i]);
- s3c2410_gpio_setpin(gpio_table[i], 0);
- }
- ret = misc_register(&misc);
- printk (DEVICE_NAME" initialized\n");
- return ret;
- }
- static void __exit dev_exit(void)
- {
- misc_deregister(&misc);
- }
- module_init(dev_init);
- module_exit(dev_exit);
- MODULE_LICENSE("GPL");
- MODULE_AUTHOR("www.embedsky.net");
- MODULE_DESCRIPTION("GPIO control for EmbedSky SKY2440/TQ2440 Board");
复制代码 我在这个LED驱动程序中怎么没有看到虚拟地址到物理地址的映射啊,我觉得应该有一个ioremap()才对啊,怎么没有呢?为了不耽误大家逛MM论坛的时间,先发张MM图。。。。
|
|