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>
12 #include <asm/uaccess.h>
13 #include <asm/sections.h>
15 #include <asm/ans-lcd.h>
18 #define ANSLCD_ADDR 0xf301c000
19 #define ANSLCD_CTRL_IX 0x00
20 #define ANSLCD_DATA_IX 0x10
22 static unsigned long anslcd_short_delay = 80;
23 static unsigned long anslcd_long_delay = 3280;
24 static volatile unsigned char* anslcd_ptr;
29 anslcd_write_byte_ctrl ( unsigned char c )
32 printk(KERN_DEBUG "LCD: CTRL byte: %02x\n",c);
34 out_8(anslcd_ptr + ANSLCD_CTRL_IX, c);
39 udelay(anslcd_long_delay); break;
40 default: udelay(anslcd_short_delay);
45 anslcd_write_byte_data ( unsigned char c )
47 out_8(anslcd_ptr + ANSLCD_DATA_IX, c);
48 udelay(anslcd_short_delay);
52 anslcd_write( struct file * file, const char * buf,
53 size_t count, loff_t *ppos )
58 printk(KERN_DEBUG "LCD: write\n");
61 if ( verify_area(VERIFY_READ, buf, count) )
65 if (__get_user(c, p++))
67 anslcd_write_byte_data( c );
74 anslcd_ioctl( struct inode * inode, struct file * file,
75 unsigned int cmd, unsigned long arg )
80 printk(KERN_DEBUG "LCD: ioctl(%d,%d)\n",cmd,arg);
86 anslcd_write_byte_ctrl ( 0x38 );
87 anslcd_write_byte_ctrl ( 0x0f );
88 anslcd_write_byte_ctrl ( 0x06 );
89 anslcd_write_byte_ctrl ( 0x01 );
90 anslcd_write_byte_ctrl ( 0x02 );
95 for (; ch; temp++) { /* FIXME: This is ugly, but should work, as a \0 byte is not a valid command code */
96 anslcd_write_byte_ctrl ( ch );
100 case ANSLCD_SETSHORTDELAY:
101 if (!capable(CAP_SYS_ADMIN))
103 anslcd_short_delay=arg;
105 case ANSLCD_SETLONGDELAY:
106 if (!capable(CAP_SYS_ADMIN))
108 anslcd_long_delay=arg;
116 anslcd_open( struct inode * inode, struct file * file )
121 struct file_operations anslcd_fops = {
127 static struct miscdevice anslcd_dev = {
133 const char anslcd_logo[] = "********************" /* Line #1 */
134 "* LINUX! *" /* Line #3 */
135 "* Welcome to *" /* Line #2 */
136 "********************"; /* Line #4 */
142 struct device_node* node;
144 node = find_devices("lcd");
145 if (!node || !node->parent)
147 if (strcmp(node->parent->name, "gc"))
150 anslcd_ptr = (volatile unsigned char*)ioremap(ANSLCD_ADDR, 0x20);
152 misc_register(&anslcd_dev);
155 printk(KERN_DEBUG "LCD: init\n");
158 anslcd_write_byte_ctrl ( 0x38 );
159 anslcd_write_byte_ctrl ( 0x0c );
160 anslcd_write_byte_ctrl ( 0x06 );
161 anslcd_write_byte_ctrl ( 0x01 );
162 anslcd_write_byte_ctrl ( 0x02 );
164 anslcd_write_byte_data(anslcd_logo[a]);
169 __initcall(anslcd_init);