Re: [PATCH] i2c i.MX: Fix divider table

2012-07-11 Thread Richard Zhao
On Fri, Jul 06, 2012 at 08:28:52AM +0200, Sascha Hauer wrote:
 On Fri, Jul 06, 2012 at 08:52:50AM +0800, Richard Zhao wrote:
  On Thu, Jul 05, 2012 at 06:01:53PM +0200, Sascha Hauer wrote:
   On Thu, Jul 05, 2012 at 10:52:39PM +0800, Richard Zhao wrote:
On Thu, Jul 05, 2012 at 03:10:26PM +0200, Sascha Hauer wrote:
 Measurements on i.MX1 and i.MX53 have shown that the divider values
 in the datasheets are wrong. the values from first, third and fourth
 column were all measured to be 8 higher than in the datasheet. It
 should be safe to assume that the SoCs between i.MX1 and i.MX53 behave
 the same as the i2c unit is unchanged since the i.MX1.
We may need to check with IC guys? Or you've done?
   
   I don't have contact to the IC guys. Could you do this? I'd be
   interested in the results.
  Sure, but it may be slow, as you know, many people are in summer break.
 
 Thanks. It can take longer, the resulting frequencies are all too low,
 so we are on the safe side.
Sascha,

IC guys confirmed that the spec is right:

This an adaptive feature of our I2C module may apply to all IMX chips.
No mistake in the table of RMs.

The divider is designed to guarantee SCL high level and low level last
time. Divider will hold when SCL transition from 1 to 0 or 0 to 1, if
the transition time is longer than 1 internal pre-divided clock cycle.
The pre-divided clock is divided from I2C module clock, used for
generating SCL. So you will see SCL clock cycle is some way longer than
calculated value using IFDR.

Transition time will different from rising or falling edge, different
pull-up resistors, and different SCL loading.

This feature make sure transition time won’t eat both level time of SCL.

Thanks
Richard
 
 Sascha
 
 -- 
 Pengutronix e.K.   | |
 Industrial Linux Solutions | http://www.pengutronix.de/  |
 Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
 Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
 

--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] i2c i.MX: Fix divider table

2012-07-11 Thread Richard Zhao
On Wed, Jul 11, 2012 at 08:38:38PM +0200, Sascha Hauer wrote:
 Hi Richard,
 
 On Wed, Jul 11, 2012 at 02:01:21PM +0800, Richard Zhao wrote:
  
  IC guys confirmed that the spec is right:
  
  This an adaptive feature of our I2C module may apply to all IMX chips.
  No mistake in the table of RMs.
  
  The divider is designed to guarantee SCL high level and low level last
  time. Divider will hold when SCL transition from 1 to 0 or 0 to 1, if
  the transition time is longer than 1 internal pre-divided clock cycle.
  The pre-divided clock is divided from I2C module clock, used for
  generating SCL. So you will see SCL clock cycle is some way longer than
  calculated value using IFDR.
  
  Transition time will different from rising or falling edge, different
  pull-up resistors, and different SCL loading.
  
  This feature make sure transition time won’t eat both level time of SCL.
 
 Thanks for clarification. Does this mean that this feature is used to
 synchronize between the bus clock and and bitclock?
Per my understanding,
Not exactly. Divided clock is only used for count time of SCL level
hold. This means, even if the i2c bus loading is high (long level
setup time), the i2c may still work.

Thanks
Richard
 
 I'll send a documentation patch for this next week to make this clear.
 
 Sascha
 
 -- 
 Pengutronix e.K.   | |
 Industrial Linux Solutions | http://www.pengutronix.de/  |
 Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
 Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
 

--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] i2c: imx: make bitrate unsigned int

2012-07-09 Thread Richard Zhao
On Sun, Jul 08, 2012 at 01:24:47PM +0200, Wolfram Sang wrote:
 sparse found this assignment of u32 to an int. Fix it:
 
 drivers/i2c/busses/i2c-imx.c:540:56: warning: incorrect type in argument 3 
 (different signedness)
Could you change imxi2c_platform_data.bitrate to unsigned int too?

Thanks
Richard
 
 Signed-off-by: Wolfram Sang wolf...@the-dreams.de
 Cc: Richard Zhao richard.z...@freescale.com
 ---
  drivers/i2c/busses/i2c-imx.c |4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
 index a93e846..3f5dfe8 100644
 --- a/drivers/i2c/busses/i2c-imx.c
 +++ b/drivers/i2c/busses/i2c-imx.c
 @@ -471,8 +471,8 @@ static int __init i2c_imx_probe(struct platform_device 
 *pdev)
   struct imxi2c_platform_data *pdata = pdev-dev.platform_data;
   struct pinctrl *pinctrl;
   void __iomem *base;
 - int irq, bitrate;
 - int ret;
 + int irq, ret;
 + u32 bitrate;
  
   dev_dbg(pdev-dev, %s\n, __func__);
  
 -- 
 1.7.10
 
 

--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V2] i2c: imx: make bitrate an u32 type

2012-07-09 Thread Richard Zhao
On Tue, Jul 10, 2012 at 12:28:30AM +0200, Wolfram Sang wrote:
 sparse found this assignment of u32 to an int. Fix it:
 
 drivers/i2c/busses/i2c-imx.c:540:56: warning: incorrect type in argument 3 
 (different signedness)
 
 and also fix the type in platform_data. All current users use values
 which fit into the old and new type, so it is a safe change.
 
 Signed-off-by: Wolfram Sang wolf...@the-dreams.de
 Cc: Richard Zhao richard.z...@freescale.com
 Cc: Sascha Hauer s.ha...@pengutronix.de
Reviewed-by: Richard Zhao richard.z...@freescale.com
 ---
 
 Changes since V1: also change type in platform_data. Thanks to Richard.
 
  arch/arm/plat-mxc/include/mach/i2c.h |2 +-
  drivers/i2c/busses/i2c-imx.c |4 ++--
  2 files changed, 3 insertions(+), 3 deletions(-)
 
 diff --git a/arch/arm/plat-mxc/include/mach/i2c.h 
 b/arch/arm/plat-mxc/include/mach/i2c.h
 index 375cdd0..8289d91 100644
 --- a/arch/arm/plat-mxc/include/mach/i2c.h
 +++ b/arch/arm/plat-mxc/include/mach/i2c.h
 @@ -15,7 +15,7 @@
   *
   **/
  struct imxi2c_platform_data {
 - int bitrate;
 + u32 bitrate;
  };
  
  #endif /* __ASM_ARCH_I2C_H_ */
 diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
 index dd2a083..90460dd 100644
 --- a/drivers/i2c/busses/i2c-imx.c
 +++ b/drivers/i2c/busses/i2c-imx.c
 @@ -471,8 +471,8 @@ static int __init i2c_imx_probe(struct platform_device 
 *pdev)
   struct imxi2c_platform_data *pdata = pdev-dev.platform_data;
   struct pinctrl *pinctrl;
   void __iomem *base;
 - int irq, bitrate;
 - int ret;
 + int irq, ret;
 + u32 bitrate;
  
   dev_dbg(pdev-dev, %s\n, __func__);
  
 -- 
 1.7.10.4
 
 
 ___
 linux-arm-kernel mailing list
 linux-arm-ker...@lists.infradead.org
 http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] i2c i.MX: Fix divider table

2012-07-05 Thread Richard Zhao
On Thu, Jul 05, 2012 at 03:10:26PM +0200, Sascha Hauer wrote:
 Measurements on i.MX1 and i.MX53 have shown that the divider values
 in the datasheets are wrong. the values from first, third and fourth
 column were all measured to be 8 higher than in the datasheet. It
 should be safe to assume that the SoCs between i.MX1 and i.MX53 behave
 the same as the i2c unit is unchanged since the i.MX1.
We may need to check with IC guys? Or you've done?

Thanks
Richard
 
 Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
 ---
  drivers/i2c/busses/i2c-imx.c |   31 ++-
  1 file changed, 18 insertions(+), 13 deletions(-)
 
 diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
 index 8d6b504..aabbe31 100644
 --- a/drivers/i2c/busses/i2c-imx.c
 +++ b/drivers/i2c/busses/i2c-imx.c
 @@ -98,22 +98,27 @@
   * Document Number: MC9328MXLRM, Rev. 5.1, 06/2007
   *
   * Duplicated divider values removed from list
 + *
 + * These values (mostly) do not match the ones in the datasheet because
 + * measurements have shown that the values are wrong. This was tested
 + * on i.MX1 and i.MX53, so it shoud be safe to assume that the SoCs in
 + * between behave the same.
   */
  
  static u16 __initdata i2c_clk_div[50][2] = {
 - { 22,   0x20 }, { 24,   0x21 }, { 26,   0x22 }, { 28,   0x23 },
 - { 30,   0x00 }, { 32,   0x24 }, { 36,   0x25 }, { 40,   0x26 },
 - { 42,   0x03 }, { 44,   0x27 }, { 48,   0x28 }, { 52,   0x05 },
 - { 56,   0x29 }, { 60,   0x06 }, { 64,   0x2A }, { 72,   0x2B },
 - { 80,   0x2C }, { 88,   0x09 }, { 96,   0x2D }, { 104,  0x0A },
 - { 112,  0x2E }, { 128,  0x2F }, { 144,  0x0C }, { 160,  0x30 },
 - { 192,  0x31 }, { 224,  0x32 }, { 240,  0x0F }, { 256,  0x33 },
 - { 288,  0x10 }, { 320,  0x34 }, { 384,  0x35 }, { 448,  0x36 },
 - { 480,  0x13 }, { 512,  0x37 }, { 576,  0x14 }, { 640,  0x38 },
 - { 768,  0x39 }, { 896,  0x3A }, { 960,  0x17 }, { 1024, 0x3B },
 - { 1152, 0x18 }, { 1280, 0x3C }, { 1536, 0x3D }, { 1792, 0x3E },
 - { 1920, 0x1B }, { 2048, 0x3F }, { 2304, 0x1C }, { 2560, 0x1D },
 - { 3072, 0x1E }, { 3840, 0x1F }
 + { 30,   0x20 }, { 32,   0x21 }, { 34,   0x22 }, { 36,   0x23 },
 + { 38,   0x00 }, { 40,   0x24 }, { 44,   0x25 }, { 48,   0x26 },
 + { 50,   0x03 }, { 52,   0x27 }, { 56,   0x28 }, { 60,   0x05 },
 + { 64,   0x29 }, { 68,   0x06 }, { 72,   0x2A }, { 80,   0x2B },
 + { 88,   0x2C }, { 96,   0x09 }, { 104,  0x2D }, { 112,  0x0A },
 + { 120,  0x2E }, { 136,  0x2F }, { 152,  0x0C }, { 168,  0x30 },
 + { 200,  0x31 }, { 232,  0x32 }, { 248,  0x0F }, { 264,  0x33 },
 + { 288,  0x10 }, { 328,  0x34 }, { 392,  0x35 }, { 456,  0x36 },
 + { 480,  0x13 }, { 520,  0x37 }, { 576,  0x14 }, { 648,  0x38 },
 + { 776,  0x39 }, { 904,  0x3A }, { 960,  0x17 }, { 1032, 0x3B },
 + { 1152, 0x18 }, { 1288, 0x3C }, { 1544, 0x3D }, { 1800, 0x3E },
 + { 1920, 0x1B }, { 2048, 0x3F }, { 2304, 0x1C }, { 2560, 0x1D },
 + { 3072, 0x1E }, { 3840, 0x1F }
  };
  
  struct imx_i2c_struct {
 -- 
 1.7.10
 
 
 ___
 linux-arm-kernel mailing list
 linux-arm-ker...@lists.infradead.org
 http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V2 00/11] enable imx6q_sabrelite sgtl5000 audio support

2012-05-21 Thread Richard Zhao
Hi Mark,

   ASoC: imx-audmux: add pinctrl support
   ASoC: fsl_ssi: convert to use devm_clk_get
Linus has sent out pull request for pinctrl. So is that ok for you
to pick up the above two patch?

Thanks
Richard

--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V2 00/11] enable imx6q_sabrelite sgtl5000 audio support

2012-05-21 Thread Richard Zhao
On Mon, May 21, 2012 at 03:45:44PM +0100, Mark Brown wrote:
 On Mon, May 21, 2012 at 08:59:31PM +0800, Richard Zhao wrote:
 
 ASoC: imx-audmux: add pinctrl support
 ASoC: fsl_ssi: convert to use devm_clk_get
 
  Linus has sent out pull request for pinctrl. So is that ok for you
  to pick up the above two patch?
 
 No, apart from anything else the second patch depends on clkdev which is
 nothing to do with pinctrl!
All right, It's my fault to mix a clean up patch. It may hold until the
merge window is closed.
  For the first patch it wasn't clear if the
 changes in pinctrl were the actual dependencies or if there were more
 things needed from the ARM tree,
I remembered someone already explained the dependencies. It depends
on imx pinctrl work and dummy pinctrl enabled in ARM platform code. It
is why Shawn suggest it goes to ARM SoC.
 and in any case until those patches are
 actually in the ASoC tree we'll break the build if they get applied.
All righ, It's ok, if you think, I have to wait for one more cycle to
see the patch on mainline.
 
 Guys, you really need to think about how you're organising what you're
 doing more.  You need to split your work out into focused lines of
 development rather than just having a single branch.  
Except the clean up patch, others are all related to enable audio. Do
you mean I supposed to split them in advance?
 
 This patch series contains a whole bunch of different changes (the
 devm_clk_get() change is as far as I can tell completely unrelated to
 the rest for example) with unclear dependencies on multiple external
 trees.  You should be splitting unrelated changes out, trying to
 minimise interdependencies, and clearly identifying the dependencies
 that are there we can get things applied in a timely fashion.
hmm.. I should write more about dependencies in commit message.
 
 Please resend these patches *after* their dependencies are in mainline.
OK.

Thanks
Richard

--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] i2c: imx: convert to use managed functions

2012-05-13 Thread Richard Zhao
On Mon, May 14, 2012 at 11:05:03AM +0800, Shawn Guo wrote:
 On Sat, May 12, 2012 at 09:02:23PM +0800, Richard Zhao wrote:
  Signed-off-by: Richard Zhao richard.z...@freescale.com
  ---
   drivers/i2c/busses/i2c-imx.c |   59 
  ++
   1 file changed, 14 insertions(+), 45 deletions(-)
  
 Nice cleanup.
 
  diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
  index 56bce9a..927da64 100644
  --- a/drivers/i2c/busses/i2c-imx.c
  +++ b/drivers/i2c/busses/i2c-imx.c
  @@ -118,7 +118,6 @@ static u16 __initdata i2c_clk_div[50][2] = {
   
   struct imx_i2c_struct {
  struct i2c_adapter  adapter;
  -   struct resource *res;
  struct clk  *clk;
  void __iomem*base;
  int irq;
 
 Is it being used elsewhere except i2c_imx_probe()?  If not, we can
 remove it from the struct?
Nice catch.
 
  @@ -473,7 +472,6 @@ static int __init i2c_imx_probe(struct platform_device 
  *pdev)
  struct imxi2c_platform_data *pdata = pdev-dev.platform_data;
  struct pinctrl *pinctrl;
  void __iomem *base;
  -   resource_size_t res_size;
  int irq, bitrate;
  int ret;
   
  @@ -490,25 +488,16 @@ static int __init i2c_imx_probe(struct 
  platform_device *pdev)
  return -ENOENT;
  }
   
  -   res_size = resource_size(res);
  -
  -   if (!request_mem_region(res-start, res_size, DRIVER_NAME)) {
  -   dev_err(pdev-dev, request_mem_region failed\n);
  +   base = devm_request_and_ioremap(pdev-dev, res);
  +   if (!base)
  return -EBUSY;
 
 Since we are moving to devm_request_and_ioremap, I'd recommend change
 the error code to what the function kerneldoc suggests, -EADDRNOTAVAIL.
Correct.
 
  -   }
  -
  -   base = ioremap(res-start, res_size);
  -   if (!base) {
  -   dev_err(pdev-dev, ioremap failed\n);
  -   ret = -EIO;
  -   goto fail1;
  -   }
   
  -   i2c_imx = kzalloc(sizeof(struct imx_i2c_struct), GFP_KERNEL);
  +   i2c_imx = devm_kzalloc(pdev-dev, sizeof(struct imx_i2c_struct),
  +   GFP_KERNEL);
  if (!i2c_imx) {
  dev_err(pdev-dev, can't allocate interface\n);
  ret = -ENOMEM;
  -   goto fail2;
  +   return ret;
  }
   
  /* Setup i2c_imx driver structure */
  @@ -520,27 +509,27 @@ static int __init i2c_imx_probe(struct 
  platform_device *pdev)
  i2c_imx-adapter.dev.of_node= pdev-dev.of_node;
  i2c_imx-irq= irq;
  i2c_imx-base   = base;
  -   i2c_imx-res= res;
   
  pinctrl = devm_pinctrl_get_select_default(pdev-dev);
  if (IS_ERR(pinctrl)) {
  ret = PTR_ERR(pinctrl);
  -   goto fail3;
  +   return ret;
  }
   
  /* Get I2C clock */
  -   i2c_imx-clk = clk_get(pdev-dev, i2c_clk);
  +   i2c_imx-clk = devm_clk_get(pdev-dev, i2c_clk);
  if (IS_ERR(i2c_imx-clk)) {
  ret = PTR_ERR(i2c_imx-clk);
  dev_err(pdev-dev, can't get I2C clock\n);
  -   goto fail3;
  +   return ret;
  }
 
 Ok, you are basing the patch on two APIs,
 devm_pinctrl_get_select_default and devm_clk_get, that have not hit
 mainline, so it looks like a candidate for the next merge window.
hmm..., If it has to be, that's ok.

Thanks
Richard
 
 Regards,
 Shawn
 
   
  /* Request IRQ */
  -   ret = request_irq(i2c_imx-irq, i2c_imx_isr, 0, pdev-name, i2c_imx);
  +   ret = devm_request_irq(pdev-dev, i2c_imx-irq, i2c_imx_isr, 0,
  +   pdev-name, i2c_imx);
  if (ret) {
  dev_err(pdev-dev, can't claim irq %d\n, i2c_imx-irq);
  -   goto fail4;
  +   return ret;
  }
   
  /* Init queue */
  @@ -565,7 +554,7 @@ static int __init i2c_imx_probe(struct platform_device 
  *pdev)
  ret = i2c_add_numbered_adapter(i2c_imx-adapter);
  if (ret  0) {
  dev_err(pdev-dev, registration failed\n);
  -   goto fail5;
  +   return ret;
  }
   
  of_i2c_register_devices(i2c_imx-adapter);
  @@ -575,26 +564,14 @@ static int __init i2c_imx_probe(struct 
  platform_device *pdev)
   
  dev_dbg(i2c_imx-adapter.dev, claimed irq %d\n, i2c_imx-irq);
  dev_dbg(i2c_imx-adapter.dev, device resources from 0x%x to 0x%x\n,
  -   i2c_imx-res-start, i2c_imx-res-end);
  +   res-start, res-end);
  dev_dbg(i2c_imx-adapter.dev, allocated %d bytes at 0x%x \n,
  -   res_size, i2c_imx-res-start);
  +   resource_size(res), res-start);
  dev_dbg(i2c_imx-adapter.dev, adapter name: \%s\\n,
  i2c_imx-adapter.name);
  dev_dbg(i2c_imx-adapter.dev, IMX I2C adapter registered\n);
   
  return 0;   /* Return OK */
  -
  -fail5:
  -   free_irq(i2c_imx-irq, i2c_imx);
  -fail4:
  -   clk_put(i2c_imx-clk);
  -fail3:
  -   kfree(i2c_imx);
  -fail2:
  -   iounmap(base);
  -fail1:
  -   release_mem_region(res-start

Re: [PATCH V2 03/11] ASoC: imx-audmux: add pinctrl support

2012-05-10 Thread Richard Zhao
On Thu, May 10, 2012 at 09:44:04AM +0100, Mark Brown wrote:
 On Thu, May 10, 2012 at 02:39:06PM +0800, Shawn Guo wrote:
  On Thu, May 10, 2012 at 08:35:33AM +0800, Richard Zhao wrote:
 
   It's based on your for-next. But for working, it depends on
   pinctl/for-next.
 
  Mark, may I have your ack to have it go through arm-soc?  I will ask
  Arnd pull your sound/for-v3.5 branch into arm-soc as a dependency.
  You need to ensure the branch will not be rebased.
 
 for-3.5 is the entire undifferentiated blob of ASoC stuff, it's not
 really suitable for merging elsewhere.  It won't actually get rebased
 but the idea of merging it into other trees doesn't seem terribly
 clever, it'd make having topic branches in arm-soc a bit of a joke and
 if you pull it right now you'll get problems in -next due to the the
 ux500 stuff.
 
 What does working mean in this context - what happens without the
 pinctl changes?
devm_pinctrl_get_select_default function is added in below commit which
is in pinctrl/for-next.

commit 6d4ca1fb467932773da7b808c52f3d7ef4461ba0
Author: Stephen Warren swar...@nvidia.com
Date:   Mon Apr 16 10:51:00 2012 -0600

pinctrl: implement devm_pinctrl_get()/put()

These functions allow the driver core to automatically clean up any
allocations made by drivers, thus leading to simplified drivers.

Signed-off-by: Stephen Warren swar...@nvidia.com
Signed-off-by: Linus Walleij linus.wall...@linaro.org


So it'll fail compile without pinctrl/for-next. I guess Linus may need
to prepare a non-rebase base for others to merge.

Thanks
Richard

--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V2 03/11] ASoC: imx-audmux: add pinctrl support

2012-05-10 Thread Richard Zhao
On Thu, May 10, 2012 at 02:26:31PM +0200, Linus Walleij wrote:
 On Thu, May 10, 2012 at 12:23 PM, Richard Zhao
 richard.z...@freescale.com wrote:
  On Thu, May 10, 2012 at 10:27:34AM +0100, Mark Brown wrote:
  On Thu, May 10, 2012 at 05:05:00PM +0800, Richard Zhao wrote:
 
   devm_pinctrl_get_select_default function is added in below commit which
   is in pinctrl/for-next.
 
  Oh, dear.  That's unfortunate, I guess it's not on a branch in pinctl
  which can be pulled separately (...)
 
  I prefer to have a non-rebase pinctrl branch. We can not defer pinctrl
  patch for all drivers. pinctrl will be so widely used.
 
  Hi Linus,
 
  Could you comment?
 
 You're lucky because a few ARM SoC:s wanted a stable tag to
 use for pinctrl merges.
 
 Ref:
 git://git.linaro.org/people/triad/linux-pinctrl.git
 
 The tag pinctrl-mergebase-20120418
I only find the tag at your kernel.org git tree. Linaro switched git
server again? strange.

Mark,

Are you ok with that?

Thanks
Richard
 contains the devm and other changes, Stephen is already using
 that for Tegra stuff and it's solid as a rock. Newer patches are
 put on top of this and since pinctrl has no deps in any directions
 it will be requested for pull as soon as the merge window opens.
 
 Yours,
 Linus Walleij
 

--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 01/11] dma: imx-sdma: make channel0 operations atomic

2012-05-09 Thread Richard Zhao
device_prep_dma_cyclic may be call in audio trigger function which is
atomic context, so we make it atomic too.

 - change channel0 lock to spinlock.
 - Use polling to wait for channel0 finish running.

Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 drivers/dma/imx-sdma.c |   57 ++-
 1 files changed, 31 insertions(+), 26 deletions(-)

diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index fddccae..4fd48eb 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -24,7 +24,7 @@
 #include linux/mm.h
 #include linux/interrupt.h
 #include linux/clk.h
-#include linux/wait.h
+#include linux/delay.h
 #include linux/sched.h
 #include linux/semaphore.h
 #include linux/spinlock.h
@@ -324,7 +324,7 @@ struct sdma_engine {
struct dma_device   dma_device;
struct clk  *clk_ipg;
struct clk  *clk_ahb;
-   struct mutexchannel_0_lock;
+   spinlock_t  channel_0_lock;
struct sdma_script_start_addrs  *script_addrs;
 };
 
@@ -402,19 +402,27 @@ static void sdma_enable_channel(struct sdma_engine *sdma, 
int channel)
 }
 
 /*
- * sdma_run_channel - run a channel and wait till it's done
+ * sdma_run_channel0 - run a channel and wait till it's done
  */
-static int sdma_run_channel(struct sdma_channel *sdmac)
+static int sdma_run_channel0(struct sdma_engine *sdma)
 {
-   struct sdma_engine *sdma = sdmac-sdma;
-   int channel = sdmac-channel;
int ret;
+   unsigned long timeout = 500;
 
-   init_completion(sdmac-done);
+   sdma_enable_channel(sdma, 0);
 
-   sdma_enable_channel(sdma, channel);
+   while (!(ret = readl_relaxed(sdma-regs + SDMA_H_INTR)  1)) {
+   if (timeout-- = 0)
+   break;
+   udelay(1);
+   }
 
-   ret = wait_for_completion_timeout(sdmac-done, HZ);
+   if (ret) {
+   /* Clear the interrupt status */
+   writel_relaxed(ret, sdma-regs + SDMA_H_INTR);
+   } else {
+   dev_err(sdma-dev, Timeout waiting for CH0 ready\n);
+   }
 
return ret ? 0 : -ETIMEDOUT;
 }
@@ -426,17 +434,17 @@ static int sdma_load_script(struct sdma_engine *sdma, 
void *buf, int size,
void *buf_virt;
dma_addr_t buf_phys;
int ret;
-
-   mutex_lock(sdma-channel_0_lock);
+   unsigned long flags;
 
buf_virt = dma_alloc_coherent(NULL,
size,
buf_phys, GFP_KERNEL);
if (!buf_virt) {
-   ret = -ENOMEM;
-   goto err_out;
+   return -ENOMEM;
}
 
+   spin_lock_irqsave(sdma-channel_0_lock, flags);
+
bd0-mode.command = C0_SETPM;
bd0-mode.status = BD_DONE | BD_INTR | BD_WRAP | BD_EXTD;
bd0-mode.count = size / 2;
@@ -445,12 +453,11 @@ static int sdma_load_script(struct sdma_engine *sdma, 
void *buf, int size,
 
memcpy(buf_virt, buf, size);
 
-   ret = sdma_run_channel(sdma-channel[0]);
+   ret = sdma_run_channel0(sdma);
 
-   dma_free_coherent(NULL, size, buf_virt, buf_phys);
+   spin_unlock_irqrestore(sdma-channel_0_lock, flags);
 
-err_out:
-   mutex_unlock(sdma-channel_0_lock);
+   dma_free_coherent(NULL, size, buf_virt, buf_phys);
 
return ret;
 }
@@ -539,10 +546,6 @@ static void mxc_sdma_handle_channel(struct sdma_channel 
*sdmac)
 {
complete(sdmac-done);
 
-   /* not interested in channel 0 interrupts */
-   if (sdmac-channel == 0)
-   return;
-
if (sdmac-flags  IMX_DMA_SG_LOOP)
sdma_handle_channel_loop(sdmac);
else
@@ -555,6 +558,8 @@ static irqreturn_t sdma_int_handler(int irq, void *dev_id)
unsigned long stat;
 
stat = readl_relaxed(sdma-regs + SDMA_H_INTR);
+   /* not interested in channel 0 interrupts */
+   stat = ~1;
writel_relaxed(stat, sdma-regs + SDMA_H_INTR);
 
while (stat) {
@@ -660,6 +665,7 @@ static int sdma_load_context(struct sdma_channel *sdmac)
struct sdma_context_data *context = sdma-context;
struct sdma_buffer_descriptor *bd0 = sdma-channel[0].bd;
int ret;
+   unsigned long flags;
 
if (sdmac-direction == DMA_DEV_TO_MEM) {
load_address = sdmac-pc_from_device;
@@ -677,7 +683,7 @@ static int sdma_load_context(struct sdma_channel *sdmac)
dev_dbg(sdma-dev, event_mask0 = 0x%08x\n, (u32)sdmac-event_mask[0]);
dev_dbg(sdma-dev, event_mask1 = 0x%08x\n, (u32)sdmac-event_mask[1]);
 
-   mutex_lock(sdma-channel_0_lock);
+   spin_lock_irqsave(sdma-channel_0_lock, flags);
 
memset(context, 0, sizeof(*context));
context-channel_state.pc = load_address;
@@ -696,10 +702,9 @@ static int sdma_load_context(struct sdma_channel *sdmac)
bd0-mode.count = sizeof(*context) / 4;
bd0-buffer_addr = sdma-context_phys

[PATCH V2 02/11] ARM: dts: imx6q-sabrelite: add i2c1 pinctrl support

2012-05-09 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 arch/arm/boot/dts/imx6q-sabrelite.dts |2 ++
 arch/arm/boot/dts/imx6q.dtsi  |7 +++
 2 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/imx6q-sabrelite.dts 
b/arch/arm/boot/dts/imx6q-sabrelite.dts
index 2f631f2..85b7c6c 100644
--- a/arch/arm/boot/dts/imx6q-sabrelite.dts
+++ b/arch/arm/boot/dts/imx6q-sabrelite.dts
@@ -76,6 +76,8 @@
i2c@021a { /* I2C1 */
status = okay;
clock-frequency = 10;
+   pinctrl-names = default;
+   pinctrl-0 = pinctrl_i2c1_1;
 
codec: sgtl5000@0a {
compatible = fsl,sgtl5000;
diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi
index 949f979..f95aa3c 100644
--- a/arch/arm/boot/dts/imx6q.dtsi
+++ b/arch/arm/boot/dts/imx6q.dtsi
@@ -486,6 +486,13 @@
reg = 0x020e 0x4000;
 
/* shared pinctrl settings */
+   i2c1 {
+   pinctrl_i2c1_1: i2c1grp-1 {
+   fsl,pins = 137 0x4001b8b1  
/* MX6Q_PAD_EIM_D21__I2C1_SCL */
+   196 0x4001b8b1;
/* MX6Q_PAD_EIM_D28__I2C1_SDA */
+   };
+   };
+
usdhc3 {
pinctrl_usdhc3_1: usdhc3grp-1 {
fsl,pins = 1273 0x17059
/* MX6Q_PAD_SD3_CMD__USDHC3_CMD */
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 06/11] ASoC: fsl_ssi: convert to use devm_clk_get

2012-05-09 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 sound/soc/fsl/fsl_ssi.c |7 ++-
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 4ed2afd..b10a427 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -725,7 +725,7 @@ static int __devinit fsl_ssi_probe(struct platform_device 
*pdev)
u32 dma_events[2];
ssi_private-ssi_on_imx = true;
 
-   ssi_private-clk = clk_get(pdev-dev, NULL);
+   ssi_private-clk = devm_clk_get(pdev-dev, NULL);
if (IS_ERR(ssi_private-clk)) {
ret = PTR_ERR(ssi_private-clk);
dev_err(pdev-dev, could not get clock: %d\n, ret);
@@ -842,10 +842,8 @@ error_dev:
device_remove_file(pdev-dev, dev_attr);
 
 error_clk:
-   if (ssi_private-ssi_on_imx) {
+   if (ssi_private-ssi_on_imx)
clk_disable_unprepare(ssi_private-clk);
-   clk_put(ssi_private-clk);
-   }
 
 error_irq:
free_irq(ssi_private-irq, ssi_private);
@@ -871,7 +869,6 @@ static int fsl_ssi_remove(struct platform_device *pdev)
if (ssi_private-ssi_on_imx) {
platform_device_unregister(ssi_private-imx_pcm_pdev);
clk_disable_unprepare(ssi_private-clk);
-   clk_put(ssi_private-clk);
}
snd_soc_unregister_dai(pdev-dev);
device_remove_file(pdev-dev, ssi_private-dev_attr);
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 05/11] ARM: imx6q: add ssi1_ipg clk_lookup

2012-05-09 Thread Richard Zhao
It's used by audio drivers.

Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 arch/arm/mach-imx/clk-imx6q.c |   10 ++
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-imx/clk-imx6q.c b/arch/arm/mach-imx/clk-imx6q.c
index f40a35d..92550c5 100644
--- a/arch/arm/mach-imx/clk-imx6q.c
+++ b/arch/arm/mach-imx/clk-imx6q.c
@@ -155,7 +155,8 @@ enum mx6q_clks {
gpmi_bch_apb, gpmi_bch, gpmi_io, gpmi_apb, sata, sdma, spba, ssi1,
ssi2, ssi3, uart_ipg, uart_serial, usboh3, usdhc1, usdhc2, usdhc3,
usdhc4, vdo_axi, vpu_axi, cko1, pll1_sys, pll2_bus, pll3_usb_otg,
-   pll4_audio, pll5_video, pll6_mlb, pll7_usb_host, pll8_enet, clk_max
+   pll4_audio, pll5_video, pll6_mlb, pll7_usb_host, pll8_enet, ssi1_ipg,
+   ssi2_ipg, ssi3_ipg, clk_max
 };
 
 static struct clk *clk[clk_max];
@@ -367,9 +368,9 @@ int __init mx6q_clocks_init(void)
clk[sata] = imx_clk_gate2(sata,  ipg,   
base + 0x7c, 4);
clk[sdma] = imx_clk_gate2(sdma,  ahb,   
base + 0x7c, 6);
clk[spba] = imx_clk_gate2(spba,  ipg,   
base + 0x7c, 12);
-   clk[ssi1] = imx_clk_gate2(ssi1,  ssi1_podf, 
base + 0x7c, 18);
-   clk[ssi2] = imx_clk_gate2(ssi2,  ssi2_podf, 
base + 0x7c, 20);
-   clk[ssi3] = imx_clk_gate2(ssi3,  ssi3_podf, 
base + 0x7c, 22);
+   clk[ssi1_ipg] = imx_clk_gate2(ssi1_ipg,  ipg,   
base + 0x7c, 18);
+   clk[ssi2_ipg] = imx_clk_gate2(ssi2_ipg,  ipg,   
base + 0x7c, 20);
+   clk[ssi3_ipg] = imx_clk_gate2(ssi3_ipg,  ipg,   
base + 0x7c, 22);
clk[uart_ipg] = imx_clk_gate2(uart_ipg,  ipg,   
base + 0x7c, 24);
clk[uart_serial]  = imx_clk_gate2(uart_serial,   uart_serial_podf,  
base + 0x7c, 26);
clk[usboh3]   = imx_clk_gate2(usboh3,ipg,   
base + 0x80, 0);
@@ -418,6 +419,7 @@ int __init mx6q_clocks_init(void)
clk_register_clkdev(clk[sdma], NULL, 20ec000.sdma);
clk_register_clkdev(clk[dummy], NULL, 20bc000.wdog);
clk_register_clkdev(clk[dummy], NULL, 20c.wdog);
+   clk_register_clkdev(clk[ssi1_ipg], NULL, 2028000.ssi);
 
for (i = 0; i  ARRAY_SIZE(clks_init_on); i++) {
c = clk_get_sys(clks_init_on[i], NULL);
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 08/11] ARM: dts: imx6q-sabrelite: add sound device imx6q-sabrelite-sgtl5000

2012-05-09 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 arch/arm/boot/dts/imx6q-sabrelite.dts |   14 ++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/imx6q-sabrelite.dts 
b/arch/arm/boot/dts/imx6q-sabrelite.dts
index 5b51deb..5a35bfd 100644
--- a/arch/arm/boot/dts/imx6q-sabrelite.dts
+++ b/arch/arm/boot/dts/imx6q-sabrelite.dts
@@ -110,4 +110,18 @@
regulator-always-on;
};
};
+
+   sound {
+   compatible = fsl,imx6q-sabrelite-sgtl5000,
+fsl,imx-audio-sgtl5000;
+   model = imx6q-sabrelite-sgtl5000;
+   ssi-controller = ssi1;
+   audio-codec = codec;
+   audio-routing =
+   MIC_IN, Mic Jack,
+   Mic Jack, Mic Bias,
+   Headphone Jack, HP_OUT;
+   mux-int-port = 1;
+   mux-ext-port = 4;
+   };
 };
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 10/11] ARM: imx6q: change clkdev device name from xxxx.uart to xxxx.serial

2012-05-09 Thread Richard Zhao
It's because the dts changed the node name.

Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 arch/arm/mach-imx/clk-imx6q.c |   20 ++--
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-imx/clk-imx6q.c b/arch/arm/mach-imx/clk-imx6q.c
index 096fcfb..4ac1282 100644
--- a/arch/arm/mach-imx/clk-imx6q.c
+++ b/arch/arm/mach-imx/clk-imx6q.c
@@ -393,16 +393,16 @@ int __init mx6q_clocks_init(void)
clk_register_clkdev(clk[gpt_ipg_per], per, imx-gpt.0);
clk_register_clkdev(clk[twd], NULL, smp_twd);
clk_register_clkdev(clk[usboh3], NULL, usboh3);
-   clk_register_clkdev(clk[uart_serial], per, 202.uart);
-   clk_register_clkdev(clk[uart_ipg], ipg, 202.uart);
-   clk_register_clkdev(clk[uart_serial], per, 21e8000.uart);
-   clk_register_clkdev(clk[uart_ipg], ipg, 21e8000.uart);
-   clk_register_clkdev(clk[uart_serial], per, 21ec000.uart);
-   clk_register_clkdev(clk[uart_ipg], ipg, 21ec000.uart);
-   clk_register_clkdev(clk[uart_serial], per, 21f.uart);
-   clk_register_clkdev(clk[uart_ipg], ipg, 21f.uart);
-   clk_register_clkdev(clk[uart_serial], per, 21f4000.uart);
-   clk_register_clkdev(clk[uart_ipg], ipg, 21f4000.uart);
+   clk_register_clkdev(clk[uart_serial], per, 202.serial);
+   clk_register_clkdev(clk[uart_ipg], ipg, 202.serial);
+   clk_register_clkdev(clk[uart_serial], per, 21e8000.serial);
+   clk_register_clkdev(clk[uart_ipg], ipg, 21e8000.serial);
+   clk_register_clkdev(clk[uart_serial], per, 21ec000.serial);
+   clk_register_clkdev(clk[uart_ipg], ipg, 21ec000.serial);
+   clk_register_clkdev(clk[uart_serial], per, 21f.serial);
+   clk_register_clkdev(clk[uart_ipg], ipg, 21f.serial);
+   clk_register_clkdev(clk[uart_serial], per, 21f4000.serial);
+   clk_register_clkdev(clk[uart_ipg], ipg, 21f4000.serial);
clk_register_clkdev(clk[enet], NULL, 2188000.enet);
clk_register_clkdev(clk[usdhc1], NULL, 219.usdhc);
clk_register_clkdev(clk[usdhc2], NULL, 2194000.usdhc);
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 09/11] ARM: dts: imx6q-sabrelite: add serial2 pinctrl support

2012-05-09 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 arch/arm/boot/dts/imx6q-sabrelite.dts |2 ++
 arch/arm/boot/dts/imx6q.dtsi  |7 +++
 2 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/imx6q-sabrelite.dts 
b/arch/arm/boot/dts/imx6q-sabrelite.dts
index 5a35bfd..e0ec929 100644
--- a/arch/arm/boot/dts/imx6q-sabrelite.dts
+++ b/arch/arm/boot/dts/imx6q-sabrelite.dts
@@ -73,6 +73,8 @@
 
uart2: serial@021e8000 {
status = okay;
+   pinctrl-names = default;
+   pinctrl-0 = pinctrl_serial2_1;
};
 
i2c@021a { /* I2C1 */
diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi
index 5795b93..31c3d5f 100644
--- a/arch/arm/boot/dts/imx6q.dtsi
+++ b/arch/arm/boot/dts/imx6q.dtsi
@@ -502,6 +502,13 @@
};
};
 
+   serial2 {
+   pinctrl_serial2_1: serial2grp-1 {
+   fsl,pins = 183 0x1b0b1 
/* MX6Q_PAD_EIM_D26__UART2_TXD */
+   191 0x1b0b1;   
/* MX6Q_PAD_EIM_D27__UART2_RXD */
+   };
+   };
+
usdhc3 {
pinctrl_usdhc3_1: usdhc3grp-1 {
fsl,pins = 1273 0x17059
/* MX6Q_PAD_SD3_CMD__USDHC3_CMD */
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 11/11] ARM: imx6q: change clkdev device name from xxxx.enet to xxxx.ethernet

2012-05-09 Thread Richard Zhao
It's because the dts changed the node name.

Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 arch/arm/mach-imx/clk-imx6q.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-imx/clk-imx6q.c b/arch/arm/mach-imx/clk-imx6q.c
index 4ac1282..cab02d0 100644
--- a/arch/arm/mach-imx/clk-imx6q.c
+++ b/arch/arm/mach-imx/clk-imx6q.c
@@ -403,7 +403,7 @@ int __init mx6q_clocks_init(void)
clk_register_clkdev(clk[uart_ipg], ipg, 21f.serial);
clk_register_clkdev(clk[uart_serial], per, 21f4000.serial);
clk_register_clkdev(clk[uart_ipg], ipg, 21f4000.serial);
-   clk_register_clkdev(clk[enet], NULL, 2188000.enet);
+   clk_register_clkdev(clk[enet], NULL, 2188000.ethernet);
clk_register_clkdev(clk[usdhc1], NULL, 219.usdhc);
clk_register_clkdev(clk[usdhc2], NULL, 2194000.usdhc);
clk_register_clkdev(clk[usdhc3], NULL, 2198000.usdhc);
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V2 03/11] ASoC: imx-audmux: add pinctrl support

2012-05-09 Thread Richard Zhao
On Wed, May 09, 2012 at 05:00:06PM +0100, Mark Brown wrote:
 On Wed, May 09, 2012 at 07:33:02PM +0800, Richard Zhao wrote:
  Signed-off-by: Richard Zhao richard.z...@freescale.com
 
 I guess this depends on some other tree and can't just be directly
 applied to ASoC?
It's based on your for-next. But for working, it depends on
pinctl/for-next.

Thanks
Richard

--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 11/11] ARM: dts: imx6q-sabrelite: add sound device imx6q-sabrelite-sgtl5000

2012-05-02 Thread Richard Zhao
On Tue, May 01, 2012 at 08:55:14PM +0800, Shawn Guo wrote:
 On Fri, Apr 27, 2012 at 03:03:05PM +0800, Richard Zhao wrote:
  From: Richard Zhao richard.z...@linaro.org
  
  Signed-off-by: Richard Zhao richard.z...@linaro.org
  Signed-off-by: Richard Zhao richard.z...@freescale.com
  ---
   arch/arm/boot/dts/imx6q-sabrelite.dts |   13 +
   1 files changed, 13 insertions(+), 0 deletions(-)
  
  diff --git a/arch/arm/boot/dts/imx6q-sabrelite.dts 
  b/arch/arm/boot/dts/imx6q-sabrelite.dts
  index cdae2dd..20aa767 100644
  --- a/arch/arm/boot/dts/imx6q-sabrelite.dts
  +++ b/arch/arm/boot/dts/imx6q-sabrelite.dts
  @@ -97,4 +97,17 @@
  regulator-always-on;
  };
  };
  +
  +   sound {
  +   compatible = fsl,imx6q-sabrelite-sgtl5000,
  +fsl,imx-audio-sgtl5000;
  +   model = imx6q-sabrelite-sgtl5000;
  +   ssi-controller = ssi1;
  +   audio-codec = codec;
  +   audio-routing =
  +   MIC_IN, Mic Jack,
 
 Just curious if you have capture working without enabling Mic Bias
 power supplier.
I should add a Mic Jack, Mic Bias. When arecord, mic_bias_event
is called.
It's strange that it can not record any voice. debugging ...

Thanks
Richard
 
 Regards,
 Shawn
 
  +   Headphone Jack, HP_OUT;
  +   mux-int-port = 1;
  +   mux-ext-port = 4;
  +   };
   };
  -- 
  1.7.5.4
  
  
 

--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 03/11] ASoC: fsl: add sgtl5000 clock support for imx-sgtl5000

2012-05-02 Thread Richard Zhao
On Tue, May 01, 2012 at 09:44:48PM +0800, Shawn Guo wrote:
 On Fri, Apr 27, 2012 at 03:02:57PM +0800, Richard Zhao wrote:
  From: Richard Zhao richard.z...@linaro.org
  
  It tries to clk_get the clock. And if it failed, it assumes the clock
  by default enabled.
  
  Signed-off-by: Richard Zhao richard.z...@freescale.com
  ---
   sound/soc/fsl/imx-sgtl5000.c |   40 
  
   1 files changed, 32 insertions(+), 8 deletions(-)
  
  diff --git a/sound/soc/fsl/imx-sgtl5000.c b/sound/soc/fsl/imx-sgtl5000.c
  index 73b935e..3a729ca 100644
  --- a/sound/soc/fsl/imx-sgtl5000.c
  +++ b/sound/soc/fsl/imx-sgtl5000.c
  @@ -13,6 +13,8 @@
   #include linux/module.h
   #include linux/of.h
   #include linux/of_platform.h
  +#include linux/of_i2c.h
  +#include linux/clk.h
   #include sound/soc.h
   
   #include ../codecs/sgtl5000.h
  @@ -25,6 +27,7 @@ struct imx_sgtl5000_data {
  struct snd_soc_card card;
  char codec_dai_name[DAI_NAME_SIZE];
  char platform_name[DAI_NAME_SIZE];
  +   struct clk *codec_clk;
  unsigned int clk_frequency;
   };
   
  @@ -58,6 +61,7 @@ static int __devinit imx_sgtl5000_probe(struct 
  platform_device *pdev)
  struct device_node *np = pdev-dev.of_node;
  struct device_node *ssi_np, *codec_np;
  struct platform_device *ssi_pdev;
  +   struct i2c_client *codec_dev;
  struct imx_sgtl5000_data *data;
  int int_port, ext_port;
  int ret;
  @@ -113,6 +117,11 @@ static int __devinit imx_sgtl5000_probe(struct 
  platform_device *pdev)
  ret = -EINVAL;
  goto fail;
  }
  +   codec_dev = of_find_i2c_device_by_node(codec_np);
  +   if (!codec_dev) {
  +   dev_err(pdev-dev, failed to find codec platform device\n);
  +   return -EINVAL;
  +   }
 
 What if the codec is accessed via SPI bus on some machines?
 
   
  data = devm_kzalloc(pdev-dev, sizeof(*data), GFP_KERNEL);
  if (!data) {
  @@ -120,11 +129,20 @@ static int __devinit imx_sgtl5000_probe(struct 
  platform_device *pdev)
  goto fail;
  }
   
  -   ret = of_property_read_u32(codec_np, clock-frequency,
  -  data-clk_frequency);
  -   if (ret) {
  -   dev_err(pdev-dev, clock-frequency missing or invalid\n);
  -   goto fail;
  +   data-codec_clk = clk_get(codec_dev-dev, NULL);
 
 It's a clock of sgtl5000 codec.  I feel it makes more sense to have
 sgtl5000 device driver than machine driver to manage this clock.
The ASoC machine driver handled the clock settings, I just followed the
same way, using snd_soc_dai_set_sysclk to set codec clk. But what you
said  is reasonable. I also find it's impossible to use devm_get_clk.

Mark, do you suggest get clk in ASoC machine driver or in codec driver?

Thanks
Richard
 
 Regards,
 Shawn
 
  +   if (IS_ERR(data-codec_clk)) {
  +   /* assuming clock enabled by default */
  +   data-codec_clk = NULL;
  +   ret = of_property_read_u32(codec_np, clock-frequency,
  +   data-clk_frequency);
  +   if (ret) {
  +   dev_err(codec_dev-dev,
  +   clock-frequency missing or invalid\n);
  +   goto fail;
  +   }
  +   } else {
  +   data-clk_frequency = clk_get_rate(data-codec_clk);
  +   clk_prepare_enable(data-codec_clk);
  }
 

--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 10/11] ARM: imx6q_sabrelite: clkdev_add cko1 for sgtl5000

2012-05-02 Thread Richard Zhao
On Tue, May 01, 2012 at 08:47:10PM +0800, Shawn Guo wrote:
 On Fri, Apr 27, 2012 at 03:03:04PM +0800, Richard Zhao wrote:
  Signed-off-by: Richard Zhao richard.z...@freescale.com
  ---
   arch/arm/mach-imx/clk-imx6q.c  |3 +++
   arch/arm/mach-imx/mach-imx6q.c |   28 
   2 files changed, 31 insertions(+), 0 deletions(-)
  
  diff --git a/arch/arm/mach-imx/clk-imx6q.c b/arch/arm/mach-imx/clk-imx6q.c
  index 9a03dcc..4ea0de0 100644
  --- a/arch/arm/mach-imx/clk-imx6q.c
  +++ b/arch/arm/mach-imx/clk-imx6q.c
  @@ -419,6 +419,9 @@ int __init mx6q_clocks_init(void)
  clk_register_clkdev(clk[dummy], NULL, 20bc000.wdog);
  clk_register_clkdev(clk[dummy], NULL, 20c.wdog);
  clk_register_clkdev(clk[ssi1], NULL, 2028000.ssi);
  +   clk_register_clkdev(clk[cko1_sel], cko1_sel, NULL);
  +   clk_register_clkdev(clk[ahb], ahb, NULL);
  +   clk_register_clkdev(clk[cko1], cko1, NULL);
   
  for (i = 0; i  ARRAY_SIZE(clks_init_on); i++) {
  c = clk_get_sys(clks_init_on[i], NULL);
  diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c
  index d25c5d8..e9b2522 100644
  --- a/arch/arm/mach-imx/mach-imx6q.c
  +++ b/arch/arm/mach-imx/mach-imx6q.c
  @@ -10,6 +10,8 @@
* http://www.gnu.org/copyleft/gpl.html
*/
   
  +#include linux/clkdev.h
  +#include linux/clk.h
 
 Nit: I would have linux/clk.h put before linux/clkdev.h.
ok
 
   #include linux/delay.h
   #include linux/init.h
   #include linux/io.h
  @@ -75,10 +77,36 @@ static int ksz9021rn_phy_fixup(struct phy_device 
  *phydev)
  return 0;
   }
   
  +static void __init imx6q_cko1_setup(void)
 
 I would say this is a sabrelite specific setup so far.
ok
 
  +{
  +   struct clk *cko1_sel, *ahb, *cko1;
  +   unsigned long rate;
  +
  +   cko1_sel = clk_get_sys(NULL, cko1_sel);
  +   ahb = clk_get_sys(NULL, ahb);
  +   cko1 = clk_get_sys(NULL, cko1);
  +   if (IS_ERR(cko1_sel) || IS_ERR(ahb) || IS_ERR(cko1)) {
  +   printk(KERN_ERR cko1 setup failed!\n);
 
 pr_err
ok

Thanks
Richard
 
  +   goto put_clk;
  +   }
  +   clk_set_parent(cko1_sel, ahb);
  +   rate = clk_round_rate(cko1, 1600);
  +   clk_set_rate(cko1, rate);
  +   clk_register_clkdev(cko1, NULL, 0-000a);
 
 This dev_id looks a little strange to me.  I understand that's the
 consequence of having sgtl5000 clock managed in ASoC machine driver
 imx-sgtl5000.  IMO, having sgtl5000 driver manages its clock and
 looking up the clock with dev_id simply as sgtl5000 makes more
 sense to me.  Will put more comment on your imx-sgtl5000 clock patch.
 
 Regards,
 Shawn
 
  +put_clk:
  +   if (!IS_ERR(cko1_sel))
  +   clk_put(cko1_sel);
  +   if (!IS_ERR(ahb))
  +   clk_put(ahb);
  +   if (!IS_ERR(cko1))
  +   clk_put(cko1);
  +}
  +
   static void __init imx6q_sabrelite_init(void)
   {
  phy_register_fixup_for_uid(PHY_ID_KSZ9021, MICREL_PHY_ID_MASK,
  ksz9021rn_phy_fixup);
  +   imx6q_cko1_setup();
   }
   
   static void __init imx6q_init_machine(void)
  -- 
  1.7.5.4
  
  
 

--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 09/11] ARM: imx6q: add ssi1 clk_lookup

2012-04-29 Thread Richard Zhao
On Fri, Apr 27, 2012 at 11:25:29AM +0200, Sascha Hauer wrote:
 On Fri, Apr 27, 2012 at 05:10:56PM +0800, Richard Zhao wrote:
  On Fri, Apr 27, 2012 at 10:04:12AM +0200, Sascha Hauer wrote:
   On Fri, Apr 27, 2012 at 03:03:03PM +0800, Richard Zhao wrote:
It's used by audio drivers.

Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 arch/arm/mach-imx/clk-imx6q.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-imx/clk-imx6q.c 
b/arch/arm/mach-imx/clk-imx6q.c
index f40a35d..9a03dcc 100644
--- a/arch/arm/mach-imx/clk-imx6q.c
+++ b/arch/arm/mach-imx/clk-imx6q.c
@@ -418,6 +418,7 @@ int __init mx6q_clocks_init(void)
clk_register_clkdev(clk[sdma], NULL, 20ec000.sdma);
clk_register_clkdev(clk[dummy], NULL, 20bc000.wdog);
clk_register_clkdev(clk[dummy], NULL, 20c.wdog);
+   clk_register_clkdev(clk[ssi1], NULL, 2028000.ssi);
   
   The ssi clock needs a general cleanup on all i.MX just like I cleaned up
   the other units. The SSI unit has at least a register clock and a baud
   clock. What the driver requests and enables is the register clock.
   
   The baud clock is currently unused and is needed only for master mode
   (which is not implemented in the ssi driver)
  Are you sure for that? If I don't enable clk[ssi1], the ssi will not
  work.
  
   
   So where we want to come to is:
   
 clk_register_clkdev(clk[ipg], ipg, 2028000.ssi);
  ssi don't have ipg gate. We can let it always on for imx6q.
 
 Can you please ask your IC guys for clarification?
 
 For example on i.MX5 we have a ssi ipg clock and a ssi serial clock.
 Both can be gated with two individual gate bits.
 
 The i.MX6 datasheet (and also several other i.MX datasheets) is quite
 nebulous. The i.MX6 has only one gate bit for each SSI unit, but
 it's not clear if this bit actually gates both the ipg and serial
 clock or only one of them.
You're right. ipg and serial clocks share the same gate. How do we
handle it? I think it's not the only one and won't be last one.
 
 My general idea is that each unit in the SoC has different input clocks.
 In the driver we need to clk_get() the input clocks. If a given SoC has
 no software control over some of the devices input clocks, then we need
 to provide a dummy for this, because other SoCs have control over the
 clock.
Great.

Thanks
Richard
 
 Sascha
 
 -- 
 Pengutronix e.K.   | |
 Industrial Linux Solutions | http://www.pengutronix.de/  |
 Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
 Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
 
 ___
 linux-arm-kernel mailing list
 linux-arm-ker...@lists.infradead.org
 http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 01/11] dma: imx-sdma: make channel0 operations atomic

2012-04-27 Thread Richard Zhao
device_prep_dma_cyclic may be call in audio trigger function which is
atomic context, so we make it atomic too.

 - change channel0 lock to spinlock.
 - Use polling to wait for channel0 finish running.

Signed-off-by: Lothar Waßmann l...@karo-electronics.de
Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 drivers/dma/imx-sdma.c |   57 +++
 1 files changed, 33 insertions(+), 24 deletions(-)

diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index fddccae..fc49ffa 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -24,7 +24,7 @@
 #include linux/mm.h
 #include linux/interrupt.h
 #include linux/clk.h
-#include linux/wait.h
+#include linux/delay.h
 #include linux/sched.h
 #include linux/semaphore.h
 #include linux/spinlock.h
@@ -324,7 +324,7 @@ struct sdma_engine {
struct dma_device   dma_device;
struct clk  *clk_ipg;
struct clk  *clk_ahb;
-   struct mutexchannel_0_lock;
+   spinlock_t  channel_0_lock;
struct sdma_script_start_addrs  *script_addrs;
 };
 
@@ -402,19 +402,31 @@ static void sdma_enable_channel(struct sdma_engine *sdma, 
int channel)
 }
 
 /*
- * sdma_run_channel - run a channel and wait till it's done
+ * sdma_run_channel0 - run a channel and wait till it's done
  */
-static int sdma_run_channel(struct sdma_channel *sdmac)
+static int sdma_run_channel0(struct sdma_channel *sdmac)
 {
struct sdma_engine *sdma = sdmac-sdma;
int channel = sdmac-channel;
int ret;
+   unsigned long timeout = 500;
 
-   init_completion(sdmac-done);
-
+   if (channel)
+   return -EINVAL;
sdma_enable_channel(sdma, channel);
 
-   ret = wait_for_completion_timeout(sdmac-done, HZ);
+   while (!(ret = readl_relaxed(sdma-regs + SDMA_H_INTR)  1)) {
+   if (timeout-- = 0)
+   break;
+   udelay(1);
+   }
+
+   if (ret) {
+   /* Clear the interrupt status */
+   writel_relaxed(ret, sdma-regs + SDMA_H_INTR);
+   } else {
+   dev_err(sdma-dev, Timeout waiting for CH0 ready\n);
+   }
 
return ret ? 0 : -ETIMEDOUT;
 }
@@ -426,17 +438,17 @@ static int sdma_load_script(struct sdma_engine *sdma, 
void *buf, int size,
void *buf_virt;
dma_addr_t buf_phys;
int ret;
-
-   mutex_lock(sdma-channel_0_lock);
+   unsigned long flags;
 
buf_virt = dma_alloc_coherent(NULL,
size,
buf_phys, GFP_KERNEL);
if (!buf_virt) {
-   ret = -ENOMEM;
-   goto err_out;
+   return -ENOMEM;
}
 
+   spin_lock_irqsave(sdma-channel_0_lock, flags);
+
bd0-mode.command = C0_SETPM;
bd0-mode.status = BD_DONE | BD_INTR | BD_WRAP | BD_EXTD;
bd0-mode.count = size / 2;
@@ -445,12 +457,11 @@ static int sdma_load_script(struct sdma_engine *sdma, 
void *buf, int size,
 
memcpy(buf_virt, buf, size);
 
-   ret = sdma_run_channel(sdma-channel[0]);
+   ret = sdma_run_channel0(sdma-channel[0]);
 
-   dma_free_coherent(NULL, size, buf_virt, buf_phys);
+   spin_unlock_irqrestore(sdma-channel_0_lock, flags);
 
-err_out:
-   mutex_unlock(sdma-channel_0_lock);
+   dma_free_coherent(NULL, size, buf_virt, buf_phys);
 
return ret;
 }
@@ -539,10 +550,6 @@ static void mxc_sdma_handle_channel(struct sdma_channel 
*sdmac)
 {
complete(sdmac-done);
 
-   /* not interested in channel 0 interrupts */
-   if (sdmac-channel == 0)
-   return;
-
if (sdmac-flags  IMX_DMA_SG_LOOP)
sdma_handle_channel_loop(sdmac);
else
@@ -555,6 +562,8 @@ static irqreturn_t sdma_int_handler(int irq, void *dev_id)
unsigned long stat;
 
stat = readl_relaxed(sdma-regs + SDMA_H_INTR);
+   /* not interested in channel 0 interrupts */
+   stat = ~1;
writel_relaxed(stat, sdma-regs + SDMA_H_INTR);
 
while (stat) {
@@ -660,6 +669,7 @@ static int sdma_load_context(struct sdma_channel *sdmac)
struct sdma_context_data *context = sdma-context;
struct sdma_buffer_descriptor *bd0 = sdma-channel[0].bd;
int ret;
+   unsigned long flags;
 
if (sdmac-direction == DMA_DEV_TO_MEM) {
load_address = sdmac-pc_from_device;
@@ -677,7 +687,7 @@ static int sdma_load_context(struct sdma_channel *sdmac)
dev_dbg(sdma-dev, event_mask0 = 0x%08x\n, (u32)sdmac-event_mask[0]);
dev_dbg(sdma-dev, event_mask1 = 0x%08x\n, (u32)sdmac-event_mask[1]);
 
-   mutex_lock(sdma-channel_0_lock);
+   spin_lock_irqsave(sdma-channel_0_lock, flags);
 
memset(context, 0, sizeof(*context));
context-channel_state.pc = load_address;
@@ -696,10 +706,9 @@ static int sdma_load_context(struct sdma_channel *sdmac

[PATCH 02/11] ASoC: imx-sgtl5000: add of_node_put when probe fail.

2012-04-27 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 sound/soc/fsl/imx-sgtl5000.c |   29 ++---
 1 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/sound/soc/fsl/imx-sgtl5000.c b/sound/soc/fsl/imx-sgtl5000.c
index e1a7441..73b935e 100644
--- a/sound/soc/fsl/imx-sgtl5000.c
+++ b/sound/soc/fsl/imx-sgtl5000.c
@@ -103,24 +103,28 @@ static int __devinit imx_sgtl5000_probe(struct 
platform_device *pdev)
codec_np = of_parse_phandle(pdev-dev.of_node, audio-codec, 0);
if (!ssi_np || !codec_np) {
dev_err(pdev-dev, phandle missing or invalid\n);
-   return -EINVAL;
+   ret = -EINVAL;
+   goto fail;
}
 
ssi_pdev = of_find_device_by_node(ssi_np);
if (!ssi_pdev) {
dev_err(pdev-dev, failed to find SSI platform device\n);
-   return -EINVAL;
+   ret = -EINVAL;
+   goto fail;
}
 
data = devm_kzalloc(pdev-dev, sizeof(*data), GFP_KERNEL);
-   if (!data)
-   return -ENOMEM;
+   if (!data) {
+   ret = -ENOMEM;
+   goto fail;
+   }
 
ret = of_property_read_u32(codec_np, clock-frequency,
   data-clk_frequency);
if (ret) {
dev_err(pdev-dev, clock-frequency missing or invalid\n);
-   return ret;
+   goto fail;
}
 
data-dai.name = HiFi;
@@ -136,10 +140,10 @@ static int __devinit imx_sgtl5000_probe(struct 
platform_device *pdev)
data-card.dev = pdev-dev;
ret = snd_soc_of_parse_card_name(data-card, model);
if (ret)
-   return ret;
+   goto fail;
ret = snd_soc_of_parse_audio_routing(data-card, audio-routing);
if (ret)
-   return ret;
+   goto fail;
data-card.num_links = 1;
data-card.dai_link = data-dai;
data-card.dapm_widgets = imx_sgtl5000_dapm_widgets;
@@ -148,14 +152,17 @@ static int __devinit imx_sgtl5000_probe(struct 
platform_device *pdev)
ret = snd_soc_register_card(data-card);
if (ret) {
dev_err(pdev-dev, snd_soc_register_card failed (%d)\n, ret);
-   return ret;
+   goto fail;
}
 
platform_set_drvdata(pdev, data);
-   of_node_put(ssi_np);
-   of_node_put(codec_np);
+fail:
+   if (ssi_np)
+   of_node_put(ssi_np);
+   if (codec_np)
+   of_node_put(codec_np);
 
-   return 0;
+   return ret;
 }
 
 static int __devexit imx_sgtl5000_remove(struct platform_device *pdev)
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 00/11] enable imx6q_sabrelite sgtl5000 audio support

2012-04-27 Thread Richard Zhao
It's based on Dong Aisheng's early pinctrl patch and Sascha's v2
convert to common clk patch.

You can also get at:
https://github.com/riczhao/kernel-imx/tree/topics/audio

Richard Zhao (11):
  dma: imx-sdma: make channel0 operations atomic
  ASoC: imx-sgtl5000: add of_node_put when probe fail.
  ASoC: fsl: add sgtl5000 clock support for imx-sgtl5000
  i2c: imx: add pinctrl support
  ARM: imx6q: move imx6q_sabrelite specific code to a dedicated
function
  ARM: dts: imx6q-sabrelite: add ssi device
  ARM: dts: imx6q-sabrelite: add audmux device
  ASoC: imx-audmux: add pinctrl support
  ARM: imx6q: add ssi1 clk_lookup
  ARM: imx6q_sabrelite: clkdev_add cko1 for sgtl5000
  ARM: dts: imx6q-sabrelite: add sound device imx6q-sabrelite-sgtl5000

 arch/arm/boot/dts/imx6q-sabrelite.dts |   30 
 arch/arm/boot/dts/imx6q.dtsi  |   46 +++--
 arch/arm/mach-imx/clk-imx6q.c |4 ++
 arch/arm/mach-imx/mach-imx6q.c|   37 +++-
 drivers/dma/imx-sdma.c|   57 ++-
 drivers/i2c/busses/i2c-imx.c  |9 +
 sound/soc/fsl/imx-audmux.c|8 
 sound/soc/fsl/imx-sgtl5000.c  |   61 +
 8 files changed, 208 insertions(+), 44 deletions(-)

Thanks
Richard
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 03/11] ASoC: fsl: add sgtl5000 clock support for imx-sgtl5000

2012-04-27 Thread Richard Zhao
From: Richard Zhao richard.z...@linaro.org

It tries to clk_get the clock. And if it failed, it assumes the clock
by default enabled.

Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 sound/soc/fsl/imx-sgtl5000.c |   40 
 1 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/sound/soc/fsl/imx-sgtl5000.c b/sound/soc/fsl/imx-sgtl5000.c
index 73b935e..3a729ca 100644
--- a/sound/soc/fsl/imx-sgtl5000.c
+++ b/sound/soc/fsl/imx-sgtl5000.c
@@ -13,6 +13,8 @@
 #include linux/module.h
 #include linux/of.h
 #include linux/of_platform.h
+#include linux/of_i2c.h
+#include linux/clk.h
 #include sound/soc.h
 
 #include ../codecs/sgtl5000.h
@@ -25,6 +27,7 @@ struct imx_sgtl5000_data {
struct snd_soc_card card;
char codec_dai_name[DAI_NAME_SIZE];
char platform_name[DAI_NAME_SIZE];
+   struct clk *codec_clk;
unsigned int clk_frequency;
 };
 
@@ -58,6 +61,7 @@ static int __devinit imx_sgtl5000_probe(struct 
platform_device *pdev)
struct device_node *np = pdev-dev.of_node;
struct device_node *ssi_np, *codec_np;
struct platform_device *ssi_pdev;
+   struct i2c_client *codec_dev;
struct imx_sgtl5000_data *data;
int int_port, ext_port;
int ret;
@@ -113,6 +117,11 @@ static int __devinit imx_sgtl5000_probe(struct 
platform_device *pdev)
ret = -EINVAL;
goto fail;
}
+   codec_dev = of_find_i2c_device_by_node(codec_np);
+   if (!codec_dev) {
+   dev_err(pdev-dev, failed to find codec platform device\n);
+   return -EINVAL;
+   }
 
data = devm_kzalloc(pdev-dev, sizeof(*data), GFP_KERNEL);
if (!data) {
@@ -120,11 +129,20 @@ static int __devinit imx_sgtl5000_probe(struct 
platform_device *pdev)
goto fail;
}
 
-   ret = of_property_read_u32(codec_np, clock-frequency,
-  data-clk_frequency);
-   if (ret) {
-   dev_err(pdev-dev, clock-frequency missing or invalid\n);
-   goto fail;
+   data-codec_clk = clk_get(codec_dev-dev, NULL);
+   if (IS_ERR(data-codec_clk)) {
+   /* assuming clock enabled by default */
+   data-codec_clk = NULL;
+   ret = of_property_read_u32(codec_np, clock-frequency,
+   data-clk_frequency);
+   if (ret) {
+   dev_err(codec_dev-dev,
+   clock-frequency missing or invalid\n);
+   goto fail;
+   }
+   } else {
+   data-clk_frequency = clk_get_rate(data-codec_clk);
+   clk_prepare_enable(data-codec_clk);
}
 
data-dai.name = HiFi;
@@ -140,10 +158,10 @@ static int __devinit imx_sgtl5000_probe(struct 
platform_device *pdev)
data-card.dev = pdev-dev;
ret = snd_soc_of_parse_card_name(data-card, model);
if (ret)
-   goto fail;
+   goto clk_fail;
ret = snd_soc_of_parse_audio_routing(data-card, audio-routing);
if (ret)
-   goto fail;
+   goto clk_fail;
data-card.num_links = 1;
data-card.dai_link = data-dai;
data-card.dapm_widgets = imx_sgtl5000_dapm_widgets;
@@ -152,10 +170,12 @@ static int __devinit imx_sgtl5000_probe(struct 
platform_device *pdev)
ret = snd_soc_register_card(data-card);
if (ret) {
dev_err(pdev-dev, snd_soc_register_card failed (%d)\n, ret);
-   goto fail;
+   goto clk_fail;
}
 
platform_set_drvdata(pdev, data);
+clk_fail:
+   clk_put(data-codec_clk);
 fail:
if (ssi_np)
of_node_put(ssi_np);
@@ -169,6 +189,10 @@ static int __devexit imx_sgtl5000_remove(struct 
platform_device *pdev)
 {
struct imx_sgtl5000_data *data = platform_get_drvdata(pdev);
 
+   if (data-codec_clk) {
+   clk_disable_unprepare(data-codec_clk);
+   clk_put(data-codec_clk);
+   }
snd_soc_unregister_card(data-card);
 
return 0;
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 04/11] i2c: imx: add pinctrl support

2012-04-27 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 arch/arm/boot/dts/imx6q-sabrelite.dts |2 ++
 arch/arm/boot/dts/imx6q.dtsi  |   16 
 drivers/i2c/busses/i2c-imx.c  |9 +
 3 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/imx6q-sabrelite.dts 
b/arch/arm/boot/dts/imx6q-sabrelite.dts
index 4663a4e..4e13293 100644
--- a/arch/arm/boot/dts/imx6q-sabrelite.dts
+++ b/arch/arm/boot/dts/imx6q-sabrelite.dts
@@ -50,6 +50,8 @@
i2c@021a { /* I2C1 */
status = okay;
clock-frequency = 10;
+   pinctrl-names = default;
+   pinctrl-0 = pinctrl_i2c1_1;
 
codec: sgtl5000@0a {
compatible = fsl,sgtl5000;
diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi
index 2ba32e7..fe8c80d 100644
--- a/arch/arm/boot/dts/imx6q.dtsi
+++ b/arch/arm/boot/dts/imx6q.dtsi
@@ -390,6 +390,22 @@
reg = 0x020e 0x4000;
 
/* shared pinctrl settings */
+   i2c1 {
+   pinctrl_i2c1_1: i2c1grp-1 {
+   fsl,pins =  
MX6Q_PAD_EIM_D21,
+   
MX6Q_PAD_EIM_D28;
+   fsl,hysteresis = 1;
+   fsl,mux = 0x16 0x11;
+   fsl,pull = 2;
+   fsl,pue = 1;
+   fsl,pke = 1;
+   fsl,open-drain = 1;
+   fsl,speed = 2;
+   fsl,drive-strength = 6;
+   fsl,slew-rate = 1;
+   };
+   };
+
uart4 {
pinctrl_uart4_1: uart4grp-1 {
fsl,pins =  
MX6Q_PAD_KEY_COL0,
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index dfb84b7..7a52067 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -48,6 +48,7 @@
 #include linux/platform_device.h
 #include linux/clk.h
 #include linux/slab.h
+#include linux/pinctrl/consumer.h
 #include linux/of.h
 #include linux/of_device.h
 #include linux/of_i2c.h
@@ -470,6 +471,7 @@ static int __init i2c_imx_probe(struct platform_device 
*pdev)
struct imx_i2c_struct *i2c_imx;
struct resource *res;
struct imxi2c_platform_data *pdata = pdev-dev.platform_data;
+   struct pinctrl *pct;
void __iomem *base;
resource_size_t res_size;
int irq, bitrate;
@@ -520,6 +522,13 @@ static int __init i2c_imx_probe(struct platform_device 
*pdev)
i2c_imx-base   = base;
i2c_imx-res= res;
 
+   pct = devm_pinctrl_get_select_default(pdev-dev);
+   if (IS_ERR(pct)) {
+   dev_err(pdev-dev, can't get/select pinctrl\n);
+   ret = PTR_ERR(pct);
+   goto fail3;
+   }
+
/* Get I2C clock */
i2c_imx-clk = clk_get(pdev-dev, i2c_clk);
if (IS_ERR(i2c_imx-clk)) {
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 06/11] ARM: dts: imx6q-sabrelite: add ssi device

2012-04-27 Thread Richard Zhao
From: Richard Zhao richard.z...@linaro.org

Signed-off-by: Richard Zhao richard.z...@linaro.org
Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 arch/arm/boot/dts/imx6q-sabrelite.dts |9 +
 arch/arm/boot/dts/imx6q.dtsi  |   18 +++---
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boot/dts/imx6q-sabrelite.dts 
b/arch/arm/boot/dts/imx6q-sabrelite.dts
index 4e13293..7bd8855 100644
--- a/arch/arm/boot/dts/imx6q-sabrelite.dts
+++ b/arch/arm/boot/dts/imx6q-sabrelite.dts
@@ -22,6 +22,15 @@
};
 
soc {
+   aips-bus@0200 { /* AIPS1 */
+   spba-bus@0200 {
+   ssi1: ssi@02028000 {
+   fsl,mode = i2s-slave;
+   status = okay;
+   };
+   };
+   };
+
aips-bus@0210 { /* AIPS2 */
enet@02188000 {
phy-mode = rgmii;
diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi
index fe8c80d..da42fc0 100644
--- a/arch/arm/boot/dts/imx6q.dtsi
+++ b/arch/arm/boot/dts/imx6q.dtsi
@@ -177,19 +177,31 @@
interrupts = 0 51 0x04;
};
 
-   ssi@02028000 { /* SSI1 */
+   ssi1: ssi@02028000 {
+   compatible = 
fsl,imx6q-ssi,fsl,imx21-ssi;
reg = 0x02028000 0x4000;
interrupts = 0 46 0x04;
+   fsl,fifo-depth = 15;
+   fsl,ssi-dma-events = 38 37;
+   status = disabled;
};
 
-   ssi@0202c000 { /* SSI2 */
+   ssi2: ssi@0202c000 {
+   compatible = 
fsl,imx6q-ssi,fsl,imx21-ssi;
reg = 0x0202c000 0x4000;
interrupts = 0 47 0x04;
+   fsl,fifo-depth = 15;
+   fsl,ssi-dma-events = 42 41;
+   status = disabled;
};
 
-   ssi@0203 { /* SSI3 */
+   ssi3: ssi@0203 {
+   compatible = 
fsl,imx6q-ssi,fsl,imx21-ssi;
reg = 0x0203 0x4000;
interrupts = 0 48 0x04;
+   fsl,fifo-depth = 15;
+   fsl,ssi-dma-events = 46 45;
+   status = disabled;
};
 
asrc@02034000 {
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 07/11] ARM: dts: imx6q-sabrelite: add audmux device

2012-04-27 Thread Richard Zhao
From: Richard Zhao richard.z...@linaro.org

Signed-off-by: Richard Zhao richard.z...@linaro.org
Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 arch/arm/boot/dts/imx6q-sabrelite.dts |3 +++
 arch/arm/boot/dts/imx6q.dtsi  |2 ++
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/imx6q-sabrelite.dts 
b/arch/arm/boot/dts/imx6q-sabrelite.dts
index 7bd8855..02f93bc 100644
--- a/arch/arm/boot/dts/imx6q-sabrelite.dts
+++ b/arch/arm/boot/dts/imx6q-sabrelite.dts
@@ -52,6 +52,9 @@
status = okay;
};
 
+   audmux@021d8000 {
+   status = okay;
+   };
uart2: uart@021e8000 {
status = okay;
};
diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi
index da42fc0..7bf402e 100644
--- a/arch/arm/boot/dts/imx6q.dtsi
+++ b/arch/arm/boot/dts/imx6q.dtsi
@@ -596,7 +596,9 @@
};
 
audmux@021d8000 {
+   compatible = fsl,imx6q-audmux, 
fsl,imx31-audmux;
reg = 0x021d8000 0x4000;
+   status = disabled;
};
 
mipi@021dc000 { /* MIPI-CSI */
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 09/11] ARM: imx6q: add ssi1 clk_lookup

2012-04-27 Thread Richard Zhao
It's used by audio drivers.

Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 arch/arm/mach-imx/clk-imx6q.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-imx/clk-imx6q.c b/arch/arm/mach-imx/clk-imx6q.c
index f40a35d..9a03dcc 100644
--- a/arch/arm/mach-imx/clk-imx6q.c
+++ b/arch/arm/mach-imx/clk-imx6q.c
@@ -418,6 +418,7 @@ int __init mx6q_clocks_init(void)
clk_register_clkdev(clk[sdma], NULL, 20ec000.sdma);
clk_register_clkdev(clk[dummy], NULL, 20bc000.wdog);
clk_register_clkdev(clk[dummy], NULL, 20c.wdog);
+   clk_register_clkdev(clk[ssi1], NULL, 2028000.ssi);
 
for (i = 0; i  ARRAY_SIZE(clks_init_on); i++) {
c = clk_get_sys(clks_init_on[i], NULL);
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/11] ARM: imx6q_sabrelite: clkdev_add cko1 for sgtl5000

2012-04-27 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 arch/arm/mach-imx/clk-imx6q.c  |3 +++
 arch/arm/mach-imx/mach-imx6q.c |   28 
 2 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-imx/clk-imx6q.c b/arch/arm/mach-imx/clk-imx6q.c
index 9a03dcc..4ea0de0 100644
--- a/arch/arm/mach-imx/clk-imx6q.c
+++ b/arch/arm/mach-imx/clk-imx6q.c
@@ -419,6 +419,9 @@ int __init mx6q_clocks_init(void)
clk_register_clkdev(clk[dummy], NULL, 20bc000.wdog);
clk_register_clkdev(clk[dummy], NULL, 20c.wdog);
clk_register_clkdev(clk[ssi1], NULL, 2028000.ssi);
+   clk_register_clkdev(clk[cko1_sel], cko1_sel, NULL);
+   clk_register_clkdev(clk[ahb], ahb, NULL);
+   clk_register_clkdev(clk[cko1], cko1, NULL);
 
for (i = 0; i  ARRAY_SIZE(clks_init_on); i++) {
c = clk_get_sys(clks_init_on[i], NULL);
diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c
index d25c5d8..e9b2522 100644
--- a/arch/arm/mach-imx/mach-imx6q.c
+++ b/arch/arm/mach-imx/mach-imx6q.c
@@ -10,6 +10,8 @@
  * http://www.gnu.org/copyleft/gpl.html
  */
 
+#include linux/clkdev.h
+#include linux/clk.h
 #include linux/delay.h
 #include linux/init.h
 #include linux/io.h
@@ -75,10 +77,36 @@ static int ksz9021rn_phy_fixup(struct phy_device *phydev)
return 0;
 }
 
+static void __init imx6q_cko1_setup(void)
+{
+   struct clk *cko1_sel, *ahb, *cko1;
+   unsigned long rate;
+
+   cko1_sel = clk_get_sys(NULL, cko1_sel);
+   ahb = clk_get_sys(NULL, ahb);
+   cko1 = clk_get_sys(NULL, cko1);
+   if (IS_ERR(cko1_sel) || IS_ERR(ahb) || IS_ERR(cko1)) {
+   printk(KERN_ERR cko1 setup failed!\n);
+   goto put_clk;
+   }
+   clk_set_parent(cko1_sel, ahb);
+   rate = clk_round_rate(cko1, 1600);
+   clk_set_rate(cko1, rate);
+   clk_register_clkdev(cko1, NULL, 0-000a);
+put_clk:
+   if (!IS_ERR(cko1_sel))
+   clk_put(cko1_sel);
+   if (!IS_ERR(ahb))
+   clk_put(ahb);
+   if (!IS_ERR(cko1))
+   clk_put(cko1);
+}
+
 static void __init imx6q_sabrelite_init(void)
 {
phy_register_fixup_for_uid(PHY_ID_KSZ9021, MICREL_PHY_ID_MASK,
ksz9021rn_phy_fixup);
+   imx6q_cko1_setup();
 }
 
 static void __init imx6q_init_machine(void)
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 01/11] dma: imx-sdma: make channel0 operations atomic

2012-04-27 Thread Richard Zhao
device_prep_dma_cyclic may be call in audio trigger function which is
atomic context, so we make it atomic too.

 - change channel0 lock to spinlock.
 - Use polling to wait for channel0 finish running.

Signed-off-by: Lothar Waßmann l...@karo-electronics.de
Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 drivers/dma/imx-sdma.c |   57 +++
 1 files changed, 33 insertions(+), 24 deletions(-)

diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index fddccae..fc49ffa 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -24,7 +24,7 @@
 #include linux/mm.h
 #include linux/interrupt.h
 #include linux/clk.h
-#include linux/wait.h
+#include linux/delay.h
 #include linux/sched.h
 #include linux/semaphore.h
 #include linux/spinlock.h
@@ -324,7 +324,7 @@ struct sdma_engine {
struct dma_device   dma_device;
struct clk  *clk_ipg;
struct clk  *clk_ahb;
-   struct mutexchannel_0_lock;
+   spinlock_t  channel_0_lock;
struct sdma_script_start_addrs  *script_addrs;
 };
 
@@ -402,19 +402,31 @@ static void sdma_enable_channel(struct sdma_engine *sdma, 
int channel)
 }
 
 /*
- * sdma_run_channel - run a channel and wait till it's done
+ * sdma_run_channel0 - run a channel and wait till it's done
  */
-static int sdma_run_channel(struct sdma_channel *sdmac)
+static int sdma_run_channel0(struct sdma_channel *sdmac)
 {
struct sdma_engine *sdma = sdmac-sdma;
int channel = sdmac-channel;
int ret;
+   unsigned long timeout = 500;
 
-   init_completion(sdmac-done);
-
+   if (channel)
+   return -EINVAL;
sdma_enable_channel(sdma, channel);
 
-   ret = wait_for_completion_timeout(sdmac-done, HZ);
+   while (!(ret = readl_relaxed(sdma-regs + SDMA_H_INTR)  1)) {
+   if (timeout-- = 0)
+   break;
+   udelay(1);
+   }
+
+   if (ret) {
+   /* Clear the interrupt status */
+   writel_relaxed(ret, sdma-regs + SDMA_H_INTR);
+   } else {
+   dev_err(sdma-dev, Timeout waiting for CH0 ready\n);
+   }
 
return ret ? 0 : -ETIMEDOUT;
 }
@@ -426,17 +438,17 @@ static int sdma_load_script(struct sdma_engine *sdma, 
void *buf, int size,
void *buf_virt;
dma_addr_t buf_phys;
int ret;
-
-   mutex_lock(sdma-channel_0_lock);
+   unsigned long flags;
 
buf_virt = dma_alloc_coherent(NULL,
size,
buf_phys, GFP_KERNEL);
if (!buf_virt) {
-   ret = -ENOMEM;
-   goto err_out;
+   return -ENOMEM;
}
 
+   spin_lock_irqsave(sdma-channel_0_lock, flags);
+
bd0-mode.command = C0_SETPM;
bd0-mode.status = BD_DONE | BD_INTR | BD_WRAP | BD_EXTD;
bd0-mode.count = size / 2;
@@ -445,12 +457,11 @@ static int sdma_load_script(struct sdma_engine *sdma, 
void *buf, int size,
 
memcpy(buf_virt, buf, size);
 
-   ret = sdma_run_channel(sdma-channel[0]);
+   ret = sdma_run_channel0(sdma-channel[0]);
 
-   dma_free_coherent(NULL, size, buf_virt, buf_phys);
+   spin_unlock_irqrestore(sdma-channel_0_lock, flags);
 
-err_out:
-   mutex_unlock(sdma-channel_0_lock);
+   dma_free_coherent(NULL, size, buf_virt, buf_phys);
 
return ret;
 }
@@ -539,10 +550,6 @@ static void mxc_sdma_handle_channel(struct sdma_channel 
*sdmac)
 {
complete(sdmac-done);
 
-   /* not interested in channel 0 interrupts */
-   if (sdmac-channel == 0)
-   return;
-
if (sdmac-flags  IMX_DMA_SG_LOOP)
sdma_handle_channel_loop(sdmac);
else
@@ -555,6 +562,8 @@ static irqreturn_t sdma_int_handler(int irq, void *dev_id)
unsigned long stat;
 
stat = readl_relaxed(sdma-regs + SDMA_H_INTR);
+   /* not interested in channel 0 interrupts */
+   stat = ~1;
writel_relaxed(stat, sdma-regs + SDMA_H_INTR);
 
while (stat) {
@@ -660,6 +669,7 @@ static int sdma_load_context(struct sdma_channel *sdmac)
struct sdma_context_data *context = sdma-context;
struct sdma_buffer_descriptor *bd0 = sdma-channel[0].bd;
int ret;
+   unsigned long flags;
 
if (sdmac-direction == DMA_DEV_TO_MEM) {
load_address = sdmac-pc_from_device;
@@ -677,7 +687,7 @@ static int sdma_load_context(struct sdma_channel *sdmac)
dev_dbg(sdma-dev, event_mask0 = 0x%08x\n, (u32)sdmac-event_mask[0]);
dev_dbg(sdma-dev, event_mask1 = 0x%08x\n, (u32)sdmac-event_mask[1]);
 
-   mutex_lock(sdma-channel_0_lock);
+   spin_lock_irqsave(sdma-channel_0_lock, flags);
 
memset(context, 0, sizeof(*context));
context-channel_state.pc = load_address;
@@ -696,10 +706,9 @@ static int sdma_load_context(struct sdma_channel *sdmac

[PATCH 02/11] ASoC: imx-sgtl5000: add of_node_put when probe fail.

2012-04-27 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 sound/soc/fsl/imx-sgtl5000.c |   29 ++---
 1 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/sound/soc/fsl/imx-sgtl5000.c b/sound/soc/fsl/imx-sgtl5000.c
index e1a7441..73b935e 100644
--- a/sound/soc/fsl/imx-sgtl5000.c
+++ b/sound/soc/fsl/imx-sgtl5000.c
@@ -103,24 +103,28 @@ static int __devinit imx_sgtl5000_probe(struct 
platform_device *pdev)
codec_np = of_parse_phandle(pdev-dev.of_node, audio-codec, 0);
if (!ssi_np || !codec_np) {
dev_err(pdev-dev, phandle missing or invalid\n);
-   return -EINVAL;
+   ret = -EINVAL;
+   goto fail;
}
 
ssi_pdev = of_find_device_by_node(ssi_np);
if (!ssi_pdev) {
dev_err(pdev-dev, failed to find SSI platform device\n);
-   return -EINVAL;
+   ret = -EINVAL;
+   goto fail;
}
 
data = devm_kzalloc(pdev-dev, sizeof(*data), GFP_KERNEL);
-   if (!data)
-   return -ENOMEM;
+   if (!data) {
+   ret = -ENOMEM;
+   goto fail;
+   }
 
ret = of_property_read_u32(codec_np, clock-frequency,
   data-clk_frequency);
if (ret) {
dev_err(pdev-dev, clock-frequency missing or invalid\n);
-   return ret;
+   goto fail;
}
 
data-dai.name = HiFi;
@@ -136,10 +140,10 @@ static int __devinit imx_sgtl5000_probe(struct 
platform_device *pdev)
data-card.dev = pdev-dev;
ret = snd_soc_of_parse_card_name(data-card, model);
if (ret)
-   return ret;
+   goto fail;
ret = snd_soc_of_parse_audio_routing(data-card, audio-routing);
if (ret)
-   return ret;
+   goto fail;
data-card.num_links = 1;
data-card.dai_link = data-dai;
data-card.dapm_widgets = imx_sgtl5000_dapm_widgets;
@@ -148,14 +152,17 @@ static int __devinit imx_sgtl5000_probe(struct 
platform_device *pdev)
ret = snd_soc_register_card(data-card);
if (ret) {
dev_err(pdev-dev, snd_soc_register_card failed (%d)\n, ret);
-   return ret;
+   goto fail;
}
 
platform_set_drvdata(pdev, data);
-   of_node_put(ssi_np);
-   of_node_put(codec_np);
+fail:
+   if (ssi_np)
+   of_node_put(ssi_np);
+   if (codec_np)
+   of_node_put(codec_np);
 
-   return 0;
+   return ret;
 }
 
 static int __devexit imx_sgtl5000_remove(struct platform_device *pdev)
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 04/11] i2c: imx: add pinctrl support

2012-04-27 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 arch/arm/boot/dts/imx6q-sabrelite.dts |2 ++
 arch/arm/boot/dts/imx6q.dtsi  |   16 
 drivers/i2c/busses/i2c-imx.c  |9 +
 3 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/imx6q-sabrelite.dts 
b/arch/arm/boot/dts/imx6q-sabrelite.dts
index 4663a4e..4e13293 100644
--- a/arch/arm/boot/dts/imx6q-sabrelite.dts
+++ b/arch/arm/boot/dts/imx6q-sabrelite.dts
@@ -50,6 +50,8 @@
i2c@021a { /* I2C1 */
status = okay;
clock-frequency = 10;
+   pinctrl-names = default;
+   pinctrl-0 = pinctrl_i2c1_1;
 
codec: sgtl5000@0a {
compatible = fsl,sgtl5000;
diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi
index 2ba32e7..fe8c80d 100644
--- a/arch/arm/boot/dts/imx6q.dtsi
+++ b/arch/arm/boot/dts/imx6q.dtsi
@@ -390,6 +390,22 @@
reg = 0x020e 0x4000;
 
/* shared pinctrl settings */
+   i2c1 {
+   pinctrl_i2c1_1: i2c1grp-1 {
+   fsl,pins =  
MX6Q_PAD_EIM_D21,
+   
MX6Q_PAD_EIM_D28;
+   fsl,hysteresis = 1;
+   fsl,mux = 0x16 0x11;
+   fsl,pull = 2;
+   fsl,pue = 1;
+   fsl,pke = 1;
+   fsl,open-drain = 1;
+   fsl,speed = 2;
+   fsl,drive-strength = 6;
+   fsl,slew-rate = 1;
+   };
+   };
+
uart4 {
pinctrl_uart4_1: uart4grp-1 {
fsl,pins =  
MX6Q_PAD_KEY_COL0,
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index dfb84b7..7a52067 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -48,6 +48,7 @@
 #include linux/platform_device.h
 #include linux/clk.h
 #include linux/slab.h
+#include linux/pinctrl/consumer.h
 #include linux/of.h
 #include linux/of_device.h
 #include linux/of_i2c.h
@@ -470,6 +471,7 @@ static int __init i2c_imx_probe(struct platform_device 
*pdev)
struct imx_i2c_struct *i2c_imx;
struct resource *res;
struct imxi2c_platform_data *pdata = pdev-dev.platform_data;
+   struct pinctrl *pct;
void __iomem *base;
resource_size_t res_size;
int irq, bitrate;
@@ -520,6 +522,13 @@ static int __init i2c_imx_probe(struct platform_device 
*pdev)
i2c_imx-base   = base;
i2c_imx-res= res;
 
+   pct = devm_pinctrl_get_select_default(pdev-dev);
+   if (IS_ERR(pct)) {
+   dev_err(pdev-dev, can't get/select pinctrl\n);
+   ret = PTR_ERR(pct);
+   goto fail3;
+   }
+
/* Get I2C clock */
i2c_imx-clk = clk_get(pdev-dev, i2c_clk);
if (IS_ERR(i2c_imx-clk)) {
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 03/11] ASoC: fsl: add sgtl5000 clock support for imx-sgtl5000

2012-04-27 Thread Richard Zhao
From: Richard Zhao richard.z...@linaro.org

It tries to clk_get the clock. And if it failed, it assumes the clock
by default enabled.

Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 sound/soc/fsl/imx-sgtl5000.c |   40 
 1 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/sound/soc/fsl/imx-sgtl5000.c b/sound/soc/fsl/imx-sgtl5000.c
index 73b935e..3a729ca 100644
--- a/sound/soc/fsl/imx-sgtl5000.c
+++ b/sound/soc/fsl/imx-sgtl5000.c
@@ -13,6 +13,8 @@
 #include linux/module.h
 #include linux/of.h
 #include linux/of_platform.h
+#include linux/of_i2c.h
+#include linux/clk.h
 #include sound/soc.h
 
 #include ../codecs/sgtl5000.h
@@ -25,6 +27,7 @@ struct imx_sgtl5000_data {
struct snd_soc_card card;
char codec_dai_name[DAI_NAME_SIZE];
char platform_name[DAI_NAME_SIZE];
+   struct clk *codec_clk;
unsigned int clk_frequency;
 };
 
@@ -58,6 +61,7 @@ static int __devinit imx_sgtl5000_probe(struct 
platform_device *pdev)
struct device_node *np = pdev-dev.of_node;
struct device_node *ssi_np, *codec_np;
struct platform_device *ssi_pdev;
+   struct i2c_client *codec_dev;
struct imx_sgtl5000_data *data;
int int_port, ext_port;
int ret;
@@ -113,6 +117,11 @@ static int __devinit imx_sgtl5000_probe(struct 
platform_device *pdev)
ret = -EINVAL;
goto fail;
}
+   codec_dev = of_find_i2c_device_by_node(codec_np);
+   if (!codec_dev) {
+   dev_err(pdev-dev, failed to find codec platform device\n);
+   return -EINVAL;
+   }
 
data = devm_kzalloc(pdev-dev, sizeof(*data), GFP_KERNEL);
if (!data) {
@@ -120,11 +129,20 @@ static int __devinit imx_sgtl5000_probe(struct 
platform_device *pdev)
goto fail;
}
 
-   ret = of_property_read_u32(codec_np, clock-frequency,
-  data-clk_frequency);
-   if (ret) {
-   dev_err(pdev-dev, clock-frequency missing or invalid\n);
-   goto fail;
+   data-codec_clk = clk_get(codec_dev-dev, NULL);
+   if (IS_ERR(data-codec_clk)) {
+   /* assuming clock enabled by default */
+   data-codec_clk = NULL;
+   ret = of_property_read_u32(codec_np, clock-frequency,
+   data-clk_frequency);
+   if (ret) {
+   dev_err(codec_dev-dev,
+   clock-frequency missing or invalid\n);
+   goto fail;
+   }
+   } else {
+   data-clk_frequency = clk_get_rate(data-codec_clk);
+   clk_prepare_enable(data-codec_clk);
}
 
data-dai.name = HiFi;
@@ -140,10 +158,10 @@ static int __devinit imx_sgtl5000_probe(struct 
platform_device *pdev)
data-card.dev = pdev-dev;
ret = snd_soc_of_parse_card_name(data-card, model);
if (ret)
-   goto fail;
+   goto clk_fail;
ret = snd_soc_of_parse_audio_routing(data-card, audio-routing);
if (ret)
-   goto fail;
+   goto clk_fail;
data-card.num_links = 1;
data-card.dai_link = data-dai;
data-card.dapm_widgets = imx_sgtl5000_dapm_widgets;
@@ -152,10 +170,12 @@ static int __devinit imx_sgtl5000_probe(struct 
platform_device *pdev)
ret = snd_soc_register_card(data-card);
if (ret) {
dev_err(pdev-dev, snd_soc_register_card failed (%d)\n, ret);
-   goto fail;
+   goto clk_fail;
}
 
platform_set_drvdata(pdev, data);
+clk_fail:
+   clk_put(data-codec_clk);
 fail:
if (ssi_np)
of_node_put(ssi_np);
@@ -169,6 +189,10 @@ static int __devexit imx_sgtl5000_remove(struct 
platform_device *pdev)
 {
struct imx_sgtl5000_data *data = platform_get_drvdata(pdev);
 
+   if (data-codec_clk) {
+   clk_disable_unprepare(data-codec_clk);
+   clk_put(data-codec_clk);
+   }
snd_soc_unregister_card(data-card);
 
return 0;
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 05/11] ARM: imx6q: move imx6q_sabrelite specific code to a dedicated function

2012-04-27 Thread Richard Zhao
It'll be easier to add other board specific code.

Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 arch/arm/mach-imx/mach-imx6q.c |9 +++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c
index da6c1d9..d25c5d8 100644
--- a/arch/arm/mach-imx/mach-imx6q.c
+++ b/arch/arm/mach-imx/mach-imx6q.c
@@ -75,11 +75,16 @@ static int ksz9021rn_phy_fixup(struct phy_device *phydev)
return 0;
 }
 
+static void __init imx6q_sabrelite_init(void)
+{
+   phy_register_fixup_for_uid(PHY_ID_KSZ9021, MICREL_PHY_ID_MASK,
+   ksz9021rn_phy_fixup);
+}
+
 static void __init imx6q_init_machine(void)
 {
if (of_machine_is_compatible(fsl,imx6q-sabrelite))
-   phy_register_fixup_for_uid(PHY_ID_KSZ9021, MICREL_PHY_ID_MASK,
-  ksz9021rn_phy_fixup);
+   imx6q_sabrelite_init();
 
of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
 
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 06/11] ARM: dts: imx6q-sabrelite: add ssi device

2012-04-27 Thread Richard Zhao
From: Richard Zhao richard.z...@linaro.org

Signed-off-by: Richard Zhao richard.z...@linaro.org
Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 arch/arm/boot/dts/imx6q-sabrelite.dts |9 +
 arch/arm/boot/dts/imx6q.dtsi  |   18 +++---
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boot/dts/imx6q-sabrelite.dts 
b/arch/arm/boot/dts/imx6q-sabrelite.dts
index 4e13293..7bd8855 100644
--- a/arch/arm/boot/dts/imx6q-sabrelite.dts
+++ b/arch/arm/boot/dts/imx6q-sabrelite.dts
@@ -22,6 +22,15 @@
};
 
soc {
+   aips-bus@0200 { /* AIPS1 */
+   spba-bus@0200 {
+   ssi1: ssi@02028000 {
+   fsl,mode = i2s-slave;
+   status = okay;
+   };
+   };
+   };
+
aips-bus@0210 { /* AIPS2 */
enet@02188000 {
phy-mode = rgmii;
diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi
index fe8c80d..da42fc0 100644
--- a/arch/arm/boot/dts/imx6q.dtsi
+++ b/arch/arm/boot/dts/imx6q.dtsi
@@ -177,19 +177,31 @@
interrupts = 0 51 0x04;
};
 
-   ssi@02028000 { /* SSI1 */
+   ssi1: ssi@02028000 {
+   compatible = 
fsl,imx6q-ssi,fsl,imx21-ssi;
reg = 0x02028000 0x4000;
interrupts = 0 46 0x04;
+   fsl,fifo-depth = 15;
+   fsl,ssi-dma-events = 38 37;
+   status = disabled;
};
 
-   ssi@0202c000 { /* SSI2 */
+   ssi2: ssi@0202c000 {
+   compatible = 
fsl,imx6q-ssi,fsl,imx21-ssi;
reg = 0x0202c000 0x4000;
interrupts = 0 47 0x04;
+   fsl,fifo-depth = 15;
+   fsl,ssi-dma-events = 42 41;
+   status = disabled;
};
 
-   ssi@0203 { /* SSI3 */
+   ssi3: ssi@0203 {
+   compatible = 
fsl,imx6q-ssi,fsl,imx21-ssi;
reg = 0x0203 0x4000;
interrupts = 0 48 0x04;
+   fsl,fifo-depth = 15;
+   fsl,ssi-dma-events = 46 45;
+   status = disabled;
};
 
asrc@02034000 {
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/11] ARM: imx6q_sabrelite: clkdev_add cko1 for sgtl5000

2012-04-27 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 arch/arm/mach-imx/clk-imx6q.c  |3 +++
 arch/arm/mach-imx/mach-imx6q.c |   28 
 2 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-imx/clk-imx6q.c b/arch/arm/mach-imx/clk-imx6q.c
index 9a03dcc..4ea0de0 100644
--- a/arch/arm/mach-imx/clk-imx6q.c
+++ b/arch/arm/mach-imx/clk-imx6q.c
@@ -419,6 +419,9 @@ int __init mx6q_clocks_init(void)
clk_register_clkdev(clk[dummy], NULL, 20bc000.wdog);
clk_register_clkdev(clk[dummy], NULL, 20c.wdog);
clk_register_clkdev(clk[ssi1], NULL, 2028000.ssi);
+   clk_register_clkdev(clk[cko1_sel], cko1_sel, NULL);
+   clk_register_clkdev(clk[ahb], ahb, NULL);
+   clk_register_clkdev(clk[cko1], cko1, NULL);
 
for (i = 0; i  ARRAY_SIZE(clks_init_on); i++) {
c = clk_get_sys(clks_init_on[i], NULL);
diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c
index d25c5d8..e9b2522 100644
--- a/arch/arm/mach-imx/mach-imx6q.c
+++ b/arch/arm/mach-imx/mach-imx6q.c
@@ -10,6 +10,8 @@
  * http://www.gnu.org/copyleft/gpl.html
  */
 
+#include linux/clkdev.h
+#include linux/clk.h
 #include linux/delay.h
 #include linux/init.h
 #include linux/io.h
@@ -75,10 +77,36 @@ static int ksz9021rn_phy_fixup(struct phy_device *phydev)
return 0;
 }
 
+static void __init imx6q_cko1_setup(void)
+{
+   struct clk *cko1_sel, *ahb, *cko1;
+   unsigned long rate;
+
+   cko1_sel = clk_get_sys(NULL, cko1_sel);
+   ahb = clk_get_sys(NULL, ahb);
+   cko1 = clk_get_sys(NULL, cko1);
+   if (IS_ERR(cko1_sel) || IS_ERR(ahb) || IS_ERR(cko1)) {
+   printk(KERN_ERR cko1 setup failed!\n);
+   goto put_clk;
+   }
+   clk_set_parent(cko1_sel, ahb);
+   rate = clk_round_rate(cko1, 1600);
+   clk_set_rate(cko1, rate);
+   clk_register_clkdev(cko1, NULL, 0-000a);
+put_clk:
+   if (!IS_ERR(cko1_sel))
+   clk_put(cko1_sel);
+   if (!IS_ERR(ahb))
+   clk_put(ahb);
+   if (!IS_ERR(cko1))
+   clk_put(cko1);
+}
+
 static void __init imx6q_sabrelite_init(void)
 {
phy_register_fixup_for_uid(PHY_ID_KSZ9021, MICREL_PHY_ID_MASK,
ksz9021rn_phy_fixup);
+   imx6q_cko1_setup();
 }
 
 static void __init imx6q_init_machine(void)
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 07/11] ARM: dts: imx6q-sabrelite: add audmux device

2012-04-27 Thread Richard Zhao
From: Richard Zhao richard.z...@linaro.org

Signed-off-by: Richard Zhao richard.z...@linaro.org
Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 arch/arm/boot/dts/imx6q-sabrelite.dts |3 +++
 arch/arm/boot/dts/imx6q.dtsi  |2 ++
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/imx6q-sabrelite.dts 
b/arch/arm/boot/dts/imx6q-sabrelite.dts
index 7bd8855..02f93bc 100644
--- a/arch/arm/boot/dts/imx6q-sabrelite.dts
+++ b/arch/arm/boot/dts/imx6q-sabrelite.dts
@@ -52,6 +52,9 @@
status = okay;
};
 
+   audmux@021d8000 {
+   status = okay;
+   };
uart2: uart@021e8000 {
status = okay;
};
diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi
index da42fc0..7bf402e 100644
--- a/arch/arm/boot/dts/imx6q.dtsi
+++ b/arch/arm/boot/dts/imx6q.dtsi
@@ -596,7 +596,9 @@
};
 
audmux@021d8000 {
+   compatible = fsl,imx6q-audmux, 
fsl,imx31-audmux;
reg = 0x021d8000 0x4000;
+   status = disabled;
};
 
mipi@021dc000 { /* MIPI-CSI */
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 08/11] ASoC: imx-audmux: add pinctrl support

2012-04-27 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 arch/arm/boot/dts/imx6q-sabrelite.dts |3 +++
 arch/arm/boot/dts/imx6q.dtsi  |   10 ++
 sound/soc/fsl/imx-audmux.c|8 
 3 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/imx6q-sabrelite.dts 
b/arch/arm/boot/dts/imx6q-sabrelite.dts
index 02f93bc..cdae2dd 100644
--- a/arch/arm/boot/dts/imx6q-sabrelite.dts
+++ b/arch/arm/boot/dts/imx6q-sabrelite.dts
@@ -54,7 +54,10 @@
 
audmux@021d8000 {
status = okay;
+   pinctrl-names = default;
+   pinctrl-0 = pinctrl_audmux_1;
};
+
uart2: uart@021e8000 {
status = okay;
};
diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi
index 7bf402e..3c3004d 100644
--- a/arch/arm/boot/dts/imx6q.dtsi
+++ b/arch/arm/boot/dts/imx6q.dtsi
@@ -402,6 +402,16 @@
reg = 0x020e 0x4000;
 
/* shared pinctrl settings */
+   audmux {
+   pinctrl_audmux_1: audmux-1 {
+   fsl,pins =  
MX6Q_PAD_SD2_DAT0,
+   
MX6Q_PAD_SD2_DAT3,
+   
MX6Q_PAD_SD2_DAT2,
+   
MX6Q_PAD_SD2_DAT1;
+   fsl,mux = 3 3 3 3;
+   };
+   };
+
i2c1 {
pinctrl_i2c1_1: i2c1grp-1 {
fsl,pins =  
MX6Q_PAD_EIM_D21,
diff --git a/sound/soc/fsl/imx-audmux.c b/sound/soc/fsl/imx-audmux.c
index f237003..6c7dfc0 100644
--- a/sound/soc/fsl/imx-audmux.c
+++ b/sound/soc/fsl/imx-audmux.c
@@ -26,6 +26,7 @@
 #include linux/of_device.h
 #include linux/platform_device.h
 #include linux/slab.h
+#include linux/pinctrl/consumer.h
 
 #include imx-audmux.h
 
@@ -249,6 +250,7 @@ EXPORT_SYMBOL_GPL(imx_audmux_v2_configure_port);
 static int __devinit imx_audmux_probe(struct platform_device *pdev)
 {
struct resource *res;
+   struct pinctrl *pct;
const struct of_device_id *of_id =
of_match_device(imx_audmux_dt_ids, pdev-dev);
 
@@ -257,6 +259,12 @@ static int __devinit imx_audmux_probe(struct 
platform_device *pdev)
if (!audmux_base)
return -EADDRNOTAVAIL;
 
+   pct = devm_pinctrl_get_select_default(pdev-dev);
+   if (IS_ERR(pct)) {
+   dev_err(pdev-dev, setup pinctrl failed!);
+   return PTR_ERR(pct);
+   }
+
audmux_clk = clk_get(pdev-dev, audmux);
if (IS_ERR(audmux_clk)) {
dev_dbg(pdev-dev, cannot get clock: %ld\n,
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 09/11] ARM: imx6q: add ssi1 clk_lookup

2012-04-27 Thread Richard Zhao
It's used by audio drivers.

Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 arch/arm/mach-imx/clk-imx6q.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-imx/clk-imx6q.c b/arch/arm/mach-imx/clk-imx6q.c
index f40a35d..9a03dcc 100644
--- a/arch/arm/mach-imx/clk-imx6q.c
+++ b/arch/arm/mach-imx/clk-imx6q.c
@@ -418,6 +418,7 @@ int __init mx6q_clocks_init(void)
clk_register_clkdev(clk[sdma], NULL, 20ec000.sdma);
clk_register_clkdev(clk[dummy], NULL, 20bc000.wdog);
clk_register_clkdev(clk[dummy], NULL, 20c.wdog);
+   clk_register_clkdev(clk[ssi1], NULL, 2028000.ssi);
 
for (i = 0; i  ARRAY_SIZE(clks_init_on); i++) {
c = clk_get_sys(clks_init_on[i], NULL);
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 11/11] ARM: dts: imx6q-sabrelite: add sound device imx6q-sabrelite-sgtl5000

2012-04-27 Thread Richard Zhao
From: Richard Zhao richard.z...@linaro.org

Signed-off-by: Richard Zhao richard.z...@linaro.org
Signed-off-by: Richard Zhao richard.z...@freescale.com
---
 arch/arm/boot/dts/imx6q-sabrelite.dts |   13 +
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/imx6q-sabrelite.dts 
b/arch/arm/boot/dts/imx6q-sabrelite.dts
index cdae2dd..20aa767 100644
--- a/arch/arm/boot/dts/imx6q-sabrelite.dts
+++ b/arch/arm/boot/dts/imx6q-sabrelite.dts
@@ -97,4 +97,17 @@
regulator-always-on;
};
};
+
+   sound {
+   compatible = fsl,imx6q-sabrelite-sgtl5000,
+fsl,imx-audio-sgtl5000;
+   model = imx6q-sabrelite-sgtl5000;
+   ssi-controller = ssi1;
+   audio-codec = codec;
+   audio-routing =
+   MIC_IN, Mic Jack,
+   Headphone Jack, HP_OUT;
+   mux-int-port = 1;
+   mux-ext-port = 4;
+   };
 };
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 01/11] dma: imx-sdma: make channel0 operations atomic

2012-04-27 Thread Richard Zhao
On Fri, Apr 27, 2012 at 01:51:40PM +0530, Vinod Koul wrote:
 On Fri, 2012-04-27 at 15:02 +0800, Richard Zhao wrote:
  device_prep_dma_cyclic may be call in audio trigger function which is
  atomic context, so we make it atomic too.
 No this is wrong behavior. You should not call dma prepare functions in
 any of the sound trigger calls. It would make sense to move this in
 sound prepare callback.
Then, could you please doc it somewhere? I think I'm not the only one
confused.

Thanks
Richard
 
 -- 
 ~Vinod
 
 

--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 09/11] ARM: imx6q: add ssi1 clk_lookup

2012-04-27 Thread Richard Zhao
On Fri, Apr 27, 2012 at 10:04:12AM +0200, Sascha Hauer wrote:
 On Fri, Apr 27, 2012 at 03:03:03PM +0800, Richard Zhao wrote:
  It's used by audio drivers.
  
  Signed-off-by: Richard Zhao richard.z...@freescale.com
  ---
   arch/arm/mach-imx/clk-imx6q.c |1 +
   1 files changed, 1 insertions(+), 0 deletions(-)
  
  diff --git a/arch/arm/mach-imx/clk-imx6q.c b/arch/arm/mach-imx/clk-imx6q.c
  index f40a35d..9a03dcc 100644
  --- a/arch/arm/mach-imx/clk-imx6q.c
  +++ b/arch/arm/mach-imx/clk-imx6q.c
  @@ -418,6 +418,7 @@ int __init mx6q_clocks_init(void)
  clk_register_clkdev(clk[sdma], NULL, 20ec000.sdma);
  clk_register_clkdev(clk[dummy], NULL, 20bc000.wdog);
  clk_register_clkdev(clk[dummy], NULL, 20c.wdog);
  +   clk_register_clkdev(clk[ssi1], NULL, 2028000.ssi);
 
 The ssi clock needs a general cleanup on all i.MX just like I cleaned up
 the other units. The SSI unit has at least a register clock and a baud
 clock. What the driver requests and enables is the register clock.
 
 The baud clock is currently unused and is needed only for master mode
 (which is not implemented in the ssi driver)
Are you sure for that? If I don't enable clk[ssi1], the ssi will not
work.

 
 So where we want to come to is:
 
   clk_register_clkdev(clk[ipg], ipg, 2028000.ssi);
ssi don't have ipg gate. We can let it always on for imx6q.

Thanks
Richard
   clk_register_clkdev(clk[ssi1], baud, 2028000.ssi);
 
 Sascha
 
 
 -- 
 Pengutronix e.K.   | |
 Industrial Linux Solutions | http://www.pengutronix.de/  |
 Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
 Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
 

--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 01/11] dma: imx-sdma: make channel0 operations atomic

2012-04-27 Thread Richard Zhao
On Fri, Apr 27, 2012 at 09:55:44AM +0200, Sascha Hauer wrote:
 On Fri, Apr 27, 2012 at 03:02:55PM +0800, Richard Zhao wrote:
  device_prep_dma_cyclic may be call in audio trigger function which is
  atomic context, so we make it atomic too.
  
   - change channel0 lock to spinlock.
   - Use polling to wait for channel0 finish running.
  
  Signed-off-by: Lothar Waßmann l...@karo-electronics.de
  Signed-off-by: Richard Zhao richard.z...@freescale.com
  ---
   drivers/dma/imx-sdma.c |   57 
  +++
   1 files changed, 33 insertions(+), 24 deletions(-)
  
  diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
  index fddccae..fc49ffa 100644
  --- a/drivers/dma/imx-sdma.c
  +++ b/drivers/dma/imx-sdma.c
  @@ -24,7 +24,7 @@
   #include linux/mm.h
   #include linux/interrupt.h
   #include linux/clk.h
  -#include linux/wait.h
  +#include linux/delay.h
   #include linux/sched.h
   #include linux/semaphore.h
   #include linux/spinlock.h
  @@ -324,7 +324,7 @@ struct sdma_engine {
  struct dma_device   dma_device;
  struct clk  *clk_ipg;
  struct clk  *clk_ahb;
  -   struct mutexchannel_0_lock;
  +   spinlock_t  channel_0_lock;
  struct sdma_script_start_addrs  *script_addrs;
   };
   
  @@ -402,19 +402,31 @@ static void sdma_enable_channel(struct sdma_engine 
  *sdma, int channel)
   }
   
   /*
  - * sdma_run_channel - run a channel and wait till it's done
  + * sdma_run_channel0 - run a channel and wait till it's done
*/
  -static int sdma_run_channel(struct sdma_channel *sdmac)
  +static int sdma_run_channel0(struct sdma_channel *sdmac)
 
 Renaming this to sdma_run_channel0 is fine, but then the argument should
 be changed to struct sdma_engine. It makes no sense to say in the
 function name that this function is channel 0 only and at the same time
 allow to pass in an arbitrary other channel.
Correct. Thanks.

Richard
 
 Sascha
 
 
 -- 
 Pengutronix e.K.   | |
 Industrial Linux Solutions | http://www.pengutronix.de/  |
 Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
 Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
 

--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4] I2C: add CSR SiRFprimaII on-chip I2C controllers driver

2011-12-20 Thread Richard Zhao
On Wed, Dec 21, 2011 at 11:29:29AM +0800, Barry Song wrote:
 2011/12/21 Russell King - ARM Linux li...@arm.linux.org.uk:
  On Wed, Dec 14, 2011 at 04:55:27PM +0800, Barry Song wrote:
  +static int __devinit i2c_sirfsoc_probe(struct platform_device *pdev)
  +{
  +     struct clk *clk;
  +
  +     clk = clk_get(pdev-dev, NULL);
  +     err = clk_prepare(clk);
  +     err = clk_enable(clk);
  ...
  +     clk_disable(clk);
  +
  +     dev_info(pdev-dev,  I2C adapter ready to operate\n);
  +
  +     return 0;
  +}
  +
  +static int __devexit i2c_sirfsoc_remove(struct platform_device *pdev)
  +{
  +     clk_disable(siic-clk);
  +     clk_unprepare(siic-clk);
  +     clk_put(siic-clk);
 
There's a handy clk_disable_unprepare function in the patch I ever sent
out. It's in Sascha or Shawn's tree.

Richard
  This doesn't look right - look at the state which you leave the clk in
  upon successful probe, and now look at what you do when you do a remove.
 
  It seems that you disable an already disabled clock to me.
 
 Russell, thanks! i will fix that in v5. but i have to wait for Ben's
 feedback and add other fixes together before doing that.
 Ben seems to have been scheduled out, i hope the state is
 TASK_INTERRUPTBILE not TASK_UNINTERRUPTBILE. Then my signal can wake
 up him.
 
 Thanks
 barry
 
 ___
 linux-arm-kernel mailing list
 linux-arm-ker...@lists.infradead.org
 http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V3 10/14] ARM: mxs: add clk_prepare/clk_unprepare

2011-12-19 Thread Richard Zhao
On Mon, Dec 19, 2011 at 11:21:41PM +0100, Marek Vasut wrote:
  Signed-off-by: Richard Zhao richard.z...@linaro.org
  ---
   arch/arm/mach-mxs/system.c |2 +-
   arch/arm/mach-mxs/timer.c  |2 +-
   2 files changed, 2 insertions(+), 2 deletions(-)
  
  diff --git a/arch/arm/mach-mxs/system.c b/arch/arm/mach-mxs/system.c
  index 20ec3bd..9760a12 100644
  --- a/arch/arm/mach-mxs/system.c
  +++ b/arch/arm/mach-mxs/system.c
  @@ -66,7 +66,7 @@ static int __init mxs_arch_reset_init(void)
  
  clk = clk_get_sys(rtc, NULL);
  if (!IS_ERR(clk))
  -   clk_enable(clk);
  +   clk_prepare_enable(clk);
  
  return 0;
   }
  diff --git a/arch/arm/mach-mxs/timer.c b/arch/arm/mach-mxs/timer.c
  index cace0d2..564a632 100644
  --- a/arch/arm/mach-mxs/timer.c
  +++ b/arch/arm/mach-mxs/timer.c
  @@ -245,7 +245,7 @@ static int __init mxs_clocksource_init(struct clk
  *timer_clk)
  
   void __init mxs_timer_init(struct clk *timer_clk, int irq)
   {
  -   clk_enable(timer_clk);
  +   clk_prepare_enable(timer_clk);
  
  /*
   * Initialize timers to a known state
 
 Hi Richard,
 
 I just came across this, will this also help solve the mxs problem with mutex 
 lock begin done in atomic context in clk_enable/disable()?
No, It's for converting to generic clock framwork.
You can look at Mike's generic clock patches. clk_hw_ops.enable/disable
definitely can not sleep.
On register side, there' two way to protect register:
 - use a global spin lock
 - only use spin lock wherever gate register share the same one with
   other non-gate register.

Thanks
Richard
 
 M
 
 ___
 linux-arm-kernel mailing list
 linux-arm-ker...@lists.infradead.org
 http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
 

--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V4 00/14] add clk_prepare/clk_unprepare to imx drivers

2011-12-02 Thread Richard Zhao
Is there any body merged this patch series?

Thanks
Richard
On Thu, Nov 17, 2011 at 09:22:11AM +0800, Richard Zhao wrote:
 Hi Sascha,
 
 Would you merge this patch series?
 
 Thanks
 Richard 
 
 
 ___
 linux-arm-kernel mailing list
 linux-arm-ker...@lists.infradead.org
 http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
 

--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V4 00/14] add clk_prepare/clk_unprepare to imx drivers

2011-12-02 Thread Richard Zhao
On Fri, Dec 02, 2011 at 07:07:14PM +0800, Richard Zhao wrote:
 Is there any body merged this patch series?
Thanks, Sascha! Just found it's in your imx-features branch.

Richard
 
 Thanks
 Richard
 On Thu, Nov 17, 2011 at 09:22:11AM +0800, Richard Zhao wrote:
  Hi Sascha,
  
  Would you merge this patch series?
  
  Thanks
  Richard 
  
  
  ___
  linux-arm-kernel mailing list
  linux-arm-ker...@lists.infradead.org
  http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
  
 
 
 ___
 linux-arm-kernel mailing list
 linux-arm-ker...@lists.infradead.org
 http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
 

--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V4 00/14] add clk_prepare/clk_unprepare to imx drivers

2011-11-16 Thread Richard Zhao
Hi Sascha,

Would you merge this patch series?

Thanks
Richard 

--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V4 01/14] clk: add helper functions clk_prepare_enable and clk_disable_unprepare

2011-11-14 Thread Richard Zhao
It's for migrating to generic clk framework API.

The helper functions  help cases clk_enable/clk_disable is used
in non-atomic context.
For example, Call clk_enable in probe and clk_disable in remove.

Signed-off-by: Richard Zhao richard.z...@linaro.org
---
 include/linux/clk.h |   22 ++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/include/linux/clk.h b/include/linux/clk.h
index 7213b52..b9d46fa 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -107,6 +107,28 @@ static inline void clk_unprepare(struct clk *clk)
 }
 #endif
 
+/* clk_prepare_enable helps cases using clk_enable in non-atomic context. */
+static inline int clk_prepare_enable(struct clk *clk)
+{
+   int ret;
+
+   ret = clk_prepare(clk);
+   if (ret)
+   return ret;
+   ret = clk_enable(clk);
+   if (ret)
+   clk_unprepare(clk);
+
+   return ret;
+}
+
+/* clk_disable_unprepare helps cases using clk_disable in non-atomic context. 
*/
+static inline void clk_disable_unprepare(struct clk *clk)
+{
+   clk_disable(clk);
+   clk_unprepare(clk);
+}
+
 /**
  * clk_get_rate - obtain the current clock rate (in Hz) for a clock source.
  *   This is only valid once the clock source has been enabled.
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V4 02/14] ARM: mxc: time: add clk_prepare/clk_unprepare

2011-11-14 Thread Richard Zhao
It's for migrating to generic clk framework API.

Signed-off-by: Richard Zhao richard.z...@linaro.org
---
 arch/arm/plat-mxc/time.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/plat-mxc/time.c b/arch/arm/plat-mxc/time.c
index 4b0fe28..b4e8b18 100644
--- a/arch/arm/plat-mxc/time.c
+++ b/arch/arm/plat-mxc/time.c
@@ -292,7 +292,7 @@ void __init mxc_timer_init(struct clk *timer_clk, void 
__iomem *base, int irq)
 {
uint32_t tctl_val;
 
-   clk_enable(timer_clk);
+   clk_prepare_enable(timer_clk);
 
timer_base = base;
 
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V4 00/14] add clk_prepare/clk_unprepare to imx drivers

2011-11-14 Thread Richard Zhao
Changes since V3:
 - add more comments

Changes since V2:
 - fix clk_prepare_enable bug

Changes since V1:
 - Add common helper functions clk_prepare_enable/clk_disable_unprepare
 - serial/imx: move clk_disable_unprepare before clk_put


Richard Zhao (14):
  clk: add helper functions clk_prepare_enable and clk_disable_unprepare
  ARM: mxc: time: add clk_prepare/clk_unprepare
  ARM: mxc: ahci: add clk_prepare/clk_unprepare
  ARM: mxc: pwm: add clk_prepare/clk_unprepare
  ARM: mxc: epit: add clk_prepare/clk_unprepare
  ARM: mxc: arch_reset: add clk_prepare/clk_unprepare
  ARM: mxc: audmux-v2: add clk_prepare/clk_unprepare
  ARM: pm-imx5: add clk_prepare/clk_unprepare
  ARM: mx31moboard: add clk_prepare/clk_unprepare
  ARM: mxs: add clk_prepare/clk_unprepare
  serial: imx: add clk_prepare/clk_unprepare
  net: fec: add clk_prepare/clk_unprepare
  i2c: imx: add clk_prepare/clk_unprepare
  mmc: sdhci-esdhc-imx: add clk_prepare/clk_unprepare

 arch/arm/mach-imx/mach-mx31moboard.c  |2 +-
 arch/arm/mach-mx5/pm-imx5.c   |4 ++--
 arch/arm/mach-mxs/system.c|2 +-
 arch/arm/mach-mxs/timer.c |2 +-
 arch/arm/plat-mxc/audmux-v2.c |8 
 arch/arm/plat-mxc/devices/platform-ahci-imx.c |   16 
 arch/arm/plat-mxc/epit.c  |2 +-
 arch/arm/plat-mxc/pwm.c   |4 ++--
 arch/arm/plat-mxc/system.c|2 +-
 arch/arm/plat-mxc/time.c  |2 +-
 drivers/i2c/busses/i2c-imx.c  |4 ++--
 drivers/mmc/host/sdhci-esdhc-imx.c|6 +++---
 drivers/net/ethernet/freescale/fec.c  |   10 +-
 drivers/tty/serial/imx.c  |7 +++
 include/linux/clk.h   |   22 ++
 15 files changed, 57 insertions(+), 36 deletions(-)


Thanks
Richard


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V4 06/14] ARM: mxc: arch_reset: add clk_prepare/clk_unprepare

2011-11-14 Thread Richard Zhao
It's for migrating to generic clk framework API.

Signed-off-by: Richard Zhao richard.z...@linaro.org
---
 arch/arm/plat-mxc/system.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/plat-mxc/system.c b/arch/arm/plat-mxc/system.c
index 9dad8dc..a667adc 100644
--- a/arch/arm/plat-mxc/system.c
+++ b/arch/arm/plat-mxc/system.c
@@ -54,7 +54,7 @@ void arch_reset(char mode, const char *cmd)
 
clk = clk_get_sys(imx2-wdt.0, NULL);
if (!IS_ERR(clk))
-   clk_enable(clk);
+   clk_prepare_enable(clk);
wcr_enable = (1  2);
}
 
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V4 03/14] ARM: mxc: ahci: add clk_prepare/clk_unprepare

2011-11-14 Thread Richard Zhao
It's for migrating to generic clk framework API.

Signed-off-by: Richard Zhao richard.z...@linaro.org
---
 arch/arm/plat-mxc/devices/platform-ahci-imx.c |   16 
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/arch/arm/plat-mxc/devices/platform-ahci-imx.c 
b/arch/arm/plat-mxc/devices/platform-ahci-imx.c
index d8a56ae..ade4a1c 100644
--- a/arch/arm/plat-mxc/devices/platform-ahci-imx.c
+++ b/arch/arm/plat-mxc/devices/platform-ahci-imx.c
@@ -60,9 +60,9 @@ static int imx_sata_init(struct device *dev, void __iomem 
*addr)
dev_err(dev, no sata clock.\n);
return PTR_ERR(sata_clk);
}
-   ret = clk_enable(sata_clk);
+   ret = clk_prepare_enable(sata_clk);
if (ret) {
-   dev_err(dev, can't enable sata clock.\n);
+   dev_err(dev, can't prepare/enable sata clock.\n);
goto put_sata_clk;
}
 
@@ -73,9 +73,9 @@ static int imx_sata_init(struct device *dev, void __iomem 
*addr)
ret = PTR_ERR(sata_ref_clk);
goto release_sata_clk;
}
-   ret = clk_enable(sata_ref_clk);
+   ret = clk_prepare_enable(sata_ref_clk);
if (ret) {
-   dev_err(dev, can't enable sata ref clock.\n);
+   dev_err(dev, can't prepare/enable sata ref clock.\n);
goto put_sata_ref_clk;
}
 
@@ -104,11 +104,11 @@ static int imx_sata_init(struct device *dev, void __iomem 
*addr)
return 0;
 
 release_sata_ref_clk:
-   clk_disable(sata_ref_clk);
+   clk_disable_unprepare(sata_ref_clk);
 put_sata_ref_clk:
clk_put(sata_ref_clk);
 release_sata_clk:
-   clk_disable(sata_clk);
+   clk_disable_unprepare(sata_clk);
 put_sata_clk:
clk_put(sata_clk);
 
@@ -117,10 +117,10 @@ put_sata_clk:
 
 static void imx_sata_exit(struct device *dev)
 {
-   clk_disable(sata_ref_clk);
+   clk_disable_unprepare(sata_ref_clk);
clk_put(sata_ref_clk);
 
-   clk_disable(sata_clk);
+   clk_disable_unprepare(sata_clk);
clk_put(sata_clk);
 
 }
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V4 04/14] ARM: mxc: pwm: add clk_prepare/clk_unprepare

2011-11-14 Thread Richard Zhao
It's for migrating to generic clk framework API.

Signed-off-by: Richard Zhao richard.z...@linaro.org
---
 arch/arm/plat-mxc/pwm.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/plat-mxc/pwm.c b/arch/arm/plat-mxc/pwm.c
index 42d74ea..68c7199b 100644
--- a/arch/arm/plat-mxc/pwm.c
+++ b/arch/arm/plat-mxc/pwm.c
@@ -118,7 +118,7 @@ int pwm_enable(struct pwm_device *pwm)
int rc = 0;
 
if (!pwm-clk_enabled) {
-   rc = clk_enable(pwm-clk);
+   rc = clk_prepare_enable(pwm-clk);
if (!rc)
pwm-clk_enabled = 1;
}
@@ -131,7 +131,7 @@ void pwm_disable(struct pwm_device *pwm)
writel(0, pwm-mmio_base + MX3_PWMCR);
 
if (pwm-clk_enabled) {
-   clk_disable(pwm-clk);
+   clk_disable_unprepare(pwm-clk);
pwm-clk_enabled = 0;
}
 }
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V4 05/14] ARM: mxc: epit: add clk_prepare/clk_unprepare

2011-11-14 Thread Richard Zhao
It's for migrating to generic clk framework API.

Signed-off-by: Richard Zhao richard.z...@linaro.org
---
 arch/arm/plat-mxc/epit.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/plat-mxc/epit.c b/arch/arm/plat-mxc/epit.c
index d3467f8..9129c9e 100644
--- a/arch/arm/plat-mxc/epit.c
+++ b/arch/arm/plat-mxc/epit.c
@@ -203,7 +203,7 @@ static int __init epit_clockevent_init(struct clk 
*timer_clk)
 
 void __init epit_timer_init(struct clk *timer_clk, void __iomem *base, int irq)
 {
-   clk_enable(timer_clk);
+   clk_prepare_enable(timer_clk);
 
timer_base = base;
 
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V4 08/14] ARM: pm-imx5: add clk_prepare/clk_unprepare

2011-11-14 Thread Richard Zhao
It's for migrating to generic clk framework API.

Signed-off-by: Richard Zhao richard.z...@linaro.org
---
 arch/arm/mach-mx5/pm-imx5.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-mx5/pm-imx5.c b/arch/arm/mach-mx5/pm-imx5.c
index 98052fc..2bdc85f 100644
--- a/arch/arm/mach-mx5/pm-imx5.c
+++ b/arch/arm/mach-mx5/pm-imx5.c
@@ -22,7 +22,7 @@ static struct clk *gpc_dvfs_clk;
 
 static int mx5_suspend_prepare(void)
 {
-   return clk_enable(gpc_dvfs_clk);
+   return clk_prepare_enable(gpc_dvfs_clk);
 }
 
 static int mx5_suspend_enter(suspend_state_t state)
@@ -52,7 +52,7 @@ static int mx5_suspend_enter(suspend_state_t state)
 
 static void mx5_suspend_finish(void)
 {
-   clk_disable(gpc_dvfs_clk);
+   clk_disable_unprepare(gpc_dvfs_clk);
 }
 
 static int mx5_pm_valid(suspend_state_t state)
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V4 12/14] net: fec: add clk_prepare/clk_unprepare

2011-11-14 Thread Richard Zhao
It's for migrating to generic clk framework API.

Signed-off-by: Richard Zhao richard.z...@linaro.org
---
 drivers/net/ethernet/freescale/fec.c |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec.c 
b/drivers/net/ethernet/freescale/fec.c
index 1124ce0..e96fa44 100644
--- a/drivers/net/ethernet/freescale/fec.c
+++ b/drivers/net/ethernet/freescale/fec.c
@@ -1588,7 +1588,7 @@ fec_probe(struct platform_device *pdev)
ret = PTR_ERR(fep-clk);
goto failed_clk;
}
-   clk_enable(fep-clk);
+   clk_prepare_enable(fep-clk);
 
ret = fec_enet_init(ndev);
if (ret)
@@ -1611,7 +1611,7 @@ failed_register:
fec_enet_mii_remove(fep);
 failed_mii_init:
 failed_init:
-   clk_disable(fep-clk);
+   clk_disable_unprepare(fep-clk);
clk_put(fep-clk);
 failed_clk:
for (i = 0; i  FEC_IRQ_NUM; i++) {
@@ -1638,7 +1638,7 @@ fec_drv_remove(struct platform_device *pdev)
 
fec_stop(ndev);
fec_enet_mii_remove(fep);
-   clk_disable(fep-clk);
+   clk_disable_unprepare(fep-clk);
clk_put(fep-clk);
iounmap(fep-hwp);
unregister_netdev(ndev);
@@ -1664,7 +1664,7 @@ fec_suspend(struct device *dev)
fec_stop(ndev);
netif_device_detach(ndev);
}
-   clk_disable(fep-clk);
+   clk_disable_unprepare(fep-clk);
 
return 0;
 }
@@ -1675,7 +1675,7 @@ fec_resume(struct device *dev)
struct net_device *ndev = dev_get_drvdata(dev);
struct fec_enet_private *fep = netdev_priv(ndev);
 
-   clk_enable(fep-clk);
+   clk_prepare_enable(fep-clk);
if (netif_running(ndev)) {
fec_restart(ndev, fep-full_duplex);
netif_device_attach(ndev);
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V4 10/14] ARM: mxs: add clk_prepare/clk_unprepare

2011-11-14 Thread Richard Zhao
It's for migrating to generic clk framework API.

Signed-off-by: Richard Zhao richard.z...@linaro.org
---
 arch/arm/mach-mxs/system.c |2 +-
 arch/arm/mach-mxs/timer.c  |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-mxs/system.c b/arch/arm/mach-mxs/system.c
index 20ec3bd..9760a12 100644
--- a/arch/arm/mach-mxs/system.c
+++ b/arch/arm/mach-mxs/system.c
@@ -66,7 +66,7 @@ static int __init mxs_arch_reset_init(void)
 
clk = clk_get_sys(rtc, NULL);
if (!IS_ERR(clk))
-   clk_enable(clk);
+   clk_prepare_enable(clk);
 
return 0;
 }
diff --git a/arch/arm/mach-mxs/timer.c b/arch/arm/mach-mxs/timer.c
index cace0d2..564a632 100644
--- a/arch/arm/mach-mxs/timer.c
+++ b/arch/arm/mach-mxs/timer.c
@@ -245,7 +245,7 @@ static int __init mxs_clocksource_init(struct clk 
*timer_clk)
 
 void __init mxs_timer_init(struct clk *timer_clk, int irq)
 {
-   clk_enable(timer_clk);
+   clk_prepare_enable(timer_clk);
 
/*
 * Initialize timers to a known state
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V4 14/14] mmc: sdhci-esdhc-imx: add clk_prepare/clk_unprepare

2011-11-14 Thread Richard Zhao
It's for migrating to generic clk framework API.

Signed-off-by: Richard Zhao richard.z...@linaro.org
---
 drivers/mmc/host/sdhci-esdhc-imx.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c 
b/drivers/mmc/host/sdhci-esdhc-imx.c
index ae57769..f1ae37e 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -462,7 +462,7 @@ static int __devinit sdhci_esdhc_imx_probe(struct 
platform_device *pdev)
err = PTR_ERR(clk);
goto err_clk_get;
}
-   clk_enable(clk);
+   clk_prepare_enable(clk);
pltfm_host-clk = clk;
 
if (!is_imx25_esdhc(imx_data))
@@ -550,7 +550,7 @@ no_card_detect_irq:
gpio_free(boarddata-wp_gpio);
 no_card_detect_pin:
 no_board_data:
-   clk_disable(pltfm_host-clk);
+   clk_disable_unprepare(pltfm_host-clk);
clk_put(pltfm_host-clk);
 err_clk_get:
kfree(imx_data);
@@ -577,7 +577,7 @@ static int __devexit sdhci_esdhc_imx_remove(struct 
platform_device *pdev)
gpio_free(boarddata-cd_gpio);
}
 
-   clk_disable(pltfm_host-clk);
+   clk_disable_unprepare(pltfm_host-clk);
clk_put(pltfm_host-clk);
kfree(imx_data);
 
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V4 13/14] i2c: imx: add clk_prepare/clk_unprepare

2011-11-14 Thread Richard Zhao
It's for migrating to generic clk framework API.

Signed-off-by: Richard Zhao richard.z...@linaro.org
---
 drivers/i2c/busses/i2c-imx.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 58832e5..8d1ab6f 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -196,7 +196,7 @@ static int i2c_imx_start(struct imx_i2c_struct *i2c_imx)
 
dev_dbg(i2c_imx-adapter.dev, %s\n, __func__);
 
-   clk_enable(i2c_imx-clk);
+   clk_prepare_enable(i2c_imx-clk);
writeb(i2c_imx-ifdr, i2c_imx-base + IMX_I2C_IFDR);
/* Enable I2C controller */
writeb(0, i2c_imx-base + IMX_I2C_I2SR);
@@ -245,7 +245,7 @@ static void i2c_imx_stop(struct imx_i2c_struct *i2c_imx)
 
/* Disable I2C controller */
writeb(0, i2c_imx-base + IMX_I2C_I2CR);
-   clk_disable(i2c_imx-clk);
+   clk_disable_unprepare(i2c_imx-clk);
 }
 
 static void __init i2c_imx_set_clk(struct imx_i2c_struct *i2c_imx,
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V4 11/14] serial: imx: add clk_prepare/clk_unprepare

2011-11-14 Thread Richard Zhao
It's for migrating to generic clk framework API.

Signed-off-by: Richard Zhao richard.z...@linaro.org
---
 drivers/tty/serial/imx.c |7 +++
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 163fc90..8f3709f 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -1390,7 +1390,7 @@ static int serial_imx_probe(struct platform_device *pdev)
ret = PTR_ERR(sport-clk);
goto unmap;
}
-   clk_enable(sport-clk);
+   clk_prepare_enable(sport-clk);
 
sport-port.uartclk = clk_get_rate(sport-clk);
 
@@ -1413,8 +1413,8 @@ deinit:
if (pdata  pdata-exit)
pdata-exit(pdev);
 clkput:
+   clk_disable_unprepare(sport-clk);
clk_put(sport-clk);
-   clk_disable(sport-clk);
 unmap:
iounmap(sport-port.membase);
 free:
@@ -1434,11 +1434,10 @@ static int serial_imx_remove(struct platform_device 
*pdev)
 
if (sport) {
uart_remove_one_port(imx_reg, sport-port);
+   clk_disable_unprepare(sport-clk);
clk_put(sport-clk);
}
 
-   clk_disable(sport-clk);
-
if (pdata  pdata-exit)
pdata-exit(pdev);
 
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V2 01/14] clk: add helper functions clk_prepare_enable and clk_disable_unprepare

2011-11-11 Thread Richard Zhao
On Fri, Nov 11, 2011 at 09:49:50AM +0100, Sascha Hauer wrote:
 On Fri, Nov 11, 2011 at 09:10:16AM +0800, Richard Zhao wrote:
  Signed-off-by: Richard Zhao richard.z...@linaro.org
  ---
   include/linux/clk.h |   19 +++
   1 files changed, 19 insertions(+), 0 deletions(-)
  
  diff --git a/include/linux/clk.h b/include/linux/clk.h
  index 7213b52..63985f7 100644
  --- a/include/linux/clk.h
  +++ b/include/linux/clk.h
  @@ -107,6 +107,25 @@ static inline void clk_unprepare(struct clk *clk)
   }
   #endif
   
  +static inline int clk_prepare_enable(struct clk *clk)
  +{
  +   int ret;
  +
  +   ret = clk_prepare(clk);
  +   if (!ret)
  +   ret = clk_enable(clk);
  +   if (ret)
  +   clk_unprepare(clk);
 
 As Baruch already pointed out this is hard to read. Also it contains a
 bug. When clk_prepare fails clk_unprepare is called afterwards.
 
 Hint: Kernel guys are not afraid of having multiple return statements
 in a function, instead they like it when something is handled early
 without having to read the rest of the function.
{
int ret;

ret = clk_prepare(clk);
if (ret)
return ret;
ret = clk_enable(clk);
if (ret)
clk_unprepare(clk);
return ret;

Like above code? Thanks for review.

Richard
 
 Sascha
 
 -- 
 Pengutronix e.K.   | |
 Industrial Linux Solutions | http://www.pengutronix.de/  |
 Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
 Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
 
 ___
 linux-arm-kernel mailing list
 linux-arm-ker...@lists.infradead.org
 http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
 

--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V3 00/14] add clk_prepare/clk_unprepare to imx drivers

2011-11-11 Thread Richard Zhao
Changes since V2:
 - fix clk_prepare_enable bug

Changes since V1:
 - Add common helper functions clk_prepare_enable/clk_disable_unprepare
 - serial/imx: move clk_disable_unprepare before clk_put

Richard Zhao (14):
  clk: add helper functions clk_prepare_enable and clk_disable_unprepare
  ARM: mxc: time: add clk_prepare/clk_unprepare
  ARM: mxc: ahci: add clk_prepare/clk_unprepare
  ARM: mxc: pwm: add clk_prepare/clk_unprepare
  ARM: mxc: epit: add clk_prepare/clk_unprepare
  ARM: mxc: arch_reset: add clk_prepare/clk_unprepare
  ARM: mxc: audmux-v2: add clk_prepare/clk_unprepare
  ARM: pm-imx5: add clk_prepare/clk_unprepare
  ARM: mx31moboard: add clk_prepare/clk_unprepare
  ARM: mxs: add clk_prepare/clk_unprepare
  serial: imx: add clk_prepare/clk_unprepare
  net: fec: add clk_prepare/clk_unprepare
  i2c: imx: add clk_prepare/clk_unprepare
  mmc: sdhci-esdhc-imx: add clk_prepare/clk_unprepare

 arch/arm/mach-imx/mach-mx31moboard.c  |2 +-
 arch/arm/mach-mx5/pm-imx5.c   |4 ++--
 arch/arm/mach-mxs/system.c|2 +-
 arch/arm/mach-mxs/timer.c |2 +-
 arch/arm/plat-mxc/audmux-v2.c |8 
 arch/arm/plat-mxc/devices/platform-ahci-imx.c |   16 
 arch/arm/plat-mxc/epit.c  |2 +-
 arch/arm/plat-mxc/pwm.c   |4 ++--
 arch/arm/plat-mxc/system.c|2 +-
 arch/arm/plat-mxc/time.c  |2 +-
 drivers/i2c/busses/i2c-imx.c  |4 ++--
 drivers/mmc/host/sdhci-esdhc-imx.c|6 +++---
 drivers/net/ethernet/freescale/fec.c  |   10 +-
 drivers/tty/serial/imx.c  |7 +++
 include/linux/clk.h   |   20 
 15 files changed, 55 insertions(+), 36 deletions(-)

Thanks
Richard

--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V3 02/14] ARM: mxc: time: add clk_prepare/clk_unprepare

2011-11-11 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@linaro.org
---
 arch/arm/plat-mxc/time.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/plat-mxc/time.c b/arch/arm/plat-mxc/time.c
index 4b0fe28..b4e8b18 100644
--- a/arch/arm/plat-mxc/time.c
+++ b/arch/arm/plat-mxc/time.c
@@ -292,7 +292,7 @@ void __init mxc_timer_init(struct clk *timer_clk, void 
__iomem *base, int irq)
 {
uint32_t tctl_val;
 
-   clk_enable(timer_clk);
+   clk_prepare_enable(timer_clk);
 
timer_base = base;
 
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V3 03/14] ARM: mxc: ahci: add clk_prepare/clk_unprepare

2011-11-11 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@linaro.org
---
 arch/arm/plat-mxc/devices/platform-ahci-imx.c |   16 
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/arch/arm/plat-mxc/devices/platform-ahci-imx.c 
b/arch/arm/plat-mxc/devices/platform-ahci-imx.c
index d8a56ae..ade4a1c 100644
--- a/arch/arm/plat-mxc/devices/platform-ahci-imx.c
+++ b/arch/arm/plat-mxc/devices/platform-ahci-imx.c
@@ -60,9 +60,9 @@ static int imx_sata_init(struct device *dev, void __iomem 
*addr)
dev_err(dev, no sata clock.\n);
return PTR_ERR(sata_clk);
}
-   ret = clk_enable(sata_clk);
+   ret = clk_prepare_enable(sata_clk);
if (ret) {
-   dev_err(dev, can't enable sata clock.\n);
+   dev_err(dev, can't prepare/enable sata clock.\n);
goto put_sata_clk;
}
 
@@ -73,9 +73,9 @@ static int imx_sata_init(struct device *dev, void __iomem 
*addr)
ret = PTR_ERR(sata_ref_clk);
goto release_sata_clk;
}
-   ret = clk_enable(sata_ref_clk);
+   ret = clk_prepare_enable(sata_ref_clk);
if (ret) {
-   dev_err(dev, can't enable sata ref clock.\n);
+   dev_err(dev, can't prepare/enable sata ref clock.\n);
goto put_sata_ref_clk;
}
 
@@ -104,11 +104,11 @@ static int imx_sata_init(struct device *dev, void __iomem 
*addr)
return 0;
 
 release_sata_ref_clk:
-   clk_disable(sata_ref_clk);
+   clk_disable_unprepare(sata_ref_clk);
 put_sata_ref_clk:
clk_put(sata_ref_clk);
 release_sata_clk:
-   clk_disable(sata_clk);
+   clk_disable_unprepare(sata_clk);
 put_sata_clk:
clk_put(sata_clk);
 
@@ -117,10 +117,10 @@ put_sata_clk:
 
 static void imx_sata_exit(struct device *dev)
 {
-   clk_disable(sata_ref_clk);
+   clk_disable_unprepare(sata_ref_clk);
clk_put(sata_ref_clk);
 
-   clk_disable(sata_clk);
+   clk_disable_unprepare(sata_clk);
clk_put(sata_clk);
 
 }
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V3 01/14] clk: add helper functions clk_prepare_enable and clk_disable_unprepare

2011-11-11 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@linaro.org
---
 include/linux/clk.h |   20 
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/include/linux/clk.h b/include/linux/clk.h
index 7213b52..a7dc00d 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -107,6 +107,26 @@ static inline void clk_unprepare(struct clk *clk)
 }
 #endif
 
+static inline int clk_prepare_enable(struct clk *clk)
+{
+   int ret;
+
+   ret = clk_prepare(clk);
+   if (ret)
+   return ret;
+   ret = clk_enable(clk);
+   if (ret)
+   clk_unprepare(clk);
+
+   return ret;
+}
+
+static inline void clk_disable_unprepare(struct clk *clk)
+{
+   clk_disable(clk);
+   clk_unprepare(clk);
+}
+
 /**
  * clk_get_rate - obtain the current clock rate (in Hz) for a clock source.
  *   This is only valid once the clock source has been enabled.
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V3 06/14] ARM: mxc: arch_reset: add clk_prepare/clk_unprepare

2011-11-11 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@linaro.org
---
 arch/arm/plat-mxc/system.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/plat-mxc/system.c b/arch/arm/plat-mxc/system.c
index 9dad8dc..a667adc 100644
--- a/arch/arm/plat-mxc/system.c
+++ b/arch/arm/plat-mxc/system.c
@@ -54,7 +54,7 @@ void arch_reset(char mode, const char *cmd)
 
clk = clk_get_sys(imx2-wdt.0, NULL);
if (!IS_ERR(clk))
-   clk_enable(clk);
+   clk_prepare_enable(clk);
wcr_enable = (1  2);
}
 
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V3 07/14] ARM: mxc: audmux-v2: add clk_prepare/clk_unprepare

2011-11-11 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@linaro.org
---
 arch/arm/plat-mxc/audmux-v2.c |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm/plat-mxc/audmux-v2.c b/arch/arm/plat-mxc/audmux-v2.c
index 8cced35..0e51fc3 100644
--- a/arch/arm/plat-mxc/audmux-v2.c
+++ b/arch/arm/plat-mxc/audmux-v2.c
@@ -73,13 +73,13 @@ static ssize_t audmux_read_file(struct file *file, char 
__user *user_buf,
return -ENOMEM;
 
if (audmux_clk)
-   clk_enable(audmux_clk);
+   clk_prepare_enable(audmux_clk);
 
ptcr = readl(audmux_base + MXC_AUDMUX_V2_PTCR(port));
pdcr = readl(audmux_base + MXC_AUDMUX_V2_PDCR(port));
 
if (audmux_clk)
-   clk_disable(audmux_clk);
+   clk_disable_unprepare(audmux_clk);
 
ret = snprintf(buf, PAGE_SIZE, PDCR: %08x\nPTCR: %08x\n,
   pdcr, ptcr);
@@ -172,13 +172,13 @@ int mxc_audmux_v2_configure_port(unsigned int port, 
unsigned int ptcr,
return -ENOSYS;
 
if (audmux_clk)
-   clk_enable(audmux_clk);
+   clk_prepare_enable(audmux_clk);
 
writel(ptcr, audmux_base + MXC_AUDMUX_V2_PTCR(port));
writel(pdcr, audmux_base + MXC_AUDMUX_V2_PDCR(port));
 
if (audmux_clk)
-   clk_disable(audmux_clk);
+   clk_disable_unprepare(audmux_clk);
 
return 0;
 }
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V3 10/14] ARM: mxs: add clk_prepare/clk_unprepare

2011-11-11 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@linaro.org
---
 arch/arm/mach-mxs/system.c |2 +-
 arch/arm/mach-mxs/timer.c  |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-mxs/system.c b/arch/arm/mach-mxs/system.c
index 20ec3bd..9760a12 100644
--- a/arch/arm/mach-mxs/system.c
+++ b/arch/arm/mach-mxs/system.c
@@ -66,7 +66,7 @@ static int __init mxs_arch_reset_init(void)
 
clk = clk_get_sys(rtc, NULL);
if (!IS_ERR(clk))
-   clk_enable(clk);
+   clk_prepare_enable(clk);
 
return 0;
 }
diff --git a/arch/arm/mach-mxs/timer.c b/arch/arm/mach-mxs/timer.c
index cace0d2..564a632 100644
--- a/arch/arm/mach-mxs/timer.c
+++ b/arch/arm/mach-mxs/timer.c
@@ -245,7 +245,7 @@ static int __init mxs_clocksource_init(struct clk 
*timer_clk)
 
 void __init mxs_timer_init(struct clk *timer_clk, int irq)
 {
-   clk_enable(timer_clk);
+   clk_prepare_enable(timer_clk);
 
/*
 * Initialize timers to a known state
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V3 04/14] ARM: mxc: pwm: add clk_prepare/clk_unprepare

2011-11-11 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@linaro.org
---
 arch/arm/plat-mxc/pwm.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/plat-mxc/pwm.c b/arch/arm/plat-mxc/pwm.c
index 42d74ea..68c7199b 100644
--- a/arch/arm/plat-mxc/pwm.c
+++ b/arch/arm/plat-mxc/pwm.c
@@ -118,7 +118,7 @@ int pwm_enable(struct pwm_device *pwm)
int rc = 0;
 
if (!pwm-clk_enabled) {
-   rc = clk_enable(pwm-clk);
+   rc = clk_prepare_enable(pwm-clk);
if (!rc)
pwm-clk_enabled = 1;
}
@@ -131,7 +131,7 @@ void pwm_disable(struct pwm_device *pwm)
writel(0, pwm-mmio_base + MX3_PWMCR);
 
if (pwm-clk_enabled) {
-   clk_disable(pwm-clk);
+   clk_disable_unprepare(pwm-clk);
pwm-clk_enabled = 0;
}
 }
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V3 12/14] net: fec: add clk_prepare/clk_unprepare

2011-11-11 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@linaro.org
---
 drivers/net/ethernet/freescale/fec.c |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec.c 
b/drivers/net/ethernet/freescale/fec.c
index 1124ce0..e96fa44 100644
--- a/drivers/net/ethernet/freescale/fec.c
+++ b/drivers/net/ethernet/freescale/fec.c
@@ -1588,7 +1588,7 @@ fec_probe(struct platform_device *pdev)
ret = PTR_ERR(fep-clk);
goto failed_clk;
}
-   clk_enable(fep-clk);
+   clk_prepare_enable(fep-clk);
 
ret = fec_enet_init(ndev);
if (ret)
@@ -1611,7 +1611,7 @@ failed_register:
fec_enet_mii_remove(fep);
 failed_mii_init:
 failed_init:
-   clk_disable(fep-clk);
+   clk_disable_unprepare(fep-clk);
clk_put(fep-clk);
 failed_clk:
for (i = 0; i  FEC_IRQ_NUM; i++) {
@@ -1638,7 +1638,7 @@ fec_drv_remove(struct platform_device *pdev)
 
fec_stop(ndev);
fec_enet_mii_remove(fep);
-   clk_disable(fep-clk);
+   clk_disable_unprepare(fep-clk);
clk_put(fep-clk);
iounmap(fep-hwp);
unregister_netdev(ndev);
@@ -1664,7 +1664,7 @@ fec_suspend(struct device *dev)
fec_stop(ndev);
netif_device_detach(ndev);
}
-   clk_disable(fep-clk);
+   clk_disable_unprepare(fep-clk);
 
return 0;
 }
@@ -1675,7 +1675,7 @@ fec_resume(struct device *dev)
struct net_device *ndev = dev_get_drvdata(dev);
struct fec_enet_private *fep = netdev_priv(ndev);
 
-   clk_enable(fep-clk);
+   clk_prepare_enable(fep-clk);
if (netif_running(ndev)) {
fec_restart(ndev, fep-full_duplex);
netif_device_attach(ndev);
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V3 05/14] ARM: mxc: epit: add clk_prepare/clk_unprepare

2011-11-11 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@linaro.org
---
 arch/arm/plat-mxc/epit.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/plat-mxc/epit.c b/arch/arm/plat-mxc/epit.c
index d3467f8..9129c9e 100644
--- a/arch/arm/plat-mxc/epit.c
+++ b/arch/arm/plat-mxc/epit.c
@@ -203,7 +203,7 @@ static int __init epit_clockevent_init(struct clk 
*timer_clk)
 
 void __init epit_timer_init(struct clk *timer_clk, void __iomem *base, int irq)
 {
-   clk_enable(timer_clk);
+   clk_prepare_enable(timer_clk);
 
timer_base = base;
 
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V2 01/14] clk: add helper functions clk_prepare_enable and clk_disable_unprepare

2011-11-11 Thread Richard Zhao
On Fri, Nov 11, 2011 at 12:56:44PM +0100, Sascha Hauer wrote:
 On Fri, Nov 11, 2011 at 10:27:27AM +, Russell King - ARM Linux wrote:
  On Fri, Nov 11, 2011 at 10:15:56AM +0100, Sascha Hauer wrote:
   On Fri, Nov 11, 2011 at 05:05:47PM +0800, Richard Zhao wrote:
{
int ret;

ret = clk_prepare(clk);
if (ret)
return ret;
ret = clk_enable(clk);
if (ret)
clk_unprepare(clk);
return ret;
   
   Yes, looks good.
  
  While this looks like a nice easy solution for converting existing
  drivers, I'd suggest thinking about this a little more...
  
  I would suggest some thought is given to the placement of clk_enable()
  and clk_disable() when adding clk_prepare(), especially if your existing
  clk_enable() function can only be called from non-atomic contexts.
  
  Obviously, the transition path needs to be along these lines:
  
  1. add clk_prepare() to drivers
  2. implement clk_prepare() and make clk_enable() callable from non-atomic
 contexts
  3. move clk_enable() in drivers to places it can be called from non-atomic
 contexts to achieve greater power savings (maybe via the runtime pm)
Hi Russell,

There are use cases calling clk_enable in atomic context, but there are even 
more
cases caling in non-atomic context. The patch meant to help the latter cases.
Tuning of driver power savings can be left to other contributers. Is it ok
if I add below comments:
/* clk_prepare_enable helps cases using clk_enable in non-atomic context. */
static inline int clk_prepare_enable(struct clk *clk)
...
/* clk_disable_unprepare helps cases using clk_disable in non-atomic context. */
static inline void clk_disable_unprepare(struct clk *clk)
...

Thanks
Richard
  
  and where a driver is shared between different sub-architectures which
  have non-atomic clk_enable()s, (3) can only happen when all those sub-
  architectures have been updated to step (2).
 
 The drivers changed here all do clk_prepare/enable in their probe
 function. I agree that this clk_prepare_enable patch gives kind of
 wrong motivation to just use this function and to forget about
 potential power savings with proper integration of clk_prepare/enable.
 I think though that it will take a long time until all drivers really
 do this no matter if we have such a helper or not. I think that in the
 meantime it's better to have a little helper than to clobber the probe
 code with additional error handling.
 
 Sascha
 
 -- 
 Pengutronix e.K.   | |
 Industrial Linux Solutions | http://www.pengutronix.de/  |
 Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
 Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
 
 ___
 linux-arm-kernel mailing list
 linux-arm-ker...@lists.infradead.org
 http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
 

--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 01/14] clk: add helper functions clk_prepare_enable and clk_disable_unprepare

2011-11-10 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@linaro.org
---
 include/linux/clk.h |   19 +++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/include/linux/clk.h b/include/linux/clk.h
index 7213b52..63985f7 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -107,6 +107,25 @@ static inline void clk_unprepare(struct clk *clk)
 }
 #endif
 
+static inline int clk_prepare_enable(struct clk *clk)
+{
+   int ret;
+
+   ret = clk_prepare(clk);
+   if (!ret)
+   ret = clk_enable(clk);
+   if (ret)
+   clk_unprepare(clk);
+
+   return ret;
+}
+
+static inline void clk_disable_unprepare(struct clk *clk)
+{
+   clk_disable(clk);
+   clk_unprepare(clk);
+}
+
 /**
  * clk_get_rate - obtain the current clock rate (in Hz) for a clock source.
  *   This is only valid once the clock source has been enabled.
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 02/14] ARM: mxc: time: add clk_prepare/clk_unprepare

2011-11-10 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@linaro.org
---
 arch/arm/plat-mxc/time.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/plat-mxc/time.c b/arch/arm/plat-mxc/time.c
index 4b0fe28..b4e8b18 100644
--- a/arch/arm/plat-mxc/time.c
+++ b/arch/arm/plat-mxc/time.c
@@ -292,7 +292,7 @@ void __init mxc_timer_init(struct clk *timer_clk, void 
__iomem *base, int irq)
 {
uint32_t tctl_val;
 
-   clk_enable(timer_clk);
+   clk_prepare_enable(timer_clk);
 
timer_base = base;
 
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 05/14] ARM: mxc: epit: add clk_prepare/clk_unprepare

2011-11-10 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@linaro.org
---
 arch/arm/plat-mxc/epit.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/plat-mxc/epit.c b/arch/arm/plat-mxc/epit.c
index d3467f8..9129c9e 100644
--- a/arch/arm/plat-mxc/epit.c
+++ b/arch/arm/plat-mxc/epit.c
@@ -203,7 +203,7 @@ static int __init epit_clockevent_init(struct clk 
*timer_clk)
 
 void __init epit_timer_init(struct clk *timer_clk, void __iomem *base, int irq)
 {
-   clk_enable(timer_clk);
+   clk_prepare_enable(timer_clk);
 
timer_base = base;
 
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 06/14] ARM: mxc: arch_reset: add clk_prepare/clk_unprepare

2011-11-10 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@linaro.org
---
 arch/arm/plat-mxc/system.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/plat-mxc/system.c b/arch/arm/plat-mxc/system.c
index 9dad8dc..a667adc 100644
--- a/arch/arm/plat-mxc/system.c
+++ b/arch/arm/plat-mxc/system.c
@@ -54,7 +54,7 @@ void arch_reset(char mode, const char *cmd)
 
clk = clk_get_sys(imx2-wdt.0, NULL);
if (!IS_ERR(clk))
-   clk_enable(clk);
+   clk_prepare_enable(clk);
wcr_enable = (1  2);
}
 
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 10/14] ARM: mxs: add clk_prepare/clk_unprepare

2011-11-10 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@linaro.org
---
 arch/arm/mach-mxs/system.c |2 +-
 arch/arm/mach-mxs/timer.c  |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-mxs/system.c b/arch/arm/mach-mxs/system.c
index 20ec3bd..9760a12 100644
--- a/arch/arm/mach-mxs/system.c
+++ b/arch/arm/mach-mxs/system.c
@@ -66,7 +66,7 @@ static int __init mxs_arch_reset_init(void)
 
clk = clk_get_sys(rtc, NULL);
if (!IS_ERR(clk))
-   clk_enable(clk);
+   clk_prepare_enable(clk);
 
return 0;
 }
diff --git a/arch/arm/mach-mxs/timer.c b/arch/arm/mach-mxs/timer.c
index cace0d2..564a632 100644
--- a/arch/arm/mach-mxs/timer.c
+++ b/arch/arm/mach-mxs/timer.c
@@ -245,7 +245,7 @@ static int __init mxs_clocksource_init(struct clk 
*timer_clk)
 
 void __init mxs_timer_init(struct clk *timer_clk, int irq)
 {
-   clk_enable(timer_clk);
+   clk_prepare_enable(timer_clk);
 
/*
 * Initialize timers to a known state
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 11/14] serial: imx: add clk_prepare/clk_unprepare

2011-11-10 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@linaro.org
---
 drivers/tty/serial/imx.c |7 +++
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 163fc90..8f3709f 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -1390,7 +1390,7 @@ static int serial_imx_probe(struct platform_device *pdev)
ret = PTR_ERR(sport-clk);
goto unmap;
}
-   clk_enable(sport-clk);
+   clk_prepare_enable(sport-clk);
 
sport-port.uartclk = clk_get_rate(sport-clk);
 
@@ -1413,8 +1413,8 @@ deinit:
if (pdata  pdata-exit)
pdata-exit(pdev);
 clkput:
+   clk_disable_unprepare(sport-clk);
clk_put(sport-clk);
-   clk_disable(sport-clk);
 unmap:
iounmap(sport-port.membase);
 free:
@@ -1434,11 +1434,10 @@ static int serial_imx_remove(struct platform_device 
*pdev)
 
if (sport) {
uart_remove_one_port(imx_reg, sport-port);
+   clk_disable_unprepare(sport-clk);
clk_put(sport-clk);
}
 
-   clk_disable(sport-clk);
-
if (pdata  pdata-exit)
pdata-exit(pdev);
 
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 07/14] ARM: mxc: audmux-v2: add clk_prepare/clk_unprepare

2011-11-10 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@linaro.org
---
 arch/arm/plat-mxc/audmux-v2.c |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm/plat-mxc/audmux-v2.c b/arch/arm/plat-mxc/audmux-v2.c
index 8cced35..0e51fc3 100644
--- a/arch/arm/plat-mxc/audmux-v2.c
+++ b/arch/arm/plat-mxc/audmux-v2.c
@@ -73,13 +73,13 @@ static ssize_t audmux_read_file(struct file *file, char 
__user *user_buf,
return -ENOMEM;
 
if (audmux_clk)
-   clk_enable(audmux_clk);
+   clk_prepare_enable(audmux_clk);
 
ptcr = readl(audmux_base + MXC_AUDMUX_V2_PTCR(port));
pdcr = readl(audmux_base + MXC_AUDMUX_V2_PDCR(port));
 
if (audmux_clk)
-   clk_disable(audmux_clk);
+   clk_disable_unprepare(audmux_clk);
 
ret = snprintf(buf, PAGE_SIZE, PDCR: %08x\nPTCR: %08x\n,
   pdcr, ptcr);
@@ -172,13 +172,13 @@ int mxc_audmux_v2_configure_port(unsigned int port, 
unsigned int ptcr,
return -ENOSYS;
 
if (audmux_clk)
-   clk_enable(audmux_clk);
+   clk_prepare_enable(audmux_clk);
 
writel(ptcr, audmux_base + MXC_AUDMUX_V2_PTCR(port));
writel(pdcr, audmux_base + MXC_AUDMUX_V2_PDCR(port));
 
if (audmux_clk)
-   clk_disable(audmux_clk);
+   clk_disable_unprepare(audmux_clk);
 
return 0;
 }
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 00/14] add clk_prepare/clk_unprepare to imx drivers

2011-11-10 Thread Richard Zhao
Changes from V1:
 - Add common helper functions clk_prepare_enable/clk_disable_unprepare
 - serial/imx: move clk_disable_unprepare before clk_put

Thanks
Richard

--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 03/14] ARM: mxc: ahci: add clk_prepare/clk_unprepare

2011-11-10 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@linaro.org
---
 arch/arm/plat-mxc/devices/platform-ahci-imx.c |   16 
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/arch/arm/plat-mxc/devices/platform-ahci-imx.c 
b/arch/arm/plat-mxc/devices/platform-ahci-imx.c
index d8a56ae..ade4a1c 100644
--- a/arch/arm/plat-mxc/devices/platform-ahci-imx.c
+++ b/arch/arm/plat-mxc/devices/platform-ahci-imx.c
@@ -60,9 +60,9 @@ static int imx_sata_init(struct device *dev, void __iomem 
*addr)
dev_err(dev, no sata clock.\n);
return PTR_ERR(sata_clk);
}
-   ret = clk_enable(sata_clk);
+   ret = clk_prepare_enable(sata_clk);
if (ret) {
-   dev_err(dev, can't enable sata clock.\n);
+   dev_err(dev, can't prepare/enable sata clock.\n);
goto put_sata_clk;
}
 
@@ -73,9 +73,9 @@ static int imx_sata_init(struct device *dev, void __iomem 
*addr)
ret = PTR_ERR(sata_ref_clk);
goto release_sata_clk;
}
-   ret = clk_enable(sata_ref_clk);
+   ret = clk_prepare_enable(sata_ref_clk);
if (ret) {
-   dev_err(dev, can't enable sata ref clock.\n);
+   dev_err(dev, can't prepare/enable sata ref clock.\n);
goto put_sata_ref_clk;
}
 
@@ -104,11 +104,11 @@ static int imx_sata_init(struct device *dev, void __iomem 
*addr)
return 0;
 
 release_sata_ref_clk:
-   clk_disable(sata_ref_clk);
+   clk_disable_unprepare(sata_ref_clk);
 put_sata_ref_clk:
clk_put(sata_ref_clk);
 release_sata_clk:
-   clk_disable(sata_clk);
+   clk_disable_unprepare(sata_clk);
 put_sata_clk:
clk_put(sata_clk);
 
@@ -117,10 +117,10 @@ put_sata_clk:
 
 static void imx_sata_exit(struct device *dev)
 {
-   clk_disable(sata_ref_clk);
+   clk_disable_unprepare(sata_ref_clk);
clk_put(sata_ref_clk);
 
-   clk_disable(sata_clk);
+   clk_disable_unprepare(sata_clk);
clk_put(sata_clk);
 
 }
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 09/14] ARM: mx31moboard: add clk_prepare/clk_unprepare

2011-11-10 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@linaro.org
---
 arch/arm/mach-imx/mach-mx31moboard.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-imx/mach-mx31moboard.c 
b/arch/arm/mach-imx/mach-mx31moboard.c
index 07034f4..d1a9337 100644
--- a/arch/arm/mach-imx/mach-mx31moboard.c
+++ b/arch/arm/mach-imx/mach-mx31moboard.c
@@ -505,7 +505,7 @@ static void mx31moboard_poweroff(void)
struct clk *clk = clk_get_sys(imx2-wdt.0, NULL);
 
if (!IS_ERR(clk))
-   clk_enable(clk);
+   clk_prepare_enable(clk);
 
mxc_iomux_mode(MX31_PIN_WATCHDOG_RST__WATCHDOG_RST);
 
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 04/14] ARM: mxc: pwm: add clk_prepare/clk_unprepare

2011-11-10 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@linaro.org
---
 arch/arm/plat-mxc/pwm.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/plat-mxc/pwm.c b/arch/arm/plat-mxc/pwm.c
index 42d74ea..68c7199b 100644
--- a/arch/arm/plat-mxc/pwm.c
+++ b/arch/arm/plat-mxc/pwm.c
@@ -118,7 +118,7 @@ int pwm_enable(struct pwm_device *pwm)
int rc = 0;
 
if (!pwm-clk_enabled) {
-   rc = clk_enable(pwm-clk);
+   rc = clk_prepare_enable(pwm-clk);
if (!rc)
pwm-clk_enabled = 1;
}
@@ -131,7 +131,7 @@ void pwm_disable(struct pwm_device *pwm)
writel(0, pwm-mmio_base + MX3_PWMCR);
 
if (pwm-clk_enabled) {
-   clk_disable(pwm-clk);
+   clk_disable_unprepare(pwm-clk);
pwm-clk_enabled = 0;
}
 }
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 08/14] ARM: pm-imx5: add clk_prepare/clk_unprepare

2011-11-10 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@linaro.org
---
 arch/arm/mach-mx5/pm-imx5.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-mx5/pm-imx5.c b/arch/arm/mach-mx5/pm-imx5.c
index 98052fc..2bdc85f 100644
--- a/arch/arm/mach-mx5/pm-imx5.c
+++ b/arch/arm/mach-mx5/pm-imx5.c
@@ -22,7 +22,7 @@ static struct clk *gpc_dvfs_clk;
 
 static int mx5_suspend_prepare(void)
 {
-   return clk_enable(gpc_dvfs_clk);
+   return clk_prepare_enable(gpc_dvfs_clk);
 }
 
 static int mx5_suspend_enter(suspend_state_t state)
@@ -52,7 +52,7 @@ static int mx5_suspend_enter(suspend_state_t state)
 
 static void mx5_suspend_finish(void)
 {
-   clk_disable(gpc_dvfs_clk);
+   clk_disable_unprepare(gpc_dvfs_clk);
 }
 
 static int mx5_pm_valid(suspend_state_t state)
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 13/14] i2c: imx: add clk_prepare/clk_unprepare

2011-11-10 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@linaro.org
---
 drivers/i2c/busses/i2c-imx.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 58832e5..8d1ab6f 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -196,7 +196,7 @@ static int i2c_imx_start(struct imx_i2c_struct *i2c_imx)
 
dev_dbg(i2c_imx-adapter.dev, %s\n, __func__);
 
-   clk_enable(i2c_imx-clk);
+   clk_prepare_enable(i2c_imx-clk);
writeb(i2c_imx-ifdr, i2c_imx-base + IMX_I2C_IFDR);
/* Enable I2C controller */
writeb(0, i2c_imx-base + IMX_I2C_I2SR);
@@ -245,7 +245,7 @@ static void i2c_imx_stop(struct imx_i2c_struct *i2c_imx)
 
/* Disable I2C controller */
writeb(0, i2c_imx-base + IMX_I2C_I2CR);
-   clk_disable(i2c_imx-clk);
+   clk_disable_unprepare(i2c_imx-clk);
 }
 
 static void __init i2c_imx_set_clk(struct imx_i2c_struct *i2c_imx,
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 14/14] mmc: sdhci-esdhc-imx: add clk_prepare/clk_unprepare

2011-11-10 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@linaro.org
---
 drivers/mmc/host/sdhci-esdhc-imx.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c 
b/drivers/mmc/host/sdhci-esdhc-imx.c
index ae57769..f1ae37e 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -462,7 +462,7 @@ static int __devinit sdhci_esdhc_imx_probe(struct 
platform_device *pdev)
err = PTR_ERR(clk);
goto err_clk_get;
}
-   clk_enable(clk);
+   clk_prepare_enable(clk);
pltfm_host-clk = clk;
 
if (!is_imx25_esdhc(imx_data))
@@ -550,7 +550,7 @@ no_card_detect_irq:
gpio_free(boarddata-wp_gpio);
 no_card_detect_pin:
 no_board_data:
-   clk_disable(pltfm_host-clk);
+   clk_disable_unprepare(pltfm_host-clk);
clk_put(pltfm_host-clk);
 err_clk_get:
kfree(imx_data);
@@ -577,7 +577,7 @@ static int __devexit sdhci_esdhc_imx_remove(struct 
platform_device *pdev)
gpio_free(boarddata-cd_gpio);
}
 
-   clk_disable(pltfm_host-clk);
+   clk_disable_unprepare(pltfm_host-clk);
clk_put(pltfm_host-clk);
kfree(imx_data);
 
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/1] i2c: imx: convert clk_prepare/clk_unprepare

2011-11-09 Thread Richard Zhao
Signed-off-by: Richard Zhao richard.z...@linaro.org
---
 drivers/i2c/busses/i2c-imx.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 58832e5..aad623b 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -196,6 +196,7 @@ static int i2c_imx_start(struct imx_i2c_struct *i2c_imx)
 
dev_dbg(i2c_imx-adapter.dev, %s\n, __func__);
 
+   clk_prepare(i2c_imx-clk);
clk_enable(i2c_imx-clk);
writeb(i2c_imx-ifdr, i2c_imx-base + IMX_I2C_IFDR);
/* Enable I2C controller */
@@ -246,6 +247,7 @@ static void i2c_imx_stop(struct imx_i2c_struct *i2c_imx)
/* Disable I2C controller */
writeb(0, i2c_imx-base + IMX_I2C_I2CR);
clk_disable(i2c_imx-clk);
+   clk_unprepare(i2c_imx-clk);
 }
 
 static void __init i2c_imx_set_clk(struct imx_i2c_struct *i2c_imx,
-- 
1.7.5.4


--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V1 1/3] i2c: imx: check busy bit when START/STOP

2009-10-30 Thread Richard Zhao
On Fri, Oct 30, 2009 at 8:40 AM, Ben Dooks ben-li...@fluff.org wrote:
 Does anyone have any comments on these, or shall I look at merging
 them as fixes?

 --
 Ben (b...@fluff.org, http://www.fluff.org/)

  'a smiley only costs 4 bytes'


Thanks, Ben! I've test these patch on imx31 pdk and imx51 pdk.

  Richard
--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V1 1/3] i2c: imx: check busy bit when START/STOP

2009-10-20 Thread Richard Zhao
On Sat, Oct 17, 2009 at 5:46 PM, Richard Zhao linux...@gmail.com wrote:
 The controller can't do anything else before it actually generates START/STOP.
 So we check busy bit to make sure START/STOP is successfully finished.

 If we don't check busy bit, START/STOP may fail on some fast CPUs.

 Signed-off-by: Richard Zhao linux...@gmail.com

 diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
 index 4afba3e..6055e92 100644
 --- a/drivers/i2c/busses/i2c-imx.c
 +++ b/drivers/i2c/busses/i2c-imx.c
 @@ -120,19 +120,25 @@ struct imx_i2c_struct {
        wait_queue_head_t       queue;
        unsigned long           i2csr;
        unsigned int            disable_delay;
 +       int                     stopped;
  };

  /** Functions for IMX I2C adapter driver 
 ***
  ***/

 -static int i2c_imx_bus_busy(struct imx_i2c_struct *i2c_imx)
 +static int i2c_imx_bus_busy(struct imx_i2c_struct *i2c_imx, int for_busy)
  {
        unsigned long orig_jiffies = jiffies;
 +       unsigned int temp;

        dev_dbg(i2c_imx-adapter.dev, %s\n, __func__);

 -       /* wait for bus not busy */
 -       while (readb(i2c_imx-base + IMX_I2C_I2SR)  I2SR_IBB) {
 +       while (1) {
 +               temp = readb(i2c_imx-base + IMX_I2C_I2SR);
 +               if (for_busy  (temp  I2SR_IBB))
 +                       break;
 +               if (!for_busy  !(temp  I2SR_IBB))
 +                       break;
                if (signal_pending(current)) {
                        dev_dbg(i2c_imx-adapter.dev,
                                %s I2C Interrupted\n, __func__);
 @@ -179,39 +185,55 @@ static int i2c_imx_acked(struct imx_i2c_struct *i2c_imx)
        return 0;
  }

 -static void i2c_imx_start(struct imx_i2c_struct *i2c_imx)
 +static int i2c_imx_start(struct imx_i2c_struct *i2c_imx)
  {
        unsigned int temp = 0;
 +       int result;

        dev_dbg(i2c_imx-adapter.dev, %s\n, __func__);

        /* Enable I2C controller */
 +       writeb(0, i2c_imx-base + IMX_I2C_I2SR);
        writeb(I2CR_IEN, i2c_imx-base + IMX_I2C_I2CR);
 +
 +       /* Wait controller to be stable */
 +       udelay(50);
 +
        /* Start I2C transaction */
        temp = readb(i2c_imx-base + IMX_I2C_I2CR);
        temp |= I2CR_MSTA;
        writeb(temp, i2c_imx-base + IMX_I2C_I2CR);
 +       result = i2c_imx_bus_busy(i2c_imx, 1);
 +       if (result)
 +               return result;
 +       i2c_imx-stopped = 0;
 +
        temp |= I2CR_IIEN | I2CR_MTX | I2CR_TXAK;
        writeb(temp, i2c_imx-base + IMX_I2C_I2CR);
 +       return result;
  }

  static void i2c_imx_stop(struct imx_i2c_struct *i2c_imx)
  {
        unsigned int temp = 0;

 -       /* Stop I2C transaction */
 -       dev_dbg(i2c_imx-adapter.dev, %s\n, __func__);
 -       temp = readb(i2c_imx-base + IMX_I2C_I2CR);
 -       temp = ~I2CR_MSTA;
 -       writeb(temp, i2c_imx-base + IMX_I2C_I2CR);
 -       /* setup chip registers to defaults */
 -       writeb(I2CR_IEN, i2c_imx-base + IMX_I2C_I2CR);
 -       writeb(0, i2c_imx-base + IMX_I2C_I2SR);
 +       if (!i2c_imx-stopped) {
 +               /* Stop I2C transaction */
 +               dev_dbg(i2c_imx-adapter.dev, %s\n, __func__);
 +               temp = readb(i2c_imx-base + IMX_I2C_I2CR);
 +               temp = ~(I2CR_MSTA | I2CR_MTX);
 +               writeb(temp, i2c_imx-base + IMX_I2C_I2CR);
 +               i2c_imx-stopped = 1;
 +       }
        /*
         * This delay caused by an i.MXL hardware bug.
         * If no (or too short) delay, no STOP bit will be generated.
         */
        udelay(i2c_imx-disable_delay);
 +
 +       if (!i2c_imx-stopped)
 +               i2c_imx_bus_busy(i2c_imx, 0);
 +
        /* Disable I2C controller */
        writeb(0, i2c_imx-base + IMX_I2C_I2CR);
  }
 @@ -341,11 +363,15 @@ static int i2c_imx_read(struct imx_i2c_struct *i2c_imx, 
 struct i2c_msg *msgs)
                if (result)
                        return result;
                if (i == (msgs-len - 1)) {
 +                       /* It must generate STOP before read I2DR to prevent
 +                          controller from generating another clock cycle */
                        dev_dbg(i2c_imx-adapter.dev,
                                %s clear MSTA\n, __func__);
                        temp = readb(i2c_imx-base + IMX_I2C_I2CR);
 -                       temp = ~I2CR_MSTA;
 +                       temp = ~(I2CR_MSTA | I2CR_MTX);
                        writeb(temp, i2c_imx-base + IMX_I2C_I2CR);
 +                       i2c_imx_bus_busy(i2c_imx, 0);
 +                       i2c_imx-stopped = 1;
                } else if (i == (msgs-len - 2)) {
                        dev_dbg(i2c_imx-adapter.dev,
                                %s set TXAK\n, __func__);
 @@ -370,14 +396,11 @@ static int i2c_imx_xfer(struct i2c_adapter *adapter,

        dev_dbg(i2c_imx-adapter.dev, %s\n, __func__);

 -       /* Check if i2c bus

[PATCH V1 1/3] i2c: imx: check busy bit when START/STOP

2009-10-17 Thread Richard Zhao
The controller can't do anything else before it actually generates START/STOP.
So we check busy bit to make sure START/STOP is successfully finished.

If we don't check busy bit, START/STOP may fail on some fast CPUs.

Signed-off-by: Richard Zhao linux...@gmail.com

diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 4afba3e..6055e92 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -120,19 +120,25 @@ struct imx_i2c_struct {
wait_queue_head_t   queue;
unsigned long   i2csr;
unsigned intdisable_delay;
+   int stopped;
 };
 
 /** Functions for IMX I2C adapter driver 
***
 
***/
 
-static int i2c_imx_bus_busy(struct imx_i2c_struct *i2c_imx)
+static int i2c_imx_bus_busy(struct imx_i2c_struct *i2c_imx, int for_busy)
 {
unsigned long orig_jiffies = jiffies;
+   unsigned int temp;
 
dev_dbg(i2c_imx-adapter.dev, %s\n, __func__);
 
-   /* wait for bus not busy */
-   while (readb(i2c_imx-base + IMX_I2C_I2SR)  I2SR_IBB) {
+   while (1) {
+   temp = readb(i2c_imx-base + IMX_I2C_I2SR);
+   if (for_busy  (temp  I2SR_IBB))
+   break;
+   if (!for_busy  !(temp  I2SR_IBB))
+   break;
if (signal_pending(current)) {
dev_dbg(i2c_imx-adapter.dev,
%s I2C Interrupted\n, __func__);
@@ -179,39 +185,55 @@ static int i2c_imx_acked(struct imx_i2c_struct *i2c_imx)
return 0;
 }
 
-static void i2c_imx_start(struct imx_i2c_struct *i2c_imx)
+static int i2c_imx_start(struct imx_i2c_struct *i2c_imx)
 {
unsigned int temp = 0;
+   int result;
 
dev_dbg(i2c_imx-adapter.dev, %s\n, __func__);
 
/* Enable I2C controller */
+   writeb(0, i2c_imx-base + IMX_I2C_I2SR);
writeb(I2CR_IEN, i2c_imx-base + IMX_I2C_I2CR);
+
+   /* Wait controller to be stable */
+   udelay(50);
+
/* Start I2C transaction */
temp = readb(i2c_imx-base + IMX_I2C_I2CR);
temp |= I2CR_MSTA;
writeb(temp, i2c_imx-base + IMX_I2C_I2CR);
+   result = i2c_imx_bus_busy(i2c_imx, 1);
+   if (result)
+   return result;
+   i2c_imx-stopped = 0;
+
temp |= I2CR_IIEN | I2CR_MTX | I2CR_TXAK;
writeb(temp, i2c_imx-base + IMX_I2C_I2CR);
+   return result;
 }
 
 static void i2c_imx_stop(struct imx_i2c_struct *i2c_imx)
 {
unsigned int temp = 0;
 
-   /* Stop I2C transaction */
-   dev_dbg(i2c_imx-adapter.dev, %s\n, __func__);
-   temp = readb(i2c_imx-base + IMX_I2C_I2CR);
-   temp = ~I2CR_MSTA;
-   writeb(temp, i2c_imx-base + IMX_I2C_I2CR);
-   /* setup chip registers to defaults */
-   writeb(I2CR_IEN, i2c_imx-base + IMX_I2C_I2CR);
-   writeb(0, i2c_imx-base + IMX_I2C_I2SR);
+   if (!i2c_imx-stopped) {
+   /* Stop I2C transaction */
+   dev_dbg(i2c_imx-adapter.dev, %s\n, __func__);
+   temp = readb(i2c_imx-base + IMX_I2C_I2CR);
+   temp = ~(I2CR_MSTA | I2CR_MTX);
+   writeb(temp, i2c_imx-base + IMX_I2C_I2CR);
+   i2c_imx-stopped = 1;
+   }
/*
 * This delay caused by an i.MXL hardware bug.
 * If no (or too short) delay, no STOP bit will be generated.
 */
udelay(i2c_imx-disable_delay);
+
+   if (!i2c_imx-stopped)
+   i2c_imx_bus_busy(i2c_imx, 0);
+
/* Disable I2C controller */
writeb(0, i2c_imx-base + IMX_I2C_I2CR);
 }
@@ -341,11 +363,15 @@ static int i2c_imx_read(struct imx_i2c_struct *i2c_imx, 
struct i2c_msg *msgs)
if (result)
return result;
if (i == (msgs-len - 1)) {
+   /* It must generate STOP before read I2DR to prevent
+  controller from generating another clock cycle */
dev_dbg(i2c_imx-adapter.dev,
%s clear MSTA\n, __func__);
temp = readb(i2c_imx-base + IMX_I2C_I2CR);
-   temp = ~I2CR_MSTA;
+   temp = ~(I2CR_MSTA | I2CR_MTX);
writeb(temp, i2c_imx-base + IMX_I2C_I2CR);
+   i2c_imx_bus_busy(i2c_imx, 0);
+   i2c_imx-stopped = 1;
} else if (i == (msgs-len - 2)) {
dev_dbg(i2c_imx-adapter.dev,
%s set TXAK\n, __func__);
@@ -370,14 +396,11 @@ static int i2c_imx_xfer(struct i2c_adapter *adapter,
 
dev_dbg(i2c_imx-adapter.dev, %s\n, __func__);
 
-   /* Check if i2c bus is not busy */
-   result = i2c_imx_bus_busy(i2c_imx);
+   /* Start I2C transfer */
+   result = i2c_imx_start(i2c_imx

[PATCH V1 2/3] i2c: imx: only imx1 needs disable delay

2009-10-17 Thread Richard Zhao
check cpu_is_mx1() when disable delay.

Signed-off-by: Richard Zhao linux...@gmail.com

diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 6055e92..671d37c 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -225,11 +225,13 @@ static void i2c_imx_stop(struct imx_i2c_struct *i2c_imx)
writeb(temp, i2c_imx-base + IMX_I2C_I2CR);
i2c_imx-stopped = 1;
}
-   /*
-* This delay caused by an i.MXL hardware bug.
-* If no (or too short) delay, no STOP bit will be generated.
-*/
-   udelay(i2c_imx-disable_delay);
+   if (cpu_is_mx1()) {
+   /*
+* This delay caused by an i.MXL hardware bug.
+* If no (or too short) delay, no STOP bit will be generated.
+*/
+   udelay(i2c_imx-disable_delay);
+   }
 
if (!i2c_imx-stopped)
i2c_imx_bus_busy(i2c_imx, 0);
-- 
1.6.0.4

--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/4] i2c: imx: check busy bit when START/STOP

2009-10-04 Thread Richard Zhao
On Fri, Oct 2, 2009 at 10:11 PM, Wolfram Sang w.s...@pengutronix.de wrote:
 On Fri, Oct 02, 2009 at 04:17:09PM +0800, Richard Zhao wrote:
 On Fri, Oct 2, 2009 at 3:26 PM, Sascha Hauer s.ha...@pengutronix.de wrote:
  On Fri, Oct 02, 2009 at 08:57:04AM +0800, Richard Zhao wrote:
  On Fri, Oct 2, 2009 at 12:37 AM, Wolfram Sang w.s...@pengutronix.de 
  wrote:
Ah, so 'make the driver work on i.MX51' is a good statement which 
should
be part of the commit message.
   Well, maybe I can mention it.
   But I think the good point is to present what you modified, not the 
   side effect.
  
   It is not the side effect but the intention :) As no code is changed 
   without a
   need, the reason really should be in the patch description.
  No, it's not intention. I'm just trying to make the controller work in
  a right way. Without this patch, maybe some other fast cpus have
  problem too. I just tested mx31 and mx51. I will add Without this
  patch, i2c on some fast SoCs (for example imx51) will not work. Is it
  ok for you?
 
  Please remember that we do not have i.MX51 support in mainline, so this
  is irrelevant atm.
 So I don't need to meantion mx51? Without this patch, i2c on some
 fast SoCs will not work is all right?

 Sounds good to me!

  At the moment we have a driver which is not multi master capable.
  Looking at the datasheet the change you do seems not enough to change
  this. So we should take a patch which changes something from which you
  think it might be needed? And you don't even have the details at hand?
 
  No.
 Ok, It seems I have no reason to keep the busy wait before START.
 Wolfram, do you agree to remove the busy wait?

 If somebody really needs multi-master and is able to test it, then it can be
 reimplemented (but as said, this needs a lot more changes). Have to have a
 closer look though, if it may detect a stalled bus.

 I saw you submmited the original driver.

 I helped in getting it accepted, but the commit is mainly from Darius.

 Regards,

   Wolfram

 --
 Pengutronix e.K.                           | Wolfram Sang                |
 Industrial Linux Solutions                 | http://www.pengutronix.de/  |

 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.9 (GNU/Linux)

 iEYEARECAAYFAkrGCfoACgkQD27XaX1/VRtdtQCfQY/HExUvAyQbilCV+F83UZZ4
 /ZQAnicn78e46mlqE3Z/9xXFMW8B2QCA
 =qYV9
 -END PGP SIGNATURE-



Let me sumerize the comments:
1. Sascha, Wolfram: tell why add IBB check in commit message. Add
something like Without this patch, i2c on some fast SoCs will not
work. Agree
2. Sascha: Remove IBB check before START.  Agree.
3. Andrew: Optimize the busy wait loop. Agree.

Thanks
Richard
--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/4] i2c: imx: add macros and printk to make debug easy

2009-10-04 Thread Richard Zhao
On Thu, Oct 1, 2009 at 5:30 PM, Richard Zhao linux...@gmail.com wrote:
 On Thu, Oct 1, 2009 at 4:26 PM, Sascha Hauer s.ha...@pengutronix.de wrote:
 On Thu, Oct 01, 2009 at 04:01:50PM +0800, Richard Zhao wrote:
 On Thu, Oct 1, 2009 at 3:29 PM, Sascha Hauer s.ha...@pengutronix.de wrote:
  On Thu, Oct 01, 2009 at 09:13:32AM +0800, Richard Zhao wrote:
  When CONFIG_I2C_DEBUG_BUS is enabled, it helps dump registers at 
  operation
  fail condition, and print i2c_msg to xfer.
 
  Signed-off-by: Richard Zhao linux...@gmail.com
 
  Honestly I don't think we need this. It makes the driver too verbose for
  my taste.
 
  Sascha
 
 
 
  diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
  index c1e541c..87faea4 100644
  --- a/drivers/i2c/busses/i2c-imx.c
  +++ b/drivers/i2c/busses/i2c-imx.c
  @@ -125,6 +125,20 @@ struct imx_i2c_struct {
   /** Functions for IMX I2C adapter driver 
  ***
   ***/
 
  +#ifdef CONFIG_I2C_DEBUG_BUS
  +#define reg_dump(i2c_imx) \
  +{ \
  +     printk(KERN_DEBUG fun %s:%d , __func__, __LINE__); \
  +     printk(KERN_DEBUG IADR %02x IFDR %02x I2CR %02x I2SR %02x\n, \
  +             readb(i2c_imx-base + IMX_I2C_IADR), \
  +             readb(i2c_imx-base + IMX_I2C_IFDR), \
  +             readb(i2c_imx-base + IMX_I2C_I2CR), \
  +             readb(i2c_imx-base + IMX_I2C_I2SR)); \
  +}
  +#else
  +#define reg_dump(i2c_imx)
  +#endif
  +
   static int i2c_imx_bus_busy(struct imx_i2c_struct *i2c_imx, int 
  for_busy)
   {
        unsigned long orig_jiffies = jiffies;
  @@ -146,6 +160,7 @@ static int i2c_imx_bus_busy(struct imx_i2c_struct 
  *i2c_imx, int for_busy)
                if (time_after(jiffies, orig_jiffies + HZ / 1000)) {
                        dev_dbg(i2c_imx-adapter.dev,
                                %s I2C bus is busy\n, __func__);
  +                     reg_dump(i2c_imx);
                        return -EIO;
                }
                schedule();
  @@ -164,9 +179,11 @@ static int i2c_imx_trx_complete(struct 
  imx_i2c_struct *i2c_imx)
 
        if (unlikely(result  0)) {
                dev_dbg(i2c_imx-adapter.dev, %s result  0\n, 
  __func__);
  +             reg_dump(i2c_imx);
                return result;
        } else if (unlikely(!(i2c_imx-i2csr  I2SR_IIF))) {
                dev_dbg(i2c_imx-adapter.dev, %s Timeout\n, __func__);
  +             reg_dump(i2c_imx);
                return -ETIMEDOUT;
        }
        dev_dbg(i2c_imx-adapter.dev, %s TRX complete\n, __func__);
  @@ -178,6 +195,7 @@ static int i2c_imx_acked(struct imx_i2c_struct 
  *i2c_imx)
   {
        if (readb(i2c_imx-base + IMX_I2C_I2SR)  I2SR_RXAK) {
                dev_dbg(i2c_imx-adapter.dev, %s No ACK\n, __func__);
  +             reg_dump(i2c_imx);
                return -EIO;  /* No ACK */
        }
 
  @@ -197,17 +215,20 @@ static int i2c_imx_start(struct imx_i2c_struct 
  *i2c_imx)
        writeb(I2CR_IEN, i2c_imx-base + IMX_I2C_I2CR);
 
        result = i2c_imx_bus_busy(i2c_imx, 0);
  -     if (result)
  +     if (result) {
  +             reg_dump(i2c_imx);
                return result;
  +     }
 
        /* Start I2C transaction */
        temp = readb(i2c_imx-base + IMX_I2C_I2CR);
        temp |= I2CR_MSTA;
        writeb(temp, i2c_imx-base + IMX_I2C_I2CR);
        result = i2c_imx_bus_busy(i2c_imx, 1);
  -     if (result)
  +     if (result) {
  +             reg_dump(i2c_imx);
                return result;
  -
  +     }
        temp |= I2CR_IIEN | I2CR_MTX | I2CR_TXAK;
        writeb(temp, i2c_imx-base + IMX_I2C_I2CR);
        return result;
  @@ -228,7 +249,8 @@ static void i2c_imx_stop(struct imx_i2c_struct 
  *i2c_imx)
         */
        udelay(i2c_imx-disable_delay);
 
  -     i2c_imx_bus_busy(i2c_imx, 0);
  +     if (i2c_imx_bus_busy(i2c_imx, 0))
  +             reg_dump(i2c_imx);
 
        /* Disable I2C controller */
        writeb(0, i2c_imx-base + IMX_I2C_I2CR);
  @@ -389,7 +411,18 @@ static int i2c_imx_xfer(struct i2c_adapter *adapter,
        struct imx_i2c_struct *i2c_imx = i2c_get_adapdata(adapter);
 
        dev_dbg(i2c_imx-adapter.dev, %s\n, __func__);
  -
  +#ifdef CONFIG_I2C_DEBUG_BUS
  +     for (i = 0; i  num; i++) {
  +             printk(KERN_DEBUG msg%d addr %02x RD %d cnt %d d:, i,
  +                     msgs[i].addr, msgs[i].flags  I2C_M_RD, 
  msgs[i].len);
  +             if (!(msgs[i].flags  I2C_M_RD)) {
  +                     int j;
  +                     for (j = 0; j  msgs[i].len; j++)
  +                             printk(%02x , msgs[i].buf[j]);
  +             }
  +             printk(\n);
  +     }
  +#endif
        /* Start I2C transfer */
        result = i2c_imx_start(i2c_imx);
        if (result)
  @@ -404,8 +437,10 @@ static int i2c_imx_xfer(struct i2c_adapter *adapter,
                        temp |= I2CR_RSTA;
                        writeb(temp, i2c_imx-base + IMX_I2C_I2CR

Re: [PATCH 4/4] i2c: imx: disable clock when it's possible to save power.

2009-10-04 Thread Richard Zhao
On Thu, Oct 1, 2009 at 4:00 PM, Sascha Hauer s.ha...@pengutronix.de wrote:
 On Thu, Oct 01, 2009 at 03:56:29PM +0800, Richard Zhao wrote:
 On Thu, Oct 1, 2009 at 3:34 PM, Sascha Hauer s.ha...@pengutronix.de wrote:
  On Thu, Oct 01, 2009 at 09:13:33AM +0800, Richard Zhao wrote:
  Enable clock before START, disable it after STOP.
 
  The clk_diable/enable calls in suspend/resume should be removed also.
 
  Sascha
 
 
  Signed-off-by: Richard Zhao linux...@gmail.com
 
  diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
  index 87faea4..72ddea3 100644
  --- a/drivers/i2c/busses/i2c-imx.c
  +++ b/drivers/i2c/busses/i2c-imx.c
  @@ -120,6 +120,7 @@ struct imx_i2c_struct {
        wait_queue_head_t       queue;
        unsigned long           i2csr;
        unsigned int            disable_delay;
  +     unsigned int            ifdr; /* IMX_I2C_IFDR */
   };
 
   /** Functions for IMX I2C adapter driver 
  ***
  @@ -210,6 +211,8 @@ static int i2c_imx_start(struct imx_i2c_struct 
  *i2c_imx)
 
        dev_dbg(i2c_imx-adapter.dev, %s\n, __func__);
 
  +     clk_enable(i2c_imx-clk);
  +     writeb(i2c_imx-ifdr, i2c_imx-base + IMX_I2C_IFDR);
        /* Enable I2C controller */
        writeb(0, i2c_imx-base + IMX_I2C_I2SR);
        writeb(I2CR_IEN, i2c_imx-base + IMX_I2C_I2CR);
  @@ -254,6 +257,7 @@ static void i2c_imx_stop(struct imx_i2c_struct 
  *i2c_imx)
 
        /* Disable I2C controller */
        writeb(0, i2c_imx-base + IMX_I2C_I2CR);
  +     clk_disable(i2c_imx-clk);
   }
 
   static void __init i2c_imx_set_clk(struct imx_i2c_struct *i2c_imx,
  @@ -273,8 +277,8 @@ static void __init i2c_imx_set_clk(struct 
  imx_i2c_struct *i2c_imx,
        else
                for (i = 0; i2c_clk_div[i][0]  div; i++);
 
  -     /* Write divider value to register */
  -     writeb(i2c_clk_div[i][1], i2c_imx-base + IMX_I2C_IFDR);
  +     /* Store divider value */
  +     i2c_imx-ifdr = i2c_clk_div[i][1];
 
        if (cpu_is_mx1()) {
                /*
  @@ -555,7 +559,6 @@ static int __init i2c_imx_probe(struct 
  platform_device *pdev)
                dev_err(pdev-dev, can't get I2C clock\n);
                goto fail3;
        }
  -     clk_enable(i2c_imx-clk);
 
        /* Request IRQ */
        ret = request_irq(i2c_imx-irq, i2c_imx_isr, 0, pdev-name, 
  i2c_imx);
  @@ -604,7 +607,6 @@ static int __init i2c_imx_probe(struct 
  platform_device *pdev)
   fail5:
        free_irq(i2c_imx-irq, i2c_imx);
   fail4:
  -     clk_disable(i2c_imx-clk);
        clk_put(i2c_imx-clk);
   fail3:
        release_mem_region(i2c_imx-res-start, resource_size(res));
  @@ -641,8 +643,6 @@ static int __exit i2c_imx_remove(struct 
  platform_device *pdev)
        if (pdata  pdata-exit)
                pdata-exit(pdev-dev);
 
  -     /* Disable I2C clock */
  -     clk_disable(i2c_imx-clk);
        clk_put(i2c_imx-clk);
 
        release_mem_region(i2c_imx-res-start, 
  resource_size(i2c_imx-res));
  --
  1.6.0.4
 
 
 
  --
  Pengutronix e.K.                           |                             |
  Industrial Linux Solutions                 | http://www.pengutronix.de/  |
  Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
  Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917- |
 

 I don't think we have any suspend/resume routine. And we won't need it any 
 more.

 Ups, my bad. I have it in my local tree and didn't realize it isn't
 upstream.

 Sascha


 --
 Pengutronix e.K.                           |                             |
 Industrial Linux Solutions                 | http://www.pengutronix.de/  |
 Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
 Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917- |


Hi Sascha,

Do I need re-send this patch when I re-send out other patches?

Thanks
Richard
--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/4] i2c: imx: check busy bit when START/STOP

2009-10-02 Thread Richard Zhao
On Fri, Oct 2, 2009 at 3:26 PM, Sascha Hauer s.ha...@pengutronix.de wrote:
 On Fri, Oct 02, 2009 at 08:57:04AM +0800, Richard Zhao wrote:
 On Fri, Oct 2, 2009 at 12:37 AM, Wolfram Sang w.s...@pengutronix.de wrote:
   Ah, so 'make the driver work on i.MX51' is a good statement which should
   be part of the commit message.
  Well, maybe I can mention it.
  But I think the good point is to present what you modified, not the side 
  effect.
 
  It is not the side effect but the intention :) As no code is changed 
  without a
  need, the reason really should be in the patch description.
 No, it's not intention. I'm just trying to make the controller work in
 a right way. Without this patch, maybe some other fast cpus have
 problem too. I just tested mx31 and mx51. I will add Without this
 patch, i2c on some fast SoCs (for example imx51) will not work. Is it
 ok for you?

 Please remember that we do not have i.MX51 support in mainline, so this
 is irrelevant atm.
So I don't need to meantion mx51? Without this patch, i2c on some
fast SoCs will not work is all right?

 
  Yes. But I don't have multi-master system. So I can't say that.
  The code is just taken from Freescale latest code. Without it, It
  could also cause a device error. I forget the details.  Anyway, it
  doesn't make anything wrong.
 
  Do you know where the details are explained?
 No, I don't. I don't have device in hand now. If you have, could you
 please help do a simple test?
 Use hw to simulate multi-master system. Before execute xfer, you first
 pull down SDA, then pull down SDC. It simulates a START. and execute
 xfer to see whether IBB is set?

 No, we won't do any tests on hardware.

 At the moment we have a driver which is not multi master capable.
 Looking at the datasheet the change you do seems not enough to change
 this. So we should take a patch which changes something from which you
 think it might be needed? And you don't even have the details at hand?

 No.
Ok, It seems I have no reason to keep the busy wait before START.
Wolfram, do you agree to remove the busy wait? I saw you submmited the
original driver.
Let get away from multi-master. There's nearly no multi-master i2c bus
system in reality.

Thanks
Richard

 Sascha

 --
 Pengutronix e.K.                           |                             |
 Industrial Linux Solutions                 | http://www.pengutronix.de/  |
 Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
 Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917- |

--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 4/4] i2c: imx: disable clock when it's possible to save power.

2009-10-01 Thread Richard Zhao
On Thu, Oct 1, 2009 at 3:34 PM, Sascha Hauer s.ha...@pengutronix.de wrote:
 On Thu, Oct 01, 2009 at 09:13:33AM +0800, Richard Zhao wrote:
 Enable clock before START, disable it after STOP.

 The clk_diable/enable calls in suspend/resume should be removed also.

 Sascha


 Signed-off-by: Richard Zhao linux...@gmail.com

 diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
 index 87faea4..72ddea3 100644
 --- a/drivers/i2c/busses/i2c-imx.c
 +++ b/drivers/i2c/busses/i2c-imx.c
 @@ -120,6 +120,7 @@ struct imx_i2c_struct {
       wait_queue_head_t       queue;
       unsigned long           i2csr;
       unsigned int            disable_delay;
 +     unsigned int            ifdr; /* IMX_I2C_IFDR */
  };

  /** Functions for IMX I2C adapter driver 
 ***
 @@ -210,6 +211,8 @@ static int i2c_imx_start(struct imx_i2c_struct *i2c_imx)

       dev_dbg(i2c_imx-adapter.dev, %s\n, __func__);

 +     clk_enable(i2c_imx-clk);
 +     writeb(i2c_imx-ifdr, i2c_imx-base + IMX_I2C_IFDR);
       /* Enable I2C controller */
       writeb(0, i2c_imx-base + IMX_I2C_I2SR);
       writeb(I2CR_IEN, i2c_imx-base + IMX_I2C_I2CR);
 @@ -254,6 +257,7 @@ static void i2c_imx_stop(struct imx_i2c_struct *i2c_imx)

       /* Disable I2C controller */
       writeb(0, i2c_imx-base + IMX_I2C_I2CR);
 +     clk_disable(i2c_imx-clk);
  }

  static void __init i2c_imx_set_clk(struct imx_i2c_struct *i2c_imx,
 @@ -273,8 +277,8 @@ static void __init i2c_imx_set_clk(struct imx_i2c_struct 
 *i2c_imx,
       else
               for (i = 0; i2c_clk_div[i][0]  div; i++);

 -     /* Write divider value to register */
 -     writeb(i2c_clk_div[i][1], i2c_imx-base + IMX_I2C_IFDR);
 +     /* Store divider value */
 +     i2c_imx-ifdr = i2c_clk_div[i][1];

       if (cpu_is_mx1()) {
               /*
 @@ -555,7 +559,6 @@ static int __init i2c_imx_probe(struct platform_device 
 *pdev)
               dev_err(pdev-dev, can't get I2C clock\n);
               goto fail3;
       }
 -     clk_enable(i2c_imx-clk);

       /* Request IRQ */
       ret = request_irq(i2c_imx-irq, i2c_imx_isr, 0, pdev-name, i2c_imx);
 @@ -604,7 +607,6 @@ static int __init i2c_imx_probe(struct platform_device 
 *pdev)
  fail5:
       free_irq(i2c_imx-irq, i2c_imx);
  fail4:
 -     clk_disable(i2c_imx-clk);
       clk_put(i2c_imx-clk);
  fail3:
       release_mem_region(i2c_imx-res-start, resource_size(res));
 @@ -641,8 +643,6 @@ static int __exit i2c_imx_remove(struct platform_device 
 *pdev)
       if (pdata  pdata-exit)
               pdata-exit(pdev-dev);

 -     /* Disable I2C clock */
 -     clk_disable(i2c_imx-clk);
       clk_put(i2c_imx-clk);

       release_mem_region(i2c_imx-res-start, resource_size(i2c_imx-res));
 --
 1.6.0.4



 --
 Pengutronix e.K.                           |                             |
 Industrial Linux Solutions                 | http://www.pengutronix.de/  |
 Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
 Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917- |


I don't think we have any suspend/resume routine. And we won't need it any more.

Thanks
Richard
--
To unsubscribe from this list: send the line unsubscribe linux-i2c in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


  1   2   >