ia64/linux-2.6.18-xen.hg

annotate drivers/macintosh/ans-lcd.c @ 893:f994bfe9b93b

linux/blktap2: reduce TLB flush scope

c/s 885 added very coarse TLB flushing. Since these flushes always
follow single page updates, single page flushes (when available) are
sufficient.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jun 04 10:32:57 2009 +0100 (2009-06-04)
parents 831230e53067
children
rev   line source
ian@0 1 /*
ian@0 2 * /dev/lcd driver for Apple Network Servers.
ian@0 3 */
ian@0 4
ian@0 5 #include <linux/types.h>
ian@0 6 #include <linux/errno.h>
ian@0 7 #include <linux/kernel.h>
ian@0 8 #include <linux/miscdevice.h>
ian@0 9 #include <linux/fcntl.h>
ian@0 10 #include <linux/init.h>
ian@0 11 #include <linux/delay.h>
ian@0 12 #include <linux/fs.h>
ian@0 13
ian@0 14 #include <asm/uaccess.h>
ian@0 15 #include <asm/sections.h>
ian@0 16 #include <asm/prom.h>
ian@0 17 #include <asm/ans-lcd.h>
ian@0 18 #include <asm/io.h>
ian@0 19
ian@0 20 #define ANSLCD_ADDR 0xf301c000
ian@0 21 #define ANSLCD_CTRL_IX 0x00
ian@0 22 #define ANSLCD_DATA_IX 0x10
ian@0 23
ian@0 24 static unsigned long anslcd_short_delay = 80;
ian@0 25 static unsigned long anslcd_long_delay = 3280;
ian@0 26 static volatile unsigned char __iomem *anslcd_ptr;
ian@0 27
ian@0 28 #undef DEBUG
ian@0 29
ian@0 30 static void
ian@0 31 anslcd_write_byte_ctrl ( unsigned char c )
ian@0 32 {
ian@0 33 #ifdef DEBUG
ian@0 34 printk(KERN_DEBUG "LCD: CTRL byte: %02x\n",c);
ian@0 35 #endif
ian@0 36 out_8(anslcd_ptr + ANSLCD_CTRL_IX, c);
ian@0 37 switch(c) {
ian@0 38 case 1:
ian@0 39 case 2:
ian@0 40 case 3:
ian@0 41 udelay(anslcd_long_delay); break;
ian@0 42 default: udelay(anslcd_short_delay);
ian@0 43 }
ian@0 44 }
ian@0 45
ian@0 46 static void
ian@0 47 anslcd_write_byte_data ( unsigned char c )
ian@0 48 {
ian@0 49 out_8(anslcd_ptr + ANSLCD_DATA_IX, c);
ian@0 50 udelay(anslcd_short_delay);
ian@0 51 }
ian@0 52
ian@0 53 static ssize_t
ian@0 54 anslcd_write( struct file * file, const char __user * buf,
ian@0 55 size_t count, loff_t *ppos )
ian@0 56 {
ian@0 57 const char __user *p = buf;
ian@0 58 int i;
ian@0 59
ian@0 60 #ifdef DEBUG
ian@0 61 printk(KERN_DEBUG "LCD: write\n");
ian@0 62 #endif
ian@0 63
ian@0 64 if (!access_ok(VERIFY_READ, buf, count))
ian@0 65 return -EFAULT;
ian@0 66 for ( i = *ppos; count > 0; ++i, ++p, --count )
ian@0 67 {
ian@0 68 char c;
ian@0 69 __get_user(c, p);
ian@0 70 anslcd_write_byte_data( c );
ian@0 71 }
ian@0 72 *ppos = i;
ian@0 73 return p - buf;
ian@0 74 }
ian@0 75
ian@0 76 static int
ian@0 77 anslcd_ioctl( struct inode * inode, struct file * file,
ian@0 78 unsigned int cmd, unsigned long arg )
ian@0 79 {
ian@0 80 char ch, __user *temp;
ian@0 81
ian@0 82 #ifdef DEBUG
ian@0 83 printk(KERN_DEBUG "LCD: ioctl(%d,%d)\n",cmd,arg);
ian@0 84 #endif
ian@0 85
ian@0 86 switch ( cmd )
ian@0 87 {
ian@0 88 case ANSLCD_CLEAR:
ian@0 89 anslcd_write_byte_ctrl ( 0x38 );
ian@0 90 anslcd_write_byte_ctrl ( 0x0f );
ian@0 91 anslcd_write_byte_ctrl ( 0x06 );
ian@0 92 anslcd_write_byte_ctrl ( 0x01 );
ian@0 93 anslcd_write_byte_ctrl ( 0x02 );
ian@0 94 return 0;
ian@0 95 case ANSLCD_SENDCTRL:
ian@0 96 temp = (char __user *) arg;
ian@0 97 __get_user(ch, temp);
ian@0 98 for (; ch; temp++) { /* FIXME: This is ugly, but should work, as a \0 byte is not a valid command code */
ian@0 99 anslcd_write_byte_ctrl ( ch );
ian@0 100 __get_user(ch, temp);
ian@0 101 }
ian@0 102 return 0;
ian@0 103 case ANSLCD_SETSHORTDELAY:
ian@0 104 if (!capable(CAP_SYS_ADMIN))
ian@0 105 return -EACCES;
ian@0 106 anslcd_short_delay=arg;
ian@0 107 return 0;
ian@0 108 case ANSLCD_SETLONGDELAY:
ian@0 109 if (!capable(CAP_SYS_ADMIN))
ian@0 110 return -EACCES;
ian@0 111 anslcd_long_delay=arg;
ian@0 112 return 0;
ian@0 113 default:
ian@0 114 return -EINVAL;
ian@0 115 }
ian@0 116 }
ian@0 117
ian@0 118 static int
ian@0 119 anslcd_open( struct inode * inode, struct file * file )
ian@0 120 {
ian@0 121 return 0;
ian@0 122 }
ian@0 123
ian@0 124 struct file_operations anslcd_fops = {
ian@0 125 .write = anslcd_write,
ian@0 126 .ioctl = anslcd_ioctl,
ian@0 127 .open = anslcd_open,
ian@0 128 };
ian@0 129
ian@0 130 static struct miscdevice anslcd_dev = {
ian@0 131 ANSLCD_MINOR,
ian@0 132 "anslcd",
ian@0 133 &anslcd_fops
ian@0 134 };
ian@0 135
ian@0 136 const char anslcd_logo[] = "********************" /* Line #1 */
ian@0 137 "* LINUX! *" /* Line #3 */
ian@0 138 "* Welcome to *" /* Line #2 */
ian@0 139 "********************"; /* Line #4 */
ian@0 140
ian@0 141 static int __init
ian@0 142 anslcd_init(void)
ian@0 143 {
ian@0 144 int a;
ian@0 145 int retval;
ian@0 146 struct device_node* node;
ian@0 147
ian@0 148 node = find_devices("lcd");
ian@0 149 if (!node || !node->parent)
ian@0 150 return -ENODEV;
ian@0 151 if (strcmp(node->parent->name, "gc"))
ian@0 152 return -ENODEV;
ian@0 153
ian@0 154 anslcd_ptr = ioremap(ANSLCD_ADDR, 0x20);
ian@0 155
ian@0 156 retval = misc_register(&anslcd_dev);
ian@0 157 if(retval < 0){
ian@0 158 printk(KERN_INFO "LCD: misc_register failed\n");
ian@0 159 iounmap(anslcd_ptr);
ian@0 160 return retval;
ian@0 161 }
ian@0 162
ian@0 163 #ifdef DEBUG
ian@0 164 printk(KERN_DEBUG "LCD: init\n");
ian@0 165 #endif
ian@0 166
ian@0 167 anslcd_write_byte_ctrl ( 0x38 );
ian@0 168 anslcd_write_byte_ctrl ( 0x0c );
ian@0 169 anslcd_write_byte_ctrl ( 0x06 );
ian@0 170 anslcd_write_byte_ctrl ( 0x01 );
ian@0 171 anslcd_write_byte_ctrl ( 0x02 );
ian@0 172 for(a=0;a<80;a++) {
ian@0 173 anslcd_write_byte_data(anslcd_logo[a]);
ian@0 174 }
ian@0 175 return 0;
ian@0 176 }
ian@0 177
ian@0 178 static void __exit
ian@0 179 anslcd_exit(void)
ian@0 180 {
ian@0 181 misc_deregister(&anslcd_dev);
ian@0 182 iounmap(anslcd_ptr);
ian@0 183 }
ian@0 184
ian@0 185 module_init(anslcd_init);
ian@0 186 module_exit(anslcd_exit);