Lines Matching full:prescale

69  * @prescale: MTU3 prescale
79 u8 prescale[RZ_MTU3_MAX_HW_CHANNELS]; member
116 u8 prescale; in rz_mtu3_pwm_calculate_prescale() local
119 * Supported prescale values are 1, 4, 16 and 64. in rz_mtu3_pwm_calculate_prescale()
120 * TODO: Support prescale values 2, 8, 32, 256 and 1024. in rz_mtu3_pwm_calculate_prescale()
124 prescale = 3; in rz_mtu3_pwm_calculate_prescale()
126 prescale = (fls(prescaled_period_cycles) + 1) / 2; in rz_mtu3_pwm_calculate_prescale()
128 return prescale; in rz_mtu3_pwm_calculate_prescale()
282 u8 prescale, val; in rz_mtu3_pwm_get_state() local
295 prescale = FIELD_GET(RZ_MTU3_TCR_TPCS, val); in rz_mtu3_pwm_get_state()
297 /* With prescale <= 7 and pv <= 0xffff this doesn't overflow. */ in rz_mtu3_pwm_get_state()
298 tmp = NSEC_PER_SEC * (u64)pv << (2 * prescale); in rz_mtu3_pwm_get_state()
300 tmp = NSEC_PER_SEC * (u64)dc << (2 * prescale); in rz_mtu3_pwm_get_state()
313 static u16 rz_mtu3_pwm_calculate_pv_or_dc(u64 period_or_duty_cycle, u8 prescale) in rz_mtu3_pwm_calculate_pv_or_dc() argument
315 return min(period_or_duty_cycle >> (2 * prescale), (u64)U16_MAX); in rz_mtu3_pwm_calculate_pv_or_dc()
325 u8 prescale; in rz_mtu3_pwm_config() local
335 prescale = rz_mtu3_pwm_calculate_prescale(rz_mtu3_pwm, period_cycles); in rz_mtu3_pwm_config()
338 * Prescalar is shared by multiple channels, so prescale can in rz_mtu3_pwm_config()
341 * it, if current prescale value is less than the one we want to set. in rz_mtu3_pwm_config()
344 if (rz_mtu3_pwm->prescale[ch] > prescale) in rz_mtu3_pwm_config()
347 prescale = rz_mtu3_pwm->prescale[ch]; in rz_mtu3_pwm_config()
350 pv = rz_mtu3_pwm_calculate_pv_or_dc(period_cycles, prescale); in rz_mtu3_pwm_config()
354 dc = rz_mtu3_pwm_calculate_pv_or_dc(duty_cycles, prescale); in rz_mtu3_pwm_config()
368 val = RZ_MTU3_TCR_CKEG_RISING | prescale; in rz_mtu3_pwm_config()
371 if (rz_mtu3_pwm->prescale[ch] != prescale && rz_mtu3_pwm->enable_count[ch]) in rz_mtu3_pwm_config()
386 if (rz_mtu3_pwm->prescale[ch] != prescale) { in rz_mtu3_pwm_config()
392 rz_mtu3_pwm->prescale[ch] = prescale; in rz_mtu3_pwm_config()