aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc')
-rw-r--r--arch/powerpc/Kconfig13
-rw-r--r--arch/powerpc/Kconfig.debug1
-rw-r--r--arch/powerpc/boot/dts/mpc8641_hpcn.dts12
-rw-r--r--arch/powerpc/configs/g5_defconfig1
-rw-r--r--arch/powerpc/kernel/Makefile1
-rw-r--r--arch/powerpc/kernel/asm-offsets.c1
-rw-r--r--arch/powerpc/kernel/entry_32.S5
-rw-r--r--arch/powerpc/kernel/head_64.S11
-rw-r--r--arch/powerpc/kernel/irq.c10
-rw-r--r--arch/powerpc/kernel/misc_32.S25
-rw-r--r--arch/powerpc/kernel/process.c2
-rw-r--r--arch/powerpc/kernel/rio.c52
-rw-r--r--arch/powerpc/kernel/setup_32.c21
-rw-r--r--arch/powerpc/mm/mem.c30
-rw-r--r--arch/powerpc/platforms/86xx/Kconfig1
-rw-r--r--arch/powerpc/platforms/86xx/mpc86xx_hpcn.c1
-rw-r--r--arch/powerpc/platforms/powermac/Makefile5
-rw-r--r--arch/powerpc/platforms/powermac/setup.c3
-rw-r--r--arch/powerpc/platforms/pseries/Makefile1
-rw-r--r--arch/powerpc/platforms/pseries/hotplug-memory.c141
-rw-r--r--arch/powerpc/sysdev/fsl_rio.c711
-rw-r--r--arch/powerpc/sysdev/fsl_rio.h20
22 files changed, 762 insertions, 306 deletions
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 4e40c122bf26..3934e2659407 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -608,6 +608,19 @@ source "drivers/pcmcia/Kconfig"
608 608
609source "drivers/pci/hotplug/Kconfig" 609source "drivers/pci/hotplug/Kconfig"
610 610
611config HAS_RAPIDIO
612 bool
613 default n
614
615config RAPIDIO
616 bool "RapidIO support"
617 depends on HAS_RAPIDIO
618 help
619 If you say Y here, the kernel will include drivers and
620 infrastructure code to support RapidIO interconnect devices.
621
622source "drivers/rapidio/Kconfig"
623
611endmenu 624endmenu
612 625
613menu "Advanced setup" 626menu "Advanced setup"
diff --git a/arch/powerpc/Kconfig.debug b/arch/powerpc/Kconfig.debug
index 807a2dce6263..a7d24e692bab 100644
--- a/arch/powerpc/Kconfig.debug
+++ b/arch/powerpc/Kconfig.debug
@@ -118,7 +118,6 @@ config XMON_DISASSEMBLY
118 118
119config IRQSTACKS 119config IRQSTACKS
120 bool "Use separate kernel stacks when processing interrupts" 120 bool "Use separate kernel stacks when processing interrupts"
121 depends on PPC64
122 help 121 help
123 If you say Y here the kernel will use separate kernel stacks 122 If you say Y here the kernel will use separate kernel stacks
124 for handling hard and soft interrupts. This can help avoid 123 for handling hard and soft interrupts. This can help avoid
diff --git a/arch/powerpc/boot/dts/mpc8641_hpcn.dts b/arch/powerpc/boot/dts/mpc8641_hpcn.dts
index 7f9b999843ce..1e4bfe9cadb9 100644
--- a/arch/powerpc/boot/dts/mpc8641_hpcn.dts
+++ b/arch/powerpc/boot/dts/mpc8641_hpcn.dts
@@ -26,6 +26,7 @@
26 serial1 = &serial1; 26 serial1 = &serial1;
27 pci0 = &pci0; 27 pci0 = &pci0;
28 pci1 = &pci1; 28 pci1 = &pci1;
29 rapidio0 = &rapidio0;
29 }; 30 };
30 31
31 cpus { 32 cpus {
@@ -500,4 +501,15 @@
500 0x0 0x00100000>; 501 0x0 0x00100000>;
501 }; 502 };
502 }; 503 };
504 rapidio0: rapidio@f80c0000 {
505 #address-cells = <2>;
506 #size-cells = <2>;
507 compatible = "fsl,rapidio-delta";
508 reg = <0xf80c0000 0x20000>;
509 ranges = <0 0 0xc0000000 0 0x20000000>;
510 interrupt-parent = <&mpic>;
511 /* err_irq bell_outb_irq bell_inb_irq
512 msg1_tx_irq msg1_rx_irq msg2_tx_irq msg2_rx_irq */
513 interrupts = <48 2 49 2 50 2 53 2 54 2 55 2 56 2>;
514 };
503}; 515};
diff --git a/arch/powerpc/configs/g5_defconfig b/arch/powerpc/configs/g5_defconfig
index a20501f89474..88338a9f5e95 100644
--- a/arch/powerpc/configs/g5_defconfig
+++ b/arch/powerpc/configs/g5_defconfig
@@ -696,6 +696,7 @@ CONFIG_WINDFARM=y
696CONFIG_WINDFARM_PM81=y 696CONFIG_WINDFARM_PM81=y
697CONFIG_WINDFARM_PM91=y 697CONFIG_WINDFARM_PM91=y
698CONFIG_WINDFARM_PM112=y 698CONFIG_WINDFARM_PM112=y
699CONFIG_WINDFARM_PM121=y
699# CONFIG_PMAC_RACKMETER is not set 700# CONFIG_PMAC_RACKMETER is not set
700CONFIG_NETDEVICES=y 701CONFIG_NETDEVICES=y
701# CONFIG_NETDEVICES_MULTIQUEUE is not set 702# CONFIG_NETDEVICES_MULTIQUEUE is not set
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 9177b21b1a95..d14cebf62bb0 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -73,7 +73,6 @@ pci64-$(CONFIG_PPC64) += pci_dn.o isa-bridge.o
73obj-$(CONFIG_PCI) += pci_$(CONFIG_WORD_SIZE).o $(pci64-y) \ 73obj-$(CONFIG_PCI) += pci_$(CONFIG_WORD_SIZE).o $(pci64-y) \
74 pci-common.o 74 pci-common.o
75obj-$(CONFIG_PCI_MSI) += msi.o 75obj-$(CONFIG_PCI_MSI) += msi.o
76obj-$(CONFIG_RAPIDIO) += rio.o
77obj-$(CONFIG_KEXEC) += machine_kexec.o crash.o \ 76obj-$(CONFIG_KEXEC) += machine_kexec.o crash.o \
78 machine_kexec_$(CONFIG_WORD_SIZE).o 77 machine_kexec_$(CONFIG_WORD_SIZE).o
79obj-$(CONFIG_AUDIT) += audit.o 78obj-$(CONFIG_AUDIT) += audit.o
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
index 59044e7ed6f4..ec9228d687b0 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -63,6 +63,7 @@ int main(void)
63#endif /* CONFIG_PPC64 */ 63#endif /* CONFIG_PPC64 */
64 64
65 DEFINE(KSP, offsetof(struct thread_struct, ksp)); 65 DEFINE(KSP, offsetof(struct thread_struct, ksp));
66 DEFINE(KSP_LIMIT, offsetof(struct thread_struct, ksp_limit));
66 DEFINE(PT_REGS, offsetof(struct thread_struct, regs)); 67 DEFINE(PT_REGS, offsetof(struct thread_struct, regs));
67 DEFINE(THREAD_FPEXC_MODE, offsetof(struct thread_struct, fpexc_mode)); 68 DEFINE(THREAD_FPEXC_MODE, offsetof(struct thread_struct, fpexc_mode));
68 DEFINE(THREAD_FPR0, offsetof(struct thread_struct, fpr[0])); 69 DEFINE(THREAD_FPR0, offsetof(struct thread_struct, fpr[0]));
diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index 84c868633068..0c8614d9875c 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -137,11 +137,12 @@ transfer_to_handler:
1372: /* if from kernel, check interrupted DOZE/NAP mode and 1372: /* if from kernel, check interrupted DOZE/NAP mode and
138 * check for stack overflow 138 * check for stack overflow
139 */ 139 */
140 lwz r9,THREAD_INFO-THREAD(r12) 140 lwz r9,KSP_LIMIT(r12)
141 cmplw r1,r9 /* if r1 <= current->thread_info */ 141 cmplw r1,r9 /* if r1 <= ksp_limit */
142 ble- stack_ovf /* then the kernel stack overflowed */ 142 ble- stack_ovf /* then the kernel stack overflowed */
1435: 1435:
144#ifdef CONFIG_6xx 144#ifdef CONFIG_6xx
145 rlwinm r9,r1,0,0,31-THREAD_SHIFT
145 tophys(r9,r9) /* check local flags */ 146 tophys(r9,r9) /* check local flags */
146 lwz r12,TI_LOCAL_FLAGS(r9) 147 lwz r12,TI_LOCAL_FLAGS(r9)
147 mtcrf 0x01,r12 148 mtcrf 0x01,r12
diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
index 215973a2c8d5..024805e1747d 100644
--- a/arch/powerpc/kernel/head_64.S
+++ b/arch/powerpc/kernel/head_64.S
@@ -239,6 +239,10 @@ instruction_access_slb_pSeries:
239 .globl system_call_pSeries 239 .globl system_call_pSeries
240system_call_pSeries: 240system_call_pSeries:
241 HMT_MEDIUM 241 HMT_MEDIUM
242BEGIN_FTR_SECTION
243 cmpdi r0,0x1ebe
244 beq- 1f
245END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE)
242 mr r9,r13 246 mr r9,r13
243 mfmsr r10 247 mfmsr r10
244 mfspr r13,SPRN_SPRG3 248 mfspr r13,SPRN_SPRG3
@@ -253,6 +257,13 @@ system_call_pSeries:
253 rfid 257 rfid
254 b . /* prevent speculative execution */ 258 b . /* prevent speculative execution */
255 259
260/* Fast LE/BE switch system call */
2611: mfspr r12,SPRN_SRR1
262 xori r12,r12,MSR_LE
263 mtspr SPRN_SRR1,r12
264 rfid /* return to userspace */
265 b .
266
256 STD_EXCEPTION_PSERIES(0xd00, single_step) 267 STD_EXCEPTION_PSERIES(0xd00, single_step)
257 STD_EXCEPTION_PSERIES(0xe00, trap_0e) 268 STD_EXCEPTION_PSERIES(0xe00, trap_0e)
258 269
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index 425616f92d18..2f73f705d564 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -307,6 +307,7 @@ void do_IRQ(struct pt_regs *regs)
307 if (curtp != irqtp) { 307 if (curtp != irqtp) {
308 struct irq_desc *desc = irq_desc + irq; 308 struct irq_desc *desc = irq_desc + irq;
309 void *handler = desc->handle_irq; 309 void *handler = desc->handle_irq;
310 unsigned long saved_sp_limit = current->thread.ksp_limit;
310 if (handler == NULL) 311 if (handler == NULL)
311 handler = &__do_IRQ; 312 handler = &__do_IRQ;
312 irqtp->task = curtp->task; 313 irqtp->task = curtp->task;
@@ -319,7 +320,10 @@ void do_IRQ(struct pt_regs *regs)
319 (irqtp->preempt_count & ~SOFTIRQ_MASK) | 320 (irqtp->preempt_count & ~SOFTIRQ_MASK) |
320 (curtp->preempt_count & SOFTIRQ_MASK); 321 (curtp->preempt_count & SOFTIRQ_MASK);
321 322
323 current->thread.ksp_limit = (unsigned long)irqtp +
324 _ALIGN_UP(sizeof(struct thread_info), 16);
322 call_handle_irq(irq, desc, irqtp, handler); 325 call_handle_irq(irq, desc, irqtp, handler);
326 current->thread.ksp_limit = saved_sp_limit;
323 irqtp->task = NULL; 327 irqtp->task = NULL;
324 328
325 329
@@ -352,9 +356,7 @@ void __init init_IRQ(void)
352{ 356{
353 if (ppc_md.init_IRQ) 357 if (ppc_md.init_IRQ)
354 ppc_md.init_IRQ(); 358 ppc_md.init_IRQ();
355#ifdef CONFIG_PPC64
356 irq_ctx_init(); 359 irq_ctx_init();
357#endif
358} 360}
359 361
360 362
@@ -383,11 +385,15 @@ void irq_ctx_init(void)
383static inline void do_softirq_onstack(void) 385static inline void do_softirq_onstack(void)
384{ 386{
385 struct thread_info *curtp, *irqtp; 387 struct thread_info *curtp, *irqtp;
388 unsigned long saved_sp_limit = current->thread.ksp_limit;
386 389
387 curtp = current_thread_info(); 390 curtp = current_thread_info();
388 irqtp = softirq_ctx[smp_processor_id()]; 391 irqtp = softirq_ctx[smp_processor_id()];
389 irqtp->task = curtp->task; 392 irqtp->task = curtp->task;
393 current->thread.ksp_limit = (unsigned long)irqtp +
394 _ALIGN_UP(sizeof(struct thread_info), 16);
390 call_do_softirq(irqtp); 395 call_do_softirq(irqtp);
396 current->thread.ksp_limit = saved_sp_limit;
391 irqtp->task = NULL; 397 irqtp->task = NULL;
392} 398}
393 399
diff --git a/arch/powerpc/kernel/misc_32.S b/arch/powerpc/kernel/misc_32.S
index 92ccc6fcc5b0..89aaaa6f3561 100644
--- a/arch/powerpc/kernel/misc_32.S
+++ b/arch/powerpc/kernel/misc_32.S
@@ -32,6 +32,31 @@
32 32
33 .text 33 .text
34 34
35#ifdef CONFIG_IRQSTACKS
36_GLOBAL(call_do_softirq)
37 mflr r0
38 stw r0,4(r1)
39 stwu r1,THREAD_SIZE-STACK_FRAME_OVERHEAD(r3)
40 mr r1,r3
41 bl __do_softirq
42 lwz r1,0(r1)
43 lwz r0,4(r1)
44 mtlr r0
45 blr
46
47_GLOBAL(call_handle_irq)
48 mflr r0
49 stw r0,4(r1)
50 mtctr r6
51 stwu r1,THREAD_SIZE-STACK_FRAME_OVERHEAD(r5)
52 mr r1,r5
53 bctrl
54 lwz r1,0(r1)
55 lwz r0,4(r1)
56 mtlr r0
57 blr
58#endif /* CONFIG_IRQSTACKS */
59
35/* 60/*
36 * This returns the high 64 bits of the product of two 64-bit numbers. 61 * This returns the high 64 bits of the product of two 64-bit numbers.
37 */ 62 */
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 6caad17ea72e..7de41c3948ec 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -589,6 +589,8 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
589 kregs = (struct pt_regs *) sp; 589 kregs = (struct pt_regs *) sp;
590 sp -= STACK_FRAME_OVERHEAD; 590 sp -= STACK_FRAME_OVERHEAD;
591 p->thread.ksp = sp; 591 p->thread.ksp = sp;
592 p->thread.ksp_limit = (unsigned long)task_stack_page(p) +
593 _ALIGN_UP(sizeof(struct thread_info), 16);
592 594
593#ifdef CONFIG_PPC64 595#ifdef CONFIG_PPC64
594 if (cpu_has_feature(CPU_FTR_SLB)) { 596 if (cpu_has_feature(CPU_FTR_SLB)) {
diff --git a/arch/powerpc/kernel/rio.c b/arch/powerpc/kernel/rio.c
deleted file mode 100644
index 29487fedfc76..000000000000
--- a/arch/powerpc/kernel/rio.c
+++ /dev/null
@@ -1,52 +0,0 @@
1/*
2 * RapidIO PPC32 support
3 *
4 * Copyright 2005 MontaVista Software, Inc.
5 * Matt Porter <mporter@kernel.crashing.org>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 */
12
13#include <linux/init.h>
14#include <linux/kernel.h>
15#include <linux/rio.h>
16
17#include <asm/rio.h>
18
19/**
20 * platform_rio_init - Do platform specific RIO init
21 *
22 * Any platform specific initialization of RapdIO
23 * hardware is done here as well as registration
24 * of any active master ports in the system.
25 */
26void __attribute__ ((weak))
27 platform_rio_init(void)
28{
29 printk(KERN_WARNING "RIO: No platform_rio_init() present\n");
30}
31
32/**
33 * ppc_rio_init - Do PPC32 RIO init
34 *
35 * Calls platform-specific RIO init code and then calls
36 * rio_init_mports() to initialize any master ports that
37 * have been registered with the RIO subsystem.
38 */
39static int __init ppc_rio_init(void)
40{
41 printk(KERN_INFO "RIO: RapidIO init\n");
42
43 /* Platform specific initialization */
44 platform_rio_init();
45
46 /* Enumerate all registered ports */
47 rio_init_mports();
48
49 return 0;
50}
51
52subsys_initcall(ppc_rio_init);
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
index 36f6779c88d4..5112a4aa801d 100644
--- a/arch/powerpc/kernel/setup_32.c
+++ b/arch/powerpc/kernel/setup_32.c
@@ -16,6 +16,7 @@
16#include <linux/root_dev.h> 16#include <linux/root_dev.h>
17#include <linux/cpu.h> 17#include <linux/cpu.h>
18#include <linux/console.h> 18#include <linux/console.h>
19#include <linux/lmb.h>
19 20
20#include <asm/io.h> 21#include <asm/io.h>
21#include <asm/prom.h> 22#include <asm/prom.h>
@@ -229,6 +230,24 @@ int __init ppc_init(void)
229 230
230arch_initcall(ppc_init); 231arch_initcall(ppc_init);
231 232
233#ifdef CONFIG_IRQSTACKS
234static void __init irqstack_early_init(void)
235{
236 unsigned int i;
237
238 /* interrupt stacks must be in lowmem, we get that for free on ppc32
239 * as the lmb is limited to lowmem by LMB_REAL_LIMIT */
240 for_each_possible_cpu(i) {
241 softirq_ctx[i] = (struct thread_info *)
242 __va(lmb_alloc(THREAD_SIZE, THREAD_SIZE));
243 hardirq_ctx[i] = (struct thread_info *)
244 __va(lmb_alloc(THREAD_SIZE, THREAD_SIZE));
245 }
246}
247#else
248#define irqstack_early_init()
249#endif
250
232/* Warning, IO base is not yet inited */ 251/* Warning, IO base is not yet inited */
233void __init setup_arch(char **cmdline_p) 252void __init setup_arch(char **cmdline_p)
234{ 253{
@@ -286,6 +305,8 @@ void __init setup_arch(char **cmdline_p)
286 init_mm.end_data = (unsigned long) _edata; 305 init_mm.end_data = (unsigned long) _edata;
287 init_mm.brk = klimit; 306 init_mm.brk = klimit;
288 307
308 irqstack_early_init();
309
289 /* set up the bootmem stuff with available memory */ 310 /* set up the bootmem stuff with available memory */
290 do_init_bootmem(); 311 do_init_bootmem();
291 if ( ppc_md.progress ) ppc_md.progress("setup_arch: bootmem", 0x3eab); 312 if ( ppc_md.progress ) ppc_md.progress("setup_arch: bootmem", 0x3eab);
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index d9e37f365b54..f67e118116fa 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -154,19 +154,35 @@ out:
154 154
155/* 155/*
156 * walk_memory_resource() needs to make sure there is no holes in a given 156 * walk_memory_resource() needs to make sure there is no holes in a given
157 * memory range. On PPC64, since this range comes from /sysfs, the range 157 * memory range. PPC64 does not maintain the memory layout in /proc/iomem.
158 * is guaranteed to be valid, non-overlapping and can not contain any 158 * Instead it maintains it in lmb.memory structures. Walk through the
159 * holes. By the time we get here (memory add or remove), /proc/device-tree 159 * memory regions, find holes and callback for contiguous regions.
160 * is updated and correct. Only reason we need to check against device-tree
161 * would be if we allow user-land to specify a memory range through a
162 * system call/ioctl etc. instead of doing offline/online through /sysfs.
163 */ 160 */
164int 161int
165walk_memory_resource(unsigned long start_pfn, unsigned long nr_pages, void *arg, 162walk_memory_resource(unsigned long start_pfn, unsigned long nr_pages, void *arg,
166 int (*func)(unsigned long, unsigned long, void *)) 163 int (*func)(unsigned long, unsigned long, void *))
167{ 164{
168 return (*func)(start_pfn, nr_pages, arg); 165 struct lmb_property res;
166 unsigned long pfn, len;
167 u64 end;
168 int ret = -1;
169
170 res.base = (u64) start_pfn << PAGE_SHIFT;
171 res.size = (u64) nr_pages << PAGE_SHIFT;
172
173 end = res.base + res.size - 1;
174 while ((res.base < end) && (lmb_find(&res) >= 0)) {
175 pfn = (unsigned long)(res.base >> PAGE_SHIFT);
176 len = (unsigned long)(res.size >> PAGE_SHIFT);
177 ret = (*func)(pfn, len, arg);
178 if (ret)
179 break;
180 res.base += (res.size + 1);
181 res.size = (end - res.base + 1);
182 }
183 return ret;
169} 184}
185EXPORT_SYMBOL_GPL(walk_memory_resource);
170 186
171#endif /* CONFIG_MEMORY_HOTPLUG */ 187#endif /* CONFIG_MEMORY_HOTPLUG */
172 188
diff --git a/arch/powerpc/platforms/86xx/Kconfig b/arch/powerpc/platforms/86xx/Kconfig
index 7442c58d44f5..053f49a1dcae 100644
--- a/arch/powerpc/platforms/86xx/Kconfig
+++ b/arch/powerpc/platforms/86xx/Kconfig
@@ -8,6 +8,7 @@ config MPC8641_HPCN
8 select PPC_I8259 8 select PPC_I8259
9 select DEFAULT_UIMAGE 9 select DEFAULT_UIMAGE
10 select FSL_ULI1575 10 select FSL_ULI1575
11 select HAS_RAPIDIO
11 help 12 help
12 This option enables support for the MPC8641 HPCN board. 13 This option enables support for the MPC8641 HPCN board.
13 14
diff --git a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
index f947f555fd46..f13704aabbea 100644
--- a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
+++ b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
@@ -221,6 +221,7 @@ mpc86xx_time_init(void)
221 221
222static __initdata struct of_device_id of_bus_ids[] = { 222static __initdata struct of_device_id of_bus_ids[] = {
223 { .compatible = "simple-bus", }, 223 { .compatible = "simple-bus", },
224 { .compatible = "fsl,rapidio-delta", },
224 {}, 225 {},
225}; 226};
226 227
diff --git a/arch/powerpc/platforms/powermac/Makefile b/arch/powerpc/platforms/powermac/Makefile
index 78093d7f97af..4d72c8f72159 100644
--- a/arch/powerpc/platforms/powermac/Makefile
+++ b/arch/powerpc/platforms/powermac/Makefile
@@ -6,7 +6,10 @@ obj-y += pic.o setup.o time.o feature.o pci.o \
6obj-$(CONFIG_PMAC_BACKLIGHT) += backlight.o 6obj-$(CONFIG_PMAC_BACKLIGHT) += backlight.o
7obj-$(CONFIG_CPU_FREQ_PMAC) += cpufreq_32.o 7obj-$(CONFIG_CPU_FREQ_PMAC) += cpufreq_32.o
8obj-$(CONFIG_CPU_FREQ_PMAC64) += cpufreq_64.o 8obj-$(CONFIG_CPU_FREQ_PMAC64) += cpufreq_64.o
9obj-$(CONFIG_NVRAM) += nvram.o 9# CONFIG_NVRAM is an arch. independant tristate symbol, for pmac32 we really
10# need this to be a bool. Cheat here and pretend CONFIG_NVRAM=m is really
11# CONFIG_NVRAM=y
12obj-$(CONFIG_NVRAM:m=y) += nvram.o
10# ppc64 pmac doesn't define CONFIG_NVRAM but needs nvram stuff 13# ppc64 pmac doesn't define CONFIG_NVRAM but needs nvram stuff
11obj-$(CONFIG_PPC64) += nvram.o 14obj-$(CONFIG_PPC64) += nvram.o
12obj-$(CONFIG_PPC32) += bootx_init.o 15obj-$(CONFIG_PPC32) += bootx_init.o
diff --git a/arch/powerpc/platforms/powermac/setup.c b/arch/powerpc/platforms/powermac/setup.c
index bf44c5441a36..00bd0166d07f 100644
--- a/arch/powerpc/platforms/powermac/setup.c
+++ b/arch/powerpc/platforms/powermac/setup.c
@@ -337,7 +337,8 @@ static void __init pmac_setup_arch(void)
337 find_via_pmu(); 337 find_via_pmu();
338 smu_init(); 338 smu_init();
339 339
340#if defined(CONFIG_NVRAM) || defined(CONFIG_PPC64) 340#if defined(CONFIG_NVRAM) || defined(CONFIG_NVRAM_MODULE) || \
341 defined(CONFIG_PPC64)
341 pmac_nvram_init(); 342 pmac_nvram_init();
342#endif 343#endif
343 344
diff --git a/arch/powerpc/platforms/pseries/Makefile b/arch/powerpc/platforms/pseries/Makefile
index bd2593ed28dd..554c6e42ef2a 100644
--- a/arch/powerpc/platforms/pseries/Makefile
+++ b/arch/powerpc/platforms/pseries/Makefile
@@ -18,6 +18,7 @@ obj-$(CONFIG_PCI) += pci.o pci_dlpar.o
18obj-$(CONFIG_PCI_MSI) += msi.o 18obj-$(CONFIG_PCI_MSI) += msi.o
19 19
20obj-$(CONFIG_HOTPLUG_CPU) += hotplug-cpu.o 20obj-$(CONFIG_HOTPLUG_CPU) += hotplug-cpu.o
21obj-$(CONFIG_MEMORY_HOTPLUG) += hotplug-memory.o
21 22
22obj-$(CONFIG_HVC_CONSOLE) += hvconsole.o 23obj-$(CONFIG_HVC_CONSOLE) += hvconsole.o
23obj-$(CONFIG_HVCS) += hvcserver.o 24obj-$(CONFIG_HVCS) += hvcserver.o
diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c
new file mode 100644
index 000000000000..3c5727dd5aa5
--- /dev/null
+++ b/arch/powerpc/platforms/pseries/hotplug-memory.c
@@ -0,0 +1,141 @@
1/*
2 * pseries Memory Hotplug infrastructure.
3 *
4 * Copyright (C) 2008 Badari Pulavarty, IBM Corporation
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#include <linux/of.h>
13#include <linux/lmb.h>
14#include <asm/firmware.h>
15#include <asm/machdep.h>
16#include <asm/pSeries_reconfig.h>
17
18static int pseries_remove_memory(struct device_node *np)
19{
20 const char *type;
21 const unsigned int *my_index;
22 const unsigned int *regs;
23 u64 start_pfn, start;
24 struct zone *zone;
25 int ret = -EINVAL;
26
27 /*
28 * Check to see if we are actually removing memory
29 */
30 type = of_get_property(np, "device_type", NULL);
31 if (type == NULL || strcmp(type, "memory") != 0)
32 return 0;
33
34 /*
35 * Find the memory index and size of the removing section
36 */
37 my_index = of_get_property(np, "ibm,my-drc-index", NULL);
38 if (!my_index)
39 return ret;
40
41 regs = of_get_property(np, "reg", NULL);
42 if (!regs)
43 return ret;
44
45 start_pfn = section_nr_to_pfn(*my_index & 0xffff);
46 zone = page_zone(pfn_to_page(start_pfn));
47
48 /*
49 * Remove section mappings and sysfs entries for the
50 * section of the memory we are removing.
51 *
52 * NOTE: Ideally, this should be done in generic code like
53 * remove_memory(). But remove_memory() gets called by writing
54 * to sysfs "state" file and we can't remove sysfs entries
55 * while writing to it. So we have to defer it to here.
56 */
57 ret = __remove_pages(zone, start_pfn, regs[3] >> PAGE_SHIFT);
58 if (ret)
59 return ret;
60
61 /*
62 * Update memory regions for memory remove
63 */
64 lmb_remove(start_pfn << PAGE_SHIFT, regs[3]);
65
66 /*
67 * Remove htab bolted mappings for this section of memory
68 */
69 start = (unsigned long)__va(start_pfn << PAGE_SHIFT);
70 ret = remove_section_mapping(start, start + regs[3]);
71 return ret;
72}
73
74static int pseries_add_memory(struct device_node *np)
75{
76 const char *type;
77 const unsigned int *my_index;
78 const unsigned int *regs;
79 u64 start_pfn;
80 int ret = -EINVAL;
81
82 /*
83 * Check to see if we are actually adding memory
84 */
85 type = of_get_property(np, "device_type", NULL);
86 if (type == NULL || strcmp(type, "memory") != 0)
87 return 0;
88
89 /*
90 * Find the memory index and size of the added section
91 */
92 my_index = of_get_property(np, "ibm,my-drc-index", NULL);
93 if (!my_index)
94 return ret;
95
96 regs = of_get_property(np, "reg", NULL);
97 if (!regs)
98 return ret;
99
100 start_pfn = section_nr_to_pfn(*my_index & 0xffff);
101
102 /*
103 * Update memory region to represent the memory add
104 */
105 lmb_add(start_pfn << PAGE_SHIFT, regs[3]);
106 return 0;
107}
108
109static int pseries_memory_notifier(struct notifier_block *nb,
110 unsigned long action, void *node)
111{
112 int err = NOTIFY_OK;
113
114 switch (action) {
115 case PSERIES_RECONFIG_ADD:
116 if (pseries_add_memory(node))
117 err = NOTIFY_BAD;
118 break;
119 case PSERIES_RECONFIG_REMOVE:
120 if (pseries_remove_memory(node))
121 err = NOTIFY_BAD;
122 break;
123 default:
124 err = NOTIFY_DONE;
125 break;
126 }
127 return err;
128}
129
130static struct notifier_block pseries_mem_nb = {
131 .notifier_call = pseries_memory_notifier,
132};
133
134static int __init pseries_memory_hotplug_init(void)
135{
136 if (firmware_has_feature(FW_FEATURE_LPAR))
137 pSeries_reconfig_notifier_register(&pseries_mem_nb);
138
139 return 0;
140}
141machine_device_initcall(pseries, pseries_memory_hotplug_init);
diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c
index af2425e4655f..3d920376f58e 100644
--- a/arch/powerpc/sysdev/fsl_rio.c
+++ b/arch/powerpc/sysdev/fsl_rio.c
@@ -1,5 +1,8 @@
1/* 1/*
2 * MPC85xx RapidIO support 2 * Freescale MPC85xx/MPC86xx RapidIO support
3 *
4 * Copyright (C) 2007, 2008 Freescale Semiconductor, Inc.
5 * Zhang Wei <wei.zhang@freescale.com>
3 * 6 *
4 * Copyright 2005 MontaVista Software, Inc. 7 * Copyright 2005 MontaVista Software, Inc.
5 * Matt Porter <mporter@kernel.crashing.org> 8 * Matt Porter <mporter@kernel.crashing.org>
@@ -17,12 +20,23 @@
17#include <linux/interrupt.h> 20#include <linux/interrupt.h>
18#include <linux/rio.h> 21#include <linux/rio.h>
19#include <linux/rio_drv.h> 22#include <linux/rio_drv.h>
23#include <linux/of_platform.h>
24#include <linux/delay.h>
20 25
21#include <asm/io.h> 26#include <asm/io.h>
22 27
23#define RIO_REGS_BASE (CCSRBAR + 0xc0000) 28/* RapidIO definition irq, which read from OF-tree */
29#define IRQ_RIO_BELL(m) (((struct rio_priv *)(m->priv))->bellirq)
30#define IRQ_RIO_TX(m) (((struct rio_priv *)(m->priv))->txirq)
31#define IRQ_RIO_RX(m) (((struct rio_priv *)(m->priv))->rxirq)
32
24#define RIO_ATMU_REGS_OFFSET 0x10c00 33#define RIO_ATMU_REGS_OFFSET 0x10c00
25#define RIO_MSG_REGS_OFFSET 0x11000 34#define RIO_P_MSG_REGS_OFFSET 0x11000
35#define RIO_S_MSG_REGS_OFFSET 0x13000
36#define RIO_ESCSR 0x158
37#define RIO_CCSR 0x15c
38#define RIO_ISR_AACR 0x10120
39#define RIO_ISR_AACR_AA 0x1 /* Accept All ID */
26#define RIO_MAINT_WIN_SIZE 0x400000 40#define RIO_MAINT_WIN_SIZE 0x400000
27#define RIO_DBELL_WIN_SIZE 0x1000 41#define RIO_DBELL_WIN_SIZE 0x1000
28 42
@@ -50,18 +64,18 @@
50#define DOORBELL_DSR_TE 0x00000080 64#define DOORBELL_DSR_TE 0x00000080
51#define DOORBELL_DSR_QFI 0x00000010 65#define DOORBELL_DSR_QFI 0x00000010
52#define DOORBELL_DSR_DIQI 0x00000001 66#define DOORBELL_DSR_DIQI 0x00000001
53#define DOORBELL_TID_OFFSET 0x03 67#define DOORBELL_TID_OFFSET 0x02
54#define DOORBELL_SID_OFFSET 0x05 68#define DOORBELL_SID_OFFSET 0x04
55#define DOORBELL_INFO_OFFSET 0x06 69#define DOORBELL_INFO_OFFSET 0x06
56 70
57#define DOORBELL_MESSAGE_SIZE 0x08 71#define DOORBELL_MESSAGE_SIZE 0x08
58#define DBELL_SID(x) (*(u8 *)(x + DOORBELL_SID_OFFSET)) 72#define DBELL_SID(x) (*(u16 *)(x + DOORBELL_SID_OFFSET))
59#define DBELL_TID(x) (*(u8 *)(x + DOORBELL_TID_OFFSET)) 73#define DBELL_TID(x) (*(u16 *)(x + DOORBELL_TID_OFFSET))
60#define DBELL_INF(x) (*(u16 *)(x + DOORBELL_INFO_OFFSET)) 74#define DBELL_INF(x) (*(u16 *)(x + DOORBELL_INFO_OFFSET))
61 75
62struct rio_atmu_regs { 76struct rio_atmu_regs {
63 u32 rowtar; 77 u32 rowtar;
64 u32 pad1; 78 u32 rowtear;
65 u32 rowbar; 79 u32 rowbar;
66 u32 pad2; 80 u32 pad2;
67 u32 rowar; 81 u32 rowar;
@@ -87,7 +101,15 @@ struct rio_msg_regs {
87 u32 ifqdpar; 101 u32 ifqdpar;
88 u32 pad6; 102 u32 pad6;
89 u32 ifqepar; 103 u32 ifqepar;
90 u32 pad7[250]; 104 u32 pad7[226];
105 u32 odmr;
106 u32 odsr;
107 u32 res0[4];
108 u32 oddpr;
109 u32 oddatr;
110 u32 res1[3];
111 u32 odretcr;
112 u32 res2[12];
91 u32 dmr; 113 u32 dmr;
92 u32 dsr; 114 u32 dsr;
93 u32 pad8; 115 u32 pad8;
@@ -112,20 +134,12 @@ struct rio_tx_desc {
112 u32 res4; 134 u32 res4;
113}; 135};
114 136
115static u32 regs_win; 137struct rio_dbell_ring {
116static struct rio_atmu_regs *atmu_regs;
117static struct rio_atmu_regs *maint_atmu_regs;
118static struct rio_atmu_regs *dbell_atmu_regs;
119static u32 dbell_win;
120static u32 maint_win;
121static struct rio_msg_regs *msg_regs;
122
123static struct rio_dbell_ring {
124 void *virt; 138 void *virt;
125 dma_addr_t phys; 139 dma_addr_t phys;
126} dbell_ring; 140};
127 141
128static struct rio_msg_tx_ring { 142struct rio_msg_tx_ring {
129 void *virt; 143 void *virt;
130 dma_addr_t phys; 144 dma_addr_t phys;
131 void *virt_buffer[RIO_MAX_TX_RING_SIZE]; 145 void *virt_buffer[RIO_MAX_TX_RING_SIZE];
@@ -133,19 +147,35 @@ static struct rio_msg_tx_ring {
133 int tx_slot; 147 int tx_slot;
134 int size; 148 int size;
135 void *dev_id; 149 void *dev_id;
136} msg_tx_ring; 150};
137 151
138static struct rio_msg_rx_ring { 152struct rio_msg_rx_ring {
139 void *virt; 153 void *virt;
140 dma_addr_t phys; 154 dma_addr_t phys;
141 void *virt_buffer[RIO_MAX_RX_RING_SIZE]; 155 void *virt_buffer[RIO_MAX_RX_RING_SIZE];
142 int rx_slot; 156 int rx_slot;
143 int size; 157 int size;
144 void *dev_id; 158 void *dev_id;
145} msg_rx_ring; 159};
160
161struct rio_priv {
162 void __iomem *regs_win;
163 struct rio_atmu_regs __iomem *atmu_regs;
164 struct rio_atmu_regs __iomem *maint_atmu_regs;
165 struct rio_atmu_regs __iomem *dbell_atmu_regs;
166 void __iomem *dbell_win;
167 void __iomem *maint_win;
168 struct rio_msg_regs __iomem *msg_regs;
169 struct rio_dbell_ring dbell_ring;
170 struct rio_msg_tx_ring msg_tx_ring;
171 struct rio_msg_rx_ring msg_rx_ring;
172 int bellirq;
173 int txirq;
174 int rxirq;
175};
146 176
147/** 177/**
148 * mpc85xx_rio_doorbell_send - Send a MPC85xx doorbell message 178 * fsl_rio_doorbell_send - Send a MPC85xx doorbell message
149 * @index: ID of RapidIO interface 179 * @index: ID of RapidIO interface
150 * @destid: Destination ID of target device 180 * @destid: Destination ID of target device
151 * @data: 16-bit info field of RapidIO doorbell message 181 * @data: 16-bit info field of RapidIO doorbell message
@@ -153,18 +183,34 @@ static struct rio_msg_rx_ring {
153 * Sends a MPC85xx doorbell message. Returns %0 on success or 183 * Sends a MPC85xx doorbell message. Returns %0 on success or
154 * %-EINVAL on failure. 184 * %-EINVAL on failure.
155 */ 185 */
156static int mpc85xx_rio_doorbell_send(int index, u16 destid, u16 data) 186static int fsl_rio_doorbell_send(struct rio_mport *mport,
187 int index, u16 destid, u16 data)
157{ 188{
158 pr_debug("mpc85xx_doorbell_send: index %d destid %4.4x data %4.4x\n", 189 struct rio_priv *priv = mport->priv;
190 pr_debug("fsl_doorbell_send: index %d destid %4.4x data %4.4x\n",
159 index, destid, data); 191 index, destid, data);
160 out_be32((void *)&dbell_atmu_regs->rowtar, destid << 22); 192 switch (mport->phy_type) {
161 out_be16((void *)(dbell_win), data); 193 case RIO_PHY_PARALLEL:
194 out_be32(&priv->dbell_atmu_regs->rowtar, destid << 22);
195 out_be16(priv->dbell_win, data);
196 break;
197 case RIO_PHY_SERIAL:
198 /* In the serial version silicons, such as MPC8548, MPC8641,
199 * below operations is must be.
200 */
201 out_be32(&priv->msg_regs->odmr, 0x00000000);
202 out_be32(&priv->msg_regs->odretcr, 0x00000004);
203 out_be32(&priv->msg_regs->oddpr, destid << 16);
204 out_be32(&priv->msg_regs->oddatr, data);
205 out_be32(&priv->msg_regs->odmr, 0x00000001);
206 break;
207 }
162 208
163 return 0; 209 return 0;
164} 210}
165 211
166/** 212/**
167 * mpc85xx_local_config_read - Generate a MPC85xx local config space read 213 * fsl_local_config_read - Generate a MPC85xx local config space read
168 * @index: ID of RapdiIO interface 214 * @index: ID of RapdiIO interface
169 * @offset: Offset into configuration space 215 * @offset: Offset into configuration space
170 * @len: Length (in bytes) of the maintenance transaction 216 * @len: Length (in bytes) of the maintenance transaction
@@ -173,17 +219,19 @@ static int mpc85xx_rio_doorbell_send(int index, u16 destid, u16 data)
173 * Generates a MPC85xx local configuration space read. Returns %0 on 219 * Generates a MPC85xx local configuration space read. Returns %0 on
174 * success or %-EINVAL on failure. 220 * success or %-EINVAL on failure.
175 */ 221 */
176static int mpc85xx_local_config_read(int index, u32 offset, int len, u32 * data) 222static int fsl_local_config_read(struct rio_mport *mport,
223 int index, u32 offset, int len, u32 *data)
177{ 224{
178 pr_debug("mpc85xx_local_config_read: index %d offset %8.8x\n", index, 225 struct rio_priv *priv = mport->priv;
226 pr_debug("fsl_local_config_read: index %d offset %8.8x\n", index,
179 offset); 227 offset);
180 *data = in_be32((void *)(regs_win + offset)); 228 *data = in_be32(priv->regs_win + offset);
181 229
182 return 0; 230 return 0;
183} 231}
184 232
185/** 233/**
186 * mpc85xx_local_config_write - Generate a MPC85xx local config space write 234 * fsl_local_config_write - Generate a MPC85xx local config space write
187 * @index: ID of RapdiIO interface 235 * @index: ID of RapdiIO interface
188 * @offset: Offset into configuration space 236 * @offset: Offset into configuration space
189 * @len: Length (in bytes) of the maintenance transaction 237 * @len: Length (in bytes) of the maintenance transaction
@@ -192,18 +240,20 @@ static int mpc85xx_local_config_read(int index, u32 offset, int len, u32 * data)
192 * Generates a MPC85xx local configuration space write. Returns %0 on 240 * Generates a MPC85xx local configuration space write. Returns %0 on
193 * success or %-EINVAL on failure. 241 * success or %-EINVAL on failure.
194 */ 242 */
195static int mpc85xx_local_config_write(int index, u32 offset, int len, u32 data) 243static int fsl_local_config_write(struct rio_mport *mport,
244 int index, u32 offset, int len, u32 data)
196{ 245{
246 struct rio_priv *priv = mport->priv;
197 pr_debug 247 pr_debug
198 ("mpc85xx_local_config_write: index %d offset %8.8x data %8.8x\n", 248 ("fsl_local_config_write: index %d offset %8.8x data %8.8x\n",
199 index, offset, data); 249 index, offset, data);
200 out_be32((void *)(regs_win + offset), data); 250 out_be32(priv->regs_win + offset, data);
201 251
202 return 0; 252 return 0;
203} 253}
204 254
205/** 255/**
206 * mpc85xx_rio_config_read - Generate a MPC85xx read maintenance transaction 256 * fsl_rio_config_read - Generate a MPC85xx read maintenance transaction
207 * @index: ID of RapdiIO interface 257 * @index: ID of RapdiIO interface
208 * @destid: Destination ID of transaction 258 * @destid: Destination ID of transaction
209 * @hopcount: Number of hops to target device 259 * @hopcount: Number of hops to target device
@@ -215,18 +265,19 @@ static int mpc85xx_local_config_write(int index, u32 offset, int len, u32 data)
215 * success or %-EINVAL on failure. 265 * success or %-EINVAL on failure.
216 */ 266 */
217static int 267static int
218mpc85xx_rio_config_read(int index, u16 destid, u8 hopcount, u32 offset, int len, 268fsl_rio_config_read(struct rio_mport *mport, int index, u16 destid,
219 u32 * val) 269 u8 hopcount, u32 offset, int len, u32 *val)
220{ 270{
271 struct rio_priv *priv = mport->priv;
221 u8 *data; 272 u8 *data;
222 273
223 pr_debug 274 pr_debug
224 ("mpc85xx_rio_config_read: index %d destid %d hopcount %d offset %8.8x len %d\n", 275 ("fsl_rio_config_read: index %d destid %d hopcount %d offset %8.8x len %d\n",
225 index, destid, hopcount, offset, len); 276 index, destid, hopcount, offset, len);
226 out_be32((void *)&maint_atmu_regs->rowtar, 277 out_be32(&priv->maint_atmu_regs->rowtar,
227 (destid << 22) | (hopcount << 12) | ((offset & ~0x3) >> 9)); 278 (destid << 22) | (hopcount << 12) | ((offset & ~0x3) >> 9));
228 279
229 data = (u8 *) maint_win + offset; 280 data = (u8 *) priv->maint_win + offset;
230 switch (len) { 281 switch (len) {
231 case 1: 282 case 1:
232 *val = in_8((u8 *) data); 283 *val = in_8((u8 *) data);
@@ -243,7 +294,7 @@ mpc85xx_rio_config_read(int index, u16 destid, u8 hopcount, u32 offset, int len,
243} 294}
244 295
245/** 296/**
246 * mpc85xx_rio_config_write - Generate a MPC85xx write maintenance transaction 297 * fsl_rio_config_write - Generate a MPC85xx write maintenance transaction
247 * @index: ID of RapdiIO interface 298 * @index: ID of RapdiIO interface
248 * @destid: Destination ID of transaction 299 * @destid: Destination ID of transaction
249 * @hopcount: Number of hops to target device 300 * @hopcount: Number of hops to target device
@@ -255,17 +306,18 @@ mpc85xx_rio_config_read(int index, u16 destid, u8 hopcount, u32 offset, int len,
255 * success or %-EINVAL on failure. 306 * success or %-EINVAL on failure.
256 */ 307 */
257static int 308static int
258mpc85xx_rio_config_write(int index, u16 destid, u8 hopcount, u32 offset, 309fsl_rio_config_write(struct rio_mport *mport, int index, u16 destid,
259 int len, u32 val) 310 u8 hopcount, u32 offset, int len, u32 val)
260{ 311{
312 struct rio_priv *priv = mport->priv;
261 u8 *data; 313 u8 *data;
262 pr_debug 314 pr_debug
263 ("mpc85xx_rio_config_write: index %d destid %d hopcount %d offset %8.8x len %d val %8.8x\n", 315 ("fsl_rio_config_write: index %d destid %d hopcount %d offset %8.8x len %d val %8.8x\n",
264 index, destid, hopcount, offset, len, val); 316 index, destid, hopcount, offset, len, val);
265 out_be32((void *)&maint_atmu_regs->rowtar, 317 out_be32(&priv->maint_atmu_regs->rowtar,
266 (destid << 22) | (hopcount << 12) | ((offset & ~0x3) >> 9)); 318 (destid << 22) | (hopcount << 12) | ((offset & ~0x3) >> 9));
267 319
268 data = (u8 *) maint_win + offset; 320 data = (u8 *) priv->maint_win + offset;
269 switch (len) { 321 switch (len) {
270 case 1: 322 case 1:
271 out_8((u8 *) data, val); 323 out_8((u8 *) data, val);
@@ -296,9 +348,10 @@ int
296rio_hw_add_outb_message(struct rio_mport *mport, struct rio_dev *rdev, int mbox, 348rio_hw_add_outb_message(struct rio_mport *mport, struct rio_dev *rdev, int mbox,
297 void *buffer, size_t len) 349 void *buffer, size_t len)
298{ 350{
351 struct rio_priv *priv = mport->priv;
299 u32 omr; 352 u32 omr;
300 struct rio_tx_desc *desc = 353 struct rio_tx_desc *desc = (struct rio_tx_desc *)priv->msg_tx_ring.virt
301 (struct rio_tx_desc *)msg_tx_ring.virt + msg_tx_ring.tx_slot; 354 + priv->msg_tx_ring.tx_slot;
302 int ret = 0; 355 int ret = 0;
303 356
304 pr_debug 357 pr_debug
@@ -311,31 +364,43 @@ rio_hw_add_outb_message(struct rio_mport *mport, struct rio_dev *rdev, int mbox,
311 } 364 }
312 365
313 /* Copy and clear rest of buffer */ 366 /* Copy and clear rest of buffer */
314 memcpy(msg_tx_ring.virt_buffer[msg_tx_ring.tx_slot], buffer, len); 367 memcpy(priv->msg_tx_ring.virt_buffer[priv->msg_tx_ring.tx_slot], buffer,
368 len);
315 if (len < (RIO_MAX_MSG_SIZE - 4)) 369 if (len < (RIO_MAX_MSG_SIZE - 4))
316 memset((void *)((u32) msg_tx_ring. 370 memset(priv->msg_tx_ring.virt_buffer[priv->msg_tx_ring.tx_slot]
317 virt_buffer[msg_tx_ring.tx_slot] + len), 0, 371 + len, 0, RIO_MAX_MSG_SIZE - len);
318 RIO_MAX_MSG_SIZE - len);
319 372
320 /* Set mbox field for message */ 373 switch (mport->phy_type) {
321 desc->dport = mbox & 0x3; 374 case RIO_PHY_PARALLEL:
375 /* Set mbox field for message */
376 desc->dport = mbox & 0x3;
322 377
323 /* Enable EOMI interrupt, set priority, and set destid */ 378 /* Enable EOMI interrupt, set priority, and set destid */
324 desc->dattr = 0x28000000 | (rdev->destid << 2); 379 desc->dattr = 0x28000000 | (rdev->destid << 2);
380 break;
381 case RIO_PHY_SERIAL:
382 /* Set mbox field for message, and set destid */
383 desc->dport = (rdev->destid << 16) | (mbox & 0x3);
384
385 /* Enable EOMI interrupt and priority */
386 desc->dattr = 0x28000000;
387 break;
388 }
325 389
326 /* Set transfer size aligned to next power of 2 (in double words) */ 390 /* Set transfer size aligned to next power of 2 (in double words) */
327 desc->dwcnt = is_power_of_2(len) ? len : 1 << get_bitmask_order(len); 391 desc->dwcnt = is_power_of_2(len) ? len : 1 << get_bitmask_order(len);
328 392
329 /* Set snooping and source buffer address */ 393 /* Set snooping and source buffer address */
330 desc->saddr = 0x00000004 | msg_tx_ring.phys_buffer[msg_tx_ring.tx_slot]; 394 desc->saddr = 0x00000004
395 | priv->msg_tx_ring.phys_buffer[priv->msg_tx_ring.tx_slot];
331 396
332 /* Increment enqueue pointer */ 397 /* Increment enqueue pointer */
333 omr = in_be32((void *)&msg_regs->omr); 398 omr = in_be32(&priv->msg_regs->omr);
334 out_be32((void *)&msg_regs->omr, omr | RIO_MSG_OMR_MUI); 399 out_be32(&priv->msg_regs->omr, omr | RIO_MSG_OMR_MUI);
335 400
336 /* Go to next descriptor */ 401 /* Go to next descriptor */
337 if (++msg_tx_ring.tx_slot == msg_tx_ring.size) 402 if (++priv->msg_tx_ring.tx_slot == priv->msg_tx_ring.size)
338 msg_tx_ring.tx_slot = 0; 403 priv->msg_tx_ring.tx_slot = 0;
339 404
340 out: 405 out:
341 return ret; 406 return ret;
@@ -344,7 +409,7 @@ rio_hw_add_outb_message(struct rio_mport *mport, struct rio_dev *rdev, int mbox,
344EXPORT_SYMBOL_GPL(rio_hw_add_outb_message); 409EXPORT_SYMBOL_GPL(rio_hw_add_outb_message);
345 410
346/** 411/**
347 * mpc85xx_rio_tx_handler - MPC85xx outbound message interrupt handler 412 * fsl_rio_tx_handler - MPC85xx outbound message interrupt handler
348 * @irq: Linux interrupt number 413 * @irq: Linux interrupt number
349 * @dev_instance: Pointer to interrupt-specific data 414 * @dev_instance: Pointer to interrupt-specific data
350 * 415 *
@@ -352,32 +417,34 @@ EXPORT_SYMBOL_GPL(rio_hw_add_outb_message);
352 * mailbox event handler and acks the interrupt occurrence. 417 * mailbox event handler and acks the interrupt occurrence.
353 */ 418 */
354static irqreturn_t 419static irqreturn_t
355mpc85xx_rio_tx_handler(int irq, void *dev_instance) 420fsl_rio_tx_handler(int irq, void *dev_instance)
356{ 421{
357 int osr; 422 int osr;
358 struct rio_mport *port = (struct rio_mport *)dev_instance; 423 struct rio_mport *port = (struct rio_mport *)dev_instance;
424 struct rio_priv *priv = port->priv;
359 425
360 osr = in_be32((void *)&msg_regs->osr); 426 osr = in_be32(&priv->msg_regs->osr);
361 427
362 if (osr & RIO_MSG_OSR_TE) { 428 if (osr & RIO_MSG_OSR_TE) {
363 pr_info("RIO: outbound message transmission error\n"); 429 pr_info("RIO: outbound message transmission error\n");
364 out_be32((void *)&msg_regs->osr, RIO_MSG_OSR_TE); 430 out_be32(&priv->msg_regs->osr, RIO_MSG_OSR_TE);
365 goto out; 431 goto out;
366 } 432 }
367 433
368 if (osr & RIO_MSG_OSR_QOI) { 434 if (osr & RIO_MSG_OSR_QOI) {
369 pr_info("RIO: outbound message queue overflow\n"); 435 pr_info("RIO: outbound message queue overflow\n");
370 out_be32((void *)&msg_regs->osr, RIO_MSG_OSR_QOI); 436 out_be32(&priv->msg_regs->osr, RIO_MSG_OSR_QOI);
371 goto out; 437 goto out;
372 } 438 }
373 439
374 if (osr & RIO_MSG_OSR_EOMI) { 440 if (osr & RIO_MSG_OSR_EOMI) {
375 u32 dqp = in_be32((void *)&msg_regs->odqdpar); 441 u32 dqp = in_be32(&priv->msg_regs->odqdpar);
376 int slot = (dqp - msg_tx_ring.phys) >> 5; 442 int slot = (dqp - priv->msg_tx_ring.phys) >> 5;
377 port->outb_msg[0].mcback(port, msg_tx_ring.dev_id, -1, slot); 443 port->outb_msg[0].mcback(port, priv->msg_tx_ring.dev_id, -1,
444 slot);
378 445
379 /* Ack the end-of-message interrupt */ 446 /* Ack the end-of-message interrupt */
380 out_be32((void *)&msg_regs->osr, RIO_MSG_OSR_EOMI); 447 out_be32(&priv->msg_regs->osr, RIO_MSG_OSR_EOMI);
381 } 448 }
382 449
383 out: 450 out:
@@ -398,6 +465,7 @@ mpc85xx_rio_tx_handler(int irq, void *dev_instance)
398int rio_open_outb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entries) 465int rio_open_outb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entries)
399{ 466{
400 int i, j, rc = 0; 467 int i, j, rc = 0;
468 struct rio_priv *priv = mport->priv;
401 469
402 if ((entries < RIO_MIN_TX_RING_SIZE) || 470 if ((entries < RIO_MIN_TX_RING_SIZE) ||
403 (entries > RIO_MAX_TX_RING_SIZE) || (!is_power_of_2(entries))) { 471 (entries > RIO_MAX_TX_RING_SIZE) || (!is_power_of_2(entries))) {
@@ -406,54 +474,53 @@ int rio_open_outb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entr
406 } 474 }
407 475
408 /* Initialize shadow copy ring */ 476 /* Initialize shadow copy ring */
409 msg_tx_ring.dev_id = dev_id; 477 priv->msg_tx_ring.dev_id = dev_id;
410 msg_tx_ring.size = entries; 478 priv->msg_tx_ring.size = entries;
411 479
412 for (i = 0; i < msg_tx_ring.size; i++) { 480 for (i = 0; i < priv->msg_tx_ring.size; i++) {
413 if (! 481 priv->msg_tx_ring.virt_buffer[i] =
414 (msg_tx_ring.virt_buffer[i] = 482 dma_alloc_coherent(NULL, RIO_MSG_BUFFER_SIZE,
415 dma_alloc_coherent(NULL, RIO_MSG_BUFFER_SIZE, 483 &priv->msg_tx_ring.phys_buffer[i], GFP_KERNEL);
416 &msg_tx_ring.phys_buffer[i], 484 if (!priv->msg_tx_ring.virt_buffer[i]) {
417 GFP_KERNEL))) {
418 rc = -ENOMEM; 485 rc = -ENOMEM;
419 for (j = 0; j < msg_tx_ring.size; j++) 486 for (j = 0; j < priv->msg_tx_ring.size; j++)
420 if (msg_tx_ring.virt_buffer[j]) 487 if (priv->msg_tx_ring.virt_buffer[j])
421 dma_free_coherent(NULL, 488 dma_free_coherent(NULL,
422 RIO_MSG_BUFFER_SIZE, 489 RIO_MSG_BUFFER_SIZE,
423 msg_tx_ring. 490 priv->msg_tx_ring.
424 virt_buffer[j], 491 virt_buffer[j],
425 msg_tx_ring. 492 priv->msg_tx_ring.
426 phys_buffer[j]); 493 phys_buffer[j]);
427 goto out; 494 goto out;
428 } 495 }
429 } 496 }
430 497
431 /* Initialize outbound message descriptor ring */ 498 /* Initialize outbound message descriptor ring */
432 if (!(msg_tx_ring.virt = dma_alloc_coherent(NULL, 499 priv->msg_tx_ring.virt = dma_alloc_coherent(NULL,
433 msg_tx_ring.size * 500 priv->msg_tx_ring.size * RIO_MSG_DESC_SIZE,
434 RIO_MSG_DESC_SIZE, 501 &priv->msg_tx_ring.phys, GFP_KERNEL);
435 &msg_tx_ring.phys, 502 if (!priv->msg_tx_ring.virt) {
436 GFP_KERNEL))) {
437 rc = -ENOMEM; 503 rc = -ENOMEM;
438 goto out_dma; 504 goto out_dma;
439 } 505 }
440 memset(msg_tx_ring.virt, 0, msg_tx_ring.size * RIO_MSG_DESC_SIZE); 506 memset(priv->msg_tx_ring.virt, 0,
441 msg_tx_ring.tx_slot = 0; 507 priv->msg_tx_ring.size * RIO_MSG_DESC_SIZE);
508 priv->msg_tx_ring.tx_slot = 0;
442 509
443 /* Point dequeue/enqueue pointers at first entry in ring */ 510 /* Point dequeue/enqueue pointers at first entry in ring */
444 out_be32((void *)&msg_regs->odqdpar, msg_tx_ring.phys); 511 out_be32(&priv->msg_regs->odqdpar, priv->msg_tx_ring.phys);
445 out_be32((void *)&msg_regs->odqepar, msg_tx_ring.phys); 512 out_be32(&priv->msg_regs->odqepar, priv->msg_tx_ring.phys);
446 513
447 /* Configure for snooping */ 514 /* Configure for snooping */
448 out_be32((void *)&msg_regs->osar, 0x00000004); 515 out_be32(&priv->msg_regs->osar, 0x00000004);
449 516
450 /* Clear interrupt status */ 517 /* Clear interrupt status */
451 out_be32((void *)&msg_regs->osr, 0x000000b3); 518 out_be32(&priv->msg_regs->osr, 0x000000b3);
452 519
453 /* Hook up outbound message handler */ 520 /* Hook up outbound message handler */
454 if ((rc = 521 rc = request_irq(IRQ_RIO_TX(mport), fsl_rio_tx_handler, 0,
455 request_irq(MPC85xx_IRQ_RIO_TX, mpc85xx_rio_tx_handler, 0, 522 "msg_tx", (void *)mport);
456 "msg_tx", (void *)mport)) < 0) 523 if (rc < 0)
457 goto out_irq; 524 goto out_irq;
458 525
459 /* 526 /*
@@ -463,28 +530,28 @@ int rio_open_outb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entr
463 * Chaining mode 530 * Chaining mode
464 * Disable 531 * Disable
465 */ 532 */
466 out_be32((void *)&msg_regs->omr, 0x00100220); 533 out_be32(&priv->msg_regs->omr, 0x00100220);
467 534
468 /* Set number of entries */ 535 /* Set number of entries */
469 out_be32((void *)&msg_regs->omr, 536 out_be32(&priv->msg_regs->omr,
470 in_be32((void *)&msg_regs->omr) | 537 in_be32(&priv->msg_regs->omr) |
471 ((get_bitmask_order(entries) - 2) << 12)); 538 ((get_bitmask_order(entries) - 2) << 12));
472 539
473 /* Now enable the unit */ 540 /* Now enable the unit */
474 out_be32((void *)&msg_regs->omr, in_be32((void *)&msg_regs->omr) | 0x1); 541 out_be32(&priv->msg_regs->omr, in_be32(&priv->msg_regs->omr) | 0x1);
475 542
476 out: 543 out:
477 return rc; 544 return rc;
478 545
479 out_irq: 546 out_irq:
480 dma_free_coherent(NULL, msg_tx_ring.size * RIO_MSG_DESC_SIZE, 547 dma_free_coherent(NULL, priv->msg_tx_ring.size * RIO_MSG_DESC_SIZE,
481 msg_tx_ring.virt, msg_tx_ring.phys); 548 priv->msg_tx_ring.virt, priv->msg_tx_ring.phys);
482 549
483 out_dma: 550 out_dma:
484 for (i = 0; i < msg_tx_ring.size; i++) 551 for (i = 0; i < priv->msg_tx_ring.size; i++)
485 dma_free_coherent(NULL, RIO_MSG_BUFFER_SIZE, 552 dma_free_coherent(NULL, RIO_MSG_BUFFER_SIZE,
486 msg_tx_ring.virt_buffer[i], 553 priv->msg_tx_ring.virt_buffer[i],
487 msg_tx_ring.phys_buffer[i]); 554 priv->msg_tx_ring.phys_buffer[i]);
488 555
489 return rc; 556 return rc;
490} 557}
@@ -499,19 +566,20 @@ int rio_open_outb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entr
499 */ 566 */
500void rio_close_outb_mbox(struct rio_mport *mport, int mbox) 567void rio_close_outb_mbox(struct rio_mport *mport, int mbox)
501{ 568{
569 struct rio_priv *priv = mport->priv;
502 /* Disable inbound message unit */ 570 /* Disable inbound message unit */
503 out_be32((void *)&msg_regs->omr, 0); 571 out_be32(&priv->msg_regs->omr, 0);
504 572
505 /* Free ring */ 573 /* Free ring */
506 dma_free_coherent(NULL, msg_tx_ring.size * RIO_MSG_DESC_SIZE, 574 dma_free_coherent(NULL, priv->msg_tx_ring.size * RIO_MSG_DESC_SIZE,
507 msg_tx_ring.virt, msg_tx_ring.phys); 575 priv->msg_tx_ring.virt, priv->msg_tx_ring.phys);
508 576
509 /* Free interrupt */ 577 /* Free interrupt */
510 free_irq(MPC85xx_IRQ_RIO_TX, (void *)mport); 578 free_irq(IRQ_RIO_TX(mport), (void *)mport);
511} 579}
512 580
513/** 581/**
514 * mpc85xx_rio_rx_handler - MPC85xx inbound message interrupt handler 582 * fsl_rio_rx_handler - MPC85xx inbound message interrupt handler
515 * @irq: Linux interrupt number 583 * @irq: Linux interrupt number
516 * @dev_instance: Pointer to interrupt-specific data 584 * @dev_instance: Pointer to interrupt-specific data
517 * 585 *
@@ -519,16 +587,17 @@ void rio_close_outb_mbox(struct rio_mport *mport, int mbox)
519 * mailbox event handler and acks the interrupt occurrence. 587 * mailbox event handler and acks the interrupt occurrence.
520 */ 588 */
521static irqreturn_t 589static irqreturn_t
522mpc85xx_rio_rx_handler(int irq, void *dev_instance) 590fsl_rio_rx_handler(int irq, void *dev_instance)
523{ 591{
524 int isr; 592 int isr;
525 struct rio_mport *port = (struct rio_mport *)dev_instance; 593 struct rio_mport *port = (struct rio_mport *)dev_instance;
594 struct rio_priv *priv = port->priv;
526 595
527 isr = in_be32((void *)&msg_regs->isr); 596 isr = in_be32(&priv->msg_regs->isr);
528 597
529 if (isr & RIO_MSG_ISR_TE) { 598 if (isr & RIO_MSG_ISR_TE) {
530 pr_info("RIO: inbound message reception error\n"); 599 pr_info("RIO: inbound message reception error\n");
531 out_be32((void *)&msg_regs->isr, RIO_MSG_ISR_TE); 600 out_be32((void *)&priv->msg_regs->isr, RIO_MSG_ISR_TE);
532 goto out; 601 goto out;
533 } 602 }
534 603
@@ -540,10 +609,10 @@ mpc85xx_rio_rx_handler(int irq, void *dev_instance)
540 * make the callback with an unknown/invalid mailbox number 609 * make the callback with an unknown/invalid mailbox number
541 * argument. 610 * argument.
542 */ 611 */
543 port->inb_msg[0].mcback(port, msg_rx_ring.dev_id, -1, -1); 612 port->inb_msg[0].mcback(port, priv->msg_rx_ring.dev_id, -1, -1);
544 613
545 /* Ack the queueing interrupt */ 614 /* Ack the queueing interrupt */
546 out_be32((void *)&msg_regs->isr, RIO_MSG_ISR_DIQI); 615 out_be32(&priv->msg_regs->isr, RIO_MSG_ISR_DIQI);
547 } 616 }
548 617
549 out: 618 out:
@@ -564,6 +633,7 @@ mpc85xx_rio_rx_handler(int irq, void *dev_instance)
564int rio_open_inb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entries) 633int rio_open_inb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entries)
565{ 634{
566 int i, rc = 0; 635 int i, rc = 0;
636 struct rio_priv *priv = mport->priv;
567 637
568 if ((entries < RIO_MIN_RX_RING_SIZE) || 638 if ((entries < RIO_MIN_RX_RING_SIZE) ||
569 (entries > RIO_MAX_RX_RING_SIZE) || (!is_power_of_2(entries))) { 639 (entries > RIO_MAX_RX_RING_SIZE) || (!is_power_of_2(entries))) {
@@ -572,36 +642,35 @@ int rio_open_inb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entri
572 } 642 }
573 643
574 /* Initialize client buffer ring */ 644 /* Initialize client buffer ring */
575 msg_rx_ring.dev_id = dev_id; 645 priv->msg_rx_ring.dev_id = dev_id;
576 msg_rx_ring.size = entries; 646 priv->msg_rx_ring.size = entries;
577 msg_rx_ring.rx_slot = 0; 647 priv->msg_rx_ring.rx_slot = 0;
578 for (i = 0; i < msg_rx_ring.size; i++) 648 for (i = 0; i < priv->msg_rx_ring.size; i++)
579 msg_rx_ring.virt_buffer[i] = NULL; 649 priv->msg_rx_ring.virt_buffer[i] = NULL;
580 650
581 /* Initialize inbound message ring */ 651 /* Initialize inbound message ring */
582 if (!(msg_rx_ring.virt = dma_alloc_coherent(NULL, 652 priv->msg_rx_ring.virt = dma_alloc_coherent(NULL,
583 msg_rx_ring.size * 653 priv->msg_rx_ring.size * RIO_MAX_MSG_SIZE,
584 RIO_MAX_MSG_SIZE, 654 &priv->msg_rx_ring.phys, GFP_KERNEL);
585 &msg_rx_ring.phys, 655 if (!priv->msg_rx_ring.virt) {
586 GFP_KERNEL))) {
587 rc = -ENOMEM; 656 rc = -ENOMEM;
588 goto out; 657 goto out;
589 } 658 }
590 659
591 /* Point dequeue/enqueue pointers at first entry in ring */ 660 /* Point dequeue/enqueue pointers at first entry in ring */
592 out_be32((void *)&msg_regs->ifqdpar, (u32) msg_rx_ring.phys); 661 out_be32(&priv->msg_regs->ifqdpar, (u32) priv->msg_rx_ring.phys);
593 out_be32((void *)&msg_regs->ifqepar, (u32) msg_rx_ring.phys); 662 out_be32(&priv->msg_regs->ifqepar, (u32) priv->msg_rx_ring.phys);
594 663
595 /* Clear interrupt status */ 664 /* Clear interrupt status */
596 out_be32((void *)&msg_regs->isr, 0x00000091); 665 out_be32(&priv->msg_regs->isr, 0x00000091);
597 666
598 /* Hook up inbound message handler */ 667 /* Hook up inbound message handler */
599 if ((rc = 668 rc = request_irq(IRQ_RIO_RX(mport), fsl_rio_rx_handler, 0,
600 request_irq(MPC85xx_IRQ_RIO_RX, mpc85xx_rio_rx_handler, 0, 669 "msg_rx", (void *)mport);
601 "msg_rx", (void *)mport)) < 0) { 670 if (rc < 0) {
602 dma_free_coherent(NULL, RIO_MSG_BUFFER_SIZE, 671 dma_free_coherent(NULL, RIO_MSG_BUFFER_SIZE,
603 msg_tx_ring.virt_buffer[i], 672 priv->msg_tx_ring.virt_buffer[i],
604 msg_tx_ring.phys_buffer[i]); 673 priv->msg_tx_ring.phys_buffer[i]);
605 goto out; 674 goto out;
606 } 675 }
607 676
@@ -612,15 +681,13 @@ int rio_open_inb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entri
612 * Unmask all interrupt sources 681 * Unmask all interrupt sources
613 * Disable 682 * Disable
614 */ 683 */
615 out_be32((void *)&msg_regs->imr, 0x001b0060); 684 out_be32(&priv->msg_regs->imr, 0x001b0060);
616 685
617 /* Set number of queue entries */ 686 /* Set number of queue entries */
618 out_be32((void *)&msg_regs->imr, 687 setbits32(&priv->msg_regs->imr, (get_bitmask_order(entries) - 2) << 12);
619 in_be32((void *)&msg_regs->imr) |
620 ((get_bitmask_order(entries) - 2) << 12));
621 688
622 /* Now enable the unit */ 689 /* Now enable the unit */
623 out_be32((void *)&msg_regs->imr, in_be32((void *)&msg_regs->imr) | 0x1); 690 setbits32(&priv->msg_regs->imr, 0x1);
624 691
625 out: 692 out:
626 return rc; 693 return rc;
@@ -636,15 +703,16 @@ int rio_open_inb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entri
636 */ 703 */
637void rio_close_inb_mbox(struct rio_mport *mport, int mbox) 704void rio_close_inb_mbox(struct rio_mport *mport, int mbox)
638{ 705{
706 struct rio_priv *priv = mport->priv;
639 /* Disable inbound message unit */ 707 /* Disable inbound message unit */
640 out_be32((void *)&msg_regs->imr, 0); 708 out_be32(&priv->msg_regs->imr, 0);
641 709
642 /* Free ring */ 710 /* Free ring */
643 dma_free_coherent(NULL, msg_rx_ring.size * RIO_MAX_MSG_SIZE, 711 dma_free_coherent(NULL, priv->msg_rx_ring.size * RIO_MAX_MSG_SIZE,
644 msg_rx_ring.virt, msg_rx_ring.phys); 712 priv->msg_rx_ring.virt, priv->msg_rx_ring.phys);
645 713
646 /* Free interrupt */ 714 /* Free interrupt */
647 free_irq(MPC85xx_IRQ_RIO_RX, (void *)mport); 715 free_irq(IRQ_RIO_RX(mport), (void *)mport);
648} 716}
649 717
650/** 718/**
@@ -659,21 +727,22 @@ void rio_close_inb_mbox(struct rio_mport *mport, int mbox)
659int rio_hw_add_inb_buffer(struct rio_mport *mport, int mbox, void *buf) 727int rio_hw_add_inb_buffer(struct rio_mport *mport, int mbox, void *buf)
660{ 728{
661 int rc = 0; 729 int rc = 0;
730 struct rio_priv *priv = mport->priv;
662 731
663 pr_debug("RIO: rio_hw_add_inb_buffer(), msg_rx_ring.rx_slot %d\n", 732 pr_debug("RIO: rio_hw_add_inb_buffer(), msg_rx_ring.rx_slot %d\n",
664 msg_rx_ring.rx_slot); 733 priv->msg_rx_ring.rx_slot);
665 734
666 if (msg_rx_ring.virt_buffer[msg_rx_ring.rx_slot]) { 735 if (priv->msg_rx_ring.virt_buffer[priv->msg_rx_ring.rx_slot]) {
667 printk(KERN_ERR 736 printk(KERN_ERR
668 "RIO: error adding inbound buffer %d, buffer exists\n", 737 "RIO: error adding inbound buffer %d, buffer exists\n",
669 msg_rx_ring.rx_slot); 738 priv->msg_rx_ring.rx_slot);
670 rc = -EINVAL; 739 rc = -EINVAL;
671 goto out; 740 goto out;
672 } 741 }
673 742
674 msg_rx_ring.virt_buffer[msg_rx_ring.rx_slot] = buf; 743 priv->msg_rx_ring.virt_buffer[priv->msg_rx_ring.rx_slot] = buf;
675 if (++msg_rx_ring.rx_slot == msg_rx_ring.size) 744 if (++priv->msg_rx_ring.rx_slot == priv->msg_rx_ring.size)
676 msg_rx_ring.rx_slot = 0; 745 priv->msg_rx_ring.rx_slot = 0;
677 746
678 out: 747 out:
679 return rc; 748 return rc;
@@ -691,20 +760,21 @@ EXPORT_SYMBOL_GPL(rio_hw_add_inb_buffer);
691 */ 760 */
692void *rio_hw_get_inb_message(struct rio_mport *mport, int mbox) 761void *rio_hw_get_inb_message(struct rio_mport *mport, int mbox)
693{ 762{
694 u32 imr; 763 struct rio_priv *priv = mport->priv;
695 u32 phys_buf, virt_buf; 764 u32 phys_buf, virt_buf;
696 void *buf = NULL; 765 void *buf = NULL;
697 int buf_idx; 766 int buf_idx;
698 767
699 phys_buf = in_be32((void *)&msg_regs->ifqdpar); 768 phys_buf = in_be32(&priv->msg_regs->ifqdpar);
700 769
701 /* If no more messages, then bail out */ 770 /* If no more messages, then bail out */
702 if (phys_buf == in_be32((void *)&msg_regs->ifqepar)) 771 if (phys_buf == in_be32(&priv->msg_regs->ifqepar))
703 goto out2; 772 goto out2;
704 773
705 virt_buf = (u32) msg_rx_ring.virt + (phys_buf - msg_rx_ring.phys); 774 virt_buf = (u32) priv->msg_rx_ring.virt + (phys_buf
706 buf_idx = (phys_buf - msg_rx_ring.phys) / RIO_MAX_MSG_SIZE; 775 - priv->msg_rx_ring.phys);
707 buf = msg_rx_ring.virt_buffer[buf_idx]; 776 buf_idx = (phys_buf - priv->msg_rx_ring.phys) / RIO_MAX_MSG_SIZE;
777 buf = priv->msg_rx_ring.virt_buffer[buf_idx];
708 778
709 if (!buf) { 779 if (!buf) {
710 printk(KERN_ERR 780 printk(KERN_ERR
@@ -716,11 +786,10 @@ void *rio_hw_get_inb_message(struct rio_mport *mport, int mbox)
716 memcpy(buf, (void *)virt_buf, RIO_MAX_MSG_SIZE); 786 memcpy(buf, (void *)virt_buf, RIO_MAX_MSG_SIZE);
717 787
718 /* Clear the available buffer */ 788 /* Clear the available buffer */
719 msg_rx_ring.virt_buffer[buf_idx] = NULL; 789 priv->msg_rx_ring.virt_buffer[buf_idx] = NULL;
720 790
721 out1: 791 out1:
722 imr = in_be32((void *)&msg_regs->imr); 792 setbits32(&priv->msg_regs->imr, RIO_MSG_IMR_MI);
723 out_be32((void *)&msg_regs->imr, imr | RIO_MSG_IMR_MI);
724 793
725 out2: 794 out2:
726 return buf; 795 return buf;
@@ -729,7 +798,7 @@ void *rio_hw_get_inb_message(struct rio_mport *mport, int mbox)
729EXPORT_SYMBOL_GPL(rio_hw_get_inb_message); 798EXPORT_SYMBOL_GPL(rio_hw_get_inb_message);
730 799
731/** 800/**
732 * mpc85xx_rio_dbell_handler - MPC85xx doorbell interrupt handler 801 * fsl_rio_dbell_handler - MPC85xx doorbell interrupt handler
733 * @irq: Linux interrupt number 802 * @irq: Linux interrupt number
734 * @dev_instance: Pointer to interrupt-specific data 803 * @dev_instance: Pointer to interrupt-specific data
735 * 804 *
@@ -737,31 +806,31 @@ EXPORT_SYMBOL_GPL(rio_hw_get_inb_message);
737 * doorbell event handlers and executes a matching event handler. 806 * doorbell event handlers and executes a matching event handler.
738 */ 807 */
739static irqreturn_t 808static irqreturn_t
740mpc85xx_rio_dbell_handler(int irq, void *dev_instance) 809fsl_rio_dbell_handler(int irq, void *dev_instance)
741{ 810{
742 int dsr; 811 int dsr;
743 struct rio_mport *port = (struct rio_mport *)dev_instance; 812 struct rio_mport *port = (struct rio_mport *)dev_instance;
813 struct rio_priv *priv = port->priv;
744 814
745 dsr = in_be32((void *)&msg_regs->dsr); 815 dsr = in_be32(&priv->msg_regs->dsr);
746 816
747 if (dsr & DOORBELL_DSR_TE) { 817 if (dsr & DOORBELL_DSR_TE) {
748 pr_info("RIO: doorbell reception error\n"); 818 pr_info("RIO: doorbell reception error\n");
749 out_be32((void *)&msg_regs->dsr, DOORBELL_DSR_TE); 819 out_be32(&priv->msg_regs->dsr, DOORBELL_DSR_TE);
750 goto out; 820 goto out;
751 } 821 }
752 822
753 if (dsr & DOORBELL_DSR_QFI) { 823 if (dsr & DOORBELL_DSR_QFI) {
754 pr_info("RIO: doorbell queue full\n"); 824 pr_info("RIO: doorbell queue full\n");
755 out_be32((void *)&msg_regs->dsr, DOORBELL_DSR_QFI); 825 out_be32(&priv->msg_regs->dsr, DOORBELL_DSR_QFI);
756 goto out; 826 goto out;
757 } 827 }
758 828
759 /* XXX Need to check/dispatch until queue empty */ 829 /* XXX Need to check/dispatch until queue empty */
760 if (dsr & DOORBELL_DSR_DIQI) { 830 if (dsr & DOORBELL_DSR_DIQI) {
761 u32 dmsg = 831 u32 dmsg =
762 (u32) dbell_ring.virt + 832 (u32) priv->dbell_ring.virt +
763 (in_be32((void *)&msg_regs->dqdpar) & 0xfff); 833 (in_be32(&priv->msg_regs->dqdpar) & 0xfff);
764 u32 dmr;
765 struct rio_dbell *dbell; 834 struct rio_dbell *dbell;
766 int found = 0; 835 int found = 0;
767 836
@@ -784,9 +853,8 @@ mpc85xx_rio_dbell_handler(int irq, void *dev_instance)
784 ("RIO: spurious doorbell, sid %2.2x tid %2.2x info %4.4x\n", 853 ("RIO: spurious doorbell, sid %2.2x tid %2.2x info %4.4x\n",
785 DBELL_SID(dmsg), DBELL_TID(dmsg), DBELL_INF(dmsg)); 854 DBELL_SID(dmsg), DBELL_TID(dmsg), DBELL_INF(dmsg));
786 } 855 }
787 dmr = in_be32((void *)&msg_regs->dmr); 856 setbits32(&priv->msg_regs->dmr, DOORBELL_DMR_DI);
788 out_be32((void *)&msg_regs->dmr, dmr | DOORBELL_DMR_DI); 857 out_be32(&priv->msg_regs->dsr, DOORBELL_DSR_DIQI);
789 out_be32((void *)&msg_regs->dsr, DOORBELL_DSR_DIQI);
790 } 858 }
791 859
792 out: 860 out:
@@ -794,21 +862,22 @@ mpc85xx_rio_dbell_handler(int irq, void *dev_instance)
794} 862}
795 863
796/** 864/**
797 * mpc85xx_rio_doorbell_init - MPC85xx doorbell interface init 865 * fsl_rio_doorbell_init - MPC85xx doorbell interface init
798 * @mport: Master port implementing the inbound doorbell unit 866 * @mport: Master port implementing the inbound doorbell unit
799 * 867 *
800 * Initializes doorbell unit hardware and inbound DMA buffer 868 * Initializes doorbell unit hardware and inbound DMA buffer
801 * ring. Called from mpc85xx_rio_setup(). Returns %0 on success 869 * ring. Called from fsl_rio_setup(). Returns %0 on success
802 * or %-ENOMEM on failure. 870 * or %-ENOMEM on failure.
803 */ 871 */
804static int mpc85xx_rio_doorbell_init(struct rio_mport *mport) 872static int fsl_rio_doorbell_init(struct rio_mport *mport)
805{ 873{
874 struct rio_priv *priv = mport->priv;
806 int rc = 0; 875 int rc = 0;
807 876
808 /* Map outbound doorbell window immediately after maintenance window */ 877 /* Map outbound doorbell window immediately after maintenance window */
809 if (!(dbell_win = 878 priv->dbell_win = ioremap(mport->iores.start + RIO_MAINT_WIN_SIZE,
810 (u32) ioremap(mport->iores.start + RIO_MAINT_WIN_SIZE, 879 RIO_DBELL_WIN_SIZE);
811 RIO_DBELL_WIN_SIZE))) { 880 if (!priv->dbell_win) {
812 printk(KERN_ERR 881 printk(KERN_ERR
813 "RIO: unable to map outbound doorbell window\n"); 882 "RIO: unable to map outbound doorbell window\n");
814 rc = -ENOMEM; 883 rc = -ENOMEM;
@@ -816,37 +885,36 @@ static int mpc85xx_rio_doorbell_init(struct rio_mport *mport)
816 } 885 }
817 886
818 /* Initialize inbound doorbells */ 887 /* Initialize inbound doorbells */
819 if (!(dbell_ring.virt = dma_alloc_coherent(NULL, 888 priv->dbell_ring.virt = dma_alloc_coherent(NULL, 512 *
820 512 * DOORBELL_MESSAGE_SIZE, 889 DOORBELL_MESSAGE_SIZE, &priv->dbell_ring.phys, GFP_KERNEL);
821 &dbell_ring.phys, 890 if (!priv->dbell_ring.virt) {
822 GFP_KERNEL))) {
823 printk(KERN_ERR "RIO: unable allocate inbound doorbell ring\n"); 891 printk(KERN_ERR "RIO: unable allocate inbound doorbell ring\n");
824 rc = -ENOMEM; 892 rc = -ENOMEM;
825 iounmap((void *)dbell_win); 893 iounmap(priv->dbell_win);
826 goto out; 894 goto out;
827 } 895 }
828 896
829 /* Point dequeue/enqueue pointers at first entry in ring */ 897 /* Point dequeue/enqueue pointers at first entry in ring */
830 out_be32((void *)&msg_regs->dqdpar, (u32) dbell_ring.phys); 898 out_be32(&priv->msg_regs->dqdpar, (u32) priv->dbell_ring.phys);
831 out_be32((void *)&msg_regs->dqepar, (u32) dbell_ring.phys); 899 out_be32(&priv->msg_regs->dqepar, (u32) priv->dbell_ring.phys);
832 900
833 /* Clear interrupt status */ 901 /* Clear interrupt status */
834 out_be32((void *)&msg_regs->dsr, 0x00000091); 902 out_be32(&priv->msg_regs->dsr, 0x00000091);
835 903
836 /* Hook up doorbell handler */ 904 /* Hook up doorbell handler */
837 if ((rc = 905 rc = request_irq(IRQ_RIO_BELL(mport), fsl_rio_dbell_handler, 0,
838 request_irq(MPC85xx_IRQ_RIO_BELL, mpc85xx_rio_dbell_handler, 0, 906 "dbell_rx", (void *)mport);
839 "dbell_rx", (void *)mport) < 0)) { 907 if (rc < 0) {
840 iounmap((void *)dbell_win); 908 iounmap(priv->dbell_win);
841 dma_free_coherent(NULL, 512 * DOORBELL_MESSAGE_SIZE, 909 dma_free_coherent(NULL, 512 * DOORBELL_MESSAGE_SIZE,
842 dbell_ring.virt, dbell_ring.phys); 910 priv->dbell_ring.virt, priv->dbell_ring.phys);
843 printk(KERN_ERR 911 printk(KERN_ERR
844 "MPC85xx RIO: unable to request inbound doorbell irq"); 912 "MPC85xx RIO: unable to request inbound doorbell irq");
845 goto out; 913 goto out;
846 } 914 }
847 915
848 /* Configure doorbells for snooping, 512 entries, and enable */ 916 /* Configure doorbells for snooping, 512 entries, and enable */
849 out_be32((void *)&msg_regs->dmr, 0x00108161); 917 out_be32(&priv->msg_regs->dmr, 0x00108161);
850 918
851 out: 919 out:
852 return rc; 920 return rc;
@@ -854,7 +922,7 @@ static int mpc85xx_rio_doorbell_init(struct rio_mport *mport)
854 922
855static char *cmdline = NULL; 923static char *cmdline = NULL;
856 924
857static int mpc85xx_rio_get_hdid(int index) 925static int fsl_rio_get_hdid(int index)
858{ 926{
859 /* XXX Need to parse multiple entries in some format */ 927 /* XXX Need to parse multiple entries in some format */
860 if (!cmdline) 928 if (!cmdline)
@@ -863,7 +931,7 @@ static int mpc85xx_rio_get_hdid(int index)
863 return simple_strtol(cmdline, NULL, 0); 931 return simple_strtol(cmdline, NULL, 0);
864} 932}
865 933
866static int mpc85xx_rio_get_cmdline(char *s) 934static int fsl_rio_get_cmdline(char *s)
867{ 935{
868 if (!s) 936 if (!s)
869 return 0; 937 return 0;
@@ -872,61 +940,266 @@ static int mpc85xx_rio_get_cmdline(char *s)
872 return 1; 940 return 1;
873} 941}
874 942
875__setup("riohdid=", mpc85xx_rio_get_cmdline); 943__setup("riohdid=", fsl_rio_get_cmdline);
944
945static inline void fsl_rio_info(struct device *dev, u32 ccsr)
946{
947 const char *str;
948 if (ccsr & 1) {
949 /* Serial phy */
950 switch (ccsr >> 30) {
951 case 0:
952 str = "1";
953 break;
954 case 1:
955 str = "4";
956 break;
957 default:
958 str = "Unknown";
959 break;;
960 }
961 dev_info(dev, "Hardware port width: %s\n", str);
962
963 switch ((ccsr >> 27) & 7) {
964 case 0:
965 str = "Single-lane 0";
966 break;
967 case 1:
968 str = "Single-lane 2";
969 break;
970 case 2:
971 str = "Four-lane";
972 break;
973 default:
974 str = "Unknown";
975 break;
976 }
977 dev_info(dev, "Training connection status: %s\n", str);
978 } else {
979 /* Parallel phy */
980 if (!(ccsr & 0x80000000))
981 dev_info(dev, "Output port operating in 8-bit mode\n");
982 if (!(ccsr & 0x08000000))
983 dev_info(dev, "Input port operating in 8-bit mode\n");
984 }
985}
876 986
877/** 987/**
878 * mpc85xx_rio_setup - Setup MPC85xx RapidIO interface 988 * fsl_rio_setup - Setup MPC85xx RapidIO interface
879 * @law_start: Starting physical address of RapidIO LAW 989 * @fsl_rio_setup - Setup Freescale PowerPC RapidIO interface
880 * @law_size: Size of RapidIO LAW
881 * 990 *
882 * Initializes MPC85xx RapidIO hardware interface, configures 991 * Initializes MPC85xx RapidIO hardware interface, configures
883 * master port with system-specific info, and registers the 992 * master port with system-specific info, and registers the
884 * master port with the RapidIO subsystem. 993 * master port with the RapidIO subsystem.
885 */ 994 */
886void mpc85xx_rio_setup(int law_start, int law_size) 995int fsl_rio_setup(struct of_device *dev)
887{ 996{
888 struct rio_ops *ops; 997 struct rio_ops *ops;
889 struct rio_mport *port; 998 struct rio_mport *port;
999 struct rio_priv *priv;
1000 int rc = 0;
1001 const u32 *dt_range, *cell;
1002 struct resource regs;
1003 int rlen;
1004 u32 ccsr;
1005 u64 law_start, law_size;
1006 int paw, aw, sw;
1007
1008 if (!dev->node) {
1009 dev_err(&dev->dev, "Device OF-Node is NULL");
1010 return -EFAULT;
1011 }
1012
1013 rc = of_address_to_resource(dev->node, 0, &regs);
1014 if (rc) {
1015 dev_err(&dev->dev, "Can't get %s property 'reg'\n",
1016 dev->node->full_name);
1017 return -EFAULT;
1018 }
1019 dev_info(&dev->dev, "Of-device full name %s\n", dev->node->full_name);
1020 dev_info(&dev->dev, "Regs start 0x%08x size 0x%08x\n", regs.start,
1021 regs.end - regs.start + 1);
1022
1023 dt_range = of_get_property(dev->node, "ranges", &rlen);
1024 if (!dt_range) {
1025 dev_err(&dev->dev, "Can't get %s property 'ranges'\n",
1026 dev->node->full_name);
1027 return -EFAULT;
1028 }
1029
1030 /* Get node address wide */
1031 cell = of_get_property(dev->node, "#address-cells", NULL);
1032 if (cell)
1033 aw = *cell;
1034 else
1035 aw = of_n_addr_cells(dev->node);
1036 /* Get node size wide */
1037 cell = of_get_property(dev->node, "#size-cells", NULL);
1038 if (cell)
1039 sw = *cell;
1040 else
1041 sw = of_n_size_cells(dev->node);
1042 /* Get parent address wide wide */
1043 paw = of_n_addr_cells(dev->node);
1044
1045 law_start = of_read_number(dt_range + aw, paw);
1046 law_size = of_read_number(dt_range + aw + paw, sw);
1047
1048 dev_info(&dev->dev, "LAW start 0x%016llx, size 0x%016llx.\n",
1049 law_start, law_size);
890 1050
891 ops = kmalloc(sizeof(struct rio_ops), GFP_KERNEL); 1051 ops = kmalloc(sizeof(struct rio_ops), GFP_KERNEL);
892 ops->lcread = mpc85xx_local_config_read; 1052 ops->lcread = fsl_local_config_read;
893 ops->lcwrite = mpc85xx_local_config_write; 1053 ops->lcwrite = fsl_local_config_write;
894 ops->cread = mpc85xx_rio_config_read; 1054 ops->cread = fsl_rio_config_read;
895 ops->cwrite = mpc85xx_rio_config_write; 1055 ops->cwrite = fsl_rio_config_write;
896 ops->dsend = mpc85xx_rio_doorbell_send; 1056 ops->dsend = fsl_rio_doorbell_send;
897 1057
898 port = kmalloc(sizeof(struct rio_mport), GFP_KERNEL); 1058 port = kzalloc(sizeof(struct rio_mport), GFP_KERNEL);
899 port->id = 0; 1059 port->id = 0;
900 port->index = 0; 1060 port->index = 0;
1061
1062 priv = kzalloc(sizeof(struct rio_priv), GFP_KERNEL);
1063 if (!priv) {
1064 printk(KERN_ERR "Can't alloc memory for 'priv'\n");
1065 rc = -ENOMEM;
1066 goto err;
1067 }
1068
901 INIT_LIST_HEAD(&port->dbells); 1069 INIT_LIST_HEAD(&port->dbells);
902 port->iores.start = law_start; 1070 port->iores.start = law_start;
903 port->iores.end = law_start + law_size; 1071 port->iores.end = law_start + law_size;
904 port->iores.flags = IORESOURCE_MEM; 1072 port->iores.flags = IORESOURCE_MEM;
905 1073
1074 priv->bellirq = irq_of_parse_and_map(dev->node, 2);
1075 priv->txirq = irq_of_parse_and_map(dev->node, 3);
1076 priv->rxirq = irq_of_parse_and_map(dev->node, 4);
1077 dev_info(&dev->dev, "bellirq: %d, txirq: %d, rxirq %d\n", priv->bellirq,
1078 priv->txirq, priv->rxirq);
1079
906 rio_init_dbell_res(&port->riores[RIO_DOORBELL_RESOURCE], 0, 0xffff); 1080 rio_init_dbell_res(&port->riores[RIO_DOORBELL_RESOURCE], 0, 0xffff);
907 rio_init_mbox_res(&port->riores[RIO_INB_MBOX_RESOURCE], 0, 0); 1081 rio_init_mbox_res(&port->riores[RIO_INB_MBOX_RESOURCE], 0, 0);
908 rio_init_mbox_res(&port->riores[RIO_OUTB_MBOX_RESOURCE], 0, 0); 1082 rio_init_mbox_res(&port->riores[RIO_OUTB_MBOX_RESOURCE], 0, 0);
909 strcpy(port->name, "RIO0 mport"); 1083 strcpy(port->name, "RIO0 mport");
910 1084
911 port->ops = ops; 1085 port->ops = ops;
912 port->host_deviceid = mpc85xx_rio_get_hdid(port->id); 1086 port->host_deviceid = fsl_rio_get_hdid(port->id);
913 1087
1088 port->priv = priv;
914 rio_register_mport(port); 1089 rio_register_mport(port);
915 1090
916 regs_win = (u32) ioremap(RIO_REGS_BASE, 0x20000); 1091 priv->regs_win = ioremap(regs.start, regs.end - regs.start + 1);
917 atmu_regs = (struct rio_atmu_regs *)(regs_win + RIO_ATMU_REGS_OFFSET); 1092
918 maint_atmu_regs = atmu_regs + 1; 1093 /* Probe the master port phy type */
919 dbell_atmu_regs = atmu_regs + 2; 1094 ccsr = in_be32(priv->regs_win + RIO_CCSR);
920 msg_regs = (struct rio_msg_regs *)(regs_win + RIO_MSG_REGS_OFFSET); 1095 port->phy_type = (ccsr & 1) ? RIO_PHY_SERIAL : RIO_PHY_PARALLEL;
1096 dev_info(&dev->dev, "RapidIO PHY type: %s\n",
1097 (port->phy_type == RIO_PHY_PARALLEL) ? "parallel" :
1098 ((port->phy_type == RIO_PHY_SERIAL) ? "serial" :
1099 "unknown"));
1100 /* Checking the port training status */
1101 if (in_be32((priv->regs_win + RIO_ESCSR)) & 1) {
1102 dev_err(&dev->dev, "Port is not ready. "
1103 "Try to restart connection...\n");
1104 switch (port->phy_type) {
1105 case RIO_PHY_SERIAL:
1106 /* Disable ports */
1107 out_be32(priv->regs_win + RIO_CCSR, 0);
1108 /* Set 1x lane */
1109 setbits32(priv->regs_win + RIO_CCSR, 0x02000000);
1110 /* Enable ports */
1111 setbits32(priv->regs_win + RIO_CCSR, 0x00600000);
1112 break;
1113 case RIO_PHY_PARALLEL:
1114 /* Disable ports */
1115 out_be32(priv->regs_win + RIO_CCSR, 0x22000000);
1116 /* Enable ports */
1117 out_be32(priv->regs_win + RIO_CCSR, 0x44000000);
1118 break;
1119 }
1120 msleep(100);
1121 if (in_be32((priv->regs_win + RIO_ESCSR)) & 1) {
1122 dev_err(&dev->dev, "Port restart failed.\n");
1123 rc = -ENOLINK;
1124 goto err;
1125 }
1126 dev_info(&dev->dev, "Port restart success!\n");
1127 }
1128 fsl_rio_info(&dev->dev, ccsr);
1129
1130 port->sys_size = (in_be32((priv->regs_win + RIO_PEF_CAR))
1131 & RIO_PEF_CTLS) >> 4;
1132 dev_info(&dev->dev, "RapidIO Common Transport System size: %d\n",
1133 port->sys_size ? 65536 : 256);
1134
1135 priv->atmu_regs = (struct rio_atmu_regs *)(priv->regs_win
1136 + RIO_ATMU_REGS_OFFSET);
1137 priv->maint_atmu_regs = priv->atmu_regs + 1;
1138 priv->dbell_atmu_regs = priv->atmu_regs + 2;
1139 priv->msg_regs = (struct rio_msg_regs *)(priv->regs_win +
1140 ((port->phy_type == RIO_PHY_SERIAL) ?
1141 RIO_S_MSG_REGS_OFFSET : RIO_P_MSG_REGS_OFFSET));
1142
1143 /* Set to receive any dist ID for serial RapidIO controller. */
1144 if (port->phy_type == RIO_PHY_SERIAL)
1145 out_be32((priv->regs_win + RIO_ISR_AACR), RIO_ISR_AACR_AA);
921 1146
922 /* Configure maintenance transaction window */ 1147 /* Configure maintenance transaction window */
923 out_be32((void *)&maint_atmu_regs->rowbar, 0x000c0000); 1148 out_be32(&priv->maint_atmu_regs->rowbar, 0x000c0000);
924 out_be32((void *)&maint_atmu_regs->rowar, 0x80077015); 1149 out_be32(&priv->maint_atmu_regs->rowar, 0x80077015);
925 1150
926 maint_win = (u32) ioremap(law_start, RIO_MAINT_WIN_SIZE); 1151 priv->maint_win = ioremap(law_start, RIO_MAINT_WIN_SIZE);
927 1152
928 /* Configure outbound doorbell window */ 1153 /* Configure outbound doorbell window */
929 out_be32((void *)&dbell_atmu_regs->rowbar, 0x000c0400); 1154 out_be32(&priv->dbell_atmu_regs->rowbar, 0x000c0400);
930 out_be32((void *)&dbell_atmu_regs->rowar, 0x8004200b); 1155 out_be32(&priv->dbell_atmu_regs->rowar, 0x8004200b);
931 mpc85xx_rio_doorbell_init(port); 1156 fsl_rio_doorbell_init(port);
1157
1158 return 0;
1159err:
1160 if (priv)
1161 iounmap(priv->regs_win);
1162 kfree(ops);
1163 kfree(priv);
1164 kfree(port);
1165 return rc;
1166}
1167
1168/* The probe function for RapidIO peer-to-peer network.
1169 */
1170static int __devinit fsl_of_rio_rpn_probe(struct of_device *dev,
1171 const struct of_device_id *match)
1172{
1173 int rc;
1174 printk(KERN_INFO "Setting up RapidIO peer-to-peer network %s\n",
1175 dev->node->full_name);
1176
1177 rc = fsl_rio_setup(dev);
1178 if (rc)
1179 goto out;
1180
1181 /* Enumerate all registered ports */
1182 rc = rio_init_mports();
1183out:
1184 return rc;
1185};
1186
1187static const struct of_device_id fsl_of_rio_rpn_ids[] = {
1188 {
1189 .compatible = "fsl,rapidio-delta",
1190 },
1191 {},
1192};
1193
1194static struct of_platform_driver fsl_of_rio_rpn_driver = {
1195 .name = "fsl-of-rio",
1196 .match_table = fsl_of_rio_rpn_ids,
1197 .probe = fsl_of_rio_rpn_probe,
1198};
1199
1200static __init int fsl_of_rio_rpn_init(void)
1201{
1202 return of_register_platform_driver(&fsl_of_rio_rpn_driver);
932} 1203}
1204
1205subsys_initcall(fsl_of_rio_rpn_init);
diff --git a/arch/powerpc/sysdev/fsl_rio.h b/arch/powerpc/sysdev/fsl_rio.h
deleted file mode 100644
index 6d3ff30b1579..000000000000
--- a/arch/powerpc/sysdev/fsl_rio.h
+++ /dev/null
@@ -1,20 +0,0 @@
1/*
2 * MPC85xx RapidIO definitions
3 *
4 * Copyright 2005 MontaVista Software, Inc.
5 * Matt Porter <mporter@kernel.crashing.org>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 */
12
13#ifndef __PPC_SYSLIB_PPC85XX_RIO_H
14#define __PPC_SYSLIB_PPC85XX_RIO_H
15
16#include <linux/init.h>
17
18extern void mpc85xx_rio_setup(int law_start, int law_size);
19
20#endif /* __PPC_SYSLIB_PPC85XX_RIO_H */