mt7620.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * This program is free software; you can redistribute it and/or modify it
  3. * under the terms of the GNU General Public License version 2 as published
  4. * by the Free Software Foundation.
  5. *
  6. * Parts of this file are based on Ralink's 2.6.21 BSP
  7. *
  8. * Copyright (C) 2008-2011 Gabor Juhos <juhosg@openwrt.org>
  9. * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  10. * Copyright (C) 2013 John Crispin <john@phrozen.org>
  11. */
  12. #ifndef _MT7620_REGS_H_
  13. #define _MT7620_REGS_H_
  14. #define MT7620_SYSC_BASE 0x10000000
  15. #define SYSC_REG_CHIP_NAME0 0x00
  16. #define SYSC_REG_CHIP_NAME1 0x04
  17. #define SYSC_REG_EFUSE_CFG 0x08
  18. #define SYSC_REG_CHIP_REV 0x0c
  19. #define SYSC_REG_SYSTEM_CONFIG0 0x10
  20. #define SYSC_REG_SYSTEM_CONFIG1 0x14
  21. #define SYSC_REG_CLKCFG0 0x2c
  22. #define SYSC_REG_CPU_SYS_CLKCFG 0x3c
  23. #define SYSC_REG_CPLL_CONFIG0 0x54
  24. #define SYSC_REG_CPLL_CONFIG1 0x58
  25. #define MT7620_CHIP_NAME0 0x3637544d
  26. #define MT7620_CHIP_NAME1 0x20203032
  27. #define MT7628_CHIP_NAME1 0x20203832
  28. #define SYSCFG0_XTAL_FREQ_SEL BIT(6)
  29. #define CHIP_REV_PKG_MASK 0x1
  30. #define CHIP_REV_PKG_SHIFT 16
  31. #define CHIP_REV_VER_MASK 0xf
  32. #define CHIP_REV_VER_SHIFT 8
  33. #define CHIP_REV_ECO_MASK 0xf
  34. #define CLKCFG0_PERI_CLK_SEL BIT(4)
  35. #define CPU_SYS_CLKCFG_OCP_RATIO_SHIFT 16
  36. #define CPU_SYS_CLKCFG_OCP_RATIO_MASK 0xf
  37. #define CPU_SYS_CLKCFG_OCP_RATIO_1 0 /* 1:1 (Reserved) */
  38. #define CPU_SYS_CLKCFG_OCP_RATIO_1_5 1 /* 1:1.5 (Reserved) */
  39. #define CPU_SYS_CLKCFG_OCP_RATIO_2 2 /* 1:2 */
  40. #define CPU_SYS_CLKCFG_OCP_RATIO_2_5 3 /* 1:2.5 (Reserved) */
  41. #define CPU_SYS_CLKCFG_OCP_RATIO_3 4 /* 1:3 */
  42. #define CPU_SYS_CLKCFG_OCP_RATIO_3_5 5 /* 1:3.5 (Reserved) */
  43. #define CPU_SYS_CLKCFG_OCP_RATIO_4 6 /* 1:4 */
  44. #define CPU_SYS_CLKCFG_OCP_RATIO_5 7 /* 1:5 */
  45. #define CPU_SYS_CLKCFG_OCP_RATIO_10 8 /* 1:10 */
  46. #define CPU_SYS_CLKCFG_CPU_FDIV_SHIFT 8
  47. #define CPU_SYS_CLKCFG_CPU_FDIV_MASK 0x1f
  48. #define CPU_SYS_CLKCFG_CPU_FFRAC_SHIFT 0
  49. #define CPU_SYS_CLKCFG_CPU_FFRAC_MASK 0x1f
  50. #define CPLL_CFG0_SW_CFG BIT(31)
  51. #define CPLL_CFG0_PLL_MULT_RATIO_SHIFT 16
  52. #define CPLL_CFG0_PLL_MULT_RATIO_MASK 0x7
  53. #define CPLL_CFG0_LC_CURFCK BIT(15)
  54. #define CPLL_CFG0_BYPASS_REF_CLK BIT(14)
  55. #define CPLL_CFG0_PLL_DIV_RATIO_SHIFT 10
  56. #define CPLL_CFG0_PLL_DIV_RATIO_MASK 0x3
  57. #define CPLL_CFG1_CPU_AUX1 BIT(25)
  58. #define CPLL_CFG1_CPU_AUX0 BIT(24)
  59. #define SYSCFG0_DRAM_TYPE_MASK 0x3
  60. #define SYSCFG0_DRAM_TYPE_SHIFT 4
  61. #define SYSCFG0_DRAM_TYPE_SDRAM 0
  62. #define SYSCFG0_DRAM_TYPE_DDR1 1
  63. #define SYSCFG0_DRAM_TYPE_DDR2 2
  64. #define SYSCFG0_DRAM_TYPE_UNKNOWN 3
  65. #define SYSCFG0_DRAM_TYPE_DDR2_MT7628 0
  66. #define SYSCFG0_DRAM_TYPE_DDR1_MT7628 1
  67. #define MT7620_DRAM_BASE 0x0
  68. #define MT7620_SDRAM_SIZE_MIN 2
  69. #define MT7620_SDRAM_SIZE_MAX 64
  70. #define MT7620_DDR1_SIZE_MIN 32
  71. #define MT7620_DDR1_SIZE_MAX 128
  72. #define MT7620_DDR2_SIZE_MIN 32
  73. #define MT7620_DDR2_SIZE_MAX 256
  74. #define MT7620_GPIO_MODE_UART0_SHIFT 2
  75. #define MT7620_GPIO_MODE_UART0_MASK 0x7
  76. #define MT7620_GPIO_MODE_UART0(x) ((x) << MT7620_GPIO_MODE_UART0_SHIFT)
  77. #define MT7620_GPIO_MODE_UARTF 0x0
  78. #define MT7620_GPIO_MODE_PCM_UARTF 0x1
  79. #define MT7620_GPIO_MODE_PCM_I2S 0x2
  80. #define MT7620_GPIO_MODE_I2S_UARTF 0x3
  81. #define MT7620_GPIO_MODE_PCM_GPIO 0x4
  82. #define MT7620_GPIO_MODE_GPIO_UARTF 0x5
  83. #define MT7620_GPIO_MODE_GPIO_I2S 0x6
  84. #define MT7620_GPIO_MODE_GPIO 0x7
  85. #define MT7620_GPIO_MODE_NAND 0
  86. #define MT7620_GPIO_MODE_SD 1
  87. #define MT7620_GPIO_MODE_ND_SD_GPIO 2
  88. #define MT7620_GPIO_MODE_ND_SD_MASK 0x3
  89. #define MT7620_GPIO_MODE_ND_SD_SHIFT 18
  90. #define MT7620_GPIO_MODE_PCIE_RST 0
  91. #define MT7620_GPIO_MODE_PCIE_REF 1
  92. #define MT7620_GPIO_MODE_PCIE_GPIO 2
  93. #define MT7620_GPIO_MODE_PCIE_MASK 0x3
  94. #define MT7620_GPIO_MODE_PCIE_SHIFT 16
  95. #define MT7620_GPIO_MODE_WDT_RST 0
  96. #define MT7620_GPIO_MODE_WDT_REF 1
  97. #define MT7620_GPIO_MODE_WDT_GPIO 2
  98. #define MT7620_GPIO_MODE_WDT_MASK 0x3
  99. #define MT7620_GPIO_MODE_WDT_SHIFT 21
  100. #define MT7620_GPIO_MODE_I2C 0
  101. #define MT7620_GPIO_MODE_UART1 5
  102. #define MT7620_GPIO_MODE_MDIO 8
  103. #define MT7620_GPIO_MODE_RGMII1 9
  104. #define MT7620_GPIO_MODE_RGMII2 10
  105. #define MT7620_GPIO_MODE_SPI 11
  106. #define MT7620_GPIO_MODE_SPI_REF_CLK 12
  107. #define MT7620_GPIO_MODE_WLED 13
  108. #define MT7620_GPIO_MODE_JTAG 15
  109. #define MT7620_GPIO_MODE_EPHY 15
  110. #define MT7620_GPIO_MODE_PA 20
  111. static inline int mt7620_get_eco(void)
  112. {
  113. return rt_sysc_r32(SYSC_REG_CHIP_REV) & CHIP_REV_ECO_MASK;
  114. }
  115. #endif