rt305x.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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 _RT305X_REGS_H_
  13. #define _RT305X_REGS_H_
  14. extern enum ralink_soc_type ralink_soc;
  15. static inline int soc_is_rt3050(void)
  16. {
  17. return ralink_soc == RT305X_SOC_RT3050;
  18. }
  19. static inline int soc_is_rt3052(void)
  20. {
  21. return ralink_soc == RT305X_SOC_RT3052;
  22. }
  23. static inline int soc_is_rt305x(void)
  24. {
  25. return soc_is_rt3050() || soc_is_rt3052();
  26. }
  27. static inline int soc_is_rt3350(void)
  28. {
  29. return ralink_soc == RT305X_SOC_RT3350;
  30. }
  31. static inline int soc_is_rt3352(void)
  32. {
  33. return ralink_soc == RT305X_SOC_RT3352;
  34. }
  35. static inline int soc_is_rt5350(void)
  36. {
  37. return ralink_soc == RT305X_SOC_RT5350;
  38. }
  39. #define RT305X_SYSC_BASE 0x10000000
  40. #define SYSC_REG_CHIP_NAME0 0x00
  41. #define SYSC_REG_CHIP_NAME1 0x04
  42. #define SYSC_REG_CHIP_ID 0x0c
  43. #define SYSC_REG_SYSTEM_CONFIG 0x10
  44. #define RT3052_CHIP_NAME0 0x30335452
  45. #define RT3052_CHIP_NAME1 0x20203235
  46. #define RT3350_CHIP_NAME0 0x33335452
  47. #define RT3350_CHIP_NAME1 0x20203035
  48. #define RT3352_CHIP_NAME0 0x33335452
  49. #define RT3352_CHIP_NAME1 0x20203235
  50. #define RT5350_CHIP_NAME0 0x33355452
  51. #define RT5350_CHIP_NAME1 0x20203035
  52. #define CHIP_ID_ID_MASK 0xff
  53. #define CHIP_ID_ID_SHIFT 8
  54. #define CHIP_ID_REV_MASK 0xff
  55. #define RT305X_SYSCFG_CPUCLK_SHIFT 18
  56. #define RT305X_SYSCFG_CPUCLK_MASK 0x1
  57. #define RT305X_SYSCFG_CPUCLK_LOW 0x0
  58. #define RT305X_SYSCFG_CPUCLK_HIGH 0x1
  59. #define RT305X_SYSCFG_SRAM_CS0_MODE_SHIFT 2
  60. #define RT305X_SYSCFG_CPUCLK_MASK 0x1
  61. #define RT305X_SYSCFG_SRAM_CS0_MODE_WDT 0x1
  62. #define RT3352_SYSCFG0_CPUCLK_SHIFT 8
  63. #define RT3352_SYSCFG0_CPUCLK_MASK 0x1
  64. #define RT3352_SYSCFG0_CPUCLK_LOW 0x0
  65. #define RT3352_SYSCFG0_CPUCLK_HIGH 0x1
  66. #define RT5350_SYSCFG0_CPUCLK_SHIFT 8
  67. #define RT5350_SYSCFG0_CPUCLK_MASK 0x3
  68. #define RT5350_SYSCFG0_CPUCLK_360 0x0
  69. #define RT5350_SYSCFG0_CPUCLK_320 0x2
  70. #define RT5350_SYSCFG0_CPUCLK_300 0x3
  71. #define RT5350_SYSCFG0_DRAM_SIZE_SHIFT 12
  72. #define RT5350_SYSCFG0_DRAM_SIZE_MASK 7
  73. #define RT5350_SYSCFG0_DRAM_SIZE_2M 0
  74. #define RT5350_SYSCFG0_DRAM_SIZE_8M 1
  75. #define RT5350_SYSCFG0_DRAM_SIZE_16M 2
  76. #define RT5350_SYSCFG0_DRAM_SIZE_32M 3
  77. #define RT5350_SYSCFG0_DRAM_SIZE_64M 4
  78. /* multi function gpio pins */
  79. #define RT305X_GPIO_I2C_SD 1
  80. #define RT305X_GPIO_I2C_SCLK 2
  81. #define RT305X_GPIO_SPI_EN 3
  82. #define RT305X_GPIO_SPI_CLK 4
  83. /* GPIO 7-14 is shared between UART0, PCM and I2S interfaces */
  84. #define RT305X_GPIO_7 7
  85. #define RT305X_GPIO_10 10
  86. #define RT305X_GPIO_14 14
  87. #define RT305X_GPIO_UART1_TXD 15
  88. #define RT305X_GPIO_UART1_RXD 16
  89. #define RT305X_GPIO_JTAG_TDO 17
  90. #define RT305X_GPIO_JTAG_TDI 18
  91. #define RT305X_GPIO_MDIO_MDC 22
  92. #define RT305X_GPIO_MDIO_MDIO 23
  93. #define RT305X_GPIO_SDRAM_MD16 24
  94. #define RT305X_GPIO_SDRAM_MD31 39
  95. #define RT305X_GPIO_GE0_TXD0 40
  96. #define RT305X_GPIO_GE0_RXCLK 51
  97. #define RT305X_GPIO_MODE_UART0_SHIFT 2
  98. #define RT305X_GPIO_MODE_UART0_MASK 0x7
  99. #define RT305X_GPIO_MODE_UART0(x) ((x) << RT305X_GPIO_MODE_UART0_SHIFT)
  100. #define RT305X_GPIO_MODE_UARTF 0
  101. #define RT305X_GPIO_MODE_PCM_UARTF 1
  102. #define RT305X_GPIO_MODE_PCM_I2S 2
  103. #define RT305X_GPIO_MODE_I2S_UARTF 3
  104. #define RT305X_GPIO_MODE_PCM_GPIO 4
  105. #define RT305X_GPIO_MODE_GPIO_UARTF 5
  106. #define RT305X_GPIO_MODE_GPIO_I2S 6
  107. #define RT305X_GPIO_MODE_GPIO 7
  108. #define RT305X_GPIO_MODE_I2C 0
  109. #define RT305X_GPIO_MODE_SPI 1
  110. #define RT305X_GPIO_MODE_UART1 5
  111. #define RT305X_GPIO_MODE_JTAG 6
  112. #define RT305X_GPIO_MODE_MDIO 7
  113. #define RT305X_GPIO_MODE_SDRAM 8
  114. #define RT305X_GPIO_MODE_RGMII 9
  115. #define RT5350_GPIO_MODE_PHY_LED 14
  116. #define RT5350_GPIO_MODE_SPI_CS1 21
  117. #define RT3352_GPIO_MODE_LNA 18
  118. #define RT3352_GPIO_MODE_PA 20
  119. #define RT3352_SYSC_REG_SYSCFG0 0x010
  120. #define RT3352_SYSC_REG_SYSCFG1 0x014
  121. #define RT3352_SYSC_REG_CLKCFG1 0x030
  122. #define RT3352_SYSC_REG_RSTCTRL 0x034
  123. #define RT3352_SYSC_REG_USB_PS 0x05c
  124. #define RT3352_CLKCFG0_XTAL_SEL BIT(20)
  125. #define RT3352_CLKCFG1_UPHY0_CLK_EN BIT(18)
  126. #define RT3352_CLKCFG1_UPHY1_CLK_EN BIT(20)
  127. #define RT3352_RSTCTRL_UHST BIT(22)
  128. #define RT3352_RSTCTRL_UDEV BIT(25)
  129. #define RT3352_SYSCFG1_USB0_HOST_MODE BIT(10)
  130. #define RT305X_SDRAM_BASE 0x00000000
  131. #define RT305X_MEM_SIZE_MIN 2
  132. #define RT305X_MEM_SIZE_MAX 64
  133. #define RT3352_MEM_SIZE_MIN 2
  134. #define RT3352_MEM_SIZE_MAX 256
  135. #endif