]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/arm/plat-omap/clock.c
[ARM] OMAP clock: drop clk_get_usecount()
[linux-2.6-omap-h63xx.git] / arch / arm / plat-omap / clock.c
index 7b040072859410baaa763c7568359c46bb3a526d..9833d73511a196850a7e48b5ef235562d3a4f05a 100644 (file)
@@ -36,43 +36,6 @@ static struct clk_functions *arch_clock;
  * Standard clock functions defined in include/linux/clk.h
  *-------------------------------------------------------------------------*/
 
-/*
- * Returns a clock. Note that we first try to use device id on the bus
- * and clock name. If this fails, we try to use clock name only.
- */
-struct clk * clk_get(struct device *dev, const char *id)
-{
-       struct clk *p, *clk = ERR_PTR(-ENOENT);
-       int idno;
-
-       if (dev == NULL || dev->bus != &platform_bus_type)
-               idno = -1;
-       else
-               idno = to_platform_device(dev)->id;
-
-       mutex_lock(&clocks_mutex);
-
-       list_for_each_entry(p, &clocks, node) {
-               if (p->id == idno && strcmp(id, p->name) == 0) {
-                       clk = p;
-                       goto found;
-               }
-       }
-
-       list_for_each_entry(p, &clocks, node) {
-               if (strcmp(id, p->name) == 0) {
-                       clk = p;
-                       break;
-               }
-       }
-
-found:
-       mutex_unlock(&clocks_mutex);
-
-       return clk;
-}
-EXPORT_SYMBOL(clk_get);
-
 int clk_enable(struct clk *clk)
 {
        unsigned long flags;
@@ -113,22 +76,6 @@ out:
 }
 EXPORT_SYMBOL(clk_disable);
 
-int clk_get_usecount(struct clk *clk)
-{
-       unsigned long flags;
-       int ret = 0;
-
-       if (clk == NULL || IS_ERR(clk))
-               return 0;
-
-       spin_lock_irqsave(&clockfw_lock, flags);
-       ret = clk->usecount;
-       spin_unlock_irqrestore(&clockfw_lock, flags);
-
-       return ret;
-}
-EXPORT_SYMBOL(clk_get_usecount);
-
 unsigned long clk_get_rate(struct clk *clk)
 {
        unsigned long flags;
@@ -145,11 +92,6 @@ unsigned long clk_get_rate(struct clk *clk)
 }
 EXPORT_SYMBOL(clk_get_rate);
 
-void clk_put(struct clk *clk)
-{
-}
-EXPORT_SYMBOL(clk_put);
-
 /*-------------------------------------------------------------------------
  * Optional clock functions defined in include/linux/clk.h
  *-------------------------------------------------------------------------*/
@@ -182,6 +124,11 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
        spin_lock_irqsave(&clockfw_lock, flags);
        if (arch_clock->clk_set_rate)
                ret = arch_clock->clk_set_rate(clk, rate);
+       if (ret == 0) {
+               if (clk->recalc)
+                       clk->recalc(clk);
+               propagate_rate(clk);
+       }
        spin_unlock_irqrestore(&clockfw_lock, flags);
 
        return ret;
@@ -198,7 +145,12 @@ int clk_set_parent(struct clk *clk, struct clk *parent)
 
        spin_lock_irqsave(&clockfw_lock, flags);
        if (arch_clock->clk_set_parent)
-               ret =  arch_clock->clk_set_parent(clk, parent);
+               ret = arch_clock->clk_set_parent(clk, parent);
+       if (ret == 0) {
+               if (clk->recalc)
+                       clk->recalc(clk);
+               propagate_rate(clk);
+       }
        spin_unlock_irqrestore(&clockfw_lock, flags);
 
        return ret;
@@ -207,18 +159,7 @@ EXPORT_SYMBOL(clk_set_parent);
 
 struct clk *clk_get_parent(struct clk *clk)
 {
-       unsigned long flags;
-       struct clk * ret = NULL;
-
-       if (clk == NULL || IS_ERR(clk))
-               return ret;
-
-       spin_lock_irqsave(&clockfw_lock, flags);
-       if (arch_clock->clk_get_parent)
-               ret = arch_clock->clk_get_parent(clk);
-       spin_unlock_irqrestore(&clockfw_lock, flags);
-
-       return ret;
+       return clk->parent;
 }
 EXPORT_SYMBOL(clk_get_parent);
 
@@ -253,8 +194,17 @@ void followparent_recalc(struct clk *clk)
                return;
 
        clk->rate = clk->parent->rate;
-       if (unlikely(clk->flags & RATE_PROPAGATES))
-               propagate_rate(clk);
+}
+
+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 */
@@ -262,17 +212,15 @@ void propagate_rate(struct clk * tclk)
 {
        struct clk *clkp;
 
-       if (tclk == NULL || IS_ERR(tclk))
-               return;
-
-       list_for_each_entry(clkp, &clocks, node) {
-               if (likely(clkp->parent != tclk))
-                       continue;
-               if (likely((u32)clkp->recalc))
+       list_for_each_entry(clkp, &tclk->children, sibling) {
+               if (clkp->recalc)
                        clkp->recalc(clkp);
+               propagate_rate(clkp);
        }
 }
 
+static LIST_HEAD(root_clks);
+
 /**
  * recalculate_root_clocks - recalculate and propagate all root clocks
  *
@@ -284,18 +232,35 @@ void recalculate_root_clocks(void)
 {
        struct clk *clkp;
 
-       list_for_each_entry(clkp, &clocks, node) {
-               if (unlikely(!clkp->parent) && likely((u32)clkp->recalc))
+       list_for_each_entry(clkp, &root_clks, sibling) {
+               if (clkp->recalc)
                        clkp->recalc(clkp);
+               propagate_rate(clkp);
        }
 }
 
+void clk_init_one(struct clk *clk)
+{
+       INIT_LIST_HEAD(&clk->children);
+}
+
 int clk_register(struct clk *clk)
 {
        if (clk == NULL || IS_ERR(clk))
                return -EINVAL;
 
+       /*
+        * trap out already registered clocks
+        */
+       if (clk->node.next || clk->node.prev)
+               return 0;
+
        mutex_lock(&clocks_mutex);
+       if (clk->parent)
+               list_add(&clk->sibling, &clk->parent->children);
+       else
+               list_add(&clk->sibling, &root_clks);
+
        list_add(&clk->node, &clocks);
        if (clk->init)
                clk->init(clk);
@@ -311,6 +276,7 @@ void clk_unregister(struct clk *clk)
                return;
 
        mutex_lock(&clocks_mutex);
+       list_del(&clk->sibling);
        list_del(&clk->node);
        mutex_unlock(&clocks_mutex);
 }