1 diff -urN linux-2.6.16.7/arch/mips/au1000/mtx-1/irqmap.c linux-2.6.16.7.new/arch/mips/au1000/mtx-1/irqmap.c
2 --- linux-2.6.16.7/arch/mips/au1000/mtx-1/irqmap.c 2006-04-17 23:53:25.000000000 +0200
3 +++ linux-2.6.16.7.new/arch/mips/au1000/mtx-1/irqmap.c 2006-04-23 11:54:31.000000000 +0200
5 { AU1500_GPIO_202, INTC_INT_LOW_LEVEL, 0 },
6 { AU1500_GPIO_203, INTC_INT_LOW_LEVEL, 0 },
7 { AU1500_GPIO_205, INTC_INT_LOW_LEVEL, 0 },
8 + { AU1500_GPIO_207, INTC_INT_RISE_AND_FALL_EDGE, 0 },
11 int au1xxx_nr_irqs = sizeof(au1xxx_irq_map)/sizeof(au1xxx_irq_map_t);
12 diff -urN linux-2.6.16.7/arch/mips/au1000/mtx-1/Makefile linux-2.6.16.7.new/arch/mips/au1000/mtx-1/Makefile
13 --- linux-2.6.16.7/arch/mips/au1000/mtx-1/Makefile 2006-04-17 23:53:25.000000000 +0200
14 +++ linux-2.6.16.7.new/arch/mips/au1000/mtx-1/Makefile 2006-04-23 14:01:36.000000000 +0200
18 lib-y := init.o board_setup.o irqmap.o
19 +obj-y := mtx-1_sysbtn.o platform.o
20 diff -urN linux-2.6.16.7/arch/mips/au1000/mtx-1/mtx-1_sysbtn.c linux-2.6.16.7.new/arch/mips/au1000/mtx-1/mtx-1_sysbtn.c
21 --- linux-2.6.16.7/arch/mips/au1000/mtx-1/mtx-1_sysbtn.c 1970-01-01 01:00:00.000000000 +0100
22 +++ linux-2.6.16.7.new/arch/mips/au1000/mtx-1/mtx-1_sysbtn.c 2006-04-23 14:01:17.000000000 +0200
25 + * Driver for the MTX-1 System Button.
27 + * (c) Copyright 2005 4G Systems <info@4g-systems.biz>, All Rights Reserved.
28 + * http://www.4g-systems.biz
30 + * This program is free software; you can redistribute it and/or
31 + * modify it under the terms of the GNU General Public License
32 + * as published by the Free Software Foundation; either version
33 + * 2 of the License, or (at your option) any later version.
35 + * Neither Michael Stickel nor 4G Systeme GmbH admit liability nor provide
36 + * warranty for any of this software. This material is provided
37 + * "AS-IS" and at no charge.
39 + * (c) Copyright 2005 4G Systems <info@4g-systems.biz>
43 + * Author: Michael Stickel michael.stickel@4g-systems.biz
46 + * After the module is loaded there is a device /dev/misc/btn
47 + * that can be read. It returns one char '1' if the button
48 + * has been pressed an '0' if it has been released.
50 +#include <linux/autoconf.h>
51 +#include <linux/module.h>
52 +#include <linux/version.h>
53 +#include <linux/types.h>
54 +#include <linux/errno.h>
55 +#include <linux/kernel.h>
56 +#include <linux/poll.h>
57 +#include <linux/sched.h>
58 +#include <linux/miscdevice.h>
59 +#include <linux/slab.h>
60 +#include <linux/init.h>
61 +#include <linux/irq.h>
62 +#include <linux/interrupt.h>
64 +#include <asm/uaccess.h>
66 +#include <asm/mach-au1x00/au1000.h>
74 +# define TRUE (!FALSE)
78 +//---------[ declarations ]-----------------
81 +static DECLARE_WAIT_QUEUE_HEAD(mtx1btn_wait_queue);
82 +static char state_changed;
83 +static char last_value;
84 +static char is_inuse;
87 +//---------[ Hardware Functions ]-----------------
89 +// The MTX-1 Button is attached to GPIO207.
90 +#define MTX1_GPIO2_SYSBTN (7)
91 +#define MTX1_SYSBTN_IRQ (AU1500_GPIO_207)
94 +static char mtx1_getbtn (int btnno)
97 + return (au_readl(GPIO2_PINSTATE) & (1<<MTX1_GPIO2_SYSBTN)) ? 0 : 1;
102 +static void mtx1_initbuttons (void)
104 + au_writel (au_readl(GPIO2_DIR) & ~(1<<MTX1_GPIO2_SYSBTN), GPIO2_DIR);
108 +//---------[ Interrupt handling ]-----------------
111 +static void mtx1_btn_interrupt (int irq, void *private)
113 + char value = mtx1_getbtn(0);
114 + if (last_value != value)
116 + last_value = value;
118 + wake_up (&mtx1btn_wait_queue);
120 +// kill_fasync(&async_queue, SIGIO, POLL_OUT);
124 +static int mtx1_btn_startirq (void)
126 + if (!request_irq (MTX1_SYSBTN_IRQ, mtx1_btn_interrupt, 0 /* | SA_INTERRUPT */, "mtx1btn", (void *)&state_changed)) {
132 +static int mtx1_btn_stopirq (void)
134 + free_irq(MTX1_SYSBTN_IRQ, (void *)&state_changed);
140 +//---------[ File Functions ]-----------------
143 +static int mtx1sysbtn_minor = -1;
146 +static int mtx1sysbtn_open (struct inode *inode, struct file *file)
148 + if (MINOR(inode->i_rdev)!=mtx1sysbtn_minor) return -ENODEV;
149 + if (is_inuse) return -EBUSY;
151 + last_value = mtx1_getbtn(0);
157 +static int mtx1sysbtn_release (struct inode *inode, struct file *file) {
158 + if (MINOR(inode->i_rdev)==mtx1sysbtn_minor) {
165 +static ssize_t mtx1sysbtn_read (struct file *file, char *buf, size_t count, loff_t *ppos)
169 + if (!state_changed)
170 + interruptible_sleep_on (&mtx1btn_wait_queue);
172 + char c = last_value ? '1' : '0'; /* mtx1_getbtn(0) */
173 + if(copy_to_user(buf, &c, 1))
179 +static unsigned int mtx1sysbtn_poll (struct file *file, poll_table * wait)
181 + unsigned int mask = 0;
183 + poll_wait (file, &mtx1btn_wait_queue, wait);
185 + if (state_changed) // state changed since last time.
186 + mask |= POLLIN | POLLRDNORM;
192 +static struct file_operations mtx1sysbtn_fops = {
193 + .owner = THIS_MODULE,
194 + .read = mtx1sysbtn_read,
195 + .poll = mtx1sysbtn_poll,
196 + .open = mtx1sysbtn_open,
197 + .release = mtx1sysbtn_release
201 +static struct miscdevice mtx1sysbtn_miscdev = {
202 + MISC_DYNAMIC_MINOR /* SYSBTN_MINOR */ ,
209 +//---------[ Module Functions ]-----------------
212 +void __exit exit_mtx1_sysbtn (void)
215 + mtx1_btn_stopirq ();
216 + misc_deregister(&mtx1sysbtn_miscdev);
220 +static int __init init_mtx1_sysbtn (void)
222 + printk("MTX-1 System Button driver\n");
224 + mtx1_initbuttons ();
225 + if (misc_register (&mtx1sysbtn_miscdev) >= 0) {
226 + mtx1sysbtn_minor = mtx1sysbtn_miscdev.minor;
227 + if (mtx1_btn_startirq () == 0) {
231 + misc_deregister(&mtx1sysbtn_miscdev);
236 +module_init(init_mtx1_sysbtn);
237 +module_exit(exit_mtx1_sysbtn);
239 +MODULE_AUTHOR("Michael Stickel");
240 +MODULE_DESCRIPTION("Driver for the MTX-1 system button");
241 +MODULE_LICENSE("GPL");