1 #ifndef _I8042_SPARCIO_H
2 #define _I8042_SPARCIO_H
4 #include <linux/config.h>
8 #include <asm/of_device.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;
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 #define OBP_PS2KBD_NAME1 "kb_ps2"
45 #define OBP_PS2KBD_NAME2 "keyboard"
46 #define OBP_PS2MS_NAME1 "kdmouse"
47 #define OBP_PS2MS_NAME2 "mouse"
49 static int __devinit sparc_i8042_probe(struct of_device *op, const struct of_device_id *match)
51 struct device_node *dp = op->node;
55 if (!strcmp(dp->name, OBP_PS2KBD_NAME1) ||
56 !strcmp(dp->name, OBP_PS2KBD_NAME2)) {
57 struct of_device *kbd = of_find_device_by_node(dp);
58 unsigned int irq = kbd->irqs[0];
59 if (irq == 0xffffffff)
62 kbd_iobase = of_ioremap(&kbd->resource[0],
64 } else if (!strcmp(dp->name, OBP_PS2MS_NAME1) ||
65 !strcmp(dp->name, OBP_PS2MS_NAME2)) {
66 struct of_device *ms = of_find_device_by_node(dp);
67 unsigned int irq = ms->irqs[0];
68 if (irq == 0xffffffff)
79 static int __devexit sparc_i8042_remove(struct of_device *op)
81 of_iounmap(kbd_iobase, 8);
86 static struct of_device_id sparc_i8042_match[] = {
92 MODULE_DEVICE_TABLE(of, i8042_match);
94 static struct of_platform_driver sparc_i8042_driver = {
96 .match_table = sparc_i8042_match,
97 .probe = sparc_i8042_probe,
98 .remove = __devexit_p(sparc_i8042_remove),
101 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);
115 int err = of_register_driver(&sparc_i8042_driver,
120 if (i8042_kbd_irq == -1 ||
121 i8042_aux_irq == -1) {
123 of_iounmap(kbd_iobase, 8);
124 kbd_iobase = (void __iomem *) NULL;
133 #endif /* CONFIG_PCI */
136 static inline void i8042_platform_exit(void)
139 struct device_node *root = of_find_node_by_path("/");
141 if (strcmp(root->name, "SUNW,JavaStation-1"))
142 of_unregister_driver(&sparc_i8042_driver);
146 #endif /* _I8042_SPARCIO_H */