Skip to content

Commit 388091a

Browse files
ene-stevenfabiobaltieri
authored andcommitted
soc: kb1200 soc
Add support for ENE KB1200 SOC Signed-off-by: Steven Chang <[email protected]>
1 parent 9897761 commit 388091a

File tree

17 files changed

+625
-0
lines changed

17 files changed

+625
-0
lines changed

soc/ene/kb1200/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Copyright (c) 2023 ENE Technology Inc.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
zephyr_library()
5+
zephyr_library_sources(soc.c)
6+
7+
set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/arm/cortex_m/scripts/linker.ld CACHE INTERNAL "")

soc/ene/kb1200/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright (c) 2024 ENE Technology Inc.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config SOC_KB1200
5+
select ARM
6+
select CPU_CORTEX_M4
7+
select CPU_HAS_ARM_MPU
8+
select CPU_CORTEX_M_HAS_DWT
9+
select CPU_HAS_FPU

soc/ene/kb1200/Kconfig.defconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright (c) 2023 ENE Technology Inc.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
if SOC_KB1200
5+
6+
config NUM_IRQS
7+
default 64
8+
9+
config SYS_CLOCK_HW_CYCLES_PER_SEC
10+
default $(dt_node_int_prop_int,/cpus/cpu@0,clock-frequency)
11+
12+
config BUILD_OUTPUT_BIN
13+
default y
14+
15+
config BUILD_OUTPUT_HEX
16+
default y
17+
18+
endif # SOC_KB1200

soc/ene/kb1200/Kconfig.soc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright (c) 2024 ENE Technology Inc.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config SOC_KB1200
5+
bool
6+
help
7+
ENE KB1200
8+
9+
config SOC
10+
default "kb1200" if SOC_KB1200

soc/ene/kb1200/reg/adc.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright (c) 2024 ENE Technology Inc.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef ENE_KB1200_ADC_H
8+
#define ENE_KB1200_ADC_H
9+
10+
/**
11+
* Structure type to access Analog to Digital Converter (ADC).
12+
*/
13+
struct adc_regs {
14+
volatile uint32_t ADCCFG; /* Configuration Register */
15+
volatile uint32_t Reserved[3]; /* Reserved */
16+
volatile uint32_t ADCDAT[14]; /* Data Register */
17+
};
18+
19+
#define ADC_CHANNEL_BIT_POS 16
20+
#define ADC_CHANNEL_BIT_MASK 0x3FFF0000
21+
22+
#define ADC_RESOLUTION 10 /* Unit:bits */
23+
#define ADC_VREF_ANALOG 3300 /* Unit:mV */
24+
#define ADC_MAX_CHAN 14
25+
26+
#define ADC_FUNCTION_ENABLE 0x0001
27+
#define ADC_INVALID_VALUE 0x8000
28+
29+
#define ADC_WAIT_TIME 100
30+
#define ADC_WAIT_CNT 100
31+
32+
#endif /* ENE_KB1200_ADDA_H */

soc/ene/kb1200/reg/fsmbm.h

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
/*
2+
* Copyright (c) 2024 ENE Technology Inc.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef ENE_KB1200_FSMBM_H
8+
#define ENE_KB1200_FSMBM_H
9+
10+
/**
11+
* Structure type to access Flexible SMBus Master (FSMBM).
12+
*/
13+
struct fsmbm_regs {
14+
volatile uint32_t FSMBMCFG; /* Configuration Register */
15+
volatile uint8_t FSMBMIE; /* Interrupt Enable Register */
16+
volatile uint8_t Reserved0[3];
17+
volatile uint8_t FSMBMPF; /* Event Pending Flag Register */
18+
volatile uint8_t Reserved1[3];
19+
volatile uint8_t FSMBMFRT; /* Protocol Control Register */
20+
volatile uint8_t Reserved2[3];
21+
volatile uint16_t FSMBMPEC; /* PEC Value Register */
22+
volatile uint16_t Reserved3;
23+
volatile uint8_t FSMBMSTS; /* Status Register */
24+
volatile uint8_t Reserved4[3];
25+
volatile uint8_t FSMBMADR; /* Slave Address Register */
26+
volatile uint8_t Reserved5[3];
27+
volatile uint8_t FSMBMCMD; /* Command Register */
28+
volatile uint8_t Reserved6[3];
29+
volatile uint8_t FSMBMDAT[32]; /* Data Register */
30+
volatile uint8_t FSMBMPRTC_P; /* Protocol Register */
31+
volatile uint8_t FSMBMPRTC_C; /* Protocol Register */
32+
volatile uint16_t Reserved7;
33+
volatile uint8_t FSMBMNADR; /* HostNotify Slave Address Register */
34+
volatile uint8_t Reserved8[3];
35+
volatile uint16_t FSMBMNDAT; /* HostNotify Data Register */
36+
volatile uint16_t Reserved9;
37+
};
38+
39+
#define FSMBM_NUM 10
40+
41+
/* data->state */
42+
#define STATE_IDLE 0
43+
#define STATE_SENDING 1
44+
#define STATE_RECEIVING 2
45+
#define STATE_COMPLETE 3
46+
47+
/* PROTOCOL */
48+
#define FLEXIBLE_PROTOCOL 0x7F
49+
50+
/* Error code */
51+
#define FSMBM_NO_ERROR 0x00
52+
#define FSMBM_DEVICE_ADDR_NO_ACK 0x10
53+
#define FSMBM_CMD_NO_ACK 0x12
54+
#define FSMBM_DEVICE_DATA_NO_ACK 0x13
55+
#define FSMBM_LOST_ARBITRATION 0x17
56+
#define FSMBM_SMBUS_TIMEOUT 0x18
57+
#define FSMBM_UNSUPPORTED_PRTC 0x19
58+
#define FSMBM_SMBUS_BUSY 0x1A
59+
#define FSMBM_STOP_FAIL 0x1E
60+
#define FSMBM_PEC_ERROR 0x1F
61+
/* Packet Form */
62+
#define ___NONE 0x00
63+
#define ___STOP 0x01
64+
#define __PEC_ 0x02
65+
#define __PEC_STOP 0x03
66+
#define _CNT__ 0x04
67+
#define _CNT__STOP 0x05
68+
#define _CNT_PEC_ 0x06
69+
#define _CNT_PEC_STOP 0x07
70+
#define CMD___ 0x08
71+
#define CMD___STOP 0x09
72+
#define CMD__PEC_ 0x0A
73+
#define CMD__PEC_STOP 0x0B
74+
#define CMD_CNT__ 0x0C
75+
#define CMD_CNT__STOP 0x0D
76+
#define CMD_CNT_PEC_ 0x0E
77+
#define CMD_CNT_PEC_STOP 0x0F
78+
79+
#define FLEXIBLE_CMD 0x08
80+
#define FLEXIBLE_CNT 0x04
81+
#define FLEXIBLE_PEC 0x02
82+
#define FLEXIBLE_STOP 0x01
83+
/* HW */
84+
#define FSMBM_BUFFER_SIZE 0x20
85+
#define FSMBM_MAXCNT 0xFF
86+
87+
#define FSMBM_WRITE 0x00
88+
#define FSMBM_READ 0x01
89+
90+
/* Clock Setting = 1 / (1u + (1u * N)) ,50% Duty Cycle */
91+
#define FSMBM_CLK_1M 0x0000
92+
#define FSMBM_CLK_500K 0x0101
93+
#define FSMBM_CLK_333K 0x0202
94+
#define FSMBM_CLK_250K 0x0303
95+
#define FSMBM_CLK_200K 0x0404
96+
#define FSMBM_CLK_167K 0x0505
97+
#define FSMBM_CLK_143K 0x0606
98+
#define FSMBM_CLK_125K 0x0707
99+
#define FSMBM_CLK_111K 0x0808
100+
#define FSMBM_CLK_100K 0x0909
101+
#define FSMBM_CLK_91K 0x0A0A
102+
#define FSMBM_CLK_83K 0x0B0B
103+
#define FSMBM_CLK_71K 0x0D0D
104+
#define FSMBM_CLK_63K 0x0F0F
105+
#define FSMBM_CLK_50K 0x1313
106+
#define FSMBM_CLK_40K 0x1818
107+
#define FSMBM_CLK_30K 0x2020
108+
#define FSMBM_CLK_20K 0x3131
109+
#define FSMBM_CLK_10K 0x6363
110+
/* Other(non 50% Duty Cycle) */
111+
#define FSMBM_CLK_400K 0x0102
112+
113+
#define FSMBM_COMPLETE_EVENT 0x01
114+
#define FSMBM_HOST_NOTIFY_EVENT 0x02
115+
#define FSMBM_BLOCK_FINISH_EVENT 0x04
116+
117+
#define FSMBM_FUNCTION_ENABLE 0x01
118+
#define FSMBM_TIMEOUT_ENABLE 0x02
119+
#define FSMBM_HW_RESET 0x10
120+
121+
#define FSMBM_CLK_POS 16
122+
#define FSMBM_CLK_MASK 0xFFFF
123+
#define FSMBM_STS_MASK 0x1F
124+
125+
#endif /* ENE_KB1200_FSMBM_H */

soc/ene/kb1200/reg/gcfg.h

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright (c) 2023 ENE Technology Inc.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef ENE_KB1200_GCFG_H
8+
#define ENE_KB1200_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 VCCSTA; /*VCC Status Register */
22+
volatile uint8_t Reserved1[3]; /*Reserved */
23+
volatile uint16_t GPIOMUX; /*GPIO MUX Control Register */
24+
volatile uint16_t Reserved2; /*Reserved */
25+
volatile uint16_t I2CSPMS; /*I2CS Pin Map Selection Register */
26+
volatile uint16_t Reserved3; /*Reserved */
27+
volatile uint8_t CLKCFG; /*Clock Configuration Register */
28+
volatile uint8_t Reserved4[3]; /*Reserved */
29+
volatile uint32_t DPLLFREQ; /*DPLL Frequency Register */
30+
volatile uint32_t Reserved5; /*Reserved */
31+
volatile uint32_t GCFGMISC; /*Misc. Register */
32+
volatile uint8_t EXTIE; /*Extended Command Interrupt Enable Register */
33+
volatile uint8_t Reserved6[3]; /*Reserved */
34+
volatile uint8_t EXTPF; /*Extended Command Pending Flag Register */
35+
volatile uint8_t Reserved7[3]; /*Reserved */
36+
volatile uint32_t EXTARG; /*Extended Command Argument0/1/2 Register */
37+
volatile uint8_t EXTCMD; /*Extended Command Port Register */
38+
volatile uint8_t Reserved8[3]; /*Reserved */
39+
volatile uint32_t ADCOTR; /*ADCO Register */
40+
volatile uint32_t IDSR; /*IDSR Register */
41+
volatile uint32_t Reserved9[14]; /*Reserved */
42+
volatile uint32_t TRAPMODE;
43+
volatile uint32_t CLK1UCFG;
44+
volatile uint32_t LDO15TRIM;
45+
volatile uint32_t Reserved10;
46+
volatile uint32_t WWTR;
47+
volatile uint32_t ECMISC2;
48+
volatile uint32_t DPLLCTRL;
49+
};
50+
51+
#define GCFG_CLKCFG_96M 0x00000004
52+
#define GCFG_CLKCFG_48M 0x00000014
53+
#define GCFG_CLKCFG_24M 0x00000024
54+
55+
#endif /* ENE_KB1200_GCFG_H */

soc/ene/kb1200/reg/gpio.h

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright (c) 2023 ENE Technology Inc.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef ENE_KB1200_GPIO_H
8+
#define ENE_KB1200_GPIO_H
9+
10+
/**
11+
* Structure type to access General Purpose Input/Output (GPIO).
12+
*/
13+
struct gpio_regs {
14+
volatile uint32_t GPIOFS; /*Function Selection Register */
15+
volatile uint32_t Reserved1[3];
16+
volatile uint32_t GPIOOE; /*Output Enable Register */
17+
volatile uint32_t Reserved2[3];
18+
volatile uint32_t GPIOD; /*Output Data Register */
19+
volatile uint32_t Reserved3[3];
20+
volatile uint32_t GPIOIN; /*Input Data Register */
21+
volatile uint32_t Reserved4[3];
22+
volatile uint32_t GPIOPU; /*Pull Up Register */
23+
volatile uint32_t Reserved5[3];
24+
volatile uint32_t GPIOOD; /*Open Drain Register */
25+
volatile uint32_t Reserved6[3];
26+
volatile uint32_t GPIOIE; /*Input Enable Register */
27+
volatile uint32_t Reserved7[3];
28+
volatile uint32_t GPIODC; /*Driving Control Register */
29+
volatile uint32_t Reserved8[3];
30+
volatile uint32_t GPIOLV; /*Low Voltage Mode Enable Register */
31+
volatile uint32_t Reserved9[3];
32+
volatile uint32_t GPIOPD; /*Pull Down Register */
33+
volatile uint32_t Reserved10[3];
34+
volatile uint32_t GPIOFL; /*Function Lock Register */
35+
volatile uint32_t Reserved11[3];
36+
};
37+
38+
#define NUM_KB1200_GPIO_PORTS 4
39+
40+
/*-- Constant Define --------------------------------------------*/
41+
#define GPIO00_PWMLED0_PWM8 0x00
42+
#define GPIO01_SERRXD1_UARTSIN 0x01
43+
#define GPIO03_SERTXD1_UARTSOUT 0x03
44+
#define GPIO22_ESBDAT_PWM9 0x22
45+
#define GPIO28_32KOUT_SERCLK2 0x28
46+
#define GPIO36_UARTSOUT_SERTXD2 0x36
47+
#define GPIO5C_KSO6_P80DAT 0x5C
48+
#define GPIO5D_KSO7_P80CLK 0x5D
49+
#define GPIO5E_KSO8_SERRXD1 0x5E
50+
#define GPIO5F_KSO9_SERTXD1 0x5F
51+
#define GPIO71_SDA8_UARTRTS 0x71
52+
#define GPIO38_SCL4_PWM1 0x38
53+
54+
55+
#endif /* ENE_KB1200_GPIO_H */

soc/ene/kb1200/reg/gptd.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright (c) 2023 ENE Technology Inc.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef ENE_KB1200_GPTD_H
8+
#define ENE_KB1200_GPTD_H
9+
10+
/**
11+
* Structure type to access GPIO Trigger Detector (GPTD).
12+
*/
13+
struct gptd_regs {
14+
volatile uint32_t GPTDIE; /*Interrupt Enable Register */
15+
volatile uint32_t Reserved1[3];
16+
volatile uint32_t GPTDPF; /*Event Pending Flag Register */
17+
volatile uint32_t Reserved2[3];
18+
volatile uint32_t GPTDCHG; /*Change Trigger Register */
19+
volatile uint32_t Reserved3[3];
20+
volatile uint32_t GPTDEL; /*Level/Edge Trigger Register */
21+
volatile uint32_t Reserved4[3];
22+
volatile uint32_t GPTDPS; /*Polarity Selection Register */
23+
volatile uint32_t Reserved5[3];
24+
volatile uint32_t GPTDWE; /*WakeUP Enable Register */
25+
volatile uint32_t Reserved6[3];
26+
};
27+
28+
#endif /* ENE_KB1200_GPTD_H */

soc/ene/kb1200/reg/pmu.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (c) 2023 ENE Technology Inc.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef ENE_KB1200_PMU_H
8+
#define ENE_KB1200_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+
volatile uint8_t PMUSTAF; /*Status Flag */
22+
volatile uint8_t Reserved3[3]; /*Reserved */
23+
};
24+
25+
/* STOP Wakeup Source */
26+
#define PMU_STOP_WU_GPTD 0x00000001
27+
#define PMU_STOP_WU_VC0 0x00000002
28+
#define PMU_STOP_WU_VC1 0x00000004
29+
#define PMU_STOP_WU_IKB 0x00000010
30+
#define PMU_STOP_WU_WDT 0x00000100
31+
#define PMU_STOP_WU_HIBTMR 0x00000400
32+
#define PMU_STOP_WU_eSPI 0x00010000
33+
#define PMU_STOP_WU_SPIS 0x00010000
34+
#define PMU_STOP_WU_I2CD32 0x00020000
35+
#define PMU_STOP_WU_EDI32 0x00040000
36+
#define PMU_STOP_WU_SWD 0x00080000
37+
#define PMU_STOP_WU_ITIM 0x00100000
38+
#define PMU_STOP_WU_I2CS0 0x01000000
39+
#define PMU_STOP_WU_I2CS1 0x02000000
40+
#define PMU_STOP_WU_I2CS2 0x04000000
41+
#define PMU_STOP_WU_I2CS3 0x08000000
42+
43+
#define PMU_IDLE_WU_ENABLE 0x00000001
44+
45+
#endif /* ENE_KB1200_PMU_H */

0 commit comments

Comments
 (0)