ip27-xtalk.c 3.1 KB

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