forked from xuos/xiuos
support lt768 lcd
This commit is contained in:
+49
@@ -0,0 +1,49 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||
#
|
||||
|
||||
comment "K210 Configuration Options"
|
||||
|
||||
menu "K210 Peripheral Support"
|
||||
|
||||
# These "hidden" settings determine whether a peripheral option is available
|
||||
# for the selected MCU
|
||||
|
||||
config K210_HAVE_UART0
|
||||
bool
|
||||
default y
|
||||
select UART0_SERIALDRIVER
|
||||
select ARCH_HAVE_SERIAL_TERMIOS
|
||||
|
||||
# These are the peripheral selections proper
|
||||
|
||||
config K210_UART0
|
||||
bool "UART0"
|
||||
default y
|
||||
select ARCH_HAVE_UART0
|
||||
select ARCH_HAVE_SERIAL_TERMIOS
|
||||
select K210_UART
|
||||
|
||||
config K210_HAVE_LCD
|
||||
bool
|
||||
default n
|
||||
|
||||
config K210_LCD
|
||||
bool "LCD"
|
||||
default n
|
||||
select K210_HAVE_LCD
|
||||
|
||||
config K210_LCD_BACKLIGHT
|
||||
bool "LCD BACKLIGHT"
|
||||
default n
|
||||
|
||||
endmenu
|
||||
|
||||
menu "K210 Others"
|
||||
|
||||
config K210_WITH_QEMU
|
||||
bool "qemu support"
|
||||
default n
|
||||
|
||||
endmenu
|
||||
@@ -57,6 +57,7 @@ CHIP_CSRCS = k210_allocateheap.c k210_clockconfig.c
|
||||
CHIP_CSRCS += k210_irq.c k210_irq_dispatch.c k210_systemreset.c
|
||||
CHIP_CSRCS += k210_lowputc.c k210_serial.c k210_fpioa.c
|
||||
CHIP_CSRCS += k210_start.c k210_timerisr.c k210_gpiohs.c k210_gpio.c
|
||||
CHIP_CSRCS += k210_sysctl.c
|
||||
|
||||
ifeq ($(CONFIG_BUILD_PROTECTED),y)
|
||||
CMN_CSRCS += riscv_task_start.c riscv_pthread_start.c
|
||||
|
||||
+1329
File diff suppressed because it is too large
Load Diff
Executable
+153
@@ -0,0 +1,153 @@
|
||||
/****************************************************************************
|
||||
* arch/risc-v/src/k210/k210_clockconfig.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/arch.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "riscv_internal.h"
|
||||
#include "k210_clockconfig.h"
|
||||
#include "k210_sysctl.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define OSC_FREQ 26000000UL
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static uint32_t g_cpu_clock = 390000000;//416000000;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: k210_get_cpuclk
|
||||
****************************************************************************/
|
||||
|
||||
uint32_t k210_get_cpuclk(void)
|
||||
{
|
||||
return g_cpu_clock;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: k210_get_pll0clk
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_K210_WITH_QEMU
|
||||
uint32_t k210_get_pll0clk(void)
|
||||
{
|
||||
uint32_t pll0;
|
||||
uint32_t nr;
|
||||
uint32_t nf;
|
||||
uint32_t od;
|
||||
|
||||
pll0 = getreg32(K210_SYSCTL_PLL0);
|
||||
nr = PLL_CLK_R(pll0) + 1;
|
||||
nf = PLL_CLK_F(pll0) + 1;
|
||||
od = PLL_CLK_OD(pll0) + 1;
|
||||
|
||||
return OSC_FREQ / nr * nf / od;
|
||||
}
|
||||
|
||||
uint32_t k210_get_pll1clk(void)
|
||||
{
|
||||
uint32_t pll1;
|
||||
uint32_t nr;
|
||||
uint32_t nf;
|
||||
uint32_t od;
|
||||
|
||||
pll1 = getreg32(K210_SYSCTL_PLL1);
|
||||
nr = PLL_CLK_R(pll1) + 1;
|
||||
nf = PLL_CLK_F(pll1) + 1;
|
||||
od = PLL_CLK_OD(pll1) + 1;
|
||||
|
||||
return OSC_FREQ / nr * nf / od;
|
||||
}
|
||||
|
||||
uint32_t k210_get_pll2clk(void)
|
||||
{
|
||||
uint32_t pll2;
|
||||
uint32_t nr;
|
||||
uint32_t nf;
|
||||
uint32_t od;
|
||||
|
||||
pll2 = getreg32(K210_SYSCTL_PLL2);
|
||||
nr = PLL_CLK_R(pll2) + 1;
|
||||
nf = PLL_CLK_F(pll2) + 1;
|
||||
od = PLL_CLK_OD(pll2) + 1;
|
||||
|
||||
return OSC_FREQ / nr * nf / od;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: k210_clockconfig
|
||||
****************************************************************************/
|
||||
|
||||
void k210_clockconfig(void)
|
||||
{
|
||||
#ifndef CONFIG_K210_WITH_QEMU
|
||||
uint32_t clksel0;
|
||||
|
||||
/* Obtain clock selector for ACLK */
|
||||
clksel0 = getreg32(K210_SYSCTL_CLKSEL0);
|
||||
|
||||
if (1 == CLKSEL0_ACLK_SEL(clksel0))
|
||||
{
|
||||
/* PLL0 selected */
|
||||
g_cpu_clock = k210_get_pll0clk() / 2;
|
||||
|
||||
syslog(LOG_NOTICE, "g_cpu clock = %d sel %#x\r\n", g_cpu_clock, clksel0);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* OSC selected */
|
||||
|
||||
g_cpu_clock = OSC_FREQ;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void k210_sysctl_init(void)
|
||||
{
|
||||
// sysctl_pll_set_freq(SYSCTL_PLL0, 800000000UL);
|
||||
// sysctl_pll_set_freq(SYSCTL_PLL1, 400000000UL);
|
||||
// sysctl_pll_set_freq(SYSCTL_PLL2, 45158400UL);
|
||||
sysctl_clock_set_threshold(SYSCTL_THRESHOLD_APB1, 2);
|
||||
|
||||
// sysctl_set_power_mode(SYSCTL_POWER_BANK0, SYSCTL_POWER_V18);
|
||||
// sysctl_set_power_mode(SYSCTL_POWER_BANK1, SYSCTL_POWER_V18);
|
||||
// sysctl_set_power_mode(SYSCTL_POWER_BANK2, SYSCTL_POWER_V18);
|
||||
}
|
||||
Executable
+67
@@ -0,0 +1,67 @@
|
||||
/****************************************************************************
|
||||
* arch/risc-v/src/k210/k210_clockconfig.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ARCH_RISCV_SRC_K210_K210_CLOCKCONFIG_H
|
||||
#define __ARCH_RISCV_SRC_K210_K210_CLOCKCONFIG_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include "k210_memorymap.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
EXTERN uint32_t k210_get_cpuclk(void);
|
||||
EXTERN uint32_t k210_get_pll0clk(void);
|
||||
EXTERN void k210_clockconfig(void);
|
||||
EXTERN void k210_sysctl_init(void);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
#undef EXTERN
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __ARCH_RISCV_SRC_K210_K210_CLOCKCONFIG_H */
|
||||
@@ -38,6 +38,8 @@
|
||||
#include <stdbool.h>
|
||||
#include "k210_gpio_common.h"
|
||||
|
||||
#define HS_GPIO(n) (K210_IO_FUNC_GPIOHS0 + n)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
Executable
+50
@@ -0,0 +1,50 @@
|
||||
/****************************************************************************
|
||||
* arch/risc-v/src/k210/k210_memorymap.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ARCH_RISCV_SRC_K210_K210_MEMORYMAP_H
|
||||
#define __ARCH_RISCV_SRC_K210_K210_MEMORYMAP_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include "riscv_internal.h"
|
||||
#include "hardware/k210_memorymap.h"
|
||||
#include "hardware/k210_uart.h"
|
||||
#include "hardware/k210_clint.h"
|
||||
#include "hardware/k210_plic.h"
|
||||
//#include "hardware/k210_sysctl.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Idle thread stack starts from _ebss */
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
#define K210_IDLESTACK_BASE (uintptr_t)&_ebss
|
||||
#else
|
||||
#define K210_IDLESTACK_BASE _ebss
|
||||
#endif
|
||||
|
||||
#define K210_IDLESTACK0_BASE (K210_IDLESTACK_BASE)
|
||||
#define K210_IDLESTACK0_TOP (K210_IDLESTACK0_BASE + CONFIG_IDLETHREAD_STACKSIZE)
|
||||
|
||||
#endif /* __ARCH_RISCV_SRC_K210_K210_MEMORYMAP_H */
|
||||
+1853
File diff suppressed because it is too large
Load Diff
+1097
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user