1 /* 2 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 * 15 * Description: pwm driver implementatioin. 16 */ 17 18 #ifndef __PWM_DRV_H__ 19 #define __PWM_DRV_H__ 20 21 #include <hi3861_platform.h> 22 #include <hi_pwm.h> 23 24 #define PWM_BASE_ADDR_STEP 0x100 25 #define pwm_base_addr(pwm_num) (HI_PWM_REG_BASE + (pwm_num) * PWM_BASE_ADDR_STEP) 26 27 #define pwm_en_reg(base_addr) ((base_addr)+ 0x0) 28 #define pwm_start_reg(base_addr) ((base_addr) + 0x4) 29 #define pwm_freq_reg(base_addr) ((base_addr) + 0x8) 30 #define pwm_duty_reg(base_addr) ((base_addr) + 0xC) 31 32 typedef struct { 33 hi_bool is_init; 34 hi_u8 reserved[3]; /* 3bytes reserved */ 35 hi_u32 pwm_sem; 36 }pwm_ctl; 37 38 typedef struct { 39 pwm_ctl pwm[HI_PWM_PORT_MAX]; 40 }pwm_ctx; 41 42 hi_u32 pwm_check_port(hi_pwm_port port); 43 hi_bool pwm_is_init(hi_pwm_port port); 44 hi_u32 pwm_lock(hi_pwm_port port); 45 hi_u32 pwm_unlock(hi_pwm_port port); 46 pwm_ctl *pwm_get_ctl(hi_pwm_port port); 47 48 49 #endif 50 51