[PATCH v2] i2c: imx: Remove unneeded comments

2016-01-04 Thread Fabio Estevam
These multi-lines comments do not follow the standard kernel coding
style. In fact, they are not useful comments, so get rid of them.

Signed-off-by: Fabio Estevam <fabio.este...@nxp.com>
---
Changes since v1:
- Rebased against latest tree

 drivers/i2c/busses/i2c-imx.c | 12 
 1 file changed, 12 deletions(-)

diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index dcea8d2..8b68dbf 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -29,9 +29,6 @@
  *
  */
 
-/** Includes 
***
-***/
-
 #include 
 #include 
 #include 
@@ -57,9 +54,6 @@
 #include 
 #include 
 
-/** Defines 

-***/
-
 /* This will be the driver name the kernel reports */
 #define DRIVER_NAME "imx-i2c"
 
@@ -123,9 +117,6 @@
 
 #define I2C_PM_TIMEOUT 10 /* ms */
 
-/** Variables 
**
-***/
-
 /*
  * sorted list of clock divider, register value pairs
  * taken from table 26-5, p.26-9, Freescale i.MX
@@ -419,9 +410,6 @@ static void i2c_imx_dma_free(struct imx_i2c_struct *i2c_imx)
dma->chan_using = NULL;
 }
 
-/** Functions for IMX I2C adapter driver 
***
-***/
-
 static int i2c_imx_bus_busy(struct imx_i2c_struct *i2c_imx, int for_busy)
 {
unsigned long orig_jiffies = jiffies;
-- 
1.9.1

--
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/2] i2c: imx: Improve message log when DMA is not used

2015-11-01 Thread Fabio Estevam
From: Fabio Estevam <fabio.este...@freescale.com>

When DMA cannot be used, it is better to state that the I2C controller
will operate in PIO mode.

Signed-off-by: Fabio Estevam <fabio.este...@freescale.com>
---
 drivers/i2c/busses/i2c-imx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 785aa67..1e522c3 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -339,7 +339,7 @@ fail_tx:
dma_release_channel(dma->chan_tx);
 fail_al:
devm_kfree(dev, dma);
-   dev_info(dev, "can't use DMA\n");
+   dev_info(dev, "can't use DMA, using PIO instead.\n");
 }
 
 static void i2c_imx_dma_callback(void *arg)
-- 
1.9.1

--
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 2/2] i2c: imx: Remove unneeded comments

2015-11-01 Thread Fabio Estevam
From: Fabio Estevam <fabio.este...@freescale.com>

These multi-lines comments do not follow the standard kernel coding
style. In fact, they are not useful comments, so get rid of them.

Signed-off-by: Fabio Estevam <fabio.este...@freescale.com>
---
 drivers/i2c/busses/i2c-imx.c | 12 
 1 file changed, 12 deletions(-)

diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 1e522c3..696c920 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -29,9 +29,6 @@
  *
  */
 
-/** Includes 
***
-***/
-
 #include 
 #include 
 #include 
@@ -54,9 +51,6 @@
 #include 
 #include 
 
-/** Defines 

-***/
-
 /* This will be the driver name the kernel reports */
 #define DRIVER_NAME "imx-i2c"
 
@@ -118,9 +112,6 @@
 #define I2CR_IEN_OPCODE_0  0x0
 #define I2CR_IEN_OPCODE_1  I2CR_IEN
 
-/** Variables 
**
-***/
-
 /*
  * sorted list of clock divider, register value pairs
  * taken from table 26-5, p.26-9, Freescale i.MX
@@ -409,9 +400,6 @@ static void i2c_imx_dma_free(struct imx_i2c_struct *i2c_imx)
dma->chan_using = NULL;
 }
 
-/** Functions for IMX I2C adapter driver 
***
-***/
-
 static int i2c_imx_bus_busy(struct imx_i2c_struct *i2c_imx, int for_busy)
 {
unsigned long orig_jiffies = jiffies;
-- 
1.9.1

--
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] i2c: i2c-imx: Use -ENXIO as error in the NACK case

2015-10-22 Thread Fabio Estevam
According to Documentation/i2c/fault-codes the response to a bus NACK
should be -ENXIO, so fix the error code.

This change is similar to commit 6ff4b1051632 ("i2c: rcar: fix NACK
error code").

Signed-off-by: Fabio Estevam <fabio.este...@freescale.com>
---
 drivers/i2c/busses/i2c-imx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 785aa67..329cf13 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -461,7 +461,7 @@ static int i2c_imx_acked(struct imx_i2c_struct *i2c_imx)
 {
if (imx_i2c_read_reg(i2c_imx, IMX_I2C_I2SR) & I2SR_RXAK) {
dev_dbg(_imx->adapter.dev, "<%s> No ACK\n", __func__);
-   return -EIO;  /* No ACK */
+   return -ENXIO;  /* No ACK */
}
 
dev_dbg(_imx->adapter.dev, "<%s> ACK received\n", __func__);
-- 
1.9.1

--
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: core: Fix probing of i2c slaves without interrupts

2014-11-17 Thread Fabio Estevam
On Mon, Nov 17, 2014 at 9:43 AM, Geert Uytterhoeven
geert+rene...@glider.be wrote:
 Since commit 2fd36c55264926e2 (i2c: core: Map OF IRQ at probe time),
 i2c slaves without interrupts (e.g. da9210 and at24 on r8a7791/koelsch)
 fail to probe:

 at24: probe of 2-0050 failed with error -22

 da9210: probe of 6-0068 failed with error -22

 This happens because the call to of_irq_get() in i2c_device_probe()
 returns -EINVAL.

 If a device node does not have an interrupts property,
 of_irq_parse_one() fails. Unlike irq_of_parse_and_map(), of_irq_get()
 does not ignore errors from of_irq_parse_one(), but forwards them.

 Make i2c_device_probe() ignore all errors but -EPROBE_DEFER to fix this,
 just like platform_get_irq() and platform_get_irq_byname() already do.

 Fixes: 2fd36c55264926e2 (i2c: core: Map OF IRQ at probe time)
 Signed-off-by: Geert Uytterhoeven geert+rene...@glider.be

With this patch applied my codec and PMIC can be probed again:

Tested-by: Fabio Estevam fabio.este...@freescale.com

Thanks
--
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/2] i2c-imx: Use the preferred form for passing a size of a struct

2014-11-06 Thread Fabio Estevam
From: Fabio Estevam fabio.este...@freescale.com

According to Documentation/CodingStyle - Chapter 14:

The preferred form for passing a size of a struct is the following:

p = kmalloc(sizeof(*p), ...);

The alternative form where struct name is spelled out hurts readability and
introduces an opportunity for a bug when the pointer variable type is changed
but the corresponding sizeof that is passed to a memory allocator is not.

So do it as recommeded.

Signed-off-by: Fabio Estevam fabio.este...@freescale.com
---
 drivers/i2c/busses/i2c-imx.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index c48e46a..47269e0 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -673,8 +673,7 @@ static int i2c_imx_probe(struct platform_device *pdev)
if (IS_ERR(base))
return PTR_ERR(base);
 
-   i2c_imx = devm_kzalloc(pdev-dev, sizeof(struct imx_i2c_struct),
-   GFP_KERNEL);
+   i2c_imx = devm_kzalloc(pdev-dev, sizeof(*i2c_imx), GFP_KERNEL);
if (!i2c_imx)
return -ENOMEM;
 
-- 
1.9.1

--
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 2/2] i2c-mxs: Use the preferred form for passing a size of a struct

2014-11-06 Thread Fabio Estevam
From: Fabio Estevam fabio.este...@freescale.com

According to Documentation/CodingStyle - Chapter 14:

The preferred form for passing a size of a struct is the following:

p = kmalloc(sizeof(*p), ...);

The alternative form where struct name is spelled out hurts readability and
introduces an opportunity for a bug when the pointer variable type is changed
but the corresponding sizeof that is passed to a memory allocator is not.

So do it as recommeded.

Signed-off-by: Fabio Estevam fabio.este...@freescale.com
---
 drivers/i2c/busses/i2c-mxs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c
index 07e1be6..3e7893a 100644
--- a/drivers/i2c/busses/i2c-mxs.c
+++ b/drivers/i2c/busses/i2c-mxs.c
@@ -811,7 +811,7 @@ static int mxs_i2c_probe(struct platform_device *pdev)
struct resource *res;
int err, irq;
 
-   i2c = devm_kzalloc(dev, sizeof(struct mxs_i2c_dev), GFP_KERNEL);
+   i2c = devm_kzalloc(dev, sizeof(*i2c), GFP_KERNEL);
if (!i2c)
return -ENOMEM;
 
-- 
1.9.1

--
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] i2c-imx: Disable the clock on probe failure

2014-10-04 Thread Fabio Estevam
From: Fabio Estevam fabio.este...@freescale.com

In the case of errors during probe, we should disable i2c_imx-clk.

Signed-off-by: Fabio Estevam fabio.este...@freescale.com
---
 drivers/i2c/busses/i2c-imx.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index ceff87c..c48e46a 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -710,7 +710,7 @@ static int i2c_imx_probe(struct platform_device *pdev)
pdev-name, i2c_imx);
if (ret) {
dev_err(pdev-dev, can't claim irq %d\n, irq);
-   return ret;
+   goto clk_disable;
}
 
/* Init queue */
@@ -735,7 +735,7 @@ static int 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);
-   return ret;
+   goto clk_disable;
}
 
/* Set up platform driver data */
@@ -749,6 +749,10 @@ static int i2c_imx_probe(struct platform_device *pdev)
dev_info(i2c_imx-adapter.dev, IMX I2C adapter registered\n);
 
return 0;   /* Return OK */
+
+clk_disable:
+   clk_disable_unprepare(i2c_imx-clk);
+   return ret;
 }
 
 static int i2c_imx_remove(struct platform_device *pdev)
-- 
1.9.1

--
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 14/17] i2c: nomadik: Fixup deployment of runtime PM

2014-02-05 Thread Fabio Estevam
On Tue, Feb 4, 2014 at 1:58 PM, Ulf Hansson ulf.hans...@linaro.org wrote:

 +static int nmk_i2c_runtime_resume(struct device *dev)
 +{
 +   struct amba_device *adev = to_amba_device(dev);,
 +   struct nmk_i2c_dev *nmk_i2c = amba_get_drvdata(adev);
 +
 +   clk_prepare_enable(nmk_i2c-clk);

Previously the code was checking the return value from
clk_prepare_enable(). You should keep the check here.

Regards,

Fabio Estevam
--
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] i2c: i2c-imx: Check the return value from clk_prepare_enable()

2013-12-04 Thread Fabio Estevam
From: Fabio Estevam fabio.este...@freescale.com

clk_prepare_enable() may fail, so let's check its return value and propagate it
in the case of error.

Signed-off-by: Fabio Estevam fabio.este...@freescale.com
---
 drivers/i2c/busses/i2c-imx.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 1d7efa3..d0cfbb4 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -312,7 +312,9 @@ static int i2c_imx_start(struct imx_i2c_struct *i2c_imx)
 
dev_dbg(i2c_imx-adapter.dev, %s\n, __func__);
 
-   clk_prepare_enable(i2c_imx-clk);
+   result = clk_prepare_enable(i2c_imx-clk);
+   if (result)
+   return result;
imx_i2c_write_reg(i2c_imx-ifdr, i2c_imx, IMX_I2C_IFDR);
/* Enable I2C controller */
imx_i2c_write_reg(i2c_imx-hwdata-i2sr_clr_opcode, i2c_imx, 
IMX_I2C_I2SR);
-- 
1.8.1.2

--
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: i2c_mxs: Set ACK_MODE bit

2013-08-20 Thread Fabio Estevam
On Tue, Aug 20, 2013 at 4:04 PM, Wolfram Sang w...@the-dreams.de wrote:

 According to the mx23 erratum 2727 this patch is needed.

 Have you measured it yourself?

No, only relying on the mx23 errata doc here.
--
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: i2c_mxs: Set ACK_MODE bit

2013-08-20 Thread Fabio Estevam
On Tue, Aug 20, 2013 at 4:20 PM, Wolfram Sang w...@the-dreams.de wrote:

  Have you measured it yourself?

 No, only relying on the mx23 errata doc here.

 Only send patches when you KNOW what you are changing, i.e. you verified
 to the best of your knowledge. Really! Docs have so many bugs...

 Honestly, I hate dealing with patches which are more or less guesses.
 They offload the QA to me and I surely have enough own tasks to do...

Ok. sir. Will investigate more about this erratum entry.
--
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: i2c_mxs: Set ACK_MODE bit

2013-08-19 Thread Fabio Estevam

On 08/15/2013 07:08 AM, Wolfram Sang wrote:

On Tue, Jul 02, 2013 at 01:01:00PM -0300, Fabio Estevam wrote:

According to mx23 erratum 2727:

2727 : I2C 9th Clock Pulse (ACK) not generated when RETAIN_CLOCK set.

Description:

When RETAIN_CLOCK is set, the ninth clock pulse (ACK) is not generated.
However, the SDA line is read at the proper timing interval. If
RETAIN_CLOCK is cleared, the ninth clock pulse is generated.
Also, the HW_I2C_VERSION register incorrectly states the version is 1.2.
It should be 1.3.

Workaround:
HW_I2C_CTRL1[ACK_MODE] has default value of 0. It should be set to 1 to
enable the fix for this issue.

It has also been noticed that mx28 needs to implement this fix in order to have
SMBus to work properly.

Reported-by: Christoph Baumann c...@sgoc.de
Signed-off-by: Fabio Estevam fabio.este...@freescale.com


What's with this one? Bogus? Needed? Still needed after PIO rework?


According to the mx23 erratum 2727 this patch is needed.

Regards,

Fabio Estevam



--
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: i2c-mxs: Use DMA mode even for small transfers

2013-07-23 Thread Fabio Estevam
Wolfram,

On Mon, Jul 15, 2013 at 10:30 AM, Fabio Estevam feste...@gmail.com wrote:

 Any comment about this patch, please?

 If you are happy with it, could we please have it applied into stable?

 3.10 is currently broken without this patch.

Ping?
--
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: i2c-mxs: Use DMA mode even for small transfers

2013-07-23 Thread Fabio Estevam
Hi Marek,

On Wed, Jul 24, 2013 at 12:02 AM, Marek Vasut ma...@denx.de wrote:

 Yes, the big question is if we want to use this patch or fix the PIO. I think
 this one is much less intrusive, so I'd vouch for yours for 3.10 .

Correct. Also according to Documentation/stable_kernel_rules.txt :

Rules on what kind of patches are accepted, and which ones are not, into the
-stable tree:


 - It cannot be bigger than 100 lines, with context.

Your PIO fix is really appreciated, but it surpasses 100 lines, so it
would be better if we go with this one first so that it can reach
3.10, and then we can use your PIO fix later.

Regards,

Fabio Estevam
--
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] i2c: i2c-mxs: Check the return value from stmp_reset_block()

2013-07-10 Thread Fabio Estevam
From: Fabio Estevam fabio.este...@freescale.com

stmp_reset_block() may fail, so let's check its return value and propagate it in
the case of error.

Signed-off-by: Fabio Estevam fabio.este...@freescale.com
---
 drivers/i2c/busses/i2c-mxs.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c
index df8ff5a..1891ae7 100644
--- a/drivers/i2c/busses/i2c-mxs.c
+++ b/drivers/i2c/busses/i2c-mxs.c
@@ -123,9 +123,11 @@ struct mxs_i2c_dev {
booldma_read;
 };
 
-static void mxs_i2c_reset(struct mxs_i2c_dev *i2c)
+static int mxs_i2c_reset(struct mxs_i2c_dev *i2c)
 {
-   stmp_reset_block(i2c-regs);
+   int ret = stmp_reset_block(i2c-regs);
+   if (ret)
+   return ret;
 
/*
 * Configure timing for the I2C block. The I2C TIMING2 register has to
@@ -139,6 +141,8 @@ static void mxs_i2c_reset(struct mxs_i2c_dev *i2c)
writel(0x00300030, i2c-regs + MXS_I2C_TIMING2);
 
writel(MXS_I2C_IRQ_MASK  8, i2c-regs + MXS_I2C_CTRL1_SET);
+
+   return 0;
 }
 
 static void mxs_i2c_dma_finish(struct mxs_i2c_dev *i2c)
@@ -683,7 +687,9 @@ static int mxs_i2c_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, i2c);
 
/* Do reset to enforce correct startup after pinmuxing */
-   mxs_i2c_reset(i2c);
+   err = mxs_i2c_reset(i2c);
+   if (err)
+   return err;
 
adap = i2c-adapter;
strlcpy(adap-name, MXS I2C adapter, sizeof(adap-name));
-- 
1.8.1.2

--
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] i2c: i2c-mxs: Check the return value from stmp_reset_block()

2013-07-10 Thread Fabio Estevam
From: Fabio Estevam fabio.este...@freescale.com

stmp_reset_block() may fail, so let's check its return value and propagate it in
the case of error.

Signed-off-by: Fabio Estevam fabio.este...@freescale.com
---
Changes since v1:
- Check the return value of all occurences of mxs_i2c_reset()

 drivers/i2c/busses/i2c-mxs.c | 26 +++---
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c
index df8ff5a..90c052e 100644
--- a/drivers/i2c/busses/i2c-mxs.c
+++ b/drivers/i2c/busses/i2c-mxs.c
@@ -123,9 +123,11 @@ struct mxs_i2c_dev {
booldma_read;
 };
 
-static void mxs_i2c_reset(struct mxs_i2c_dev *i2c)
+static int mxs_i2c_reset(struct mxs_i2c_dev *i2c)
 {
-   stmp_reset_block(i2c-regs);
+   int ret = stmp_reset_block(i2c-regs);
+   if (ret)
+   return ret;
 
/*
 * Configure timing for the I2C block. The I2C TIMING2 register has to
@@ -139,6 +141,8 @@ static void mxs_i2c_reset(struct mxs_i2c_dev *i2c)
writel(0x00300030, i2c-regs + MXS_I2C_TIMING2);
 
writel(MXS_I2C_IRQ_MASK  8, i2c-regs + MXS_I2C_CTRL1_SET);
+
+   return 0;
 }
 
 static void mxs_i2c_dma_finish(struct mxs_i2c_dev *i2c)
@@ -475,7 +479,7 @@ static int mxs_i2c_xfer_msg(struct i2c_adapter *adap, 
struct i2c_msg *msg,
int stop)
 {
struct mxs_i2c_dev *i2c = i2c_get_adapdata(adap);
-   int ret;
+   int ret, err;
int flags;
 
flags = stop ? MXS_I2C_CTRL0_POST_SEND_STOP : 0;
@@ -495,8 +499,11 @@ static int mxs_i2c_xfer_msg(struct i2c_adapter *adap, 
struct i2c_msg *msg,
i2c-cmd_err = 0;
if (msg-len  8) {
ret = mxs_i2c_pio_setup_xfer(adap, msg, flags);
-   if (ret)
-   mxs_i2c_reset(i2c);
+   if (ret) {
+   err = mxs_i2c_reset(i2c);
+   if (err)
+   return err;
+   }
} else {
INIT_COMPLETION(i2c-cmd_complete);
ret = mxs_i2c_dma_setup_xfer(adap, msg, flags);
@@ -527,7 +534,10 @@ static int mxs_i2c_xfer_msg(struct i2c_adapter *adap, 
struct i2c_msg *msg,
 timeout:
dev_dbg(i2c-dev, Timeout!\n);
mxs_i2c_dma_finish(i2c);
-   mxs_i2c_reset(i2c);
+   ret = mxs_i2c_reset(i2c);
+   if (ret)
+   return ret;
+
return -ETIMEDOUT;
 }
 
@@ -683,7 +693,9 @@ static int mxs_i2c_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, i2c);
 
/* Do reset to enforce correct startup after pinmuxing */
-   mxs_i2c_reset(i2c);
+   err = mxs_i2c_reset(i2c);
+   if (err)
+   return err;
 
adap = i2c-adapter;
strlcpy(adap-name, MXS I2C adapter, sizeof(adap-name));
-- 
1.8.1.2

--
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] i2c: i2c_mxs: Set ACK_MODE bit

2013-07-02 Thread Fabio Estevam
According to mx23 erratum 2727:

2727 : I2C 9th Clock Pulse (ACK) not generated when RETAIN_CLOCK set.

Description:

When RETAIN_CLOCK is set, the ninth clock pulse (ACK) is not generated. 
However, the SDA line is read at the proper timing interval. If 
RETAIN_CLOCK is cleared, the ninth clock pulse is generated.
Also, the HW_I2C_VERSION register incorrectly states the version is 1.2. 
It should be 1.3.

Workaround:
HW_I2C_CTRL1[ACK_MODE] has default value of 0. It should be set to 1 to 
enable the fix for this issue.

It has also been noticed that mx28 needs to implement this fix in order to have
SMBus to work properly.

Reported-by: Christoph Baumann c...@sgoc.de
Signed-off-by: Fabio Estevam fabio.este...@freescale.com
---
 drivers/i2c/busses/i2c-mxs.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c
index 6d8094d..ce7ac86 100644
--- a/drivers/i2c/busses/i2c-mxs.c
+++ b/drivers/i2c/busses/i2c-mxs.c
@@ -56,6 +56,7 @@
 #define MXS_I2C_CTRL1_CLR  (0x48)
 
 #define MXS_I2C_CTRL1_CLR_GOT_A_NAK0x1000
+#define MXS_I2C_CTRL1_ACK_MODE 0x0800
 #define MXS_I2C_CTRL1_BUS_FREE_IRQ 0x80
 #define MXS_I2C_CTRL1_DATA_ENGINE_CMPLT_IRQ0x40
 #define MXS_I2C_CTRL1_NO_SLAVE_ACK_IRQ 0x20
@@ -140,6 +141,14 @@ static void mxs_i2c_reset(struct mxs_i2c_dev *i2c)
writel(0x00300030, i2c-regs + MXS_I2C_TIMING2);
 
writel(MXS_I2C_IRQ_MASK  8, i2c-regs + MXS_I2C_CTRL1_SET);
+
+   /*
+* According to mx23 erratum 2727:
+* I2C 9th Clock Pulse (ACK) not generated when RETAIN_CLOCK set
+*
+* HW_I2C_CTRL1[ACK_MODE] needs to be set when RETAIN_CLOCK is set.
+*/
+   writel(MXS_I2C_CTRL1_ACK_MODE, i2c-regs + MXS_I2C_CTRL1_SET);
 }
 
 static void mxs_i2c_dma_finish(struct mxs_i2c_dev *i2c)
-- 
1.8.1.2


--
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] i2c: i2c-mxs: Use DMA mode even for small transfers

2013-07-01 Thread Fabio Estevam
From: Fabio Estevam fabio.este...@freescale.com

Recently we have been seing some reports about PIO mode not working properly.

- http://www.spinics.net/lists/linux-i2c/msg11985.html
- http://marc.info/?l=linux-i2cm=137235593101385w=2
- https://lkml.org/lkml/2013/6/24/430

Let's use DMA mode even for small transfers.

Without this patch, i2c reads the incorrect sgtl5000 version on a mx28evk when
touchscreen is enabled:
   
[5.856270] sgtl5000 0-000a: Device with ID register 0 is not a sgtl5000 
[9.877307] sgtl5000 0-000a: ASoC: failed to probe CODEC -19 
[9.883528] mxs-sgtl5000 sound.12: ASoC: failed to instantiate card -19  
[9.892955] mxs-sgtl5000 sound.12: snd_soc_register_card failed (-19)  

Cc: sta...@vger.kernel.org
Signed-off-by: Fabio Estevam fabio.este...@freescale.com
---
Applies against 3.10

Changes since v1:
- Keep the PIO code

 drivers/i2c/busses/i2c-mxs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c
index 2039f23..6d8094d 100644
--- a/drivers/i2c/busses/i2c-mxs.c
+++ b/drivers/i2c/busses/i2c-mxs.c
@@ -494,7 +494,7 @@ static int mxs_i2c_xfer_msg(struct i2c_adapter *adap, 
struct i2c_msg *msg,
 * based on this empirical measurement and a lot of previous frobbing.
 */
i2c-cmd_err = 0;
-   if (msg-len  8) {
+   if (0) {/* disable PIO mode until a proper fix is made */
ret = mxs_i2c_pio_setup_xfer(adap, msg, flags);
if (ret)
mxs_i2c_reset(i2c);
-- 
1.8.1.2

--
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/13] i2c: i2c-mxs: Let device core handle pinctrl

2013-06-08 Thread Fabio Estevam
On Sat, Jun 8, 2013 at 4:15 AM, Wolfram Sang w...@the-dreams.de wrote:

 Yes, with series like this, you really need a cover-letter and CC it to
 all people involved. And mention there if you want these patches go via
 a specific tree or each patch via the corresponding subsystem tree. And
 mention if the patches are depending on each other. Otherwise I don't
 really know what to do with these patches.

Ok, understood, Wolfram.

Please apply in your tree, if it looks good for you.

Thanks,

Fabio Estevam
--
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/13] i2c: i2c-mxs: Let device core handle pinctrl

2013-05-26 Thread Fabio Estevam
Hi Wolfram,

On Mon, May 6, 2013 at 3:05 PM, Fabio Estevam
fabio.este...@freescale.com wrote:
 Since commit ab78029 (drivers/pinctrl: grab default handles from device core),
 we can rely on device core for handling pinctrl.

 So remove devm_pinctrl_get_select_default() from the driver.

 Cc: Wolfram Sang w...@the-dreams.de
 Cc: linux-i2c@vger.kernel.org
 Signed-off-by: Fabio Estevam fabio.este...@freescale.com

Any comments on this one?
--
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/13] i2c: i2c-mxs: Let device core handle pinctrl

2013-05-06 Thread Fabio Estevam
Since commit ab78029 (drivers/pinctrl: grab default handles from device core),
we can rely on device core for handling pinctrl.

So remove devm_pinctrl_get_select_default() from the driver. 

Cc: Wolfram Sang w...@the-dreams.de
Cc: linux-i2c@vger.kernel.org
Signed-off-by: Fabio Estevam fabio.este...@freescale.com
---
 drivers/i2c/busses/i2c-mxs.c |6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c
index 120f246..7f3dced 100644
--- a/drivers/i2c/busses/i2c-mxs.c
+++ b/drivers/i2c/busses/i2c-mxs.c
@@ -24,7 +24,6 @@
 #include linux/platform_device.h
 #include linux/jiffies.h
 #include linux/io.h
-#include linux/pinctrl/consumer.h
 #include linux/stmp_device.h
 #include linux/of.h
 #include linux/of_device.h
@@ -604,16 +603,11 @@ static int mxs_i2c_probe(struct platform_device *pdev)
struct device *dev = pdev-dev;
struct mxs_i2c_dev *i2c;
struct i2c_adapter *adap;
-   struct pinctrl *pinctrl;
struct resource *res;
resource_size_t res_size;
int err, irq, dmairq;
dma_cap_mask_t mask;
 
-   pinctrl = devm_pinctrl_get_select_default(dev);
-   if (IS_ERR(pinctrl))
-   return PTR_ERR(pinctrl);
-
i2c = devm_kzalloc(dev, sizeof(struct mxs_i2c_dev), GFP_KERNEL);
if (!i2c)
return -ENOMEM;
-- 
1.7.9.5


--
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 02/13] i2c: i2c-imx: Let device core handle pinctrl

2013-05-06 Thread Fabio Estevam
Since commit ab78029 (drivers/pinctrl: grab default handles from device core),
we can rely on device core for handling pinctrl.

So remove devm_pinctrl_get_select_default() from the driver. 

Cc: Wolfram Sang w...@the-dreams.de
Cc: linux-i2c@vger.kernel.org
Signed-off-by: Fabio Estevam fabio.este...@freescale.com
---
 drivers/i2c/busses/i2c-imx.c |8 
 1 file changed, 8 deletions(-)

diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 82f20c6..8c7526c 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -51,7 +51,6 @@
 #include linux/of.h
 #include linux/of_device.h
 #include linux/of_i2c.h
-#include linux/pinctrl/consumer.h
 #include linux/platform_data/i2c-imx.h
 
 /** Defines 

@@ -493,7 +492,6 @@ 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 *pinctrl;
void __iomem *base;
int irq, ret;
u32 bitrate;
@@ -535,12 +533,6 @@ static int __init i2c_imx_probe(struct platform_device 
*pdev)
i2c_imx-adapter.dev.of_node= pdev-dev.of_node;
i2c_imx-base   = base;
 
-   pinctrl = devm_pinctrl_get_select_default(pdev-dev);
-   if (IS_ERR(pinctrl)) {
-   dev_err(pdev-dev, can't get/select pinctrl\n);
-   return PTR_ERR(pinctrl);
-   }
-
/* Get I2C clock */
i2c_imx-clk = devm_clk_get(pdev-dev, NULL);
if (IS_ERR(i2c_imx-clk)) {
-- 
1.7.9.5


--
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] i2c: i2c-mxs: Fix type of error code

2013-01-07 Thread Fabio Estevam
From: Fabio Estevam fabio.este...@freescale.com

cmd_err is used to handle error code, so it should not be unsigned.

This fixes the following warning when building with W=1 option:

drivers/i2c/busses/i2c-mxs.c: In function 'mxs_i2c_xfer_msg':
drivers/i2c/busses/i2c-mxs.c:331:19: warning: comparison between signed and 
unsigned integer expressions [-Wsign-compare]

Signed-off-by: Fabio Estevam fabio.este...@freescale.com
---
 drivers/i2c/busses/i2c-mxs.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c
index 1b1a936..621153a 100644
--- a/drivers/i2c/busses/i2c-mxs.c
+++ b/drivers/i2c/busses/i2c-mxs.c
@@ -127,7 +127,7 @@ struct mxs_i2c_dev {
struct device *dev;
void __iomem *regs;
struct completion cmd_complete;
-   u32 cmd_err;
+   int cmd_err;
struct i2c_adapter adapter;
const struct mxs_i2c_speed_config *speed;
 
-- 
1.7.9.5

--
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 2/2] i2c: mxs: Do not disable the I2C SMBus quick mode

2012-11-20 Thread Fabio Estevam
Tim,

On Mon, Nov 19, 2012 at 1:05 PM, Tim Michals tcmich...@gmail.com wrote:

 I tested both patches using Linux version 3.7.0-rc4 with the following
 command:
 #  i2cdetect -r 0 20 30
 Usage: i2cdetect [-y] [-a] [-q|-r] I2CBUS [FIRST LAST]
i2cdetect -F I2CBUS
i2cdetect -l
   I2CBUS is an integer or an I2C bus name
   If provided, FIRST and LAST limit the probing range.
 # i2cdetect -r 0 20 30
 WARNING! This program can confuse your I2C bus, cause data loss and worse!
 I will probe file /dev/i2c-0 using read byte commands.
 I will probe address range 0x14-0x1e.
 Continue? [Y/n] y
  0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
 00:
 10: -- [   31.83] mxs-i2c 80058000.i2c: Failed to get PIO
 reg. .
 -- -- [   32.83] mxs-i2c 80058000.i2c: Failed to get PIO reg. write
 descrip.
 -- -- [   33.83] mxs-i2c 80058000.i2c: Failed to get PIO reg. write
 descrip.
 -- -- [   34.83] mxs-i2c 80058000.i2c: Failed to get PIO reg. write
 descrip.
 -- -- [   35.83] mxs-i2c 80058000.i2c: Failed to get PIO reg. write
 descrip.

Which I2C device you have in the bus? Can you share your dts?

Regards,

Fabio Estevam
--
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: Kconfig: Allow I2C_MXS to be selected by MX23

2012-11-19 Thread Fabio Estevam
Hi Wolfram,

On Mon, Nov 19, 2012 at 6:49 AM, Wolfram Sang w.s...@pengutronix.de wrote:
 On Sat, Nov 17, 2012 at 05:48:54PM -0200, Fabio Estevam wrote:
 From: Fabio Estevam fabio.este...@freescale.com

 With the recent DMA support addition to the i2c-mxs driver, it is now 
 possible
 to also run it on mx23, so update the Kconfig entry accordingly.

 Signed-off-by: Fabio Estevam fabio.este...@freescale.com

 Did you test it?

I don't have the I2C connector board for mx23-olinuxino, but I have
been helping Fadil Berisha (on Cc) to get I2C to work on mx23.

He managed to get I2C working on his mx23 board and posted the results at:
https://www.olimex.com/forum/index.php?topic=283.msg1086#msg1086

He has already sent the dts patches to the ARM kernel list.

Regards,

Fabio Estevam
--
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] i2c: Kconfig: Allow I2C_MXS to be selected by MX23

2012-11-17 Thread Fabio Estevam
From: Fabio Estevam fabio.este...@freescale.com

With the recent DMA support addition to the i2c-mxs driver, it is now possible 
to also run it on mx23, so update the Kconfig entry accordingly.

Signed-off-by: Fabio Estevam fabio.este...@freescale.com
---
 drivers/i2c/busses/Kconfig |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index e9df461..34f48f3 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -482,12 +482,12 @@ config I2C_MV64XXX
  will be called i2c-mv64xxx.
 
 config I2C_MXS
-   tristate Freescale i.MX28 I2C interface
-   depends on SOC_IMX28
+   tristate Freescale MXS I2C interface
+   depends on ARCH_MXS
select STMP_DEVICE
help
  Say Y here if you want to use the I2C bus controller on
- the Freescale i.MX28 processors.
+ the Freescale MXS processors.
 
  This driver can also be built as a module.  If so, the module
  will be called i2c-mxs.
-- 
1.7.9.5

--
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: Kconfig: Allow I2C_MXS to be selected by MX23

2012-11-17 Thread Fabio Estevam
On Sun, Nov 18, 2012 at 3:23 AM, Marek Vasut ma...@denx.de wrote:


 Won't i.MX23/i.MX28 instead of MXS be less confusing? Either way:

 Acked-by: Marek Vasut ma...@denx.de

I kept MXS to let it consistent with other Kconfig files, such as
spi-mxs, mmcmxs, etc.

Thanks,

Fabio Estevam
--
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: mxs: Handle i2c DMA failure properly

2012-11-16 Thread Fabio Estevam
Hi Tim,

On Fri, Nov 16, 2012 at 1:24 PM, Tim Michals tcmich...@gmail.com wrote:

 My suggestion was to always clear the DMA in the reset i2c code.  This way
 if there is an error reported from the ISR or a timeout, it always clears
 it.  I've tested this approach with I2C devices connected and and doing a
 i2cdetect -r 0.

Thanks for the explanation.

Maybe you could post your proposed patch?

Thanks,

Fabio Estevam
--
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: mxs: Handle i2c DMA failure properly

2012-11-14 Thread Fabio Estevam
Hi Marek,

On Wed, Nov 14, 2012 at 12:31 PM, Marek Vasut ma...@denx.de wrote:
 Properly terminate the DMA transfer in case the DMA PIO transfer
 or setup fails for any reason. While at it, enable support for
 SMBUS_QUICK. This essentially fixes i2c-detect on this IP.

Shouldn't this be split into two patches?

Regards,

Fabio Estevam
--
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] MXS: Implement DMA support into mxs-i2c

2012-09-16 Thread Fabio Estevam
Hi Wolfram,

On Sun, Sep 16, 2012 at 7:44 AM, Wolfram Sang w.s...@pengutronix.de wrote:

 Tested-by: Fabio Estevam fabio.este...@freescale.com

 Thanks, may I ask what your tests were?

I used i2c-tools to read/write to an i2c at24 eeprom connected to my mx28evk.

Regards,

Fabio Estevam
--
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] MXS: Implement DMA support into mxs-i2c

2012-08-27 Thread Fabio Estevam
On Fri, Aug 24, 2012 at 12:44 AM, Marek Vasut ma...@denx.de wrote:
 This patch implements DMA support into mxs-i2c. DMA transfers are now enabled
 via DT. The DMA operation is enabled by default.

 Signed-off-by: Marek Vasut ma...@denx.de
 CC: Fabio Estevam fabio.este...@freescale.com
 Cc: linux-i2c@vger.kernel.org
 CC: Shawn Guo shawn@linaro.org
 Cc: Wolfram Sang w.s...@pengutronix.de

On a mx28evk:

Tested-by: Fabio Estevam fabio.este...@freescale.com

Wolfram,

Adding dma support into mxs-i2c has also the benefit to allow i2c on
mx23 to work.

Please consider applying this one.

Thanks,

Fabio Estevam
--
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


I2C_FUNC_SMBUS_QUICK on i2c-mxs

2012-08-27 Thread Fabio Estevam
Hi,

When using i2cdetect on a mx28 I get:

$ i2cdetect 0
Error: Can't use SMBus Quick Write command on this bus (ISA bus?)

Enabling I2C_FUNC_SMBUS_QUICK the error goes away:
---
 drivers/i2c/busses/i2c-mxs.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c
index 088c5c1..84484bb 100644
--- a/drivers/i2c/busses/i2c-mxs.c
+++ b/drivers/i2c/busses/i2c-mxs.c
@@ -322,7 +322,7 @@ static int mxs_i2c_xfer(struct i2c_adapter *adap,
struct i2c_msg msgs[],

 static u32 mxs_i2c_func(struct i2c_adapter *adap)
 {
-   return I2C_FUNC_I2C | (I2C_FUNC_SMBUS_EMUL  ~I2C_FUNC_SMBUS_QUICK);
+   return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
 }

 static irqreturn_t mxs_i2c_isr(int this_irq, void *dev_id)
-- 
1.7.9.5

Could anyone clarify whether I2C_FUNC_SMBUS_QUICK option could be
turned on or not?

Thanks,

Fabio Estevam
--
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] i2c: mxs: Indicate that i2c driver was succesfully registered

2012-08-18 Thread Fabio Estevam
From: Fabio Estevam fabio.este...@freescale.com

It is useful information in dmesg to have a message indicating that the i2c
driver was succesfully registered.

Signed-off-by: Fabio Estevam fabio.este...@freescale.com
--
 drivers/i2c/busses/i2c-mxs.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c
index 088c5c1..619cbc8 100644
--- a/drivers/i2c/busses/i2c-mxs.c
+++ b/drivers/i2c/busses/i2c-mxs.c
@@ -447,6 +447,8 @@ static int __devinit mxs_i2c_probe(struct platform_device 
*pdev)
 
of_i2c_register_devices(adap);
 
+   dev_info(dev, MXS I2C adapter registered\n);
+
return 0;
 }
 
-- 
1.7.9.5

--
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/2] i2c: imx: Use dev_info to indicate that i2c driver was succesfully registered

2012-08-01 Thread Fabio Estevam
From: Fabio Estevam fabio.este...@freescale.com

It is useful information in dmesg to have a message indicating that the i2c
driver was succesfully registered, so promote it to dev_info.

Signed-off-by: Fabio Estevam fabio.este...@freescale.com
---
 drivers/i2c/busses/i2c-imx.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 0722f86..e143629 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -564,7 +564,7 @@ static int __init i2c_imx_probe(struct platform_device 
*pdev)
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);
+   dev_info(i2c_imx-adapter.dev, IMX I2C adapter registered\n);
 
return 0;   /* Return OK */
 }
-- 
1.7.1

--
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 2/2] i2c: imx: Use dev_dbg logging style

2012-08-01 Thread Fabio Estevam
From: Fabio Estevam fabio.este...@freescale.com

Use dev_dbg logging style as it is done in other parts of this driver.

Signed-off-by: Fabio Estevam fabio.este...@freescale.com
---
 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 e143629..2e1d5f4 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -272,9 +272,9 @@ static void __init i2c_imx_set_clk(struct imx_i2c_struct 
*i2c_imx,
 
/* dev_dbg() can't be used, because adapter is not yet registered */
 #ifdef CONFIG_I2C_DEBUG_BUS
-   printk(KERN_DEBUG I2C: %s I2C_CLK=%d, REQ DIV=%d\n,
+   dev_dbg(i2c_imx-adapter.dev, %s I2C_CLK=%d, REQ DIV=%d\n,
__func__, i2c_clk_rate, div);
-   printk(KERN_DEBUG I2C: %s IFDR[IC]=0x%x, REAL DIV=%d\n,
+   dev_dbg(i2c_imx-adapter.dev, %s IFDR[IC]=0x%x, REAL DIV=%d\n,
__func__, i2c_clk_div[i][1], i2c_clk_div[i][0]);
 #endif
 }
-- 
1.7.1

--
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] i2c: i2c-imx: Adapt the clock name to the new clock framework

2012-07-06 Thread Fabio Estevam
With the new i.mx clock framework the i2c clock is registered as:

clk_register_clkdev(clk[i2c1_ipg_gate], NULL, imx-i2c.0)

So we do not need to pass i2c_clk string and can use NULL instead.

Signed-off-by: Fabio Estevam fabio.este...@freescale.com
---
 drivers/i2c/busses/i2c-imx.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 370031a..a8709b1 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -528,7 +528,7 @@ static int __init i2c_imx_probe(struct platform_device 
*pdev)
}
 
/* Get I2C clock */
-   i2c_imx-clk = clk_get(pdev-dev, i2c_clk);
+   i2c_imx-clk = clk_get(pdev-dev, NULL);
if (IS_ERR(i2c_imx-clk)) {
ret = PTR_ERR(i2c_imx-clk);
dev_err(pdev-dev, can't get I2C clock\n);
-- 
1.7.1

--
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] i2c: i2c-smbus: Use module_i2c_driver()

2012-07-02 Thread Fabio Estevam
Using module_i2c_driver() makes the code smaller and cleaner.

Signed-off-by: Fabio Estevam fabio.este...@freescale.com
---
 drivers/i2c/i2c-smbus.c |   13 +
 1 files changed, 1 insertions(+), 12 deletions(-)

diff --git a/drivers/i2c/i2c-smbus.c b/drivers/i2c/i2c-smbus.c
index 9836d08..df3e0bf 100644
--- a/drivers/i2c/i2c-smbus.c
+++ b/drivers/i2c/i2c-smbus.c
@@ -245,18 +245,7 @@ int i2c_handle_smbus_alert(struct i2c_client *ara)
 }
 EXPORT_SYMBOL_GPL(i2c_handle_smbus_alert);
 
-static int __init i2c_smbus_init(void)
-{
-   return i2c_add_driver(smbalert_driver);
-}
-
-static void __exit i2c_smbus_exit(void)
-{
-   i2c_del_driver(smbalert_driver);
-}
-
-module_init(i2c_smbus_init);
-module_exit(i2c_smbus_exit);
+module_i2c_driver(smbalert_driver);
 
 MODULE_AUTHOR(Jean Delvare kh...@linux-fr.org);
 MODULE_DESCRIPTION(SMBus protocol extensions support);
-- 
1.7.1


--
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: mxs: disable QUEUE when sending is done

2012-04-27 Thread Fabio Estevam
Hi Wolfram,

On Fri, Apr 27, 2012 at 11:23 AM, Wolfram Sang w.s...@pengutronix.de wrote:

        if (i2c-cmd_err == -ENXIO)
                mxs_i2c_reset(i2c);
 +       else
 +               writel(MXS_I2C_QUEUECTRL_QUEUE_RUN,
 +                               i2c-regs + MXS_I2C_QUEUECTRL_CLR);

When setting the QUEUE_RUN, do we really want to clear all the other
bits of QUEUECTRL_CLR register?

I am wondering if we should only set QUEUE_RUN bit here.

My mx28evk does not come with i2c eeprom. I hope I will solder one
soon so I can test it.

Thanks,

Fabio Estevam
--
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] i2c: i2c-mxs: Fix build warning

2012-04-05 Thread Fabio Estevam
Fix the following build warning:

drivers/i2c/busses/i2c-mxs.c:207:8: warning: 'data' may be used uninitialized 
in this function [-Wuninitialized]

Signed-off-by: Fabio Estevam fabio.este...@freescale.com
---
 drivers/i2c/busses/i2c-mxs.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c
index 3d471d5..6a24a86 100644
--- a/drivers/i2c/busses/i2c-mxs.c
+++ b/drivers/i2c/busses/i2c-mxs.c
@@ -194,7 +194,7 @@ static int mxs_i2c_wait_for_data(struct mxs_i2c_dev *i2c)
 
 static int mxs_i2c_finish_read(struct mxs_i2c_dev *i2c, u8 *buf, int len)
 {
-   u32 data;
+   u32 data = 0;
int i;
 
for (i = 0; i  len; i++) {
-- 
1.7.1

--
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: i2c-mxs: Fix build warning

2012-04-05 Thread Fabio Estevam
On Thu, Apr 5, 2012 at 5:16 PM, Wolfram Sang w.s...@pengutronix.de wrote:
 On Thu, Apr 05, 2012 at 05:09:55PM -0300, Fabio Estevam wrote:
 Fix the following build warning:

 drivers/i2c/busses/i2c-mxs.c:207:8: warning: 'data' may be used 
 uninitialized in this function [-Wuninitialized]

 Signed-off-by: Fabio Estevam fabio.este...@freescale.com

 Do you agree with the compiler?

After looking at it carefully I conclude that is not possible for
'data' to be used uninitialized.
--
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 6/6] mfd: mc13xxx: Add i2c driver

2012-03-14 Thread Fabio Estevam
Hi Marc,

On Wed, Mar 14, 2012 at 5:43 PM, Marc Reilly m...@cpdesign.com.au wrote:

 +
 +static const struct i2c_device_id mc13xxx_i2c_device_id[] = {
 +       {
 +               .name = mc13783,
 +               .driver_data = MC13XXX_ID_MC13783

mc13783 does not have i2c interface.
--
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] i2c: mxs: Let i2c-mxs be built for MX23

2011-10-21 Thread Fabio Estevam
MX23 and MX28 share the same I2C block, so let i2c-mxs be built for MX23 too.

Signed-off-by: Fabio Estevam fabio.este...@freescale.com
---
 drivers/i2c/busses/Kconfig |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 646068e..08748db 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -456,11 +456,11 @@ config I2C_MV64XXX
  will be called i2c-mv64xxx.
 
 config I2C_MXS
-   tristate Freescale i.MX28 I2C interface
-   depends on SOC_IMX28
+   tristate Freescale i.MXS I2C interface
+   depends on (SOC_IMX28 || SOC_IMX23)
help
  Say Y here if you want to use the I2C bus controller on
- the Freescale i.MX28 processors.
+ the Freescale i.MXS processors.
 
  This driver can also be built as a module.  If so, the module
  will be called i2c-mxs.
-- 
1.7.1


--
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] i2c: mxs: Let i2c-mxs be built for MX23

2011-10-21 Thread Fabio Estevam
MX23 and MX28 share the same I2C block, so let i2c-mxs be built for MX23 too.

Signed-off-by: Fabio Estevam fabio.este...@freescale.com
---
Changes since v1:
- Remove unneeded parenthesis

 drivers/i2c/busses/Kconfig |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 646068e..08748db 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -456,11 +456,11 @@ config I2C_MV64XXX
  will be called i2c-mv64xxx.
 
 config I2C_MXS
-   tristate Freescale i.MX28 I2C interface
-   depends on SOC_IMX28
+   tristate Freescale i.MXS I2C interface
+   depends on SOC_IMX28 || SOC_IMX23
help
  Say Y here if you want to use the I2C bus controller on
- the Freescale i.MX28 processors.
+ the Freescale i.MXS processors.
 
  This driver can also be built as a module.  If so, the module
  will be called i2c-mxs.
-- 
1.7.1


--
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