Azure Sphere MT3620 M4 API Reference Manual
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
mhal_pwm.h
1 /*
2  * (C) 2005-2020 MediaTek Inc. All rights reserved.
3  *
4  * Copyright Statement:
5  *
6  * This MT3620 driver software/firmware and related documentation
7  * ("MediaTek Software") are protected under relevant copyright laws.
8  * The information contained herein is confidential and proprietary to
9  * MediaTek Inc. ("MediaTek"). You may only use, reproduce, modify, or
10  * distribute (as applicable) MediaTek Software if you have agreed to and been
11  * bound by this Statement and the applicable license agreement with MediaTek
12  * ("License Agreement") and been granted explicit permission to do so within
13  * the License Agreement ("Permitted User"). If you are not a Permitted User,
14  * please cease any access or use of MediaTek Software immediately.
15  *
16  * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
17  * THAT MEDIATEK SOFTWARE RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE
18  * PROVIDED TO RECEIVER ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS
19  * ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
21  * NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH
22  * RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
23  * INCORPORATED IN, OR SUPPLIED WITH MEDIATEK SOFTWARE, AND RECEIVER AGREES TO
24  * LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
25  * RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
26  * OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK
27  * SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE
28  * RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
29  * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S
30  * ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO MEDIATEK SOFTWARE RELEASED
31  * HEREUNDER WILL BE ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY
32  * RECEIVER TO MEDIATEK DURING THE PRECEDING TWELVE (12) MONTHS FOR SUCH
33  * MEDIATEK SOFTWARE AT ISSUE.
34  */
35 
36 #ifndef __MHAL_PWM_H__
37 #define __MHAL_PWM_H__
38 
39 #include "mhal_osai.h"
40 
114 #define PWM_EPTR 1
115 
116 #define PWM_EPARAMETER 2
117 
118 #define PWM_ENOMEM 3
119 
120 #define PWM_EFAULT 4
121 
122 #define PWM_EAGAIN 5
123 
124 #define PWM_ETIMEOUT 6
125 
126 #define PWM_ECLK 7
127 
129 #define MAX_GROUP_NUM 3
130 
144 typedef enum {
145  PWM_BIT0 = 0,
147  PWM_BIT1 = 1,
149  PWM_BIT2 = 2,
151  PWM_BIT3 = 3,
156 
158 typedef enum {
159  PWM_IDLE = 0,
164 
166 typedef enum {
167  PWM_DP0 = 0,
178 
180 typedef enum {
191 } pwm_channels;
192 
193 typedef enum {
202 } pwm_clks;
203 
204 typedef enum{
212 
228  const void __iomem *pwm_register;
230  u32 pwm_nums;
232  u32 index;
261 };
262 
268  void __iomem *base;
275 };
293 #ifdef __cplusplus
294 extern "C" {
295 #endif
296 
308 
323  pwm_channels channel_num);
324 
336  pwm_channels channel_num);
337 
352 int mtk_mhal_pwm_init(struct mtk_pwm_controller *ctlr,
353  u32 channel_bit_map);
354 
367 int mtk_mhal_pwm_deinit(struct mtk_pwm_controller *ctlr,
368  u32 channel_bit_map);
369 
386  pwm_channels channel_num);
387 
404  pwm_channels channel_num);
405 
423 int mtk_mhal_pwm_start(struct mtk_pwm_controller *ctlr,
424  pwm_channels channel_num);
425 
442 int mtk_mhal_pwm_stop(struct mtk_pwm_controller *ctlr,
443  pwm_channels channel_num);
444 
460  pwm_channels channel_num);
461 
476  pwm_channels channel_num);
477 
492  pwm_channels channel_num);
493 
511  pwm_channels channel_num);
512 
533  pwm_channels channel_num);
534 
553  pwm_channels channel_num);
554 
569 int mtk_mhal_pwm_kick(struct mtk_pwm_controller *ctlr,
570  pwm_channels channel_num);
593 int mtk_mhal_pwm_dpsel(struct mtk_pwm_controller *ctlr,
594  pwm_channels channel_num);
595 
596 #ifdef __cplusplus
597 }
598 #endif
599 
613 #endif /* __MHAL_PWM_H__ */
614 
615 
u32 total_count
PWM total count calculator according to PWM frequency and clock.
Definition: mhal_pwm.h:248
int mtk_mhal_pwm_dpsel(struct mtk_pwm_controller *ctlr, pwm_channels channel_num)
This function is used to set PWM channel's differential mode.
int mtk_mhal_pwm_get_duty_cycle(struct mtk_pwm_controller *ctlr, pwm_channels channel_num)
This function is used to get the current duty cycle of the PWM.
u32 current_frequency
PWM hardware current's output frequency.
Definition: mhal_pwm.h:252
PWM status is busy.
Definition: mhal_pwm.h:161
u32 frequency
PWM output frequency.
Definition: mhal_pwm.h:246
u8 replay_mode
Enable replay mode or one shot mode.
Definition: mhal_pwm.h:240
PWM channel0 bit map.
Definition: mhal_pwm.h:145
PWM channel2 bit map.
Definition: mhal_pwm.h:149
int mtk_mhal_pwm_global_kick(struct mtk_pwm_controller *ctlr)
This function is used to reset PWM hardware by group.
int mtk_mhal_pwm_start(struct mtk_pwm_controller *ctlr, pwm_channels channel_num)
This function is used to start the PWM hardware.
void __iomem * base
PWM controller base address.
Definition: mhal_pwm.h:268
PWM max channel <invalid>
Definition: mhal_pwm.h:189
int mtk_mhal_pwm_feature_enable(struct mtk_pwm_controller *ctlr, pwm_channels channel_num)
This function is used to select PWM global kick, IO ctrl, polarity setting.
PWM differential mode select PWM channel3.
Definition: mhal_pwm.h:173
char group_number
PWM controller group number.
Definition: mhal_pwm.h:270
PWM differential mode select PWM channel2.
Definition: mhal_pwm.h:171
u32 current_duty_cycle
PWM hardware current's output duty cycle,typical value(0~100)
Definition: mhal_pwm.h:250
int mtk_mhal_pwm_kick(struct mtk_pwm_controller *ctlr, pwm_channels channel_num)
This function is used to kick PWM hardware output waveform in 2-state mode.
32K clock source
Definition: mhal_pwm.h:194
int mtk_mhal_pwm_deinit(struct mtk_pwm_controller *ctlr, u32 channel_bit_map)
This function is used to de-initialize PWM hardware.
pwm_s0_s1_stages
Definition: mhal_pwm.h:204
pwm_channels
Defines the PWM channel number.
Definition: mhal_pwm.h:180
int mtk_mhal_pwm_set_duty_cycle(struct mtk_pwm_controller *ctlr, pwm_channels channel_num)
This function is used to set PWM duty cycle.
max clock source <invalid>
Definition: mhal_pwm.h:200
int mtk_mhal_pwm_disable_clk(struct mtk_pwm_controller *ctlr, pwm_channels channel_num)
This function is used to disable PWM clock.
u32 s1_stay_cycle
The stay cycles of S1.
Definition: mhal_pwm.h:238
int mtk_mhal_pwm_config_s0_s1_freq_duty(struct mtk_pwm_controller *ctlr, pwm_channels channel_num)
This function is used to set PWM frequency and duty cycle in 2-state mode.
PWM differential mode select max <invalid>
Definition: mhal_pwm.h:175
u32 duty_cycle
PWM duty cycle,typical value(0~100)
Definition: mhal_pwm.h:244
PWM channel1.
Definition: mhal_pwm.h:183
u32 pwm_nums
PWM controller's channel number.
Definition: mhal_pwm.h:230
2M clock source
Definition: mhal_pwm.h:196
int mtk_mhal_pwm_clock_select(struct mtk_pwm_controller *ctlr)
This function is used to select PWM clock source of the PWM controller.
pwm_clks
Definition: mhal_pwm.h:193
PWM channel2.
Definition: mhal_pwm.h:185
PWM max channel <invalid>
Definition: mhal_pwm.h:153
u8 polarity_set
PWM polarity setting.
Definition: mhal_pwm.h:258
PWM channel1 bit map.
Definition: mhal_pwm.h:147
u8 io_ctrl_sel
PWM IO ctrl function setting.
Definition: mhal_pwm.h:256
pwm_differential_select mode
Defines the PWM channel's differential mode.
Definition: mhal_pwm.h:234
PWM channel3.
Definition: mhal_pwm.h:187
int mtk_mhal_pwm_get_running_status(struct mtk_pwm_controller *ctlr, pwm_channels channel_num)
This function is used to get the current status of PWM.
Interface to PWM, used to store the hardware register base address, group information and clock...
Definition: mhal_pwm.h:266
u8 global_kick_enable
PWM group global kick function.
Definition: mhal_pwm.h:254
pwm_s0_s1_stages stage
Select PWM S0 or S1 stage to configure.
Definition: mhal_pwm.h:242
pwm_channels_bit_map
Defines the PWM channel bit map.
Definition: mhal_pwm.h:144
xtal clock source
Definition: mhal_pwm.h:198
pwm_running_status running_status
PWM in busy or idle status.
Definition: mhal_pwm.h:260
int mtk_mhal_pwm_s0_s1_stay_cycle_config(struct mtk_pwm_controller *ctlr, pwm_channels channel_num)
This function is used to set PWM stay cycles of S0 and S1 in 2-state mode.
pwm_clks group_clock
Clock source of this PWM controller.
Definition: mhal_pwm.h:272
max pwm 2-state stage <invalid>
Definition: mhal_pwm.h:209
pwm_differential_select
Defines the PWM channel's differential mode.
Definition: mhal_pwm.h:166
struct mtk_com_pwm_data * data
M-HAL pwm channel common structure information.
Definition: mhal_pwm.h:274
int mtk_mhal_pwm_get_frequency(struct mtk_pwm_controller *ctlr, pwm_channels channel_num)
This function is used to get current frequency of the PWM with the unit of frequency being Hz...
pwm_running_status
Defines the PWM running status.
Definition: mhal_pwm.h:158
PWM channel3 bit map.
Definition: mhal_pwm.h:151
Used to store the PWM base address, group number, clock source, pwm channel common structure informat...
Definition: mhal_pwm.h:226
PWM channel0.
Definition: mhal_pwm.h:181
u32 index
PWM controller's channel index.
Definition: mhal_pwm.h:232
PWM differential mode select PWM channel0.
Definition: mhal_pwm.h:167
int mtk_mhal_pwm_enable_clk(struct mtk_pwm_controller *ctlr, pwm_channels channel_num)
This function is used to enable PWM clock before operating hardware.
S1 stage.
Definition: mhal_pwm.h:207
u32 s0_stay_cycle
The stay cycles of S0.
Definition: mhal_pwm.h:236
int mtk_mhal_pwm_stop(struct mtk_pwm_controller *ctlr, pwm_channels channel_num)
This function is used to stop the PWM hardware.
PWM status is idle.
Definition: mhal_pwm.h:159
const void __iomem * pwm_register
PWM controller register offset by channel.
Definition: mhal_pwm.h:228
int mtk_mhal_pwm_init(struct mtk_pwm_controller *ctlr, u32 channel_bit_map)
This function is used to initialize the PWM hardware.
int mtk_mhal_pwm_set_frequency(struct mtk_pwm_controller *ctlr, pwm_channels channel_num)
This function is used to set PWM frequency.
S0 stage.
Definition: mhal_pwm.h:205
PWM differential mode select PWM channel1.
Definition: mhal_pwm.h:169