linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vincenzo Frascino <vincenzo.frascino-qxv4g6HH51o@public.gmane.org>
To: Shubhrajyoti Datta
	<omaplinuxkernel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Viresh KUMAR <viresh.kumar-qxv4g6HH51o@public.gmane.org>,
	"khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org"
	<khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>,
	"ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org"
	<ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org>,
	"w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org"
	<w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>,
	Armando VISCONTI <armando.visconti-qxv4g6HH51o@public.gmane.org>,
	Shiraz HASHIM <shiraz.hashim-qxv4g6HH51o@public.gmane.org>,
	Vipin KUMAR <vipin.kumar-qxv4g6HH51o@public.gmane.org>,
	Rajeev KUMAR <rajeev-dlh.kumar-qxv4g6HH51o@public.gmane.org>,
	Deepak SIKRI <deepak.sikri-qxv4g6HH51o@public.gmane.org>,
	Vipul Kumar SAMAR <vipulkumar.samar-qxv4g6HH51o@public.gmane.org>,
	Amit VIRDI <Amit.VIRDI-qxv4g6HH51o@public.gmane.org>,
	Pratyush ANAND <pratyush.anand-qxv4g6HH51o@public.gmane.org>,
	Bhupesh SHARMA <bhupesh.sharma-qxv4g6HH51o@public.gmane.org>,
	"viresh.linux-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org"
	<viresh.linux-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Bhavna YADAV <bhavna.yadav-qxv4g6HH51o@public.gmane.org>,
	Mirko GARDI <mirko.gardi-qxv4g6HH51o@public.gmane.org>,
	Salvatore DE DOMINICIS
	<salvatore.dedominicis-qxv4g6HH51o@public.gmane.org>,
	"linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH 2/2] i2c/designware: Provide optional i2c bus recovery function
Date: Mon, 27 Feb 2012 10:12:15 +0100	[thread overview]
Message-ID: <4F4B48EF.3030906@st.com> (raw)
In-Reply-To: <CAM=Q2cudYcSqAKk4qNg7MQxRBCkJ-XXXSL-Bg=sZ2+hvS_Qcxw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

Hi Shubhrajyoti,

Il 27/02/2012 08:21, Shubhrajyoti Datta ha scritto:
> On Fri, Feb 24, 2012 at 5:01 PM, Viresh Kumar <viresh.kumar-qxv4g6HH51o@public.gmane.org> wrote:
>> From: Vincenzo Frascino <vincenzo.frascino-qxv4g6HH51o@public.gmane.org>
>>
>> Add optional i2c_recover_bus() function to the Synopsys DesignWare I2C adapter
>> driver that performs i2c bus recovery after timeout. The scope of this routine
>> is to define i2c bus recovery procedure as specified in the i2c protocol Rev. 03
>> section 3.16 titled "Bus clear".
> What do you do in the function ?
With this function we provide the bus clear procedure for i2c recovery as
described in the the i2c protocol Rev. 03 section 3.16 titled "Bus clear".
>
> Could we have it in the driver file itself?
As it is thought now, it's implementation depends a little bit from the platform
we are using, but, sure, it can be generalized and put into the driver.
>
>> Since the Designware I2C controller doesn't provide direct control over SDA and
>> SCL lines hence the intent is to let platform try to recover the bus if they
>> have the capability to take control of I2C pads and follow the recovery
>> protocol.
> So the function is passed in the pdata.
Yes, it is.
>> Signed-off-by: Vincenzo Frascino <vincenzo.frascino-qxv4g6HH51o@public.gmane.org>
>> Signed-off-by: Shiraz Hashim <shiraz.hashim-qxv4g6HH51o@public.gmane.org>
>> Signed-off-by: Viresh Kumar <viresh.kumar-qxv4g6HH51o@public.gmane.org>
>> ---
>>  drivers/i2c/busses/i2c-designware-core.c    |    4 +++
>>  drivers/i2c/busses/i2c-designware-core.h    |    3 +-
>>  drivers/i2c/busses/i2c-designware-platdrv.c |    8 ++++++
>>  include/linux/i2c/i2c-designware.h          |   33 +++++++++++++++++++++++++++
>>  4 files changed, 47 insertions(+), 1 deletions(-)
>>  create mode 100644 include/linux/i2c/i2c-designware.h
>>
>> diff --git a/drivers/i2c/busses/i2c-designware-core.c b/drivers/i2c/busses/i2c-designware-core.c
>> index df87992..91d9357 100644
>> --- a/drivers/i2c/busses/i2c-designware-core.c
>> +++ b/drivers/i2c/busses/i2c-designware-core.c
>> @@ -525,6 +525,10 @@ i2c_dw_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
>>        ret = wait_for_completion_interruptible_timeout(&dev->cmd_complete, HZ);
>>        if (ret == 0) {
>>                dev_err(dev->dev, "controller timed out\n");
>> +               if (dev->i2c_recover_bus) {
>> +                       dev_info(dev->dev, "try i2c bus recovery\n");
>> +                       dev->i2c_recover_bus(dev->recovery_data);
>> +               }
>>                i2c_dw_init(dev);
>>                ret = -ETIMEDOUT;
>>                goto done;
>> diff --git a/drivers/i2c/busses/i2c-designware-core.h b/drivers/i2c/busses/i2c-designware-core.h
>> index 02d1a2d..e2f3119 100644
>> --- a/drivers/i2c/busses/i2c-designware-core.h
>> +++ b/drivers/i2c/busses/i2c-designware-core.h
>> @@ -34,7 +34,6 @@
>>  #define DW_IC_CON_RESTART_EN           0x20
>>  #define DW_IC_CON_SLAVE_DISABLE                0x40
>>
>> -
>>  /**
>>  * struct dw_i2c_dev - private i2c-designware data
>>  * @dev: driver model device node
>> @@ -88,6 +87,8 @@ struct dw_i2c_dev {
>>        u32                     master_cfg;
>>        unsigned int            tx_fifo_depth;
>>        unsigned int            rx_fifo_depth;
>> +       void                    (*i2c_recover_bus)(void *);
>> +       void                    *recovery_data;
>>  };
>>
>>  extern u32 dw_readl(struct dw_i2c_dev *dev, int offset);
>> diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
>> index c5ac2dc..2237398 100644
>> --- a/drivers/i2c/busses/i2c-designware-platdrv.c
>> +++ b/drivers/i2c/busses/i2c-designware-platdrv.c
>> @@ -29,6 +29,7 @@
>>  #include <linux/module.h>
>>  #include <linux/delay.h>
>>  #include <linux/i2c.h>
>> +#include <linux/i2c/i2c-designware.h>
>>  #include <linux/clk.h>
>>  #include <linux/errno.h>
>>  #include <linux/sched.h>
>> @@ -55,6 +56,7 @@ static int __devinit dw_i2c_probe(struct platform_device *pdev)
>>        struct dw_i2c_dev *dev;
>>        struct i2c_adapter *adap;
>>        struct resource *mem, *ioarea;
>> +       struct i2c_dw_pdata *pdata;
>>        int irq, r;
>>
>>        /* NOTE: driver uses the static register mapping */
>> @@ -98,6 +100,12 @@ static int __devinit dw_i2c_probe(struct platform_device *pdev)
>>        }
>>        clk_enable(dev->clk);
>>
>> +       pdata = dev_get_platdata(&pdev->dev);
>> +       if (pdata && pdata->i2c_recover_bus) {
>> +               dev->i2c_recover_bus = pdata->i2c_recover_bus;
>> +               dev->recovery_data = &pdev;
>> +       }
>> +
>>        dev->functionality =
>>                I2C_FUNC_I2C |
>>                I2C_FUNC_10BIT_ADDR |
>> diff --git a/include/linux/i2c/i2c-designware.h b/include/linux/i2c/i2c-designware.h
>> new file mode 100644
>> index 0000000..e40ad85
>> --- /dev/null
>> +++ b/include/linux/i2c/i2c-designware.h
>> @@ -0,0 +1,33 @@
>> +/*
>> + * Synopsys DesignWare I2C adapter driver's platform data
>> + *
>> + * Copyright (C) 2012 ST Microelectronics.
>> + * Author: Vincenzo Frascino <vincenzo.frascino-qxv4g6HH51o@public.gmane.org>
>> + *
>> + * This software is licensed under the terms of the GNU General Public
>> + * License version 2, as published by the Free Software Foundation, and
>> + * may be copied, distributed, and modified under those terms.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> + * GNU General Public License for more details.
>> + *
>> + */
>> +#ifndef I2C_DESIGNWARE_H
>> +#define I2C_DESIGNWARE_H
>> +
>> +#include <linux/platform_device.h>
>> +
>> +/* I2C Designware Platform Data */
>> +struct i2c_dw_pdata {
>> +       /*
>> +        * The scope of this routine is to define i2c bus recovery procedure
>> +        * as specified in the i2c protocol Rev. 03 section 3.16 titled
>> +        * "Bus clear".
>> +        * Its implementation is platform dependant.
>> +        */
>> +       void (*i2c_recover_bus)(void *);
>> +};
>> +
>> +#endif /* I2C_DESIGNWARE_H */
>> --
>> 1.7.8.110.g4cb5d
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
>> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Thanks for the comments,

Vincenzo Frascino

  parent reply	other threads:[~2012-02-27  9:12 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-24 11:31 [PATCH 1/2] i2c/busses: Add PM support Viresh Kumar
     [not found] ` <0ca1d8990c23a45193a32d0e7e889620b995af59.1330082915.git.viresh.kumar-qxv4g6HH51o@public.gmane.org>
2012-02-24 11:31   ` [PATCH 2/2] i2c/designware: Provide optional i2c bus recovery function Viresh Kumar
     [not found]     ` <351031347b845920a0ea78e7491d955137e3d7aa.1330082915.git.viresh.kumar-qxv4g6HH51o@public.gmane.org>
2012-02-27  7:21       ` Shubhrajyoti Datta
     [not found]         ` <CAM=Q2cudYcSqAKk4qNg7MQxRBCkJ-XXXSL-Bg=sZ2+hvS_Qcxw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-02-27  7:27           ` Laxman Dewangan
     [not found]             ` <4F4B3072.6050903-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2012-02-27  8:10               ` Rajeev kumar
     [not found]                 ` <4F4B3A62.4080409-qxv4g6HH51o@public.gmane.org>
2012-02-27  8:22                   ` Laxman Dewangan
     [not found]                     ` <4F4B3D54.4010502-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2012-02-27  8:41                       ` Rajeev kumar
     [not found]                         ` <4F4B41CF.7080603-qxv4g6HH51o@public.gmane.org>
2012-02-27  8:45                           ` Laxman Dewangan
2012-02-27  9:12               ` Shubhrajyoti Datta
     [not found]                 ` <CAM=Q2cs-nCuSmkBFtv4odbqoRJcPkXk4Rz-H=9S6RDG3Z8kcEQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-02-27  9:19                   ` Laxman Dewangan
2012-02-27 10:10                   ` Rajeev kumar
     [not found]                     ` <4F4B569F.3080607-qxv4g6HH51o@public.gmane.org>
2012-02-27 10:27                       ` Viresh Kumar
     [not found]                         ` <4F4B5A9A.4050303-qxv4g6HH51o@public.gmane.org>
2012-02-28 13:23                           ` viresh kumar
     [not found]                             ` <CAOh2x=nfNGpBmHVd1bPT9+AezDMEjaC4ktj4hX9=yWg2_k7r3Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-02-28 13:55                               ` Salvatore DE DOMINICIS
     [not found]                                 ` <4E01B0DA4B09044DB320A047A7063F8DCA93DAA13E-+EwDPpWUVoSs+H57zxxw29BPR1lH4CV8@public.gmane.org>
2012-02-28 14:05                                   ` Vincenzo Frascino
2012-02-29  4:58                                   ` Viresh Kumar
     [not found]                                     ` <4F4DB073.9030906-qxv4g6HH51o@public.gmane.org>
2012-02-29  8:59                                       ` Vincenzo Frascino
2012-03-01 13:45                                       ` Michael Lawnick
2012-02-29 11:52                               ` Laxman Dewangan
     [not found]                                 ` <4F4E118B.2030403-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2012-02-29 11:58                                   ` Viresh Kumar
     [not found]                                     ` <4F4E12D9.90909-qxv4g6HH51o@public.gmane.org>
2012-02-29 12:18                                       ` Laxman Dewangan
     [not found]                                         ` <4F4E1797.7010503-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2012-02-29 17:58                                           ` viresh kumar
     [not found]                                 ` <CAOh2x=mrO+7UBK=nbGLQsVzj5YmOfuh1RAiA4qznXe8nt6pRKA@mail.gmail.com>
     [not found]                                   ` <4F4F12EC.1020703@nvidia.com>
     [not found]                                     ` <4F4F12EC.1020703-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2012-03-01  6:35                                       ` Viresh Kumar
2012-07-02  5:58                       ` Rajeev kumar
     [not found]                         ` <4FF1388B.4030108-qxv4g6HH51o@public.gmane.org>
2012-07-02  6:32                           ` Shubhrajyoti Datta
     [not found]                             ` <CAM=Q2ct+z_bGYvaOvAQ=AEzOSNh4Uob-HY-DemsYeS-mB-juEg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-07-02  6:55                               ` Rajeev kumar
2012-02-27  9:12           ` Vincenzo Frascino [this message]
2012-03-23  8:10   ` [PATCH 1/2] i2c/busses: Add PM support Viresh Kumar
2012-04-22 18:24   ` Wolfram Sang

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=4F4B48EF.3030906@st.com \
    --to=vincenzo.frascino-qxv4g6hh51o@public.gmane.org \
    --cc=Amit.VIRDI-qxv4g6HH51o@public.gmane.org \
    --cc=armando.visconti-qxv4g6HH51o@public.gmane.org \
    --cc=ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org \
    --cc=bhavna.yadav-qxv4g6HH51o@public.gmane.org \
    --cc=bhupesh.sharma-qxv4g6HH51o@public.gmane.org \
    --cc=deepak.sikri-qxv4g6HH51o@public.gmane.org \
    --cc=khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mirko.gardi-qxv4g6HH51o@public.gmane.org \
    --cc=omaplinuxkernel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=pratyush.anand-qxv4g6HH51o@public.gmane.org \
    --cc=rajeev-dlh.kumar-qxv4g6HH51o@public.gmane.org \
    --cc=salvatore.dedominicis-qxv4g6HH51o@public.gmane.org \
    --cc=shiraz.hashim-qxv4g6HH51o@public.gmane.org \
    --cc=vipin.kumar-qxv4g6HH51o@public.gmane.org \
    --cc=vipulkumar.samar-qxv4g6HH51o@public.gmane.org \
    --cc=viresh.kumar-qxv4g6HH51o@public.gmane.org \
    --cc=viresh.linux-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org \
    /path/to/YOUR_REPLY

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

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