2019-05-29 01:10:12 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 1999, 2000 Ralf Baechle (ralf@gnu.org)
|
|
|
|
* Copyright (C) 1999, 2000 Silcon Graphics, Inc.
|
|
|
|
* Copyright (C) 2004 Christoph Hellwig.
|
|
|
|
*
|
|
|
|
* Generic XTALK initialization code
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
2009-06-19 21:05:26 +08:00
|
|
|
#include <linux/smp.h>
|
2019-05-08 05:09:13 +08:00
|
|
|
#include <linux/platform_device.h>
|
2019-10-03 17:52:30 +08:00
|
|
|
#include <linux/platform_data/sgi-w1.h>
|
2019-05-08 05:09:13 +08:00
|
|
|
#include <linux/platform_data/xtalk-bridge.h>
|
|
|
|
#include <asm/sn/addrs.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <asm/sn/types.h>
|
|
|
|
#include <asm/sn/klconfig.h>
|
|
|
|
#include <asm/pci/bridge.h>
|
|
|
|
#include <asm/xtalk/xtalk.h>
|
|
|
|
|
|
|
|
|
2013-01-22 19:59:30 +08:00
|
|
|
#define XBOW_WIDGET_PART_NUM 0x0
|
|
|
|
#define XXBOW_WIDGET_PART_NUM 0xd000 /* Xbow in Xbridge */
|
|
|
|
#define BASE_XBOW_PORT 8 /* Lowest external port */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2019-05-08 05:09:13 +08:00
|
|
|
static void bridge_platform_create(nasid_t nasid, int widget, int masterwid)
|
|
|
|
{
|
|
|
|
struct xtalk_bridge_platform_data *bd;
|
2019-10-03 17:52:30 +08:00
|
|
|
struct sgi_w1_platform_data *wd;
|
2019-05-08 05:09:13 +08:00
|
|
|
struct platform_device *pdev;
|
2019-10-03 17:52:30 +08:00
|
|
|
struct resource w1_res;
|
2019-05-08 05:09:13 +08:00
|
|
|
unsigned long offset;
|
|
|
|
|
2019-10-03 17:52:30 +08:00
|
|
|
offset = NODE_OFFSET(nasid);
|
|
|
|
|
|
|
|
wd = kzalloc(sizeof(*wd), GFP_KERNEL);
|
|
|
|
if (!wd)
|
|
|
|
goto no_mem;
|
|
|
|
|
|
|
|
snprintf(wd->dev_id, sizeof(wd->dev_id), "bridge-%012lx",
|
|
|
|
offset + (widget << SWIN_SIZE_BITS));
|
|
|
|
|
|
|
|
memset(&w1_res, 0, sizeof(w1_res));
|
|
|
|
w1_res.start = offset + (widget << SWIN_SIZE_BITS) +
|
|
|
|
offsetof(struct bridge_regs, b_nic);
|
|
|
|
w1_res.end = w1_res.start + 3;
|
|
|
|
w1_res.flags = IORESOURCE_MEM;
|
|
|
|
|
|
|
|
pdev = platform_device_alloc("sgi_w1", PLATFORM_DEVID_AUTO);
|
|
|
|
if (!pdev) {
|
|
|
|
kfree(wd);
|
|
|
|
goto no_mem;
|
|
|
|
}
|
|
|
|
platform_device_add_resources(pdev, &w1_res, 1);
|
|
|
|
platform_device_add_data(pdev, wd, sizeof(*wd));
|
|
|
|
platform_device_add(pdev);
|
|
|
|
|
2019-05-08 05:09:13 +08:00
|
|
|
bd = kzalloc(sizeof(*bd), GFP_KERNEL);
|
|
|
|
if (!bd)
|
|
|
|
goto no_mem;
|
|
|
|
pdev = platform_device_alloc("xtalk-bridge", PLATFORM_DEVID_AUTO);
|
|
|
|
if (!pdev) {
|
|
|
|
kfree(bd);
|
|
|
|
goto no_mem;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bd->bridge_addr = RAW_NODE_SWIN_BASE(nasid, widget);
|
|
|
|
bd->intr_addr = BIT_ULL(47) + 0x01800000 + PI_INT_PEND_MOD;
|
|
|
|
bd->nasid = nasid;
|
|
|
|
bd->masterwid = masterwid;
|
|
|
|
|
|
|
|
bd->mem.name = "Bridge PCI MEM";
|
2019-10-03 17:52:30 +08:00
|
|
|
bd->mem.start = offset + (widget << SWIN_SIZE_BITS) + BRIDGE_DEVIO0;
|
|
|
|
bd->mem.end = offset + (widget << SWIN_SIZE_BITS) + SWIN_SIZE - 1;
|
2019-05-08 05:09:13 +08:00
|
|
|
bd->mem.flags = IORESOURCE_MEM;
|
|
|
|
bd->mem_offset = offset;
|
|
|
|
|
|
|
|
bd->io.name = "Bridge PCI IO";
|
2019-10-03 17:52:30 +08:00
|
|
|
bd->io.start = offset + (widget << SWIN_SIZE_BITS) + BRIDGE_DEVIO0;
|
|
|
|
bd->io.end = offset + (widget << SWIN_SIZE_BITS) + SWIN_SIZE - 1;
|
2019-05-08 05:09:13 +08:00
|
|
|
bd->io.flags = IORESOURCE_IO;
|
|
|
|
bd->io_offset = offset;
|
|
|
|
|
|
|
|
platform_device_add_data(pdev, bd, sizeof(*bd));
|
|
|
|
platform_device_add(pdev);
|
|
|
|
pr_info("xtalk:n%d/%x bridge widget\n", nasid, widget);
|
|
|
|
return;
|
|
|
|
|
|
|
|
no_mem:
|
|
|
|
pr_warn("xtalk:n%d/%x bridge create out of memory\n", nasid, widget);
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
MIPS: Delete __cpuinit/__CPUINIT usage from MIPS code
commit 3747069b25e419f6b51395f48127e9812abc3596 upstream.
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
and are flagged as __cpuinit -- so if we remove the __cpuinit from
the arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
related content into no-ops as early as possible, since that will get
rid of these warnings. In any case, they are temporary and harmless.
Here, we remove all the MIPS __cpuinit from C code and __CPUINIT
from asm files. MIPS is interesting in this respect, because there
are also uasm users hiding behind their own renamed versions of the
__cpuinit macros.
[1] https://lkml.org/lkml/2013/5/20/589
[ralf@linux-mips.org: Folded in Paul's followup fix.]
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/5494/
Patchwork: https://patchwork.linux-mips.org/patch/5495/
Patchwork: https://patchwork.linux-mips.org/patch/5509/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
2013-06-18 21:38:59 +08:00
|
|
|
static int probe_one_port(nasid_t nasid, int widget, int masterwid)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2013-01-22 19:59:30 +08:00
|
|
|
widgetreg_t widget_id;
|
2005-04-17 06:20:36 +08:00
|
|
|
xwidget_part_num_t partnum;
|
|
|
|
|
|
|
|
widget_id = *(volatile widgetreg_t *)
|
|
|
|
(RAW_NODE_SWIN_BASE(nasid, widget) + WIDGET_ID);
|
|
|
|
partnum = XWIDGET_PART_NUM(widget_id);
|
|
|
|
|
|
|
|
switch (partnum) {
|
|
|
|
case BRIDGE_WIDGET_PART_NUM:
|
|
|
|
case XBRIDGE_WIDGET_PART_NUM:
|
2019-05-08 05:09:13 +08:00
|
|
|
bridge_platform_create(nasid, widget, masterwid);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
default:
|
2019-10-03 17:52:30 +08:00
|
|
|
pr_info("xtalk:n%d/%d unknown widget (0x%x)\n",
|
|
|
|
nasid, widget, partnum);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
MIPS: Delete __cpuinit/__CPUINIT usage from MIPS code
commit 3747069b25e419f6b51395f48127e9812abc3596 upstream.
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
and are flagged as __cpuinit -- so if we remove the __cpuinit from
the arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
related content into no-ops as early as possible, since that will get
rid of these warnings. In any case, they are temporary and harmless.
Here, we remove all the MIPS __cpuinit from C code and __CPUINIT
from asm files. MIPS is interesting in this respect, because there
are also uasm users hiding behind their own renamed versions of the
__cpuinit macros.
[1] https://lkml.org/lkml/2013/5/20/589
[ralf@linux-mips.org: Folded in Paul's followup fix.]
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/5494/
Patchwork: https://patchwork.linux-mips.org/patch/5495/
Patchwork: https://patchwork.linux-mips.org/patch/5509/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
2013-06-18 21:38:59 +08:00
|
|
|
static int xbow_probe(nasid_t nasid)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
lboard_t *brd;
|
|
|
|
klxbow_t *xbow_p;
|
|
|
|
unsigned masterwid, i;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* found xbow, so may have multiple bridges
|
|
|
|
* need to probe xbow
|
|
|
|
*/
|
|
|
|
brd = find_lboard((lboard_t *)KL_CONFIG_INFO(nasid), KLTYPE_MIDPLANE8);
|
|
|
|
if (!brd)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
xbow_p = (klxbow_t *)find_component(brd, NULL, KLSTRUCT_XBOW);
|
|
|
|
if (!xbow_p)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
/*
|
2016-05-22 06:39:18 +08:00
|
|
|
* Okay, here's a xbow. Let's arbitrate and find
|
2005-04-17 06:20:36 +08:00
|
|
|
* out if we should initialize it. Set enabled
|
|
|
|
* hub connected at highest or lowest widget as
|
|
|
|
* master.
|
|
|
|
*/
|
|
|
|
#ifdef WIDGET_A
|
|
|
|
i = HUB_WIDGET_ID_MAX + 1;
|
|
|
|
do {
|
|
|
|
i--;
|
|
|
|
} while ((!XBOW_PORT_TYPE_HUB(xbow_p, i)) ||
|
|
|
|
(!XBOW_PORT_IS_ENABLED(xbow_p, i)));
|
|
|
|
#else
|
|
|
|
i = HUB_WIDGET_ID_MIN - 1;
|
|
|
|
do {
|
|
|
|
i++;
|
|
|
|
} while ((!XBOW_PORT_TYPE_HUB(xbow_p, i)) ||
|
|
|
|
(!XBOW_PORT_IS_ENABLED(xbow_p, i)));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
masterwid = i;
|
|
|
|
if (nasid != XBOW_PORT_NASID(xbow_p, i))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
for (i = HUB_WIDGET_ID_MIN; i <= HUB_WIDGET_ID_MAX; i++) {
|
|
|
|
if (XBOW_PORT_IS_ENABLED(xbow_p, i) &&
|
|
|
|
XBOW_PORT_TYPE_IO(xbow_p, i))
|
|
|
|
probe_one_port(nasid, i, masterwid);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-10-03 20:27:24 +08:00
|
|
|
static void xtalk_probe_node(nasid_t nasid)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2013-01-22 19:59:30 +08:00
|
|
|
volatile u64 hubreg;
|
2005-04-17 06:20:36 +08:00
|
|
|
xwidget_part_num_t partnum;
|
2013-01-22 19:59:30 +08:00
|
|
|
widgetreg_t widget_id;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
hubreg = REMOTE_HUB_L(nasid, IIO_LLP_CSR);
|
|
|
|
|
|
|
|
/* check whether the link is up */
|
|
|
|
if (!(hubreg & IIO_LLP_CSR_IS_UP))
|
|
|
|
return;
|
|
|
|
|
|
|
|
widget_id = *(volatile widgetreg_t *)
|
2013-01-22 19:59:30 +08:00
|
|
|
(RAW_NODE_SWIN_BASE(nasid, 0x0) + WIDGET_ID);
|
2005-04-17 06:20:36 +08:00
|
|
|
partnum = XWIDGET_PART_NUM(widget_id);
|
|
|
|
|
|
|
|
switch (partnum) {
|
|
|
|
case BRIDGE_WIDGET_PART_NUM:
|
2019-05-08 05:09:13 +08:00
|
|
|
bridge_platform_create(nasid, 0x8, 0xa);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
case XBOW_WIDGET_PART_NUM:
|
|
|
|
case XXBOW_WIDGET_PART_NUM:
|
2019-05-08 05:09:13 +08:00
|
|
|
pr_info("xtalk:n%d/0 xbow widget\n", nasid);
|
2005-04-17 06:20:36 +08:00
|
|
|
xbow_probe(nasid);
|
|
|
|
break;
|
|
|
|
default:
|
2019-05-08 05:09:13 +08:00
|
|
|
pr_info("xtalk:n%d/0 unknown widget (0x%x)\n", nasid, partnum);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2019-02-19 23:57:18 +08:00
|
|
|
|
|
|
|
static int __init xtalk_init(void)
|
|
|
|
{
|
2019-10-03 20:27:24 +08:00
|
|
|
nasid_t nasid;
|
2019-02-19 23:57:18 +08:00
|
|
|
|
2019-10-03 20:27:24 +08:00
|
|
|
for_each_online_node(nasid)
|
|
|
|
xtalk_probe_node(nasid);
|
2019-02-19 23:57:18 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
arch_initcall(xtalk_init);
|