starfire.c 2.8 KB

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