hardware.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. /*
  2. * Keystone2: Common SoC definitions, structures etc.
  3. *
  4. * (C) Copyright 2012-2014
  5. * Texas Instruments Incorporated, <www.ti.com>
  6. *
  7. * SPDX-License-Identifier: GPL-2.0+
  8. */
  9. #ifndef __ASM_ARCH_HARDWARE_H
  10. #define __ASM_ARCH_HARDWARE_H
  11. #include <config.h>
  12. #ifndef __ASSEMBLY__
  13. #include <linux/sizes.h>
  14. #include <asm/io.h>
  15. #define REG(addr) (*(volatile unsigned int *)(addr))
  16. #define REG_P(addr) ((volatile unsigned int *)(addr))
  17. typedef volatile unsigned int dv_reg;
  18. typedef volatile unsigned int *dv_reg_p;
  19. #endif
  20. #define BIT(x) (1 << (x))
  21. #define KS2_DDRPHY_PIR_OFFSET 0x04
  22. #define KS2_DDRPHY_PGCR0_OFFSET 0x08
  23. #define KS2_DDRPHY_PGCR1_OFFSET 0x0C
  24. #define KS2_DDRPHY_PGSR0_OFFSET 0x10
  25. #define KS2_DDRPHY_PGSR1_OFFSET 0x14
  26. #define KS2_DDRPHY_PLLCR_OFFSET 0x18
  27. #define KS2_DDRPHY_PTR0_OFFSET 0x1C
  28. #define KS2_DDRPHY_PTR1_OFFSET 0x20
  29. #define KS2_DDRPHY_PTR2_OFFSET 0x24
  30. #define KS2_DDRPHY_PTR3_OFFSET 0x28
  31. #define KS2_DDRPHY_PTR4_OFFSET 0x2C
  32. #define KS2_DDRPHY_DCR_OFFSET 0x44
  33. #define KS2_DDRPHY_DTPR0_OFFSET 0x48
  34. #define KS2_DDRPHY_DTPR1_OFFSET 0x4C
  35. #define KS2_DDRPHY_DTPR2_OFFSET 0x50
  36. #define KS2_DDRPHY_MR0_OFFSET 0x54
  37. #define KS2_DDRPHY_MR1_OFFSET 0x58
  38. #define KS2_DDRPHY_MR2_OFFSET 0x5C
  39. #define KS2_DDRPHY_DTCR_OFFSET 0x68
  40. #define KS2_DDRPHY_PGCR2_OFFSET 0x8C
  41. #define KS2_DDRPHY_ZQ0CR1_OFFSET 0x184
  42. #define KS2_DDRPHY_ZQ1CR1_OFFSET 0x194
  43. #define KS2_DDRPHY_ZQ2CR1_OFFSET 0x1A4
  44. #define KS2_DDRPHY_ZQ3CR1_OFFSET 0x1B4
  45. #define KS2_DDRPHY_DATX8_8_OFFSET 0x3C0
  46. #define IODDRM_MASK 0x00000180
  47. #define ZCKSEL_MASK 0x01800000
  48. #define CL_MASK 0x00000072
  49. #define WR_MASK 0x00000E00
  50. #define BL_MASK 0x00000003
  51. #define RRMODE_MASK 0x00040000
  52. #define UDIMM_MASK 0x20000000
  53. #define BYTEMASK_MASK 0x0003FC00
  54. #define MPRDQ_MASK 0x00000080
  55. #define PDQ_MASK 0x00000070
  56. #define NOSRA_MASK 0x08000000
  57. #define ECC_MASK 0x00000001
  58. /* DDR3 definitions */
  59. #define KS2_DDR3A_EMIF_CTRL_BASE 0x21010000
  60. #define KS2_DDR3A_EMIF_DATA_BASE 0x80000000
  61. #define KS2_DDR3A_DDRPHYC 0x02329000
  62. #define KS2_DDR3_MIDR_OFFSET 0x00
  63. #define KS2_DDR3_STATUS_OFFSET 0x04
  64. #define KS2_DDR3_SDCFG_OFFSET 0x08
  65. #define KS2_DDR3_SDRFC_OFFSET 0x10
  66. #define KS2_DDR3_SDTIM1_OFFSET 0x18
  67. #define KS2_DDR3_SDTIM2_OFFSET 0x1C
  68. #define KS2_DDR3_SDTIM3_OFFSET 0x20
  69. #define KS2_DDR3_SDTIM4_OFFSET 0x28
  70. #define KS2_DDR3_PMCTL_OFFSET 0x38
  71. #define KS2_DDR3_ZQCFG_OFFSET 0xC8
  72. #define KS2_DDR3_PLLCTRL_PHY_RESET 0x80000000
  73. #define KS2_UART0_BASE 0x02530c00
  74. #define KS2_UART1_BASE 0x02531000
  75. /* Boot Config */
  76. #define KS2_DEVICE_STATE_CTRL_BASE 0x02620000
  77. #define KS2_JTAG_ID_REG (KS2_DEVICE_STATE_CTRL_BASE + 0x18)
  78. #define KS2_DEVSTAT (KS2_DEVICE_STATE_CTRL_BASE + 0x20)
  79. /* PSC */
  80. #define KS2_PSC_BASE 0x02350000
  81. #define KS2_LPSC_GEM_0 15
  82. #define KS2_LPSC_TETRIS 52
  83. #define KS2_TETRIS_PWR_DOMAIN 31
  84. /* Chip configuration unlock codes and registers */
  85. #define KS2_KICK0 (KS2_DEVICE_STATE_CTRL_BASE + 0x38)
  86. #define KS2_KICK1 (KS2_DEVICE_STATE_CTRL_BASE + 0x3c)
  87. #define KS2_KICK0_MAGIC 0x83e70b13
  88. #define KS2_KICK1_MAGIC 0x95a4f1e0
  89. /* PLL control registers */
  90. #define KS2_MAINPLLCTL0 (KS2_DEVICE_STATE_CTRL_BASE + 0x350)
  91. #define KS2_MAINPLLCTL1 (KS2_DEVICE_STATE_CTRL_BASE + 0x354)
  92. #define KS2_PASSPLLCTL0 (KS2_DEVICE_STATE_CTRL_BASE + 0x358)
  93. #define KS2_PASSPLLCTL1 (KS2_DEVICE_STATE_CTRL_BASE + 0x35C)
  94. #define KS2_DDR3APLLCTL0 (KS2_DEVICE_STATE_CTRL_BASE + 0x360)
  95. #define KS2_DDR3APLLCTL1 (KS2_DEVICE_STATE_CTRL_BASE + 0x364)
  96. #define KS2_ARMPLLCTL0 (KS2_DEVICE_STATE_CTRL_BASE + 0x370)
  97. #define KS2_ARMPLLCTL1 (KS2_DEVICE_STATE_CTRL_BASE + 0x374)
  98. #define KS2_PLL_CNTRL_BASE 0x02310000
  99. #define KS2_CLOCK_BASE KS2_PLL_CNTRL_BASE
  100. #define KS2_RSTCTRL_RSTYPE (KS2_PLL_CNTRL_BASE + 0xe4)
  101. #define KS2_RSTCTRL (KS2_PLL_CNTRL_BASE + 0xe8)
  102. #define KS2_RSTCTRL_RSCFG (KS2_PLL_CNTRL_BASE + 0xec)
  103. #define KS2_RSTCTRL_KEY 0x5a69
  104. #define KS2_RSTCTRL_MASK 0xffff0000
  105. #define KS2_RSTCTRL_SWRST 0xfffe0000
  106. #define KS2_RSTYPE_PLL_SOFT BIT(13)
  107. /* SPI */
  108. #define KS2_SPI0_BASE 0x21000400
  109. #define KS2_SPI1_BASE 0x21000600
  110. #define KS2_SPI2_BASE 0x21000800
  111. #define KS2_SPI_BASE KS2_SPI0_BASE
  112. /* AEMIF */
  113. #define KS2_AEMIF_CNTRL_BASE 0x21000a00
  114. #define DAVINCI_ASYNC_EMIF_CNTRL_BASE KS2_AEMIF_CNTRL_BASE
  115. /* Flag from ks2_debug options to check if DSPs need to stay ON */
  116. #define DBG_LEAVE_DSPS_ON 0x1
  117. /* Device speed */
  118. #define KS2_REV1_DEVSPEED (KS2_DEVICE_STATE_CTRL_BASE + 0xc98)
  119. #define KS2_EFUSE_BOOTROM (KS2_DEVICE_STATE_CTRL_BASE + 0xc90)
  120. /* Queue manager */
  121. #define KS2_QM_BASE_ADDRESS 0x23a80000
  122. #define KS2_QM_CONF_BASE 0x02a02000
  123. #define KS2_QM_DESC_SETUP_BASE 0x02a03000
  124. #define KS2_QM_STATUS_RAM_BASE 0x02a06000
  125. #define KS2_QM_INTD_CONF_BASE 0x02a0c000
  126. #define KS2_QM_PDSP1_CMD_BASE 0x02a20000
  127. #define KS2_QM_PDSP1_CTRL_BASE 0x02a0f000
  128. #define KS2_QM_PDSP1_IRAM_BASE 0x02a10000
  129. #define KS2_QM_MANAGER_QUEUES_BASE 0x02a80000
  130. #define KS2_QM_MANAGER_Q_PROXY_BASE 0x02ac0000
  131. #define KS2_QM_QUEUE_STATUS_BASE 0x02a40000
  132. #define KS2_QM_LINK_RAM_BASE 0x00100000
  133. #define KS2_QM_REGION_NUM 64
  134. #define KS2_QM_QPOOL_NUM 4000
  135. /* MSMC control */
  136. #define KS2_MSMC_CTRL_BASE 0x0bc00000
  137. /* USB */
  138. #define KS2_USB_SS_BASE 0x02680000
  139. #define KS2_USB_HOST_XHCI_BASE (KS2_USB_SS_BASE + 0x10000)
  140. #define KS2_DEV_USB_PHY_BASE 0x02620738
  141. #define KS2_USB_PHY_CFG_BASE 0x02630000
  142. #ifdef CONFIG_SOC_K2HK
  143. #include <asm/arch/hardware-k2hk.h>
  144. #endif
  145. #ifdef CONFIG_SOC_K2E
  146. #include <asm/arch/hardware-k2e.h>
  147. #endif
  148. #ifndef __ASSEMBLY__
  149. static inline int cpu_is_k2hk(void)
  150. {
  151. unsigned int jtag_id = __raw_readl(KS2_JTAG_ID_REG);
  152. unsigned int part_no = (jtag_id >> 12) & 0xffff;
  153. return (part_no == 0xb981) ? 1 : 0;
  154. }
  155. static inline int cpu_is_k2e(void)
  156. {
  157. unsigned int jtag_id = __raw_readl(KS2_JTAG_ID_REG);
  158. unsigned int part_no = (jtag_id >> 12) & 0xffff;
  159. return (part_no == 0xb9a6) ? 1 : 0;
  160. }
  161. static inline int cpu_revision(void)
  162. {
  163. unsigned int jtag_id = __raw_readl(KS2_JTAG_ID_REG);
  164. unsigned int rev = (jtag_id >> 28) & 0xf;
  165. return rev;
  166. }
  167. int cpu_to_bus(u32 *ptr, u32 length);
  168. void sdelay(unsigned long);
  169. #endif
  170. #endif /* __ASM_ARCH_HARDWARE_H */