Skip to content

Commit 65991a8

Browse files
ene-stevenkartben
authored andcommitted
soc: ene: kb106x soc
Add ENE KB106X SoC Signed-off-by: Steven Chang <[email protected]>
1 parent e4ae7d0 commit 65991a8

File tree

18 files changed

+571
-0
lines changed

18 files changed

+571
-0
lines changed

soc/ene/kb106x/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
add_subdirectory(common)
4+
add_subdirectory(${SOC_SERIES})

soc/ene/kb106x/Kconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright (c) 2025 ENE Technology Inc.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config SOC_FAMILY_KB106X
5+
select BUILD_OUTPUT_HEX
6+
select BUILD_OUTPUT_BIN
7+
select HAS_SEGGER_RTT if ZEPHYR_SEGGER_MODULE
8+
9+
if SOC_FAMILY_KB106X
10+
11+
rsource "*/Kconfig"
12+
13+
endif # SOC_FAMILY_KB106X

soc/ene/kb106x/Kconfig.defconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright (c) 2025 ENE Technology Inc.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
if SOC_FAMILY_KB106X
5+
6+
rsource "*/Kconfig.defconfig"
7+
8+
endif # SOC_FAMILY_KB106X

soc/ene/kb106x/Kconfig.soc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright (c) 2025 ENE Technology Inc.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config SOC_FAMILY_KB106X
5+
bool
6+
7+
config SOC_FAMILY
8+
default "kb106x" if SOC_FAMILY_KB106X
9+
10+
rsource "*/Kconfig.soc"

soc/ene/kb106x/common/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
zephyr_library()
4+
zephyr_include_directories(.)
5+
zephyr_library_sources_ifdef(CONFIG_PM power.c)

soc/ene/kb106x/common/power.c

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
/*
2+
* Copyright (c) 2025 ENE Technology Inc.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/kernel.h>
8+
#include <zephyr/device.h>
9+
#include <zephyr/pm/pm.h>
10+
#include <power.h>
11+
12+
void kb106x_soc_deep_sleep(void)
13+
{
14+
#if defined(CONFIG_TRACING)
15+
sys_trace_idle();
16+
#endif
17+
/*
18+
* PRIMASK is always cleared on ARMv7-M and ARMv8-M (not used
19+
* for interrupt locking), and configuring BASEPRI to the lowest
20+
* priority to ensure wake-up will cause interrupts to be serviced
21+
* before entering low power state.
22+
*
23+
* Set PRIMASK before configuring BASEPRI to prevent interruption
24+
* before wake-up.
25+
*/
26+
__disable_irq();
27+
28+
SCB->SCR |= BIT(2);
29+
/*
30+
* Set wake-up interrupt priority to the lowest and synchronize to
31+
* ensure that this is visible to the WFI instruction.
32+
*/
33+
__set_BASEPRI(0);
34+
__ISB();
35+
36+
__DSB();
37+
__WFI();
38+
SCB->SCR &= ~BIT(2);
39+
40+
#if defined(CONFIG_TRACING)
41+
sys_trace_idle_exit();
42+
#endif
43+
__enable_irq();
44+
__ISB();
45+
}
46+
47+
void kb106x_soc_idle(void)
48+
{
49+
#if defined(CONFIG_TRACING)
50+
sys_trace_idle();
51+
#endif
52+
/*
53+
* PRIMASK is always cleared on ARMv7-M and ARMv8-M (not used
54+
* for interrupt locking), and configuring BASEPRI to the lowest
55+
* priority to ensure wake-up will cause interrupts to be serviced
56+
* before entering low power state.
57+
*
58+
* Set PRIMASK before configuring BASEPRI to prevent interruption
59+
* before wake-up.
60+
*/
61+
__disable_irq();
62+
63+
SCB->SCR &= ~BIT(2);
64+
/*
65+
* Set wake-up interrupt priority to the lowest and synchronize to
66+
* ensure that this is visible to the WFI instruction.
67+
*/
68+
__set_BASEPRI(0);
69+
__ISB();
70+
71+
__DSB();
72+
__WFI();
73+
#if defined(CONFIG_TRACING)
74+
sys_trace_idle_exit();
75+
#endif
76+
77+
__enable_irq();
78+
__ISB();
79+
}
80+
81+
__weak void pm_state_set(enum pm_state state, uint8_t substate_id)
82+
{
83+
ARG_UNUSED(substate_id);
84+
85+
switch (state) {
86+
case PM_STATE_ACTIVE:
87+
break;
88+
case PM_STATE_RUNTIME_IDLE:
89+
__fallthrough;
90+
case PM_STATE_SUSPEND_TO_IDLE:
91+
kb106x_soc_idle();
92+
break;
93+
case PM_STATE_STANDBY:
94+
__fallthrough;
95+
case PM_STATE_SUSPEND_TO_RAM:
96+
__fallthrough;
97+
case PM_STATE_SUSPEND_TO_DISK:
98+
__fallthrough;
99+
case PM_STATE_SOFT_OFF:
100+
kb106x_soc_deep_sleep();
101+
break;
102+
default:
103+
k_cpu_idle();
104+
break;
105+
}
106+
}
107+
108+
__weak void pm_state_exit_post_ops(enum pm_state state, uint8_t substate_id)
109+
{
110+
ARG_UNUSED(state);
111+
ARG_UNUSED(substate_id);
112+
}

soc/ene/kb106x/common/power.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Copyright (c) 2025 ENE Technology Inc.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef _KB106X_POWER_H_
8+
#define _KB106X_POWER_H_
9+
10+
void kb106x_soc_deep_sleep(void);
11+
void kb106x_soc_idle(void);
12+
13+
#endif /* _KB106X_POWER_H_ */

soc/ene/kb106x/common/reg/gcfg.h

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/*
2+
* Copyright (c) 2025 ENE Technology Inc.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef ENE_KB106X_GCFG_H
8+
#define ENE_KB106X_GCFG_H
9+
10+
/**
11+
* Structure type to access General Configuration (GCFG).
12+
*/
13+
struct gcfg_regs {
14+
volatile uint8_t IDV; /*Version ID Register */
15+
volatile uint8_t Reserved0; /*Reserved */
16+
volatile uint16_t IDC; /*Chip ID Register */
17+
volatile uint32_t FWID; /*Firmware ID Register */
18+
volatile uint32_t MCURST; /*MCU Reset Control Register */
19+
volatile uint32_t RSTFLAG; /*Reset Pending Flag Register */
20+
volatile uint32_t GPIOALT; /*GPIO Alternate Register */
21+
volatile uint8_t GPIOBPC1513; /*GPIO Bypass Control Register */
22+
volatile uint8_t GPIOBPC1718; /*GPIO Bypass Control Register */
23+
volatile uint8_t GPIOBPC7E6B; /*GPIO Bypass Control Register */
24+
volatile uint8_t Reserved1; /*Reserved */
25+
volatile uint16_t GPIOMUX; /*GPIO MUX Control Register */
26+
volatile uint16_t Reserved2; /*Reserved */
27+
volatile uint8_t I2CSPMS; /*I2CS Pin Map Selection Register */
28+
volatile uint8_t Reserved3[3]; /*Reserved */
29+
volatile uint8_t CLKCFG; /*Clock Configuration Register */
30+
volatile uint8_t Reserved4[3]; /*Reserved */
31+
volatile uint32_t DPLLFREQ; /*DPLL Frequency Register */
32+
volatile uint8_t GPIORPSC_C; /*Auto-Reset at Power Sequence Fail Register */
33+
volatile uint8_t GPIORPSC_5X; /*Auto-Reset at Power Sequence Fail Register */
34+
volatile uint8_t GPIORPSC_6X; /*Auto-Reset at Power Sequence Fail Register */
35+
volatile uint8_t Reserved5; /*Reserved */
36+
volatile uint32_t GCFGMISC; /*Misc. Register */
37+
volatile uint8_t EXTIE; /*Extended Command Interrupt Enable Register */
38+
volatile uint8_t Reserved6[3]; /*Reserved */
39+
volatile uint8_t EXTPF; /*Extended Command Pending Flag Register */
40+
volatile uint8_t Reserved7[3]; /*Reserved */
41+
volatile uint32_t EXTARG; /*Extended Command Argument0/1/2 Register */
42+
volatile uint8_t EXTCMD; /*Extended Command Port Register */
43+
volatile uint8_t Reserved8[3]; /*Reserved */
44+
volatile uint32_t ADCOTR; /*ADCO Register */
45+
volatile uint32_t Reserved9; /*Reserved */
46+
volatile uint32_t IDSR; /*IDSR Register */
47+
volatile uint32_t Reserved10[13]; /*Reserved */
48+
volatile uint32_t TRAPMODE;
49+
volatile uint32_t CLK1UCFG;
50+
volatile uint32_t LDO15TRIM;
51+
};
52+
53+
#define GCFG_CLKCFG_48M 0x00000014
54+
#define GCFG_CLKCFG_24M 0x00000004
55+
56+
/*-- Constant Define -------------------------------------------*/
57+
#define LDO15_OFFSET 0x22
58+
#define ECMISC2_OFFSET 0x25
59+
#define CLOCK_SOURCE_OSC32K 1
60+
#define CLOCK_SOURCE_EXTERNAL 0
61+
#define EXTERNAL_CLOCK_GPIO_NUM 0x5D
62+
63+
#define FREQ_96M48M 0
64+
#define FREQ_48M24M 1
65+
#define FREQ_24M12M 2
66+
#define FREQ_12M06M 3
67+
68+
#define DPLL_32K_TARGET_VALUE 0x05B9UL
69+
#define DPLL_SOF_TARGET_VALUE 0xBB80UL
70+
#define DPLL_DONT_CARE_VALUE 3
71+
#define DPLL_DISABLE 0
72+
#define DPLL_SOURCE_SOF 1
73+
#define DPLL_SOURCE_OSC32K 2
74+
#define DPLL_SOURCE_EXTCLK 3
75+
/* gcfg->FWID status flag */
76+
#define ECFV_NORMAL_RUN 0x00
77+
#define ECFV_PREPARE_UPDATE_ESCD 0x01
78+
#define ECFV_UPDATE_ESCD 0x81
79+
#define ECFV_PREPARE_UPDATE_BIOS 0x02
80+
#define ECFV_UPDATE_BIOS 0x82
81+
#define ECFV_PREPARE_ENTER_DEEP_SLEEP 0x03
82+
#define ECFV_ENTER_DEEP_SLEEP 0x83
83+
#define S0I3_ENTER_STOP 0x04
84+
#define NON_DEEP_SLEEP_STATE 0x05
85+
#define MAIN_LOOP_ENTER_IDLE 0x06
86+
87+
/* VCC Status */
88+
#define VCC_0V 0x00
89+
#define VCC_3P3V 0x01
90+
#define VCC_1P8V 0x02
91+
92+
#endif /* ENE_KB106X_GCFG_H */

soc/ene/kb106x/common/reg/pmu.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright (c) 2025 ENE Technology Inc.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef ENE_KB106X_PMU_H
8+
#define ENE_KB106X_PMU_H
9+
10+
/**
11+
* Structure type to access Power Management Unit (PMU).
12+
*/
13+
struct pmu_regs {
14+
volatile uint8_t PMUIDLE; /*IDLE wakeup by Interrupt Register */
15+
volatile uint8_t Reserved0[3]; /*Reserved */
16+
volatile uint32_t PMUSTOP; /*STOP Wakeup Source Register */
17+
volatile uint8_t PMUSTOPC; /*STOP Control Register */
18+
volatile uint8_t Reserved1[3]; /*Reserved */
19+
volatile uint8_t PMUCTRL; /*Control Register */
20+
volatile uint8_t Reserved2[3]; /*Reserved */
21+
};
22+
23+
/* STOP Wakeup Source */
24+
#define PMU_STOP_WU_GPTD 0x00000001
25+
#define PMU_STOP_WU_VC0 0x00000002
26+
#define PMU_STOP_WU_VC1 0x00000004
27+
#define PMU_STOP_WU_IKB 0x00000010
28+
#define PMU_STOP_WU_WDT 0x00000100
29+
#define PMU_STOP_WU_HIBTMR 0x00000400
30+
#define PMU_STOP_WU_eSPI 0x00010000
31+
#define PMU_STOP_WU_I2CD32 0x00020000
32+
#define PMU_STOP_WU_EDI32 0x00040000
33+
#define PMU_STOP_WU_SWD 0x00080000
34+
#define PMU_STOP_WU_I2CS0 0x01000000
35+
#define PMU_STOP_WU_I2CS1 0x02000000
36+
#define PMU_STOP_WU_USB 0x04000000
37+
38+
#define PMU_IDLE_WU_ENABLE 0x00000001
39+
40+
#endif /* ENE_KB106X_PMU_H */

soc/ene/kb106x/common/reg/vcc0.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (c) 2025 ENE Technology Inc.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef ENE_KB106X_VCC0_H
8+
#define ENE_KB106X_VCC0_H
9+
10+
/**
11+
* brief Structure type to access VCC0 Power Domain Module (VCC0).
12+
*/
13+
struct vcc0_regs {
14+
volatile uint16_t PAREGPLC; /*VCC0 PLC Register */
15+
volatile uint16_t PAREGFLAG; /*VCC0 Flag Register */
16+
volatile uint8_t PB8SCR; /*Power Button Override Control Register */
17+
volatile uint8_t Reserved0[3]; /*Reserved */
18+
volatile uint32_t PASCR; /*VCC0 Scratch Register */
19+
volatile uint32_t Reserved1[5]; /*Reserved */
20+
volatile uint8_t Reserved2; /*Reserved */
21+
volatile uint8_t IOSCCFG_T; /*OSC32K Configuration Register */
22+
volatile uint16_t Reserved3; /*Reserved */
23+
volatile uint32_t Reserved4[7]; /*Reserved */
24+
volatile uint8_t HIBTMRCFG; /*Hibernation Timer Configuration Register */
25+
volatile uint8_t Reserved5[3]; /*Reserved */
26+
volatile uint8_t HIBTMRIE; /*Hibernation Timer Interrupt Enable Register */
27+
volatile uint8_t Reserved6[3]; /*Reserved */
28+
volatile uint8_t HIBTMRPF; /*Hibernation Timer Pending Flag Register */
29+
volatile uint8_t Reserved7[3]; /*Reserved */
30+
volatile uint32_t HIBTMRMAT; /*Hibernation Timer Match Value Register */
31+
volatile uint32_t HIBTMRCNT; /*Hibernation Timer count Value Register */
32+
};
33+
34+
#endif /* ENE_KB106X_VCC0_H */

0 commit comments

Comments
 (0)