huangcm
2025-07-03 a76b2fadf6ad4adf86e241e3753a63efe03ef80c
feat(fix): close ar100s uart7 debug
2 files added
8 files modified
219 ■■■■ changed files
longan/brandy/arisc/ar100s/.config 6 ●●●● patch | view | raw | blame | history
longan/brandy/arisc/ar100s/driver/pmu/pmu_tcs4838.c 83 ●●●●● patch | view | raw | blame | history
longan/brandy/arisc/ar100s/driver/uart/uart.c 4 ●●●● patch | view | raw | blame | history
longan/brandy/arisc/ar100s/include/config/auto.conf 4 ●●●● patch | view | raw | blame | history
longan/brandy/arisc/ar100s/include/driver/dfs.h 31 ●●●●● patch | view | raw | blame | history
longan/brandy/arisc/ar100s/include/generated/autoconf.h 4 ●●●● patch | view | raw | blame | history
longan/brandy/arisc/ar100s/include/system/debugger.h 45 ●●●●● patch | view | raw | blame | history
longan/brandy/arisc/ar100s/system/debugger/Kconfig 8 ●●●● patch | view | raw | blame | history
longan/brandy/arisc/ar100s/system/debugger/debugger.c 32 ●●●●● patch | view | raw | blame | history
longan/brandy/arisc/ar100s/system/debugger/debugger_i.h 2 ●●●●● patch | view | raw | blame | history
longan/brandy/arisc/ar100s/.config
....@@ -37,11 +37,7 @@
3737 #
3838 # debug printk function
3939 #
40
-CFG_DEBUGGER_PRINTF=y
41
-CFG_DEBUG_ERR=y
42
-CFG_DEBUG_LOG=y
43
-CFG_DEBUG_WRN=y
44
-# CFG_DEBUG_INF is not set
40
+# CFG_DEBUGGER_PRINTF is not set
4541
4642 #
4743 # shell function
longan/brandy/arisc/ar100s/driver/pmu/pmu_tcs4838.c
....@@ -0,0 +1,83 @@
1
+/*
2
+*********************************************************************************************************
3
+* AR100 SYSTEM
4
+* AR100 Software System Develop Kits
5
+* pmu module
6
+*
7
+* (c) Copyright 2012-2016, Sunny China
8
+* All Rights Reserved
9
+*
10
+* File : pmu.c
11
+* By : Sunny
12
+* Version : v1.0
13
+* Date : 2012-5-22
14
+* Descript: power management unit.
15
+* Update : date auther ver notes
16
+* 2012-5-22 13:33:03 Sunny 1.0 Create this file.
17
+*********************************************************************************************************
18
+*/
19
+
20
+#include "pmu_i.h"
21
+
22
+/**
23
+ * tcs4838 voltages info table,
24
+ * the index of table is voltage type.
25
+ */
26
+pmu_onoff_reg_bitmap_t tcs4838_onoff_reg_bitmap[] = {
27
+ //dev_addr //reg_addr //offset //state //dvm_en
28
+ {RSB_RTSADDR_TCS4838, TCS4838_VSEL0, 7, 1, 0},//TCS4838_DCDC0
29
+ {RSB_RTSADDR_TCS4838, TCS4838_VSEL1, 7, 1, 0},//TCS4838_DCDC1
30
+};
31
+
32
+/**
33
+ * tcs4838 check,
34
+ */
35
+s32 tcs4838_is_exist(void)
36
+{
37
+ u8 devaddr;
38
+ u8 regaddr;
39
+ u8 data;
40
+
41
+ devaddr = RSB_RTSADDR_TCS4838;
42
+ regaddr = TCS4838_ID1;
43
+
44
+ pmu_reg_read(&devaddr, &regaddr, &data, 1);
45
+ data &= 0xE0;
46
+
47
+ if (data == 0x80) {
48
+ return TRUE;
49
+ }
50
+
51
+ return FALSE;
52
+}
53
+
54
+/**
55
+ * tcs4838 specific function,
56
+ */
57
+
58
+s32 tcs4838_pmu_set_voltage_state(u32 type, u32 state)
59
+{
60
+ u8 devaddr;
61
+ u8 regaddr;
62
+ u8 data;
63
+ u32 offset;
64
+
65
+ devaddr = tcs4838_onoff_reg_bitmap[type].devaddr;
66
+ regaddr = tcs4838_onoff_reg_bitmap[type].regaddr;
67
+ offset = tcs4838_onoff_reg_bitmap[type].offset;
68
+// tcs4838_onoff_reg_bitmap[type].state = state;
69
+
70
+ //read-modify-write
71
+ pmu_reg_read(&devaddr, &regaddr, &data, 1);
72
+ data &= (~(1 << offset));
73
+ data |= (state << offset);
74
+ pmu_reg_write(&devaddr, &regaddr, &data, 1);
75
+
76
+ if (state == POWER_VOL_ON) {
77
+ //delay 1ms for open PMU output
78
+ time_mdelay(1);
79
+ }
80
+
81
+ return OK;
82
+}
83
+
longan/brandy/arisc/ar100s/driver/uart/uart.c
....@@ -7,7 +7,7 @@
77 */
88 #include "uart_i.h"
99
10
-volatile u32 uart_pin_not_used = 0;
10
+volatile u32 uart_pin_not_used = 1;
1111 volatile u32 uart_lock = 1;
1212 volatile static u32 uart_rate;
1313
....@@ -115,7 +115,7 @@
115115 s32 uart_exit(void)
116116 {
117117 uart_lock = 1;
118
- uart_pin_not_used = 0;
118
+ uart_pin_not_used = 1;
119119
120120 pin_set_multi_sel(PIN_GRP_PL, 2, 7);
121121 pin_set_multi_sel(PIN_GRP_PL, 3, 7);
longan/brandy/arisc/ar100s/include/config/auto.conf
....@@ -5,15 +5,11 @@
55 CFG_OPENRISC=y
66 CFG_PMU_USED=y
77 CFG_SUN50IW10P1=y
8
-CFG_DEBUG_WRN=y
9
-CFG_DEBUG_ERR=y
108 CFG_AR100S_OS=y
11
-CFG_DEBUGGER_PRINTF=y
129 CFG_EVB_PLATFORM=y
1310 CFG_AXP803_USED=y
1411 CFG_STANDBY_SERVICE=y
1512 CFG_CPUX_ARM64=y
1613 CFG_TWI_USED=y
1714 CFG_WATCHDOG_USED=y
18
-CFG_DEBUG_LOG=y
1915 CFG_FDT_USED=y
longan/brandy/arisc/ar100s/include/driver/dfs.h
....@@ -0,0 +1,31 @@
1
+/*
2
+*******************************************************************************
3
+* AR100 SYSTEM
4
+* AR100 Software System Develop Kits
5
+* dram module
6
+*
7
+* (c) Copyright 2012-2016, Sunny China
8
+* All Rights Reserved
9
+*
10
+* File : dfs.h
11
+* By : Fanqh
12
+* Version : v1.0
13
+* Date : 2022-1-10
14
+* Descript: dram dfs header.
15
+* Update : date auther ver notes
16
+* 2022-1-10 10:28:51 Fanqh 1.0 Create this file.
17
+********************************************************************************
18
+*/
19
+#ifndef __DFS_H__
20
+#define __DFS_H__
21
+
22
+#include <driver/timer.h>
23
+#include <driver/dram.h>
24
+#include <system/para.h>
25
+
26
+#ifdef CFG_DRAMFREQ_USED
27
+extern int mctl_mdfs_software(__dram_para_t *para, unsigned int freq_id);
28
+#else
29
+static inline int mctl_mdfs_software(__dram_para_t *para, unsigned int freq_id) { return -1; }
30
+#endif
31
+#endif
longan/brandy/arisc/ar100s/include/generated/autoconf.h
....@@ -7,15 +7,11 @@
77 #define CFG_OPENRISC 1
88 #define CFG_PMU_USED 1
99 #define CFG_SUN50IW10P1 1
10
-#define CFG_DEBUG_WRN 1
11
-#define CFG_DEBUG_ERR 1
1210 #define CFG_AR100S_OS 1
13
-#define CFG_DEBUGGER_PRINTF 1
1411 #define CFG_EVB_PLATFORM 1
1512 #define CFG_AXP803_USED 1
1613 #define CFG_STANDBY_SERVICE 1
1714 #define CFG_CPUX_ARM64 1
1815 #define CFG_TWI_USED 1
1916 #define CFG_WATCHDOG_USED 1
20
-#define CFG_DEBUG_LOG 1
2117 #define CFG_FDT_USED 1
longan/brandy/arisc/ar100s/include/system/debugger.h
....@@ -22,7 +22,8 @@
2222
2323 /* extern u32 debug_level; */
2424
25
-#ifdef CFG_DEBUGGER_PRINTF
25
+#define ENOSYS 88
26
+// #ifdef CFG_DEBUGGER_PRINTF
2627 /*
2728 *********************************************************************************************************
2829 * INITIALIZE DEBUGGER
....@@ -111,47 +112,5 @@
111112 */
112113 s32 set_debug_level(u32 level);
113114
114
-#else
115
-static inline s32 debugger_init(void)
116
-{
117
- return -ENOSYS;
118
-}
119
-
120
-static inline s32 debugger_exit(void)
121
-{
122
- return -ENOSYS;
123
-}
124
-
125
-static inline s32 debugger_putc(char ch)
126
-{
127
- return -ENOSYS;
128
-}
129
-
130
-static inline u32 debugger_get(char *buf)
131
-{
132
- return -ENOSYS;
133
-}
134
-
135
-static inline s32 debugger_puts(char *string)
136
-{
137
- return -ENOSYS;
138
-}
139
-
140
-static inline s32 debugger_printf(u32 level, const char *format, ...)
141
-{
142
- return -ENOSYS;
143
-}
144
-
145
-static inline s32 vprintk(u32 level, const char *format, va_list args)
146
-{
147
- return -ENOSYS;
148
-}
149
-
150
-static inline s32 set_debug_level(u32 level)
151
-{
152
- return -ENOSYS;
153
-}
154
-
155
-#endif
156115
157116 #endif /* __DEBUGGER_H__ */
longan/brandy/arisc/ar100s/system/debugger/Kconfig
....@@ -5,21 +5,21 @@
55
66 config DEBUGGER_PRINTF
77 bool "debugger printf support"
8
- default y
8
+ default n
99
1010 if DEBUGGER_PRINTF
1111
1212 config DEBUG_ERR
1313 bool "err debug support"
14
- default y
14
+ default n
1515
1616 config DEBUG_LOG
1717 bool "log debug support"
18
- default y
18
+ default n
1919
2020 config DEBUG_WRN
2121 bool "warn debug support"
22
- default y
22
+ default n
2323
2424 config DEBUG_INF
2525 bool "inf debug support"
longan/brandy/arisc/ar100s/system/debugger/debugger.c
....@@ -35,6 +35,7 @@
3535 */
3636 s32 debugger_init(void)
3737 {
38
+#ifdef CFG_DEBUGGER_PRINTF
3839 /* initialize serial module */
3940 uart_init();
4041 #ifdef CFG_SHELL_USED
....@@ -44,6 +45,9 @@
4445 #endif
4546
4647 return OK;
48
+#else
49
+ return -ENOSYS;
50
+#endif
4751 }
4852
4953 /*
....@@ -59,7 +63,11 @@
5963 */
6064 s32 debugger_exit(void)
6165 {
66
+#ifdef CFG_DEBUGGER_PRINTF
6267 return OK;
68
+#else
69
+ return -ENOSYS;
70
+#endif
6371 }
6472
6573 /*
....@@ -75,9 +83,13 @@
7583 */
7684 s32 debugger_putc(char ch)
7785 {
86
+#ifdef CFG_DEBUGGER_PRINTF
7887 uart_putc(ch);
7988
8089 return OK;
90
+#else
91
+ return -ENOSYS;
92
+#endif
8193 }
8294
8395 /*
....@@ -93,7 +105,11 @@
93105 */
94106 u32 debugger_get(char *buf)
95107 {
108
+#ifdef CFG_DEBUGGER_PRINTF
96109 return uart_get(buf);
110
+#else
111
+ return -ENOSYS;
112
+#endif
97113 }
98114
99115 /*
....@@ -109,9 +125,13 @@
109125 */
110126 s32 debugger_puts(char *string)
111127 {
128
+#ifdef CFG_DEBUGGER_PRINTF
112129 uart_puts(string);
113130
114131 return OK;
132
+#else
133
+ return -ENOSYS;
134
+#endif
115135 }
116136
117137 /*
....@@ -137,6 +157,7 @@
137157 char debugger_buffer[DEBUG_BUFFER_SIZE];
138158 s32 debugger_printf(u32 level, const char *format, ...)
139159 {
160
+#ifdef CFG_DEBUGGER_PRINTF
140161 va_list args;
141162 char string[16]; /* align by cpu word */
142163 char *pdest;
....@@ -237,8 +258,12 @@
237258 return (pdest - debugger_buffer);
238259 }
239260 return OK;
261
+#else
262
+ return -ENOSYS;
263
+#endif
240264 }
241265
266
+#ifdef CFG_DEBUGGER_PRINTF
242267 static s32 print_align(char *string, s32 len, s32 align)
243268 {
244269 /*
....@@ -254,6 +279,7 @@
254279 /* not fill anything */
255280 return 0;
256281 }
282
+#endif
257283
258284 /*
259285 *********************************************************************************************************
....@@ -266,6 +292,7 @@
266292 * Returns : OK if print current time succeeded, others if failed.
267293 *********************************************************************************************************
268294 */
295
+#ifdef CFG_DEBUGGER_PRINTF
269296 static s32 print_current_time(void)
270297 {
271298 char time[12];
....@@ -309,6 +336,7 @@
309336
310337 return OK;
311338 }
339
+#endif
312340
313341 /*
314342 *********************************************************************************************************
....@@ -323,8 +351,12 @@
323351 */
324352 s32 set_debug_level(u32 level)
325353 {
354
+#ifdef CFG_DEBUGGER_PRINTF
326355 LOG("debug_mask from %d to %d\n", debug_level, level);
327356 debug_level = level;
328357
329358 return OK;
359
+#else
360
+ return -ENOSYS;
361
+#endif
330362 }
longan/brandy/arisc/ar100s/system/debugger/debugger_i.h
....@@ -21,8 +21,10 @@
2121
2222 #include "include.h"
2323
24
+#ifdef CFG_DEBUGGER_PRINTF
2425 static s32 print_align(char *string, s32 len, s32 align);
2526 static s32 print_current_time(void);
27
+#endif
2628
2729
2830 #endif /* __DEBUGGER_I_H__ */