synchronousMemoryDatabase.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. * arch/arm/mach-ixp4xx/include/mach/io.h
  3. *
  4. * Author: Deepak Saxena <dsaxena@plexity.net>
  5. *
  6. * Copyright (C) 2002-2005 MontaVista Software, Inc.
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #ifndef __ASM_ARM_ARCH_IO_H
  13. #define __ASM_ARM_ARCH_IO_H
  14. #include <linux/bitops.h>
  15. #include <mach/hardware.h>
  16. extern int (*ixp4xx_pci_read)(u32 addr, u32 cmd, u32* data);
  17. extern int ixp4xx_pci_write(u32 addr, u32 cmd, u32 data);
  18. /*
  19. * IXP4xx provides two methods of accessing PCI memory space:
  20. *
  21. * 1) A direct mapped window from 0x48000000 to 0x4BFFFFFF (64MB).
  22. * To access PCI via this space, we simply ioremap() the BAR
  23. * into the kernel and we can use the standard read[bwl]/write[bwl]
  24. * macros. This is the preffered method due to speed but it
  25. * limits the system to just 64MB of PCI memory. This can be
  26. * problematic if using video cards and other memory-heavy targets.
  27. *
  28. * 2) If > 64MB of memory space is required, the IXP4xx can use indirect
  29. * registers to access the whole 4 GB of PCI memory space (as we do below
  30. * for I/O transactions). This allows currently for up to 1 GB (0x10000000
  31. * to 0x4FFFFFFF) of memory on the bus. The disadvantage of this is that
  32. * every PCI access requires three local register accesses plus a spinlock,
  33. * but in some cases the performance hit is acceptable. In addition, you
  34. * cannot mmap() PCI devices in this case.
  35. */
  36. #ifdef CONFIG_IXP4XX_INDIRECT_PCI
  37. /*
  38. * In the case of using indirect PCI, we simply return the actual PCI
  39. * address and our read/write implementation use that to drive the
  40. * access registers. If something outside of PCI is ioremap'd, we
  41. * fallback to the default.
  42. */
  43. static inline int is_pci_memory(u32 addr)
  44. {
  45. return (addr >= PCIBIOS_MIN_MEM) && (addr <= 0x4FFFFFFF);
  46. }
  47. #define writeb(v, p) __indirect_writeb(v, p)
  48. #define writew(v, p) __indirect_writew(v, p)
  49. #define writel(v, p) __indirect_writel(v, p)
  50. #define writesb(p, v, l) __indirect_writesb(p, v, l)
  51. #define writesw(p, v, l) __indirect_writesw(p, v, l)
  52. #define writesl(p, v, l) __indirect_writesl(p, v, l)
  53. #define readb(p) __indirect_readb(p)
  54. #define readw(p) __indirect_readw(p)
  55. #define readl(p) __indirect_readl(p)
  56. #define readsb(p, v, l) __indirect_readsb(p, v, l)
  57. #define readsw(p, v, l) __indirect_readsw(p, v, l)
  58. #define readsl(p, v, l) __indirect_readsl(p, v, l)
  59. static inline void __indirect_writeb(u8 value, volatile void __iomem *p)
  60. {
  61. u32 addr = (u32)p;
  62. u32 n, byte_enables, data;
  63. if (!is_pci_memory(addr)) {
  64. __raw_writeb(value, addr);
  65. return;
  66. }
  67. n = addr % 4;
  68. byte_enables = (0xf & ~BIT(n)) << IXP4XX_PCI_NP_CBE_BESL;
  69. data = value << (8*n);
  70. ixp4xx_pci_write(addr, byte_enables | NP_CMD_MEMWRITE, data);
  71. }
  72. static inline void __indirect_writesb(volatile void __iomem *bus_addr,
  73. const u8 *vaddr, int count)
  74. {
  75. while (count--)
  76. writeb(*vaddr++, bus_addr);
  77. }
  78. static inline void __indirect_writew(u16 value, volatile void __iomem *p)
  79. {
  80. u32 addr = (u32)p;
  81. u32 n, byte_enables, data;
  82. if (!is_pci_memory(addr)) {
  83. __raw_writew(value, addr);
  84. return;
  85. }
  86. n = addr % 4;
  87. byte_enables = (0xf & ~(BIT(n) | BIT(n+1))) << IXP4XX_PCI_NP_CBE_BESL;
  88. data = value << (8*n);
  89. ixp4xx_pci_write(addr, byte_enables | NP_CMD_MEMWRITE, data);
  90. }
  91. static inline void __indirect_writesw(volatile void __iomem *bus_addr,
  92. const u16 *vaddr, int count)
  93. {
  94. while (count--)
  95. writew(*vaddr++, bus_addr);
  96. }
  97. static inline void __indirect_writel(u32 value, volatile void __iomem *p)
  98. {
  99. u32 addr = (__force u32)p;
  100. if (!is_pci_memory(addr)) {
  101. __raw_writel(value, p);
  102. return;
  103. }
  104. ixp4xx_pci_write(addr, NP_CMD_MEMWRITE, value);
  105. }
  106. static inline void __indirect_writesl(volatile void __iomem *bus_addr,
  107. const u32 *vaddr, int count)
  108. {
  109. while (count--)
  110. writel(*vaddr++, bus_addr);
  111. }
  112. static inline unsigned char __indirect_readb(const volatile void __iomem *p)
  113. {