1 #include <linux/module.h>
2 #include <linux/errno.h>
3 #include <linux/cdev.h>
4 #include <linux/types.h>
5 #include <linux/errno.h>
6 #include <linux/miscdevice.h>
7 #include <linux/slab.h>
8 #include <linux/ioport.h>
9 #include <linux/fcntl.h>
10 #include <linux/mc146818rtc.h>
11 #include <linux/netdevice.h>
12 #include <linux/sched.h>
13 #include <linux/delay.h>
16 #include <asm/uaccess.h>
17 #include <asm/system.h>
18 #include <linux/delay.h>
24 #define LCD_Cursor_Left 5
25 #define LCD_Cursor_Right 6
26 #define LCD_Disp_Left 7
27 #define LCD_Disp_Right 8
28 #define LCD_Get_Cursor 9
29 #define LCD_Set_Cursor 10
33 #define LCD_Cursor_Off 14
34 #define LCD_Cursor_On 15
35 #define LCD_Get_Cursor_Pos 16
36 #define LCD_Set_Cursor_Pos 17
37 #define LCD_Blink_Off 18
39 #define kLCD_IR na_lcd_16207_0
40 #define kLCD_DR (na_lcd_16207_0 + 8)
42 #define LCDWriteData(x) outl(x , kLCD_DR)
43 #define LCDWriteInst(x) outl(x , kLCD_IR)
45 #define LCDReadData inl(kLCD_DR)
46 #define LCDReadInst inl(kLCD_IR)
51 static int Device_Open
= 0;
53 static int lcd_16207_ioctl(struct inode
*inode
,struct file
*filp
,
54 unsigned int cmd
,unsigned long arg
);
56 static int lcd_16207_open(struct inode
*inode
,struct file
*filp
)
58 static int counter
= 0;
59 if(Device_Open
)return -EBUSY
;
61 printk("You have open the device %d times\n",counter
++);
65 static int lcd_16207_release(struct inode
*inode
,struct file
*filp
)
68 printk("You have release the device\n");
72 static int lcd_16207_ioctl(struct inode
*inode
,struct file
*filp
,
73 unsigned int cmd
,unsigned long arg
)
75 volatile unsigned long display
;
80 (&display
, (unsigned long *) arg
,
84 LCDWriteInst(display
);
89 (&display
, (unsigned long *) arg
,
93 LCDWriteData(display
);
104 static struct file_operations lcd_16207_fops
={
105 .ioctl
= lcd_16207_ioctl
,
106 .open
= lcd_16207_open
,
107 .release
= lcd_16207_release
,
110 static int lcd_16207_init(void)
112 int ret
= register_chrdev(Major
,"LCD_PIO",&lcd_16207_fops
);
115 printk("Registering the device failed with %d\n",Major
);
118 printk("You have init Device %d\n",Major
);
122 static void lcd_16207_exit(void)
124 if(unregister_chrdev(Major
,"LCD_PIO"))
125 printk("exit failed");
128 module_init(lcd_16207_init
);
129 module_exit(lcd_16207_exit
);
131 MODULE_AUTHOR("Andrew Bose");
132 MODULE_LICENSE("GPL");