2 * /dev/lcd driver for Apple Network Servers.
5 #include <linux/types.h>
6 #include <linux/errno.h>
7 #include <linux/kernel.h>
8 #include <linux/miscdevice.h>
9 #include <linux/fcntl.h>
10 #include <linux/init.h>
11 #include <linux/delay.h>
14 #include <asm/uaccess.h>
15 #include <asm/sections.h>
21 #define ANSLCD_ADDR 0xf301c000
22 #define ANSLCD_CTRL_IX 0x00
23 #define ANSLCD_DATA_IX 0x10
25 static unsigned long anslcd_short_delay = 80;
26 static unsigned long anslcd_long_delay = 3280;
27 static volatile unsigned char __iomem *anslcd_ptr;
32 anslcd_write_byte_ctrl ( unsigned char c )
35 printk(KERN_DEBUG "LCD: CTRL byte: %02x\n",c);
37 out_8(anslcd_ptr + ANSLCD_CTRL_IX, c);
42 udelay(anslcd_long_delay); break;
43 default: udelay(anslcd_short_delay);
48 anslcd_write_byte_data ( unsigned char c )
50 out_8(anslcd_ptr + ANSLCD_DATA_IX, c);
51 udelay(anslcd_short_delay);
55 anslcd_write( struct file * file, const char __user * buf,
56 size_t count, loff_t *ppos )
58 const char __user *p = buf;
62 printk(KERN_DEBUG "LCD: write\n");
65 if (!access_ok(VERIFY_READ, buf, count))
67 for ( i = *ppos; count > 0; ++i, ++p, --count )
71 anslcd_write_byte_data( c );
78 anslcd_ioctl( struct inode * inode, struct file * file,
79 unsigned int cmd, unsigned long arg )
81 char ch, __user *temp;
84 printk(KERN_DEBUG "LCD: ioctl(%d,%d)\n",cmd,arg);
90 anslcd_write_byte_ctrl ( 0x38 );
91 anslcd_write_byte_ctrl ( 0x0f );
92 anslcd_write_byte_ctrl ( 0x06 );
93 anslcd_write_byte_ctrl ( 0x01 );
94 anslcd_write_byte_ctrl ( 0x02 );
97 temp = (char __user *) arg;
99 for (; ch; temp++) { /* FIXME: This is ugly, but should work, as a \0 byte is not a valid command code */
100 anslcd_write_byte_ctrl ( ch );
101 __get_user(ch, temp);
104 case ANSLCD_SETSHORTDELAY:
105 if (!capable(CAP_SYS_ADMIN))
107 anslcd_short_delay=arg;
109 case ANSLCD_SETLONGDELAY:
110 if (!capable(CAP_SYS_ADMIN))
112 anslcd_long_delay=arg;
120 anslcd_open( struct inode * inode, struct file * file )
125 const struct file_operations anslcd_fops = {
126 .write = anslcd_write,
127 .ioctl = anslcd_ioctl,
131 static struct miscdevice anslcd_dev = {
137 const char anslcd_logo[] = "********************" /* Line #1 */
138 "* LINUX! *" /* Line #3 */
139 "* Welcome to *" /* Line #2 */
140 "********************"; /* Line #4 */
147 struct device_node* node;
149 node = of_find_node_by_name(NULL, "lcd");
150 if (!node || !node->parent || strcmp(node->parent->name, "gc")) {
156 anslcd_ptr = ioremap(ANSLCD_ADDR, 0x20);
158 retval = misc_register(&anslcd_dev);
160 printk(KERN_INFO "LCD: misc_register failed\n");
166 printk(KERN_DEBUG "LCD: init\n");
169 anslcd_write_byte_ctrl ( 0x38 );
170 anslcd_write_byte_ctrl ( 0x0c );
171 anslcd_write_byte_ctrl ( 0x06 );
172 anslcd_write_byte_ctrl ( 0x01 );
173 anslcd_write_byte_ctrl ( 0x02 );
175 anslcd_write_byte_data(anslcd_logo[a]);
183 misc_deregister(&anslcd_dev);
187 module_init(anslcd_init);
188 module_exit(anslcd_exit);