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>
17 #include <asm/ans-lcd.h>
20 #define ANSLCD_ADDR 0xf301c000
21 #define ANSLCD_CTRL_IX 0x00
22 #define ANSLCD_DATA_IX 0x10
24 static unsigned long anslcd_short_delay
= 80;
25 static unsigned long anslcd_long_delay
= 3280;
26 static volatile unsigned char __iomem
*anslcd_ptr
;
31 anslcd_write_byte_ctrl ( unsigned char c
)
34 printk(KERN_DEBUG
"LCD: CTRL byte: %02x\n",c
);
36 out_8(anslcd_ptr
+ ANSLCD_CTRL_IX
, c
);
41 udelay(anslcd_long_delay
); break;
42 default: udelay(anslcd_short_delay
);
47 anslcd_write_byte_data ( unsigned char c
)
49 out_8(anslcd_ptr
+ ANSLCD_DATA_IX
, c
);
50 udelay(anslcd_short_delay
);
54 anslcd_write( struct file
* file
, const char __user
* buf
,
55 size_t count
, loff_t
*ppos
)
57 const char __user
*p
= buf
;
61 printk(KERN_DEBUG
"LCD: write\n");
64 if (!access_ok(VERIFY_READ
, buf
, count
))
66 for ( i
= *ppos
; count
> 0; ++i
, ++p
, --count
)
70 anslcd_write_byte_data( c
);
77 anslcd_ioctl( struct inode
* inode
, struct file
* file
,
78 unsigned int cmd
, unsigned long arg
)
80 char ch
, __user
*temp
;
83 printk(KERN_DEBUG
"LCD: ioctl(%d,%d)\n",cmd
,arg
);
89 anslcd_write_byte_ctrl ( 0x38 );
90 anslcd_write_byte_ctrl ( 0x0f );
91 anslcd_write_byte_ctrl ( 0x06 );
92 anslcd_write_byte_ctrl ( 0x01 );
93 anslcd_write_byte_ctrl ( 0x02 );
96 temp
= (char __user
*) arg
;
98 for (; ch
; temp
++) { /* FIXME: This is ugly, but should work, as a \0 byte is not a valid command code */
99 anslcd_write_byte_ctrl ( ch
);
100 __get_user(ch
, temp
);
103 case ANSLCD_SETSHORTDELAY
:
104 if (!capable(CAP_SYS_ADMIN
))
106 anslcd_short_delay
=arg
;
108 case ANSLCD_SETLONGDELAY
:
109 if (!capable(CAP_SYS_ADMIN
))
111 anslcd_long_delay
=arg
;
119 anslcd_open( struct inode
* inode
, struct file
* file
)
124 struct file_operations anslcd_fops
= {
125 .write
= anslcd_write
,
126 .ioctl
= anslcd_ioctl
,
130 static struct miscdevice anslcd_dev
= {
136 const char anslcd_logo
[] = "********************" /* Line #1 */
137 "* LINUX! *" /* Line #3 */
138 "* Welcome to *" /* Line #2 */
139 "********************"; /* Line #4 */
146 struct device_node
* node
;
148 node
= find_devices("lcd");
149 if (!node
|| !node
->parent
)
151 if (strcmp(node
->parent
->name
, "gc"))
154 anslcd_ptr
= ioremap(ANSLCD_ADDR
, 0x20);
156 retval
= misc_register(&anslcd_dev
);
158 printk(KERN_INFO
"LCD: misc_register failed\n");
164 printk(KERN_DEBUG
"LCD: init\n");
167 anslcd_write_byte_ctrl ( 0x38 );
168 anslcd_write_byte_ctrl ( 0x0c );
169 anslcd_write_byte_ctrl ( 0x06 );
170 anslcd_write_byte_ctrl ( 0x01 );
171 anslcd_write_byte_ctrl ( 0x02 );
173 anslcd_write_byte_data(anslcd_logo
[a
]);
181 misc_deregister(&anslcd_dev
);
185 module_init(anslcd_init
);
186 module_exit(anslcd_exit
);