All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joshua Kinard <kumba@gentoo.org>
To: Ralf Baechle <ralf@linux-mips.org>
Cc: Linux MIPS List <linux-mips@linux-mips.org>
Subject: [PATCH v2 2/2]: MIPS: IP27: Xtalk detection cleanups
Date: Mon, 25 May 2015 14:16:04 -0400	[thread overview]
Message-ID: <556366E4.70407@gentoo.org> (raw)

From: Joshua Kinard <kumba@gentoo.org>

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.

Signed-off-by: Joshua Kinard <kumba@gentoo.org>
---
 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
diff --git a/arch/mips/sgi-ip27/ip27-xtalk.c b/arch/mips/sgi-ip27/ip27-xtalk.c
index 20f582a..c262208 100644
--- a/arch/mips/sgi-ip27/ip27-xtalk.c
+++ b/arch/mips/sgi-ip27/ip27-xtalk.c
@@ -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;
 }

             reply	other threads:[~2015-05-25 18:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-25 18:16 Joshua Kinard [this message]
2015-06-05 11:41 ` [PATCH v2 2/2]: MIPS: IP27: Xtalk detection cleanups Ralf Baechle
2015-06-05 23:33   ` Joshua Kinard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=556366E4.70407@gentoo.org \
    --to=kumba@gentoo.org \
    --cc=linux-mips@linux-mips.org \
    --cc=ralf@linux-mips.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.