Patchwork [3/5] ARM: imx: add audio codec clk lookup for imx53-qsb

login
register
mail settings
Submitter Shawn Guo
Date May 11, 2012, 6:42 a.m.
Message ID <1336718568-26810-4-git-send-email-shawn.guo@linaro.org>
Download mbox | patch
Permalink /patch/158450/
State New
Headers show

Comments

Shawn Guo - May 11, 2012, 6:42 a.m.
On imx53-qsb board, the clk ssi_ext.0 is used as the clock input
to audio codec sgtl5000.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 arch/arm/mach-imx/imx53-dt.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
Sascha Hauer - May 14, 2012, 8:22 a.m.
On Fri, May 11, 2012 at 02:42:46PM +0800, Shawn Guo wrote:
> On imx53-qsb board, the clk ssi_ext.0 is used as the clock input
> to audio codec sgtl5000.
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> ---
>  arch/arm/mach-imx/imx53-dt.c |   19 +++++++++++++++++++
>  1 files changed, 19 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/arm/mach-imx/imx53-dt.c b/arch/arm/mach-imx/imx53-dt.c
> index 574eca4..139ec4e 100644
> --- a/arch/arm/mach-imx/imx53-dt.c
> +++ b/arch/arm/mach-imx/imx53-dt.c
> @@ -10,6 +10,9 @@
>   * http://www.gnu.org/copyleft/gpl.html
>   */
>  
> +#include <linux/clk.h>
> +#include <linux/clkdev.h>
> +#include <linux/err.h>
>  #include <linux/io.h>
>  #include <linux/irq.h>
>  #include <linux/irqdomain.h>
> @@ -81,6 +84,19 @@ static const struct of_device_id imx53_iomuxc_of_match[] __initconst = {
>  	{ /* sentinel */ }
>  };
>  
> +static void __init imx53_qsb_init(void)
> +{
> +	struct clk *clk;
> +
> +	clk = clk_get_sys("ssi_ext.0", NULL);
> +	if (IS_ERR(clk)) {
> +		pr_err("failed to get clk ssi_ext.0\n");
> +		return;
> +	}
> +
> +	clk_register_clkdev(clk, NULL, "0-000a");
> +}
> +
>  static void __init imx53_dt_init(void)
>  {
>  	struct device_node *node;
> @@ -99,6 +115,9 @@ static void __init imx53_dt_init(void)
>  		of_node_put(node);
>  	}
>  
> +	if (of_machine_is_compatible("fsl,imx53-qsb"))
> +		imx53_qsb_init();
> +

I wonder if we really want to open this can of worms here. Adding board
specific hacks (or fixups) in this file can become very messy once we
have more than only a few oftree based boards.

Sascha
Shawn Guo - May 14, 2012, 8:50 a.m.
On Mon, May 14, 2012 at 10:22:01AM +0200, Sascha Hauer wrote:
> >  static void __init imx53_dt_init(void)
> >  {
> >  	struct device_node *node;
> > @@ -99,6 +115,9 @@ static void __init imx53_dt_init(void)
> >  		of_node_put(node);
> >  	}
> >  
> > +	if (of_machine_is_compatible("fsl,imx53-qsb"))
> > +		imx53_qsb_init();
> > +
> 
> I wonder if we really want to open this can of worms here. Adding board
> specific hacks (or fixups) in this file can become very messy once we
> have more than only a few oftree based boards.
> 
>From what I have seen, this is an acceptable solution to board specific
setup.  What's the alternative on your mind?
Sascha Hauer - May 14, 2012, 8:53 a.m.
On Mon, May 14, 2012 at 04:50:03PM +0800, Shawn Guo wrote:
> On Mon, May 14, 2012 at 10:22:01AM +0200, Sascha Hauer wrote:
> > >  static void __init imx53_dt_init(void)
> > >  {
> > >  	struct device_node *node;
> > > @@ -99,6 +115,9 @@ static void __init imx53_dt_init(void)
> > >  		of_node_put(node);
> > >  	}
> > >  
> > > +	if (of_machine_is_compatible("fsl,imx53-qsb"))
> > > +		imx53_qsb_init();
> > > +
> > 
> > I wonder if we really want to open this can of worms here. Adding board
> > specific hacks (or fixups) in this file can become very messy once we
> > have more than only a few oftree based boards.
> > 
> From what I have seen, this is an acceptable solution to board specific
> setup.  What's the alternative on your mind?

Right now I do not have an alternative, I just try to see 2 years in the
future. Maybe until then we can do it this way and then I'll point to
this post saying 'I told you' ;)

I hope we won't get to that point. The above should be really in the
devicetree, right?

Sascha
Shawn Guo - May 14, 2012, 9:46 a.m.
On Mon, May 14, 2012 at 10:53:48AM +0200, Sascha Hauer wrote:
> I hope we won't get to that point. The above should be really in the
> devicetree, right?

If you are talking about that clk lookup, yes, the board specific clk
lookup is the best candidate going into device tree.

Patch

diff --git a/arch/arm/mach-imx/imx53-dt.c b/arch/arm/mach-imx/imx53-dt.c
index 574eca4..139ec4e 100644
--- a/arch/arm/mach-imx/imx53-dt.c
+++ b/arch/arm/mach-imx/imx53-dt.c
@@ -10,6 +10,9 @@ 
  * http://www.gnu.org/copyleft/gpl.html
  */
 
+#include <linux/clk.h>
+#include <linux/clkdev.h>
+#include <linux/err.h>
 #include <linux/io.h>
 #include <linux/irq.h>
 #include <linux/irqdomain.h>
@@ -81,6 +84,19 @@  static const struct of_device_id imx53_iomuxc_of_match[] __initconst = {
 	{ /* sentinel */ }
 };
 
+static void __init imx53_qsb_init(void)
+{
+	struct clk *clk;
+
+	clk = clk_get_sys("ssi_ext.0", NULL);
+	if (IS_ERR(clk)) {
+		pr_err("failed to get clk ssi_ext.0\n");
+		return;
+	}
+
+	clk_register_clkdev(clk, NULL, "0-000a");
+}
+
 static void __init imx53_dt_init(void)
 {
 	struct device_node *node;
@@ -99,6 +115,9 @@  static void __init imx53_dt_init(void)
 		of_node_put(node);
 	}
 
+	if (of_machine_is_compatible("fsl,imx53-qsb"))
+		imx53_qsb_init();
+
 	of_platform_populate(NULL, of_default_bus_match_table,
 			     imx53_auxdata_lookup, NULL);
 }