|
@@ -631,3 +631,145 @@ void clk_disable(struct clk *clk)
|
|
|
unsigned long flags;
|
|
|
|
|
|
if (clk == NULL || IS_ERR(clk))
|
|
|
+ return;
|
|
|
+
|
|
|
+ spin_lock_irqsave(&clockfw_lock, flags);
|
|
|
+ if (clk->usecount == 0) {
|
|
|
+ pr_err("Trying disable clock %s with 0 usecount\n",
|
|
|
+ clk->name);
|
|
|
+ WARN_ON(1);
|
|
|
+ goto out;
|
|
|
+ }
|
|
|
+
|
|
|
+ omap1_clk_disable(clk);
|
|
|
+
|
|
|
+out:
|
|
|
+ spin_unlock_irqrestore(&clockfw_lock, flags);
|
|
|
+}
|
|
|
+EXPORT_SYMBOL(clk_disable);
|
|
|
+
|
|
|
+unsigned long clk_get_rate(struct clk *clk)
|
|
|
+{
|
|
|
+ unsigned long flags;
|
|
|
+ unsigned long ret;
|
|
|
+
|
|
|
+ if (clk == NULL || IS_ERR(clk))
|
|
|
+ return 0;
|
|
|
+
|
|
|
+ spin_lock_irqsave(&clockfw_lock, flags);
|
|
|
+ ret = clk->rate;
|
|
|
+ spin_unlock_irqrestore(&clockfw_lock, flags);
|
|
|
+
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+EXPORT_SYMBOL(clk_get_rate);
|
|
|
+
|
|
|
+/*
|
|
|
+ * Optional clock functions defined in include/linux/clk.h
|
|
|
+ */
|
|
|
+
|
|
|
+long clk_round_rate(struct clk *clk, unsigned long rate)
|
|
|
+{
|
|
|
+ unsigned long flags;
|
|
|
+ long ret;
|
|
|
+
|
|
|
+ if (clk == NULL || IS_ERR(clk))
|
|
|
+ return 0;
|
|
|
+
|
|
|
+ spin_lock_irqsave(&clockfw_lock, flags);
|
|
|
+ ret = omap1_clk_round_rate(clk, rate);
|
|
|
+ spin_unlock_irqrestore(&clockfw_lock, flags);
|
|
|
+
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+EXPORT_SYMBOL(clk_round_rate);
|
|
|
+
|
|
|
+int clk_set_rate(struct clk *clk, unsigned long rate)
|
|
|
+{
|
|
|
+ unsigned long flags;
|
|
|
+ int ret = -EINVAL;
|
|
|
+
|
|
|
+ if (clk == NULL || IS_ERR(clk))
|
|
|
+ return ret;
|
|
|
+
|
|
|
+ spin_lock_irqsave(&clockfw_lock, flags);
|
|
|
+ ret = omap1_clk_set_rate(clk, rate);
|
|
|
+ if (ret == 0)
|
|
|
+ propagate_rate(clk);
|
|
|
+ spin_unlock_irqrestore(&clockfw_lock, flags);
|
|
|
+
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+EXPORT_SYMBOL(clk_set_rate);
|
|
|
+
|
|
|
+int clk_set_parent(struct clk *clk, struct clk *parent)
|
|
|
+{
|
|
|
+ WARN_ONCE(1, "clk_set_parent() not implemented for OMAP1\n");
|
|
|
+
|
|
|
+ return -EINVAL;
|
|
|
+}
|
|
|
+EXPORT_SYMBOL(clk_set_parent);
|
|
|
+
|
|
|
+struct clk *clk_get_parent(struct clk *clk)
|
|
|
+{
|
|
|
+ return clk->parent;
|
|
|
+}
|
|
|
+EXPORT_SYMBOL(clk_get_parent);
|
|
|
+
|
|
|
+/*
|
|
|
+ * OMAP specific clock functions shared between omap1 and omap2
|
|
|
+ */
|
|
|
+
|
|
|
+int __initdata mpurate;
|
|
|
+
|
|
|
+/*
|
|
|
+ * By default we use the rate set by the bootloader.
|
|
|
+ * You can override this with mpurate= cmdline option.
|
|
|
+ */
|
|
|
+static int __init omap_clk_setup(char *str)
|
|
|
+{
|
|
|
+ get_option(&str, &mpurate);
|
|
|
+
|
|
|
+ if (!mpurate)
|
|
|
+ return 1;
|
|
|
+
|
|
|
+ if (mpurate < 1000)
|
|
|
+ mpurate *= 1000000;
|
|
|
+
|
|
|
+ return 1;
|
|
|
+}
|
|
|
+__setup("mpurate=", omap_clk_setup);
|
|
|
+
|
|
|
+/* Used for clocks that always have same value as the parent clock */
|
|
|
+unsigned long followparent_recalc(struct clk *clk)
|
|
|
+{
|
|
|
+ return clk->parent->rate;
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * Used for clocks that have the same value as the parent clock,
|
|
|
+ * divided by some factor
|
|
|
+ */
|
|
|
+unsigned long omap_fixed_divisor_recalc(struct clk *clk)
|
|
|
+{
|
|
|
+ WARN_ON(!clk->fixed_div);
|
|
|
+
|
|
|
+ return clk->parent->rate / clk->fixed_div;
|
|
|
+}
|
|
|
+
|
|
|
+void clk_reparent(struct clk *child, struct clk *parent)
|
|
|
+{
|
|
|
+ list_del_init(&child->sibling);
|
|
|
+ if (parent)
|
|
|
+ list_add(&child->sibling, &parent->children);
|
|
|
+ child->parent = parent;
|
|
|
+
|
|
|
+ /* now do the debugfs renaming to reattach the child
|
|
|
+ to the proper parent */
|
|
|
+}
|
|
|
+
|
|
|
+/* Propagate rate to children */
|
|
|
+void propagate_rate(struct clk *tclk)
|
|
|
+{
|
|
|
+ struct clk *clkp;
|
|
|
+
|