aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/clk/sunxi/clk-sunxi.c36
-rw-r--r--include/linux/clk/sunxi.h22
2 files changed, 58 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
diff --git a/include/linux/clk/sunxi.h b/include/linux/clk/sunxi.h
new file mode 100644
index 000000000000..1ef5c899e458
--- /dev/null
+++ b/include/linux/clk/sunxi.h
@@ -0,0 +1,22 @@
1/*
2 * Copyright 2013 - Hans de Goede <hdegoede@redhat.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
15#ifndef __LINUX_CLK_SUNXI_H_
16#define __LINUX_CLK_SUNXI_H_
17
18#include <linux/clk.h>
19
20void clk_sunxi_mmc_phase_control(struct clk_hw *hw, u8 sample, u8 output);
21
22#endif