[SERIO] i8042-sparcio.h: Convert to of_driver framework.

Signed-off-by: David S. Miller <davem@davemloft.net>

authored by David S. Miller and committed by David S. Miller f57caaef ff0d2fc6

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