diff --git a/arch/mips/include/asm/xtalk/xtalk.h b/arch/mips/include/asm/xtalk/xtalk.h index 26d2ed1..b6d8373 100644 --- a/arch/mips/include/asm/xtalk/xtalk.h +++ b/arch/mips/include/asm/xtalk/xtalk.h @@ -16,19 +16,19 @@ /* * User-level device driver visible types */ -typedef char xwidgetnum_t; /* xtalk widget number (0..15) */ +typedef u8 xwidgetnum_t; /* xtalk widget number (0..15) */ #define XWIDGET_NONE -1 -typedef int xwidget_part_num_t; /* xtalk widget part number */ +typedef s32 xwidget_part_num_t; /* xtalk widget part number */ #define XWIDGET_PART_NUM_NONE -1 -typedef int xwidget_rev_num_t; /* xtalk widget revision number */ +typedef s32 xwidget_rev_num_t; /* xtalk widget revision number */ #define XWIDGET_REV_NUM_NONE -1 -typedef int xwidget_mfg_num_t; /* xtalk widget manufacturing ID */ +typedef s32 xwidget_mfg_num_t; /* xtalk widget manufacturing ID */ #define XWIDGET_MFG_NUM_NONE -1 @@ -48,9 +48,9 @@ typedef struct xtalk_piomap_s *xtalk_piomap_t; #define XIO_PACK(p, o) ((((uint64_t)(p))< #include -#include -#include +#include + +#include #include +#include +#include #include #include +#include - -#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); +unsigned long inline xtalk_get_swin(int node, int wid) +{ + return NODE_SWIN_BASE(node, wid); +} + +extern int bridge_probe(nasid_t nasid, xwidgetnum_t widget, xwidgetnum_t masterwid); -static int probe_one_port(nasid_t nasid, int widget, int masterwid) +static int probe_one_port(nasid_t nasid, xwidgetnum_t widget, xwidgetnum_t 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); - switch (partnum) { - case BRIDGE_WIDGET_PART_NUM: - case XBRIDGE_WIDGET_PART_NUM: + 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; + } + + 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; @@ -50,7 +73,7 @@ static int xbow_probe(nasid_t nasid) { lboard_t *brd; klxbow_t *xbow_p; - unsigned masterwid, i; + xwidgetnum_t masterwid, i; printk("is xbow\n"); @@ -103,8 +126,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 +136,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; }