mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 11:26:02 +09:00
clk: fractional-divider: add handle to frac numerator is not to be greater than 4
We know that under the condition of even frequency division, if the numeratoris greater than 4, the duty cycle may not be equal to 50%. In the case, weneed to keep the original numerator(<4) and denominator. Change-Id: I8cd08199df4e3d27d5697ce80370224a6f267e26 Signed-off-by: Xing Zheng <zhengxing@rock-chips.com>
This commit is contained in:
@@ -112,9 +112,18 @@ static int clk_fd_set_rate(struct clk_hw *hw, unsigned long rate,
|
||||
* which will lead to a large deviation in the result.
|
||||
* Therefore, it is required that the numerator must
|
||||
* be greater than 4.
|
||||
*
|
||||
* Note that there are some exceptions here:
|
||||
* If there is an even frac div, we need to keep the original
|
||||
* numerator(<4) and denominator. Otherwise, it may cause the
|
||||
* issue that the duty ratio is not 50%.
|
||||
*/
|
||||
if (m < 4 && m != 0) {
|
||||
val = DIV_ROUND_UP(4, m);
|
||||
if (n % 2 == 0)
|
||||
val = 1;
|
||||
else
|
||||
val = DIV_ROUND_UP(4, m);
|
||||
|
||||
n *= val;
|
||||
m *= val;
|
||||
if (n > fd->nmask) {
|
||||
|
||||
Reference in New Issue
Block a user