aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clk/sunxi/clk-sunxi.c
diff options
context:
space:
mode:
authorEmilio López <emilio@elopez.com.ar>2014-05-02 11:57:16 -0400
committerMike Turquette <mturquette@linaro.org>2014-05-05 18:55:57 -0400
commit95713978b0a2929b72933235bb07c0a793e71afa (patch)
treeaab5a046acf7561c644350a1908c40bec5848fd8 /drivers/clk/sunxi/clk-sunxi.c
parent862b728387aef3a3776ad2a261e484aff36c5e67 (diff)
clk: sunxi: Implement MMC phase control
HdG: add header exporting clk_sunxi_mmc_phase_control Signed-off-by: Emilio López <emilio@elopez.com.ar> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mike Turquette <mturquette@linaro.org>
Diffstat (limited to 'drivers/clk/sunxi/clk-sunxi.c')
-rw-r--r--drivers/clk/sunxi/clk-sunxi.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c
index bd7dc733c1ca..59f90401b900 100644
--- a/drivers/clk/sunxi/clk-sunxi.c
+++ b/drivers/clk/sunxi/clk-sunxi.c
@@ -507,6 +507,42 @@ CLK_OF_DECLARE(sun7i_a20_gmac, "allwinner,sun7i-a20-gmac-clk",
507 507
508 508
509/** 509/**
510 * clk_sunxi_mmc_phase_control() - configures MMC clock phase control
511 */
512
513void clk_sunxi_mmc_phase_control(struct clk_hw *hw, u8 sample, u8 output)
514{
515 #define to_clk_composite(_hw) container_of(_hw, struct clk_composite, hw)
516 #define to_clk_factors(_hw) container_of(_hw, struct clk_factors, hw)
517
518 struct clk_composite *composite = to_clk_composite(hw);
519 struct clk_hw *rate_hw = composite->rate_hw;
520 struct clk_factors *factors = to_clk_factors(rate_hw);
521 unsigned long flags = 0;
522 u32 reg;
523
524 if (factors->lock)
525 spin_lock_irqsave(factors->lock, flags);
526
527 reg = readl(factors->reg);
528
529 /* set sample clock phase control */
530 reg &= ~(0x7 << 20);
531 reg |= ((sample & 0x7) << 20);
532
533 /* set output clock phase control */
534 reg &= ~(0x7 << 8);
535 reg |= ((output & 0x7) << 8);
536
537 writel(reg, factors->reg);
538
539 if (factors->lock)
540 spin_unlock_irqrestore(factors->lock, flags);
541}
542EXPORT_SYMBOL(clk_sunxi_mmc_phase_control);
543
544
545/**
510 * sunxi_factors_clk_setup() - Setup function for factor clocks 546 * sunxi_factors_clk_setup() - Setup function for factor clocks
511 */ 547 */
512 548