aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-03-21 12:52:27 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-03-21 12:52:27 -0400
commit111f4268bd69cb040bf05038785cfbc4087f6341 (patch)
treed132d3296a7c44bb26659d698d0fdd4a05db1767
parenta44f99c7efdb88fa41128065c9a9445c19894e34 (diff)
parenta71f5d5d279375205009a4be56a3cf6682921292 (diff)
Merge branch 'merge' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc
* 'merge' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc: powerpc/ptrace: Remove BUG_ON when full register set not available powerpc: Factoring mpic cpu id fetching into a function powerpc: Make MPIC honor the "pic-no-reset" device tree property powerpc: Document the Open PIC device tree binding powerpc/pci: Fix crash in PCI code on ppc64 when matching device nodes
-rw-r--r--Documentation/devicetree/bindings/open-pic.txt98
-rw-r--r--arch/powerpc/include/asm/mpic.h4
-rw-r--r--arch/powerpc/include/asm/ptrace.h2
-rw-r--r--arch/powerpc/kernel/pci_dn.c7
-rw-r--r--arch/powerpc/kernel/ptrace.c15
-rw-r--r--arch/powerpc/sysdev/mpic.c85
6 files changed, 184 insertions, 27 deletions
diff --git a/Documentation/devicetree/bindings/open-pic.txt b/Documentation/devicetree/bindings/open-pic.txt
new file mode 100644
index 000000000000..909a902dff85
--- /dev/null
+++ b/Documentation/devicetree/bindings/open-pic.txt
@@ -0,0 +1,98 @@
1* Open PIC Binding
2
3This binding specifies what properties must be available in the device tree
4representation of an Open PIC compliant interrupt controller. This binding is
5based on the binding defined for Open PIC in [1] and is a superset of that
6binding.
7
8Required properties:
9
10 NOTE: Many of these descriptions were paraphrased here from [1] to aid
11 readability.
12
13 - compatible: Specifies the compatibility list for the PIC. The type
14 shall be <string> and the value shall include "open-pic".
15
16 - reg: Specifies the base physical address(s) and size(s) of this
17 PIC's addressable register space. The type shall be <prop-encoded-array>.
18
19 - interrupt-controller: The presence of this property identifies the node
20 as an Open PIC. No property value shall be defined.
21
22 - #interrupt-cells: Specifies the number of cells needed to encode an
23 interrupt source. The type shall be a <u32> and the value shall be 2.
24
25 - #address-cells: Specifies the number of cells needed to encode an
26 address. The type shall be <u32> and the value shall be 0. As such,
27 'interrupt-map' nodes do not have to specify a parent unit address.
28
29Optional properties:
30
31 - pic-no-reset: The presence of this property indicates that the PIC
32 shall not be reset during runtime initialization. No property value shall
33 be defined. The presence of this property also mandates that any
34 initialization related to interrupt sources shall be limited to sources
35 explicitly referenced in the device tree.
36
37* Interrupt Specifier Definition
38
39 Interrupt specifiers consists of 2 cells encoded as
40 follows:
41
42 - <1st-cell>: The interrupt-number that identifies the interrupt source.
43
44 - <2nd-cell>: The level-sense information, encoded as follows:
45 0 = low-to-high edge triggered
46 1 = active low level-sensitive
47 2 = active high level-sensitive
48 3 = high-to-low edge triggered
49
50* Examples
51
52Example 1:
53
54 /*
55 * An Open PIC interrupt controller
56 */
57 mpic: pic@40000 {
58 // This is an interrupt controller node.
59 interrupt-controller;
60
61 // No address cells so that 'interrupt-map' nodes which reference
62 // this Open PIC node do not need a parent address specifier.
63 #address-cells = <0>;
64
65 // Two cells to encode interrupt sources.
66 #interrupt-cells = <2>;
67
68 // Offset address of 0x40000 and size of 0x40000.
69 reg = <0x40000 0x40000>;
70
71 // Compatible with Open PIC.
72 compatible = "open-pic";
73
74 // The PIC shall not be reset.
75 pic-no-reset;
76 };
77
78Example 2:
79
80 /*
81 * An interrupt generating device that is wired to an Open PIC.
82 */
83 serial0: serial@4500 {
84 // Interrupt source '42' that is active high level-sensitive.
85 // Note that there are only two cells as specified in the interrupt
86 // parent's '#interrupt-cells' property.
87 interrupts = <42 2>;
88
89 // The interrupt controller that this device is wired to.
90 interrupt-parent = <&mpic>;
91 };
92
93* References
94
95[1] Power.org (TM) Standard for Embedded Power Architecture (TM) Platform
96 Requirements (ePAPR), Version 1.0, July 2008.
97 (http://www.power.org/resources/downloads/Power_ePAPR_APPROVED_v1.0.pdf)
98
diff --git a/arch/powerpc/include/asm/mpic.h b/arch/powerpc/include/asm/mpic.h
index 946ec4947da2..7005ee0b074d 100644
--- a/arch/powerpc/include/asm/mpic.h
+++ b/arch/powerpc/include/asm/mpic.h
@@ -367,6 +367,10 @@ struct mpic
367#define MPIC_SINGLE_DEST_CPU 0x00001000 367#define MPIC_SINGLE_DEST_CPU 0x00001000
368/* Enable CoreInt delivery of interrupts */ 368/* Enable CoreInt delivery of interrupts */
369#define MPIC_ENABLE_COREINT 0x00002000 369#define MPIC_ENABLE_COREINT 0x00002000
370/* Disable resetting of the MPIC.
371 * NOTE: This flag trumps MPIC_WANTS_RESET.
372 */
373#define MPIC_NO_RESET 0x00004000
370 374
371/* MPIC HW modification ID */ 375/* MPIC HW modification ID */
372#define MPIC_REGSET_MASK 0xf0000000 376#define MPIC_REGSET_MASK 0xf0000000
diff --git a/arch/powerpc/include/asm/ptrace.h b/arch/powerpc/include/asm/ptrace.h
index 0175a676b34b..48223f9b8728 100644
--- a/arch/powerpc/include/asm/ptrace.h
+++ b/arch/powerpc/include/asm/ptrace.h
@@ -125,8 +125,10 @@ extern int ptrace_put_reg(struct task_struct *task, int regno,
125#endif /* ! __powerpc64__ */ 125#endif /* ! __powerpc64__ */
126#define TRAP(regs) ((regs)->trap & ~0xF) 126#define TRAP(regs) ((regs)->trap & ~0xF)
127#ifdef __powerpc64__ 127#ifdef __powerpc64__
128#define NV_REG_POISON 0xdeadbeefdeadbeefUL
128#define CHECK_FULL_REGS(regs) BUG_ON(regs->trap & 1) 129#define CHECK_FULL_REGS(regs) BUG_ON(regs->trap & 1)
129#else 130#else
131#define NV_REG_POISON 0xdeadbeef
130#define CHECK_FULL_REGS(regs) \ 132#define CHECK_FULL_REGS(regs) \
131do { \ 133do { \
132 if ((regs)->trap & 1) \ 134 if ((regs)->trap & 1) \
diff --git a/arch/powerpc/kernel/pci_dn.c b/arch/powerpc/kernel/pci_dn.c
index 29852688ceaa..d225d99fe39d 100644
--- a/arch/powerpc/kernel/pci_dn.c
+++ b/arch/powerpc/kernel/pci_dn.c
@@ -176,11 +176,14 @@ static void *is_devfn_node(struct device_node *dn, void *data)
176 */ 176 */
177struct device_node *fetch_dev_dn(struct pci_dev *dev) 177struct device_node *fetch_dev_dn(struct pci_dev *dev)
178{ 178{
179 struct device_node *orig_dn = dev->dev.of_node; 179 struct pci_controller *phb = dev->sysdata;
180 struct device_node *dn; 180 struct device_node *dn;
181 unsigned long searchval = (dev->bus->number << 8) | dev->devfn; 181 unsigned long searchval = (dev->bus->number << 8) | dev->devfn;
182 182
183 dn = traverse_pci_devices(orig_dn, is_devfn_node, (void *)searchval); 183 if (WARN_ON(!phb))
184 return NULL;
185
186 dn = traverse_pci_devices(phb->dn, is_devfn_node, (void *)searchval);
184 if (dn) 187 if (dn)
185 dev->dev.of_node = dn; 188 dev->dev.of_node = dn;
186 return dn; 189 return dn;
diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
index 906536998291..895b082f1e48 100644
--- a/arch/powerpc/kernel/ptrace.c
+++ b/arch/powerpc/kernel/ptrace.c
@@ -229,12 +229,16 @@ static int gpr_get(struct task_struct *target, const struct user_regset *regset,
229 unsigned int pos, unsigned int count, 229 unsigned int pos, unsigned int count,
230 void *kbuf, void __user *ubuf) 230 void *kbuf, void __user *ubuf)
231{ 231{
232 int ret; 232 int i, ret;
233 233
234 if (target->thread.regs == NULL) 234 if (target->thread.regs == NULL)
235 return -EIO; 235 return -EIO;
236 236
237 CHECK_FULL_REGS(target->thread.regs); 237 if (!FULL_REGS(target->thread.regs)) {
238 /* We have a partial register set. Fill 14-31 with bogus values */
239 for (i = 14; i < 32; i++)
240 target->thread.regs->gpr[i] = NV_REG_POISON;
241 }
238 242
239 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, 243 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
240 target->thread.regs, 244 target->thread.regs,
@@ -641,11 +645,16 @@ static int gpr32_get(struct task_struct *target,
641 compat_ulong_t *k = kbuf; 645 compat_ulong_t *k = kbuf;
642 compat_ulong_t __user *u = ubuf; 646 compat_ulong_t __user *u = ubuf;
643 compat_ulong_t reg; 647 compat_ulong_t reg;
648 int i;
644 649
645 if (target->thread.regs == NULL) 650 if (target->thread.regs == NULL)
646 return -EIO; 651 return -EIO;
647 652
648 CHECK_FULL_REGS(target->thread.regs); 653 if (!FULL_REGS(target->thread.regs)) {
654 /* We have a partial register set. Fill 14-31 with bogus values */
655 for (i = 14; i < 32; i++)
656 target->thread.regs->gpr[i] = NV_REG_POISON;
657 }
649 658
650 pos /= sizeof(reg); 659 pos /= sizeof(reg);
651 count /= sizeof(reg); 660 count /= sizeof(reg);
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index eb7021815e2d..0f7c6718d261 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -147,6 +147,16 @@ static u32 mpic_infos[][MPIC_IDX_END] = {
147 147
148#endif /* CONFIG_MPIC_WEIRD */ 148#endif /* CONFIG_MPIC_WEIRD */
149 149
150static inline unsigned int mpic_processor_id(struct mpic *mpic)
151{
152 unsigned int cpu = 0;
153
154 if (mpic->flags & MPIC_PRIMARY)
155 cpu = hard_smp_processor_id();
156
157 return cpu;
158}
159
150/* 160/*
151 * Register accessor functions 161 * Register accessor functions
152 */ 162 */
@@ -210,19 +220,14 @@ static inline void _mpic_ipi_write(struct mpic *mpic, unsigned int ipi, u32 valu
210 220
211static inline u32 _mpic_cpu_read(struct mpic *mpic, unsigned int reg) 221static inline u32 _mpic_cpu_read(struct mpic *mpic, unsigned int reg)
212{ 222{
213 unsigned int cpu = 0; 223 unsigned int cpu = mpic_processor_id(mpic);
214 224
215 if (mpic->flags & MPIC_PRIMARY)
216 cpu = hard_smp_processor_id();
217 return _mpic_read(mpic->reg_type, &mpic->cpuregs[cpu], reg); 225 return _mpic_read(mpic->reg_type, &mpic->cpuregs[cpu], reg);
218} 226}
219 227
220static inline void _mpic_cpu_write(struct mpic *mpic, unsigned int reg, u32 value) 228static inline void _mpic_cpu_write(struct mpic *mpic, unsigned int reg, u32 value)
221{ 229{
222 unsigned int cpu = 0; 230 unsigned int cpu = mpic_processor_id(mpic);
223
224 if (mpic->flags & MPIC_PRIMARY)
225 cpu = hard_smp_processor_id();
226 231
227 _mpic_write(mpic->reg_type, &mpic->cpuregs[cpu], reg, value); 232 _mpic_write(mpic->reg_type, &mpic->cpuregs[cpu], reg, value);
228} 233}
@@ -913,6 +918,20 @@ void mpic_set_vector(unsigned int virq, unsigned int vector)
913 mpic_irq_write(src, MPIC_INFO(IRQ_VECTOR_PRI), vecpri); 918 mpic_irq_write(src, MPIC_INFO(IRQ_VECTOR_PRI), vecpri);
914} 919}
915 920
921void mpic_set_destination(unsigned int virq, unsigned int cpuid)
922{
923 struct mpic *mpic = mpic_from_irq(virq);
924 unsigned int src = mpic_irq_to_hw(virq);
925
926 DBG("mpic: set_destination(mpic:@%p,virq:%d,src:%d,cpuid:0x%x)\n",
927 mpic, virq, src, cpuid);
928
929 if (src >= mpic->irq_count)
930 return;
931
932 mpic_irq_write(src, MPIC_INFO(IRQ_DESTINATION), 1 << cpuid);
933}
934
916static struct irq_chip mpic_irq_chip = { 935static struct irq_chip mpic_irq_chip = {
917 .irq_mask = mpic_mask_irq, 936 .irq_mask = mpic_mask_irq,
918 .irq_unmask = mpic_unmask_irq, 937 .irq_unmask = mpic_unmask_irq,
@@ -993,6 +1012,16 @@ static int mpic_host_map(struct irq_host *h, unsigned int virq,
993 /* Set default irq type */ 1012 /* Set default irq type */
994 set_irq_type(virq, IRQ_TYPE_NONE); 1013 set_irq_type(virq, IRQ_TYPE_NONE);
995 1014
1015 /* If the MPIC was reset, then all vectors have already been
1016 * initialized. Otherwise, a per source lazy initialization
1017 * is done here.
1018 */
1019 if (!mpic_is_ipi(mpic, hw) && (mpic->flags & MPIC_NO_RESET)) {
1020 mpic_set_vector(virq, hw);
1021 mpic_set_destination(virq, mpic_processor_id(mpic));
1022 mpic_irq_set_priority(virq, 8);
1023 }
1024
996 return 0; 1025 return 0;
997} 1026}
998 1027
@@ -1040,6 +1069,11 @@ static struct irq_host_ops mpic_host_ops = {
1040 .xlate = mpic_host_xlate, 1069 .xlate = mpic_host_xlate,
1041}; 1070};
1042 1071
1072static int mpic_reset_prohibited(struct device_node *node)
1073{
1074 return node && of_get_property(node, "pic-no-reset", NULL);
1075}
1076
1043/* 1077/*
1044 * Exported functions 1078 * Exported functions
1045 */ 1079 */
@@ -1160,7 +1194,15 @@ struct mpic * __init mpic_alloc(struct device_node *node,
1160 mpic_map(mpic, node, paddr, &mpic->tmregs, MPIC_INFO(TIMER_BASE), 0x1000); 1194 mpic_map(mpic, node, paddr, &mpic->tmregs, MPIC_INFO(TIMER_BASE), 0x1000);
1161 1195
1162 /* Reset */ 1196 /* Reset */
1163 if (flags & MPIC_WANTS_RESET) { 1197
1198 /* When using a device-node, reset requests are only honored if the MPIC
1199 * is allowed to reset.
1200 */
1201 if (mpic_reset_prohibited(node))
1202 mpic->flags |= MPIC_NO_RESET;
1203
1204 if ((flags & MPIC_WANTS_RESET) && !(mpic->flags & MPIC_NO_RESET)) {
1205 printk(KERN_DEBUG "mpic: Resetting\n");
1164 mpic_write(mpic->gregs, MPIC_INFO(GREG_GLOBAL_CONF_0), 1206 mpic_write(mpic->gregs, MPIC_INFO(GREG_GLOBAL_CONF_0),
1165 mpic_read(mpic->gregs, MPIC_INFO(GREG_GLOBAL_CONF_0)) 1207 mpic_read(mpic->gregs, MPIC_INFO(GREG_GLOBAL_CONF_0))
1166 | MPIC_GREG_GCONF_RESET); 1208 | MPIC_GREG_GCONF_RESET);
@@ -1320,22 +1362,21 @@ void __init mpic_init(struct mpic *mpic)
1320 1362
1321 mpic_pasemi_msi_init(mpic); 1363 mpic_pasemi_msi_init(mpic);
1322 1364
1323 if (mpic->flags & MPIC_PRIMARY) 1365 cpu = mpic_processor_id(mpic);
1324 cpu = hard_smp_processor_id();
1325 else
1326 cpu = 0;
1327 1366
1328 for (i = 0; i < mpic->num_sources; i++) { 1367 if (!(mpic->flags & MPIC_NO_RESET)) {
1329 /* start with vector = source number, and masked */ 1368 for (i = 0; i < mpic->num_sources; i++) {
1330 u32 vecpri = MPIC_VECPRI_MASK | i | 1369 /* start with vector = source number, and masked */
1331 (8 << MPIC_VECPRI_PRIORITY_SHIFT); 1370 u32 vecpri = MPIC_VECPRI_MASK | i |
1371 (8 << MPIC_VECPRI_PRIORITY_SHIFT);
1332 1372
1333 /* check if protected */ 1373 /* check if protected */
1334 if (mpic->protected && test_bit(i, mpic->protected)) 1374 if (mpic->protected && test_bit(i, mpic->protected))
1335 continue; 1375 continue;
1336 /* init hw */ 1376 /* init hw */
1337 mpic_irq_write(i, MPIC_INFO(IRQ_VECTOR_PRI), vecpri); 1377 mpic_irq_write(i, MPIC_INFO(IRQ_VECTOR_PRI), vecpri);
1338 mpic_irq_write(i, MPIC_INFO(IRQ_DESTINATION), 1 << cpu); 1378 mpic_irq_write(i, MPIC_INFO(IRQ_DESTINATION), 1 << cpu);
1379 }
1339 } 1380 }
1340 1381
1341 /* Init spurious vector */ 1382 /* Init spurious vector */