2 * Copyright (C) 1999, 2000 Ralf Baechle (ralf@gnu.org)
3 * Copyright (C) 1999, 2000 Silcon Graphics, Inc.
4 * Copyright (C) 2004 Christoph Hellwig.
5 * Released under GPL v2.
7 * Generic XTALK initialization code
10 #include <linux/kernel.h>
11 #include <linux/smp.h>
12 #include <linux/platform_device.h>
13 #include <linux/platform_data/xtalk-bridge.h>
14 #include <asm/sn/addrs.h>
15 #include <asm/sn/types.h>
16 #include <asm/sn/klconfig.h>
17 #include <asm/sn/hub.h>
18 #include <asm/pci/bridge.h>
19 #include <asm/xtalk/xtalk.h>
22 #define XBOW_WIDGET_PART_NUM 0x0
23 #define XXBOW_WIDGET_PART_NUM 0xd000 /* Xbow in Xbridge */
24 #define BASE_XBOW_PORT 8 /* Lowest external port */
26 static void bridge_platform_create(nasid_t nasid
, int widget
, int masterwid
)
28 struct xtalk_bridge_platform_data
*bd
;
29 struct platform_device
*pdev
;
32 bd
= kzalloc(sizeof(*bd
), GFP_KERNEL
);
35 pdev
= platform_device_alloc("xtalk-bridge", PLATFORM_DEVID_AUTO
);
41 offset
= NODE_OFFSET(nasid
);
43 bd
->bridge_addr
= RAW_NODE_SWIN_BASE(nasid
, widget
);
44 bd
->intr_addr
= BIT_ULL(47) + 0x01800000 + PI_INT_PEND_MOD
;
46 bd
->masterwid
= masterwid
;
48 bd
->mem
.name
= "Bridge PCI MEM";
49 bd
->mem
.start
= offset
+ (widget
<< SWIN_SIZE_BITS
);
50 bd
->mem
.end
= bd
->mem
.start
+ SWIN_SIZE
- 1;
51 bd
->mem
.flags
= IORESOURCE_MEM
;
52 bd
->mem_offset
= offset
;
54 bd
->io
.name
= "Bridge PCI IO";
55 bd
->io
.start
= offset
+ (widget
<< SWIN_SIZE_BITS
);
56 bd
->io
.end
= bd
->io
.start
+ SWIN_SIZE
- 1;
57 bd
->io
.flags
= IORESOURCE_IO
;
58 bd
->io_offset
= offset
;
60 platform_device_add_data(pdev
, bd
, sizeof(*bd
));
61 platform_device_add(pdev
);
62 pr_info("xtalk:n%d/%x bridge widget\n", nasid
, widget
);
66 pr_warn("xtalk:n%d/%x bridge create out of memory\n", nasid
, widget
);
69 static int probe_one_port(nasid_t nasid
, int widget
, int masterwid
)
71 widgetreg_t widget_id
;
72 xwidget_part_num_t partnum
;
74 widget_id
= *(volatile widgetreg_t
*)
75 (RAW_NODE_SWIN_BASE(nasid
, widget
) + WIDGET_ID
);
76 partnum
= XWIDGET_PART_NUM(widget_id
);
79 case BRIDGE_WIDGET_PART_NUM
:
80 case XBRIDGE_WIDGET_PART_NUM
:
81 bridge_platform_create(nasid
, widget
, masterwid
);
90 static int xbow_probe(nasid_t nasid
)
94 unsigned masterwid
, i
;
97 * found xbow, so may have multiple bridges
100 brd
= find_lboard((lboard_t
*)KL_CONFIG_INFO(nasid
), KLTYPE_MIDPLANE8
);
104 xbow_p
= (klxbow_t
*)find_component(brd
, NULL
, KLSTRUCT_XBOW
);
109 * Okay, here's a xbow. Let's arbitrate and find
110 * out if we should initialize it. Set enabled
111 * hub connected at highest or lowest widget as
115 i
= HUB_WIDGET_ID_MAX
+ 1;
118 } while ((!XBOW_PORT_TYPE_HUB(xbow_p
, i
)) ||
119 (!XBOW_PORT_IS_ENABLED(xbow_p
, i
)));
121 i
= HUB_WIDGET_ID_MIN
- 1;
124 } while ((!XBOW_PORT_TYPE_HUB(xbow_p
, i
)) ||
125 (!XBOW_PORT_IS_ENABLED(xbow_p
, i
)));
129 if (nasid
!= XBOW_PORT_NASID(xbow_p
, i
))
132 for (i
= HUB_WIDGET_ID_MIN
; i
<= HUB_WIDGET_ID_MAX
; i
++) {
133 if (XBOW_PORT_IS_ENABLED(xbow_p
, i
) &&
134 XBOW_PORT_TYPE_IO(xbow_p
, i
))
135 probe_one_port(nasid
, i
, masterwid
);
141 static void xtalk_probe_node(cnodeid_t nid
)
145 xwidget_part_num_t partnum
;
146 widgetreg_t widget_id
;
148 nasid
= COMPACT_TO_NASID_NODEID(nid
);
149 hubreg
= REMOTE_HUB_L(nasid
, IIO_LLP_CSR
);
151 /* check whether the link is up */
152 if (!(hubreg
& IIO_LLP_CSR_IS_UP
))
155 widget_id
= *(volatile widgetreg_t
*)
156 (RAW_NODE_SWIN_BASE(nasid
, 0x0) + WIDGET_ID
);
157 partnum
= XWIDGET_PART_NUM(widget_id
);
160 case BRIDGE_WIDGET_PART_NUM
:
161 bridge_platform_create(nasid
, 0x8, 0xa);
163 case XBOW_WIDGET_PART_NUM
:
164 case XXBOW_WIDGET_PART_NUM
:
165 pr_info("xtalk:n%d/0 xbow widget\n", nasid
);
169 pr_info("xtalk:n%d/0 unknown widget (0x%x)\n", nasid
, partnum
);
174 static int __init
xtalk_init(void)
178 for_each_online_node(cnode
)
179 xtalk_probe_node(cnode
);
183 arch_initcall(xtalk_init
);