blob: ed9446f6d7e3332cdf8f9ec4f6ec0f4b1fb6784c [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _I8042_SPARCIO_H
2#define _I8042_SPARCIO_H
3
4#include <linux/config.h>
5#include <asm/io.h>
6
7#ifdef CONFIG_PCI
8#include <asm/oplib.h>
9#include <asm/ebus.h>
10#endif
11
12static int i8042_kbd_irq = -1;
13static int i8042_aux_irq = -1;
14#define I8042_KBD_IRQ i8042_kbd_irq
15#define I8042_AUX_IRQ i8042_aux_irq
16
17#define I8042_KBD_PHYS_DESC "sparcps2/serio0"
18#define I8042_AUX_PHYS_DESC "sparcps2/serio1"
19#define I8042_MUX_PHYS_DESC "sparcps2/serio%d"
20
21static void __iomem *kbd_iobase;
22
23#define I8042_COMMAND_REG (kbd_iobase + 0x64UL)
24#define I8042_DATA_REG (kbd_iobase + 0x60UL)
25
26static inline int i8042_read_data(void)
27{
28 return readb(kbd_iobase + 0x60UL);
29}
30
31static inline int i8042_read_status(void)
32{
33 return readb(kbd_iobase + 0x64UL);
34}
35
36static inline void i8042_write_data(int val)
37{
38 writeb(val, kbd_iobase + 0x60UL);
39}
40
41static inline void i8042_write_command(int val)
42{
43 writeb(val, kbd_iobase + 0x64UL);
44}
45
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"
50
Dmitry Torokhov8d5987a2005-09-04 01:41:38 -050051static int __init i8042_platform_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070052{
53#ifndef CONFIG_PCI
Dmitry Torokhov8d5987a2005-09-04 01:41:38 -050054 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -070055#else
56 char prop[128];
57 int len;
58
59 len = prom_getproperty(prom_root_node, "name", prop, sizeof(prop));
60 if (len < 0) {
61 printk("i8042: Cannot get name property of root OBP node.\n");
Dmitry Torokhov8d5987a2005-09-04 01:41:38 -050062 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 }
64 if (strncmp(prop, "SUNW,JavaStation-1", len) == 0) {
65 /* Hardcoded values for MrCoffee. */
66 i8042_kbd_irq = i8042_aux_irq = 13 | 0x20;
67 kbd_iobase = ioremap(0x71300060, 8);
68 if (!kbd_iobase)
Dmitry Torokhov8d5987a2005-09-04 01:41:38 -050069 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -070070 } else {
71 struct linux_ebus *ebus;
72 struct linux_ebus_device *edev;
73 struct linux_ebus_child *child;
74
75 for_each_ebus(ebus) {
76 for_each_ebusdev(edev, ebus) {
77 if (!strcmp(edev->prom_name, "8042"))
78 goto edev_found;
79 }
80 }
Dmitry Torokhov8d5987a2005-09-04 01:41:38 -050081 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -070082
83 edev_found:
84 for_each_edevchild(edev, child) {
85 if (!strcmp(child->prom_name, OBP_PS2KBD_NAME1) ||
86 !strcmp(child->prom_name, OBP_PS2KBD_NAME2)) {
87 i8042_kbd_irq = child->irqs[0];
88 kbd_iobase =
89 ioremap(child->resource[0].start, 8);
90 }
91 if (!strcmp(child->prom_name, OBP_PS2MS_NAME1) ||
92 !strcmp(child->prom_name, OBP_PS2MS_NAME2))
93 i8042_aux_irq = child->irqs[0];
94 }
95 if (i8042_kbd_irq == -1 ||
96 i8042_aux_irq == -1) {
97 printk("i8042: Error, 8042 device lacks both kbd and "
98 "mouse nodes.\n");
Dmitry Torokhov8d5987a2005-09-04 01:41:38 -050099 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100 }
101 }
102
103 i8042_reset = 1;
104
105 return 0;
106#endif /* CONFIG_PCI */
107}
108
109static inline void i8042_platform_exit(void)
110{
111#ifdef CONFIG_PCI
112 iounmap(kbd_iobase);
113#endif
114}
115
116#endif /* _I8042_SPARCIO_H */