|
@@ -41,11 +41,13 @@ static unsigned long clk_frac_recalc_rate(struct clk_hw *hw,
|
|
{
|
|
{
|
|
struct clk_frac *frac = to_clk_frac(hw);
|
|
struct clk_frac *frac = to_clk_frac(hw);
|
|
u32 div;
|
|
u32 div;
|
|
|
|
+ u64 tmp_rate;
|
|
|
|
|
|
div = readl_relaxed(frac->reg) >> frac->shift;
|
|
div = readl_relaxed(frac->reg) >> frac->shift;
|
|
div &= (1 << frac->width) - 1;
|
|
div &= (1 << frac->width) - 1;
|
|
|
|
|
|
- return (parent_rate >> frac->width) * div;
|
|
|
|
|
|
+ tmp_rate = (u64)parent_rate * div;
|
|
|
|
+ return tmp_rate >> frac->width;
|
|
}
|
|
}
|
|
|
|
|
|
static long clk_frac_round_rate(struct clk_hw *hw, unsigned long rate,
|
|
static long clk_frac_round_rate(struct clk_hw *hw, unsigned long rate,
|
|
@@ -54,7 +56,7 @@ static long clk_frac_round_rate(struct clk_hw *hw, unsigned long rate,
|
|
struct clk_frac *frac = to_clk_frac(hw);
|
|
struct clk_frac *frac = to_clk_frac(hw);
|
|
unsigned long parent_rate = *prate;
|
|
unsigned long parent_rate = *prate;
|
|
u32 div;
|
|
u32 div;
|
|
- u64 tmp;
|
|
|
|
|
|
+ u64 tmp, tmp_rate, result;
|
|
|
|
|
|
if (rate > parent_rate)
|
|
if (rate > parent_rate)
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
@@ -67,7 +69,11 @@ static long clk_frac_round_rate(struct clk_hw *hw, unsigned long rate,
|
|
if (!div)
|
|
if (!div)
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
|
|
|
|
- return (parent_rate >> frac->width) * div;
|
|
|
|
|
|
+ tmp_rate = (u64)parent_rate * div;
|
|
|
|
+ result = tmp_rate >> frac->width;
|
|
|
|
+ if ((result << frac->width) < tmp_rate)
|
|
|
|
+ result += 1;
|
|
|
|
+ return result;
|
|
}
|
|
}
|
|
|
|
|
|
static int clk_frac_set_rate(struct clk_hw *hw, unsigned long rate,
|
|
static int clk_frac_set_rate(struct clk_hw *hw, unsigned long rate,
|