alarmMemoryDefinition.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /*
  2. * linux/arch/alpha/kernel/core_lca.c
  3. *
  4. * Written by David Mosberger (davidm@cs.arizona.edu) with some code
  5. * taken from Dave Rusling's (david.rusling@reo.mts.dec.com) 32-bit
  6. * bios code.
  7. *
  8. * Code common to all LCA core logic chips.
  9. */
  10. #define __EXTERN_INLINE inline
  11. #include <asm/io.h>
  12. #include <asm/core_lca.h>
  13. #undef __EXTERN_INLINE
  14. #include <linux/types.h>
  15. #include <linux/pci.h>
  16. #include <linux/init.h>
  17. #include <linux/tty.h>
  18. #include <asm/ptrace.h>
  19. #include <asm/irq_regs.h>
  20. #include <asm/smp.h>
  21. #include "proto.h"
  22. #include "pci_impl.h"
  23. /*
  24. * BIOS32-style PCI interface:
  25. */
  26. /*
  27. * Machine check reasons. Defined according to PALcode sources
  28. * (osf.h and platform.h).
  29. */
  30. #define MCHK_K_TPERR 0x0080
  31. #define MCHK_K_TCPERR 0x0082
  32. #define MCHK_K_HERR 0x0084
  33. #define MCHK_K_ECC_C 0x0086
  34. #define MCHK_K_ECC_NC 0x0088
  35. #define MCHK_K_UNKNOWN 0x008A
  36. #define MCHK_K_CACKSOFT 0x008C
  37. #define MCHK_K_BUGCHECK 0x008E
  38. #define MCHK_K_OS_BUGCHECK 0x0090
  39. #define MCHK_K_DCPERR 0x0092
  40. #define MCHK_K_ICPERR 0x0094
  41. /*
  42. * Platform-specific machine-check reasons:
  43. */
  44. #define MCHK_K_SIO_SERR 0x204 /* all platforms so far */
  45. #define MCHK_K_SIO_IOCHK 0x206 /* all platforms so far */
  46. #define MCHK_K_DCSR 0x208 /* all but Noname */
  47. /*
  48. * Given a bus, device, and function number, compute resulting
  49. * configuration space address and setup the LCA_IOC_CONF register
  50. * accordingly. It is therefore not safe to have concurrent
  51. * invocations to configuration space access routines, but there
  52. * really shouldn't be any need for this.
  53. *
  54. * Type 0:
  55. *
  56. * 3 3|3 3 2 2|2 2 2 2|2 2 2 2|1 1 1 1|1 1 1 1|1 1
  57. * 3 2|1 0 9 8|7 6 5 4|3 2 1 0|9 8 7 6|5 4 3 2|1 0 9 8|7 6 5 4|3 2 1 0
  58. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  59. * | | | | | | | | | | | | | | | | | | | | | | | |F|F|F|R|R|R|R|R|R|0|0|
  60. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  61. *
  62. * 31:11 Device select bit.
  63. * 10:8 Function number
  64. * 7:2 Register number
  65. *
  66. * Type 1:
  67. *
  68. * 3 3|3 3 2 2|2 2 2 2|2 2 2 2|1 1 1 1|1 1 1 1|1 1
  69. * 3 2|1 0 9 8|7 6 5 4|3 2 1 0|9 8 7 6|5 4 3 2|1 0 9 8|7 6 5 4|3 2 1 0
  70. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  71. * | | | | | | | | | | |B|B|B|B|B|B|B|B|D|D|D|D|D|F|F|F|R|R|R|R|R|R|0|1|
  72. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  73. *
  74. * 31:24 reserved
  75. * 23:16 bus number (8 bits = 128 possible buses)
  76. * 15:11 Device number (5 bits)
  77. * 10:8 function number
  78. * 7:2 register number
  79. *
  80. * Notes:
  81. * The function number selects which function of a multi-function device
  82. * (e.g., SCSI and Ethernet).
  83. *
  84. * The register selects a DWORD (32 bit) register offset. Hence it
  85. * doesn't get shifted by 2 bits as we want to "drop" the bottom two
  86. * bits.
  87. */
  88. static int
  89. mk_conf_addr(struct pci_bus *pbus, unsigned int device_fn, int where,
  90. unsigned long *pci_addr)
  91. {
  92. unsigned long addr;
  93. u8 bus = pbus->number;
  94. if (bus == 0) {
  95. int device = device_fn >> 3;
  96. int func = device_fn & 0x7;
  97. /* Type 0 configuration cycle. */
  98. if (device > 12) {
  99. return -1;
  100. }
  101. *(vulp)LCA_IOC_CONF = 0;
  102. addr = (1 << (11 + device)) | (func << 8) | where;
  103. } else {
  104. /* Type 1 configuration cycle. */
  105. *(vulp)LCA_IOC_CONF = 1;
  106. addr = (bus << 16) | (device_fn << 8) | where;
  107. }
  108. *pci_addr = addr;
  109. return 0;
  110. }
  111. static unsigned int
  112. conf_read(unsigned long addr)
  113. {
  114. unsigned long flags, code, stat0;
  115. unsigned int value;
  116. local_irq_save(flags);
  117. /* Reset status register to avoid losing errors. */
  118. stat0 = *(vulp)LCA_IOC_STAT0;
  119. *(vulp)LCA_IOC_STAT0 = stat0;
  120. mb();
  121. /* Access configuration space. */
  122. value = *(vuip)addr;
  123. draina();
  124. stat0 = *(vulp)LCA_IOC_STAT0;
  125. if (stat0 & LCA_IOC_STAT0_ERR) {
  126. code = ((stat0 >> LCA_IOC_STAT0_CODE_SHIFT)
  127. & LCA_IOC_STAT0_CODE_MASK);
  128. if (code != 1) {
  129. printk("lca.c:conf_read: got stat0=%lx\n", stat0);
  130. }
  131. /* Reset error status. */
  132. *(vulp)LCA_IOC_STAT0 = stat0;
  133. mb();
  134. /* Reset machine check. */
  135. wrmces(0x7);
  136. value = 0xffffffff;
  137. }
  138. local_irq_restore(flags);
  139. return value;
  140. }
  141. static void
  142. conf_write(unsigned long addr, unsigned int value)
  143. {
  144. unsigned long flags, code, stat0;
  145. local_irq_save(flags); /* avoid getting hit by machine check */
  146. /* Reset status register to avoid losing errors. */
  147. stat0 = *(vulp)LCA_IOC_STAT0;
  148. *(vulp)LCA_IOC_STAT0 = stat0;
  149. mb();
  150. /* Access configuration space. */
  151. *(vuip)addr = value;
  152. draina();
  153. stat0 = *(vulp)LCA_IOC_STAT0;
  154. if (stat0 & LCA_IOC_STAT0_ERR) {
  155. code = ((stat0 >> LCA_IOC_STAT0_CODE_SHIFT)
  156. & LCA_IOC_STAT0_CODE_MASK);
  157. if (code != 1) {
  158. printk("lca.c:conf_write: got stat0=%lx\n", stat0);
  159. }
  160. /* Reset error status. */
  161. *(vulp)LCA_IOC_STAT0 = stat0;
  162. mb();