title: how to get a clock from a device tree node
body: <p>I have the following issue: I want to define the clock a CPU should use during frequency transitions in the device tree rather than in the clock driver code (in this way it will be more generic). I want to define the "transition-clock" property in the device tree, something like:</p>
  
  <pre><code> 232         cpu: cpu@01c20050 {
   233             #clock-cells = &lt;0&gt;;
   234             compatible = "allwinner,sun4i-a10-cpu-clk";
   235             reg = &lt;0x01c20050 0x4&gt;;
  -----
   243             clocks = &lt;&amp;osc32k&gt;, &lt;&amp;osc24M&gt;, &lt;&amp;pll1&gt;, &lt;&amp;pll1&gt;;
   244             transition-clock = &lt;&amp;osc24M&gt;;
   245             clock-output-names = "cpu";
   246         };
  </code></pre>
  
  <p>I changed the file "drivers/clk/clkdev.c" to search this property so I can get a clk pointer and store it in a new property in the cpu clock structure. This is what I have managed so far (changes begin on line 78):</p>
  
  <pre><code> 59 static struct clk *__of_clk_get(struct device_node *np, int index,
   60                    const char *dev_id, const char *con_id)
   61 {
   62     struct of_phandle_args clkspec;
   63     struct clk *clk, *transition_clk;
   64     struct device_node *clock_node, *transition_clock_node;
   65     int rc;
   66     
   67     if (index &lt; 0)
   68         return ERR_PTR(-EINVAL);
   69         
   70     rc = of_parse_phandle_with_args(np, "clocks", "#clock-cells", index,
   71                     &amp;clkspec);
   72     if (rc)         
   73         return ERR_PTR(rc);
   74         
   75     clk = __of_clk_get_by_clkspec(&amp;clkspec, dev_id, con_id);
   76     of_node_put(clkspec.np);
   77     
   78     clock_node = of_parse_phandle(np, "clocks", 0);
   79     pr_err("-------------------- parsing node %s\n", np-&gt;name);
   80     if (clock_node!=NULL) {
   81         pr_err("============ Clock node found %p\n", clock_node);
   82         transition_clock_node =
   83             of_parse_phandle(clock_node, "transition-clock", 0);
   84         if (transition_clock_node!=NULL) {
   85             pr_err("============ Transition clock node found %p\n",
   86                 transition_clock_node);
   87             transition_clk = clk_get(clock_node, 0);
   88             pr_err("============ Transition clock %p\n", transition_clk);
   89         }
   90     }
   91     
   92     return clk;
   93 }
  </code></pre>
  
  <p>I get pointers to the clock node and the transition clock node, but when I try to get a clock pointer from that, I get 0xfffffffe, which looks like an error:</p>
  
  <pre><code>[    2.540542] -------------------- parsing node cpu
  [    2.540546] ============ Clock node found eeef9520
  [    2.540550] ============ Transition clock node found eeef8934
  [    2.540555] ============ Transition clock fffffffe
  </code></pre>
  
  <p>I want a clock object which I can later use in </p>
  
  <pre><code>clk_set_parent(cpu_clk, cpu_clk-&gt;transition_clk)
  </code></pre>
  
  <p>Any ideas are welcome :)</p>