basicAlgorithmEncapsulation.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /*
  2. * linux/arch/alpha/kernel/core_wildfire.c
  3. *
  4. * Wildfire support.
  5. *
  6. * Copyright (C) 2000 Andrea Arcangeli <andrea@suse.de> SuSE
  7. */
  8. #define __EXTERN_INLINE inline
  9. #include <asm/io.h>
  10. #include <asm/core_wildfire.h>
  11. #undef __EXTERN_INLINE
  12. #include <linux/types.h>
  13. #include <linux/pci.h>
  14. #include <linux/sched.h>
  15. #include <linux/init.h>
  16. #include <asm/ptrace.h>
  17. #include <asm/smp.h>
  18. #include "proto.h"
  19. #include "pci_impl.h"
  20. #define DEBUG_CONFIG 0
  21. #define DEBUG_DUMP_REGS 0
  22. #define DEBUG_DUMP_CONFIG 1
  23. #if DEBUG_CONFIG
  24. # define DBG_CFG(args) printk args
  25. #else
  26. # define DBG_CFG(args)
  27. #endif
  28. #if DEBUG_DUMP_REGS
  29. static void wildfire_dump_pci_regs(int qbbno, int hoseno);
  30. static void wildfire_dump_pca_regs(int qbbno, int pcano);
  31. static void wildfire_dump_qsa_regs(int qbbno);
  32. static void wildfire_dump_qsd_regs(int qbbno);
  33. static void wildfire_dump_iop_regs(int qbbno);
  34. static void wildfire_dump_gp_regs(int qbbno);
  35. #endif
  36. #if DEBUG_DUMP_CONFIG
  37. static void wildfire_dump_hardware_config(void);
  38. #endif
  39. unsigned char wildfire_hard_qbb_map[WILDFIRE_MAX_QBB];
  40. unsigned char wildfire_soft_qbb_map[WILDFIRE_MAX_QBB];
  41. #define QBB_MAP_EMPTY 0xff
  42. unsigned long wildfire_hard_qbb_mask;
  43. unsigned long wildfire_soft_qbb_mask;
  44. unsigned long wildfire_gp_mask;
  45. unsigned long wildfire_hs_mask;
  46. unsigned long wildfire_iop_mask;
  47. unsigned long wildfire_ior_mask;
  48. unsigned long wildfire_pca_mask;
  49. unsigned long wildfire_cpu_mask;
  50. unsigned long wildfire_mem_mask;
  51. void __init
  52. wildfire_init_hose(int qbbno, int hoseno)
  53. {
  54. struct pci_controller *hose;
  55. wildfire_pci *pci;
  56. hose = alloc_pci_controller();
  57. hose->io_space = alloc_resource();
  58. hose->mem_space = alloc_resource();
  59. /* This is for userland consumption. */
  60. hose->sparse_mem_base = 0;
  61. hose->sparse_io_base = 0;
  62. hose->dense_mem_base = WILDFIRE_MEM(qbbno, hoseno);
  63. hose->dense_io_base = WILDFIRE_IO(qbbno, hoseno);
  64. hose->config_space_base = WILDFIRE_CONF(qbbno, hoseno);
  65. hose->index = (qbbno << 3) + hoseno;
  66. hose->io_space->start = WILDFIRE_IO(qbbno, hoseno) - WILDFIRE_IO_BIAS;
  67. hose->io_space->end = hose->io_space->start + WILDFIRE_IO_SPACE - 1;
  68. hose->io_space->name = pci_io_names[hoseno];
  69. hose->io_space->flags = IORESOURCE_IO;
  70. hose->mem_space->start = WILDFIRE_MEM(qbbno, hoseno)-WILDFIRE_MEM_BIAS;
  71. hose->mem_space->end = hose->mem_space->start + 0xffffffff;
  72. hose->mem_space->name = pci_mem_names[hoseno];
  73. hose->mem_space->flags = IORESOURCE_MEM;
  74. if (request_resource(&ioport_resource, hose->io_space) < 0)
  75. printk(KERN_ERR "Failed to request IO on qbb %d hose %d\n",
  76. qbbno, hoseno);
  77. if (request_resource(&iomem_resource, hose->mem_space) < 0)
  78. printk(KERN_ERR "Failed to request MEM on qbb %d hose %d\n",
  79. qbbno, hoseno);
  80. #if DEBUG_DUMP_REGS
  81. wildfire_dump_pci_regs(qbbno, hoseno);
  82. #endif
  83. /*
  84. * Set up the PCI to main memory translation windows.
  85. *
  86. * Note: Window 3 is scatter-gather only
  87. *
  88. * Window 0 is scatter-gather 8MB at 8MB (for isa)
  89. * Window 1 is direct access 1GB at 1GB
  90. * Window 2 is direct access 1GB at 2GB
  91. * Window 3 is scatter-gather 128MB at 3GB
  92. * ??? We ought to scale window 3 memory.
  93. *
  94. */
  95. hose->sg_isa = iommu_arena_new(hose, 0x00800000, 0x00800000, 0);
  96. hose->sg_pci = iommu_arena_new(hose, 0xc0000000, 0x08000000, 0);
  97. pci = WILDFIRE_pci(qbbno, hoseno);
  98. pci->pci_window[0].wbase.csr = hose->sg_isa->dma_base | 3;
  99. pci->pci_window[0].wmask.csr = (hose->sg_isa->size - 1) & 0xfff00000;
  100. pci->pci_window[0].tbase.csr = virt_to_phys(hose->sg_isa->ptes);
  101. pci->pci_window[1].wbase.csr = 0x40000000 | 1;
  102. pci->pci_window[1].wmask.csr = (0x40000000 -1) & 0xfff00000;
  103. pci->pci_window[1].tbase.csr = 0;
  104. pci->pci_window[2].wbase.csr = 0x80000000 | 1;
  105. pci->pci_window[2].wmask.csr = (0x40000000 -1) & 0xfff00000;
  106. pci->pci_window[2].tbase.csr = 0x40000000;
  107. pci->pci_window[3].wbase.csr = hose->sg_pci->dma_base | 3;
  108. pci->pci_window[3].wmask.csr = (hose->sg_pci->size - 1) & 0xfff00000;
  109. pci->pci_window[3].tbase.csr = virt_to_phys(hose->sg_pci->ptes);
  110. wildfire_pci_tbi(hose, 0, 0); /* Flush TLB at the end. */
  111. }
  112. void __init
  113. wildfire_init_pca(int qbbno, int pcano)
  114. {
  115. /* Test for PCA existence first. */
  116. if (!WILDFIRE_PCA_EXISTS(qbbno, pcano))
  117. return;
  118. #if DEBUG_DUMP_REGS
  119. wildfire_dump_pca_regs(qbbno, pcano);
  120. #endif
  121. /* Do both hoses of the PCA. */
  122. wildfire_init_hose(qbbno, (pcano << 1) + 0);
  123. wildfire_init_hose(qbbno, (pcano << 1) + 1);
  124. }
  125. void __init
  126. wildfire_init_qbb(int qbbno)
  127. {
  128. int pcano;
  129. /* Test for QBB existence first. */
  130. if (!WILDFIRE_QBB_EXISTS(qbbno))
  131. return;
  132. #if DEBUG_DUMP_REGS
  133. wildfire_dump_qsa_regs(qbbno);
  134. wildfire_dump_qsd_regs(qbbno);
  135. wildfire_dump_iop_regs(qbbno);
  136. wildfire_dump_gp_regs(qbbno);
  137. #endif
  138. /* Init all PCAs here. */
  139. for (pcano = 0; pcano < WILDFIRE_PCA_PER_QBB; pcano++) {
  140. wildfire_init_pca(qbbno, pcano);
  141. }
  142. }
  143. void __init
  144. wildfire_hardware_probe(void)
  145. {
  146. unsigned long temp;
  147. unsigned int hard_qbb, soft_qbb;
  148. wildfire_fast_qsd *fast = WILDFIRE_fast_qsd();
  149. wildfire_qsd *qsd;
  150. wildfire_qsa *qsa;
  151. wildfire_iop *iop;
  152. wildfire_gp *gp;
  153. wildfire_ne *ne;
  154. wildfire_fe *fe;
  155. int i;
  156. temp = fast->qsd_whami.csr;
  157. #if 0
  158. printk(KERN_ERR "fast QSD_WHAMI at base %p is 0x%lx\n", fast, temp);
  159. #endif
  160. hard_qbb = (temp >> 8) & 7;