1 /* $Id: uctrl.c,v 1.2 1999/09/07 23:11:08 shadow Exp $
2 * uctrl.c: TS102 Microcontroller interface on Tadpole Sparcbook 3
4 * Copyright 1999 Derrick J Brashear (shadow@dementia.org)
7 #include <linux/config.h>
8 #include <linux/module.h>
9 #include <linux/sched.h>
10 #include <linux/errno.h>
11 #include <linux/delay.h>
12 #include <linux/interrupt.h>
13 #include <linux/malloc.h>
14 #include <linux/ioport.h>
15 #include <linux/init.h>
16 #include <linux/miscdevice.h>
19 #include <asm/openprom.h>
20 #include <asm/oplib.h>
21 #include <asm/system.h>
24 #include <asm/pgtable.h>
27 #define UCTRL_MINOR 174
34 static struct uctrl_driver drv
;
37 uctrl_llseek(struct file
*file
, loff_t offset
, int type
)
43 uctrl_ioctl(struct inode
*inode
, struct file
*file
,
44 unsigned int cmd
, unsigned long arg
)
54 uctrl_open(struct inode
*inode
, struct file
*file
)
61 uctrl_release(struct inode
*inode
, struct file
*file
)
67 void uctrl_interrupt(int irq
, void *dev_id
, struct pt_regs
*regs
)
69 struct uctrl_driver
*driver
= (struct uctrl_driver
*)dev_id
;
70 printk("in uctrl_interrupt\n");
73 static struct file_operations uctrl_fops
= {
86 static struct miscdevice uctrl_dev
= {
95 int __init
uctrl_init(void)
98 struct uctrl_driver
*driver
= &drv
;
100 struct linux_prom_irqs tmp_irq
[2];
101 unsigned int vaddr
[2] = { 0, 0 };
102 int tmpnode
, uctrlnode
= prom_getchild(prom_root_node
);
104 tmpnode
= prom_searchsiblings(uctrlnode
, "obio");
107 uctrlnode
= prom_getchild(tmpnode
);
109 uctrlnode
= prom_searchsiblings(uctrlnode
, "uctrl");
114 /* the prom mapped it for us */
115 len
= prom_getproperty(uctrlnode
, "address", (void *) vaddr
,
117 driver
->regs
= vaddr
[0];
119 len
= prom_getproperty(uctrlnode
, "intr", (char *) tmp_irq
,
122 driver
->irq
= tmp_irq
[0].pri
;
124 request_irq(driver
->irq
, uctrl_interrupt
, 0,
127 enable_irq(driver
->irq
);
129 if (misc_register(&uctrl_dev
)) {
130 printk("%s: unable to get misc minor %d\n",
131 __FUNCTION__
, uctrl_dev
.minor
);
132 disable_irq(driver
->irq
);
133 free_irq(driver
->irq
, driver
);
137 printk(KERN_INFO
, "uctrl: 0x%x (irq %d)\n", driver
->regs
, __irq_itoa(driver
->irq
));
143 void cleanup_module(void)
145 struct uctrl_driver
*driver
= &drv
;
147 misc_deregister(&uctrl_dev
);
149 disable_irq(driver
->irq
);
150 free_irq(driver
->irq
, driver
);