memoryOperation.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * linux/arch/alpha/kernel/core_mcpcia.c
  3. *
  4. * Based on code written by David A Rusling (david.rusling@reo.mts.dec.com).
  5. *
  6. * Code common to all MCbus-PCI Adaptor core logic chipsets
  7. */
  8. #define __EXTERN_INLINE inline
  9. #include <asm/io.h>
  10. #include <asm/core_mcpcia.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 <linux/delay.h>
  17. #include <asm/ptrace.h>
  18. #include "proto.h"
  19. #include "pci_impl.h"
  20. /*
  21. * NOTE: Herein lie back-to-back mb instructions. They are magic.
  22. * One plausible explanation is that the i/o controller does not properly
  23. * handle the system transaction. Another involves timing. Ho hum.
  24. */
  25. /*
  26. * BIOS32-style PCI interface:
  27. */
  28. #define DEBUG_CFG 0
  29. #if DEBUG_CFG
  30. # define DBG_CFG(args) printk args
  31. #else
  32. # define DBG_CFG(args)
  33. #endif
  34. /*
  35. * Given a bus, device, and function number, compute resulting
  36. * configuration space address and setup the MCPCIA_HAXR2 register
  37. * accordingly. It is therefore not safe to have concurrent
  38. * invocations to configuration space access routines, but there
  39. * really shouldn't be any need for this.
  40. *
  41. * Type 0:
  42. *
  43. * 3 3|3 3 2 2|2 2 2 2|2 2 2 2|1 1 1 1|1 1 1 1|1 1
  44. * 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
  45. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  46. * | | |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|
  47. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  48. *
  49. * 31:11 Device select bit.
  50. * 10:8 Function number
  51. * 7:2 Register number
  52. *
  53. * Type 1:
  54. *
  55. * 3 3|3 3 2 2|2 2 2 2|2 2 2 2|1 1 1 1|1 1 1 1|1 1
  56. * 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
  57. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  58. * | | | | | | | | | | |B|B|B|B|B|B|B|B|D|D|D|D|D|F|F|F|R|R|R|R|R|R|0|1|
  59. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  60. *
  61. * 31:24 reserved
  62. * 23:16 bus number (8 bits = 128 possible buses)
  63. * 15:11 Device number (5 bits)
  64. * 10:8 function number
  65. * 7:2 register number
  66. *
  67. * Notes:
  68. * The function number selects which function of a multi-function device
  69. * (e.g., SCSI and Ethernet).
  70. *
  71. * The register selects a DWORD (32 bit) register offset. Hence it
  72. * doesn't get shifted by 2 bits as we want to "drop" the bottom two
  73. * bits.
  74. */
  75. static unsigned int
  76. conf_read(unsigned long addr, unsigned char type1,
  77. struct pci_controller *hose)
  78. {
  79. unsigned long flags;