2  * Drivers for the Total Impact PPC based computer "BRIQ"
 
   3  * by Dr. Karsten Jeppesen
 
   7 #include <linux/module.h>
 
   9 #include <linux/types.h>
 
  10 #include <linux/errno.h>
 
  11 #include <linux/sched.h>
 
  12 #include <linux/tty.h>
 
  13 #include <linux/timer.h>
 
  14 #include <linux/kernel.h>
 
  15 #include <linux/wait.h>
 
  16 #include <linux/string.h>
 
  17 #include <linux/slab.h>
 
  18 #include <linux/ioport.h>
 
  19 #include <linux/delay.h>
 
  20 #include <linux/miscdevice.h>
 
  23 #include <linux/init.h>
 
  25 #include <asm/uaccess.h>
 
  29 #define         BRIQ_PANEL_MINOR        156
 
  30 #define         BRIQ_PANEL_VFD_IOPORT   0x0390
 
  31 #define         BRIQ_PANEL_LED_IOPORT   0x0398
 
  32 #define         BRIQ_PANEL_VER          "1.1 (04/20/2002)"
 
  33 #define         BRIQ_PANEL_MSG0         "Loading Linux"
 
  35 static int              vfd_is_open;
 
  36 static unsigned char    vfd[40];
 
  37 static int              vfd_cursor;
 
  38 static unsigned char    ledpb, led;
 
  40 static void update_vfd(void)
 
  45         outb(0x02, BRIQ_PANEL_VFD_IOPORT);
 
  47                 outb(vfd[i], BRIQ_PANEL_VFD_IOPORT + 1);
 
  49         /* cursor to next line */
 
  50         outb(0xc0, BRIQ_PANEL_VFD_IOPORT);
 
  52                 outb(vfd[i], BRIQ_PANEL_VFD_IOPORT + 1);
 
  56 static void set_led(char state)
 
  60         else if (state == 'G')
 
  62         else if (state == 'Y')
 
  64         else if (state == 'X')
 
  66         outb(led, BRIQ_PANEL_LED_IOPORT);
 
  69 static int briq_panel_open(struct inode *ino, struct file *filep)
 
  71         /* enforce single access */
 
  79 static int briq_panel_release(struct inode *ino, struct file *filep)
 
  89 static ssize_t briq_panel_read(struct file *file, char __user *buf, size_t count,
 
  95 #if 0   /*  Can't seek (pread) on this device  */
 
  96         if (ppos != &file->f_pos)
 
 103         c = (inb(BRIQ_PANEL_LED_IOPORT) & 0x000c) | (ledpb & 0x0003);
 
 105         /* upper button released */
 
 106         if ((!(ledpb & 0x0004)) && (c & 0x0004)) {
 
 109                 if (copy_to_user(buf, &cp, 1))
 
 113         /* lower button released */
 
 114         else if ((!(ledpb & 0x0008)) && (c & 0x0008)) {
 
 117                 if (copy_to_user(buf, &cp, 1))
 
 126 static void scroll_vfd( void )
 
 130         for (i=0; i<20; i++) {
 
 137 static ssize_t briq_panel_write(struct file *file, const char __user *buf, size_t len,
 
 143 #if 0   /*  Can't seek (pwrite) on this device  */
 
 144         if (ppos != &file->f_pos)
 
 155                 if (get_user(c, buf))
 
 160                 } else if (c == 27) {
 
 162                 } else if (c == 12) {
 
 167                 } else if (c == 10) {
 
 170                         else if (vfd_cursor < 40)
 
 172                         else if (vfd_cursor < 60)
 
 177                         /* just a character */
 
 180                         vfd[vfd_cursor++] = c;
 
 190 static struct file_operations briq_panel_fops = {
 
 191         .owner          = THIS_MODULE,
 
 192         .read           = briq_panel_read,
 
 193         .write          = briq_panel_write,
 
 194         .open           = briq_panel_open,
 
 195         .release        = briq_panel_release,
 
 198 static struct miscdevice briq_panel_miscdev = {
 
 204 static int __init briq_panel_init(void)
 
 206         struct device_node *root = find_path_device("/");
 
 210         machine = get_property(root, "model", NULL);
 
 211         if (!machine || strncmp(machine, "TotalImpact,BRIQ-1", 18) != 0)
 
 215                 "briq_panel: v%s Dr. Karsten Jeppesen (kj@totalimpact.com)\n",
 
 218         if (!request_region(BRIQ_PANEL_VFD_IOPORT, 4, "BRIQ Front Panel"))
 
 221         if (!request_region(BRIQ_PANEL_LED_IOPORT, 2, "BRIQ Front Panel")) {
 
 222                 release_region(BRIQ_PANEL_VFD_IOPORT, 4);
 
 225         ledpb = inb(BRIQ_PANEL_LED_IOPORT) & 0x000c;
 
 227         if (misc_register(&briq_panel_miscdev) < 0) {
 
 228                 release_region(BRIQ_PANEL_VFD_IOPORT, 4);
 
 229                 release_region(BRIQ_PANEL_LED_IOPORT, 2);
 
 233         outb(0x38, BRIQ_PANEL_VFD_IOPORT);      /* Function set */
 
 234         outb(0x01, BRIQ_PANEL_VFD_IOPORT);      /* Clear display */
 
 235         outb(0x0c, BRIQ_PANEL_VFD_IOPORT);      /* Display on */
 
 236         outb(0x06, BRIQ_PANEL_VFD_IOPORT);      /* Entry normal */
 
 258 static void __exit briq_panel_exit(void)
 
 260         misc_deregister(&briq_panel_miscdev);
 
 261         release_region(BRIQ_PANEL_VFD_IOPORT, 4);
 
 262         release_region(BRIQ_PANEL_LED_IOPORT, 2);
 
 265 module_init(briq_panel_init);
 
 266 module_exit(briq_panel_exit);
 
 268 MODULE_LICENSE("GPL");
 
 269 MODULE_AUTHOR("Karsten Jeppesen <karsten@jeppesens.com>");
 
 270 MODULE_DESCRIPTION("Driver for the Total Impact briQ front panel");