net/mlx4_core: Reduce harmless SRIOV error message to debug level
[linux-2.6-block.git] / drivers / input / serio / i8042-sparcio.h
CommitLineData
1da177e4
LT
1#ifndef _I8042_SPARCIO_H
2#define _I8042_SPARCIO_H
3
c6ed413d
SR
4#include <linux/of_device.h>
5
1da177e4 6#include <asm/io.h>
1da177e4 7#include <asm/oplib.h>
f57caaef 8#include <asm/prom.h>
1da177e4
LT
9
10static int i8042_kbd_irq = -1;
11static int i8042_aux_irq = -1;
12#define I8042_KBD_IRQ i8042_kbd_irq
13#define I8042_AUX_IRQ i8042_aux_irq
14
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"
18
19static void __iomem *kbd_iobase;
20
21#define I8042_COMMAND_REG (kbd_iobase + 0x64UL)
22#define I8042_DATA_REG (kbd_iobase + 0x60UL)
23
24static inline int i8042_read_data(void)
25{
26 return readb(kbd_iobase + 0x60UL);
27}
28
29static inline int i8042_read_status(void)
30{
31 return readb(kbd_iobase + 0x64UL);
32}
33
34static inline void i8042_write_data(int val)
35{
36 writeb(val, kbd_iobase + 0x60UL);
37}
38
39static inline void i8042_write_command(int val)
40{
41 writeb(val, kbd_iobase + 0x64UL);
42}
43
8c6a5cad
AB
44#ifdef CONFIG_PCI
45
fb92be7b
VS
46static struct resource *kbd_res;
47
1da177e4
LT
48#define OBP_PS2KBD_NAME1 "kb_ps2"
49#define OBP_PS2KBD_NAME2 "keyboard"
50#define OBP_PS2MS_NAME1 "kdmouse"
51#define OBP_PS2MS_NAME2 "mouse"
52
5298cc4c 53static int sparc_i8042_probe(struct platform_device *op)
f57caaef 54{
61c7a080 55 struct device_node *dp = op->dev.of_node;
f57caaef
DM
56
57 dp = dp->child;
58 while (dp) {
59 if (!strcmp(dp->name, OBP_PS2KBD_NAME1) ||
60 !strcmp(dp->name, OBP_PS2KBD_NAME2)) {
2dc11581 61 struct platform_device *kbd = of_find_device_by_node(dp);
1636f8ac 62 unsigned int irq = kbd->archdata.irqs[0];
f57caaef 63 if (irq == 0xffffffff)
1636f8ac 64 irq = op->archdata.irqs[0];
f57caaef
DM
65 i8042_kbd_irq = irq;
66 kbd_iobase = of_ioremap(&kbd->resource[0],
67 0, 8, "kbd");
e3a411a3 68 kbd_res = &kbd->resource[0];
f57caaef
DM
69 } else if (!strcmp(dp->name, OBP_PS2MS_NAME1) ||
70 !strcmp(dp->name, OBP_PS2MS_NAME2)) {
2dc11581 71 struct platform_device *ms = of_find_device_by_node(dp);
1636f8ac 72 unsigned int irq = ms->archdata.irqs[0];
f57caaef 73 if (irq == 0xffffffff)
1636f8ac 74 irq = op->archdata.irqs[0];
f57caaef
DM
75 i8042_aux_irq = irq;
76 }
77
78 dp = dp->sibling;
79 }
80
81 return 0;
82}
83
e2619cf7 84static int sparc_i8042_remove(struct platform_device *op)
f57caaef 85{
e3a411a3 86 of_iounmap(kbd_res, kbd_iobase, 8);
f57caaef
DM
87
88 return 0;
89}
90
fd098316 91static const struct of_device_id sparc_i8042_match[] = {
f57caaef
DM
92 {
93 .name = "8042",
94 },
95 {},
96};
6b8f3ef4 97MODULE_DEVICE_TABLE(of, sparc_i8042_match);
f57caaef 98
4ebb24f7 99static struct platform_driver sparc_i8042_driver = {
4018294b
GL
100 .driver = {
101 .name = "i8042",
4018294b
GL
102 .of_match_table = sparc_i8042_match,
103 },
f57caaef 104 .probe = sparc_i8042_probe,
1cb0aa88 105 .remove = sparc_i8042_remove,
f57caaef
DM
106};
107
8d5987a6 108static int __init i8042_platform_init(void)
1da177e4 109{
f57caaef 110 struct device_node *root = of_find_node_by_path("/");
1da177e4 111
f57caaef 112 if (!strcmp(root->name, "SUNW,JavaStation-1")) {
1da177e4
LT
113 /* Hardcoded values for MrCoffee. */
114 i8042_kbd_irq = i8042_aux_irq = 13 | 0x20;
115 kbd_iobase = ioremap(0x71300060, 8);
116 if (!kbd_iobase)
8d5987a6 117 return -ENODEV;
1da177e4 118 } else {
4ebb24f7 119 int err = platform_driver_register(&sparc_i8042_driver);
f57caaef
DM
120 if (err)
121 return err;
122
1da177e4
LT
123 if (i8042_kbd_irq == -1 ||
124 i8042_aux_irq == -1) {
f57caaef 125 if (kbd_iobase) {
e3a411a3 126 of_iounmap(kbd_res, kbd_iobase, 8);
f57caaef
DM
127 kbd_iobase = (void __iomem *) NULL;
128 }
8d5987a6 129 return -ENODEV;
1da177e4
LT
130 }
131 }
132
930e1924 133 i8042_reset = I8042_RESET_ALWAYS;
1da177e4
LT
134
135 return 0;
1da177e4
LT
136}
137
138static inline void i8042_platform_exit(void)
139{
f57caaef
DM
140 struct device_node *root = of_find_node_by_path("/");
141
142 if (strcmp(root->name, "SUNW,JavaStation-1"))
4ebb24f7 143 platform_driver_unregister(&sparc_i8042_driver);
1da177e4
LT
144}
145
8c6a5cad
AB
146#else /* !CONFIG_PCI */
147static int __init i8042_platform_init(void)
148{
149 return -ENODEV;
150}
151
152static inline void i8042_platform_exit(void)
153{
154}
155#endif /* !CONFIG_PCI */
156
1da177e4 157#endif /* _I8042_SPARCIO_H */