From a76b2fadf6ad4adf86e241e3753a63efe03ef80c Mon Sep 17 00:00:00 2001 From: huangcm <1263938474@qq.com> Date: Thu, 03 Jul 2025 02:49:16 +0000 Subject: [PATCH] feat(fix): close ar100s uart7 debug --- longan/brandy/arisc/ar100s/system/debugger/Kconfig | 8 +- longan/brandy/arisc/ar100s/system/debugger/debugger_i.h | 2 longan/brandy/arisc/ar100s/include/system/debugger.h | 45 ---------- longan/brandy/arisc/ar100s/driver/uart/uart.c | 4 longan/brandy/arisc/ar100s/include/driver/dfs.h | 31 +++++++ longan/brandy/arisc/ar100s/driver/pmu/pmu_tcs4838.c | 83 ++++++++++++++++++++ longan/brandy/arisc/ar100s/system/debugger/debugger.c | 32 ++++++++ longan/brandy/arisc/ar100s/include/config/auto.conf | 4 - longan/brandy/arisc/ar100s/include/generated/autoconf.h | 4 - longan/brandy/arisc/ar100s/.config | 6 - 10 files changed, 157 insertions(+), 62 deletions(-) diff --git a/longan/brandy/arisc/ar100s/.config b/longan/brandy/arisc/ar100s/.config index f28e527..6819289 100644 --- a/longan/brandy/arisc/ar100s/.config +++ b/longan/brandy/arisc/ar100s/.config @@ -37,11 +37,7 @@ # # debug printk function # -CFG_DEBUGGER_PRINTF=y -CFG_DEBUG_ERR=y -CFG_DEBUG_LOG=y -CFG_DEBUG_WRN=y -# CFG_DEBUG_INF is not set +# CFG_DEBUGGER_PRINTF is not set # # shell function diff --git a/longan/brandy/arisc/ar100s/driver/pmu/pmu_tcs4838.c b/longan/brandy/arisc/ar100s/driver/pmu/pmu_tcs4838.c new file mode 100644 index 0000000..6877bbf --- /dev/null +++ b/longan/brandy/arisc/ar100s/driver/pmu/pmu_tcs4838.c @@ -0,0 +1,83 @@ +/* +********************************************************************************************************* +* AR100 SYSTEM +* AR100 Software System Develop Kits +* pmu module +* +* (c) Copyright 2012-2016, Sunny China +* All Rights Reserved +* +* File : pmu.c +* By : Sunny +* Version : v1.0 +* Date : 2012-5-22 +* Descript: power management unit. +* Update : date auther ver notes +* 2012-5-22 13:33:03 Sunny 1.0 Create this file. +********************************************************************************************************* +*/ + +#include "pmu_i.h" + +/** + * tcs4838 voltages info table, + * the index of table is voltage type. + */ +pmu_onoff_reg_bitmap_t tcs4838_onoff_reg_bitmap[] = { + //dev_addr //reg_addr //offset //state //dvm_en + {RSB_RTSADDR_TCS4838, TCS4838_VSEL0, 7, 1, 0},//TCS4838_DCDC0 + {RSB_RTSADDR_TCS4838, TCS4838_VSEL1, 7, 1, 0},//TCS4838_DCDC1 +}; + +/** + * tcs4838 check, + */ +s32 tcs4838_is_exist(void) +{ + u8 devaddr; + u8 regaddr; + u8 data; + + devaddr = RSB_RTSADDR_TCS4838; + regaddr = TCS4838_ID1; + + pmu_reg_read(&devaddr, ®addr, &data, 1); + data &= 0xE0; + + if (data == 0x80) { + return TRUE; + } + + return FALSE; +} + +/** + * tcs4838 specific function, + */ + +s32 tcs4838_pmu_set_voltage_state(u32 type, u32 state) +{ + u8 devaddr; + u8 regaddr; + u8 data; + u32 offset; + + devaddr = tcs4838_onoff_reg_bitmap[type].devaddr; + regaddr = tcs4838_onoff_reg_bitmap[type].regaddr; + offset = tcs4838_onoff_reg_bitmap[type].offset; +// tcs4838_onoff_reg_bitmap[type].state = state; + + //read-modify-write + pmu_reg_read(&devaddr, ®addr, &data, 1); + data &= (~(1 << offset)); + data |= (state << offset); + pmu_reg_write(&devaddr, ®addr, &data, 1); + + if (state == POWER_VOL_ON) { + //delay 1ms for open PMU output + time_mdelay(1); + } + + return OK; +} + diff --git a/longan/brandy/arisc/ar100s/driver/uart/uart.c b/longan/brandy/arisc/ar100s/driver/uart/uart.c index f608343..4957799 100644 --- a/longan/brandy/arisc/ar100s/driver/uart/uart.c +++ b/longan/brandy/arisc/ar100s/driver/uart/uart.c @@ -7,7 +7,7 @@ */ #include "uart_i.h" -volatile u32 uart_pin_not_used = 0; +volatile u32 uart_pin_not_used = 1; volatile u32 uart_lock = 1; volatile static u32 uart_rate; @@ -115,7 +115,7 @@ s32 uart_exit(void) { uart_lock = 1; - uart_pin_not_used = 0; + uart_pin_not_used = 1; pin_set_multi_sel(PIN_GRP_PL, 2, 7); pin_set_multi_sel(PIN_GRP_PL, 3, 7); diff --git a/longan/brandy/arisc/ar100s/include/config/auto.conf b/longan/brandy/arisc/ar100s/include/config/auto.conf index 6ed26d9..9ee1d18 100644 --- a/longan/brandy/arisc/ar100s/include/config/auto.conf +++ b/longan/brandy/arisc/ar100s/include/config/auto.conf @@ -5,15 +5,11 @@ CFG_OPENRISC=y CFG_PMU_USED=y CFG_SUN50IW10P1=y -CFG_DEBUG_WRN=y -CFG_DEBUG_ERR=y CFG_AR100S_OS=y -CFG_DEBUGGER_PRINTF=y CFG_EVB_PLATFORM=y CFG_AXP803_USED=y CFG_STANDBY_SERVICE=y CFG_CPUX_ARM64=y CFG_TWI_USED=y CFG_WATCHDOG_USED=y -CFG_DEBUG_LOG=y CFG_FDT_USED=y diff --git a/longan/brandy/arisc/ar100s/include/driver/dfs.h b/longan/brandy/arisc/ar100s/include/driver/dfs.h new file mode 100644 index 0000000..41d3b6b --- /dev/null +++ b/longan/brandy/arisc/ar100s/include/driver/dfs.h @@ -0,0 +1,31 @@ +/* +******************************************************************************* +* AR100 SYSTEM +* AR100 Software System Develop Kits +* dram module +* +* (c) Copyright 2012-2016, Sunny China +* All Rights Reserved +* +* File : dfs.h +* By : Fanqh +* Version : v1.0 +* Date : 2022-1-10 +* Descript: dram dfs header. +* Update : date auther ver notes +* 2022-1-10 10:28:51 Fanqh 1.0 Create this file. +******************************************************************************** +*/ +#ifndef __DFS_H__ +#define __DFS_H__ + +#include <driver/timer.h> +#include <driver/dram.h> +#include <system/para.h> + +#ifdef CFG_DRAMFREQ_USED +extern int mctl_mdfs_software(__dram_para_t *para, unsigned int freq_id); +#else +static inline int mctl_mdfs_software(__dram_para_t *para, unsigned int freq_id) { return -1; } +#endif +#endif diff --git a/longan/brandy/arisc/ar100s/include/generated/autoconf.h b/longan/brandy/arisc/ar100s/include/generated/autoconf.h index a45360b..a5c12f1 100644 --- a/longan/brandy/arisc/ar100s/include/generated/autoconf.h +++ b/longan/brandy/arisc/ar100s/include/generated/autoconf.h @@ -7,15 +7,11 @@ #define CFG_OPENRISC 1 #define CFG_PMU_USED 1 #define CFG_SUN50IW10P1 1 -#define CFG_DEBUG_WRN 1 -#define CFG_DEBUG_ERR 1 #define CFG_AR100S_OS 1 -#define CFG_DEBUGGER_PRINTF 1 #define CFG_EVB_PLATFORM 1 #define CFG_AXP803_USED 1 #define CFG_STANDBY_SERVICE 1 #define CFG_CPUX_ARM64 1 #define CFG_TWI_USED 1 #define CFG_WATCHDOG_USED 1 -#define CFG_DEBUG_LOG 1 #define CFG_FDT_USED 1 diff --git a/longan/brandy/arisc/ar100s/include/system/debugger.h b/longan/brandy/arisc/ar100s/include/system/debugger.h index 3621d78..932f2a2 100644 --- a/longan/brandy/arisc/ar100s/include/system/debugger.h +++ b/longan/brandy/arisc/ar100s/include/system/debugger.h @@ -22,7 +22,8 @@ /* extern u32 debug_level; */ -#ifdef CFG_DEBUGGER_PRINTF +#define ENOSYS 88 +// #ifdef CFG_DEBUGGER_PRINTF /* ********************************************************************************************************* * INITIALIZE DEBUGGER @@ -111,47 +112,5 @@ */ s32 set_debug_level(u32 level); -#else -static inline s32 debugger_init(void) -{ - return -ENOSYS; -} - -static inline s32 debugger_exit(void) -{ - return -ENOSYS; -} - -static inline s32 debugger_putc(char ch) -{ - return -ENOSYS; -} - -static inline u32 debugger_get(char *buf) -{ - return -ENOSYS; -} - -static inline s32 debugger_puts(char *string) -{ - return -ENOSYS; -} - -static inline s32 debugger_printf(u32 level, const char *format, ...) -{ - return -ENOSYS; -} - -static inline s32 vprintk(u32 level, const char *format, va_list args) -{ - return -ENOSYS; -} - -static inline s32 set_debug_level(u32 level) -{ - return -ENOSYS; -} - -#endif #endif /* __DEBUGGER_H__ */ diff --git a/longan/brandy/arisc/ar100s/system/debugger/Kconfig b/longan/brandy/arisc/ar100s/system/debugger/Kconfig index 9f5400f..3eb806b 100644 --- a/longan/brandy/arisc/ar100s/system/debugger/Kconfig +++ b/longan/brandy/arisc/ar100s/system/debugger/Kconfig @@ -5,21 +5,21 @@ config DEBUGGER_PRINTF bool "debugger printf support" - default y + default n if DEBUGGER_PRINTF config DEBUG_ERR bool "err debug support" - default y + default n config DEBUG_LOG bool "log debug support" - default y + default n config DEBUG_WRN bool "warn debug support" - default y + default n config DEBUG_INF bool "inf debug support" diff --git a/longan/brandy/arisc/ar100s/system/debugger/debugger.c b/longan/brandy/arisc/ar100s/system/debugger/debugger.c index d5e14d0..e9e5fc2 100644 --- a/longan/brandy/arisc/ar100s/system/debugger/debugger.c +++ b/longan/brandy/arisc/ar100s/system/debugger/debugger.c @@ -35,6 +35,7 @@ */ s32 debugger_init(void) { +#ifdef CFG_DEBUGGER_PRINTF /* initialize serial module */ uart_init(); #ifdef CFG_SHELL_USED @@ -44,6 +45,9 @@ #endif return OK; +#else + return -ENOSYS; +#endif } /* @@ -59,7 +63,11 @@ */ s32 debugger_exit(void) { +#ifdef CFG_DEBUGGER_PRINTF return OK; +#else + return -ENOSYS; +#endif } /* @@ -75,9 +83,13 @@ */ s32 debugger_putc(char ch) { +#ifdef CFG_DEBUGGER_PRINTF uart_putc(ch); return OK; +#else + return -ENOSYS; +#endif } /* @@ -93,7 +105,11 @@ */ u32 debugger_get(char *buf) { +#ifdef CFG_DEBUGGER_PRINTF return uart_get(buf); +#else + return -ENOSYS; +#endif } /* @@ -109,9 +125,13 @@ */ s32 debugger_puts(char *string) { +#ifdef CFG_DEBUGGER_PRINTF uart_puts(string); return OK; +#else + return -ENOSYS; +#endif } /* @@ -137,6 +157,7 @@ char debugger_buffer[DEBUG_BUFFER_SIZE]; s32 debugger_printf(u32 level, const char *format, ...) { +#ifdef CFG_DEBUGGER_PRINTF va_list args; char string[16]; /* align by cpu word */ char *pdest; @@ -237,8 +258,12 @@ return (pdest - debugger_buffer); } return OK; +#else + return -ENOSYS; +#endif } +#ifdef CFG_DEBUGGER_PRINTF static s32 print_align(char *string, s32 len, s32 align) { /* @@ -254,6 +279,7 @@ /* not fill anything */ return 0; } +#endif /* ********************************************************************************************************* @@ -266,6 +292,7 @@ * Returns : OK if print current time succeeded, others if failed. ********************************************************************************************************* */ +#ifdef CFG_DEBUGGER_PRINTF static s32 print_current_time(void) { char time[12]; @@ -309,6 +336,7 @@ return OK; } +#endif /* ********************************************************************************************************* @@ -323,8 +351,12 @@ */ s32 set_debug_level(u32 level) { +#ifdef CFG_DEBUGGER_PRINTF LOG("debug_mask from %d to %d\n", debug_level, level); debug_level = level; return OK; +#else + return -ENOSYS; +#endif } diff --git a/longan/brandy/arisc/ar100s/system/debugger/debugger_i.h b/longan/brandy/arisc/ar100s/system/debugger/debugger_i.h index 20e5c66..30eda01 100644 --- a/longan/brandy/arisc/ar100s/system/debugger/debugger_i.h +++ b/longan/brandy/arisc/ar100s/system/debugger/debugger_i.h @@ -21,8 +21,10 @@ #include "include.h" +#ifdef CFG_DEBUGGER_PRINTF static s32 print_align(char *string, s32 len, s32 align); static s32 print_current_time(void); +#endif #endif /* __DEBUGGER_I_H__ */ -- Gitblit v1.6.2