temperatureMemoryDefinition.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * linux/arch/alpha/kernel/core_cia.c
  3. *
  4. * Written by David A Rusling (david.rusling@reo.mts.dec.com).
  5. * December 1995.
  6. *
  7. * Copyright (C) 1995 David A Rusling
  8. * Copyright (C) 1997, 1998 Jay Estabrook
  9. * Copyright (C) 1998, 1999, 2000 Richard Henderson
  10. *
  11. * Code common to all CIA core logic chips.
  12. */
  13. #define __EXTERN_INLINE inline
  14. #include <asm/io.h>
  15. #include <asm/core_cia.h>
  16. #undef __EXTERN_INLINE
  17. #include <linux/types.h>
  18. #include <linux/pci.h>
  19. #include <linux/sched.h>
  20. #include <linux/init.h>
  21. #include <linux/bootmem.h>
  22. #include <asm/ptrace.h>
  23. #include <asm/mce.h>
  24. #include "proto.h"
  25. #include "pci_impl.h"
  26. /*
  27. * NOTE: Herein lie back-to-back mb instructions. They are magic.
  28. * One plausible explanation is that the i/o controller does not properly
  29. * handle the system transaction. Another involves timing. Ho hum.
  30. */
  31. #define DEBUG_CONFIG 0
  32. #if DEBUG_CONFIG
  33. # define DBGC(args) printk args
  34. #else
  35. # define DBGC(args)
  36. #endif
  37. #define vip volatile int *
  38. /*
  39. * Given a bus, device, and function number, compute resulting
  40. * configuration space address. It is therefore not safe to have
  41. * concurrent invocations to configuration space access routines, but
  42. * there really shouldn't be any need for this.
  43. *
  44. * Type 0:
  45. *
  46. * 3 3|3 3 2 2|2 2 2 2|2 2 2 2|1 1 1 1|1 1 1 1|1 1
  47. * 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
  48. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  49. * | | |D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|F|F|F|R|R|R|R|R|R|0|0|
  50. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  51. *
  52. * 31:11 Device select bit.
  53. * 10:8 Function number
  54. * 7:2 Register number
  55. *
  56. * Type 1:
  57. *
  58. * 3 3|3 3 2 2|2 2 2 2|2 2 2 2|1 1 1 1|1 1 1 1|1 1
  59. * 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
  60. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  61. * | | | | | | | | | | |B|B|B|B|B|B|B|B|D|D|D|D|D|F|F|F|R|R|R|R|R|R|0|1|
  62. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  63. *
  64. * 31:24 reserved
  65. * 23:16 bus number (8 bits = 128 possible buses)
  66. * 15:11 Device number (5 bits)
  67. * 10:8 function number
  68. * 7:2 register number
  69. *
  70. * Notes:
  71. * The function number selects which function of a multi-function device
  72. * (e.g., SCSI and Ethernet).
  73. *
  74. * The register selects a DWORD (32 bit) register offset. Hence it
  75. * doesn't get shifted by 2 bits as we want to "drop" the bottom two
  76. * bits.
  77. */
  78. static int
  79. mk_conf_addr(struct pci_bus *bus_dev, unsigned int device_fn, int where,
  80. unsigned long *pci_addr, unsigned char *type1)
  81. {
  82. u8 bus = bus_dev->number;
  83. *type1 = (bus != 0);
  84. *pci_addr = (bus << 16) | (device_fn << 8) | where;
  85. DBGC(("mk_conf_addr(bus=%d ,device_fn=0x%x, where=0x%x,"
  86. " returning address 0x%p\n"
  87. bus, device_fn, where, *pci_addr));
  88. return 0;
  89. }
  90. static unsigned int
  91. conf_read(unsigned long addr, unsigned char type1)
  92. {
  93. unsigned long flags;
  94. int stat0, value;
  95. int cia_cfg = 0;
  96. DBGC(("conf_read(addr=0x%lx, type1=%d) ", addr, type1));
  97. local_irq_save(flags);
  98. /* Reset status register to avoid losing errors. */
  99. stat0 = *(vip)CIA_IOC_CIA_ERR;
  100. *(vip)CIA_IOC_CIA_ERR = stat0;
  101. mb();
  102. *(vip)CIA_IOC_CIA_ERR; /* re-read to force write */
  103. /* If Type1 access, must set CIA CFG. */
  104. if (type1) {
  105. cia_cfg = *(vip)CIA_IOC_CFG;
  106. *(vip)CIA_IOC_CFG = (cia_cfg & ~3) | 1;
  107. mb();
  108. *(vip)CIA_IOC_CFG;
  109. }
  110. mb();
  111. draina();
  112. mcheck_expected(0) = 1;
  113. mcheck_taken(0) = 0;
  114. mb();