memoryCall.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. /*
  2. * linux/arch/alpha/kernel/core_marvel.c
  3. *
  4. * Code common to all Marvel based systems.
  5. */
  6. #define __EXTERN_INLINE inline
  7. #include <asm/io.h>
  8. #include <asm/core_marvel.h>
  9. #undef __EXTERN_INLINE
  10. #include <linux/types.h>
  11. #include <linux/pci.h>
  12. #include <linux/sched.h>
  13. #include <linux/init.h>
  14. #include <linux/vmalloc.h>
  15. #include <linux/mc146818rtc.h>
  16. #include <linux/rtc.h>
  17. #include <linux/module.h>
  18. #include <linux/bootmem.h>
  19. #include <asm/ptrace.h>
  20. #include <asm/smp.h>
  21. #include <asm/gct.h>
  22. #include <asm/pgalloc.h>
  23. #include <asm/tlbflush.h>
  24. #include <asm/rtc.h>
  25. #include <asm/vga.h>
  26. #include "proto.h"
  27. #include "pci_impl.h"
  28. /*
  29. * Debug helpers
  30. */
  31. #define DEBUG_CONFIG 0
  32. #if DEBUG_CONFIG
  33. # define DBG_CFG(args) printk args
  34. #else
  35. # define DBG_CFG(args)
  36. #endif
  37. /*
  38. * Private data
  39. */
  40. static struct io7 *io7_head = NULL;
  41. /*
  42. * Helper functions
  43. */
  44. static unsigned long __attribute__ ((unused))
  45. read_ev7_csr(int pe, unsigned long offset)
  46. {
  47. ev7_csr *ev7csr = EV7_CSR_KERN(pe, offset);
  48. unsigned long q;
  49. mb();
  50. q = ev7csr->csr;
  51. mb();
  52. return q;
  53. }
  54. static void __attribute__ ((unused))
  55. write_ev7_csr(int pe, unsigned long offset, unsigned long q)
  56. {
  57. ev7_csr *ev7csr = EV7_CSR_KERN(pe, offset);
  58. mb();
  59. ev7csr->csr = q;
  60. mb();
  61. }
  62. static char * __init
  63. mk_resource_name(int pe, int port, char *str)
  64. {
  65. char tmp[80];
  66. char *name;
  67. sprintf(tmp, "PCI %s PE %d PORT %d", str, pe, port);
  68. name = alloc_bootmem(strlen(tmp) + 1);
  69. strcpy(name, tmp);
  70. return name;
  71. }
  72. inline struct io7 *
  73. marvel_next_io7(struct io7 *prev)
  74. {
  75. return (prev ? prev->next : io7_head);
  76. }
  77. struct io7 *
  78. marvel_find_io7(int pe)
  79. {
  80. struct io7 *io7;
  81. for (io7 = io7_head; io7 && io7->pe != pe; io7 = io7->next)
  82. continue;
  83. return io7;
  84. }
  85. static struct io7 * __init
  86. alloc_io7(unsigned int pe)
  87. {
  88. struct io7 *io7;
  89. struct io7 *insp;
  90. int h;
  91. if (marvel_find_io7(pe)) {
  92. printk(KERN_WARNING "IO7 at PE %d already allocated!\n", pe);
  93. return NULL;
  94. }
  95. io7 = alloc_bootmem(sizeof(*io7));
  96. io7->pe = pe;
  97. spin_lock_init(&io7->irq_lock);
  98. for (h = 0; h < 4; h++) {
  99. io7->ports[h].io7 = io7;
  100. io7->ports[h].port = h;
  101. io7->ports[h].enabled = 0; /* default to disabled */
  102. }
  103. /*
  104. * Insert in pe sorted order.
  105. */
  106. if (NULL == io7_head) /* empty list */
  107. io7_head = io7;
  108. else if (io7_head->pe > io7->pe) { /* insert at head */
  109. io7->next = io7_head;
  110. io7_head = io7;
  111. } else { /* insert at position */
  112. for (insp = io7_head; insp; insp = insp->next) {
  113. if (insp->pe == io7->pe) {
  114. printk(KERN_ERR "Too many IO7s at PE %d\n",
  115. io7->pe);
  116. return NULL;
  117. }
  118. if (NULL == insp->next ||
  119. insp->next->pe > io7->pe) { /* insert here */
  120. io7->next = insp->next;
  121. insp->next = io7;
  122. break;
  123. }
  124. }
  125. if (NULL == insp) { /* couldn't insert ?!? */
  126. printk(KERN_WARNING "Failed to insert IO7 at PE %d "
  127. " - adding at head of list\n", io7->pe);
  128. io7->next = io7_head;
  129. io7_head = io7;
  130. }
  131. }
  132. return io7;
  133. }
  134. void
  135. io7_clear_errors(struct io7 *io7)
  136. {
  137. io7_port7_csrs *p7csrs;
  138. io7_ioport_csrs *csrs;
  139. int port;
  140. /*
  141. * First the IO ports.
  142. */
  143. for (port = 0; port < 4; port++) {
  144. csrs = IO7_CSRS_KERN(io7->pe, port);
  145. csrs->POx_ERR_SUM.csr = -1UL;
  146. csrs->POx_TLB_ERR.csr = -1UL;
  147. csrs->POx_SPL_COMPLT.csr = -1UL;
  148. csrs->POx_TRANS_SUM.csr = -1UL;
  149. }
  150. /*
  151. * Then the common ones.
  152. */
  153. p7csrs = IO7_PORT7_CSRS_KERN(io7->pe);
  154. p7csrs->PO7_ERROR_SUM.csr = -1UL;
  155. p7csrs->PO7_UNCRR_SYM.csr = -1UL;
  156. p7csrs->PO7_CRRCT_SYM.csr = -1UL;
  157. }
  158. /*
  159. * IO7 PCI, PCI/X, AGP configuration.
  160. */
  161. static void __init
  162. io7_init_hose(struct io7 *io7, int port)
  163. {
  164. static int hose_index = 0;