board.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * Copyright (c) 2006-2018, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. */
  9. #include <rthw.h>
  10. #include <rtthread.h>
  11. #include "board.h"
  12. #include "tick.h"
  13. #include "drv_uart.h"
  14. #include "encoding.h"
  15. #include "fpioa.h"
  16. #include "dmac.h"
  17. #include "uarths.h"
  18. void rt_hw_console_output(const char *str)
  19. {
  20. uarths_puts(str);
  21. return ;
  22. }
  23. void init_bss(void)
  24. {
  25. unsigned int *dst;
  26. dst = &__bss_start;
  27. while (dst < &__bss_end)
  28. {
  29. *dst++ = 0;
  30. }
  31. }
  32. void primary_cpu_entry(void)
  33. {
  34. extern void entry(void);
  35. /* disable global interrupt */
  36. init_bss();
  37. rt_hw_interrupt_disable();
  38. entry();
  39. }
  40. #include <clint.h>
  41. #include <sysctl.h>
  42. int freq(void)
  43. {
  44. rt_uint64_t value = 0;
  45. value = sysctl_clock_get_freq(SYSCTL_CLOCK_PLL0);
  46. rt_kprintf("PLL0: %d\n", value);
  47. value = sysctl_clock_get_freq(SYSCTL_CLOCK_PLL1);
  48. rt_kprintf("PLL1: %d\n", value);
  49. value = sysctl_clock_get_freq(SYSCTL_CLOCK_PLL2);
  50. rt_kprintf("PLL2: %d\n", value);
  51. value = sysctl_clock_get_freq(SYSCTL_CLOCK_CPU);
  52. rt_kprintf("CPU : %d\n", value);
  53. value = sysctl_clock_get_freq(SYSCTL_CLOCK_APB0);
  54. rt_kprintf("APB0: %d\n", value);
  55. value = sysctl_clock_get_freq(SYSCTL_CLOCK_APB1);
  56. rt_kprintf("APB1: %d\n", value);
  57. value = sysctl_clock_get_freq(SYSCTL_CLOCK_APB2);
  58. rt_kprintf("APB2: %d\n", value);
  59. value = sysctl_clock_get_freq(SYSCTL_CLOCK_HCLK);
  60. rt_kprintf("HCLK: %d\n", value);
  61. value = clint_get_time();
  62. rt_kprintf("mtime: %d\n", value);
  63. return 0;
  64. }
  65. MSH_CMD_EXPORT(freq, show freq info);
  66. #ifdef RT_USING_SMP
  67. extern int rt_hw_clint_ipi_enable(void);
  68. #endif
  69. void rt_hw_board_init(void)
  70. {
  71. /* Init FPIOA */
  72. fpioa_init();
  73. /* Dmac init */
  74. dmac_init();
  75. /* initalize interrupt */
  76. rt_hw_interrupt_init();
  77. /* initialize hardware interrupt */
  78. rt_hw_uart_init();
  79. rt_hw_tick_init();
  80. #ifdef RT_USING_SMP
  81. rt_hw_clint_ipi_enable();
  82. #endif
  83. #ifdef RT_USING_CONSOLE
  84. /* set console device */
  85. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  86. #endif /* RT_USING_CONSOLE */
  87. #ifdef RT_USING_HEAP
  88. rt_kprintf("heap: [0x%08x - 0x%08x]\n", (rt_ubase_t) RT_HW_HEAP_BEGIN, (rt_ubase_t) RT_HW_HEAP_END);
  89. /* initialize memory system */
  90. rt_system_heap_init(RT_HW_HEAP_BEGIN, RT_HW_HEAP_END);
  91. #endif
  92. #ifdef RT_USING_COMPONENTS_INIT
  93. rt_components_board_init();
  94. #endif
  95. }