starfire.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. /*
  27. * Each Starfire board has 32 registers which perform translation
  28. * and delivery of traditional interrupt packets into the extended
  29. * Starfire hardware format. Essentially UPAID's now have 2 more
  30. * bits than in all previous Sun5 systems.
  31. */
  32. struct starfire_irqinfo {
  33. unsigned long imap_slots[32];
  34. unsigned long tregs[32];
  35. struct starfire_irqinfo *next;
  36. int upaid, hwmid;
  37. };
  38. static struct starfire_irqinfo *sflist = NULL;
  39. /* Beam me up Scott(McNeil)y... */
  40. void starfire_hookup(int upaid)
  41. {
  42. struct starfire_irqinfo *p;
  43. unsigned long treg_base, hwmid, i;
  44. p = kmalloc(sizeof(*p), GFP_KERNEL);
  45. if (!p) {
  46. prom_printf("starfire_hookup: No memory, this is insane.\n");
  47. prom_halt();
  48. }
  49. treg_base = 0x100fc000000UL;
  50. hwmid = ((upaid & 0x3c) << 1) |
  51. ((upaid & 0x40) >> 4) |
  52. (upaid & 0x3);
  53. p->hwmid = hwmid;
  54. treg_base += (hwmid << 33UL);
  55. treg_base += 0x200UL;
  56. for (i = 0; i < 32; i++) {
  57. p->imap_slots[i] = 0UL;
  58. p->tregs[i] = treg_base + (i * 0x10UL);
  59. /* Lets play it safe and not overwrite existing mappings */
  60. if (upa_readl(p->tregs[i]) != 0)
  61. p->imap_slots[i] = 0xdeadbeaf;
  62. }
  63. p->upaid = upaid;
  64. p->next = sflist;
  65. sflist = p;
  66. }
  67. unsigned int starfire_translate(unsigned long imap,
  68. unsigned int upaid)
  69. {
  70. struct starfire_irqinfo *p;
  71. unsigned int bus_hwmid;
  72. unsigned int i;
  73. bus_hwmid = (((unsigned long)imap) >> 33) & 0x7f;
  74. for (p = sflist; p != NULL; p = p->next)
  75. if (p->hwmid == bus_hwmid)
  76. break;
  77. if (p == NULL) {
  78. prom_printf("XFIRE: Cannot find irqinfo for imap %016lx\n",
  79. ((unsigned long)imap));
  80. prom_halt();
  81. }
  82. for (i = 0; i < 32; i++) {
  83. if (p->imap_slots[i] == imap ||
  84. p->imap_slots[i] == 0UL)
  85. break;
  86. }
  87. if (i == 32) {
  88. printk("starfire_translate: Are you kidding me?\n");
  89. panic("Lucy in the sky....");
  90. }
  91. p->imap_slots[i] = imap;
  92. /* map to real upaid */
  93. upaid = (((upaid & 0x3c) << 1) |
  94. ((upaid & 0x40) >> 4) |
  95. (upaid & 0x3));
  96. upa_writel(upaid, p->tregs[i]);
  97. return i;
  98. }