150-1-clk-sunxi-implement-mmc-phasectrl.patch 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. From 4f43ab43125a12dbc23e352ac0eb4fd80a876fb5 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Emilio=20L=C3=B3pez?= <[email protected]>
  3. Date: Fri, 20 Sep 2013 20:29:17 -0300
  4. Subject: [PATCH] clk: sunxi: Implement MMC phase control
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. Signed-off-by: Emilio López <[email protected]>
  9. ---
  10. drivers/clk/sunxi/clk-sunxi.c | 35 +++++++++++++++++++++++++++++++++++
  11. 1 file changed, 35 insertions(+)
  12. --- a/drivers/clk/sunxi/clk-sunxi.c
  13. +++ b/drivers/clk/sunxi/clk-sunxi.c
  14. @@ -361,6 +361,41 @@ static void sun4i_get_mod0_factors(u32 *
  15. /**
  16. + * clk_sunxi_mmc_phase_control() - configures MMC clock phase control
  17. + */
  18. +
  19. +void clk_sunxi_mmc_phase_control(struct clk_hw *hw, u8 sample, u8 output)
  20. +{
  21. + #define to_clk_composite(_hw) container_of(_hw, struct clk_composite, hw)
  22. + #define to_clk_factors(_hw) container_of(_hw, struct clk_factors, hw)
  23. +
  24. + struct clk_composite *composite = to_clk_composite(hw);
  25. + struct clk_hw *rate_hw = composite->rate_hw;
  26. + struct clk_factors *factors = to_clk_factors(rate_hw);
  27. + unsigned long flags = 0;
  28. + u32 reg;
  29. +
  30. + if (factors->lock)
  31. + spin_lock_irqsave(factors->lock, flags);
  32. +
  33. + reg = readl(factors->reg);
  34. +
  35. + /* set sample clock phase control */
  36. + reg &= ~(0x7 << 20);
  37. + reg |= ((sample & 0x7) << 20);
  38. +
  39. + /* set output clock phase control */
  40. + reg &= ~(0x7 << 8);
  41. + reg |= ((output & 0x7) << 8);
  42. +
  43. + writel(reg, factors->reg);
  44. +
  45. + if (factors->lock)
  46. + spin_unlock_irqrestore(factors->lock, flags);
  47. +}
  48. +
  49. +
  50. +/**
  51. * sunxi_factors_clk_setup() - Setup function for factor clocks
  52. */