[bsp][cvitek] Initialize the Milk-V Duo 256M using the device tree (#8841)

Initialize the board using the device tree
This commit is contained in:
liYangYang 2024-04-23 23:09:45 +08:00 committed by GitHub
parent ee8c61126d
commit 62544df564
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 58 additions and 28 deletions

View File

@ -33,11 +33,14 @@ CONFIG_RT_TIMER_THREAD_STACK_SIZE=8192
#
# kservice optimization
#
CONFIG_RT_KSERVICE_USING_STDLIB=y
# CONFIG_RT_KSERVICE_USING_STDLIB_MEMORY is not set
# CONFIG_RT_KSERVICE_USING_TINY_SIZE is not set
# CONFIG_RT_USING_TINY_FFS is not set
CONFIG_RT_KPRINTF_USING_LONGLONG=y
#
# klibc optimization
#
# CONFIG_RT_KLIBC_USING_STDLIB is not set
# CONFIG_RT_KLIBC_USING_TINY_SIZE is not set
CONFIG_RT_KLIBC_USING_PRINTF_LONGLONG=y
CONFIG_RT_USING_DEBUG=y
CONFIG_RT_DEBUGING_COLOR=y
CONFIG_RT_DEBUGING_CONTEXT=y
@ -82,7 +85,7 @@ CONFIG_RT_USING_SCHED_THREAD_CTX=y
CONFIG_RT_USING_CONSOLE=y
CONFIG_RT_CONSOLEBUF_SIZE=256
CONFIG_RT_CONSOLE_DEVICE_NAME="uart0"
CONFIG_RT_VER_NUM=0x50100
CONFIG_RT_VER_NUM=0x50200
CONFIG_RT_USING_STDC_ATOMIC=y
CONFIG_RT_BACKTRACE_LEVEL_MAX_NR=32
@ -173,7 +176,7 @@ CONFIG_RT_USING_DFS_ROMFS=y
#
# Device Drivers
#
# CONFIG_RT_USING_DM is not set
CONFIG_RT_USING_DM=y
CONFIG_RT_USING_DEVICE_IPC=y
CONFIG_RT_UNAMED_PIPE_NUMBER=64
CONFIG_RT_USING_SYSTEM_WORKQUEUE=y
@ -224,8 +227,14 @@ CONFIG_RT_USING_VIRTIO_CONSOLE=y
CONFIG_RT_USING_VIRTIO_CONSOLE_PORT_MAX_NR=4
CONFIG_RT_USING_VIRTIO_GPU=y
CONFIG_RT_USING_VIRTIO_INPUT=y
CONFIG_RT_USING_OFW=y
# CONFIG_RT_USING_BUILTIN_FDT is not set
CONFIG_RT_FDT_EARLYCON_MSG_SIZE=128
# CONFIG_RT_USING_PIC is not set
CONFIG_RT_USING_PIN=y
# CONFIG_RT_USING_PINCTRL is not set
CONFIG_RT_USING_KTIME=y
CONFIG_RT_USING_CLK=y
# CONFIG_RT_USING_HWTIMER is not set
#

View File

@ -14,9 +14,16 @@
#include <mm_page.h>
#include <drv_uart.h>
#include <gtimer.h>
#include <setup.h>
extern size_t MMUTable[];
#ifndef RT_USING_OFW
void idle_wfi(void)
{
asm volatile("wfi");
}
#ifdef RT_USING_SMART
struct mem_desc platform_mem_desc[] = {
{KERNEL_VADDR_START, KERNEL_VADDR_START + 0x0FFFFFFF, (rt_size_t)ARCH_MAP_FAILED, NORMAL_MEM},
@ -31,13 +38,6 @@ struct mem_desc platform_mem_desc[] =
const rt_uint32_t platform_mem_desc_size = sizeof(platform_mem_desc) / sizeof(platform_mem_desc[0]);
void idle_wfi(void)
{
asm volatile("wfi");
}
static rt_ubase_t pinmux_base = RT_NULL;
void rt_hw_board_init(void)
{
#ifdef RT_USING_SMART
@ -76,6 +76,21 @@ void rt_hw_board_init(void)
rt_components_board_init();
#endif
}
#else
void rt_hw_board_init(void)
{
rt_fdt_commit_memregion_early(&(rt_region_t)
{
.name = "memheap",
.start = (rt_size_t)rt_kmem_v2p((void *)HEAP_BEGIN),
.end = (rt_size_t)rt_kmem_v2p((void *)HEAP_END),
}, RT_TRUE);
rt_hw_common_setup();
}
#endif /* RT_USING_OFW */
static rt_ubase_t pinmux_base = RT_NULL;
rt_ubase_t pinmux_base_ioremap(void)
{

View File

@ -24,8 +24,10 @@
/* kservice optimization */
#define RT_KSERVICE_USING_STDLIB
#define RT_KPRINTF_USING_LONGLONG
/* klibc optimization */
#define RT_KLIBC_USING_PRINTF_LONGLONG
#define RT_USING_DEBUG
#define RT_DEBUGING_COLOR
#define RT_DEBUGING_CONTEXT
@ -56,7 +58,7 @@
#define RT_USING_CONSOLE
#define RT_CONSOLEBUF_SIZE 256
#define RT_CONSOLE_DEVICE_NAME "uart0"
#define RT_VER_NUM 0x50100
#define RT_VER_NUM 0x50200
#define RT_USING_STDC_ATOMIC
#define RT_BACKTRACE_LEVEL_MAX_NR 32
@ -122,6 +124,7 @@
/* Device Drivers */
#define RT_USING_DM
#define RT_USING_DEVICE_IPC
#define RT_UNAMED_PIPE_NUMBER 64
#define RT_USING_SYSTEM_WORKQUEUE
@ -145,8 +148,11 @@
#define RT_USING_VIRTIO_CONSOLE_PORT_MAX_NR 4
#define RT_USING_VIRTIO_GPU
#define RT_USING_VIRTIO_INPUT
#define RT_USING_OFW
#define RT_FDT_EARLYCON_MSG_SIZE 128
#define RT_USING_PIN
#define RT_USING_KTIME
#define RT_USING_CLK
/* Using USB */

View File

@ -252,45 +252,45 @@ int rt_hw_uart_init(void)
PINMUX_CONFIG(UART0_RX, UART0_RX);
PINMUX_CONFIG(UART0_TX, UART0_TX);
BSP_INSTALL_UART_DEVICE(0);
#if defined(ARCH_ARM) && defined(RT_USING_SMART)
#if defined(ARCH_ARM)
uart->hw_base = (rt_size_t)rt_ioremap((void*)uart->hw_base, 0x10000);
#endif /* defined(ARCH_ARM) && defined(RT_USING_SMART) */
#endif /* defined(ARCH_ARM) */
#endif
#ifdef RT_USING_UART1
PINMUX_CONFIG(IIC0_SDA, UART1_RX);
PINMUX_CONFIG(IIC0_SCL, UART1_TX);
BSP_INSTALL_UART_DEVICE(1);
#if defined(ARCH_ARM) && defined(RT_USING_SMART)
#if defined(ARCH_ARM)
uart->hw_base = (rt_size_t)rt_ioremap((void*)uart->hw_base, 0x10000);
#endif /* defined(ARCH_ARM) && defined(RT_USING_SMART) */
#endif /* defined(ARCH_ARM) */
#endif
#ifdef RT_USING_UART2
PINMUX_CONFIG(SD1_D1, UART2_RX);
PINMUX_CONFIG(SD1_D2, UART2_TX);
BSP_INSTALL_UART_DEVICE(2);
#if defined(ARCH_ARM) && defined(RT_USING_SMART)
#if defined(ARCH_ARM)
uart->hw_base = (rt_size_t)rt_ioremap((void*)uart->hw_base, 0x10000);
#endif /* defined(ARCH_ARM) && defined(RT_USING_SMART) */
#endif /* defined(ARCH_ARM) */
#endif
#ifdef RT_USING_UART3
PINMUX_CONFIG(SD1_D1, UART3_RX);
PINMUX_CONFIG(SD1_D2, UART3_TX);
BSP_INSTALL_UART_DEVICE(3);
#if defined(ARCH_ARM) && defined(RT_USING_SMART)
#if defined(ARCH_ARM)
uart->hw_base = (rt_size_t)rt_ioremap((void*)uart->hw_base, 0x10000);
#endif /* defined(ARCH_ARM) && defined(RT_USING_SMART) */
#endif /* defined(ARCH_ARM) */
#endif
#ifdef RT_USING_UART4
PINMUX_CONFIG(SD1_GP0, UART4_RX);
PINMUX_CONFIG(SD1_GP1, UART4_TX);
BSP_INSTALL_UART_DEVICE(4);
#if defined(ARCH_ARM) && defined(RT_USING_SMART)
#if defined(ARCH_ARM)
uart->hw_base = (rt_size_t)rt_ioremap((void*)uart->hw_base, 0x10000);
#endif /* defined(ARCH_ARM) && defined(RT_USING_SMART) */
#endif /* defined(ARCH_ARM) */
#endif
return 0;

View File

@ -23,12 +23,12 @@
#define PAD_MIPI_TXM0__MIPI_TXM0 0
#define PAD_MIPI_TXP0__MIPI_TXP0 0
#if defined(ARCH_ARM) && defined(RT_USING_SMART)
#if defined(ARCH_ARM)
extern rt_ubase_t pinmux_base_ioremap(void);
#define PINMUX_BASE pinmux_base_ioremap()
#else
#define PINMUX_BASE 0x03001000
#endif /* defined(ARCH_ARM) && defined(RT_USING_SMART) */
#endif /* defined(ARCH_ARM) */
#define PINMUX_MASK(PIN_NAME) FMUX_GPIO_FUNCSEL_##PIN_NAME##_MASK
#define PINMUX_OFFSET(PIN_NAME) FMUX_GPIO_FUNCSEL_##PIN_NAME##_OFFSET
#define PINMUX_VALUE(PIN_NAME, FUNC_NAME) PIN_NAME##__##FUNC_NAME