2 * /dev/lcd driver for Apple Network Servers.
5 #include <linux/types.h>
6 #include <linux/smp_lock.h>
7 #include <linux/errno.h>
8 #include <linux/kernel.h>
9 #include <linux/miscdevice.h>
10 #include <linux/fcntl.h>
11 #include <linux/init.h>
12 #include <linux/delay.h>
15 #include <asm/uaccess.h>
16 #include <asm/sections.h>
22 #define ANSLCD_ADDR 0xf301c000
23 #define ANSLCD_CTRL_IX 0x00
24 #define ANSLCD_DATA_IX 0x10
26 static unsigned long anslcd_short_delay = 80;
27 static unsigned long anslcd_long_delay = 3280;
28 static volatile unsigned char __iomem *anslcd_ptr;
33 anslcd_write_byte_ctrl ( unsigned char c )
36 printk(KERN_DEBUG "LCD: CTRL byte: %02x\n",c);
38 out_8(anslcd_ptr + ANSLCD_CTRL_IX, c);
43 udelay(anslcd_long_delay); break;
44 default: udelay(anslcd_short_delay);
49 anslcd_write_byte_data ( unsigned char c )
51 out_8(anslcd_ptr + ANSLCD_DATA_IX, c);
52 udelay(anslcd_short_delay);
56 anslcd_write( struct file * file, const char __user * buf,
57 size_t count, loff_t *ppos )
59 const char __user *p = buf;
63 printk(KERN_DEBUG "LCD: write\n");
66 if (!access_ok(VERIFY_READ, buf, count))
68 for ( i = *ppos; count > 0; ++i, ++p, --count )
72 anslcd_write_byte_data( c );
79 anslcd_ioctl( struct inode * inode, struct file * file,
80 unsigned int cmd, unsigned long arg )
82 char ch, __user *temp;
85 printk(KERN_DEBUG "LCD: ioctl(%d,%d)\n",cmd,arg);
91 anslcd_write_byte_ctrl ( 0x38 );
92 anslcd_write_byte_ctrl ( 0x0f );
93 anslcd_write_byte_ctrl ( 0x06 );
94 anslcd_write_byte_ctrl ( 0x01 );
95 anslcd_write_byte_ctrl ( 0x02 );
98 temp = (char __user *) arg;
100 for (; ch; temp++) { /* FIXME: This is ugly, but should work, as a \0 byte is not a valid command code */
101 anslcd_write_byte_ctrl ( ch );
102 __get_user(ch, temp);
105 case ANSLCD_SETSHORTDELAY:
106 if (!capable(CAP_SYS_ADMIN))
108 anslcd_short_delay=arg;
110 case ANSLCD_SETLONGDELAY:
111 if (!capable(CAP_SYS_ADMIN))
113 anslcd_long_delay=arg;
121 anslcd_open( struct inode * inode, struct file * file )
127 const struct file_operations anslcd_fops = {
128 .write = anslcd_write,
129 .ioctl = anslcd_ioctl,
133 static struct miscdevice anslcd_dev = {
139 const char anslcd_logo[] = "********************" /* Line #1 */
140 "* LINUX! *" /* Line #3 */
141 "* Welcome to *" /* Line #2 */
142 "********************"; /* Line #4 */
149 struct device_node* node;
151 node = of_find_node_by_name(NULL, "lcd");
152 if (!node || !node->parent || strcmp(node->parent->name, "gc")) {
158 anslcd_ptr = ioremap(ANSLCD_ADDR, 0x20);
160 retval = misc_register(&anslcd_dev);
162 printk(KERN_INFO "LCD: misc_register failed\n");
168 printk(KERN_DEBUG "LCD: init\n");
171 anslcd_write_byte_ctrl ( 0x38 );
172 anslcd_write_byte_ctrl ( 0x0c );
173 anslcd_write_byte_ctrl ( 0x06 );
174 anslcd_write_byte_ctrl ( 0x01 );
175 anslcd_write_byte_ctrl ( 0x02 );
177 anslcd_write_byte_data(anslcd_logo[a]);
185 misc_deregister(&anslcd_dev);
189 module_init(anslcd_init);
190 module_exit(anslcd_exit);