Skip to contentSkip to conversation

: MIPS: IP27: Xtalk detection cleanups

PATCH In review Joshua Kinard 2 participants 3 messages May 25, 2015 – Jun 5, 2015 MIPS

lore
Share & tools
lore
#0 lore raw

PATCH v2 2/2 : MIPS: IP27: Xtalk detection cleanups

From: Joshua Kinard <[email protected]>

This is the second patch of two to clean up/update the Xtalk detection code used by IP27 with some of the code used in the IP30 port.

This specific patch replaces some of the IP27 Xtalk detection code with methods used in the IP30 port, and converts the Xtalk devices into platform devices.

---
 arch/mips/include/asm/pci.h |    3 +++
 arch/mips/pci/pci.c         |   10 ++++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

This version corrects several issues detected by checkpatch.pl.

linux-mips-ip27-xtalk-cleanup.patch

arch/mips/sgi-ip27/ip27-xtalk.c +61 -26
index 20f582a..c262208 100644
@@ -9,38 +9,55 @@
 
 #include <linux/kernel.h>
 #include <linux/smp.h>
+#include <linux/platform_device.h>
+
 #include <asm/sn/types.h>
 #include <asm/sn/klconfig.h>
 #include <asm/sn/hub.h>
 #include <asm/pci/bridge.h>
 #include <asm/xtalk/xtalk.h>
+#include <asm/xtalk/xwidget.h>
 
-
-#define XBOW_WIDGET_PART_NUM	0x0
-#define XXBOW_WIDGET_PART_NUM	0xd000	/* Xbow in Xbridge */
 #define BASE_XBOW_PORT		8     /* Lowest external port */
 
 extern int bridge_probe(nasid_t nasid, int widget, int masterwid);
 
 static int probe_one_port(nasid_t nasid, int widget, int masterwid)
 {
-	widgetreg_t		widget_id;
-	xwidget_part_num_t	partnum;
+	const struct widget_ident *res;
+	u32 wid_id, wid_part, wid_mfgr, wid_rev;
 
-	widget_id = *(volatile widgetreg_t *)
+	wid_id = *(volatile widgetreg_t *)
 		(RAW_NODE_SWIN_BASE(nasid, widget) + WIDGET_ID);
-	partnum = XWIDGET_PART_NUM(widget_id);
 
-	printk(KERN_INFO "Cpu %d, Nasid 0x%x, widget 0x%x (partnum 0x%x) is ",
-			smp_processor_id(), nasid, widget, partnum);
+	wid_mfgr = XWIDGET_MFG_NUM(wid_id);
+	wid_part = XWIDGET_PART_NUM(wid_id);
+	wid_rev = XWIDGET_REV_NUM(wid_id);
+
+	for (res = widget_idents; res->name; res++)
+		if ((res->mfgr == wid_mfgr) &&
+			(res->part == wid_part))
+			break;
+
+	if (res->name == NULL) {
+		pr_info("xtalk:%d unknown widget 0x%08x\n", widget, wid_id);
+		return -ENODEV;
+	}
 
-	switch (partnum) {
-	case BRIDGE_WIDGET_PART_NUM:
-	case XBRIDGE_WIDGET_PART_NUM:
+	pr_info("Cpu %d, Nasid 0x%x, widget 0x%x (part 0x%x) is ",
+		smp_processor_id(), nasid, widget, wid_part);
+
+	switch (wid_part) {
+	case WIDGET_BRIDG_PART_NUM:
+	case WIDGET_XBRDG_PART_NUM:
 		bridge_probe(nasid, widget, masterwid);
 		break;
 	default:
-		break;
+		if (platform_device_register_simple(res->name, widget, NULL, 0))
+			pr_info("xtalk:%d %s widget (rev %s) registered as "
+				"platform device.\n", widget, res->name,
+				(res->revs[wid_rev] ?
+				 res->revs[wid_rev] : "unknown"));
 	}
 
 	return 0;
@@ -103,8 +120,8 @@ void xtalk_probe_node(cnodeid_t nid)
 {
 	volatile u64		hubreg;
 	nasid_t			nasid;
-	xwidget_part_num_t	partnum;
-	widgetreg_t		widget_id;
+	const struct widget_ident *res;
+	u32 wid_id, wid_part, wid_mfgr, wid_rev;
 
 	nasid = COMPACT_TO_NASID_NODEID(nid);
 	hubreg = REMOTE_HUB_L(nasid, IIO_LLP_CSR);
@@ -113,23 +130,41 @@ void xtalk_probe_node(cnodeid_t nid)
 	if (!(hubreg & IIO_LLP_CSR_IS_UP))
 		return;
 
-	widget_id = *(volatile widgetreg_t *)
+	wid_id = *(volatile widgetreg_t *)
 		       (RAW_NODE_SWIN_BASE(nasid, 0x0) + WIDGET_ID);
-	partnum = XWIDGET_PART_NUM(widget_id);
+	wid_mfgr = XWIDGET_MFG_NUM(wid_id);
+	wid_part = XWIDGET_PART_NUM(wid_id);
+	wid_rev = XWIDGET_REV_NUM(wid_id);
+
+	for (res = widget_idents; res->name; res++)
+		if ((res->mfgr == wid_mfgr) &&
+			(res->part == wid_part))
+			break;
+
+	if (res->name == NULL) {
+		pr_info("xtalk:%d unknown widget 0x%08x\n", 0x0, wid_id);
+		goto out;
+	}
 
-	printk(KERN_INFO "Cpu %d, Nasid 0x%x: partnum 0x%x is ",
-			smp_processor_id(), nasid, partnum);
+	pr_info("Cpu %d, Nasid 0x%x, wid_part 0x%x (part 0x%x) is ",
+		smp_processor_id(), nasid, 0x0, wid_part);
 
-	switch (partnum) {
-	case BRIDGE_WIDGET_PART_NUM:
-		bridge_probe(nasid, 0x8, 0xa);
+	switch (wid_part) {
+	case WIDGET_BRIDG_PART_NUM:
+		bridge_probe(nasid, 0x8, 0xa);  /* XXX: Fix! */
 		break;
-	case XBOW_WIDGET_PART_NUM:
-	case XXBOW_WIDGET_PART_NUM:
+	case WIDGET_XBOW_PART_NUM:
+	case WIDGET_XXBOW_PART_NUM:
 		xbow_probe(nasid);
 		break;
 	default:
-		printk(" unknown widget??\n");
-		break;
+		if (platform_device_register_simple(res->name, 0x0, NULL, 0))
+			pr_info("xtalk:%d %s widget (rev %s) registered as "
+				"as platform device.\n", 0x0, res->name,
+				(res->revs[wid_rev] ?
+				 res->revs[wid_rev] : "unknown"));
 	}
+
+out:
+	return;
 }
#1 lore raw
Quoted 8 lines · Joshua Kinard

From: Joshua Kinard <[email protected]>

This is the second patch of two to clean up/update the Xtalk detection code used by IP27 with some of the code used in the IP30 port.

This specific patch replaces some of the IP27 Xtalk detection code with methods used in the IP30 port, and converts the Xtalk devices into platform devices.

Hm... that all is good cleanup but registration as platform device doesn't help if there's no matching platform driver. I assume you have something like that as part of your yet unpublished patches?

Ralf

#2 lore raw
Quoted 7 lines · Ralf Baechle
Quoted 5 lines · Joshua Kinard

From: Joshua Kinard <[email protected]>

This is the second patch of two to clean up/update the Xtalk detection code used by IP27 with some of the code used in the IP30 port.

Quoted 7 lines
Quoted 3 lines

This specific patch replaces some of the IP27 Xtalk detection code with methods used in the IP30 port, and converts the Xtalk devices into platform devices.

Hm... that all is good cleanup but registration as platform device doesn't help if there's no matching platform driver. I assume you have something like that as part of your yet unpublished patches?

Kinda yeah. It appears the original IP27 Xtalk code was only looking for BRIDGE chips to identify and enumerate additional PCI buses. At the time I made this change, I modified a spare Impact board to fit the Onyx2 and installed it. It can boot the PROM on it and get a console, just the only odd bit is the Onyx2's PROM never expected an Impact board, so it only says "Welcome to", and nothing else at the bottom.

Linux sees the Impact board installed in the slot, but, for some reason, it was not connecting the board to the impact driver and running the impact_probe function, where I was anticipating additional errors to crop up. I gave up at that point and haven't had the time to finish chasing it down. It's that, or someone needs to help me write a driver for the InfiniteReality boards, codename "Kona" :)

But the changes should enable IP27 to probe for XIO devices that don't have a BRIDGE chip in front of them, which right now, is only the Impact (that I know of). I'm keeping an eye on eBay for other archaic XIO boards that may need testing. Just picked up an Onyx2 HD Video board of some kind. I think it's got a BRIDGE chip, though, so it might be PCI-based.

Impact itself needs more work before I can send that in. I've been using Stan's very original driver with some code clean-ups done by "Tanzy" in 2009 for the Octane, and then IP28 has a separate version from Peter Fuerst. Those need to be merged together so a single driver can work for both systems.

Same for Odyssey/VPro on Octane and maybe, IP35, but that's WAY down the road...

--J