Merge tag 'ceph-for-4.13-rc8' of git://github.com/ceph/ceph-client
[linux/fpc-iii.git] / drivers / input / serio / i8042-sparcio.h
blob6231d63860ee324031d36e6e1c42dd57407dc27f
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;
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 static struct resource *kbd_res;
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"
53 static int sparc_i8042_probe(struct platform_device *op)
55 struct device_node *dp = op->dev.of_node;
57 dp = dp->child;
58 while (dp) {
59 if (!strcmp(dp->name, OBP_PS2KBD_NAME1) ||
60 !strcmp(dp->name, OBP_PS2KBD_NAME2)) {
61 struct platform_device *kbd = of_find_device_by_node(dp);
62 unsigned int irq = kbd->archdata.irqs[0];
63 if (irq == 0xffffffff)
64 irq = op->archdata.irqs[0];
65 i8042_kbd_irq = irq;
66 kbd_iobase = of_ioremap(&kbd->resource[0],
67 0, 8, "kbd");
68 kbd_res = &kbd->resource[0];
69 } else if (!strcmp(dp->name, OBP_PS2MS_NAME1) ||
70 !strcmp(dp->name, OBP_PS2MS_NAME2)) {
71 struct platform_device *ms = of_find_device_by_node(dp);
72 unsigned int irq = ms->archdata.irqs[0];
73 if (irq == 0xffffffff)
74 irq = op->archdata.irqs[0];
75 i8042_aux_irq = irq;
78 dp = dp->sibling;
81 return 0;
84 static int sparc_i8042_remove(struct platform_device *op)
86 of_iounmap(kbd_res, kbd_iobase, 8);
88 return 0;
91 static const struct of_device_id sparc_i8042_match[] = {
93 .name = "8042",
95 {},
97 MODULE_DEVICE_TABLE(of, sparc_i8042_match);
99 static struct platform_driver sparc_i8042_driver = {
100 .driver = {
101 .name = "i8042",
102 .of_match_table = sparc_i8042_match,
104 .probe = sparc_i8042_probe,
105 .remove = 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 = platform_driver_register(&sparc_i8042_driver);
120 if (err)
121 return err;
123 if (i8042_kbd_irq == -1 ||
124 i8042_aux_irq == -1) {
125 if (kbd_iobase) {
126 of_iounmap(kbd_res, kbd_iobase, 8);
127 kbd_iobase = (void __iomem *) NULL;
129 return -ENODEV;
133 i8042_reset = I8042_RESET_ALWAYS;
135 return 0;
138 static inline void i8042_platform_exit(void)
140 struct device_node *root = of_find_node_by_path("/");
142 if (strcmp(root->name, "SUNW,JavaStation-1"))
143 platform_driver_unregister(&sparc_i8042_driver);
146 #else /* !CONFIG_PCI */
147 static int __init i8042_platform_init(void)
149 return -ENODEV;
152 static inline void i8042_platform_exit(void)
155 #endif /* !CONFIG_PCI */
157 #endif /* _I8042_SPARCIO_H */