tracing: Sanitize value returned from write(trace_marker, "...", len)
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / input / serio / i8042-sparcio.h
blob04e32f2d1241eacc9cfc6716fb22441d2dbd2a3e
1 #ifndef _I8042_SPARCIO_H
2 #define _I8042_SPARCIO_H
4 #include <linux/of_device.h>
6 #include <asm/io.h>
7 #include <asm/oplib.h>
8 #include <asm/prom.h>
10 static int i8042_kbd_irq = -1;
11 static int i8042_aux_irq = -1;
12 #define I8042_KBD_IRQ i8042_kbd_irq
13 #define I8042_AUX_IRQ i8042_aux_irq
15 #define I8042_KBD_PHYS_DESC "sparcps2/serio0"
16 #define I8042_AUX_PHYS_DESC "sparcps2/serio1"
17 #define I8042_MUX_PHYS_DESC "sparcps2/serio%d"
19 static void __iomem *kbd_iobase;
20 static struct resource *kbd_res;
22 #define I8042_COMMAND_REG (kbd_iobase + 0x64UL)
23 #define I8042_DATA_REG (kbd_iobase + 0x60UL)
25 static inline int i8042_read_data(void)
27 return readb(kbd_iobase + 0x60UL);
30 static inline int i8042_read_status(void)
32 return readb(kbd_iobase + 0x64UL);
35 static inline void i8042_write_data(int val)
37 writeb(val, kbd_iobase + 0x60UL);
40 static inline void i8042_write_command(int val)
42 writeb(val, kbd_iobase + 0x64UL);
45 #ifdef CONFIG_PCI
47 #define OBP_PS2KBD_NAME1 "kb_ps2"
48 #define OBP_PS2KBD_NAME2 "keyboard"
49 #define OBP_PS2MS_NAME1 "kdmouse"
50 #define OBP_PS2MS_NAME2 "mouse"
52 static int __devinit sparc_i8042_probe(struct of_device *op, const struct of_device_id *match)
54 struct device_node *dp = op->dev.of_node;
56 dp = dp->child;
57 while (dp) {
58 if (!strcmp(dp->name, OBP_PS2KBD_NAME1) ||
59 !strcmp(dp->name, OBP_PS2KBD_NAME2)) {
60 struct of_device *kbd = of_find_device_by_node(dp);
61 unsigned int irq = kbd->irqs[0];
62 if (irq == 0xffffffff)
63 irq = op->irqs[0];
64 i8042_kbd_irq = irq;
65 kbd_iobase = of_ioremap(&kbd->resource[0],
66 0, 8, "kbd");
67 kbd_res = &kbd->resource[0];
68 } else if (!strcmp(dp->name, OBP_PS2MS_NAME1) ||
69 !strcmp(dp->name, OBP_PS2MS_NAME2)) {
70 struct of_device *ms = of_find_device_by_node(dp);
71 unsigned int irq = ms->irqs[0];
72 if (irq == 0xffffffff)
73 irq = op->irqs[0];
74 i8042_aux_irq = irq;
77 dp = dp->sibling;
80 return 0;
83 static int __devexit sparc_i8042_remove(struct of_device *op)
85 of_iounmap(kbd_res, kbd_iobase, 8);
87 return 0;
90 static const struct of_device_id sparc_i8042_match[] = {
92 .name = "8042",
94 {},
96 MODULE_DEVICE_TABLE(of, sparc_i8042_match);
98 static struct of_platform_driver sparc_i8042_driver = {
99 .driver = {
100 .name = "i8042",
101 .owner = THIS_MODULE,
102 .of_match_table = sparc_i8042_match,
104 .probe = sparc_i8042_probe,
105 .remove = __devexit_p(sparc_i8042_remove),
108 static int __init i8042_platform_init(void)
110 struct device_node *root = of_find_node_by_path("/");
112 if (!strcmp(root->name, "SUNW,JavaStation-1")) {
113 /* Hardcoded values for MrCoffee. */
114 i8042_kbd_irq = i8042_aux_irq = 13 | 0x20;
115 kbd_iobase = ioremap(0x71300060, 8);
116 if (!kbd_iobase)
117 return -ENODEV;
118 } else {
119 int err = of_register_driver(&sparc_i8042_driver,
120 &of_bus_type);
121 if (err)
122 return err;
124 if (i8042_kbd_irq == -1 ||
125 i8042_aux_irq == -1) {
126 if (kbd_iobase) {
127 of_iounmap(kbd_res, kbd_iobase, 8);
128 kbd_iobase = (void __iomem *) NULL;
130 return -ENODEV;
134 i8042_reset = 1;
136 return 0;
139 static inline void i8042_platform_exit(void)
141 struct device_node *root = of_find_node_by_path("/");
143 if (strcmp(root->name, "SUNW,JavaStation-1"))
144 of_unregister_driver(&sparc_i8042_driver);
147 #else /* !CONFIG_PCI */
148 static int __init i8042_platform_init(void)
150 return -ENODEV;
153 static inline void i8042_platform_exit(void)
156 #endif /* !CONFIG_PCI */
158 #endif /* _I8042_SPARCIO_H */