memoryCall.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. #ifndef _IOP13XX_HW_H_
  2. #define _IOP13XX_HW_H_
  3. #ifndef __ASSEMBLY__
  4. /* The ATU offsets can change based on the strapping */
  5. extern u32 iop13xx_atux_pmmr_offset;
  6. extern u32 iop13xx_atue_pmmr_offset;
  7. void iop13xx_init_early(void);
  8. void iop13xx_init_irq(void);
  9. void iop13xx_map_io(void);
  10. void iop13xx_platform_init(void);
  11. void iop13xx_add_tpmi_devices(void);
  12. void iop13xx_init_irq(void);
  13. void iop13xx_restart(char, const char *);
  14. /* CPUID CP6 R0 Page 0 */
  15. static inline int iop13xx_cpu_id(void)
  16. {
  17. int id;
  18. asm volatile("mrc p6, 0, %0, c0, c0, 0":"=r" (id));
  19. return id;
  20. }
  21. /* WDTCR CP6 R7 Page 9 */
  22. static inline u32 read_wdtcr(void)
  23. {
  24. u32 val;
  25. asm volatile("mrc p6, 0, %0, c7, c9, 0":"=r" (val));
  26. return val;
  27. }
  28. static inline void write_wdtcr(u32 val)
  29. {
  30. asm volatile("mcr p6, 0, %0, c7, c9, 0"::"r" (val));
  31. }
  32. /* WDTSR CP6 R8 Page 9 */
  33. static inline u32 read_wdtsr(void)
  34. {
  35. u32 val;
  36. asm volatile("mrc p6, 0, %0, c8, c9, 0":"=r" (val));
  37. return val;
  38. }
  39. static inline void write_wdtsr(u32 val)
  40. {
  41. asm volatile("mcr p6, 0, %0, c8, c9, 0"::"r" (val));
  42. }
  43. /* RCSR - Reset Cause Status Register */
  44. static inline u32 read_rcsr(void)
  45. {
  46. u32 val;
  47. asm volatile("mrc p6, 0, %0, c0, c1, 0":"=r" (val));
  48. return val;
  49. }
  50. extern unsigned long get_iop_tick_rate(void);
  51. #endif
  52. /*
  53. * IOP13XX I/O and Mem space regions for PCI autoconfiguration
  54. */
  55. #define IOP13XX_MAX_RAM_SIZE 0x80000000UL /* 2GB */
  56. #define IOP13XX_PCI_OFFSET IOP13XX_MAX_RAM_SIZE
  57. /* PCI MAP
  58. * bus range cpu phys cpu virt note
  59. * 0x0000.0000 + 2GB (n/a) (n/a) inbound, 1:1 mapping with Physical RAM
  60. * 0x8000.0000 + 928M 0x1.8000.0000 (ioremap) PCIX outbound memory window
  61. * 0x8000.0000 + 928M 0x2.8000.0000 (ioremap) PCIE outbound memory window
  62. *
  63. * IO MAP
  64. * 0x00000 + 64K 0x0.fffb.0000 0xfee0.0000 PCIX outbound i/o window
  65. * 0x10000 + 64K 0x0.fffd.0000 0xfee1.0000 PCIE outbound i/o window
  66. */
  67. #define IOP13XX_PCIX_LOWER_IO_PA 0xfffb0000UL
  68. #define IOP13XX_PCIX_LOWER_IO_BA 0x0UL /* OIOTVR */
  69. #define IOP13XX_PCIX_MEM_PHYS_OFFSET 0x100000000ULL
  70. #define IOP13XX_PCIX_MEM_WINDOW_SIZE 0x3a000000UL
  71. #define IOP13XX_PCIX_LOWER_MEM_BA (PHYS_OFFSET + IOP13XX_PCI_OFFSET)
  72. #define IOP13XX_PCIX_LOWER_MEM_PA (IOP13XX_PCIX_MEM_PHYS_OFFSET +\
  73. IOP13XX_PCIX_LOWER_MEM_BA)
  74. #define IOP13XX_PCIX_UPPER_MEM_PA (IOP13XX_PCIX_LOWER_MEM_PA +\
  75. IOP13XX_PCIX_MEM_WINDOW_SIZE - 1)
  76. #define IOP13XX_PCIX_UPPER_MEM_BA (IOP13XX_PCIX_LOWER_MEM_BA +\
  77. IOP13XX_PCIX_MEM_WINDOW_SIZE - 1)
  78. #define IOP13XX_PCIX_MEM_COOKIE 0x80000000UL
  79. #define IOP13XX_PCIX_LOWER_MEM_RA IOP13XX_PCIX_MEM_COOKIE
  80. #define IOP13XX_PCIX_UPPER_MEM_RA (IOP13XX_PCIX_LOWER_MEM_RA +\
  81. IOP13XX_PCIX_MEM_WINDOW_SIZE - 1)
  82. #define IOP13XX_PCIX_MEM_OFFSET (IOP13XX_PCIX_MEM_COOKIE -\
  83. IOP13XX_PCIX_LOWER_MEM_BA)
  84. /* PCI-E ranges */
  85. #define IOP13XX_PCIE_LOWER_IO_PA 0xfffd0000UL
  86. #define IOP13XX_PCIE_LOWER_IO_BA 0x10000UL /* OIOTVR */
  87. #define IOP13XX_PCIE_MEM_PHYS_OFFSET 0x200000000ULL
  88. #define IOP13XX_PCIE_MEM_WINDOW_SIZE 0x3a000000UL
  89. #define IOP13XX_PCIE_LOWER_MEM_BA (PHYS_OFFSET + IOP13XX_PCI_OFFSET)
  90. #define IOP13XX_PCIE_LOWER_MEM_PA (IOP13XX_PCIE_MEM_PHYS_OFFSET +\
  91. IOP13XX_PCIE_LOWER_MEM_BA)
  92. #define IOP13XX_PCIE_UPPER_MEM_PA (IOP13XX_PCIE_LOWER_MEM_PA +\
  93. IOP13XX_PCIE_MEM_WINDOW_SIZE - 1)
  94. #define IOP13XX_PCIE_UPPER_MEM_BA (IOP13XX_PCIE_LOWER_MEM_BA +\
  95. IOP13XX_PCIE_MEM_WINDOW_SIZE - 1)
  96. /* All 0xc000.0000 - 0xfdff.ffff addresses belong to PCIe */
  97. #define IOP13XX_PCIE_MEM_COOKIE 0xc0000000UL
  98. #define IOP13XX_PCIE_LOWER_MEM_RA IOP13XX_PCIE_MEM_COOKIE
  99. #define IOP13XX_PCIE_UPPER_MEM_RA (IOP13XX_PCIE_LOWER_MEM_RA +\
  100. IOP13XX_PCIE_MEM_WINDOW_SIZE - 1)
  101. #define IOP13XX_PCIE_MEM_OFFSET (IOP13XX_PCIE_MEM_COOKIE -\
  102. IOP13XX_PCIE_LOWER_MEM_BA)
  103. /* PBI Ranges */
  104. #define IOP13XX_PBI_LOWER_MEM_PA 0xf0000000UL
  105. #define IOP13XX_PBI_MEM_WINDOW_SIZE 0x04000000UL
  106. #define IOP13XX_PBI_MEM_COOKIE 0xfa000000UL
  107. #define IOP13XX_PBI_LOWER_MEM_RA IOP13XX_PBI_MEM_COOKIE
  108. #define IOP13XX_PBI_UPPER_MEM_RA (IOP13XX_PBI_LOWER_MEM_RA +\
  109. IOP13XX_PBI_MEM_WINDOW_SIZE - 1)
  110. /*
  111. * IOP13XX chipset registers
  112. */
  113. #define IOP13XX_PMMR_PHYS_MEM_BASE 0xffd80000UL /* PMMR phys. address */
  114. #define IOP13XX_PMMR_VIRT_MEM_BASE (void __iomem *)(0xfee80000UL) /* PMMR phys. address */
  115. #define IOP13XX_PMMR_MEM_WINDOW_SIZE 0x80000
  116. #define IOP13XX_PMMR_UPPER_MEM_VA (IOP13XX_PMMR_VIRT_MEM_BASE +\
  117. IOP13XX_PMMR_MEM_WINDOW_SIZE - 1)
  118. #define IOP13XX_PMMR_UPPER_MEM_PA (IOP13XX_PMMR_PHYS_MEM_BASE +\
  119. IOP13XX_PMMR_MEM_WINDOW_SIZE - 1)
  120. #define IOP13XX_PMMR_VIRT_TO_PHYS(addr) (((addr) - IOP13XX_PMMR_VIRT_MEM_BASE)\
  121. + IOP13XX_PMMR_PHYS_MEM_BASE)
  122. #define IOP13XX_PMMR_PHYS_TO_VIRT(addr) (((addr) - IOP13XX_PMMR_PHYS_MEM_BASE)\
  123. + IOP13XX_PMMR_VIRT_MEM_BASE)
  124. #define IOP13XX_REG_ADDR32(reg) (IOP13XX_PMMR_VIRT_MEM_BASE + (reg))
  125. #define IOP13XX_REG_ADDR16(reg) (IOP13XX_PMMR_VIRT_MEM_BASE + (reg))
  126. #define IOP13XX_REG_ADDR8(reg) (IOP13XX_PMMR_VIRT_MEM_BASE + (reg))
  127. #define IOP13XX_REG_ADDR32_PHYS(reg) (IOP13XX_PMMR_PHYS_MEM_BASE + (reg))
  128. #define IOP13XX_REG_ADDR16_PHYS(reg) (IOP13XX_PMMR_PHYS_MEM_BASE + (reg))
  129. #define IOP13XX_REG_ADDR8_PHYS(reg) (IOP13XX_PMMR_PHYS_MEM_BASE + (reg))
  130. #define IOP13XX_PMMR_SIZE 0x00080000
  131. /*=================== Defines for Platform Devices =====================*/
  132. #define IOP13XX_UART0_PHYS (IOP13XX_PMMR_PHYS_MEM_BASE + 0x00002300)
  133. #define IOP13XX_UART1_PHYS (IOP13XX_PMMR_PHYS_MEM_BASE + 0x00002340)
  134. #define IOP13XX_UART0_VIRT (IOP13XX_PMMR_VIRT_MEM_BASE + 0x00002300)
  135. #define IOP13XX_UART1_VIRT (IOP13XX_PMMR_VIRT_MEM_BASE + 0x00002340)
  136. #define IOP13XX_I2C0_PHYS (IOP13XX_PMMR_PHYS_MEM_BASE | 0x00002500)
  137. #define IOP13XX_I2C1_PHYS (IOP13XX_PMMR_PHYS_MEM_BASE | 0x00002520)
  138. #define IOP13XX_I2C2_PHYS (IOP13XX_PMMR_PHYS_MEM_BASE | 0x00002540)
  139. #define IOP13XX_I2C0_VIRT (IOP13XX_PMMR_VIRT_MEM_BASE | 0x00002500)
  140. #define IOP13XX_I2C1_VIRT (IOP13XX_PMMR_VIRT_MEM_BASE | 0x00002520)
  141. #define IOP13XX_I2C2_VIRT (IOP13XX_PMMR_VIRT_MEM_BASE | 0x00002540)
  142. /* ATU selection flags */
  143. /* IOP13XX_INIT_ATU_DEFAULT = Rely on CONFIG_IOP13XX_ATU* */
  144. #define IOP13XX_INIT_ATU_DEFAULT (0)
  145. #define IOP13XX_INIT_ATU_ATUX (1 << 0)
  146. #define IOP13XX_INIT_ATU_ATUE (1 << 1)
  147. #define IOP13XX_INIT_ATU_NONE (1 << 2)
  148. /* UART selection flags */
  149. /* IOP13XX_INIT_UART_DEFAULT = Rely on CONFIG_IOP13XX_UART* */
  150. #define IOP13XX_INIT_UART_DEFAULT (0)
  151. #define IOP13XX_INIT_UART_0 (1 << 0)
  152. #define IOP13XX_INIT_UART_1 (1 << 1)
  153. /* I2C selection flags */
  154. /* IOP13XX_INIT_I2C_DEFAULT = Rely on CONFIG_IOP13XX_I2C* */
  155. #define IOP13XX_INIT_I2C_DEFAULT (0)
  156. #define IOP13XX_INIT_I2C_0 (1 << 0)
  157. #define IOP13XX_INIT_I2C_1 (1 << 1)
  158. #define IOP13XX_INIT_I2C_2 (1 << 2)
  159. /* ADMA selection flags */
  160. /* INIT_ADMA_DEFAULT = Rely on CONFIG_IOP13XX_ADMA* */
  161. #define IOP13XX_INIT_ADMA_DEFAULT (0)
  162. #define IOP13XX_INIT_ADMA_0 (1 << 0)
  163. #define IOP13XX_INIT_ADMA_1 (1 << 1)
  164. #define IOP13XX_INIT_ADMA_2 (1 << 2)
  165. /* Platform devices */
  166. #define IQ81340_NUM_UART 2
  167. #define IQ81340_NUM_I2C 3
  168. #define IQ81340_NUM_PHYS_MAP_FLASH 1
  169. #define IQ81340_NUM_ADMA 3
  170. #define IQ81340_MAX_PLAT_DEVICES (IQ81340_NUM_UART + \
  171. IQ81340_NUM_I2C + \
  172. IQ81340_NUM_PHYS_MAP_FLASH + \
  173. IQ81340_NUM_ADMA)