mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 20/23] i2c i.MX: Switch to clock support
Date: Wed, 26 Sep 2012 18:10:29 +0200	[thread overview]
Message-ID: <20120926161029.GY26553@game.jcrosoft.org> (raw)
In-Reply-To: <1348484692-24993-21-git-send-email-s.hauer@pengutronix.de>

On 13:04 Mon 24 Sep     , Sascha Hauer wrote:
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
>  drivers/i2c/busses/i2c-imx.c |   23 +++++++++++++++++++++--
>  1 file changed, 21 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> index 2ac043b..98c06f0 100644
> --- a/drivers/i2c/busses/i2c-imx.c
> +++ b/drivers/i2c/busses/i2c-imx.c
> @@ -37,7 +37,7 @@
>  #include <malloc.h>
>  #include <types.h>
>  #include <xfuncs.h>
> -
> +#include <linux/clk.h>
>  #include <linux/err.h>
>  
>  #include <io.h>
> @@ -101,6 +101,7 @@ static u16 i2c_clk_div[50][2] = {
>  
>  struct fsl_i2c_struct {
>  	void __iomem		*base;
> +	struct clk		*clk;
>  	struct i2c_adapter	adapter;
>  	unsigned int 		disable_delay;
>  	int			stopped;
> @@ -109,6 +110,19 @@ struct fsl_i2c_struct {
>  };
>  #define to_fsl_i2c_struct(a)	container_of(a, struct fsl_i2c_struct, adapter)
>  
> +#ifdef CONFIG_COMMON_CLK
> +static inline unsigned long i2c_fsl_clk_get_rate(struct fsl_i2c_struct *i2c_fsl)
> +{
> +	return clk_get_rate(i2c_fsl->clk);
> +}
> +
> +#else
> +static inline unsigned long i2c_fsl_clk_get_rate(struct fsl_i2c_struct *i2c_fsl)
> +{
> +	return fsl_get_i2cclk();
> +}
> +#endif
> +
>  #ifdef CONFIG_I2C_DEBUG
>  static void i2c_fsl_dump_reg(struct i2c_adapter *adapter)
>  {
> @@ -344,7 +358,7 @@ static void i2c_fsl_set_clk(struct fsl_i2c_struct *i2c_fsl,
>  	int i;
>  
>  	/* Divider value calculation */
> -	i2c_clk_rate = fsl_get_i2cclk();
> +	i2c_clk_rate = i2c_fsl_clk_get_rate(i2c_fsl);
>  	div = (i2c_clk_rate + rate - 1) / rate;
>  	if (div < i2c_clk_div[0][0])
>  		i = 0;
> @@ -535,6 +549,11 @@ static int __init i2c_fsl_probe(struct device_d *pdev)
>  
>  	i2c_fsl = kzalloc(sizeof(struct fsl_i2c_struct), GFP_KERNEL);
>  
> +#ifdef CONFIG_COMMON_CLK
if IS_ENABLED
> +	i2c_fsl->clk = clk_get(pdev, NULL);
> +	if (IS_ERR(i2c_fsl->clk))
> +		return PTR_ERR(i2c_fsl->clk);
no free on the error path?
> +#endif
>  	/* Setup i2c_fsl driver structure */
>  	i2c_fsl->adapter.master_xfer = i2c_fsl_xfer;
>  	i2c_fsl->adapter.nr = pdev->id;
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2012-09-26 16:13 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-24 11:04 [PATCH] common clk support Sascha Hauer
2012-09-24 11:04 ` [PATCH 01/23] err.h: introduce IS_ERR_OR_NULL Sascha Hauer
2012-09-24 11:04 ` [PATCH 02/23] clk clkdev: Add clkdev matching based on physbase Sascha Hauer
2012-09-26 16:02   ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-26 17:25     ` Sascha Hauer
2012-09-26 18:53       ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-26 19:09         ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-26 19:08       ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-26 21:31         ` Sascha Hauer
2012-09-24 11:04 ` [PATCH 03/23] clk: initial common clk support Sascha Hauer
2012-09-24 11:04 ` [PATCH 04/23] commands: Add clk commands Sascha Hauer
2012-09-24 11:04 ` [PATCH 05/23] ARM i.MX: initial clk support Sascha Hauer
2012-09-24 11:04 ` [PATCH 06/23] ARM i.MX27: implement " Sascha Hauer
2012-09-24 11:04 ` [PATCH 07/23] ARM i.MX25: Switch to common " Sascha Hauer
2012-09-24 11:04 ` [PATCH 08/23] ARM i.MX5: " Sascha Hauer
2012-09-24 11:36   ` Sascha Hauer
2012-09-24 11:04 ` [PATCH 09/23] ARM i.MX1: " Sascha Hauer
2012-09-24 11:04 ` [PATCH 10/23] ARM i.MX31: Switch to common clk Sascha Hauer
2012-09-24 11:04 ` [PATCH 11/23] ARM i.MX6: " Sascha Hauer
2012-09-24 11:04 ` [PATCH 12/23] ARM i.MX21: " Sascha Hauer
2012-09-24 11:04 ` [PATCH 13/23] ARM i.MX35: " Sascha Hauer
2012-09-24 11:04 ` [PATCH 14/23] net fec: Switch to clk support Sascha Hauer
2012-09-26 16:07   ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-24 11:04 ` [PATCH 15/23] serial i.MX: " Sascha Hauer
2012-09-26 16:08   ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-24 11:04 ` [PATCH 16/23] spi " Sascha Hauer
2012-09-24 11:04 ` [PATCH 17/23] ARM i.MX: Switch clocksource to clk_get Sascha Hauer
2012-09-24 11:04 ` [PATCH 18/23] mci i.MX ESDHC: Switch to clock support Sascha Hauer
2012-09-24 11:04 ` [PATCH 19/23] mci i.MX: " Sascha Hauer
2012-09-24 11:04 ` [PATCH 20/23] i2c " Sascha Hauer
2012-09-26 16:10   ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2012-09-24 11:04 ` [PATCH 21/23] video " Sascha Hauer
2012-09-24 11:04 ` [PATCH 22/23] video i.MX IPU: " Sascha Hauer
2012-09-24 11:04 ` [PATCH 23/23] ARM i.MX: Remove old " Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120926161029.GY26553@game.jcrosoft.org \
    --to=plagnioj@jcrosoft.com \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox