board.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #include <interrupt.h>
  2. #include <rthw.h>
  3. #include <platform.h>
  4. #if 0
  5. static struct mem_desc hw_mem_desc[] =
  6. {
  7. { 0x00000000, 0xFFFFFFFF, 0x00000000, RW_NCNB },/* None cached for 4G memory */
  8. // visual start, visual end, phy start , props
  9. { 0x00000000, 0x000FFFFF, 0x20000000, RW_CB }, /* ISR Vector table */
  10. { 0x00200000, 0x00001FFF, 0x40000000, RW_CB }, /* 8K cached SRAM 0/1 */
  11. { 0x20000000, 0x21FFFFFF, 0x20000000, RW_CB }, /* 32M cached SDRAM */
  12. { 0x90000000, 0x90001FFF, 0x40000000, RW_NCNB },/* 4K SRAM0 + 4k SRAM1 */
  13. { 0xA0000000, 0xA1FFFFFF, 0x20000000, RW_NCNB },/* 32M none-cached SDRAM */
  14. };
  15. #endif
  16. #include <encoding.h>
  17. static void rt_hw_timer_init(void)
  18. {
  19. GPIO_REG(GPIO_INPUT_EN) &= ~((0x1<< RED_LED_OFFSET) | (0x1<< GREEN_LED_OFFSET) | (0x1 << BLUE_LED_OFFSET)) ;
  20. GPIO_REG(GPIO_OUTPUT_EN) |= ((0x1<< RED_LED_OFFSET)| (0x1<< GREEN_LED_OFFSET) | (0x1 << BLUE_LED_OFFSET)) ;
  21. GPIO_REG(GPIO_OUTPUT_VAL) |= (0x1 << BLUE_LED_OFFSET) ;
  22. GPIO_REG(GPIO_OUTPUT_VAL) &= ~((0x1<< RED_LED_OFFSET) | (0x1<< GREEN_LED_OFFSET)) ;
  23. /* enable timer interrupt*/
  24. set_csr(mie, MIP_MTIP);
  25. volatile uint64_t * mtimecmp = (uint64_t*) (CLINT_CTRL_ADDR + CLINT_MTIMECMP);
  26. CLINT_REG(CLINT_MTIME) = 0x0;
  27. /* CLINT_REG(CLINT_MTIMECMP) = 0x10000;*/
  28. *mtimecmp = 0x20000;
  29. return;
  30. }
  31. void rt_hw_board_init(void)
  32. {
  33. /* initialize mmu */
  34. /* rt_hw_mmu_init(hw_mem_desc, sizeof(hw_mem_desc)/sizeof(hw_mem_desc[0]));*/
  35. /* initialize hardware interrupt */
  36. rt_hw_interrupt_init();
  37. /* initialize the system clock */
  38. //rt_hw_clock_init(); //set each pll etc.
  39. /* initialize uart */
  40. rt_hw_uart_init();
  41. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  42. /* initialize timer0 */
  43. rt_hw_timer_init();
  44. #ifdef RT_USING_COMPONENTS_INIT
  45. rt_components_board_init();
  46. #endif
  47. return;
  48. }