aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/ppc/Kconfig8
-rw-r--r--arch/ppc/configs/stx_gp3_defconfig86
-rw-r--r--arch/ppc/kernel/Makefile1
-rw-r--r--arch/ppc/kernel/rio.c52
-rw-r--r--arch/ppc/platforms/85xx/mpc85xx_ads_common.c10
-rw-r--r--arch/ppc/platforms/85xx/stx_gp3.c14
-rw-r--r--arch/ppc/syslib/Makefile1
-rw-r--r--arch/ppc/syslib/ppc85xx_rio.c932
-rw-r--r--arch/ppc/syslib/ppc85xx_rio.h21
-rw-r--r--include/asm-ppc/rio.h18
10 files changed, 1109 insertions, 34 deletions
diff --git a/arch/ppc/Kconfig b/arch/ppc/Kconfig
index f8db33d55275..8fa51b0a32d2 100644
--- a/arch/ppc/Kconfig
+++ b/arch/ppc/Kconfig
@@ -1257,6 +1257,14 @@ source "drivers/pci/Kconfig"
1257 1257
1258source "drivers/pcmcia/Kconfig" 1258source "drivers/pcmcia/Kconfig"
1259 1259
1260config RAPIDIO
1261 bool "RapidIO support" if MPC8540 || MPC8560
1262 help
1263 If you say Y here, the kernel will include drivers and
1264 infrastructure code to support RapidIO interconnect devices.
1265
1266source "drivers/rapidio/Kconfig"
1267
1260endmenu 1268endmenu
1261 1269
1262menu "Advanced setup" 1270menu "Advanced setup"
diff --git a/arch/ppc/configs/stx_gp3_defconfig b/arch/ppc/configs/stx_gp3_defconfig
index 66dae8367659..3fedc43e44ad 100644
--- a/arch/ppc/configs/stx_gp3_defconfig
+++ b/arch/ppc/configs/stx_gp3_defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.11-rc2 3# Linux kernel version: 2.6.12-rc4
4# Wed Jan 26 14:32:58 2005 4# Tue May 24 18:11:04 2005
5# 5#
6CONFIG_MMU=y 6CONFIG_MMU=y
7CONFIG_GENERIC_HARDIRQS=y 7CONFIG_GENERIC_HARDIRQS=y
@@ -11,6 +11,7 @@ CONFIG_HAVE_DEC_LOCK=y
11CONFIG_PPC=y 11CONFIG_PPC=y
12CONFIG_PPC32=y 12CONFIG_PPC32=y
13CONFIG_GENERIC_NVRAM=y 13CONFIG_GENERIC_NVRAM=y
14CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
14 15
15# 16#
16# Code maturity level options 17# Code maturity level options
@@ -18,6 +19,7 @@ CONFIG_GENERIC_NVRAM=y
18CONFIG_EXPERIMENTAL=y 19CONFIG_EXPERIMENTAL=y
19CONFIG_CLEAN_COMPILE=y 20CONFIG_CLEAN_COMPILE=y
20CONFIG_BROKEN_ON_SMP=y 21CONFIG_BROKEN_ON_SMP=y
22CONFIG_INIT_ENV_ARG_LIMIT=32
21 23
22# 24#
23# General setup 25# General setup
@@ -29,7 +31,6 @@ CONFIG_SYSVIPC=y
29# CONFIG_BSD_PROCESS_ACCT is not set 31# CONFIG_BSD_PROCESS_ACCT is not set
30CONFIG_SYSCTL=y 32CONFIG_SYSCTL=y
31# CONFIG_AUDIT is not set 33# CONFIG_AUDIT is not set
32CONFIG_LOG_BUF_SHIFT=14
33CONFIG_HOTPLUG=y 34CONFIG_HOTPLUG=y
34CONFIG_KOBJECT_UEVENT=y 35CONFIG_KOBJECT_UEVENT=y
35# CONFIG_IKCONFIG is not set 36# CONFIG_IKCONFIG is not set
@@ -37,6 +38,9 @@ CONFIG_EMBEDDED=y
37CONFIG_KALLSYMS=y 38CONFIG_KALLSYMS=y
38# CONFIG_KALLSYMS_ALL is not set 39# CONFIG_KALLSYMS_ALL is not set
39# CONFIG_KALLSYMS_EXTRA_PASS is not set 40# CONFIG_KALLSYMS_EXTRA_PASS is not set
41CONFIG_PRINTK=y
42CONFIG_BUG=y
43CONFIG_BASE_FULL=y
40CONFIG_FUTEX=y 44CONFIG_FUTEX=y
41CONFIG_EPOLL=y 45CONFIG_EPOLL=y
42# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 46# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
@@ -46,6 +50,7 @@ CONFIG_CC_ALIGN_LABELS=0
46CONFIG_CC_ALIGN_LOOPS=0 50CONFIG_CC_ALIGN_LOOPS=0
47CONFIG_CC_ALIGN_JUMPS=0 51CONFIG_CC_ALIGN_JUMPS=0
48# CONFIG_TINY_SHMEM is not set 52# CONFIG_TINY_SHMEM is not set
53CONFIG_BASE_SMALL=0
49 54
50# 55#
51# Loadable module support 56# Loadable module support
@@ -69,9 +74,11 @@ CONFIG_KMOD=y
69CONFIG_E500=y 74CONFIG_E500=y
70CONFIG_BOOKE=y 75CONFIG_BOOKE=y
71CONFIG_FSL_BOOKE=y 76CONFIG_FSL_BOOKE=y
77# CONFIG_PHYS_64BIT is not set
72# CONFIG_SPE is not set 78# CONFIG_SPE is not set
73CONFIG_MATH_EMULATION=y 79CONFIG_MATH_EMULATION=y
74# CONFIG_CPU_FREQ is not set 80# CONFIG_CPU_FREQ is not set
81# CONFIG_PM is not set
75CONFIG_85xx=y 82CONFIG_85xx=y
76CONFIG_PPC_INDIRECT_PCI_BE=y 83CONFIG_PPC_INDIRECT_PCI_BE=y
77 84
@@ -96,6 +103,7 @@ CONFIG_HIGHMEM=y
96CONFIG_BINFMT_ELF=y 103CONFIG_BINFMT_ELF=y
97CONFIG_BINFMT_MISC=m 104CONFIG_BINFMT_MISC=m
98# CONFIG_CMDLINE_BOOL is not set 105# CONFIG_CMDLINE_BOOL is not set
106CONFIG_ISA_DMA_API=y
99 107
100# 108#
101# Bus options 109# Bus options
@@ -104,15 +112,15 @@ CONFIG_PCI=y
104CONFIG_PCI_DOMAINS=y 112CONFIG_PCI_DOMAINS=y
105# CONFIG_PCI_LEGACY_PROC is not set 113# CONFIG_PCI_LEGACY_PROC is not set
106# CONFIG_PCI_NAMES is not set 114# CONFIG_PCI_NAMES is not set
115# CONFIG_PCI_DEBUG is not set
107 116
108# 117#
109# PCCARD (PCMCIA/CardBus) support 118# PCCARD (PCMCIA/CardBus) support
110# 119#
111# CONFIG_PCCARD is not set 120# CONFIG_PCCARD is not set
112 121CONFIG_RAPIDIO=y
113# 122CONFIG_RAPIDIO_8_BIT_TRANSPORT=y
114# PC-card bridges 123CONFIG_RAPIDIO_DISC_TIMEOUT=30
115#
116 124
117# 125#
118# Advanced setup 126# Advanced setup
@@ -152,7 +160,7 @@ CONFIG_PARPORT=m
152CONFIG_PARPORT_PC=m 160CONFIG_PARPORT_PC=m
153# CONFIG_PARPORT_PC_FIFO is not set 161# CONFIG_PARPORT_PC_FIFO is not set
154# CONFIG_PARPORT_PC_SUPERIO is not set 162# CONFIG_PARPORT_PC_SUPERIO is not set
155# CONFIG_PARPORT_OTHER is not set 163# CONFIG_PARPORT_GSC is not set
156# CONFIG_PARPORT_1284 is not set 164# CONFIG_PARPORT_1284 is not set
157 165
158# 166#
@@ -264,7 +272,6 @@ CONFIG_SCSI_CONSTANTS=y
264# CONFIG_SCSI_BUSLOGIC is not set 272# CONFIG_SCSI_BUSLOGIC is not set
265# CONFIG_SCSI_DMX3191D is not set 273# CONFIG_SCSI_DMX3191D is not set
266# CONFIG_SCSI_EATA is not set 274# CONFIG_SCSI_EATA is not set
267# CONFIG_SCSI_EATA_PIO is not set
268# CONFIG_SCSI_FUTURE_DOMAIN is not set 275# CONFIG_SCSI_FUTURE_DOMAIN is not set
269# CONFIG_SCSI_GDTH is not set 276# CONFIG_SCSI_GDTH is not set
270# CONFIG_SCSI_IPS is not set 277# CONFIG_SCSI_IPS is not set
@@ -274,7 +281,6 @@ CONFIG_SCSI_CONSTANTS=y
274# CONFIG_SCSI_IMM is not set 281# CONFIG_SCSI_IMM is not set
275# CONFIG_SCSI_SYM53C8XX_2 is not set 282# CONFIG_SCSI_SYM53C8XX_2 is not set
276# CONFIG_SCSI_IPR is not set 283# CONFIG_SCSI_IPR is not set
277# CONFIG_SCSI_QLOGIC_ISP is not set
278# CONFIG_SCSI_QLOGIC_FC is not set 284# CONFIG_SCSI_QLOGIC_FC is not set
279# CONFIG_SCSI_QLOGIC_1280 is not set 285# CONFIG_SCSI_QLOGIC_1280 is not set
280CONFIG_SCSI_QLA2XXX=m 286CONFIG_SCSI_QLA2XXX=m
@@ -283,6 +289,7 @@ CONFIG_SCSI_QLA2XXX=m
283# CONFIG_SCSI_QLA2300 is not set 289# CONFIG_SCSI_QLA2300 is not set
284# CONFIG_SCSI_QLA2322 is not set 290# CONFIG_SCSI_QLA2322 is not set
285# CONFIG_SCSI_QLA6312 is not set 291# CONFIG_SCSI_QLA6312 is not set
292# CONFIG_SCSI_LPFC is not set
286# CONFIG_SCSI_DC395x is not set 293# CONFIG_SCSI_DC395x is not set
287# CONFIG_SCSI_DC390T is not set 294# CONFIG_SCSI_DC390T is not set
288# CONFIG_SCSI_NSP32 is not set 295# CONFIG_SCSI_NSP32 is not set
@@ -322,7 +329,6 @@ CONFIG_NET=y
322# 329#
323CONFIG_PACKET=y 330CONFIG_PACKET=y
324# CONFIG_PACKET_MMAP is not set 331# CONFIG_PACKET_MMAP is not set
325# CONFIG_NETLINK_DEV is not set
326CONFIG_UNIX=y 332CONFIG_UNIX=y
327# CONFIG_NET_KEY is not set 333# CONFIG_NET_KEY is not set
328CONFIG_INET=y 334CONFIG_INET=y
@@ -431,7 +437,7 @@ CONFIG_IP_NF_NAT_FTP=m
431# 437#
432# Network testing 438# Network testing
433# 439#
434# CONFIG_NET_PKTGEN is not set 440CONFIG_NET_PKTGEN=y
435# CONFIG_NETPOLL is not set 441# CONFIG_NETPOLL is not set
436# CONFIG_NET_POLL_CONTROLLER is not set 442# CONFIG_NET_POLL_CONTROLLER is not set
437# CONFIG_HAMRADIO is not set 443# CONFIG_HAMRADIO is not set
@@ -499,6 +505,7 @@ CONFIG_GFAR_NAPI=y
499# Wan interfaces 505# Wan interfaces
500# 506#
501# CONFIG_WAN is not set 507# CONFIG_WAN is not set
508CONFIG_RIONET=y
502# CONFIG_FDDI is not set 509# CONFIG_FDDI is not set
503# CONFIG_HIPPI is not set 510# CONFIG_HIPPI is not set
504# CONFIG_PLIP is not set 511# CONFIG_PLIP is not set
@@ -536,20 +543,6 @@ CONFIG_INPUT_EVDEV=m
536# CONFIG_INPUT_EVBUG is not set 543# CONFIG_INPUT_EVBUG is not set
537 544
538# 545#
539# Input I/O drivers
540#
541# CONFIG_GAMEPORT is not set
542CONFIG_SOUND_GAMEPORT=y
543CONFIG_SERIO=y
544CONFIG_SERIO_I8042=y
545CONFIG_SERIO_SERPORT=y
546# CONFIG_SERIO_CT82C710 is not set
547# CONFIG_SERIO_PARKBD is not set
548# CONFIG_SERIO_PCIPS2 is not set
549CONFIG_SERIO_LIBPS2=y
550# CONFIG_SERIO_RAW is not set
551
552#
553# Input Device Drivers 546# Input Device Drivers
554# 547#
555CONFIG_INPUT_KEYBOARD=y 548CONFIG_INPUT_KEYBOARD=y
@@ -567,6 +560,19 @@ CONFIG_MOUSE_PS2=y
567# CONFIG_INPUT_MISC is not set 560# CONFIG_INPUT_MISC is not set
568 561
569# 562#
563# Hardware I/O ports
564#
565CONFIG_SERIO=y
566CONFIG_SERIO_I8042=y
567CONFIG_SERIO_SERPORT=y
568# CONFIG_SERIO_PARKBD is not set
569# CONFIG_SERIO_PCIPS2 is not set
570CONFIG_SERIO_LIBPS2=y
571# CONFIG_SERIO_RAW is not set
572# CONFIG_GAMEPORT is not set
573CONFIG_SOUND_GAMEPORT=y
574
575#
570# Character devices 576# Character devices
571# 577#
572# CONFIG_VT is not set 578# CONFIG_VT is not set
@@ -590,6 +596,7 @@ CONFIG_SERIAL_CPM_SCC2=y
590# CONFIG_SERIAL_CPM_SCC4 is not set 596# CONFIG_SERIAL_CPM_SCC4 is not set
591# CONFIG_SERIAL_CPM_SMC1 is not set 597# CONFIG_SERIAL_CPM_SMC1 is not set
592# CONFIG_SERIAL_CPM_SMC2 is not set 598# CONFIG_SERIAL_CPM_SMC2 is not set
599# CONFIG_SERIAL_JSM is not set
593CONFIG_UNIX98_PTYS=y 600CONFIG_UNIX98_PTYS=y
594CONFIG_LEGACY_PTYS=y 601CONFIG_LEGACY_PTYS=y
595CONFIG_LEGACY_PTY_COUNT=256 602CONFIG_LEGACY_PTY_COUNT=256
@@ -626,6 +633,11 @@ CONFIG_DRM=m
626# CONFIG_RAW_DRIVER is not set 633# CONFIG_RAW_DRIVER is not set
627 634
628# 635#
636# TPM devices
637#
638# CONFIG_TCG_TPM is not set
639
640#
629# I2C support 641# I2C support
630# 642#
631CONFIG_I2C=m 643CONFIG_I2C=m
@@ -648,12 +660,12 @@ CONFIG_I2C_ALGOBIT=m
648# CONFIG_I2C_AMD8111 is not set 660# CONFIG_I2C_AMD8111 is not set
649# CONFIG_I2C_I801 is not set 661# CONFIG_I2C_I801 is not set
650# CONFIG_I2C_I810 is not set 662# CONFIG_I2C_I810 is not set
663# CONFIG_I2C_PIIX4 is not set
651# CONFIG_I2C_ISA is not set 664# CONFIG_I2C_ISA is not set
652# CONFIG_I2C_MPC is not set 665# CONFIG_I2C_MPC is not set
653# CONFIG_I2C_NFORCE2 is not set 666# CONFIG_I2C_NFORCE2 is not set
654# CONFIG_I2C_PARPORT is not set 667# CONFIG_I2C_PARPORT is not set
655# CONFIG_I2C_PARPORT_LIGHT is not set 668# CONFIG_I2C_PARPORT_LIGHT is not set
656# CONFIG_I2C_PIIX4 is not set
657# CONFIG_I2C_PROSAVAGE is not set 669# CONFIG_I2C_PROSAVAGE is not set
658# CONFIG_I2C_SAVAGE4 is not set 670# CONFIG_I2C_SAVAGE4 is not set
659# CONFIG_SCx200_ACB is not set 671# CONFIG_SCx200_ACB is not set
@@ -677,7 +689,9 @@ CONFIG_I2C_ALGOBIT=m
677# CONFIG_SENSORS_ASB100 is not set 689# CONFIG_SENSORS_ASB100 is not set
678# CONFIG_SENSORS_DS1621 is not set 690# CONFIG_SENSORS_DS1621 is not set
679# CONFIG_SENSORS_FSCHER is not set 691# CONFIG_SENSORS_FSCHER is not set
692# CONFIG_SENSORS_FSCPOS is not set
680# CONFIG_SENSORS_GL518SM is not set 693# CONFIG_SENSORS_GL518SM is not set
694# CONFIG_SENSORS_GL520SM is not set
681# CONFIG_SENSORS_IT87 is not set 695# CONFIG_SENSORS_IT87 is not set
682# CONFIG_SENSORS_LM63 is not set 696# CONFIG_SENSORS_LM63 is not set
683# CONFIG_SENSORS_LM75 is not set 697# CONFIG_SENSORS_LM75 is not set
@@ -688,9 +702,11 @@ CONFIG_I2C_ALGOBIT=m
688# CONFIG_SENSORS_LM85 is not set 702# CONFIG_SENSORS_LM85 is not set
689# CONFIG_SENSORS_LM87 is not set 703# CONFIG_SENSORS_LM87 is not set
690# CONFIG_SENSORS_LM90 is not set 704# CONFIG_SENSORS_LM90 is not set
705# CONFIG_SENSORS_LM92 is not set
691# CONFIG_SENSORS_MAX1619 is not set 706# CONFIG_SENSORS_MAX1619 is not set
692# CONFIG_SENSORS_PC87360 is not set 707# CONFIG_SENSORS_PC87360 is not set
693# CONFIG_SENSORS_SMSC47B397 is not set 708# CONFIG_SENSORS_SMSC47B397 is not set
709# CONFIG_SENSORS_SIS5595 is not set
694# CONFIG_SENSORS_SMSC47M1 is not set 710# CONFIG_SENSORS_SMSC47M1 is not set
695# CONFIG_SENSORS_VIA686A is not set 711# CONFIG_SENSORS_VIA686A is not set
696# CONFIG_SENSORS_W83781D is not set 712# CONFIG_SENSORS_W83781D is not set
@@ -700,10 +716,12 @@ CONFIG_I2C_ALGOBIT=m
700# 716#
701# Other I2C Chip support 717# Other I2C Chip support
702# 718#
719# CONFIG_SENSORS_DS1337 is not set
703# CONFIG_SENSORS_EEPROM is not set 720# CONFIG_SENSORS_EEPROM is not set
704# CONFIG_SENSORS_PCF8574 is not set 721# CONFIG_SENSORS_PCF8574 is not set
705# CONFIG_SENSORS_PCF8591 is not set 722# CONFIG_SENSORS_PCF8591 is not set
706# CONFIG_SENSORS_RTC8564 is not set 723# CONFIG_SENSORS_RTC8564 is not set
724# CONFIG_SENSORS_M41T00 is not set
707# CONFIG_I2C_DEBUG_CORE is not set 725# CONFIG_I2C_DEBUG_CORE is not set
708# CONFIG_I2C_DEBUG_ALGO is not set 726# CONFIG_I2C_DEBUG_ALGO is not set
709# CONFIG_I2C_DEBUG_BUS is not set 727# CONFIG_I2C_DEBUG_BUS is not set
@@ -732,7 +750,6 @@ CONFIG_I2C_ALGOBIT=m
732# Graphics support 750# Graphics support
733# 751#
734# CONFIG_FB is not set 752# CONFIG_FB is not set
735# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
736 753
737# 754#
738# Sound 755# Sound
@@ -752,13 +769,9 @@ CONFIG_SOUND=m
752# 769#
753# USB support 770# USB support
754# 771#
755# CONFIG_USB is not set
756CONFIG_USB_ARCH_HAS_HCD=y 772CONFIG_USB_ARCH_HAS_HCD=y
757CONFIG_USB_ARCH_HAS_OHCI=y 773CONFIG_USB_ARCH_HAS_OHCI=y
758 774# CONFIG_USB is not set
759#
760# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
761#
762 775
763# 776#
764# USB Gadget Support 777# USB Gadget Support
@@ -789,6 +802,10 @@ CONFIG_JBD_DEBUG=y
789CONFIG_FS_MBCACHE=y 802CONFIG_FS_MBCACHE=y
790# CONFIG_REISERFS_FS is not set 803# CONFIG_REISERFS_FS is not set
791# CONFIG_JFS_FS is not set 804# CONFIG_JFS_FS is not set
805
806#
807# XFS support
808#
792# CONFIG_XFS_FS is not set 809# CONFIG_XFS_FS is not set
793# CONFIG_MINIX_FS is not set 810# CONFIG_MINIX_FS is not set
794# CONFIG_ROMFS_FS is not set 811# CONFIG_ROMFS_FS is not set
@@ -859,7 +876,6 @@ CONFIG_NFS_V3=y
859CONFIG_ROOT_NFS=y 876CONFIG_ROOT_NFS=y
860CONFIG_LOCKD=y 877CONFIG_LOCKD=y
861CONFIG_LOCKD_V4=y 878CONFIG_LOCKD_V4=y
862# CONFIG_EXPORTFS is not set
863CONFIG_SUNRPC=y 879CONFIG_SUNRPC=y
864# CONFIG_RPCSEC_GSS_KRB5 is not set 880# CONFIG_RPCSEC_GSS_KRB5 is not set
865# CONFIG_RPCSEC_GSS_SPKM3 is not set 881# CONFIG_RPCSEC_GSS_SPKM3 is not set
@@ -942,8 +958,10 @@ CONFIG_ZLIB_INFLATE=m
942# 958#
943# Kernel hacking 959# Kernel hacking
944# 960#
961# CONFIG_PRINTK_TIME is not set
945CONFIG_DEBUG_KERNEL=y 962CONFIG_DEBUG_KERNEL=y
946# CONFIG_MAGIC_SYSRQ is not set 963# CONFIG_MAGIC_SYSRQ is not set
964CONFIG_LOG_BUF_SHIFT=14
947# CONFIG_SCHEDSTATS is not set 965# CONFIG_SCHEDSTATS is not set
948# CONFIG_DEBUG_SLAB is not set 966# CONFIG_DEBUG_SLAB is not set
949# CONFIG_DEBUG_SPINLOCK is not set 967# CONFIG_DEBUG_SPINLOCK is not set
diff --git a/arch/ppc/kernel/Makefile b/arch/ppc/kernel/Makefile
index c610ca933a25..76a55a438f23 100644
--- a/arch/ppc/kernel/Makefile
+++ b/arch/ppc/kernel/Makefile
@@ -22,6 +22,7 @@ obj-$(CONFIG_POWER4) += cpu_setup_power4.o
22obj-$(CONFIG_MODULES) += module.o ppc_ksyms.o 22obj-$(CONFIG_MODULES) += module.o ppc_ksyms.o
23obj-$(CONFIG_NOT_COHERENT_CACHE) += dma-mapping.o 23obj-$(CONFIG_NOT_COHERENT_CACHE) += dma-mapping.o
24obj-$(CONFIG_PCI) += pci.o 24obj-$(CONFIG_PCI) += pci.o
25obj-$(CONFIG_RAPIDIO) += rio.o
25obj-$(CONFIG_KGDB) += ppc-stub.o 26obj-$(CONFIG_KGDB) += ppc-stub.o
26obj-$(CONFIG_SMP) += smp.o smp-tbsync.o 27obj-$(CONFIG_SMP) += smp.o smp-tbsync.o
27obj-$(CONFIG_TAU) += temp.o 28obj-$(CONFIG_TAU) += temp.o
diff --git a/arch/ppc/kernel/rio.c b/arch/ppc/kernel/rio.c
new file mode 100644
index 000000000000..29487fedfc76
--- /dev/null
+++ b/arch/ppc/kernel/rio.c
@@ -0,0 +1,52 @@
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/ppc/platforms/85xx/mpc85xx_ads_common.c b/arch/ppc/platforms/85xx/mpc85xx_ads_common.c
index bd3ac0136756..16ad092d8a06 100644
--- a/arch/ppc/platforms/85xx/mpc85xx_ads_common.c
+++ b/arch/ppc/platforms/85xx/mpc85xx_ads_common.c
@@ -45,6 +45,8 @@
45 45
46#include <mm/mmu_decl.h> 46#include <mm/mmu_decl.h>
47 47
48#include <syslib/ppc85xx_rio.h>
49
48#include <platforms/85xx/mpc85xx_ads_common.h> 50#include <platforms/85xx/mpc85xx_ads_common.h>
49 51
50#ifndef CONFIG_PCI 52#ifndef CONFIG_PCI
@@ -189,3 +191,11 @@ mpc85xx_exclude_device(u_char bus, u_char devfn)
189} 191}
190 192
191#endif /* CONFIG_PCI */ 193#endif /* CONFIG_PCI */
194
195#ifdef CONFIG_RAPIDIO
196void platform_rio_init(void)
197{
198 /* 512MB RIO LAW at 0xc0000000 */
199 mpc85xx_rio_setup(0xc0000000, 0x20000000);
200}
201#endif /* CONFIG_RAPIDIO */
diff --git a/arch/ppc/platforms/85xx/stx_gp3.c b/arch/ppc/platforms/85xx/stx_gp3.c
index 1e1b85f8193a..15ce9d070634 100644
--- a/arch/ppc/platforms/85xx/stx_gp3.c
+++ b/arch/ppc/platforms/85xx/stx_gp3.c
@@ -37,6 +37,7 @@
37#include <linux/module.h> 37#include <linux/module.h>
38#include <linux/fsl_devices.h> 38#include <linux/fsl_devices.h>
39#include <linux/interrupt.h> 39#include <linux/interrupt.h>
40#include <linux/rio.h>
40 41
41#include <asm/system.h> 42#include <asm/system.h>
42#include <asm/pgtable.h> 43#include <asm/pgtable.h>
@@ -57,6 +58,7 @@
57 58
58#include <syslib/cpm2_pic.h> 59#include <syslib/cpm2_pic.h>
59#include <syslib/ppc85xx_common.h> 60#include <syslib/ppc85xx_common.h>
61#include <syslib/ppc85xx_rio.h>
60 62
61 63
62unsigned char __res[sizeof(bd_t)]; 64unsigned char __res[sizeof(bd_t)];
@@ -273,6 +275,18 @@ int mpc85xx_exclude_device(u_char bus, u_char devfn)
273} 275}
274#endif /* CONFIG_PCI */ 276#endif /* CONFIG_PCI */
275 277
278#ifdef CONFIG_RAPIDIO
279void
280platform_rio_init(void)
281{
282 /*
283 * The STx firmware configures the RapidIO Local Access Window
284 * at 0xc0000000 with a size of 512MB.
285 */
286 mpc85xx_rio_setup(0xc0000000, 0x20000000);
287}
288#endif /* CONFIG_RAPIDIO */
289
276void __init 290void __init
277platform_init(unsigned long r3, unsigned long r4, unsigned long r5, 291platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
278 unsigned long r6, unsigned long r7) 292 unsigned long r6, unsigned long r7)
diff --git a/arch/ppc/syslib/Makefile b/arch/ppc/syslib/Makefile
index dcd168f9a7aa..5bd33baac243 100644
--- a/arch/ppc/syslib/Makefile
+++ b/arch/ppc/syslib/Makefile
@@ -33,6 +33,7 @@ obj-$(CONFIG_PPC4xx_DMA) += ppc4xx_dma.o
33obj-$(CONFIG_PPC4xx_EDMA) += ppc4xx_sgdma.o 33obj-$(CONFIG_PPC4xx_EDMA) += ppc4xx_sgdma.o
34ifeq ($(CONFIG_40x),y) 34ifeq ($(CONFIG_40x),y)
35obj-$(CONFIG_PCI) += pci_auto.o ppc405_pci.o 35obj-$(CONFIG_PCI) += pci_auto.o ppc405_pci.o
36obj-$(CONFIG_RAPIDIO) += ppc85xx_rio.o
36endif 37endif
37endif 38endif
38obj-$(CONFIG_8xx) += m8xx_setup.o ppc8xx_pic.o $(wdt-mpc8xx-y) \ 39obj-$(CONFIG_8xx) += m8xx_setup.o ppc8xx_pic.o $(wdt-mpc8xx-y) \
diff --git a/arch/ppc/syslib/ppc85xx_rio.c b/arch/ppc/syslib/ppc85xx_rio.c
new file mode 100644
index 000000000000..9d09c2715e0a
--- /dev/null
+++ b/arch/ppc/syslib/ppc85xx_rio.c
@@ -0,0 +1,932 @@
1/*
2 * MPC85xx RapidIO 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/config.h>
14#include <linux/init.h>
15#include <linux/module.h>
16#include <linux/types.h>
17#include <linux/dma-mapping.h>
18#include <linux/interrupt.h>
19#include <linux/rio.h>
20#include <linux/rio_drv.h>
21
22#include <asm/io.h>
23
24#define RIO_REGS_BASE (CCSRBAR + 0xc0000)
25#define RIO_ATMU_REGS_OFFSET 0x10c00
26#define RIO_MSG_REGS_OFFSET 0x11000
27#define RIO_MAINT_WIN_SIZE 0x400000
28#define RIO_DBELL_WIN_SIZE 0x1000
29
30#define RIO_MSG_OMR_MUI 0x00000002
31#define RIO_MSG_OSR_TE 0x00000080
32#define RIO_MSG_OSR_QOI 0x00000020
33#define RIO_MSG_OSR_QFI 0x00000010
34#define RIO_MSG_OSR_MUB 0x00000004
35#define RIO_MSG_OSR_EOMI 0x00000002
36#define RIO_MSG_OSR_QEI 0x00000001
37
38#define RIO_MSG_IMR_MI 0x00000002
39#define RIO_MSG_ISR_TE 0x00000080
40#define RIO_MSG_ISR_QFI 0x00000010
41#define RIO_MSG_ISR_DIQI 0x00000001
42
43#define RIO_MSG_DESC_SIZE 32
44#define RIO_MSG_BUFFER_SIZE 4096
45#define RIO_MIN_TX_RING_SIZE 2
46#define RIO_MAX_TX_RING_SIZE 2048
47#define RIO_MIN_RX_RING_SIZE 2
48#define RIO_MAX_RX_RING_SIZE 2048
49
50#define DOORBELL_DMR_DI 0x00000002
51#define DOORBELL_DSR_TE 0x00000080
52#define DOORBELL_DSR_QFI 0x00000010
53#define DOORBELL_DSR_DIQI 0x00000001
54#define DOORBELL_TID_OFFSET 0x03
55#define DOORBELL_SID_OFFSET 0x05
56#define DOORBELL_INFO_OFFSET 0x06
57
58#define DOORBELL_MESSAGE_SIZE 0x08
59#define DBELL_SID(x) (*(u8 *)(x + DOORBELL_SID_OFFSET))
60#define DBELL_TID(x) (*(u8 *)(x + DOORBELL_TID_OFFSET))
61#define DBELL_INF(x) (*(u16 *)(x + DOORBELL_INFO_OFFSET))
62
63#define is_power_of_2(x) (((x) & ((x) - 1)) == 0)
64
65struct rio_atmu_regs {
66 u32 rowtar;
67 u32 pad1;
68 u32 rowbar;
69 u32 pad2;
70 u32 rowar;
71 u32 pad3[3];
72};
73
74struct rio_msg_regs {
75 u32 omr;
76 u32 osr;
77 u32 pad1;
78 u32 odqdpar;
79 u32 pad2;
80 u32 osar;
81 u32 odpr;
82 u32 odatr;
83 u32 odcr;
84 u32 pad3;
85 u32 odqepar;
86 u32 pad4[13];
87 u32 imr;
88 u32 isr;
89 u32 pad5;
90 u32 ifqdpar;
91 u32 pad6;
92 u32 ifqepar;
93 u32 pad7[250];
94 u32 dmr;
95 u32 dsr;
96 u32 pad8;
97 u32 dqdpar;
98 u32 pad9;
99 u32 dqepar;
100 u32 pad10[26];
101 u32 pwmr;
102 u32 pwsr;
103 u32 pad11;
104 u32 pwqbar;
105};
106
107struct rio_tx_desc {
108 u32 res1;
109 u32 saddr;
110 u32 dport;
111 u32 dattr;
112 u32 res2;
113 u32 res3;
114 u32 dwcnt;
115 u32 res4;
116};
117
118static u32 regs_win;
119static struct rio_atmu_regs *atmu_regs;
120static struct rio_atmu_regs *maint_atmu_regs;
121static struct rio_atmu_regs *dbell_atmu_regs;
122static u32 dbell_win;
123static u32 maint_win;
124static struct rio_msg_regs *msg_regs;
125
126static struct rio_dbell_ring {
127 void *virt;
128 dma_addr_t phys;
129} dbell_ring;
130
131static struct rio_msg_tx_ring {
132 void *virt;
133 dma_addr_t phys;
134 void *virt_buffer[RIO_MAX_TX_RING_SIZE];
135 dma_addr_t phys_buffer[RIO_MAX_TX_RING_SIZE];
136 int tx_slot;
137 int size;
138} msg_tx_ring;
139
140static struct rio_msg_rx_ring {
141 void *virt;
142 dma_addr_t phys;
143 void *virt_buffer[RIO_MAX_RX_RING_SIZE];
144 int rx_slot;
145 int size;
146} msg_rx_ring;
147
148/**
149 * mpc85xx_rio_doorbell_send - Send a MPC85xx doorbell message
150 * @index: ID of RapidIO interface
151 * @destid: Destination ID of target device
152 * @data: 16-bit info field of RapidIO doorbell message
153 *
154 * Sends a MPC85xx doorbell message. Returns %0 on success or
155 * %-EINVAL on failure.
156 */
157static int mpc85xx_rio_doorbell_send(int index, u16 destid, u16 data)
158{
159 pr_debug("mpc85xx_doorbell_send: index %d destid %4.4x data %4.4x\n",
160 index, destid, data);
161 out_be32((void *)&dbell_atmu_regs->rowtar, destid << 22);
162 out_be16((void *)(dbell_win), data);
163
164 return 0;
165}
166
167/**
168 * mpc85xx_local_config_read - Generate a MPC85xx local config space read
169 * @index: ID of RapdiIO interface
170 * @offset: Offset into configuration space
171 * @len: Length (in bytes) of the maintenance transaction
172 * @data: Value to be read into
173 *
174 * Generates a MPC85xx local configuration space read. Returns %0 on
175 * success or %-EINVAL on failure.
176 */
177static int mpc85xx_local_config_read(int index, u32 offset, int len, u32 * data)
178{
179 pr_debug("mpc85xx_local_config_read: index %d offset %8.8x\n", index,
180 offset);
181 *data = in_be32((void *)(regs_win + offset));
182
183 return 0;
184}
185
186/**
187 * mpc85xx_local_config_write - Generate a MPC85xx local config space write
188 * @index: ID of RapdiIO interface
189 * @offset: Offset into configuration space
190 * @len: Length (in bytes) of the maintenance transaction
191 * @data: Value to be written
192 *
193 * Generates a MPC85xx local configuration space write. Returns %0 on
194 * success or %-EINVAL on failure.
195 */
196static int mpc85xx_local_config_write(int index, u32 offset, int len, u32 data)
197{
198 pr_debug
199 ("mpc85xx_local_config_write: index %d offset %8.8x data %8.8x\n",
200 index, offset, data);
201 out_be32((void *)(regs_win + offset), data);
202
203 return 0;
204}
205
206/**
207 * mpc85xx_rio_config_read - Generate a MPC85xx read maintenance transaction
208 * @index: ID of RapdiIO interface
209 * @destid: Destination ID of transaction
210 * @hopcount: Number of hops to target device
211 * @offset: Offset into configuration space
212 * @len: Length (in bytes) of the maintenance transaction
213 * @val: Location to be read into
214 *
215 * Generates a MPC85xx read maintenance transaction. Returns %0 on
216 * success or %-EINVAL on failure.
217 */
218static int
219mpc85xx_rio_config_read(int index, u16 destid, u8 hopcount, u32 offset, int len,
220 u32 * val)
221{
222 u8 *data;
223
224 pr_debug
225 ("mpc85xx_rio_config_read: index %d destid %d hopcount %d offset %8.8x len %d\n",
226 index, destid, hopcount, offset, len);
227 out_be32((void *)&maint_atmu_regs->rowtar,
228 (destid << 22) | (hopcount << 12) | ((offset & ~0x3) >> 9));
229
230 data = (u8 *) maint_win + offset;
231 switch (len) {
232 case 1:
233 *val = in_8((u8 *) data);
234 break;
235 case 2:
236 *val = in_be16((u16 *) data);
237 break;
238 default:
239 *val = in_be32((u32 *) data);
240 break;
241 }
242
243 return 0;
244}
245
246/**
247 * mpc85xx_rio_config_write - Generate a MPC85xx write maintenance transaction
248 * @index: ID of RapdiIO interface
249 * @destid: Destination ID of transaction
250 * @hopcount: Number of hops to target device
251 * @offset: Offset into configuration space
252 * @len: Length (in bytes) of the maintenance transaction
253 * @val: Value to be written
254 *
255 * Generates an MPC85xx write maintenance transaction. Returns %0 on
256 * success or %-EINVAL on failure.
257 */
258static int
259mpc85xx_rio_config_write(int index, u16 destid, u8 hopcount, u32 offset,
260 int len, u32 val)
261{
262 u8 *data;
263 pr_debug
264 ("mpc85xx_rio_config_write: index %d destid %d hopcount %d offset %8.8x len %d val %8.8x\n",
265 index, destid, hopcount, offset, len, val);
266 out_be32((void *)&maint_atmu_regs->rowtar,
267 (destid << 22) | (hopcount << 12) | ((offset & ~0x3) >> 9));
268
269 data = (u8 *) maint_win + offset;
270 switch (len) {
271 case 1:
272 out_8((u8 *) data, val);
273 break;
274 case 2:
275 out_be16((u16 *) data, val);
276 break;
277 default:
278 out_be32((u32 *) data, val);
279 break;
280 }
281
282 return 0;
283}
284
285/**
286 * rio_hw_add_outb_message - Add message to the MPC85xx outbound message queue
287 * @mport: Master port with outbound message queue
288 * @rdev: Target of outbound message
289 * @mbox: Outbound mailbox
290 * @buffer: Message to add to outbound queue
291 * @len: Length of message
292 *
293 * Adds the @buffer message to the MPC85xx outbound message queue. Returns
294 * %0 on success or %-EINVAL on failure.
295 */
296int
297rio_hw_add_outb_message(struct rio_mport *mport, struct rio_dev *rdev, int mbox,
298 void *buffer, size_t len)
299{
300 u32 omr;
301 struct rio_tx_desc *desc =
302 (struct rio_tx_desc *)msg_tx_ring.virt + msg_tx_ring.tx_slot;
303 int ret = 0;
304
305 pr_debug
306 ("RIO: rio_hw_add_outb_message(): destid %4.4x mbox %d buffer %8.8x len %8.8x\n",
307 rdev->destid, mbox, (int)buffer, len);
308
309 if ((len < 8) || (len > RIO_MAX_MSG_SIZE)) {
310 ret = -EINVAL;
311 goto out;
312 }
313
314 /* Copy and clear rest of buffer */
315 memcpy(msg_tx_ring.virt_buffer[msg_tx_ring.tx_slot], buffer, len);
316 if (len < (RIO_MAX_MSG_SIZE - 4))
317 memset((void *)((u32) msg_tx_ring.
318 virt_buffer[msg_tx_ring.tx_slot] + len), 0,
319 RIO_MAX_MSG_SIZE - len);
320
321 /* Set mbox field for message */
322 desc->dport = mbox & 0x3;
323
324 /* Enable EOMI interrupt, set priority, and set destid */
325 desc->dattr = 0x28000000 | (rdev->destid << 2);
326
327 /* Set transfer size aligned to next power of 2 (in double words) */
328 desc->dwcnt = is_power_of_2(len) ? len : 1 << get_bitmask_order(len);
329
330 /* Set snooping and source buffer address */
331 desc->saddr = 0x00000004 | msg_tx_ring.phys_buffer[msg_tx_ring.tx_slot];
332
333 /* Increment enqueue pointer */
334 omr = in_be32((void *)&msg_regs->omr);
335 out_be32((void *)&msg_regs->omr, omr | RIO_MSG_OMR_MUI);
336
337 /* Go to next descriptor */
338 if (++msg_tx_ring.tx_slot == msg_tx_ring.size)
339 msg_tx_ring.tx_slot = 0;
340
341 out:
342 return ret;
343}
344
345EXPORT_SYMBOL_GPL(rio_hw_add_outb_message);
346
347/**
348 * mpc85xx_rio_tx_handler - MPC85xx outbound message interrupt handler
349 * @irq: Linux interrupt number
350 * @dev_instance: Pointer to interrupt-specific data
351 * @regs: Register context
352 *
353 * Handles outbound message interrupts. Executes a register outbound
354 * mailbox event handler and acks the interrupt occurence.
355 */
356static irqreturn_t
357mpc85xx_rio_tx_handler(int irq, void *dev_instance, struct pt_regs *regs)
358{
359 int osr;
360 struct rio_mport *port = (struct rio_mport *)dev_instance;
361
362 osr = in_be32((void *)&msg_regs->osr);
363
364 if (osr & RIO_MSG_OSR_TE) {
365 pr_info("RIO: outbound message transmission error\n");
366 out_be32((void *)&msg_regs->osr, RIO_MSG_OSR_TE);
367 goto out;
368 }
369
370 if (osr & RIO_MSG_OSR_QOI) {
371 pr_info("RIO: outbound message queue overflow\n");
372 out_be32((void *)&msg_regs->osr, RIO_MSG_OSR_QOI);
373 goto out;
374 }
375
376 if (osr & RIO_MSG_OSR_EOMI) {
377 u32 dqp = in_be32((void *)&msg_regs->odqdpar);
378 int slot = (dqp - msg_tx_ring.phys) >> 5;
379 port->outb_msg[0].mcback(port, -1, slot);
380
381 /* Ack the end-of-message interrupt */
382 out_be32((void *)&msg_regs->osr, RIO_MSG_OSR_EOMI);
383 }
384
385 out:
386 return IRQ_HANDLED;
387}
388
389/**
390 * rio_open_outb_mbox - Initialize MPC85xx outbound mailbox
391 * @mport: Master port implementing the outbound message unit
392 * @mbox: Mailbox to open
393 * @entries: Number of entries in the outbound mailbox ring
394 *
395 * Initializes buffer ring, request the outbound message interrupt,
396 * and enables the outbound message unit. Returns %0 on success and
397 * %-EINVAL or %-ENOMEM on failure.
398 */
399int rio_open_outb_mbox(struct rio_mport *mport, int mbox, int entries)
400{
401 int i, j, rc = 0;
402
403 if ((entries < RIO_MIN_TX_RING_SIZE) ||
404 (entries > RIO_MAX_TX_RING_SIZE) || (!is_power_of_2(entries))) {
405 rc = -EINVAL;
406 goto out;
407 }
408
409 /* Initialize shadow copy ring */
410 msg_tx_ring.size = entries;
411
412 for (i = 0; i < msg_tx_ring.size; i++) {
413 if (!
414 (msg_tx_ring.virt_buffer[i] =
415 dma_alloc_coherent(NULL, RIO_MSG_BUFFER_SIZE,
416 &msg_tx_ring.phys_buffer[i],
417 GFP_KERNEL))) {
418 rc = -ENOMEM;
419 for (j = 0; j < msg_tx_ring.size; j++)
420 if (msg_tx_ring.virt_buffer[j])
421 dma_free_coherent(NULL,
422 RIO_MSG_BUFFER_SIZE,
423 msg_tx_ring.
424 virt_buffer[j],
425 msg_tx_ring.
426 phys_buffer[j]);
427 goto out;
428 }
429 }
430
431 /* Initialize outbound message descriptor ring */
432 if (!(msg_tx_ring.virt = dma_alloc_coherent(NULL,
433 msg_tx_ring.size *
434 RIO_MSG_DESC_SIZE,
435 &msg_tx_ring.phys,
436 GFP_KERNEL))) {
437 rc = -ENOMEM;
438 goto out_dma;
439 }
440 memset(msg_tx_ring.virt, 0, msg_tx_ring.size * RIO_MSG_DESC_SIZE);
441 msg_tx_ring.tx_slot = 0;
442
443 /* Point dequeue/enqueue pointers at first entry in ring */
444 out_be32((void *)&msg_regs->odqdpar, msg_tx_ring.phys);
445 out_be32((void *)&msg_regs->odqepar, msg_tx_ring.phys);
446
447 /* Configure for snooping */
448 out_be32((void *)&msg_regs->osar, 0x00000004);
449
450 /* Clear interrupt status */
451 out_be32((void *)&msg_regs->osr, 0x000000b3);
452
453 /* Hook up outbound message handler */
454 if ((rc =
455 request_irq(MPC85xx_IRQ_RIO_TX, mpc85xx_rio_tx_handler, 0,
456 "msg_tx", (void *)mport)) < 0)
457 goto out_irq;
458
459 /*
460 * Configure outbound message unit
461 * Snooping
462 * Interrupts (all enabled, except QEIE)
463 * Chaining mode
464 * Disable
465 */
466 out_be32((void *)&msg_regs->omr, 0x00100220);
467
468 /* Set number of entries */
469 out_be32((void *)&msg_regs->omr,
470 in_be32((void *)&msg_regs->omr) |
471 ((get_bitmask_order(entries) - 2) << 12));
472
473 /* Now enable the unit */
474 out_be32((void *)&msg_regs->omr, in_be32((void *)&msg_regs->omr) | 0x1);
475
476 out:
477 return rc;
478
479 out_irq:
480 dma_free_coherent(NULL, msg_tx_ring.size * RIO_MSG_DESC_SIZE,
481 msg_tx_ring.virt, msg_tx_ring.phys);
482
483 out_dma:
484 for (i = 0; i < msg_tx_ring.size; i++)
485 dma_free_coherent(NULL, RIO_MSG_BUFFER_SIZE,
486 msg_tx_ring.virt_buffer[i],
487 msg_tx_ring.phys_buffer[i]);
488
489 return rc;
490}
491
492/**
493 * rio_close_outb_mbox - Shut down MPC85xx outbound mailbox
494 * @mport: Master port implementing the outbound message unit
495 * @mbox: Mailbox to close
496 *
497 * Disables the outbound message unit, free all buffers, and
498 * frees the outbound message interrupt.
499 */
500void rio_close_outb_mbox(struct rio_mport *mport, int mbox)
501{
502 /* Disable inbound message unit */
503 out_be32((void *)&msg_regs->omr, 0);
504
505 /* Free ring */
506 dma_free_coherent(NULL, msg_tx_ring.size * RIO_MSG_DESC_SIZE,
507 msg_tx_ring.virt, msg_tx_ring.phys);
508
509 /* Free interrupt */
510 free_irq(MPC85xx_IRQ_RIO_TX, (void *)mport);
511}
512
513/**
514 * mpc85xx_rio_rx_handler - MPC85xx inbound message interrupt handler
515 * @irq: Linux interrupt number
516 * @dev_instance: Pointer to interrupt-specific data
517 * @regs: Register context
518 *
519 * Handles inbound message interrupts. Executes a registered inbound
520 * mailbox event handler and acks the interrupt occurence.
521 */
522static irqreturn_t
523mpc85xx_rio_rx_handler(int irq, void *dev_instance, struct pt_regs *regs)
524{
525 int isr;
526 struct rio_mport *port = (struct rio_mport *)dev_instance;
527
528 isr = in_be32((void *)&msg_regs->isr);
529
530 if (isr & RIO_MSG_ISR_TE) {
531 pr_info("RIO: inbound message reception error\n");
532 out_be32((void *)&msg_regs->isr, RIO_MSG_ISR_TE);
533 goto out;
534 }
535
536 /* XXX Need to check/dispatch until queue empty */
537 if (isr & RIO_MSG_ISR_DIQI) {
538 /*
539 * We implement *only* mailbox 0, but can receive messages
540 * for any mailbox/letter to that mailbox destination. So,
541 * make the callback with an unknown/invalid mailbox number
542 * argument.
543 */
544 port->inb_msg[0].mcback(port, -1, -1);
545
546 /* Ack the queueing interrupt */
547 out_be32((void *)&msg_regs->isr, RIO_MSG_ISR_DIQI);
548 }
549
550 out:
551 return IRQ_HANDLED;
552}
553
554/**
555 * rio_open_inb_mbox - Initialize MPC85xx inbound mailbox
556 * @mport: Master port implementing the inbound message unit
557 * @mbox: Mailbox to open
558 * @entries: Number of entries in the inbound mailbox ring
559 *
560 * Initializes buffer ring, request the inbound message interrupt,
561 * and enables the inbound message unit. Returns %0 on success
562 * and %-EINVAL or %-ENOMEM on failure.
563 */
564int rio_open_inb_mbox(struct rio_mport *mport, int mbox, int entries)
565{
566 int i, rc = 0;
567
568 if ((entries < RIO_MIN_RX_RING_SIZE) ||
569 (entries > RIO_MAX_RX_RING_SIZE) || (!is_power_of_2(entries))) {
570 rc = -EINVAL;
571 goto out;
572 }
573
574 /* Initialize client buffer ring */
575 msg_rx_ring.size = entries;
576 msg_rx_ring.rx_slot = 0;
577 for (i = 0; i < msg_rx_ring.size; i++)
578 msg_rx_ring.virt_buffer[i] = NULL;
579
580 /* Initialize inbound message ring */
581 if (!(msg_rx_ring.virt = dma_alloc_coherent(NULL,
582 msg_rx_ring.size *
583 RIO_MAX_MSG_SIZE,
584 &msg_rx_ring.phys,
585 GFP_KERNEL))) {
586 rc = -ENOMEM;
587 goto out;
588 }
589
590 /* Point dequeue/enqueue pointers at first entry in ring */
591 out_be32((void *)&msg_regs->ifqdpar, (u32) msg_rx_ring.phys);
592 out_be32((void *)&msg_regs->ifqepar, (u32) msg_rx_ring.phys);
593
594 /* Clear interrupt status */
595 out_be32((void *)&msg_regs->isr, 0x00000091);
596
597 /* Hook up inbound message handler */
598 if ((rc =
599 request_irq(MPC85xx_IRQ_RIO_RX, mpc85xx_rio_rx_handler, 0,
600 "msg_rx", (void *)mport)) < 0) {
601 dma_free_coherent(NULL, RIO_MSG_BUFFER_SIZE,
602 msg_tx_ring.virt_buffer[i],
603 msg_tx_ring.phys_buffer[i]);
604 goto out;
605 }
606
607 /*
608 * Configure inbound message unit:
609 * Snooping
610 * 4KB max message size
611 * Unmask all interrupt sources
612 * Disable
613 */
614 out_be32((void *)&msg_regs->imr, 0x001b0060);
615
616 /* Set number of queue entries */
617 out_be32((void *)&msg_regs->imr,
618 in_be32((void *)&msg_regs->imr) |
619 ((get_bitmask_order(entries) - 2) << 12));
620
621 /* Now enable the unit */
622 out_be32((void *)&msg_regs->imr, in_be32((void *)&msg_regs->imr) | 0x1);
623
624 out:
625 return rc;
626}
627
628/**
629 * rio_close_inb_mbox - Shut down MPC85xx inbound mailbox
630 * @mport: Master port implementing the inbound message unit
631 * @mbox: Mailbox to close
632 *
633 * Disables the inbound message unit, free all buffers, and
634 * frees the inbound message interrupt.
635 */
636void rio_close_inb_mbox(struct rio_mport *mport, int mbox)
637{
638 /* Disable inbound message unit */
639 out_be32((void *)&msg_regs->imr, 0);
640
641 /* Free ring */
642 dma_free_coherent(NULL, msg_rx_ring.size * RIO_MAX_MSG_SIZE,
643 msg_rx_ring.virt, msg_rx_ring.phys);
644
645 /* Free interrupt */
646 free_irq(MPC85xx_IRQ_RIO_RX, (void *)mport);
647}
648
649/**
650 * rio_hw_add_inb_buffer - Add buffer to the MPC85xx inbound message queue
651 * @mport: Master port implementing the inbound message unit
652 * @mbox: Inbound mailbox number
653 * @buf: Buffer to add to inbound queue
654 *
655 * Adds the @buf buffer to the MPC85xx inbound message queue. Returns
656 * %0 on success or %-EINVAL on failure.
657 */
658int rio_hw_add_inb_buffer(struct rio_mport *mport, int mbox, void *buf)
659{
660 int rc = 0;
661
662 pr_debug("RIO: rio_hw_add_inb_buffer(), msg_rx_ring.rx_slot %d\n",
663 msg_rx_ring.rx_slot);
664
665 if (msg_rx_ring.virt_buffer[msg_rx_ring.rx_slot]) {
666 printk(KERN_ERR
667 "RIO: error adding inbound buffer %d, buffer exists\n",
668 msg_rx_ring.rx_slot);
669 rc = -EINVAL;
670 goto out;
671 }
672
673 msg_rx_ring.virt_buffer[msg_rx_ring.rx_slot] = buf;
674 if (++msg_rx_ring.rx_slot == msg_rx_ring.size)
675 msg_rx_ring.rx_slot = 0;
676
677 out:
678 return rc;
679}
680
681EXPORT_SYMBOL_GPL(rio_hw_add_inb_buffer);
682
683/**
684 * rio_hw_get_inb_message - Fetch inbound message from the MPC85xx message unit
685 * @mport: Master port implementing the inbound message unit
686 * @mbox: Inbound mailbox number
687 *
688 * Gets the next available inbound message from the inbound message queue.
689 * A pointer to the message is returned on success or NULL on failure.
690 */
691void *rio_hw_get_inb_message(struct rio_mport *mport, int mbox)
692{
693 u32 imr;
694 u32 phys_buf, virt_buf;
695 void *buf = NULL;
696 int buf_idx;
697
698 phys_buf = in_be32((void *)&msg_regs->ifqdpar);
699
700 /* If no more messages, then bail out */
701 if (phys_buf == in_be32((void *)&msg_regs->ifqepar))
702 goto out2;
703
704 virt_buf = (u32) msg_rx_ring.virt + (phys_buf - msg_rx_ring.phys);
705 buf_idx = (phys_buf - msg_rx_ring.phys) / RIO_MAX_MSG_SIZE;
706 buf = msg_rx_ring.virt_buffer[buf_idx];
707
708 if (!buf) {
709 printk(KERN_ERR
710 "RIO: inbound message copy failed, no buffers\n");
711 goto out1;
712 }
713
714 /* Copy max message size, caller is expected to allocate that big */
715 memcpy(buf, (void *)virt_buf, RIO_MAX_MSG_SIZE);
716
717 /* Clear the available buffer */
718 msg_rx_ring.virt_buffer[buf_idx] = NULL;
719
720 out1:
721 imr = in_be32((void *)&msg_regs->imr);
722 out_be32((void *)&msg_regs->imr, imr | RIO_MSG_IMR_MI);
723
724 out2:
725 return buf;
726}
727
728EXPORT_SYMBOL_GPL(rio_hw_get_inb_message);
729
730/**
731 * mpc85xx_rio_dbell_handler - MPC85xx doorbell interrupt handler
732 * @irq: Linux interrupt number
733 * @dev_instance: Pointer to interrupt-specific data
734 * @regs: Register context
735 *
736 * Handles doorbell interrupts. Parses a list of registered
737 * doorbell event handlers and executes a matching event handler.
738 */
739static irqreturn_t
740mpc85xx_rio_dbell_handler(int irq, void *dev_instance, struct pt_regs *regs)
741{
742 int dsr;
743 struct rio_mport *port = (struct rio_mport *)dev_instance;
744
745 dsr = in_be32((void *)&msg_regs->dsr);
746
747 if (dsr & DOORBELL_DSR_TE) {
748 pr_info("RIO: doorbell reception error\n");
749 out_be32((void *)&msg_regs->dsr, DOORBELL_DSR_TE);
750 goto out;
751 }
752
753 if (dsr & DOORBELL_DSR_QFI) {
754 pr_info("RIO: doorbell queue full\n");
755 out_be32((void *)&msg_regs->dsr, DOORBELL_DSR_QFI);
756 goto out;
757 }
758
759 /* XXX Need to check/dispatch until queue empty */
760 if (dsr & DOORBELL_DSR_DIQI) {
761 u32 dmsg =
762 (u32) dbell_ring.virt +
763 (in_be32((void *)&msg_regs->dqdpar) & 0xfff);
764 u32 dmr;
765 struct rio_dbell *dbell;
766 int found = 0;
767
768 pr_debug
769 ("RIO: processing doorbell, sid %2.2x tid %2.2x info %4.4x\n",
770 DBELL_SID(dmsg), DBELL_TID(dmsg), DBELL_INF(dmsg));
771
772 list_for_each_entry(dbell, &port->dbells, node) {
773 if ((dbell->res->start <= DBELL_INF(dmsg)) &&
774 (dbell->res->end >= DBELL_INF(dmsg))) {
775 found = 1;
776 break;
777 }
778 }
779 if (found) {
780 dbell->dinb(port, DBELL_SID(dmsg), DBELL_TID(dmsg),
781 DBELL_INF(dmsg));
782 } else {
783 pr_debug
784 ("RIO: spurious doorbell, sid %2.2x tid %2.2x info %4.4x\n",
785 DBELL_SID(dmsg), DBELL_TID(dmsg), DBELL_INF(dmsg));
786 }
787 dmr = in_be32((void *)&msg_regs->dmr);
788 out_be32((void *)&msg_regs->dmr, dmr | DOORBELL_DMR_DI);
789 out_be32((void *)&msg_regs->dsr, DOORBELL_DSR_DIQI);
790 }
791
792 out:
793 return IRQ_HANDLED;
794}
795
796/**
797 * mpc85xx_rio_doorbell_init - MPC85xx doorbell interface init
798 * @mport: Master port implementing the inbound doorbell unit
799 *
800 * Initializes doorbell unit hardware and inbound DMA buffer
801 * ring. Called from mpc85xx_rio_setup(). Returns %0 on success
802 * or %-ENOMEM on failure.
803 */
804static int mpc85xx_rio_doorbell_init(struct rio_mport *mport)
805{
806 int rc = 0;
807
808 /* Map outbound doorbell window immediately after maintenance window */
809 if (!(dbell_win =
810 (u32) ioremap(mport->iores.start + RIO_MAINT_WIN_SIZE,
811 RIO_DBELL_WIN_SIZE))) {
812 printk(KERN_ERR
813 "RIO: unable to map outbound doorbell window\n");
814 rc = -ENOMEM;
815 goto out;
816 }
817
818 /* Initialize inbound doorbells */
819 if (!(dbell_ring.virt = dma_alloc_coherent(NULL,
820 512 * DOORBELL_MESSAGE_SIZE,
821 &dbell_ring.phys,
822 GFP_KERNEL))) {
823 printk(KERN_ERR "RIO: unable allocate inbound doorbell ring\n");
824 rc = -ENOMEM;
825 iounmap((void *)dbell_win);
826 goto out;
827 }
828
829 /* Point dequeue/enqueue pointers at first entry in ring */
830 out_be32((void *)&msg_regs->dqdpar, (u32) dbell_ring.phys);
831 out_be32((void *)&msg_regs->dqepar, (u32) dbell_ring.phys);
832
833 /* Clear interrupt status */
834 out_be32((void *)&msg_regs->dsr, 0x00000091);
835
836 /* Hook up doorbell handler */
837 if ((rc =
838 request_irq(MPC85xx_IRQ_RIO_BELL, mpc85xx_rio_dbell_handler, 0,
839 "dbell_rx", (void *)mport) < 0)) {
840 iounmap((void *)dbell_win);
841 dma_free_coherent(NULL, 512 * DOORBELL_MESSAGE_SIZE,
842 dbell_ring.virt, dbell_ring.phys);
843 printk(KERN_ERR
844 "MPC85xx RIO: unable to request inbound doorbell irq");
845 goto out;
846 }
847
848 /* Configure doorbells for snooping, 512 entries, and enable */
849 out_be32((void *)&msg_regs->dmr, 0x00108161);
850
851 out:
852 return rc;
853}
854
855static char *cmdline = NULL;
856
857static int mpc85xx_rio_get_hdid(int index)
858{
859 /* XXX Need to parse multiple entries in some format */
860 if (!cmdline)
861 return -1;
862
863 return simple_strtol(cmdline, NULL, 0);
864}
865
866static int mpc85xx_rio_get_cmdline(char *s)
867{
868 if (!s)
869 return 0;
870
871 cmdline = s;
872 return 1;
873}
874
875__setup("riohdid=", mpc85xx_rio_get_cmdline);
876
877/**
878 * mpc85xx_rio_setup - Setup MPC85xx RapidIO interface
879 * @law_start: Starting physical address of RapidIO LAW
880 * @law_size: Size of RapidIO LAW
881 *
882 * Initializes MPC85xx RapidIO hardware interface, configures
883 * master port with system-specific info, and registers the
884 * master port with the RapidIO subsystem.
885 */
886void mpc85xx_rio_setup(int law_start, int law_size)
887{
888 struct rio_ops *ops;
889 struct rio_mport *port;
890
891 ops = kmalloc(sizeof(struct rio_ops), GFP_KERNEL);
892 ops->lcread = mpc85xx_local_config_read;
893 ops->lcwrite = mpc85xx_local_config_write;
894 ops->cread = mpc85xx_rio_config_read;
895 ops->cwrite = mpc85xx_rio_config_write;
896 ops->dsend = mpc85xx_rio_doorbell_send;
897
898 port = kmalloc(sizeof(struct rio_mport), GFP_KERNEL);
899 port->id = 0;
900 port->index = 0;
901 INIT_LIST_HEAD(&port->dbells);
902 port->iores.start = law_start;
903 port->iores.end = law_start + law_size;
904 port->iores.flags = IORESOURCE_MEM;
905
906 rio_init_dbell_res(&port->riores[RIO_DOORBELL_RESOURCE], 0, 0xffff);
907 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);
909 strcpy(port->name, "RIO0 mport");
910
911 port->ops = ops;
912 port->host_deviceid = mpc85xx_rio_get_hdid(port->id);
913
914 rio_register_mport(port);
915
916 regs_win = (u32) ioremap(RIO_REGS_BASE, 0x20000);
917 atmu_regs = (struct rio_atmu_regs *)(regs_win + RIO_ATMU_REGS_OFFSET);
918 maint_atmu_regs = atmu_regs + 1;
919 dbell_atmu_regs = atmu_regs + 2;
920 msg_regs = (struct rio_msg_regs *)(regs_win + RIO_MSG_REGS_OFFSET);
921
922 /* Configure maintenance transaction window */
923 out_be32((void *)&maint_atmu_regs->rowbar, 0x000c0000);
924 out_be32((void *)&maint_atmu_regs->rowar, 0x80077015);
925
926 maint_win = (u32) ioremap(law_start, RIO_MAINT_WIN_SIZE);
927
928 /* Configure outbound doorbell window */
929 out_be32((void *)&dbell_atmu_regs->rowbar, 0x000c0400);
930 out_be32((void *)&dbell_atmu_regs->rowar, 0x8004200b);
931 mpc85xx_rio_doorbell_init(port);
932}
diff --git a/arch/ppc/syslib/ppc85xx_rio.h b/arch/ppc/syslib/ppc85xx_rio.h
new file mode 100644
index 000000000000..c0827a2c3eec
--- /dev/null
+++ b/arch/ppc/syslib/ppc85xx_rio.h
@@ -0,0 +1,21 @@
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/config.h>
17#include <linux/init.h>
18
19extern void mpc85xx_rio_setup(int law_start, int law_size);
20
21#endif /* __PPC_SYSLIB_PPC85XX_RIO_H */
diff --git a/include/asm-ppc/rio.h b/include/asm-ppc/rio.h
new file mode 100644
index 000000000000..0018bf80cb25
--- /dev/null
+++ b/include/asm-ppc/rio.h
@@ -0,0 +1,18 @@
1/*
2 * RapidIO architecture 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#ifndef ASM_PPC_RIO_H
14#define ASM_PPC_RIO_H
15
16extern void platform_rio_init(void);
17
18#endif /* ASM_PPC_RIO_H */