]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/input/lib/src/l4bus.c
update
[l4.git] / l4 / pkg / input / lib / src / l4bus.c
1 /*
2  * (c) 2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
3  *          Torsten Frenzel <frenzel@os.inf.tu-dresden.de>
4  *     economic rights: Technische Universität Dresden (Germany)
5  *
6  * This file is part of TUD:OS and distributed under the terms of the
7  * GNU General Public License 2.
8  * Please see the COPYING-GPL-2 file for details.
9  */
10 #include <linux/module.h>
11 #include <linux/init.h>
12 #include <linux/serio.h>
13 #include <linux/errno.h>
14 #include <linux/interrupt.h>
15 #include <linux/ioport.h>
16 #include <linux/device.h>
17 #include <linux/delay.h>
18 #include <linux/slab.h>
19 #include <linux/err.h>
20
21 #include <l4/io/io.h>
22
23 struct l4bus_port {
24     struct serio        *io;
25     unsigned int        irq;
26 };
27
28 #if 0
29 static irqreturn_t l4bus_int(int irq, void *dev_id, struct pt_regs *regs)
30 {
31   struct l4bus_port *port = dev_id;
32   int handled = IRQ_NONE;
33
34   (void)port;
35   return handled;
36 }
37 #endif
38
39 static int l4bus_write(struct serio *io, unsigned char val)
40 {
41   struct l4bus_port *port = io->port_data;
42   (void)port;
43
44   return 0;
45 }
46
47 static int l4bus_open(struct serio *io)
48 {
49   struct l4bus_port *port = io->port_data;
50   (void)port;
51
52   return 0;
53 }
54
55 static void l4bus_close(struct serio *io)
56 {
57   //struct l4bus_port *port = io->port_data;
58 }
59
60 static int l4bus_probe(const char *name)
61 {
62   struct l4bus_port *port;
63   struct serio *io;
64   int ret;
65
66   port = kmalloc(sizeof(struct l4bus_port), GFP_KERNEL);
67   io = kmalloc(sizeof(struct serio), GFP_KERNEL);
68   if (!port || !io) {
69       ret = -ENOMEM;
70       goto out;
71   }
72
73   memset(port, 0, sizeof(struct l4bus_port));
74   memset(io, 0, sizeof(struct serio));
75
76   io->type      = SERIO_L4;
77   io->write     = l4bus_write;
78   //io->read    = 0;
79   io->open      = l4bus_open;
80   io->close     = l4bus_close;
81   strlcpy(io->name, name, sizeof(io->name));
82   strlcpy(io->phys, name, sizeof(io->phys));
83   io->port_data   = port;
84   //io->dev.parent      = &dev->dev;
85
86   port->io      = io;
87   port->irq     = -1;
88
89   serio_register_port(io);
90   return 0;
91
92 out:
93   kfree(io);
94   kfree(port);
95   return ret;
96 }
97
98 static int __init l4bus_init(void)
99 {
100   // FIXME: iterate over vbus to find devices
101   // ... indeed: disabled those two probe functions because they emit a
102   // warning and someone might think there could be working omap input stuff
103   if (0)
104     {
105       l4bus_probe("OMAP_TSC");
106       l4bus_probe("OMAP_KP");
107     }
108   return 0;
109 }
110
111 module_init(l4bus_init);
112
113 MODULE_AUTHOR("Torsten Frenzel");
114 MODULE_DESCRIPTION("L4 bus driver");
115 MODULE_LICENSE("GPL");