global_reg.h 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. /*
  2. * This file contains the hardware definitions for Gemini.
  3. *
  4. * Copyright (C) 2009 Paulius Zaleckas <paulius.zaleckas@teltonika.lt>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. */
  11. #ifndef __MACH_GLOBAL_REG_H
  12. #define __MACH_GLOBAL_REG_H
  13. /* Global Word ID Register*/
  14. #define GLOBAL_ID 0x00
  15. #define CHIP_ID(reg) ((reg) >> 8)
  16. #define CHIP_REVISION(reg) ((reg) & 0xFF)
  17. /* Global Status Register */
  18. #define GLOBAL_STATUS 0x04
  19. #define CPU_BIG_ENDIAN (1 << 31)
  20. #define PLL_OSC_30M (1 << 30) /* else 60MHz */
  21. #define OPERATION_MODE_MASK (0xF << 26)
  22. #define OPM_IDDQ (0xF << 26)
  23. #define OPM_NAND (0xE << 26)
  24. #define OPM_RING (0xD << 26)
  25. #define OPM_DIRECT_BOOT (0xC << 26)
  26. #define OPM_USB1_PHY_TEST (0xB << 26)
  27. #define OPM_USB0_PHY_TEST (0xA << 26)
  28. #define OPM_SATA1_PHY_TEST (0x9 << 26)
  29. #define OPM_SATA0_PHY_TEST (0x8 << 26)
  30. #define OPM_ICE_ARM (0x7 << 26)
  31. #define OPM_ICE_FARADAY (0x6 << 26)
  32. #define OPM_PLL_BYPASS (0x5 << 26)
  33. #define OPM_DEBUG (0x4 << 26)
  34. #define OPM_BURN_IN (0x3 << 26)
  35. #define OPM_MBIST (0x2 << 26)
  36. #define OPM_SCAN (0x1 << 26)
  37. #define OPM_REAL (0x0 << 26)
  38. #define FLASH_TYPE_MASK (0x3 << 24)
  39. #define FLASH_TYPE_NAND_2K (0x3 << 24)
  40. #define FLASH_TYPE_NAND_512 (0x2 << 24)
  41. #define FLASH_TYPE_PARALLEL (0x1 << 24)
  42. #define FLASH_TYPE_SERIAL (0x0 << 24)
  43. /* if parallel */
  44. #define FLASH_WIDTH_16BIT (1 << 23) /* else 8 bit */
  45. /* if serial */
  46. #define FLASH_ATMEL (1 << 23) /* else STM */
  47. #define FLASH_SIZE_MASK (0x3 << 21)
  48. #define NAND_256M (0x3 << 21) /* and more */
  49. #define NAND_128M (0x2 << 21)
  50. #define NAND_64M (0x1 << 21)
  51. #define NAND_32M (0x0 << 21)
  52. #define ATMEL_16M (0x3 << 21) /* and more */
  53. #define ATMEL_8M (0x2 << 21)
  54. #define ATMEL_4M_2M (0x1 << 21)
  55. #define ATMEL_1M (0x0 << 21) /* and less */
  56. #define STM_32M (1 << 22) /* and more */
  57. #define STM_16M (0 << 22) /* and less */
  58. #define FLASH_PARALLEL_HIGH_PIN_CNT (1 << 20) /* else low pin cnt */
  59. #define CPU_AHB_RATIO_MASK (0x3 << 18)
  60. #define CPU_AHB_1_1 (0x0 << 18)
  61. #define CPU_AHB_3_2 (0x1 << 18)
  62. #define CPU_AHB_24_13 (0x2 << 18)
  63. #define CPU_AHB_2_1 (0x3 << 18)
  64. #define REG_TO_AHB_SPEED(reg) ((((reg) >> 15) & 0x7) * 10 + 130)
  65. #define AHB_SPEED_TO_REG(x) ((((x - 130)) / 10) << 15)
  66. /* it is posible to override some settings, use >> OVERRIDE_xxxx_SHIFT */
  67. #define OVERRIDE_FLASH_TYPE_SHIFT 16
  68. #define OVERRIDE_FLASH_WIDTH_SHIFT 16
  69. #define OVERRIDE_FLASH_SIZE_SHIFT 16
  70. #define OVERRIDE_CPU_AHB_RATIO_SHIFT 15
  71. #define OVERRIDE_AHB_SPEED_SHIFT 15
  72. /* Global PLL Control Register */
  73. #define GLOBAL_PLL_CTRL 0x08
  74. #define PLL_BYPASS (1 << 31)
  75. #define PLL_POWER_DOWN (1 << 8)
  76. #define PLL_CONTROL_Q (0x1F << 0)
  77. /* Global Soft Reset Control Register */
  78. #define GLOBAL_RESET 0x0C
  79. #define RESET_GLOBAL (1 << 31)
  80. #define RESET_CPU1 (1 << 30)
  81. #define RESET_TVE (1 << 28)
  82. #define RESET_SATA1 (1 << 27)
  83. #define RESET_SATA0 (1 << 26)
  84. #define RESET_CIR (1 << 25)
  85. #define RESET_EXT_DEV (1 << 24)
  86. #define RESET_WD (1 << 23)
  87. #define RESET_GPIO2 (1 << 22)
  88. #define RESET_GPIO1 (1 << 21)
  89. #define RESET_GPIO0 (1 << 20)
  90. #define RESET_SSP (1 << 19)
  91. #define RESET_UART (1 << 18)
  92. #define RESET_TIMER (1 << 17)
  93. #define RESET_RTC (1 << 16)
  94. #define RESET_INT1 (1 << 15)
  95. #define RESET_INT0 (1 << 14)
  96. #define RESET_LCD (1 << 13)
  97. #define RESET_LPC (1 << 12)
  98. #define RESET_APB (1 << 11)
  99. #define RESET_DMA (1 << 10)
  100. #define RESET_USB1 (1 << 9)
  101. #define RESET_USB0 (1 << 8)
  102. #define RESET_PCI (1 << 7)
  103. #define RESET_GMAC1 (1 << 6)
  104. #define RESET_GMAC0 (1 << 5)
  105. #define RESET_SECURITY (1 << 4)
  106. #define RESET_RAID (1 << 3)
  107. #define RESET_IDE (1 << 2)
  108. #define RESET_FLASH (1 << 1)
  109. #define RESET_DRAM (1 << 0)
  110. /* Global IO Pad Driving Capability Control Register */
  111. #define GLOBAL_IO_DRIVING_CTRL 0x10
  112. #define DRIVING_CURRENT_MASK 0x3
  113. /* here 00-4mA, 01-8mA, 10-12mA, 11-16mA */
  114. #define GPIO1_PADS_31_28_SHIFT 28
  115. #define GPIO0_PADS_31_16_SHIFT 26
  116. #define GPIO0_PADS_15_0_SHIFT 24
  117. #define PCI_AND_EXT_RESET_PADS_SHIFT 22
  118. #define IDE_PADS_SHIFT 20
  119. #define GMAC1_PADS_SHIFT 18
  120. #define GMAC0_PADS_SHIFT 16
  121. /* DRAM is not in mA and poorly documented */
  122. #define DRAM_CLOCK_PADS_SHIFT 8
  123. #define DRAM_DATA_PADS_SHIFT 4
  124. #define DRAM_CONTROL_PADS_SHIFT 0
  125. /* Global IO Pad Slew Rate Control Register */
  126. #define GLOBAL_IO_SLEW_RATE_CTRL 0x14
  127. #define GPIO1_PADS_31_28_SLOW (1 << 10)
  128. #define GPIO0_PADS_31_16_SLOW (1 << 9)
  129. #define GPIO0_PADS_15_0_SLOW (1 << 8)
  130. #define PCI_PADS_SLOW (1 << 7)
  131. #define IDE_PADS_SLOW (1 << 6)
  132. #define GMAC1_PADS_SLOW (1 << 5)
  133. #define GMAC0_PADS_SLOW (1 << 4)
  134. #define DRAM_CLOCK_PADS_SLOW (1 << 1)
  135. #define DRAM_IO_PADS_SLOW (1 << 0)
  136. /*
  137. * General skew control defines
  138. * 16 steps, each step is around 0.2ns
  139. */
  140. #define SKEW_MASK 0xF
  141. /* Global IDE PAD Skew Control Register */
  142. #define GLOBAL_IDE_SKEW_CTRL 0x18
  143. #define IDE1_HOST_STROBE_DELAY_SHIFT 28
  144. #define IDE1_DEVICE_STROBE_DELAY_SHIFT 24
  145. #define IDE1_OUTPUT_IO_SKEW_SHIFT 20
  146. #define IDE1_INPUT_IO_SKEW_SHIFT 16
  147. #define IDE0_HOST_STROBE_DELAY_SHIFT 12
  148. #define IDE0_DEVICE_STROBE_DELAY_SHIFT 8
  149. #define IDE0_OUTPUT_IO_SKEW_SHIFT 4
  150. #define IDE0_INPUT_IO_SKEW_SHIFT 0
  151. /* Global GMAC Control Pad Skew Control Register */
  152. #define GLOBAL_GMAC_CTRL_SKEW_CTRL 0x1C
  153. #define GMAC1_TXC_SKEW_SHIFT 28
  154. #define GMAC1_TXEN_SKEW_SHIFT 24
  155. #define GMAC1_RXC_SKEW_SHIFT 20
  156. #define GMAC1_RXDV_SKEW_SHIFT 16
  157. #define GMAC0_TXC_SKEW_SHIFT 12
  158. #define GMAC0_TXEN_SKEW_SHIFT 8
  159. #define GMAC0_RXC_SKEW_SHIFT 4
  160. #define GMAC0_RXDV_SKEW_SHIFT 0
  161. /* Global GMAC0 Data PAD Skew Control Register */
  162. #define GLOBAL_GMAC0_DATA_SKEW_CTRL 0x20
  163. /* Global GMAC1 Data PAD Skew Control Register */
  164. #define GLOBAL_GMAC1_DATA_SKEW_CTRL 0x24
  165. #define GMAC_TXD_SKEW_SHIFT(x) (((x) * 4) + 16)
  166. #define GMAC_RXD_SKEW_SHIFT(x) ((x) * 4)
  167. /* CPU has two AHB busses. */
  168. /* Global Arbitration0 Control Register */
  169. #define GLOBAL_ARBITRATION0_CTRL 0x28
  170. #define BOOT_CONTROLLER_HIGH_PRIO (1 << 3)
  171. #define DMA_BUS1_HIGH_PRIO (1 << 2)
  172. #define CPU0_HIGH_PRIO (1 << 0)
  173. /* Global Arbitration1 Control Register */
  174. #define GLOBAL_ARBITRATION1_CTRL 0x2C
  175. #define TVE_HIGH_PRIO (1 << 9)
  176. #define PCI_HIGH_PRIO (1 << 8)
  177. #define USB1_HIGH_PRIO (1 << 7)
  178. #define USB0_HIGH_PRIO (1 << 6)
  179. #define GMAC1_HIGH_PRIO (1 << 5)
  180. #define GMAC0_HIGH_PRIO (1 << 4)
  181. #define SECURITY_HIGH_PRIO (1 << 3)
  182. #define RAID_HIGH_PRIO (1 << 2)
  183. #define IDE_HIGH_PRIO (1 << 1)
  184. #define DMA_BUS2_HIGH_PRIO (1 << 0)
  185. /* Common bits for both arbitration registers */
  186. #define BURST_LENGTH_SHIFT 16
  187. #define BURST_LENGTH_MASK (0x3F << 16)
  188. /* Miscellaneous Control Register */
  189. #define GLOBAL_MISC_CTRL 0x30
  190. #define MEMORY_SPACE_SWAP (1 << 31)
  191. #define USB1_PLUG_MINIB (1 << 30) /* else plug is mini-A */
  192. #define USB0_PLUG_MINIB (1 << 29)
  193. #define GMAC_GMII (1 << 28)
  194. #define GMAC_1_ENABLE (1 << 27)
  195. /* TODO: define ATA/SATA bits */
  196. #define USB1_VBUS_ON (1 << 23)
  197. #define USB0_VBUS_ON (1 << 22)
  198. #define APB_CLKOUT_ENABLE (1 << 21)
  199. #define TVC_CLKOUT_ENABLE (1 << 20)
  200. #define EXT_CLKIN_ENABLE (1 << 19)
  201. #define PCI_66MHZ (1 << 18) /* else 33 MHz */
  202. #define PCI_CLKOUT_ENABLE (1 << 17)
  203. #define LPC_CLKOUT_ENABLE (1 << 16)
  204. #define USB1_WAKEUP_ON (1 << 15)
  205. #define USB0_WAKEUP_ON (1 << 14)
  206. /* TODO: define PCI idle detect bits */
  207. #define TVC_PADS_ENABLE (1 << 9)
  208. #define SSP_PADS_ENABLE (1 << 8)
  209. #define LCD_PADS_ENABLE (1 << 7)
  210. #define LPC_PADS_ENABLE (1 << 6)
  211. #define PCI_PADS_ENABLE (1 << 5)
  212. #define IDE_PADS_ENABLE (1 << 4)
  213. #define DRAM_PADS_POWER_DOWN (1 << 3)
  214. #define NAND_PADS_DISABLE (1 << 2)
  215. #define PFLASH_PADS_DISABLE (1 << 1)
  216. #define SFLASH_PADS_DISABLE (1 << 0)
  217. /* Global Clock Control Register */
  218. #define GLOBAL_CLOCK_CTRL 0x34
  219. #define POWER_STATE_G0 (1 << 31)
  220. #define POWER_STATE_S1 (1 << 30) /* else it is S3/S4 state */
  221. #define SECURITY_APB_AHB (1 << 29)
  222. /* else Security APB clk will be 0.75xAHB */
  223. /* TODO: TVC clock divider */
  224. #define PCI_CLKRUN_ENABLE (1 << 16)
  225. #define BOOT_CLK_DISABLE (1 << 13)
  226. #define TVC_CLK_DISABLE (1 << 12)
  227. #define FLASH_CLK_DISABLE (1 << 11)
  228. #define DDR_CLK_DISABLE (1 << 10)
  229. #define PCI_CLK_DISABLE (1 << 9)
  230. #define IDE_CLK_DISABLE (1 << 8)
  231. #define USB1_CLK_DISABLE (1 << 7)
  232. #define USB0_CLK_DISABLE (1 << 6)
  233. #define SATA1_CLK_DISABLE (1 << 5)
  234. #define SATA0_CLK_DISABLE (1 << 4)
  235. #define GMAC1_CLK_DISABLE (1 << 3)
  236. #define GMAC0_CLK_DISABLE (1 << 2)
  237. #define SECURITY_CLK_DISABLE (1 << 1)
  238. /* TODO: other registers definitions if needed */
  239. #endif /* __MACH_GLOBAL_REG_H */