Re: [PATCH] i2c: i2c-mxs: Fix type of error code

2013-01-07 Thread Marek Vasut
Dear Fabio Estevam,

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

Amazing catch

Acked-by: Marek Vasut 

Can this also go to -stable 3.7 ?

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

Best regards,
Marek Vasut
--
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 

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


[PATCH] i2c-EEPROM: In kernel memory accessor interface

2013-01-07 Thread Pantelis Antoniou
In kernel users need to access the EEPROM using the i2c_client
interface. Extend at24 to use it via the command interface.

Signed-off-by: Pantelis Antoniou 
---
 drivers/misc/eeprom/at24.c | 23 ++
 include/linux/i2c/eeprom.h | 59 ++
 2 files changed, 82 insertions(+)
 create mode 100644 include/linux/i2c/eeprom.h

diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
index 2baeec5..40b1a95 100644
--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /*
  * I2C EEPROMs from most vendors are inexpensive and mostly interchangeable.
@@ -672,6 +673,27 @@ static int at24_remove(struct i2c_client *client)
return 0;
 }
 
+static int at24_command(struct i2c_client *client, unsigned int cmd, void *arg)
+{
+   struct at24_data *at24;
+   const struct memory_accessor **maccp;
+
+   /* only supporting a single command */
+   if (cmd != I2C_EEPROM_GET_MEMORY_ACCESSOR)
+   return -ENOTSUPP;
+
+   /* rudimentary check */
+   if (arg == NULL)
+   return -EINVAL;
+
+   at24 = i2c_get_clientdata(client);
+
+   maccp = arg;
+   *maccp = &at24->macc;
+
+   return 0;
+}
+
 /*-*/
 
 static struct i2c_driver at24_driver = {
@@ -682,6 +704,7 @@ static struct i2c_driver at24_driver = {
.probe = at24_probe,
.remove = at24_remove,
.id_table = at24_ids,
+   .command = at24_command,
 };
 
 static int __init at24_init(void)
diff --git a/include/linux/i2c/eeprom.h b/include/linux/i2c/eeprom.h
new file mode 100644
index 000..1393980
--- /dev/null
+++ b/include/linux/i2c/eeprom.h
@@ -0,0 +1,59 @@
+/*
+ * i2c/eeprom.h
+ *
+ * In-kernel interface for accessing eeprom memory.
+ *
+ * Copyright (C) 2012 Texas Instruments Inc.
+ *Pantelis Antoniou 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+#ifndef I2C_EEPROM_H
+#define I2C_EEPROM_H
+
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * The method called in the client is
+ *
+ * int command(struct i2c_client *client, unsigned int cmd, void *arg);
+ *
+ * A single command is supported, which returns a pointer to the memory
+ * accessor already available, but which was only accessible via platform
+ * callbacks. We can't use platform callbacks anymore for device tree
+ * platforms, hence this interface.
+ *
+ */
+
+/* interface commands */
+#define I2C_EEPROM_GET_MEMORY_ACCESSOR 1
+
+static inline struct memory_accessor *
+i2c_eeprom_get_memory_accessor(struct i2c_client *client)
+{
+   int ret;
+   struct memory_accessor *macc;
+
+   /* verify that the i2c client's driver has a command method */
+   if (!client || !client->driver || !client->driver->command)
+   return ERR_PTR(-ENOTSUPP);
+
+   macc = NULL;
+   ret = client->driver->command(client, I2C_EEPROM_GET_MEMORY_ACCESSOR,
+   &macc);
+   if (ret != 0)
+   return ERR_PTR(ret);
+
+   if (macc == NULL)
+   return ERR_PTR(-ENOTSUPP);
+
+   return macc;
+}
+
+#endif
-- 
1.7.12

--
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: tegra: add support for Tegra114 SoC

2013-01-07 Thread Stephen Warren
On 01/05/2013 05:04 AM, Laxman Dewangan wrote:
> NVIDIA's Tegra114 has following enhanced feature in i2c controller:
> - Enable/disable control for per packet transfer complete interrupt.
>   Earlier SoCs could not disable this.
> - Single clock source for standard/fast and HS mode clock speed.
>   The clock divisor for fast/standard mode is added into the i2c
>   controller to meet the HS and standard/fast mode of clock speed
>   from single source.
> 
> Add support for the above feature to make it functional on T114 SOCs.

Reviewed-by: Stephen Warren 

--
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: samsung: resume race fix

2013-01-07 Thread Jean Delvare
On Mon, 7 Jan 2013 17:35:25 +0530, Naveen Krishna Ch wrote:
> On 7 November 2012 16:14, Jean Delvare  wrote:
> > On Wed, 07 Nov 2012 15:58:26 +0530, Naveen Krishna Chatradhi wrote:
> >> Don't unmark the device as suspended until after it's been re-setup.
> >>
> >> The main race would be w.r.t. an i2c driver that gets resumed at the same
> >> time (asyncronously), that is allowed to do a transfer since suspended
> >> is set to 0 before reinit, but really should have seen the -EIO return
> >> instead.
> >>
> >> Signed-off-by: Olof Johansson 
> >> Signed-off-by: Naveen Krishna Chatradhi 
> >> ---
> >>  drivers/i2c/busses/i2c-s3c2410.c |2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/i2c/busses/i2c-s3c2410.c 
> >> b/drivers/i2c/busses/i2c-s3c2410.c
> >> index 3e0335f..dbaf920 100644
> >> --- a/drivers/i2c/busses/i2c-s3c2410.c
> >> +++ b/drivers/i2c/busses/i2c-s3c2410.c
> >> @@ -1134,10 +1134,10 @@ static int s3c24xx_i2c_resume(struct device *dev)
> >>   struct platform_device *pdev = to_platform_device(dev);
> >>   struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev);
> >>
> >> - i2c->suspended = 0;
> >>   clk_prepare_enable(i2c->clk);
> >>   s3c24xx_i2c_init(i2c);
> >>   clk_disable_unprepare(i2c->clk);
> >> + i2c->suspended = 0;
> >>
> >>   return 0;
> >>  }
> >
> > Acked-by: Jean Delvare 
> I don't see this patch landed any where in linux-i2c tree, Though it was 
> acked.
> Was it missed or should i be doing something for this to be merged ??

Nothing needed from your side AFAIK, Wolfram should pick patches when I
ack them, maybe this one was simply overlooked.

-- 
Jean Delvare
--
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: samsung: resume race fix

2013-01-07 Thread Naveen Krishna Ch
On 7 November 2012 16:14, Jean Delvare  wrote:
> On Wed, 07 Nov 2012 15:58:26 +0530, Naveen Krishna Chatradhi wrote:
>> Don't unmark the device as suspended until after it's been re-setup.
>>
>> The main race would be w.r.t. an i2c driver that gets resumed at the same
>> time (asyncronously), that is allowed to do a transfer since suspended
>> is set to 0 before reinit, but really should have seen the -EIO return
>> instead.
>
> I thought that the suspend order was children first and the resume
> order was parent first?
>
> If this can really happen then I am afraid this is an issue for more
> than just i2c-s3c2410. The proposed solution is also not really
> satisfactory, as the i2c client will certainly still fail to resume
> properly (the only improvement is that now the failure is no longer
> silent.)
>
>>
>> Signed-off-by: Olof Johansson 
>> Signed-off-by: Naveen Krishna Chatradhi 
>> ---
>>  drivers/i2c/busses/i2c-s3c2410.c |2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-s3c2410.c 
>> b/drivers/i2c/busses/i2c-s3c2410.c
>> index 3e0335f..dbaf920 100644
>> --- a/drivers/i2c/busses/i2c-s3c2410.c
>> +++ b/drivers/i2c/busses/i2c-s3c2410.c
>> @@ -1134,10 +1134,10 @@ static int s3c24xx_i2c_resume(struct device *dev)
>>   struct platform_device *pdev = to_platform_device(dev);
>>   struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev);
>>
>> - i2c->suspended = 0;
>>   clk_prepare_enable(i2c->clk);
>>   s3c24xx_i2c_init(i2c);
>>   clk_disable_unprepare(i2c->clk);
>> + i2c->suspended = 0;
>>
>>   return 0;
>>  }
>
> Acked-by: Jean Delvare 
I don't see this patch landed any where in linux-i2c tree, Though it was acked.
Was it missed or should i be doing something for this to be merged ??
>
> (Not perfect but still better than before.)
>
> --
> Jean Delvare



-- 
Shine bright,
(: Nav :)
--
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/2] i2c-s3c2410: Leave the bus disabled unless it is in use

2013-01-07 Thread Naveen Krishna Ch
On 29 November 2012 20:14, Kyungmin Park  wrote:
> Acked-by: Kyungmin Park 

I don't see this patch landed any where in linux-i2c tree, Though it was acked.
Was it missed or should i be doing something for this to be merged ??

>
> On Thu, Nov 29, 2012 at 2:05 PM, Naveen Krishna Chatradhi
>  wrote:
>> From: Simon Glass 
>>
>> There is a rather odd feature of the exynos i2c controller that if it
>> is left enabled, it can lock itself up with the clk line held low.
>> This makes the bus unusable.
>>
>> Unfortunately, the s3c24xx_i2c_set_master() function does not notice
>> this, and reports a timeout. From then on the bus cannot be used until
>> the AP is rebooted.
>>
>> The problem happens when any sort of interrupt occurs (e.g. due to a
>> bus transition) when we are not in the middle of a transaction. We
>> have seen many instances of this when U-Boot leaves the bus apparently
>> happy, but Linux cannot access it.
>>
>> The current code is therefore pretty fragile.
>>
>> This fixes things by leaving the bus disabled unless we are actually
>> in a transaction. We enable the bus at the start of the transaction and
>> disable it at the end. That way we won't get interrupts and will not
>> lock up the bus.
>>
>> It might be possible to clear pending interrupts on start-up, but this
>> seems to be a more robust solution. We can't service interrupts when
>> we are not in a transaction, and anyway would rather not lock up the
>> bus while we try.
>>
>> Signed-off-by: Simon Glass 
>> Cc: Grant Grundler 
>> Signed-off-by: Naveen Krishna Chatradhi 
>> ---
>>  drivers/i2c/busses/i2c-s3c2410.c |   37 
>> +
>>  1 file changed, 33 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-s3c2410.c 
>> b/drivers/i2c/busses/i2c-s3c2410.c
>> index e93e7d6..2fd346d 100644
>> --- a/drivers/i2c/busses/i2c-s3c2410.c
>> +++ b/drivers/i2c/busses/i2c-s3c2410.c
>> @@ -186,6 +186,31 @@ static inline void s3c24xx_i2c_enable_irq(struct 
>> s3c24xx_i2c *i2c)
>> writel(tmp | S3C2410_IICCON_IRQEN, i2c->regs + S3C2410_IICCON);
>>  }
>>
>> +/*
>> + * Disable the bus so that we won't get any interrupts from now on, or try
>> + * to drive any lines. This is the default state when we don't have
>> + * anything to send/receive.
>> + *
>> + * If there is an event on the bus, or we have a pre-existing event at
>> + * kernel boot time, we may not notice the event and the I2C controller
>> + * will lock the bus with the I2C clock line low indefinitely.
>> + */
>> +static inline void s3c24xx_i2c_disable_bus(struct s3c24xx_i2c *i2c)
>> +{
>> +   unsigned long tmp;
>> +
>> +   /* Stop driving the I2C pins */
>> +   tmp = readl(i2c->regs + S3C2410_IICSTAT);
>> +   tmp &= ~S3C2410_IICSTAT_TXRXEN;
>> +   writel(tmp, i2c->regs + S3C2410_IICSTAT);
>> +
>> +   /* We don't expect any interrupts now, and don't want send acks */
>> +   tmp = readl(i2c->regs + S3C2410_IICCON);
>> +   tmp &= ~(S3C2410_IICCON_IRQEN | S3C2410_IICCON_IRQPEND |
>> +   S3C2410_IICCON_ACKEN);
>> +   writel(tmp, i2c->regs + S3C2410_IICCON);
>> +}
>> +
>>
>>  /* s3c24xx_i2c_message_start
>>   *
>> @@ -646,7 +671,11 @@ static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c,
>>
>> s3c24xx_i2c_wait_idle(i2c);
>>
>> +   s3c24xx_i2c_disable_bus(i2c);
>> +
>>   out:
>> +   i2c->state = STATE_IDLE;
>> +
>> return ret;
>>  }
>>
>> @@ -912,7 +941,6 @@ static void s3c24xx_i2c_dt_gpio_free(struct s3c24xx_i2c 
>> *i2c)
>>
>>  static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c)
>>  {
>> -   unsigned long iicon = S3C2410_IICCON_IRQEN | S3C2410_IICCON_ACKEN;
>> struct s3c2410_platform_i2c *pdata;
>> unsigned int freq;
>>
>> @@ -926,12 +954,12 @@ static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c)
>>
>> dev_info(i2c->dev, "slave address 0x%02x\n", pdata->slave_addr);
>>
>> -   writel(iicon, i2c->regs + S3C2410_IICCON);
>> +   writel(0, i2c->regs + S3C2410_IICCON);
>> +   writel(0, i2c->regs + S3C2410_IICSTAT);
>>
>> /* we need to work out the divisors for the clock... */
>>
>> if (s3c24xx_i2c_clockrate(i2c, &freq) != 0) {
>> -   writel(0, i2c->regs + S3C2410_IICCON);
>> dev_err(i2c->dev, "cannot meet bus frequency required\n");
>> return -EINVAL;
>> }
>> @@ -939,7 +967,8 @@ static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c)
>> /* todo - check that the i2c lines aren't being dragged anywhere */
>>
>> dev_info(i2c->dev, "bus frequency set to %d KHz\n", freq);
>> -   dev_dbg(i2c->dev, "S3C2410_IICCON=0x%02lx\n", iicon);
>> +   dev_dbg(i2c->dev, "S3C2410_IICCON=0x%02x\n",
>> +   readl(i2c->regs + S3C2410_IICCON));
>>
>> return 0;
>>  }
>> --
>> 1.7.9.5
>>
>>
>> ___
>> linux-arm-kernel mailing list
>> linux-arm-ker...@lists.infradead.org
>> http://lists.infradead.org/mailman/listin

Re: [PATCH V8 1/2] i2c/adapter: Add bus recovery infrastructure

2013-01-07 Thread Viresh Kumar
On 20 December 2012 14:47, Viresh Kumar  wrote:
> On 19 December 2012 05:30, Wolfram Sang  wrote:
>> Since I missed the things Paul luckily spotted, I think it might make
>> sense to actually use the framework myself to get me a better feeling
>> that I have not missed anything else. So, I am going to add support for
>> another I2C master controller to your framework and see what will happen
>> when I actually use it. It will be probably the mxs controller, I
>> collected the hardware for that already...
>
> Nothing could be better than that :)

Hi Wolfram,

HNY '13.

You got some chance to test this stuff ?
--
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