starfire.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * starfire.c: Starfire/E10000 support.
  3. *
  4. * Copyright (C) 1998 David S. Miller (davem@redhat.com)
  5. * Copyright (C) 2000 Anton Blanchard (anton@samba.org)
  6. */
  7. #include <linux/kernel.h>
  8. #include <linux/slab.h>
  9. #include <asm/page.h>
  10. #include <asm/oplib.h>
  11. #include <asm/smp.h>
  12. #include <asm/upa.h>
  13. #include <asm/starfire.h>
  14. /*
  15. * A few places around the kernel check this to see if
  16. * they need to call us to do things in a Starfire specific
  17. * way.
  18. */
  19. int this_is_starfire = 0;
  20. void check_if_starfire(void)
  21. {
  22. phandle ssnode = prom_finddevice("/ssp-serial");
  23. if (ssnode != 0 && (s32)ssnode != -1)
  24. this_is_starfire = 1;
  25. }
  26. int starfire_hard_smp_processor_id(void)
  27. {
  28. return upa_readl(0x1fff40000d0UL);
  29. }
  30. /*
  31. * Each Starfire board has 32 registers which perform translation
  32. * and delivery of traditional interrupt packets into the extended
  33. * Starfire hardware format. Essentially UPAID's now have 2 more
  34. * bits than in all previous Sun5 systems.
  35. */
  36. struct starfire_irqinfo {
  37. unsigned long imap_slots[32];
  38. unsigned long tregs[32];
  39. struct starfire_irqinfo *next;
  40. int upaid, hwmid;
  41. };
  42. static struct starfire_irqinfo *sflist = NULL;
  43. /* Beam me up Scott(McNeil)y... */
  44. void starfire_hookup(int upaid)
  45. {
  46. struct starfire_irqinfo *p;
  47. unsigned long treg_base, hwmid, i;
  48. p = kmalloc(sizeof(*p), GFP_KERNEL);
  49. if (!p) {
  50. prom_printf("starfire_hookup: No memory, this is insane.\n");
  51. prom_halt();
  52. }
  53. treg_base = 0x100fc000000UL;
  54. hwmid = ((upaid & 0x3c) << 1) |
  55. ((upaid & 0x40) >> 4) |
  56. (upaid & 0x3);
  57. p->hwmid = hwmid;
  58. treg_base += (hwmid << 33UL);
  59. treg_base += 0x200UL;
  60. for (i = 0; i < 32; i++) {
  61. p->imap_slots[i] = 0UL;
  62. p->tregs[i] = treg_base + (i * 0x10UL);
  63. /* Lets play it safe and not overwrite existing mappings */
  64. if (upa_readl(p->tregs[i]) != 0)
  65. p->imap_slots[i] = 0xdeadbeaf;
  66. }
  67. p->upaid = upaid;
  68. p->next = sflist;
  69. sflist = p;
  70. }
  71. unsigned int starfire_translate(unsigned long imap,
  72. unsigned int upaid)
  73. {
  74. struct starfire_irqinfo *p;
  75. unsigned int bus_hwmid;
  76. unsigned int i;
  77. bus_hwmid = (((unsigned long)imap) >> 33) & 0x7f;
  78. for (p = sflist; p != NULL; p = p->next)
  79. if (p->hwmid == bus_hwmid)
  80. break;
  81. if (p == NULL) {
  82. prom_printf("XFIRE: Cannot find irqinfo for imap %016lx\n",
  83. ((unsigned long)imap));
  84. prom_halt();
  85. }
  86. for (i = 0; i < 32; i++) {
  87. if (p->imap_slots[i] == imap ||
  88. p->imap_slots[i] == 0UL)
  89. break;
  90. }
  91. if (i == 32) {
  92. printk("starfire_translate: Are you kidding me?\n");
  93. panic("Lucy in the sky....");
  94. }
  95. p->imap_slots[i] = imap;
  96. /* map to real upaid */
  97. upaid = (((upaid & 0x3c) << 1) |
  98. ((upaid & 0x40) >> 4) |
  99. (upaid & 0x3));
  100. upa_writel(upaid, p->tregs[i]);
  101. return i;
  102. }