aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc64
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sparc64')
-rw-r--r--arch/sparc64/kernel/devices.c97
-rw-r--r--arch/sparc64/kernel/of_device.c3
-rw-r--r--arch/sparc64/kernel/prom.c23
3 files changed, 26 insertions, 97 deletions
diff --git a/arch/sparc64/kernel/devices.c b/arch/sparc64/kernel/devices.c
index ddbe8cda06af..f8ef2f2b9b37 100644
--- a/arch/sparc64/kernel/devices.c
+++ b/arch/sparc64/kernel/devices.c
@@ -20,8 +20,6 @@
20#include <asm/spitfire.h> 20#include <asm/spitfire.h>
21#include <asm/timer.h> 21#include <asm/timer.h>
22#include <asm/cpudata.h> 22#include <asm/cpudata.h>
23#include <asm/vdev.h>
24#include <asm/irq.h>
25 23
26/* Used to synchronize acceses to NatSemi SUPER I/O chip configure 24/* Used to synchronize acceses to NatSemi SUPER I/O chip configure
27 * operations in asm/ns87303.h 25 * operations in asm/ns87303.h
@@ -31,100 +29,6 @@ DEFINE_SPINLOCK(ns87303_lock);
31extern void cpu_probe(void); 29extern void cpu_probe(void);
32extern void central_probe(void); 30extern void central_probe(void);
33 31
34u32 sun4v_vdev_devhandle;
35struct device_node *sun4v_vdev_root;
36
37struct vdev_intmap {
38 unsigned int phys;
39 unsigned int irq;
40 unsigned int cnode;
41 unsigned int cinterrupt;
42};
43
44struct vdev_intmask {
45 unsigned int phys;
46 unsigned int interrupt;
47 unsigned int __unused;
48};
49
50static struct vdev_intmap *vdev_intmap;
51static int vdev_num_intmap;
52static struct vdev_intmask *vdev_intmask;
53
54static void __init sun4v_virtual_device_probe(void)
55{
56 struct linux_prom64_registers *regs;
57 struct property *prop;
58 struct device_node *dp;
59 int sz;
60
61 if (tlb_type != hypervisor)
62 return;
63
64 dp = of_find_node_by_name(NULL, "virtual-devices");
65 if (!dp) {
66 prom_printf("SUN4V: Fatal error, no virtual-devices node.\n");
67 prom_halt();
68 }
69
70 sun4v_vdev_root = dp;
71
72 prop = of_find_property(dp, "reg", NULL);
73 regs = prop->value;
74 sun4v_vdev_devhandle = (regs[0].phys_addr >> 32UL) & 0x0fffffff;
75
76 prop = of_find_property(dp, "interrupt-map", &sz);
77 vdev_intmap = prop->value;
78 vdev_num_intmap = sz / sizeof(struct vdev_intmap);
79
80 prop = of_find_property(dp, "interrupt-map-mask", NULL);
81 vdev_intmask = prop->value;
82
83 printk("%s: Virtual Device Bus devhandle[%x]\n",
84 dp->full_name, sun4v_vdev_devhandle);
85}
86
87unsigned int sun4v_vdev_device_interrupt(struct device_node *dev_node)
88{
89 struct property *prop;
90 unsigned int irq, reg;
91 int i;
92
93 prop = of_find_property(dev_node, "interrupts", NULL);
94 if (!prop) {
95 printk("VDEV: Cannot get \"interrupts\" "
96 "property for OBP node %s\n",
97 dev_node->full_name);
98 return 0;
99 }
100 irq = *(unsigned int *) prop->value;
101
102 prop = of_find_property(dev_node, "reg", NULL);
103 if (!prop) {
104 printk("VDEV: Cannot get \"reg\" "
105 "property for OBP node %s\n",
106 dev_node->full_name);
107 return 0;
108 }
109 reg = *(unsigned int *) prop->value;
110
111 for (i = 0; i < vdev_num_intmap; i++) {
112 if (vdev_intmap[i].phys == (reg & vdev_intmask->phys) &&
113 vdev_intmap[i].irq == (irq & vdev_intmask->interrupt)) {
114 irq = vdev_intmap[i].cinterrupt;
115 break;
116 }
117 }
118
119 if (i == vdev_num_intmap) {
120 printk("VDEV: No matching interrupt map entry "
121 "for OBP node %s\n", dev_node->full_name);
122 return 0;
123 }
124
125 return sun4v_build_irq(sun4v_vdev_devhandle, irq);
126}
127
128static const char *cpu_mid_prop(void) 32static const char *cpu_mid_prop(void)
129{ 33{
130 if (tlb_type == spitfire) 34 if (tlb_type == spitfire)
@@ -289,7 +193,6 @@ void __init device_scan(void)
289 } 193 }
290#endif 194#endif
291 195
292 sun4v_virtual_device_probe();
293 central_probe(); 196 central_probe();
294 197
295 cpu_probe(); 198 cpu_probe();
diff --git a/arch/sparc64/kernel/of_device.c b/arch/sparc64/kernel/of_device.c
index 3670dc8a7d5f..169b017eec0b 100644
--- a/arch/sparc64/kernel/of_device.c
+++ b/arch/sparc64/kernel/of_device.c
@@ -602,6 +602,9 @@ static void __init build_device_resources(struct of_device *op,
602 build_res: 602 build_res:
603 memset(r, 0, sizeof(*r)); 603 memset(r, 0, sizeof(*r));
604 if (result != OF_BAD_ADDR) { 604 if (result != OF_BAD_ADDR) {
605 if (tlb_type == hypervisor)
606 result &= 0x0fffffffffffffffUL;
607
605 r->start = result; 608 r->start = result;
606 r->end = result + size - 1; 609 r->end = result + size - 1;
607 r->flags = flags; 610 r->flags = flags;
diff --git a/arch/sparc64/kernel/prom.c b/arch/sparc64/kernel/prom.c
index 8a70c52c0447..fa484d4f241e 100644
--- a/arch/sparc64/kernel/prom.c
+++ b/arch/sparc64/kernel/prom.c
@@ -1008,6 +1008,27 @@ static struct irq_trans pci_irq_trans_table[] = {
1008}; 1008};
1009#endif 1009#endif
1010 1010
1011static unsigned int sun4v_vdev_irq_build(struct device_node *dp,
1012 unsigned int devino,
1013 void *_data)
1014{
1015 u32 devhandle = (u32) (unsigned long) _data;
1016
1017 return sun4v_build_irq(devhandle, devino);
1018}
1019
1020static void sun4v_vdev_irq_trans_init(struct device_node *dp)
1021{
1022 struct linux_prom64_registers *regs;
1023
1024 dp->irq_trans = prom_early_alloc(sizeof(struct of_irq_controller));
1025 dp->irq_trans->irq_build = sun4v_vdev_irq_build;
1026
1027 regs = of_get_property(dp, "reg", NULL);
1028 dp->irq_trans->data = (void *) (unsigned long)
1029 ((regs->phys_addr >> 32UL) & 0x0fffffff);
1030}
1031
1011static void irq_trans_init(struct device_node *dp) 1032static void irq_trans_init(struct device_node *dp)
1012{ 1033{
1013 const char *model; 1034 const char *model;
@@ -1034,6 +1055,8 @@ static void irq_trans_init(struct device_node *dp)
1034#endif 1055#endif
1035 if (!strcmp(dp->name, "central")) 1056 if (!strcmp(dp->name, "central"))
1036 return central_irq_trans_init(dp->child); 1057 return central_irq_trans_init(dp->child);
1058 if (!strcmp(dp->name, "virtual-devices"))
1059 return sun4v_vdev_irq_trans_init(dp);
1037} 1060}
1038 1061
1039static int is_root_node(const struct device_node *dp) 1062static int is_root_node(const struct device_node *dp)