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/tty.h>
12 #include <linux/timer.h>
13 #include <linux/kernel.h>
14 #include <linux/wait.h>
15 #include <linux/string.h>
16 #include <linux/ioport.h>
17 #include <linux/delay.h>
18 #include <linux/miscdevice.h>
21 #include <linux/init.h>
23 #include <asm/uaccess.h>
27 #define BRIQ_PANEL_MINOR 156
28 #define BRIQ_PANEL_VFD_IOPORT 0x0390
29 #define BRIQ_PANEL_LED_IOPORT 0x0398
30 #define BRIQ_PANEL_VER "1.1 (04/20/2002)"
31 #define BRIQ_PANEL_MSG0 "Loading Linux"
33 static int vfd_is_open
;
34 static unsigned char vfd
[40];
35 static int vfd_cursor
;
36 static unsigned char ledpb
, led
;
38 static void update_vfd(void)
43 outb(0x02, BRIQ_PANEL_VFD_IOPORT
);
45 outb(vfd
[i
], BRIQ_PANEL_VFD_IOPORT
+ 1);
47 /* cursor to next line */
48 outb(0xc0, BRIQ_PANEL_VFD_IOPORT
);
50 outb(vfd
[i
], BRIQ_PANEL_VFD_IOPORT
+ 1);
54 static void set_led(char state
)
58 else if (state
== 'G')
60 else if (state
== 'Y')
62 else if (state
== 'X')
64 outb(led
, BRIQ_PANEL_LED_IOPORT
);
67 static int briq_panel_open(struct inode
*ino
, struct file
*filep
)
70 /* enforce single access, vfd_is_open is protected by BKL */
81 static int briq_panel_release(struct inode
*ino
, struct file
*filep
)
91 static ssize_t
briq_panel_read(struct file
*file
, char __user
*buf
, size_t count
,
100 c
= (inb(BRIQ_PANEL_LED_IOPORT
) & 0x000c) | (ledpb
& 0x0003);
102 /* upper button released */
103 if ((!(ledpb
& 0x0004)) && (c
& 0x0004)) {
106 if (copy_to_user(buf
, &cp
, 1))
110 /* lower button released */
111 else if ((!(ledpb
& 0x0008)) && (c
& 0x0008)) {
114 if (copy_to_user(buf
, &cp
, 1))
123 static void scroll_vfd( void )
127 for (i
=0; i
<20; i
++) {
134 static ssize_t
briq_panel_write(struct file
*file
, const char __user
*buf
, size_t len
,
147 if (get_user(c
, buf
))
152 } else if (c
== 27) {
154 } else if (c
== 12) {
159 } else if (c
== 10) {
162 else if (vfd_cursor
< 40)
164 else if (vfd_cursor
< 60)
169 /* just a character */
172 vfd
[vfd_cursor
++] = c
;
182 static const struct file_operations briq_panel_fops
= {
183 .owner
= THIS_MODULE
,
184 .read
= briq_panel_read
,
185 .write
= briq_panel_write
,
186 .open
= briq_panel_open
,
187 .release
= briq_panel_release
,
188 .llseek
= noop_llseek
,
191 static struct miscdevice briq_panel_miscdev
= {
197 static int __init
briq_panel_init(void)
199 struct device_node
*root
= of_find_node_by_path("/");
203 machine
= of_get_property(root
, "model", NULL
);
204 if (!machine
|| strncmp(machine
, "TotalImpact,BRIQ-1", 18) != 0) {
211 "briq_panel: v%s Dr. Karsten Jeppesen (kj@totalimpact.com)\n",
214 if (!request_region(BRIQ_PANEL_VFD_IOPORT
, 4, "BRIQ Front Panel"))
217 if (!request_region(BRIQ_PANEL_LED_IOPORT
, 2, "BRIQ Front Panel")) {
218 release_region(BRIQ_PANEL_VFD_IOPORT
, 4);
221 ledpb
= inb(BRIQ_PANEL_LED_IOPORT
) & 0x000c;
223 if (misc_register(&briq_panel_miscdev
) < 0) {
224 release_region(BRIQ_PANEL_VFD_IOPORT
, 4);
225 release_region(BRIQ_PANEL_LED_IOPORT
, 2);
229 outb(0x38, BRIQ_PANEL_VFD_IOPORT
); /* Function set */
230 outb(0x01, BRIQ_PANEL_VFD_IOPORT
); /* Clear display */
231 outb(0x0c, BRIQ_PANEL_VFD_IOPORT
); /* Display on */
232 outb(0x06, BRIQ_PANEL_VFD_IOPORT
); /* Entry normal */
254 static void __exit
briq_panel_exit(void)
256 misc_deregister(&briq_panel_miscdev
);
257 release_region(BRIQ_PANEL_VFD_IOPORT
, 4);
258 release_region(BRIQ_PANEL_LED_IOPORT
, 2);
261 module_init(briq_panel_init
);
262 module_exit(briq_panel_exit
);
264 MODULE_LICENSE("GPL");
265 MODULE_AUTHOR("Karsten Jeppesen <karsten@jeppesens.com>");
266 MODULE_DESCRIPTION("Driver for the Total Impact briQ front panel");