/* This function is used to set duty ratio.  */
int tls_pwm_duty_config(u8 channel, u8 duty)
/* This function is used to set duty ratio.  */
int tls_pwm_duty_config(u8 channel, u8 duty)
{
    u32 temp = 0;
	if(channel > (PWM_CHANNEL_MAX_NUM - 1))
	{
		TLS_DBGPRT_ERR("duty param err\n");
		return WM_FAILED;
	}
	if (duty == 0)
	{
		tls_pwm_stop(channel);
		return WM_SUCCESS;
	}
    if (4 == channel)
    {
        temp = tls_reg_read32(HR_PWM_CH4_REG2) & ~0x0000FF00;
        temp |= (duty << 8);
        tls_reg_write32(HR_PWM_CH4_REG2, temp);
    }
    else
    {
        temp = tls_reg_read32(HR_PWM_CMPDAT) & ~(0xFF << channel * 8);
        temp |= (duty << (channel * 8));
        tls_reg_write32(HR_PWM_CMPDAT, temp);
    }
    return WM_SUCCESS;
}