ls1c.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /*
  2. * File : ls1c.h
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006-2011, RT-Thread Develop Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2011-08-08 lgnq first version
  13. * 2015-07-06 chinesebear modified for loongson 1c
  14. */
  15. #ifndef __LS1C_H__
  16. #define __LS1C_H__
  17. #include "../common/mipsregs.h"
  18. #define LS1C_ACPI_IRQ 0
  19. #define LS1C_HPET_IRQ 1
  20. //#define LS1C_UART0_IRQ 3 // linux中是3,v1.4版本的1c手册中是2,暂屏蔽,待确认
  21. #define LS1C_UART1_IRQ 4
  22. #define LS1C_UART2_IRQ 5
  23. #define LS1C_CAN0_IRQ 6
  24. #define LS1C_CAN1_IRQ 7
  25. #define LS1C_SPI0_IRQ 8
  26. #define LS1C_SPI1_IRQ 9
  27. #define LS1C_AC97_IRQ 10
  28. #define LS1C_MS_IRQ 11
  29. #define LS1C_KB_IRQ 12
  30. #define LS1C_DMA0_IRQ 13
  31. #define LS1C_DMA1_IRQ 14
  32. #define LS1C_DMA2_IRQ 15
  33. #define LS1C_NAND_IRQ 16
  34. #define LS1C_PWM0_IRQ 17
  35. #define LS1C_PWM1_IRQ 18
  36. #define LS1C_PWM2_IRQ 19
  37. #define LS1C_PWM3_IRQ 20
  38. #define LS1C_RTC_INT0_IRQ 21
  39. #define LS1C_RTC_INT1_IRQ 22
  40. #define LS1C_RTC_INT2_IRQ 23
  41. #define LS1C_UART3_IRQ 29
  42. #define LS1C_ADC_IRQ 30
  43. #define LS1C_SDIO_IRQ 31
  44. #define LS1C_EHCI_IRQ (32+0)
  45. #define LS1C_OHCI_IRQ (32+1)
  46. #define LS1C_OTG_IRQ (32+2)
  47. #define LS1C_MAC_IRQ (32+3)
  48. #define LS1C_CAM_IRQ (32+4)
  49. #define LS1C_UART4_IRQ (32+5)
  50. #define LS1C_UART5_IRQ (32+6)
  51. #define LS1C_UART6_IRQ (32+7)
  52. #define LS1C_UART7_IRQ (32+8)
  53. #define LS1C_UART8_IRQ (32+9)
  54. #define LS1C_UART9_IRQ (32+13)
  55. #define LS1C_UART10_IRQ (32+14)
  56. #define LS1C_UART11_IRQ (32+15)
  57. #define LS1C_I2C2_IRQ (32+17)
  58. #define LS1C_I2C1_IRQ (32+18)
  59. #define LS1C_I2C0_IRQ (32+19)
  60. #define LS1C_GPIO_IRQ 64
  61. #define LS1C_GPIO_FIRST_IRQ 64
  62. #define LS1C_GPIO_IRQ_COUNT 96
  63. #define LS1C_GPIO_LAST_IRQ (LS1C_GPIO_FIRST_IRQ + LS1C_GPIO_IRQ_COUNT-1)
  64. #define LS1C_LAST_IRQ 159
  65. #define LS1C_INTREG_BASE 0xbfd01040
  66. // 龙芯1c的中断分为五组,每组32个
  67. #define LS1C_NR_IRQS (32*5)
  68. // GPIO编号和中断号之间的互相转换
  69. #define LS1C_GPIO_TO_IRQ(GPIOn) (LS1C_GPIO_FIRST_IRQ + (GPIOn))
  70. #define LS1C_IRQ_TO_GPIO(IRQn) ((IRQn) - LS1C_GPIO_FIRST_IRQ)
  71. struct ls1c_intc_regs
  72. {
  73. volatile unsigned int int_isr;
  74. volatile unsigned int int_en;
  75. volatile unsigned int int_set;
  76. volatile unsigned int int_clr; /* offset 0x10*/
  77. volatile unsigned int int_pol;
  78. volatile unsigned int int_edge; /* offset 0 */
  79. };
  80. struct ls1c_cop_global_regs
  81. {
  82. volatile unsigned int control;
  83. volatile unsigned int rd_inten;
  84. volatile unsigned int wr_inten;
  85. volatile unsigned int rd_intisr; /* offset 0x10*/
  86. volatile unsigned int wr_intisr;
  87. unsigned int unused[11];
  88. } ;
  89. struct ls1c_cop_channel_regs
  90. {
  91. volatile unsigned int rd_control;
  92. volatile unsigned int rd_src;
  93. volatile unsigned int rd_cnt;
  94. volatile unsigned int rd_status; /* offset 0x10*/
  95. volatile unsigned int wr_control;
  96. volatile unsigned int wr_src;
  97. volatile unsigned int wr_cnt;
  98. volatile unsigned int wr_status; /* offset 0x10*/
  99. } ;
  100. struct ls1c_cop_regs
  101. {
  102. struct ls1c_cop_global_regs global;
  103. struct ls1c_cop_channel_regs chan[8][2];
  104. } ;
  105. #define __REG8(addr) *((volatile unsigned char *)(addr))
  106. #define __REG16(addr) *((volatile unsigned short *)(addr))
  107. #define __REG32(addr) *((volatile unsigned int *)(addr))
  108. #define GMAC0_BASE 0xBFE10000
  109. #define GMAC0_DMA_BASE 0xBFE11000
  110. #define GMAC1_BASE 0xBFE20000
  111. #define GMAC1_DMA_BASE 0xBFE21000
  112. #define I2C0_BASE 0xBFE58000
  113. #define PWM0_BASE 0xBFE5C000
  114. #define PWM1_BASE 0xBFE5C010
  115. #define PWM2_BASE 0xBFE5C020
  116. #define PWM3_BASE 0xBFE5C030
  117. #define WDT_BASE 0xBFE5C060
  118. #define RTC_BASE 0xBFE64000
  119. #define I2C1_BASE 0xBFE68000
  120. #define I2C2_BASE 0xBFE70000
  121. #define AC97_BASE 0xBFE74000
  122. #define NAND_BASE 0xBFE78000
  123. #define SPI_BASE 0xBFE80000
  124. #define CAN1_BASE 0xBF004300
  125. #define CAN0_BASE 0xBF004400
  126. /* Watch Dog registers */
  127. #define WDT_EN __REG32(WDT_BASE + 0x00)
  128. #define WDT_SET __REG32(WDT_BASE + 0x04)
  129. #define WDT_TIMER __REG32(WDT_BASE + 0x08)
  130. #define PLL_FREQ __REG32(0xbfe78030)
  131. #define PLL_DIV_PARAM __REG32(0xbfe78034)
  132. #endif