ip27-xtalk.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  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.
  6. *
  7. * Generic XTALK initialization code
  8. */
  9. #include <linux/kernel.h>
  10. #include <linux/smp.h>
  11. #include <asm/sn/types.h>
  12. #include <asm/sn/klconfig.h>
  13. #include <asm/sn/hub.h>
  14. #include <asm/pci/bridge.h>
  15. #include <asm/xtalk/xtalk.h>
  16. #define XBOW_WIDGET_PART_NUM 0x0
  17. #define XXBOW_WIDGET_PART_NUM 0xd000 /* Xbow in Xbridge */
  18. #define BASE_XBOW_PORT 8 /* Lowest external port */
  19. extern int bridge_probe(nasid_t nasid, int widget, int masterwid);
  20. static int probe_one_port(nasid_t nasid, int widget, int masterwid)
  21. {
  22. widgetreg_t widget_id;
  23. xwidget_part_num_t partnum;
  24. widget_id = *(volatile widgetreg_t *)
  25. (RAW_NODE_SWIN_BASE(nasid, widget) + WIDGET_ID);
  26. partnum = XWIDGET_PART_NUM(widget_id);
  27. printk(KERN_INFO "Cpu %d, Nasid 0x%x, widget 0x%x (partnum 0x%x) is ",
  28. smp_processor_id(), nasid, widget, partnum);
  29. switch (partnum) {
  30. case BRIDGE_WIDGET_PART_NUM:
  31. case XBRIDGE_WIDGET_PART_NUM:
  32. bridge_probe(nasid, widget, masterwid);
  33. break;
  34. default:
  35. break;
  36. }
  37. return 0;
  38. }
  39. static int xbow_probe(nasid_t nasid)
  40. {
  41. lboard_t *brd;
  42. klxbow_t *xbow_p;
  43. unsigned masterwid, i;
  44. printk("is xbow\n");
  45. /*
  46. * found xbow, so may have multiple bridges
  47. * need to probe xbow
  48. */
  49. brd = find_lboard((lboard_t *)KL_CONFIG_INFO(nasid), KLTYPE_MIDPLANE8);
  50. if (!brd)
  51. return -ENODEV;
  52. xbow_p = (klxbow_t *)find_component(brd, NULL, KLSTRUCT_XBOW);
  53. if (!xbow_p)
  54. return -ENODEV;
  55. /*
  56. * Okay, here's a xbow. Lets arbitrate and find
  57. * out if we should initialize it. Set enabled
  58. * hub connected at highest or lowest widget as
  59. * master.
  60. */
  61. #ifdef WIDGET_A
  62. i = HUB_WIDGET_ID_MAX + 1;
  63. do {
  64. i--;
  65. } while ((!XBOW_PORT_TYPE_HUB(xbow_p, i)) ||
  66. (!XBOW_PORT_IS_ENABLED(xbow_p, i)));
  67. #else
  68. i = HUB_WIDGET_ID_MIN - 1;
  69. do {
  70. i++;
  71. } while ((!XBOW_PORT_TYPE_HUB(xbow_p, i)) ||
  72. (!XBOW_PORT_IS_ENABLED(xbow_p, i)));
  73. #endif
  74. masterwid = i;
  75. if (nasid != XBOW_PORT_NASID(xbow_p, i))
  76. return 1;
  77. for (i = HUB_WIDGET_ID_MIN; i <= HUB_WIDGET_ID_MAX; i++) {
  78. if (XBOW_PORT_IS_ENABLED(xbow_p, i) &&
  79. XBOW_PORT_TYPE_IO(xbow_p, i))
  80. probe_one_port(nasid, i, masterwid);
  81. }
  82. return 0;
  83. }
  84. void xtalk_probe_node(cnodeid_t nid)
  85. {
  86. volatile u64 hubreg;
  87. nasid_t nasid;
  88. xwidget_part_num_t partnum;
  89. widgetreg_t widget_id;
  90. nasid = COMPACT_TO_NASID_NODEID(nid);
  91. hubreg = REMOTE_HUB_L(nasid, IIO_LLP_CSR);
  92. /* check whether the link is up */
  93. if (!(hubreg & IIO_LLP_CSR_IS_UP))
  94. return;
  95. widget_id = *(volatile widgetreg_t *)
  96. (RAW_NODE_SWIN_BASE(nasid, 0x0) + WIDGET_ID);
  97. partnum = XWIDGET_PART_NUM(widget_id);
  98. printk(KERN_INFO "Cpu %d, Nasid 0x%x: partnum 0x%x is ",
  99. smp_processor_id(), nasid, partnum);
  100. switch (partnum) {
  101. case BRIDGE_WIDGET_PART_NUM:
  102. bridge_probe(nasid, 0x8, 0xa);
  103. break;
  104. case XBOW_WIDGET_PART_NUM:
  105. case XXBOW_WIDGET_PART_NUM:
  106. xbow_probe(nasid);
  107. break;
  108. default:
  109. printk(" unknown widget??\n");
  110. break;
  111. }
  112. }