aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/serio/i8042-sparcio.h108
1 files changed, 69 insertions, 39 deletions
diff --git a/drivers/input/serio/i8042-sparcio.h b/drivers/input/serio/i8042-sparcio.h
index 6d66351805a2..9cad197a4e68 100644
--- a/drivers/input/serio/i8042-sparcio.h
+++ b/drivers/input/serio/i8042-sparcio.h
@@ -3,11 +3,9 @@
3 3
4#include <linux/config.h> 4#include <linux/config.h>
5#include <asm/io.h> 5#include <asm/io.h>
6
7#ifdef CONFIG_PCI
8#include <asm/oplib.h> 6#include <asm/oplib.h>
9#include <asm/ebus.h> 7#include <asm/prom.h>
10#endif 8#include <asm/of_device.h>
11 9
12static int i8042_kbd_irq = -1; 10static int i8042_kbd_irq = -1;
13static int i8042_aux_irq = -1; 11static int i8042_aux_irq = -1;
@@ -48,54 +46,83 @@ static inline void i8042_write_command(int val)
48#define OBP_PS2MS_NAME1 "kdmouse" 46#define OBP_PS2MS_NAME1 "kdmouse"
49#define OBP_PS2MS_NAME2 "mouse" 47#define OBP_PS2MS_NAME2 "mouse"
50 48
49static int __devinit sparc_i8042_probe(struct of_device *op, const struct of_device_id *match)
50{
51 struct device_node *dp = op->node;
52
53 dp = dp->child;
54 while (dp) {
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)
60 irq = op->irqs[0];
61 i8042_kbd_irq = irq;
62 kbd_iobase = of_ioremap(&kbd->resource[0],
63 0, 8, "kbd");
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)
69 irq = op->irqs[0];
70 i8042_aux_irq = irq;
71 }
72
73 dp = dp->sibling;
74 }
75
76 return 0;
77}
78
79static int __devexit sparc_i8042_remove(struct of_device *op)
80{
81 of_iounmap(kbd_iobase, 8);
82
83 return 0;
84}
85
86static struct of_device_id sparc_i8042_match[] = {
87 {
88 .name = "8042",
89 },
90 {},
91};
92MODULE_DEVICE_TABLE(of, i8042_match);
93
94static struct of_platform_driver sparc_i8042_driver = {
95 .name = "i8042",
96 .match_table = sparc_i8042_match,
97 .probe = sparc_i8042_probe,
98 .remove = __devexit_p(sparc_i8042_remove),
99};
100
51static int __init i8042_platform_init(void) 101static int __init i8042_platform_init(void)
52{ 102{
53#ifndef CONFIG_PCI 103#ifndef CONFIG_PCI
54 return -ENODEV; 104 return -ENODEV;
55#else 105#else
56 char prop[128]; 106 struct device_node *root = of_find_node_by_path("/");
57 int len;
58 107
59 len = prom_getproperty(prom_root_node, "name", prop, sizeof(prop)); 108 if (!strcmp(root->name, "SUNW,JavaStation-1")) {
60 if (len < 0) {
61 printk("i8042: Cannot get name property of root OBP node.\n");
62 return -ENODEV;
63 }
64 if (strncmp(prop, "SUNW,JavaStation-1", len) == 0) {
65 /* Hardcoded values for MrCoffee. */ 109 /* Hardcoded values for MrCoffee. */
66 i8042_kbd_irq = i8042_aux_irq = 13 | 0x20; 110 i8042_kbd_irq = i8042_aux_irq = 13 | 0x20;
67 kbd_iobase = ioremap(0x71300060, 8); 111 kbd_iobase = ioremap(0x71300060, 8);
68 if (!kbd_iobase) 112 if (!kbd_iobase)
69 return -ENODEV; 113 return -ENODEV;
70 } else { 114 } else {
71 struct linux_ebus *ebus; 115 int err = of_register_driver(&sparc_i8042_driver,
72 struct linux_ebus_device *edev; 116 &of_bus_type);
73 struct linux_ebus_child *child; 117 if (err)
74 118 return err;
75 for_each_ebus(ebus) { 119
76 for_each_ebusdev(edev, ebus) {
77 if (!strcmp(edev->prom_node->name, "8042"))
78 goto edev_found;
79 }
80 }
81 return -ENODEV;
82
83 edev_found:
84 for_each_edevchild(edev, child) {
85 if (!strcmp(child->prom_node->name, OBP_PS2KBD_NAME1) ||
86 !strcmp(child->prom_node->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_node->name, OBP_PS2MS_NAME1) ||
92 !strcmp(child->prom_node->name, OBP_PS2MS_NAME2))
93 i8042_aux_irq = child->irqs[0];
94 }
95 if (i8042_kbd_irq == -1 || 120 if (i8042_kbd_irq == -1 ||
96 i8042_aux_irq == -1) { 121 i8042_aux_irq == -1) {
97 printk("i8042: Error, 8042 device lacks both kbd and " 122 if (kbd_iobase) {
98 "mouse nodes.\n"); 123 of_iounmap(kbd_iobase, 8);
124 kbd_iobase = (void __iomem *) NULL;
125 }
99 return -ENODEV; 126 return -ENODEV;
100 } 127 }
101 } 128 }
@@ -109,7 +136,10 @@ static int __init i8042_platform_init(void)
109static inline void i8042_platform_exit(void) 136static inline void i8042_platform_exit(void)
110{ 137{
111#ifdef CONFIG_PCI 138#ifdef CONFIG_PCI
112 iounmap(kbd_iobase); 139 struct device_node *root = of_find_node_by_path("/");
140
141 if (strcmp(root->name, "SUNW,JavaStation-1"))
142 of_unregister_driver(&sparc_i8042_driver);
113#endif 143#endif
114} 144}
115 145