selfboot.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /*
  2. * Copyright (c) 2006-2022, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2019-12-04 Jiaxun Yang Initial version
  9. */
  10. #ifndef __RT_LS1C_SELFBOOT_H
  11. #define __RT_LS1C_SELFBOOT_H
  12. /* SDRAM PARAM macro */
  13. #define SD_FREQ (((APB_CLK / 4) * (PLL_MULT / CPU_DIV)) / SDRAM_PARAM_DIV_NUM)
  14. /* SDRAM ROW */
  15. #define ROW_1K 0x7
  16. #define ROW_2K 0x0
  17. #define ROW_4K 0x1
  18. #define ROW_8K 0x2
  19. #define ROW_16K 0x3
  20. /* SDRAM COL */
  21. #define COL_256 0x7
  22. #define COL_512 0x0
  23. #define COL_1K 0x1
  24. #define COL_2K 0x2
  25. #define COL_4K 0x3
  26. /* SDRAM WIDTH */
  27. #define WIDTH_8 0x0
  28. #define WIDTH_16 0x1
  29. #define WIDTH_32 0x2
  30. #define TRCD 3
  31. #define TCL 3
  32. #define TRP 3
  33. #define TRFC 8
  34. #define TRAS 6
  35. #define TREF 0x818
  36. #define TWR 2
  37. #define DEF_SEL 0x1
  38. #define DEF_SEL_N 0x0
  39. #define HANG_UP 0x1
  40. #define HANG_UP_N 0x0
  41. #define CFG_VALID 0x1
  42. #include "board.h"
  43. #define SD_PARA0 (0x7f<<25 | \
  44. (TRAS << 21) | \
  45. (TRFC << 17) | (TRP << 14) | (TCL << 11) | \
  46. (TRCD << 8) | (SDRAM_WIDTH << 6) | (SDRAM_COL << 3) | \
  47. SDRAM_ROW)
  48. #define SD_PARA1 ((HANG_UP_N << 8) | (DEF_SEL_N << 7) | (TWR << 5) | (TREF >> 7))
  49. #define SD_PARA1_EN ((CFG_VALID << 9) | (HANG_UP_N << 8) | \
  50. (DEF_SEL_N << 7) | (TWR << 5) | (TREF >> 7))
  51. #define LS1C_CBUS_FIRST1 0xBFE011C4
  52. #define LS1C_UART2_BASE 0xBFE48000
  53. /* UART register offset*/
  54. #define LS1C_UART_DAT_OFFSET (0)
  55. #define LS1C_UART_IER_OFFSET (1)
  56. #define LS1C_UART_IIR_OFFSET (2)
  57. #define LS1C_UART_FCR_OFFSET (2)
  58. #define LS1C_UART_LCR_OFFSET (3)
  59. #define LS1C_UART_MCR_OFFSET (4)
  60. #define LS1C_UART_LSR_OFFSET (5)
  61. #define LS1C_UART_MSR_OFFSET (6)
  62. #define LS1C_UART_LSB_OFFSET (0)
  63. #define LS1C_UART_MSB_OFFSET (1)
  64. /* interrupt enable register */
  65. #define IER_IRxE 0x1
  66. #define IER_ITxE 0x2
  67. #define IER_ILE 0x4
  68. #define IER_IME 0x8
  69. /* interrupt identification register */
  70. #define IIR_IMASK 0xf /* mask */
  71. #define IIR_RXTOUT 0xc /* receive timeout */
  72. #define IIR_RLS 0x6 /* receive line status */
  73. #define IIR_RXRDY 0x4 /* receive ready */
  74. #define IIR_TXRDY 0x2 /* transmit ready */
  75. #define IIR_NOPEND 0x1 /* nothing */
  76. #define IIR_MLSC 0x0 /* modem status */
  77. #define IIR_FIFO_MASK 0xc0 /* set if FIFOs are enabled */
  78. /* fifo control register */
  79. #define FIFO_ENABLE 0x01 /* enable fifo */
  80. #define FIFO_RCV_RST 0x02 /* reset receive fifo */
  81. #define FIFO_XMT_RST 0x04 /* reset transmit fifo */
  82. #define FIFO_DMA_MODE 0x08 /* enable dma mode */
  83. #define FIFO_TRIGGER_1 0x00 /* trigger at 1 char */
  84. #define FIFO_TRIGGER_4 0x40 /* trigger at 4 chars */
  85. #define FIFO_TRIGGER_8 0x80 /* trigger at 8 chars */
  86. #define FIFO_TRIGGER_14 0xc0 /* trigger at 14 chars */
  87. /* character format control register */
  88. #define CFCR_DLAB 0x80 /* divisor latch */
  89. #define CFCR_SBREAK 0x40 /* send break */
  90. #define CFCR_PZERO 0x30 /* zero parity */
  91. #define CFCR_PONE 0x20 /* one parity */
  92. #define CFCR_PEVEN 0x10 /* even parity */
  93. #define CFCR_PODD 0x00 /* odd parity */
  94. #define CFCR_PENAB 0x08 /* parity enable */
  95. #define CFCR_STOPB 0x04 /* 2 stop bits */
  96. #define CFCR_8BITS 0x03 /* 8 data bits */
  97. #define CFCR_7BITS 0x02 /* 7 data bits */
  98. #define CFCR_6BITS 0x01 /* 6 data bits */
  99. #define CFCR_5BITS 0x00 /* 5 data bits */
  100. /* modem control register */
  101. #define MCR_LOOPBACK 0x10 /* loopback */
  102. #define MCR_IENABLE 0x08 /* output 2 = int enable */
  103. #define MCR_DRS 0x04 /* output 1 = xxx */
  104. #define MCR_RTS 0x02 /* enable RTS */
  105. #define MCR_DTR 0x01 /* enable DTR */
  106. /* line status register */
  107. #define LSR_RCV_FIFO 0x80 /* error in receive fifo */
  108. #define LSR_TSRE 0x40 /* transmitter empty */
  109. #define LSR_TXRDY 0x20 /* transmitter ready */
  110. #define LSR_BI 0x10 /* break detected */
  111. #define LSR_FE 0x08 /* framing error */
  112. #define LSR_PE 0x04 /* parity error */
  113. #define LSR_OE 0x02 /* overrun error */
  114. #define LSR_RXRDY 0x01 /* receiver ready */
  115. #define LSR_RCV_MASK 0x1f
  116. /* External clock frequency */
  117. #define AHB_CLK (24000000)
  118. #define APB_CLK (AHB_CLK)
  119. /* START_FREQ register bits */
  120. #define M_PLL_SHIFT (8)
  121. #define M_PLL (0xff << M_PLL_SHIFT)
  122. #define FRAC_N_SHIFT (16)
  123. #define FRAC_N (0xff << FRAC_N_SHIFT)
  124. #define DIV_SDRAM_SHIFT (0)
  125. #define DIV_SDRAM (0x3 << DIV_SDRAM_SHIFT)
  126. /* CLK_DIV_PARAM register bits */
  127. #define DIV_PIX_EN (0x1 << 31)
  128. #define DIV_PIX (0x7f << 24)
  129. #define DIV_CAM_EN (0x1 << 23)
  130. #define DIV_CAM (0x7f << 16)
  131. #define DIV_CPU_EN (0x1 << 15)
  132. #define DIV_CPU (0x7f << 8)
  133. #define DIV_PIX_VALID (0x1 << 5)
  134. #define DIV_PIX_SEL (0x1 << 4)
  135. #define DIV_CAM_VALID (0x1 << 3)
  136. #define DIV_CAM_SEL (0x1 << 2)
  137. #define DIV_CPU_VALID (0x1 << 1)
  138. #define DIV_CPU_SEL (0x1 << 0)
  139. #define DIV_PIX_SHIFT (24)
  140. #define DIV_CAM_SHIFT (16)
  141. #define DIV_CPU_SHIFT (8)
  142. #endif