starfire.c 2.6 KB

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