2019-05-27 14:55:01 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2005-11-07 17:00:19 +08:00
|
|
|
/*
|
2008-04-19 04:33:38 +08:00
|
|
|
* Freescale MPC85xx/MPC86xx RapidIO support
|
2005-11-07 17:00:19 +08:00
|
|
|
*
|
2010-05-27 05:44:05 +08:00
|
|
|
* Copyright 2009 Sysgo AG
|
|
|
|
* Thomas Moll <thomas.moll@sysgo.com>
|
|
|
|
* - fixed maintenance access routines, check for aligned access
|
|
|
|
*
|
2010-05-27 05:44:00 +08:00
|
|
|
* Copyright 2009 Integrated Device Technology, Inc.
|
|
|
|
* Alex Bounine <alexandre.bounine@idt.com>
|
|
|
|
* - Added Port-Write message handling
|
|
|
|
* - Added Machine Check exception handling
|
|
|
|
*
|
2011-11-12 20:02:28 +08:00
|
|
|
* Copyright (C) 2007, 2008, 2010, 2011 Freescale Semiconductor, Inc.
|
2008-04-19 04:33:41 +08:00
|
|
|
* Zhang Wei <wei.zhang@freescale.com>
|
|
|
|
*
|
2005-11-07 17:00:19 +08:00
|
|
|
* Copyright 2005 MontaVista Software, Inc.
|
|
|
|
* Matt Porter <mporter@kernel.crashing.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/init.h>
|
2016-08-16 22:57:34 +08:00
|
|
|
#include <linux/extable.h>
|
2005-11-07 17:00:19 +08:00
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/dma-mapping.h>
|
|
|
|
#include <linux/interrupt.h>
|
2009-04-19 01:48:52 +08:00
|
|
|
#include <linux/device.h>
|
2013-09-26 20:40:04 +08:00
|
|
|
#include <linux/of_address.h>
|
|
|
|
#include <linux/of_irq.h>
|
2008-04-19 04:33:41 +08:00
|
|
|
#include <linux/of_platform.h>
|
2008-04-19 04:33:44 +08:00
|
|
|
#include <linux/delay.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2005-11-07 17:00:19 +08:00
|
|
|
|
2011-11-12 20:02:28 +08:00
|
|
|
#include <linux/io.h>
|
|
|
|
#include <linux/uaccess.h>
|
2010-05-27 05:44:00 +08:00
|
|
|
#include <asm/machdep.h>
|
2005-11-07 17:00:19 +08:00
|
|
|
|
2011-11-12 20:02:28 +08:00
|
|
|
#include "fsl_rio.h"
|
2010-05-27 05:44:00 +08:00
|
|
|
|
2011-11-12 20:02:28 +08:00
|
|
|
#undef DEBUG_PW /* Port-Write debugging */
|
2010-11-18 14:57:53 +08:00
|
|
|
|
|
|
|
#define RIO_PORT1_EDCSR 0x0640
|
|
|
|
#define RIO_PORT2_EDCSR 0x0680
|
|
|
|
#define RIO_PORT1_IECSR 0x10130
|
|
|
|
#define RIO_PORT2_IECSR 0x101B0
|
|
|
|
|
2010-10-28 06:34:34 +08:00
|
|
|
#define RIO_GCCSR 0x13c
|
2008-04-19 04:33:44 +08:00
|
|
|
#define RIO_ESCSR 0x158
|
2011-11-12 20:02:28 +08:00
|
|
|
#define ESCSR_CLEAR 0x07120204
|
2010-11-18 14:57:53 +08:00
|
|
|
#define RIO_PORT2_ESCSR 0x178
|
2008-04-19 04:33:44 +08:00
|
|
|
#define RIO_CCSR 0x15c
|
2010-11-18 14:57:53 +08:00
|
|
|
#define RIO_LTLEDCSR_IER 0x80000000
|
|
|
|
#define RIO_LTLEDCSR_PRT 0x01000000
|
2011-11-12 20:02:28 +08:00
|
|
|
#define IECSR_CLEAR 0x80000000
|
2008-04-19 04:33:44 +08:00
|
|
|
#define RIO_ISR_AACR 0x10120
|
|
|
|
#define RIO_ISR_AACR_AA 0x1 /* Accept All ID */
|
2005-11-07 17:00:19 +08:00
|
|
|
|
2014-08-05 21:52:32 +08:00
|
|
|
#define RIWTAR_TRAD_VAL_SHIFT 12
|
|
|
|
#define RIWTAR_TRAD_MASK 0x00FFFFFF
|
|
|
|
#define RIWBAR_BADD_VAL_SHIFT 12
|
|
|
|
#define RIWBAR_BADD_MASK 0x003FFFFF
|
|
|
|
#define RIWAR_ENABLE 0x80000000
|
|
|
|
#define RIWAR_TGINT_LOCAL 0x00F00000
|
|
|
|
#define RIWAR_RDTYP_NO_SNOOP 0x00040000
|
|
|
|
#define RIWAR_RDTYP_SNOOP 0x00050000
|
|
|
|
#define RIWAR_WRTYP_NO_SNOOP 0x00004000
|
|
|
|
#define RIWAR_WRTYP_SNOOP 0x00005000
|
|
|
|
#define RIWAR_WRTYP_ALLOC 0x00006000
|
|
|
|
#define RIWAR_SIZE_MASK 0x0000003F
|
|
|
|
|
2017-10-04 07:15:13 +08:00
|
|
|
static DEFINE_SPINLOCK(fsl_rio_config_lock);
|
|
|
|
|
2010-05-27 05:44:00 +08:00
|
|
|
#define __fsl_read_rio_config(x, addr, err, op) \
|
|
|
|
__asm__ __volatile__( \
|
|
|
|
"1: "op" %1,0(%2)\n" \
|
|
|
|
" eieio\n" \
|
|
|
|
"2:\n" \
|
|
|
|
".section .fixup,\"ax\"\n" \
|
|
|
|
"3: li %1,-1\n" \
|
|
|
|
" li %0,%3\n" \
|
|
|
|
" b 2b\n" \
|
2016-10-13 13:42:53 +08:00
|
|
|
".previous\n" \
|
|
|
|
EX_TABLE(1b, 3b) \
|
2010-05-27 05:44:00 +08:00
|
|
|
: "=r" (err), "=r" (x) \
|
|
|
|
: "b" (addr), "i" (-EFAULT), "0" (err))
|
|
|
|
|
2011-11-12 20:02:28 +08:00
|
|
|
void __iomem *rio_regs_win;
|
2011-11-12 20:02:29 +08:00
|
|
|
void __iomem *rmu_regs_win;
|
|
|
|
resource_size_t rio_law_start;
|
|
|
|
|
|
|
|
struct fsl_rio_dbell *dbell;
|
|
|
|
struct fsl_rio_pw *pw;
|
2010-05-27 05:44:00 +08:00
|
|
|
|
2010-06-18 14:24:20 +08:00
|
|
|
#ifdef CONFIG_E500
|
2010-11-18 14:57:32 +08:00
|
|
|
int fsl_rio_mcheck_exception(struct pt_regs *regs)
|
2010-05-27 05:44:00 +08:00
|
|
|
{
|
2011-06-17 03:09:17 +08:00
|
|
|
const struct exception_table_entry *entry;
|
|
|
|
unsigned long reason;
|
2010-05-27 05:44:00 +08:00
|
|
|
|
2011-06-17 03:09:17 +08:00
|
|
|
if (!rio_regs_win)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
reason = in_be32((u32 *)(rio_regs_win + RIO_LTLEDCSR));
|
|
|
|
if (reason & (RIO_LTLEDCSR_IER | RIO_LTLEDCSR_PRT)) {
|
|
|
|
/* Check if we are prepared to handle this fault */
|
|
|
|
entry = search_exception_tables(regs->nip);
|
|
|
|
if (entry) {
|
|
|
|
pr_debug("RIO: %s - MC Exception handled\n",
|
|
|
|
__func__);
|
|
|
|
out_be32((u32 *)(rio_regs_win + RIO_LTLEDCSR),
|
|
|
|
0);
|
|
|
|
regs->msr |= MSR_RI;
|
2016-10-14 13:47:31 +08:00
|
|
|
regs->nip = extable_fixup(entry);
|
2011-06-17 03:09:17 +08:00
|
|
|
return 1;
|
2010-05-27 05:44:00 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-18 14:57:32 +08:00
|
|
|
return 0;
|
2010-05-27 05:44:00 +08:00
|
|
|
}
|
2010-11-18 14:57:32 +08:00
|
|
|
EXPORT_SYMBOL_GPL(fsl_rio_mcheck_exception);
|
2010-06-18 14:24:20 +08:00
|
|
|
#endif
|
2010-05-27 05:44:00 +08:00
|
|
|
|
2005-11-07 17:00:19 +08:00
|
|
|
/**
|
2008-04-19 04:33:38 +08:00
|
|
|
* fsl_local_config_read - Generate a MPC85xx local config space read
|
2008-05-01 07:45:58 +08:00
|
|
|
* @mport: RapidIO master port info
|
2005-11-07 17:00:19 +08:00
|
|
|
* @index: ID of RapdiIO interface
|
|
|
|
* @offset: Offset into configuration space
|
|
|
|
* @len: Length (in bytes) of the maintenance transaction
|
|
|
|
* @data: Value to be read into
|
|
|
|
*
|
|
|
|
* Generates a MPC85xx local configuration space read. Returns %0 on
|
|
|
|
* success or %-EINVAL on failure.
|
|
|
|
*/
|
2008-04-19 04:33:41 +08:00
|
|
|
static int fsl_local_config_read(struct rio_mport *mport,
|
|
|
|
int index, u32 offset, int len, u32 *data)
|
2005-11-07 17:00:19 +08:00
|
|
|
{
|
2008-04-19 04:33:41 +08:00
|
|
|
struct rio_priv *priv = mport->priv;
|
2008-04-19 04:33:38 +08:00
|
|
|
pr_debug("fsl_local_config_read: index %d offset %8.8x\n", index,
|
2011-11-12 20:02:29 +08:00
|
|
|
offset);
|
2008-04-19 04:33:41 +08:00
|
|
|
*data = in_be32(priv->regs_win + offset);
|
2005-11-07 17:00:19 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-04-19 04:33:38 +08:00
|
|
|
* fsl_local_config_write - Generate a MPC85xx local config space write
|
2008-05-01 07:45:58 +08:00
|
|
|
* @mport: RapidIO master port info
|
2005-11-07 17:00:19 +08:00
|
|
|
* @index: ID of RapdiIO interface
|
|
|
|
* @offset: Offset into configuration space
|
|
|
|
* @len: Length (in bytes) of the maintenance transaction
|
|
|
|
* @data: Value to be written
|
|
|
|
*
|
|
|
|
* Generates a MPC85xx local configuration space write. Returns %0 on
|
|
|
|
* success or %-EINVAL on failure.
|
|
|
|
*/
|
2008-04-19 04:33:41 +08:00
|
|
|
static int fsl_local_config_write(struct rio_mport *mport,
|
|
|
|
int index, u32 offset, int len, u32 data)
|
2005-11-07 17:00:19 +08:00
|
|
|
{
|
2008-04-19 04:33:41 +08:00
|
|
|
struct rio_priv *priv = mport->priv;
|
2005-11-07 17:00:19 +08:00
|
|
|
pr_debug
|
2011-11-12 20:02:28 +08:00
|
|
|
("fsl_local_config_write: index %d offset %8.8x data %8.8x\n",
|
|
|
|
index, offset, data);
|
2008-04-19 04:33:41 +08:00
|
|
|
out_be32(priv->regs_win + offset, data);
|
2005-11-07 17:00:19 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-04-19 04:33:38 +08:00
|
|
|
* fsl_rio_config_read - Generate a MPC85xx read maintenance transaction
|
2008-05-01 07:45:58 +08:00
|
|
|
* @mport: RapidIO master port info
|
2005-11-07 17:00:19 +08:00
|
|
|
* @index: ID of RapdiIO interface
|
|
|
|
* @destid: Destination ID of transaction
|
|
|
|
* @hopcount: Number of hops to target device
|
|
|
|
* @offset: Offset into configuration space
|
|
|
|
* @len: Length (in bytes) of the maintenance transaction
|
|
|
|
* @val: Location to be read into
|
|
|
|
*
|
|
|
|
* Generates a MPC85xx read maintenance transaction. Returns %0 on
|
|
|
|
* success or %-EINVAL on failure.
|
|
|
|
*/
|
|
|
|
static int
|
2008-04-19 04:33:41 +08:00
|
|
|
fsl_rio_config_read(struct rio_mport *mport, int index, u16 destid,
|
|
|
|
u8 hopcount, u32 offset, int len, u32 *val)
|
2005-11-07 17:00:19 +08:00
|
|
|
{
|
2008-04-19 04:33:41 +08:00
|
|
|
struct rio_priv *priv = mport->priv;
|
2017-10-04 07:15:13 +08:00
|
|
|
unsigned long flags;
|
2005-11-07 17:00:19 +08:00
|
|
|
u8 *data;
|
2010-05-27 05:44:00 +08:00
|
|
|
u32 rval, err = 0;
|
2005-11-07 17:00:19 +08:00
|
|
|
|
|
|
|
pr_debug
|
2011-11-12 20:02:28 +08:00
|
|
|
("fsl_rio_config_read:"
|
|
|
|
" index %d destid %d hopcount %d offset %8.8x len %d\n",
|
2011-11-12 20:02:29 +08:00
|
|
|
index, destid, hopcount, offset, len);
|
2010-05-27 05:44:05 +08:00
|
|
|
|
|
|
|
/* 16MB maintenance window possible */
|
|
|
|
/* allow only aligned access to maintenance registers */
|
|
|
|
if (offset > (0x1000000 - len) || !IS_ALIGNED(offset, len))
|
|
|
|
return -EINVAL;
|
|
|
|
|
2017-10-04 07:15:13 +08:00
|
|
|
spin_lock_irqsave(&fsl_rio_config_lock, flags);
|
|
|
|
|
2008-04-19 04:33:41 +08:00
|
|
|
out_be32(&priv->maint_atmu_regs->rowtar,
|
2010-05-27 05:44:05 +08:00
|
|
|
(destid << 22) | (hopcount << 12) | (offset >> 12));
|
2011-11-12 20:02:28 +08:00
|
|
|
out_be32(&priv->maint_atmu_regs->rowtear, (destid >> 10));
|
2005-11-07 17:00:19 +08:00
|
|
|
|
2010-05-27 05:44:05 +08:00
|
|
|
data = (u8 *) priv->maint_win + (offset & (RIO_MAINT_WIN_SIZE - 1));
|
2005-11-07 17:00:19 +08:00
|
|
|
switch (len) {
|
|
|
|
case 1:
|
2010-05-27 05:44:00 +08:00
|
|
|
__fsl_read_rio_config(rval, data, err, "lbz");
|
2005-11-07 17:00:19 +08:00
|
|
|
break;
|
|
|
|
case 2:
|
2010-05-27 05:44:00 +08:00
|
|
|
__fsl_read_rio_config(rval, data, err, "lhz");
|
2005-11-07 17:00:19 +08:00
|
|
|
break;
|
2010-05-27 05:44:05 +08:00
|
|
|
case 4:
|
2010-05-27 05:44:00 +08:00
|
|
|
__fsl_read_rio_config(rval, data, err, "lwz");
|
2005-11-07 17:00:19 +08:00
|
|
|
break;
|
2010-05-27 05:44:05 +08:00
|
|
|
default:
|
2017-10-04 07:15:13 +08:00
|
|
|
spin_unlock_irqrestore(&fsl_rio_config_lock, flags);
|
2010-05-27 05:44:05 +08:00
|
|
|
return -EINVAL;
|
2005-11-07 17:00:19 +08:00
|
|
|
}
|
|
|
|
|
2010-05-27 05:44:00 +08:00
|
|
|
if (err) {
|
|
|
|
pr_debug("RIO: cfg_read error %d for %x:%x:%x\n",
|
|
|
|
err, destid, hopcount, offset);
|
|
|
|
}
|
|
|
|
|
2017-10-04 07:15:13 +08:00
|
|
|
spin_unlock_irqrestore(&fsl_rio_config_lock, flags);
|
2010-05-27 05:44:00 +08:00
|
|
|
*val = rval;
|
|
|
|
|
|
|
|
return err;
|
2005-11-07 17:00:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-04-19 04:33:38 +08:00
|
|
|
* fsl_rio_config_write - Generate a MPC85xx write maintenance transaction
|
2008-05-01 07:45:58 +08:00
|
|
|
* @mport: RapidIO master port info
|
2005-11-07 17:00:19 +08:00
|
|
|
* @index: ID of RapdiIO interface
|
|
|
|
* @destid: Destination ID of transaction
|
|
|
|
* @hopcount: Number of hops to target device
|
|
|
|
* @offset: Offset into configuration space
|
|
|
|
* @len: Length (in bytes) of the maintenance transaction
|
|
|
|
* @val: Value to be written
|
|
|
|
*
|
|
|
|
* Generates an MPC85xx write maintenance transaction. Returns %0 on
|
|
|
|
* success or %-EINVAL on failure.
|
|
|
|
*/
|
|
|
|
static int
|
2008-04-19 04:33:41 +08:00
|
|
|
fsl_rio_config_write(struct rio_mport *mport, int index, u16 destid,
|
|
|
|
u8 hopcount, u32 offset, int len, u32 val)
|
2005-11-07 17:00:19 +08:00
|
|
|
{
|
2008-04-19 04:33:41 +08:00
|
|
|
struct rio_priv *priv = mport->priv;
|
2017-10-04 07:15:13 +08:00
|
|
|
unsigned long flags;
|
2005-11-07 17:00:19 +08:00
|
|
|
u8 *data;
|
2017-10-04 07:15:13 +08:00
|
|
|
int ret = 0;
|
|
|
|
|
2005-11-07 17:00:19 +08:00
|
|
|
pr_debug
|
2011-11-12 20:02:28 +08:00
|
|
|
("fsl_rio_config_write:"
|
2011-11-12 20:02:29 +08:00
|
|
|
" index %d destid %d hopcount %d offset %8.8x len %d val %8.8x\n",
|
|
|
|
index, destid, hopcount, offset, len, val);
|
2010-05-27 05:44:05 +08:00
|
|
|
|
|
|
|
/* 16MB maintenance windows possible */
|
|
|
|
/* allow only aligned access to maintenance registers */
|
|
|
|
if (offset > (0x1000000 - len) || !IS_ALIGNED(offset, len))
|
|
|
|
return -EINVAL;
|
|
|
|
|
2017-10-04 07:15:13 +08:00
|
|
|
spin_lock_irqsave(&fsl_rio_config_lock, flags);
|
|
|
|
|
2008-04-19 04:33:41 +08:00
|
|
|
out_be32(&priv->maint_atmu_regs->rowtar,
|
2010-05-27 05:44:05 +08:00
|
|
|
(destid << 22) | (hopcount << 12) | (offset >> 12));
|
2011-11-12 20:02:28 +08:00
|
|
|
out_be32(&priv->maint_atmu_regs->rowtear, (destid >> 10));
|
2005-11-07 17:00:19 +08:00
|
|
|
|
2010-05-27 05:44:05 +08:00
|
|
|
data = (u8 *) priv->maint_win + (offset & (RIO_MAINT_WIN_SIZE - 1));
|
2005-11-07 17:00:19 +08:00
|
|
|
switch (len) {
|
|
|
|
case 1:
|
|
|
|
out_8((u8 *) data, val);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
out_be16((u16 *) data, val);
|
|
|
|
break;
|
2010-05-27 05:44:05 +08:00
|
|
|
case 4:
|
2005-11-07 17:00:19 +08:00
|
|
|
out_be32((u32 *) data, val);
|
|
|
|
break;
|
2010-05-27 05:44:05 +08:00
|
|
|
default:
|
2017-10-04 07:15:13 +08:00
|
|
|
ret = -EINVAL;
|
2005-11-07 17:00:19 +08:00
|
|
|
}
|
2017-10-04 07:15:13 +08:00
|
|
|
spin_unlock_irqrestore(&fsl_rio_config_lock, flags);
|
2005-11-07 17:00:19 +08:00
|
|
|
|
2017-10-04 07:15:13 +08:00
|
|
|
return ret;
|
2005-11-07 17:00:19 +08:00
|
|
|
}
|
|
|
|
|
2014-08-05 21:52:32 +08:00
|
|
|
static void fsl_rio_inbound_mem_init(struct rio_priv *priv)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* close inbound windows */
|
|
|
|
for (i = 0; i < RIO_INB_ATMU_COUNT; i++)
|
|
|
|
out_be32(&priv->inb_atmu_regs[i].riwar, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int fsl_map_inb_mem(struct rio_mport *mport, dma_addr_t lstart,
|
2016-08-03 05:06:54 +08:00
|
|
|
u64 rstart, u64 size, u32 flags)
|
2014-08-05 21:52:32 +08:00
|
|
|
{
|
|
|
|
struct rio_priv *priv = mport->priv;
|
|
|
|
u32 base_size;
|
|
|
|
unsigned int base_size_log;
|
|
|
|
u64 win_start, win_end;
|
|
|
|
u32 riwar;
|
|
|
|
int i;
|
|
|
|
|
2016-08-03 05:06:54 +08:00
|
|
|
if ((size & (size - 1)) != 0 || size > 0x400000000ULL)
|
2014-08-05 21:52:32 +08:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
base_size_log = ilog2(size);
|
|
|
|
base_size = 1 << base_size_log;
|
|
|
|
|
|
|
|
/* check if addresses are aligned with the window size */
|
|
|
|
if (lstart & (base_size - 1))
|
|
|
|
return -EINVAL;
|
|
|
|
if (rstart & (base_size - 1))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* check for conflicting ranges */
|
|
|
|
for (i = 0; i < RIO_INB_ATMU_COUNT; i++) {
|
|
|
|
riwar = in_be32(&priv->inb_atmu_regs[i].riwar);
|
|
|
|
if ((riwar & RIWAR_ENABLE) == 0)
|
|
|
|
continue;
|
|
|
|
win_start = ((u64)(in_be32(&priv->inb_atmu_regs[i].riwbar) & RIWBAR_BADD_MASK))
|
|
|
|
<< RIWBAR_BADD_VAL_SHIFT;
|
|
|
|
win_end = win_start + ((1 << ((riwar & RIWAR_SIZE_MASK) + 1)) - 1);
|
|
|
|
if (rstart < win_end && (rstart + size) > win_start)
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* find unused atmu */
|
|
|
|
for (i = 0; i < RIO_INB_ATMU_COUNT; i++) {
|
|
|
|
riwar = in_be32(&priv->inb_atmu_regs[i].riwar);
|
|
|
|
if ((riwar & RIWAR_ENABLE) == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (i >= RIO_INB_ATMU_COUNT)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
out_be32(&priv->inb_atmu_regs[i].riwtar, lstart >> RIWTAR_TRAD_VAL_SHIFT);
|
|
|
|
out_be32(&priv->inb_atmu_regs[i].riwbar, rstart >> RIWBAR_BADD_VAL_SHIFT);
|
|
|
|
out_be32(&priv->inb_atmu_regs[i].riwar, RIWAR_ENABLE | RIWAR_TGINT_LOCAL |
|
|
|
|
RIWAR_RDTYP_SNOOP | RIWAR_WRTYP_SNOOP | (base_size_log - 1));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fsl_unmap_inb_mem(struct rio_mport *mport, dma_addr_t lstart)
|
|
|
|
{
|
|
|
|
u32 win_start_shift, base_start_shift;
|
|
|
|
struct rio_priv *priv = mport->priv;
|
|
|
|
u32 riwar, riwtar;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* skip default window */
|
|
|
|
base_start_shift = lstart >> RIWTAR_TRAD_VAL_SHIFT;
|
|
|
|
for (i = 0; i < RIO_INB_ATMU_COUNT; i++) {
|
|
|
|
riwar = in_be32(&priv->inb_atmu_regs[i].riwar);
|
|
|
|
if ((riwar & RIWAR_ENABLE) == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
riwtar = in_be32(&priv->inb_atmu_regs[i].riwtar);
|
|
|
|
win_start_shift = riwtar & RIWTAR_TRAD_MASK;
|
|
|
|
if (win_start_shift == base_start_shift) {
|
|
|
|
out_be32(&priv->inb_atmu_regs[i].riwar, riwar & ~RIWAR_ENABLE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-12 20:02:29 +08:00
|
|
|
void fsl_rio_port_error_handler(int offset)
|
2010-11-18 14:57:53 +08:00
|
|
|
{
|
|
|
|
/*XXX: Error recovery is not implemented, we just clear errors */
|
|
|
|
out_be32((u32 *)(rio_regs_win + RIO_LTLEDCSR), 0);
|
|
|
|
|
|
|
|
if (offset == 0) {
|
|
|
|
out_be32((u32 *)(rio_regs_win + RIO_PORT1_EDCSR), 0);
|
2011-08-26 06:59:25 +08:00
|
|
|
out_be32((u32 *)(rio_regs_win + RIO_PORT1_IECSR), IECSR_CLEAR);
|
2010-11-18 14:57:53 +08:00
|
|
|
out_be32((u32 *)(rio_regs_win + RIO_ESCSR), ESCSR_CLEAR);
|
|
|
|
} else {
|
|
|
|
out_be32((u32 *)(rio_regs_win + RIO_PORT2_EDCSR), 0);
|
2011-08-26 06:59:25 +08:00
|
|
|
out_be32((u32 *)(rio_regs_win + RIO_PORT2_IECSR), IECSR_CLEAR);
|
2010-11-18 14:57:53 +08:00
|
|
|
out_be32((u32 *)(rio_regs_win + RIO_PORT2_ESCSR), ESCSR_CLEAR);
|
|
|
|
}
|
|
|
|
}
|
2008-04-19 04:33:44 +08:00
|
|
|
static inline void fsl_rio_info(struct device *dev, u32 ccsr)
|
|
|
|
{
|
|
|
|
const char *str;
|
|
|
|
if (ccsr & 1) {
|
|
|
|
/* Serial phy */
|
|
|
|
switch (ccsr >> 30) {
|
|
|
|
case 0:
|
|
|
|
str = "1";
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
str = "4";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
str = "Unknown";
|
2009-06-28 14:26:10 +08:00
|
|
|
break;
|
2008-04-19 04:33:44 +08:00
|
|
|
}
|
|
|
|
dev_info(dev, "Hardware port width: %s\n", str);
|
|
|
|
|
|
|
|
switch ((ccsr >> 27) & 7) {
|
|
|
|
case 0:
|
|
|
|
str = "Single-lane 0";
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
str = "Single-lane 2";
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
str = "Four-lane";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
str = "Unknown";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
dev_info(dev, "Training connection status: %s\n", str);
|
|
|
|
} else {
|
|
|
|
/* Parallel phy */
|
|
|
|
if (!(ccsr & 0x80000000))
|
|
|
|
dev_info(dev, "Output port operating in 8-bit mode\n");
|
|
|
|
if (!(ccsr & 0x08000000))
|
|
|
|
dev_info(dev, "Input port operating in 8-bit mode\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-07 17:00:19 +08:00
|
|
|
/**
|
2008-05-01 07:45:58 +08:00
|
|
|
* fsl_rio_setup - Setup Freescale PowerPC RapidIO interface
|
2010-08-06 23:25:50 +08:00
|
|
|
* @dev: platform_device pointer
|
2005-11-07 17:00:19 +08:00
|
|
|
*
|
|
|
|
* Initializes MPC85xx RapidIO hardware interface, configures
|
|
|
|
* master port with system-specific info, and registers the
|
|
|
|
* master port with the RapidIO subsystem.
|
|
|
|
*/
|
2010-07-23 05:52:34 +08:00
|
|
|
int fsl_rio_setup(struct platform_device *dev)
|
2005-11-07 17:00:19 +08:00
|
|
|
{
|
|
|
|
struct rio_ops *ops;
|
|
|
|
struct rio_mport *port;
|
2008-04-19 04:33:41 +08:00
|
|
|
struct rio_priv *priv;
|
|
|
|
int rc = 0;
|
2011-11-12 20:02:29 +08:00
|
|
|
const u32 *dt_range, *cell, *port_index;
|
|
|
|
u32 active_ports = 0;
|
|
|
|
struct resource regs, rmu_regs;
|
|
|
|
struct device_node *np, *rmu_node;
|
2008-04-19 04:33:41 +08:00
|
|
|
int rlen;
|
2008-04-19 04:33:44 +08:00
|
|
|
u32 ccsr;
|
2011-11-12 20:02:29 +08:00
|
|
|
u64 range_start, range_size;
|
2008-04-19 04:33:41 +08:00
|
|
|
int paw, aw, sw;
|
2011-11-12 20:02:29 +08:00
|
|
|
u32 i;
|
|
|
|
static int tmp;
|
|
|
|
struct device_node *rmu_np[MAX_MSG_UNIT_NUM] = {NULL};
|
2008-04-19 04:33:41 +08:00
|
|
|
|
2010-04-14 07:12:29 +08:00
|
|
|
if (!dev->dev.of_node) {
|
2008-04-19 04:33:41 +08:00
|
|
|
dev_err(&dev->dev, "Device OF-Node is NULL");
|
2011-11-12 20:02:29 +08:00
|
|
|
return -ENODEV;
|
2008-04-19 04:33:41 +08:00
|
|
|
}
|
|
|
|
|
2010-04-14 07:12:29 +08:00
|
|
|
rc = of_address_to_resource(dev->dev.of_node, 0, ®s);
|
2008-04-19 04:33:41 +08:00
|
|
|
if (rc) {
|
2017-08-21 23:16:47 +08:00
|
|
|
dev_err(&dev->dev, "Can't get %pOF property 'reg'\n",
|
|
|
|
dev->dev.of_node);
|
2008-04-19 04:33:41 +08:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
2017-08-21 23:16:47 +08:00
|
|
|
dev_info(&dev->dev, "Of-device full name %pOF\n",
|
|
|
|
dev->dev.of_node);
|
2009-05-14 06:02:24 +08:00
|
|
|
dev_info(&dev->dev, "Regs: %pR\n", ®s);
|
2008-04-19 04:33:41 +08:00
|
|
|
|
2011-11-12 20:02:29 +08:00
|
|
|
rio_regs_win = ioremap(regs.start, resource_size(®s));
|
|
|
|
if (!rio_regs_win) {
|
|
|
|
dev_err(&dev->dev, "Unable to map rio register window\n");
|
|
|
|
rc = -ENOMEM;
|
|
|
|
goto err_rio_regs;
|
2008-04-19 04:33:41 +08:00
|
|
|
}
|
|
|
|
|
2010-05-27 05:43:59 +08:00
|
|
|
ops = kzalloc(sizeof(struct rio_ops), GFP_KERNEL);
|
2009-08-07 15:00:34 +08:00
|
|
|
if (!ops) {
|
|
|
|
rc = -ENOMEM;
|
|
|
|
goto err_ops;
|
|
|
|
}
|
2008-04-19 04:33:38 +08:00
|
|
|
ops->lcread = fsl_local_config_read;
|
|
|
|
ops->lcwrite = fsl_local_config_write;
|
|
|
|
ops->cread = fsl_rio_config_read;
|
|
|
|
ops->cwrite = fsl_rio_config_write;
|
2011-11-12 20:02:29 +08:00
|
|
|
ops->dsend = fsl_rio_doorbell_send;
|
2010-05-27 05:44:00 +08:00
|
|
|
ops->pwenable = fsl_rio_pw_enable;
|
2011-11-12 20:02:29 +08:00
|
|
|
ops->open_outb_mbox = fsl_open_outb_mbox;
|
|
|
|
ops->open_inb_mbox = fsl_open_inb_mbox;
|
|
|
|
ops->close_outb_mbox = fsl_close_outb_mbox;
|
|
|
|
ops->close_inb_mbox = fsl_close_inb_mbox;
|
|
|
|
ops->add_outb_message = fsl_add_outb_message;
|
|
|
|
ops->add_inb_buffer = fsl_add_inb_buffer;
|
|
|
|
ops->get_inb_message = fsl_get_inb_message;
|
2014-08-05 21:52:32 +08:00
|
|
|
ops->map_inb = fsl_map_inb_mem;
|
|
|
|
ops->unmap_inb = fsl_unmap_inb_mem;
|
2011-11-12 20:02:29 +08:00
|
|
|
|
|
|
|
rmu_node = of_parse_phandle(dev->dev.of_node, "fsl,srio-rmu-handle", 0);
|
2014-04-29 07:20:09 +08:00
|
|
|
if (!rmu_node) {
|
|
|
|
dev_err(&dev->dev, "No valid fsl,srio-rmu-handle property\n");
|
2016-08-05 06:31:52 +08:00
|
|
|
rc = -ENOENT;
|
2011-11-12 20:02:29 +08:00
|
|
|
goto err_rmu;
|
2014-04-29 07:20:09 +08:00
|
|
|
}
|
2011-11-12 20:02:29 +08:00
|
|
|
rc = of_address_to_resource(rmu_node, 0, &rmu_regs);
|
|
|
|
if (rc) {
|
2017-08-21 23:16:47 +08:00
|
|
|
dev_err(&dev->dev, "Can't get %pOF property 'reg'\n",
|
|
|
|
rmu_node);
|
2011-11-12 20:02:29 +08:00
|
|
|
goto err_rmu;
|
|
|
|
}
|
|
|
|
rmu_regs_win = ioremap(rmu_regs.start, resource_size(&rmu_regs));
|
|
|
|
if (!rmu_regs_win) {
|
|
|
|
dev_err(&dev->dev, "Unable to map rmu register window\n");
|
2009-08-07 15:00:34 +08:00
|
|
|
rc = -ENOMEM;
|
2011-11-12 20:02:29 +08:00
|
|
|
goto err_rmu;
|
|
|
|
}
|
|
|
|
for_each_compatible_node(np, NULL, "fsl,srio-msg-unit") {
|
|
|
|
rmu_np[tmp] = np;
|
|
|
|
tmp++;
|
2009-08-07 15:00:34 +08:00
|
|
|
}
|
2008-04-19 04:33:41 +08:00
|
|
|
|
2011-11-12 20:02:29 +08:00
|
|
|
/*set up doobell node*/
|
|
|
|
np = of_find_compatible_node(NULL, NULL, "fsl,srio-dbell-unit");
|
|
|
|
if (!np) {
|
2014-04-29 07:20:09 +08:00
|
|
|
dev_err(&dev->dev, "No fsl,srio-dbell-unit node\n");
|
2011-11-12 20:02:29 +08:00
|
|
|
rc = -ENODEV;
|
|
|
|
goto err_dbell;
|
|
|
|
}
|
|
|
|
dbell = kzalloc(sizeof(struct fsl_rio_dbell), GFP_KERNEL);
|
|
|
|
if (!(dbell)) {
|
|
|
|
dev_err(&dev->dev, "Can't alloc memory for 'fsl_rio_dbell'\n");
|
2008-04-19 04:33:41 +08:00
|
|
|
rc = -ENOMEM;
|
2011-11-12 20:02:29 +08:00
|
|
|
goto err_dbell;
|
2008-04-19 04:33:41 +08:00
|
|
|
}
|
2011-11-12 20:02:29 +08:00
|
|
|
dbell->dev = &dev->dev;
|
|
|
|
dbell->bellirq = irq_of_parse_and_map(np, 1);
|
|
|
|
dev_info(&dev->dev, "bellirq: %d\n", dbell->bellirq);
|
2008-04-19 04:33:41 +08:00
|
|
|
|
2011-11-12 20:02:29 +08:00
|
|
|
aw = of_n_addr_cells(np);
|
|
|
|
dt_range = of_get_property(np, "reg", &rlen);
|
|
|
|
if (!dt_range) {
|
2017-08-21 23:16:47 +08:00
|
|
|
pr_err("%pOF: unable to find 'reg' property\n",
|
|
|
|
np);
|
2011-11-12 20:02:29 +08:00
|
|
|
rc = -ENOMEM;
|
|
|
|
goto err_pw;
|
|
|
|
}
|
|
|
|
range_start = of_read_number(dt_range, aw);
|
|
|
|
dbell->dbell_regs = (struct rio_dbell_regs *)(rmu_regs_win +
|
|
|
|
(u32)range_start);
|
|
|
|
|
|
|
|
/*set up port write node*/
|
|
|
|
np = of_find_compatible_node(NULL, NULL, "fsl,srio-port-write-unit");
|
|
|
|
if (!np) {
|
2014-04-29 07:20:09 +08:00
|
|
|
dev_err(&dev->dev, "No fsl,srio-port-write-unit node\n");
|
2011-11-12 20:02:29 +08:00
|
|
|
rc = -ENODEV;
|
|
|
|
goto err_pw;
|
|
|
|
}
|
|
|
|
pw = kzalloc(sizeof(struct fsl_rio_pw), GFP_KERNEL);
|
|
|
|
if (!(pw)) {
|
|
|
|
dev_err(&dev->dev, "Can't alloc memory for 'fsl_rio_pw'\n");
|
|
|
|
rc = -ENOMEM;
|
|
|
|
goto err_pw;
|
|
|
|
}
|
|
|
|
pw->dev = &dev->dev;
|
|
|
|
pw->pwirq = irq_of_parse_and_map(np, 0);
|
|
|
|
dev_info(&dev->dev, "pwirq: %d\n", pw->pwirq);
|
|
|
|
aw = of_n_addr_cells(np);
|
|
|
|
dt_range = of_get_property(np, "reg", &rlen);
|
|
|
|
if (!dt_range) {
|
2017-08-21 23:16:47 +08:00
|
|
|
pr_err("%pOF: unable to find 'reg' property\n",
|
|
|
|
np);
|
2011-11-12 20:02:29 +08:00
|
|
|
rc = -ENOMEM;
|
|
|
|
goto err;
|
2011-03-24 07:43:06 +08:00
|
|
|
}
|
2011-11-12 20:02:29 +08:00
|
|
|
range_start = of_read_number(dt_range, aw);
|
|
|
|
pw->pw_regs = (struct rio_pw_regs *)(rmu_regs_win + (u32)range_start);
|
|
|
|
|
|
|
|
/*set up ports node*/
|
|
|
|
for_each_child_of_node(dev->dev.of_node, np) {
|
|
|
|
port_index = of_get_property(np, "cell-index", NULL);
|
|
|
|
if (!port_index) {
|
2017-08-21 23:16:47 +08:00
|
|
|
dev_err(&dev->dev, "Can't get %pOF property 'cell-index'\n",
|
|
|
|
np);
|
2011-11-12 20:02:29 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
dt_range = of_get_property(np, "ranges", &rlen);
|
|
|
|
if (!dt_range) {
|
2017-08-21 23:16:47 +08:00
|
|
|
dev_err(&dev->dev, "Can't get %pOF property 'ranges'\n",
|
|
|
|
np);
|
2011-11-12 20:02:29 +08:00
|
|
|
continue;
|
|
|
|
}
|
2011-03-24 07:43:06 +08:00
|
|
|
|
2011-11-12 20:02:29 +08:00
|
|
|
/* Get node address wide */
|
|
|
|
cell = of_get_property(np, "#address-cells", NULL);
|
|
|
|
if (cell)
|
|
|
|
aw = *cell;
|
|
|
|
else
|
|
|
|
aw = of_n_addr_cells(np);
|
|
|
|
/* Get node size wide */
|
|
|
|
cell = of_get_property(np, "#size-cells", NULL);
|
|
|
|
if (cell)
|
|
|
|
sw = *cell;
|
|
|
|
else
|
|
|
|
sw = of_n_size_cells(np);
|
|
|
|
/* Get parent address wide wide */
|
|
|
|
paw = of_n_addr_cells(np);
|
|
|
|
range_start = of_read_number(dt_range + aw, paw);
|
|
|
|
range_size = of_read_number(dt_range + aw + paw, sw);
|
|
|
|
|
2017-08-21 23:16:47 +08:00
|
|
|
dev_info(&dev->dev, "%pOF: LAW start 0x%016llx, size 0x%016llx.\n",
|
|
|
|
np, range_start, range_size);
|
2011-11-12 20:02:29 +08:00
|
|
|
|
|
|
|
port = kzalloc(sizeof(struct rio_mport), GFP_KERNEL);
|
|
|
|
if (!port)
|
|
|
|
continue;
|
|
|
|
|
2016-03-23 05:26:26 +08:00
|
|
|
rc = rio_mport_initialize(port);
|
|
|
|
if (rc) {
|
|
|
|
kfree(port);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-11-12 20:02:29 +08:00
|
|
|
i = *port_index - 1;
|
|
|
|
port->index = (unsigned char)i;
|
|
|
|
|
|
|
|
priv = kzalloc(sizeof(struct rio_priv), GFP_KERNEL);
|
|
|
|
if (!priv) {
|
|
|
|
dev_err(&dev->dev, "Can't alloc memory for 'priv'\n");
|
|
|
|
kfree(port);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
INIT_LIST_HEAD(&port->dbells);
|
|
|
|
port->iores.start = range_start;
|
|
|
|
port->iores.end = port->iores.start + range_size - 1;
|
|
|
|
port->iores.flags = IORESOURCE_MEM;
|
|
|
|
port->iores.name = "rio_io_win";
|
|
|
|
|
|
|
|
if (request_resource(&iomem_resource, &port->iores) < 0) {
|
|
|
|
dev_err(&dev->dev, "RIO: Error requesting master port region"
|
|
|
|
" 0x%016llx-0x%016llx\n",
|
|
|
|
(u64)port->iores.start, (u64)port->iores.end);
|
|
|
|
kfree(priv);
|
|
|
|
kfree(port);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
sprintf(port->name, "RIO mport %d", i);
|
|
|
|
|
|
|
|
priv->dev = &dev->dev;
|
2014-04-08 06:38:56 +08:00
|
|
|
port->dev.parent = &dev->dev;
|
2011-11-12 20:02:29 +08:00
|
|
|
port->ops = ops;
|
|
|
|
port->priv = priv;
|
|
|
|
port->phys_efptr = 0x100;
|
2016-08-03 05:07:00 +08:00
|
|
|
port->phys_rmap = 1;
|
2011-11-12 20:02:29 +08:00
|
|
|
priv->regs_win = rio_regs_win;
|
|
|
|
|
|
|
|
ccsr = in_be32(priv->regs_win + RIO_CCSR + i*0x20);
|
2016-08-03 05:07:00 +08:00
|
|
|
|
2011-11-12 20:02:29 +08:00
|
|
|
/* Checking the port training status */
|
|
|
|
if (in_be32((priv->regs_win + RIO_ESCSR + i*0x20)) & 1) {
|
|
|
|
dev_err(&dev->dev, "Port %d is not ready. "
|
|
|
|
"Try to restart connection...\n", i);
|
2008-04-19 04:33:44 +08:00
|
|
|
/* Disable ports */
|
2011-11-12 20:02:29 +08:00
|
|
|
out_be32(priv->regs_win
|
|
|
|
+ RIO_CCSR + i*0x20, 0);
|
2008-04-19 04:33:44 +08:00
|
|
|
/* Set 1x lane */
|
2011-11-12 20:02:29 +08:00
|
|
|
setbits32(priv->regs_win
|
|
|
|
+ RIO_CCSR + i*0x20, 0x02000000);
|
2008-04-19 04:33:44 +08:00
|
|
|
/* Enable ports */
|
2011-11-12 20:02:29 +08:00
|
|
|
setbits32(priv->regs_win
|
|
|
|
+ RIO_CCSR + i*0x20, 0x00600000);
|
|
|
|
msleep(100);
|
|
|
|
if (in_be32((priv->regs_win
|
|
|
|
+ RIO_ESCSR + i*0x20)) & 1) {
|
|
|
|
dev_err(&dev->dev,
|
|
|
|
"Port %d restart failed.\n", i);
|
|
|
|
release_resource(&port->iores);
|
|
|
|
kfree(priv);
|
|
|
|
kfree(port);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
dev_info(&dev->dev, "Port %d restart success!\n", i);
|
2008-04-19 04:33:44 +08:00
|
|
|
}
|
2011-11-12 20:02:29 +08:00
|
|
|
fsl_rio_info(&dev->dev, ccsr);
|
2008-04-19 04:33:44 +08:00
|
|
|
|
2011-11-12 20:02:29 +08:00
|
|
|
port->sys_size = (in_be32((priv->regs_win + RIO_PEF_CAR))
|
2008-04-19 04:33:42 +08:00
|
|
|
& RIO_PEF_CTLS) >> 4;
|
2011-11-12 20:02:29 +08:00
|
|
|
dev_info(&dev->dev, "RapidIO Common Transport System size: %d\n",
|
|
|
|
port->sys_size ? 65536 : 256);
|
|
|
|
|
|
|
|
if (port->host_deviceid >= 0)
|
|
|
|
out_be32(priv->regs_win + RIO_GCCSR, RIO_PORT_GEN_HOST |
|
|
|
|
RIO_PORT_GEN_MASTER | RIO_PORT_GEN_DISCOVERED);
|
|
|
|
else
|
|
|
|
out_be32(priv->regs_win + RIO_GCCSR,
|
|
|
|
RIO_PORT_GEN_MASTER);
|
2008-04-19 04:33:42 +08:00
|
|
|
|
2011-11-12 20:02:29 +08:00
|
|
|
priv->atmu_regs = (struct rio_atmu_regs *)(priv->regs_win
|
|
|
|
+ ((i == 0) ? RIO_ATMU_REGS_PORT1_OFFSET :
|
|
|
|
RIO_ATMU_REGS_PORT2_OFFSET));
|
|
|
|
|
|
|
|
priv->maint_atmu_regs = priv->atmu_regs + 1;
|
2014-08-05 21:52:32 +08:00
|
|
|
priv->inb_atmu_regs = (struct rio_inb_atmu_regs __iomem *)
|
|
|
|
(priv->regs_win +
|
|
|
|
((i == 0) ? RIO_INB_ATMU_REGS_PORT1_OFFSET :
|
|
|
|
RIO_INB_ATMU_REGS_PORT2_OFFSET));
|
|
|
|
|
2016-08-03 05:07:00 +08:00
|
|
|
/* Set to receive packets with any dest ID */
|
|
|
|
out_be32((priv->regs_win + RIO_ISR_AACR + i*0x80),
|
|
|
|
RIO_ISR_AACR_AA);
|
2010-10-28 06:34:34 +08:00
|
|
|
|
2011-11-12 20:02:29 +08:00
|
|
|
/* Configure maintenance transaction window */
|
|
|
|
out_be32(&priv->maint_atmu_regs->rowbar,
|
|
|
|
port->iores.start >> 12);
|
|
|
|
out_be32(&priv->maint_atmu_regs->rowar,
|
|
|
|
0x80077000 | (ilog2(RIO_MAINT_WIN_SIZE) - 1));
|
2008-04-19 04:33:44 +08:00
|
|
|
|
2011-11-12 20:02:29 +08:00
|
|
|
priv->maint_win = ioremap(port->iores.start,
|
|
|
|
RIO_MAINT_WIN_SIZE);
|
2005-11-07 17:00:19 +08:00
|
|
|
|
2011-11-12 20:02:29 +08:00
|
|
|
rio_law_start = range_start;
|
2005-11-07 17:00:19 +08:00
|
|
|
|
2011-11-12 20:02:29 +08:00
|
|
|
fsl_rio_setup_rmu(port, rmu_np[i]);
|
2014-08-05 21:52:32 +08:00
|
|
|
fsl_rio_inbound_mem_init(priv);
|
2005-11-07 17:00:19 +08:00
|
|
|
|
2011-11-12 20:02:29 +08:00
|
|
|
dbell->mport[i] = port;
|
2016-03-23 05:26:44 +08:00
|
|
|
pw->mport[i] = port;
|
2011-11-12 20:02:29 +08:00
|
|
|
|
2016-03-23 05:26:26 +08:00
|
|
|
if (rio_register_mport(port)) {
|
|
|
|
release_resource(&port->iores);
|
|
|
|
kfree(priv);
|
|
|
|
kfree(port);
|
|
|
|
continue;
|
|
|
|
}
|
2011-11-12 20:02:29 +08:00
|
|
|
active_ports++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!active_ports) {
|
|
|
|
rc = -ENOLINK;
|
|
|
|
goto err;
|
|
|
|
}
|
2011-11-12 20:02:28 +08:00
|
|
|
|
2011-11-12 20:02:29 +08:00
|
|
|
fsl_rio_doorbell_init(dbell);
|
|
|
|
fsl_rio_port_write_init(pw);
|
2008-04-19 04:33:41 +08:00
|
|
|
|
2008-04-19 04:33:41 +08:00
|
|
|
return 0;
|
2008-04-19 04:33:41 +08:00
|
|
|
err:
|
2011-11-12 20:02:29 +08:00
|
|
|
kfree(pw);
|
2014-04-29 07:20:09 +08:00
|
|
|
pw = NULL;
|
2011-11-12 20:02:29 +08:00
|
|
|
err_pw:
|
|
|
|
kfree(dbell);
|
2014-04-29 07:20:09 +08:00
|
|
|
dbell = NULL;
|
2011-11-12 20:02:29 +08:00
|
|
|
err_dbell:
|
|
|
|
iounmap(rmu_regs_win);
|
2014-04-29 07:20:09 +08:00
|
|
|
rmu_regs_win = NULL;
|
2011-11-12 20:02:29 +08:00
|
|
|
err_rmu:
|
2009-08-07 15:00:34 +08:00
|
|
|
kfree(ops);
|
|
|
|
err_ops:
|
2011-11-12 20:02:29 +08:00
|
|
|
iounmap(rio_regs_win);
|
2014-04-29 07:20:09 +08:00
|
|
|
rio_regs_win = NULL;
|
2011-11-12 20:02:29 +08:00
|
|
|
err_rio_regs:
|
2008-04-19 04:33:41 +08:00
|
|
|
return rc;
|
2005-11-07 17:00:19 +08:00
|
|
|
}
|
2008-04-19 04:33:41 +08:00
|
|
|
|
|
|
|
/* The probe function for RapidIO peer-to-peer network.
|
|
|
|
*/
|
2012-12-22 06:04:10 +08:00
|
|
|
static int fsl_of_rio_rpn_probe(struct platform_device *dev)
|
2008-04-19 04:33:41 +08:00
|
|
|
{
|
2017-08-21 23:16:47 +08:00
|
|
|
printk(KERN_INFO "Setting up RapidIO peer-to-peer network %pOF\n",
|
|
|
|
dev->dev.of_node);
|
2008-04-19 04:33:41 +08:00
|
|
|
|
2011-03-24 07:43:04 +08:00
|
|
|
return fsl_rio_setup(dev);
|
2008-04-19 04:33:41 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct of_device_id fsl_of_rio_rpn_ids[] = {
|
|
|
|
{
|
2011-11-12 20:02:29 +08:00
|
|
|
.compatible = "fsl,srio",
|
2008-04-19 04:33:41 +08:00
|
|
|
},
|
|
|
|
{},
|
|
|
|
};
|
|
|
|
|
2011-02-23 10:59:54 +08:00
|
|
|
static struct platform_driver fsl_of_rio_rpn_driver = {
|
2010-04-14 07:13:02 +08:00
|
|
|
.driver = {
|
|
|
|
.name = "fsl-of-rio",
|
|
|
|
.of_match_table = fsl_of_rio_rpn_ids,
|
|
|
|
},
|
2008-04-19 04:33:41 +08:00
|
|
|
.probe = fsl_of_rio_rpn_probe,
|
|
|
|
};
|
|
|
|
|
|
|
|
static __init int fsl_of_rio_rpn_init(void)
|
|
|
|
{
|
2011-02-23 10:59:54 +08:00
|
|
|
return platform_driver_register(&fsl_of_rio_rpn_driver);
|
2008-04-19 04:33:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
subsys_initcall(fsl_of_rio_rpn_init);
|