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 )
59 printk(KERN_DEBUG "LCD: write\n");
62 if ( verify_area(VERIFY_READ, buf, count) )
64 for ( i = *ppos; count > 0; ++i, ++p, --count )
68 anslcd_write_byte_data( c );
75 anslcd_ioctl( struct inode * inode, struct file * file,
76 unsigned int cmd, unsigned long arg )
81 printk(KERN_DEBUG "LCD: ioctl(%d,%d)\n",cmd,arg);
87 anslcd_write_byte_ctrl ( 0x38 );
88 anslcd_write_byte_ctrl ( 0x0f );
89 anslcd_write_byte_ctrl ( 0x06 );
90 anslcd_write_byte_ctrl ( 0x01 );
91 anslcd_write_byte_ctrl ( 0x02 );
96 for (; ch; temp++) { /* FIXME: This is ugly, but should work, as a \0 byte is not a valid command code */
97 anslcd_write_byte_ctrl ( ch );
101 case ANSLCD_SETSHORTDELAY:
102 if (!capable(CAP_SYS_ADMIN))
104 anslcd_short_delay=arg;
106 case ANSLCD_SETLONGDELAY:
107 if (!capable(CAP_SYS_ADMIN))
109 anslcd_long_delay=arg;
117 anslcd_open( struct inode * inode, struct file * file )
122 struct file_operations anslcd_fops = {
123 .write = anslcd_write,
124 .ioctl = anslcd_ioctl,
128 static struct miscdevice anslcd_dev = {
134 const char anslcd_logo[] = "********************" /* Line #1 */
135 "* LINUX! *" /* Line #3 */
136 "* Welcome to *" /* Line #2 */
137 "********************"; /* Line #4 */
144 struct device_node* node;
146 node = find_devices("lcd");
147 if (!node || !node->parent)
149 if (strcmp(node->parent->name, "gc"))
152 anslcd_ptr = (volatile unsigned char*)ioremap(ANSLCD_ADDR, 0x20);
154 retval = misc_register(&anslcd_dev);
156 printk(KERN_INFO "LCD: misc_register failed\n");
162 printk(KERN_DEBUG "LCD: init\n");
165 anslcd_write_byte_ctrl ( 0x38 );
166 anslcd_write_byte_ctrl ( 0x0c );
167 anslcd_write_byte_ctrl ( 0x06 );
168 anslcd_write_byte_ctrl ( 0x01 );
169 anslcd_write_byte_ctrl ( 0x02 );
171 anslcd_write_byte_data(anslcd_logo[a]);
176 __initcall(anslcd_init);