sparc: i8042-sparcio.h: fix warning
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / input / serio / i8042-sparcio.h
blob66bafe308b0cd053252e4f0cbf8b3644dfd7c5a5
1 #ifndef _I8042_SPARCIO_H
2 #define _I8042_SPARCIO_H
4 #include <asm/io.h>
5 #include <asm/oplib.h>
6 #include <asm/prom.h>
7 #include <asm/of_device.h>
9 static int i8042_kbd_irq = -1;
10 static int i8042_aux_irq = -1;
11 #define I8042_KBD_IRQ i8042_kbd_irq
12 #define I8042_AUX_IRQ i8042_aux_irq
14 #define I8042_KBD_PHYS_DESC "sparcps2/serio0"
15 #define I8042_AUX_PHYS_DESC "sparcps2/serio1"
16 #define I8042_MUX_PHYS_DESC "sparcps2/serio%d"
18 static void __iomem *kbd_iobase;
19 static struct resource *kbd_res;
21 #define I8042_COMMAND_REG (kbd_iobase + 0x64UL)
22 #define I8042_DATA_REG (kbd_iobase + 0x60UL)
24 static inline int i8042_read_data(void)
26 return readb(kbd_iobase + 0x60UL);
29 static inline int i8042_read_status(void)
31 return readb(kbd_iobase + 0x64UL);
34 static inline void i8042_write_data(int val)
36 writeb(val, kbd_iobase + 0x60UL);
39 static inline void i8042_write_command(int val)
41 writeb(val, kbd_iobase + 0x64UL);
44 #ifdef CONFIG_PCI
46 #define OBP_PS2KBD_NAME1 "kb_ps2"
47 #define OBP_PS2KBD_NAME2 "keyboard"
48 #define OBP_PS2MS_NAME1 "kdmouse"
49 #define OBP_PS2MS_NAME2 "mouse"
51 static int __devinit sparc_i8042_probe(struct of_device *op, const struct of_device_id *match)
53 struct device_node *dp = op->node;
55 dp = dp->child;
56 while (dp) {
57 if (!strcmp(dp->name, OBP_PS2KBD_NAME1) ||
58 !strcmp(dp->name, OBP_PS2KBD_NAME2)) {
59 struct of_device *kbd = of_find_device_by_node(dp);
60 unsigned int irq = kbd->irqs[0];
61 if (irq == 0xffffffff)
62 irq = op->irqs[0];
63 i8042_kbd_irq = irq;
64 kbd_iobase = of_ioremap(&kbd->resource[0],
65 0, 8, "kbd");
66 kbd_res = &kbd->resource[0];
67 } else if (!strcmp(dp->name, OBP_PS2MS_NAME1) ||
68 !strcmp(dp->name, OBP_PS2MS_NAME2)) {
69 struct of_device *ms = of_find_device_by_node(dp);
70 unsigned int irq = ms->irqs[0];
71 if (irq == 0xffffffff)
72 irq = op->irqs[0];
73 i8042_aux_irq = irq;
76 dp = dp->sibling;
79 return 0;
82 static int __devexit sparc_i8042_remove(struct of_device *op)
84 of_iounmap(kbd_res, kbd_iobase, 8);
86 return 0;
89 static struct of_device_id sparc_i8042_match[] = {
91 .name = "8042",
93 {},
95 MODULE_DEVICE_TABLE(of, sparc_i8042_match);
97 static struct of_platform_driver sparc_i8042_driver = {
98 .name = "i8042",
99 .match_table = sparc_i8042_match,
100 .probe = sparc_i8042_probe,
101 .remove = __devexit_p(sparc_i8042_remove),
104 static int __init i8042_platform_init(void)
106 struct device_node *root = of_find_node_by_path("/");
108 if (!strcmp(root->name, "SUNW,JavaStation-1")) {
109 /* Hardcoded values for MrCoffee. */
110 i8042_kbd_irq = i8042_aux_irq = 13 | 0x20;
111 kbd_iobase = ioremap(0x71300060, 8);
112 if (!kbd_iobase)
113 return -ENODEV;
114 } else {
115 int err = of_register_driver(&sparc_i8042_driver,
116 &of_bus_type);
117 if (err)
118 return err;
120 if (i8042_kbd_irq == -1 ||
121 i8042_aux_irq == -1) {
122 if (kbd_iobase) {
123 of_iounmap(kbd_res, kbd_iobase, 8);
124 kbd_iobase = (void __iomem *) NULL;
126 return -ENODEV;
130 i8042_reset = 1;
132 return 0;
135 static inline void i8042_platform_exit(void)
137 struct device_node *root = of_find_node_by_path("/");
139 if (strcmp(root->name, "SUNW,JavaStation-1"))
140 of_unregister_driver(&sparc_i8042_driver);
143 #else /* !CONFIG_PCI */
144 static int __init i8042_platform_init(void)
146 return -ENODEV;
149 static inline void i8042_platform_exit(void)
152 #endif /* !CONFIG_PCI */
154 #endif /* _I8042_SPARCIO_H */