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/config.h>
15 #include <linux/kernel.h>
16 #include <linux/wait.h>
17 #include <linux/string.h>
18 #include <linux/slab.h>
19 #include <linux/ioport.h>
20 #include <linux/delay.h>
21 #include <linux/miscdevice.h>
24 #include <linux/init.h>
26 #include <asm/uaccess.h>
30 #define BRIQ_PANEL_MINOR 156
31 #define BRIQ_PANEL_VFD_IOPORT 0x0390
32 #define BRIQ_PANEL_LED_IOPORT 0x0398
33 #define BRIQ_PANEL_VER "1.1 (04/20/2002)"
34 #define BRIQ_PANEL_MSG0 "Loading Linux"
36 static int vfd_is_open
;
37 static unsigned char vfd
[40];
38 static int vfd_cursor
;
39 static unsigned char ledpb
, led
;
41 static void update_vfd(void)
46 outb(0x02, BRIQ_PANEL_VFD_IOPORT
);
48 outb(vfd
[i
], BRIQ_PANEL_VFD_IOPORT
+ 1);
50 /* cursor to next line */
51 outb(0xc0, BRIQ_PANEL_VFD_IOPORT
);
53 outb(vfd
[i
], BRIQ_PANEL_VFD_IOPORT
+ 1);
57 static void set_led(char state
)
61 else if (state
== 'G')
63 else if (state
== 'Y')
65 else if (state
== 'X')
67 outb(led
, BRIQ_PANEL_LED_IOPORT
);
70 static int briq_panel_open(struct inode
*ino
, struct file
*filep
)
72 /* enforce single access */
80 static int briq_panel_release(struct inode
*ino
, struct file
*filep
)
90 static ssize_t
briq_panel_read(struct file
*file
, char *buf
, size_t count
,
96 #if 0 /* Can't seek (pread) on this device */
97 if (ppos
!= &file
->f_pos
)
104 c
= (inb(BRIQ_PANEL_LED_IOPORT
) & 0x000c) | (ledpb
& 0x0003);
106 /* upper button released */
107 if ((!(ledpb
& 0x0004)) && (c
& 0x0004)) {
110 if (copy_to_user(buf
, &cp
, 1))
114 /* lower button released */
115 else if ((!(ledpb
& 0x0008)) && (c
& 0x0008)) {
118 if (copy_to_user(buf
, &cp
, 1))
127 static void scroll_vfd( void )
131 for (i
=0; i
<20; i
++) {
138 static ssize_t
briq_panel_write(struct file
*file
, const char *buf
, size_t len
,
144 #if 0 /* Can't seek (pwrite) on this device */
145 if (ppos
!= &file
->f_pos
)
158 } else if (*buf
== 27) {
160 } else if (*buf
== 12) {
165 } else if (*buf
== 10) {
168 else if (vfd_cursor
< 40)
170 else if (vfd_cursor
< 60)
175 /* just a character */
178 vfd
[vfd_cursor
++] = *buf
;
188 static struct file_operations briq_panel_fops
= {
189 .owner
= THIS_MODULE
,
190 .read
= briq_panel_read
,
191 .write
= briq_panel_write
,
192 .open
= briq_panel_open
,
193 .release
= briq_panel_release
,
196 static struct miscdevice briq_panel_miscdev
= {
202 static int __init
briq_panel_init(void)
204 struct device_node
*root
= find_path_device("/");
208 machine
= get_property(root
, "model", NULL
);
209 if (!machine
|| strncmp(machine
, "TotalImpact,BRIQ-1", 18) != 0)
213 "briq_panel: v%s Dr. Karsten Jeppesen (kj@totalimpact.com)\n",
216 if (!request_region(BRIQ_PANEL_VFD_IOPORT
, 4, "BRIQ Front Panel"))
219 if (!request_region(BRIQ_PANEL_LED_IOPORT
, 2, "BRIQ Front Panel")) {
220 release_region(BRIQ_PANEL_VFD_IOPORT
, 4);
223 ledpb
= inb(BRIQ_PANEL_LED_IOPORT
) & 0x000c;
225 if (misc_register(&briq_panel_miscdev
) < 0) {
226 release_region(BRIQ_PANEL_VFD_IOPORT
, 4);
227 release_region(BRIQ_PANEL_LED_IOPORT
, 2);
231 outb(0x38, BRIQ_PANEL_VFD_IOPORT
); /* Function set */
232 outb(0x01, BRIQ_PANEL_VFD_IOPORT
); /* Clear display */
233 outb(0x0c, BRIQ_PANEL_VFD_IOPORT
); /* Display on */
234 outb(0x06, BRIQ_PANEL_VFD_IOPORT
); /* Entry normal */
256 static void __exit
briq_panel_exit(void)
258 misc_deregister(&briq_panel_miscdev
);
259 release_region(BRIQ_PANEL_VFD_IOPORT
, 4);
260 release_region(BRIQ_PANEL_LED_IOPORT
, 2);
263 module_init(briq_panel_init
);
264 module_exit(briq_panel_exit
);
266 MODULE_LICENSE("GPL");
267 MODULE_AUTHOR("Karsten Jeppesen <karsten@jeppesens.com>");
268 MODULE_DESCRIPTION("Driver for the Total Impact briQ front panel");