1 /*
2  * Copyright (c) 2024 ENE Technology Inc.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef ENE_KB1200_PWM_H
8 #define ENE_KB1200_PWM_H
9 
10 /**
11  * Structure type to access Pulse Width Modulation (PWM).
12  */
13 struct pwm_regs {
14 	volatile uint16_t PWMCFG;        /*Configuration Register */
15 	volatile uint16_t Reserved0;     /*Reserved */
16 	volatile uint16_t PWMHIGH;       /*High Length Register */
17 	volatile uint16_t Reserved1;     /*Reserved */
18 	volatile uint16_t PWMCYC;        /*Cycle Length Register */
19 	volatile uint16_t Reserved2;     /*Reserved */
20 	volatile uint32_t PWMCHC;        /*Current High/Cycle Length Register */
21 };
22 
23 #define PWM_SOURCE_CLK_32M      0x0000
24 #define PWM_SOURCE_CLK_1M       0x4000
25 #define PWM_SOURCE_CLK_32_768K  0x8000
26 
27 #define PWM_PRESCALER_BIT_S     8
28 
29 #define PWM_RULE0               0x0000
30 #define PWM_RULE1               0x0080
31 
32 #define PWM_PUSHPULL            0x0000
33 #define PWM_OPENDRAIN           0x0002
34 #define PWM_ENABLE              0x0001
35 
36 #define PWM_INPUT_FREQ_HI       32000000u
37 #define PWM_MAX_PRESCALER       (1UL << (6))
38 #define PWM_MAX_CYCLES          (1UL << (14))
39 
40 #endif /* ENE_KB1200_PWM_H */
41