Loading arch/sparc64/kernel/devices.c +35 −69 Original line number Original line Diff line number Diff line Loading @@ -33,7 +33,7 @@ extern void cpu_probe(void); extern void central_probe(void); extern void central_probe(void); u32 sun4v_vdev_devhandle; u32 sun4v_vdev_devhandle; int sun4v_vdev_root; struct device_node *sun4v_vdev_root; struct vdev_intmap { struct vdev_intmap { unsigned int phys; unsigned int phys; Loading @@ -50,102 +50,68 @@ struct vdev_intmask { static struct vdev_intmap *vdev_intmap; static struct vdev_intmap *vdev_intmap; static int vdev_num_intmap; static int vdev_num_intmap; static struct vdev_intmask vdev_intmask; static struct vdev_intmask *vdev_intmask; static void __init sun4v_virtual_device_probe(void) static void __init sun4v_virtual_device_probe(void) { { struct linux_prom64_registers regs; struct linux_prom64_registers *regs; struct vdev_intmap *ip; struct property *prop; int node, sz, err; struct device_node *dp; int sz; if (tlb_type != hypervisor) if (tlb_type != hypervisor) return; return; node = prom_getchild(prom_root_node); dp = of_find_node_by_name(NULL, "virtual-devices"); node = prom_searchsiblings(node, "virtual-devices"); if (!dp) { if (!node) { prom_printf("SUN4V: Fatal error, no virtual-devices node.\n"); prom_printf("SUN4V: Fatal error, no virtual-devices node.\n"); prom_halt(); prom_halt(); } } sun4v_vdev_root = node; sun4v_vdev_root = dp; prom_getproperty(node, "reg", (char *)®s, sizeof(regs)); prop = of_find_property(dp, "reg", NULL); sun4v_vdev_devhandle = (regs.phys_addr >> 32UL) & 0x0fffffff; regs = prop->value; sun4v_vdev_devhandle = (regs[0].phys_addr >> 32UL) & 0x0fffffff; sz = prom_getproplen(node, "interrupt-map"); prop = of_find_property(dp, "interrupt-map", &sz); if (sz <= 0) { vdev_intmap = prop->value; prom_printf("SUN4V: Error, no vdev interrupt-map.\n"); vdev_num_intmap = sz / sizeof(struct vdev_intmap); prom_halt(); } if ((sz % sizeof(*ip)) != 0) { prom_printf("SUN4V: Bogus interrupt-map property size %d\n", sz); prom_halt(); } vdev_intmap = ip = alloc_bootmem_low_pages(sz); if (!vdev_intmap) { prom_printf("SUN4V: Error, cannot allocate vdev_intmap.\n"); prom_halt(); } err = prom_getproperty(node, "interrupt-map", (char *) ip, sz); if (err == -1) { prom_printf("SUN4V: Fatal error, no vdev interrupt-map.\n"); prom_halt(); } if (err != sz) { prom_printf("SUN4V: Inconsistent interrupt-map size, " "proplen(%d) vs getprop(%d).\n", sz,err); prom_halt(); } vdev_num_intmap = err / sizeof(*ip); err = prom_getproperty(node, "interrupt-map-mask", prop = of_find_property(dp, "interrupt-map-mask", NULL); (char *) &vdev_intmask, vdev_intmask = prop->value; sizeof(vdev_intmask)); if (err <= 0) { prom_printf("SUN4V: Fatal error, no vdev " "interrupt-map-mask.\n"); prom_halt(); } if (err % sizeof(vdev_intmask)) { prom_printf("SUN4V: Bogus interrupt-map-mask " "property size %d\n", err); prom_halt(); } printk("SUN4V: virtual-devices devhandle[%x]\n", printk("%s: Virtual Device Bus devhandle[%x]\n", sun4v_vdev_devhandle); dp->full_name, sun4v_vdev_devhandle); } } unsigned int sun4v_vdev_device_interrupt(unsigned int dev_node) unsigned int sun4v_vdev_device_interrupt(struct device_node *dev_node) { { struct property *prop; unsigned int irq, reg; unsigned int irq, reg; int err, i; int i; err = prom_getproperty(dev_node, "interrupts", prop = of_find_property(dev_node, "interrupts", NULL); (char *) &irq, sizeof(irq)); if (!prop) { if (err <= 0) { printk("VDEV: Cannot get \"interrupts\" " printk("VDEV: Cannot get \"interrupts\" " "property for OBP node %x\n", dev_node); "property for OBP node %s\n", dev_node->full_name); return 0; return 0; } } irq = *(unsigned int *) prop->value; err = prom_getproperty(dev_node, "reg", prop = of_find_property(dev_node, "reg", NULL); (char *) ®, sizeof(reg)); if (!prop) { if (err <= 0) { printk("VDEV: Cannot get \"reg\" " printk("VDEV: Cannot get \"reg\" " "property for OBP node %x\n", dev_node); "property for OBP node %s\n", dev_node->full_name); return 0; return 0; } } reg = *(unsigned int *) prop->value; for (i = 0; i < vdev_num_intmap; i++) { for (i = 0; i < vdev_num_intmap; i++) { if (vdev_intmap[i].phys == (reg & vdev_intmask.phys) && if (vdev_intmap[i].phys == (reg & vdev_intmask->phys) && vdev_intmap[i].irq == (irq & vdev_intmask.interrupt)) { vdev_intmap[i].irq == (irq & vdev_intmask->interrupt)) { irq = vdev_intmap[i].cinterrupt; irq = vdev_intmap[i].cinterrupt; break; break; } } Loading @@ -153,7 +119,7 @@ unsigned int sun4v_vdev_device_interrupt(unsigned int dev_node) if (i == vdev_num_intmap) { if (i == vdev_num_intmap) { printk("VDEV: No matching interrupt map entry " printk("VDEV: No matching interrupt map entry " "for OBP node %x\n", dev_node); "for OBP node %s\n", dev_node->full_name); return 0; return 0; } } Loading drivers/serial/sunhv.c +18 −17 Original line number Original line Diff line number Diff line Loading @@ -427,31 +427,32 @@ static int __init hv_console_compatible(char *buf, int len) static unsigned int __init get_interrupt(void) static unsigned int __init get_interrupt(void) { { const char *cons_str = "console"; struct device_node *dev_node; const char *compat_str = "compatible"; int node = prom_getchild(sun4v_vdev_root); char buf[64]; int err, len; node = prom_searchsiblings(node, cons_str); if (!node) return 0; len = prom_getproplen(node, compat_str); dev_node = sun4v_vdev_root->child; if (len == 0 || len == -1) while (dev_node != NULL) { return 0; struct property *prop; err = prom_getproperty(node, compat_str, buf, 64); if (strcmp(dev_node->name, "console")) if (err == -1) goto next_sibling; return 0; prop = of_find_property(dev_node, "compatible", NULL); if (!prop) goto next_sibling; if (!hv_console_compatible(buf, len)) if (hv_console_compatible(prop->value, prop->length)) break; next_sibling: dev_node = dev_node->sibling; } if (!dev_node) return 0; return 0; /* Ok, the this is the OBP node for the sun4v hypervisor /* Ok, the this is the OBP node for the sun4v hypervisor * console device. Decode the interrupt. * console device. Decode the interrupt. */ */ return sun4v_vdev_device_interrupt(node); return sun4v_vdev_device_interrupt(dev_node); } } static int __init sunhv_init(void) static int __init sunhv_init(void) Loading include/asm-sparc64/vdev.h +3 −2 Original line number Original line Diff line number Diff line Loading @@ -7,10 +7,11 @@ #define _SPARC64_VDEV_H #define _SPARC64_VDEV_H #include <linux/types.h> #include <linux/types.h> #include <asm/prom.h> extern u32 sun4v_vdev_devhandle; extern u32 sun4v_vdev_devhandle; extern int sun4v_vdev_root; extern struct device_node *sun4v_vdev_root; extern unsigned int sun4v_vdev_device_interrupt(unsigned int); extern unsigned int sun4v_vdev_device_interrupt(struct device_node *dev_node); #endif /* !(_SPARC64_VDEV_H) */ #endif /* !(_SPARC64_VDEV_H) */ Loading
arch/sparc64/kernel/devices.c +35 −69 Original line number Original line Diff line number Diff line Loading @@ -33,7 +33,7 @@ extern void cpu_probe(void); extern void central_probe(void); extern void central_probe(void); u32 sun4v_vdev_devhandle; u32 sun4v_vdev_devhandle; int sun4v_vdev_root; struct device_node *sun4v_vdev_root; struct vdev_intmap { struct vdev_intmap { unsigned int phys; unsigned int phys; Loading @@ -50,102 +50,68 @@ struct vdev_intmask { static struct vdev_intmap *vdev_intmap; static struct vdev_intmap *vdev_intmap; static int vdev_num_intmap; static int vdev_num_intmap; static struct vdev_intmask vdev_intmask; static struct vdev_intmask *vdev_intmask; static void __init sun4v_virtual_device_probe(void) static void __init sun4v_virtual_device_probe(void) { { struct linux_prom64_registers regs; struct linux_prom64_registers *regs; struct vdev_intmap *ip; struct property *prop; int node, sz, err; struct device_node *dp; int sz; if (tlb_type != hypervisor) if (tlb_type != hypervisor) return; return; node = prom_getchild(prom_root_node); dp = of_find_node_by_name(NULL, "virtual-devices"); node = prom_searchsiblings(node, "virtual-devices"); if (!dp) { if (!node) { prom_printf("SUN4V: Fatal error, no virtual-devices node.\n"); prom_printf("SUN4V: Fatal error, no virtual-devices node.\n"); prom_halt(); prom_halt(); } } sun4v_vdev_root = node; sun4v_vdev_root = dp; prom_getproperty(node, "reg", (char *)®s, sizeof(regs)); prop = of_find_property(dp, "reg", NULL); sun4v_vdev_devhandle = (regs.phys_addr >> 32UL) & 0x0fffffff; regs = prop->value; sun4v_vdev_devhandle = (regs[0].phys_addr >> 32UL) & 0x0fffffff; sz = prom_getproplen(node, "interrupt-map"); prop = of_find_property(dp, "interrupt-map", &sz); if (sz <= 0) { vdev_intmap = prop->value; prom_printf("SUN4V: Error, no vdev interrupt-map.\n"); vdev_num_intmap = sz / sizeof(struct vdev_intmap); prom_halt(); } if ((sz % sizeof(*ip)) != 0) { prom_printf("SUN4V: Bogus interrupt-map property size %d\n", sz); prom_halt(); } vdev_intmap = ip = alloc_bootmem_low_pages(sz); if (!vdev_intmap) { prom_printf("SUN4V: Error, cannot allocate vdev_intmap.\n"); prom_halt(); } err = prom_getproperty(node, "interrupt-map", (char *) ip, sz); if (err == -1) { prom_printf("SUN4V: Fatal error, no vdev interrupt-map.\n"); prom_halt(); } if (err != sz) { prom_printf("SUN4V: Inconsistent interrupt-map size, " "proplen(%d) vs getprop(%d).\n", sz,err); prom_halt(); } vdev_num_intmap = err / sizeof(*ip); err = prom_getproperty(node, "interrupt-map-mask", prop = of_find_property(dp, "interrupt-map-mask", NULL); (char *) &vdev_intmask, vdev_intmask = prop->value; sizeof(vdev_intmask)); if (err <= 0) { prom_printf("SUN4V: Fatal error, no vdev " "interrupt-map-mask.\n"); prom_halt(); } if (err % sizeof(vdev_intmask)) { prom_printf("SUN4V: Bogus interrupt-map-mask " "property size %d\n", err); prom_halt(); } printk("SUN4V: virtual-devices devhandle[%x]\n", printk("%s: Virtual Device Bus devhandle[%x]\n", sun4v_vdev_devhandle); dp->full_name, sun4v_vdev_devhandle); } } unsigned int sun4v_vdev_device_interrupt(unsigned int dev_node) unsigned int sun4v_vdev_device_interrupt(struct device_node *dev_node) { { struct property *prop; unsigned int irq, reg; unsigned int irq, reg; int err, i; int i; err = prom_getproperty(dev_node, "interrupts", prop = of_find_property(dev_node, "interrupts", NULL); (char *) &irq, sizeof(irq)); if (!prop) { if (err <= 0) { printk("VDEV: Cannot get \"interrupts\" " printk("VDEV: Cannot get \"interrupts\" " "property for OBP node %x\n", dev_node); "property for OBP node %s\n", dev_node->full_name); return 0; return 0; } } irq = *(unsigned int *) prop->value; err = prom_getproperty(dev_node, "reg", prop = of_find_property(dev_node, "reg", NULL); (char *) ®, sizeof(reg)); if (!prop) { if (err <= 0) { printk("VDEV: Cannot get \"reg\" " printk("VDEV: Cannot get \"reg\" " "property for OBP node %x\n", dev_node); "property for OBP node %s\n", dev_node->full_name); return 0; return 0; } } reg = *(unsigned int *) prop->value; for (i = 0; i < vdev_num_intmap; i++) { for (i = 0; i < vdev_num_intmap; i++) { if (vdev_intmap[i].phys == (reg & vdev_intmask.phys) && if (vdev_intmap[i].phys == (reg & vdev_intmask->phys) && vdev_intmap[i].irq == (irq & vdev_intmask.interrupt)) { vdev_intmap[i].irq == (irq & vdev_intmask->interrupt)) { irq = vdev_intmap[i].cinterrupt; irq = vdev_intmap[i].cinterrupt; break; break; } } Loading @@ -153,7 +119,7 @@ unsigned int sun4v_vdev_device_interrupt(unsigned int dev_node) if (i == vdev_num_intmap) { if (i == vdev_num_intmap) { printk("VDEV: No matching interrupt map entry " printk("VDEV: No matching interrupt map entry " "for OBP node %x\n", dev_node); "for OBP node %s\n", dev_node->full_name); return 0; return 0; } } Loading
drivers/serial/sunhv.c +18 −17 Original line number Original line Diff line number Diff line Loading @@ -427,31 +427,32 @@ static int __init hv_console_compatible(char *buf, int len) static unsigned int __init get_interrupt(void) static unsigned int __init get_interrupt(void) { { const char *cons_str = "console"; struct device_node *dev_node; const char *compat_str = "compatible"; int node = prom_getchild(sun4v_vdev_root); char buf[64]; int err, len; node = prom_searchsiblings(node, cons_str); if (!node) return 0; len = prom_getproplen(node, compat_str); dev_node = sun4v_vdev_root->child; if (len == 0 || len == -1) while (dev_node != NULL) { return 0; struct property *prop; err = prom_getproperty(node, compat_str, buf, 64); if (strcmp(dev_node->name, "console")) if (err == -1) goto next_sibling; return 0; prop = of_find_property(dev_node, "compatible", NULL); if (!prop) goto next_sibling; if (!hv_console_compatible(buf, len)) if (hv_console_compatible(prop->value, prop->length)) break; next_sibling: dev_node = dev_node->sibling; } if (!dev_node) return 0; return 0; /* Ok, the this is the OBP node for the sun4v hypervisor /* Ok, the this is the OBP node for the sun4v hypervisor * console device. Decode the interrupt. * console device. Decode the interrupt. */ */ return sun4v_vdev_device_interrupt(node); return sun4v_vdev_device_interrupt(dev_node); } } static int __init sunhv_init(void) static int __init sunhv_init(void) Loading
include/asm-sparc64/vdev.h +3 −2 Original line number Original line Diff line number Diff line Loading @@ -7,10 +7,11 @@ #define _SPARC64_VDEV_H #define _SPARC64_VDEV_H #include <linux/types.h> #include <linux/types.h> #include <asm/prom.h> extern u32 sun4v_vdev_devhandle; extern u32 sun4v_vdev_devhandle; extern int sun4v_vdev_root; extern struct device_node *sun4v_vdev_root; extern unsigned int sun4v_vdev_device_interrupt(unsigned int); extern unsigned int sun4v_vdev_device_interrupt(struct device_node *dev_node); #endif /* !(_SPARC64_VDEV_H) */ #endif /* !(_SPARC64_VDEV_H) */