#include <linux/errno.h>
#include <linux/delay.h>
#include <linux/clk.h>
+#include <asm/bitops.h>
#include <asm/io.h>
* Omap2 specific clock functions
*-------------------------------------------------------------------------*/
-u8 mask_to_shift(u32 mask)
-{
- return ffs(mask) - 1;
-}
-
/**
* omap2_init_clksel_parent - set a clksel clk's parent field from the hardware
* @clk: OMAP clock struct ptr to use
return;
r = __raw_readl(clk->clksel_reg) & clk->clksel_mask;
- r >>= mask_to_shift(clk->clksel_mask);
+ r >>= __ffs(clk->clksel_mask);
for (clks = clk->clksel; clks->parent && !found; clks++) {
for (clkr = clks->rates; clkr->div && !found; clkr++) {
dpll = cm_read_reg(dd->mult_div1_reg);
dpll_mult = dpll & dd->mult_mask;
- dpll_mult >>= mask_to_shift(dd->mult_mask);
+ dpll_mult >>= __ffs(dd->mult_mask);
dpll_div = dpll & dd->div1_mask;
- dpll_div >>= mask_to_shift(dd->div1_mask);
+ dpll_div >>= __ffs(dd->div1_mask);
dpll_clk = (long long)clk->parent->rate * dpll_mult;
do_div(dpll_clk, dpll_div + 1);
return 0;
field_val = cm_read_reg(div_addr) & field_mask;
- field_val >>= mask_to_shift(field_mask);
+ field_val >>= __ffs(field_mask);
return omap2_clksel_to_divisor(clk, field_val);
}
reg_val = cm_read_reg(div_addr);
reg_val &= ~field_mask;
- reg_val |= (field_val << mask_to_shift(field_mask));
+ reg_val |= (field_val << __ffs(field_mask));
cm_write_reg(reg_val, div_addr);
wmb();
/* Set new source value (previous dividers if any in effect) */
reg_val = __raw_readl(src_addr) & ~field_mask;
- reg_val |= (field_val << mask_to_shift(field_mask));
+ reg_val |= (field_val << __ffs(field_mask));
__raw_writel(reg_val, src_addr);
wmb();
#include <asm/arch/clock.h>
#include <asm/arch/sram.h>
#include <asm/div64.h>
+#include <asm/bitops.h>
#include "memory.h"
#include "clock.h"
mult = (rate / 1000000);
done_rate = CORE_CLK_SRC_DPLL;
}
- tmpset.cm_clksel1_pll |= (div << mask_to_shift(dd->mult_mask));
- tmpset.cm_clksel1_pll |= (mult << mask_to_shift(dd->div1_mask));
+ tmpset.cm_clksel1_pll |= (div << __ffs(dd->mult_mask));
+ tmpset.cm_clksel1_pll |= (mult << __ffs(dd->div1_mask));
/* Worst case */
tmpset.base_sdrc_rfr = SDRC_RFR_CTRL_BYPASS;
#include <linux/errno.h>
#include <linux/delay.h>
#include <linux/clk.h>
-
#include <linux/io.h>
#include <asm/arch/clock.h>
#include <asm/arch/sram.h>
#include <asm/div64.h>
+#include <asm/bitops.h>
#include "memory.h"
#include "clock.h"
WARN_ON(!dd->control_reg || !dd->enable_mask);
v = cm_read_reg(dd->control_reg) & dd->enable_mask;
- v >>= mask_to_shift(dd->enable_mask);
+ v >>= __ffs(dd->enable_mask);
if (v != DPLL_LOCKED)
clk->rate = clk->parent->rate;
else