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

2012-02-24 Thread Barry Song
hi Shubhrajyoti,

2012/2/17 Shubhrajyoti Datta :
> Hello,
>
> On Wed, Feb 8, 2012 at 8:58 PM, Barry Song <21cn...@gmail.com> wrote:
>> From: Zhiwu Song 
>>
>> SiRFprimaII is the latest generation application processor from CSR’s
>> multi-function SoC product family.
>> The SoC support codes are in arch/arm/mach-prima2 from Linux mainline
>> 3.0.
>> There are two I2C controllers on primaII, features include:
>> * Two I2C controller modules are on chip
>> * RISC I/O bus read write register
>> * Up to 16 bytes data buffer for issuing commands and writing data
>>  at the same time
>> * Up to 16 commands, and receiving read data 16 bytes at a time
>> * Error INT report (ACK check)
>> * No-ACK bus protocols (SCCB bus protocols)
>>
>> Signed-off-by: Zhiwu Song 
>> Signed-off-by: Xiangzhen Ye 
>> Signed-off-by: Yuping Luo 
>> Signed-off-by: Barry Song 
>> ---
>>  -v6:
>>  fix/cleanup lots of minor issues pointed out by wolfram;
>>  add OF property clock-frequency to support freq setting by DT;
>>  add lost devicetree binding document;
>>
>>  Documentation/devicetree/bindings/i2c/sirf-i2c.txt |   19 +
>>  drivers/i2c/busses/Kconfig                         |   10 +
>>  drivers/i2c/busses/Makefile                        |    1 +
>>  drivers/i2c/busses/i2c-sirf.c                      |  459 
>> 
>>  4 files changed, 489 insertions(+), 0 deletions(-)
>>  create mode 100644 Documentation/devicetree/bindings/i2c/sirf-i2c.txt
>>  create mode 100644 drivers/i2c/busses/i2c-sirf.c
>>
>> diff --git a/Documentation/devicetree/bindings/i2c/sirf-i2c.txt 
>> b/Documentation/devicetree/bindings/i2c/sirf-i2c.txt
>> new file mode 100644
>> index 000..7baf9e1
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/i2c/sirf-i2c.txt
> 
>
>> +
>> +               if (i2c_stat & SIRFSOC_I2C_STAT_NACK)
>> +                       dev_err(&siic->adapter.dev, "ACK not received\n");
> Could we send stop here?

no. when the interrupt happens and goes into the irq, the whole i2c hw
sequence has finished.

>> +               else
>> +                       dev_err(&siic->adapter.dev, "I2C error\n");
>> +
>> +               complete(&siic->done);
> 
>
>> +static int i2c_sirfsoc_resume(struct device *dev)
>> +{
>> +       struct platform_device *pdev = to_platform_device(dev);
>> +       struct i2c_adapter *adapter = platform_get_drvdata(pdev);
>> +       struct sirfsoc_i2c *siic = adapter->algo_data;
>> +
>> +       clk_enable(siic->clk);
>> +       writel(SIRFSOC_I2C_RESET, siic->base + SIRFSOC_I2C_CTRL);
> Could you explain why is a reset needed.
> Or am I missing something.

this is helping the i2c controller restore to a stable status. this
reset is not always needed, but it is sure that it can help to fix
some unstable issues of hardware if they do exist.

>
>> +       writel(SIRFSOC_I2C_CORE_EN | SIRFSOC_I2C_MASTER_MODE,
>> +               siic->base + SIRFSOC_I2C_CTRL);
>> +       writel(siic->clk_div, siic->base + SIRFSOC_I2C_CLK_CTRL);
>> +       writel(siic->sda_delay, siic->base + SIRFSOC_I2C_SDA_DELAY);
>> +       clk_disable(siic->clk);
>> +       return 0;
>> +}
>> +
>> +static const struct dev_pm_ops i2c_sirfsoc_pm_ops = {
>> +       .suspend = i2c_sirfsoc_suspend,
>> +       .resume = i2c_sirfsoc_resume,
> Could we use simple dev_pm ops here?

i guess you mean SIMPLE_DEV_PM_OPS. the only problem is i2c bus driver
doesn't need entries like:
 .freeze = suspend_fn, \
 .thaw = resume_fn, \
 .poweroff = suspend_fn, \
 .restore = resume_fn,

at least in our test, without these entries,  suspend to ram, suspend
to disk(hibernation) and poweroff have always worked well.

>
>> +};
>> +#endif
>> +
>> +static const struct of_device_id sirfsoc_i2c_of_match[] __devinitconst = {
>> +       { .compatible = "sirf,prima2-i2c", },

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


Current status of my for-3.3/for-3.4 branches

2012-02-24 Thread Wolfram Sang
Hi all (and Ben),

here is how my current branches look like:

=== for-3.3

The following changes since commit b01543dfe67bb1d191998e90d20534dc354de059:

  Linux 3.3-rc4 (2012-02-18 15:53:33 -0800)

are available in the git repository at:
  git://git.pengutronix.de/git/wsa/linux-2.6.git i2c-embedded/for-3.3

Wolfram Sang (1):
  i2c: mxs: only flag completion when queue is completely done

 drivers/i2c/busses/i2c-mxs.c |   13 ++---
 1 files changed, 10 insertions(+), 3 deletions(-)

=== for-3.4

The following changes since commit b01543dfe67bb1d191998e90d20534dc354de059:

  Linux 3.3-rc4 (2012-02-18 15:53:33 -0800)

are available in the git repository at:
  git://git.pengutronix.de/git/wsa/linux-2.6.git i2c-embedded/for-3.4

Ganesan Ramalingam (1):
  i2c: Support for Netlogic XLR/XLS I2C controller.

Jayachandran C (1):
  i2c: Move I2C_EG20T option to the right place.

Pawel Moll (1):
  i2c: versatile: Add Device Tree support

Tang Yuantian (1):
  i2c: mpc: Add support for SMBUS_READ_BLOCK_DATA

Wolfram Sang (1):
  misc: at24: describe platform_data with kernel_doc

 drivers/i2c/busses/Kconfig |   34 +++--
 drivers/i2c/busses/Makefile|3 +-
 drivers/i2c/busses/i2c-mpc.c   |   63 +++--
 drivers/i2c/busses/i2c-versatile.c |   10 ++
 drivers/i2c/busses/i2c-xlr.c   |  278 
 include/linux/i2c/at24.h   |   35 -
 6 files changed, 390 insertions(+), 33 deletions(-)
 create mode 100644 drivers/i2c/busses/i2c-xlr.c

===

Ben, can you pull these into your trees? If you don't have time right now I can
also send them directly.

There have been patches from Oskar and Viresh lately which look good to me, but
I'll give people some more time to comment on them. The driver by Barry has
outstanding comments. I decided to leave the Samsung related patches to Ben, he
knows that platform way better. Any other patches pending I missed so far?

Regards,

   Wolfram

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


signature.asc
Description: Digital signature


Re: [PATCH] i2c multiplexer driver for Proliant microserver N36L

2012-02-24 Thread Thomas Brandon
Here is the modified patch. As this is my first attempt at submitting
a patch while it obviously isn't ready for inclusion given the errors
any feedback on general style would be welcome.

Tom.

--- linux-3.2.1-gentoo-r2/drivers/i2c/busses/i2c-piix4.c2012-01-05
10:55:44.0 +1100
+++ dev/drivers/i2c/busses/i2c-piix4.c  2012-02-25 04:53:04.743198258 +1100
@@ -25,7 +25,10 @@
AMD Hudson-2
SMSC Victory66

-   Note: we assume there can only be one device, with one SMBus interface.
+   Note: we assume there can only be one device.
+   The device can register multiple i2c_adapters (up to PIIX4_MAX_ADAPTERS).
+   For devices supporting multiple ports the i2c_adapter should provide
+   an i2c_algorithm to access them.
 */

 #include 
@@ -40,6 +43,7 @@
 #include 
 #include 
 #include 
+#include 


 /* PIIX4 SMBus address offsets */
@@ -78,6 +82,9 @@
 #define PIIX4_WORD_DATA0x0C
 #define PIIX4_BLOCK_DATA   0x14

+/* Multi-port constants */
+#define PIIX4_MAX_ADAPTERS 4
+
 /* insmod parameters */

 /* If force is set to anything different from 0, we forcibly enable the
@@ -97,7 +104,15 @@ MODULE_PARM_DESC(force_addr,
 static unsigned short piix4_smba;
 static int srvrworks_csb5_delay;
 static struct pci_driver piix4_driver;
-static struct i2c_adapter piix4_adapter;
+static struct i2c_adapter *piix4_adapters[PIIX4_MAX_ADAPTERS];
+
+/* SB800 globals */
+DEFINE_MUTEX(piix4_mutex_sb800);
+static u8 piix4_adapter_ports_sb800[4];
+static u8 piix4_sel_port_sb800 = -1;
+static const char *piix4_port_names_sb800[4] = {
+   "SDA0", "SDA2", "SDA3", "SDA4"
+};

 static struct dmi_system_id __devinitdata piix4_dmi_blacklist[] = {
{
@@ -284,6 +299,8 @@ static int __devinit piix4_setup_sb800(s
else
dev_dbg(&PIIX4_dev->dev, "Using SMI# for SMBus.\n");

+   mutex_init(&piix4_mutex_sb800);
+
dev_info(&PIIX4_dev->dev,
 "SMBus Host Controller at 0x%x, revision %d\n",
 piix4_smba, i2ccfg >> 4);
@@ -291,27 +308,27 @@ static int __devinit piix4_setup_sb800(s
return 0;
 }

-static int piix4_transaction(void)
+static int piix4_transaction(struct i2c_adapter *adap)
 {
int temp;
int result = 0;
int timeout = 0;

-   dev_dbg(&piix4_adapter.dev, "Transaction (pre): CNT=%02x, CMD=%02x, "
+   dev_dbg(&adap->dev, "Transaction (pre): CNT=%02x, CMD=%02x, "
"ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTCNT),
inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0),
inb_p(SMBHSTDAT1));

/* Make sure the SMBus host is ready to start transmitting */
if ((temp = inb_p(SMBHSTSTS)) != 0x00) {
-   dev_dbg(&piix4_adapter.dev, "SMBus busy (%02x). "
+   dev_dbg(&adap->dev, "SMBus busy (%02x). "
"Resetting...\n", temp);
outb_p(temp, SMBHSTSTS);
if ((temp = inb_p(SMBHSTSTS)) != 0x00) {
-   dev_err(&piix4_adapter.dev, "Failed! (%02x)\n", temp);
+   dev_err(&adap->dev, "Failed! (%02x)\n", temp);
return -EBUSY;
} else {
-   dev_dbg(&piix4_adapter.dev, "Successful!\n");
+   dev_dbg(&adap->dev, "Successful!\n");
}
}

@@ -330,35 +347,35 @@ static int piix4_transaction(void)

/* If the SMBus is still busy, we give up */
if (timeout == MAX_TIMEOUT) {
-   dev_err(&piix4_adapter.dev, "SMBus Timeout!\n");
+   dev_err(&adap->dev, "SMBus Timeout!\n");
result = -ETIMEDOUT;
}

if (temp & 0x10) {
result = -EIO;
-   dev_err(&piix4_adapter.dev, "Error: Failed bus transaction\n");
+   dev_err(&adap->dev, "Error: Failed bus transaction\n");
}

if (temp & 0x08) {
result = -EIO;
-   dev_dbg(&piix4_adapter.dev, "Bus collision! SMBus may be "
+   dev_dbg(&adap->dev, "Bus collision! SMBus may be "
"locked until next hard reset. (sorry!)\n");
/* Clock stops and slave is stuck in mid-transmission */
}

if (temp & 0x04) {
result = -ENXIO;
-   dev_dbg(&piix4_adapter.dev, "Error: no response!\n");
+   dev_dbg(&adap->dev, "Error: no response!\n");
}

if (inb_p(SMBHSTSTS) != 0x00)
outb_p(inb(SMBHSTSTS), SMBHSTSTS);

if ((temp = inb_p(SMBHSTSTS)) != 0x00) {
-   dev_err(&piix4_adapter.dev, "Failed reset at end of "
+   dev_err(&adap->dev, "Failed reset at end of "
"transaction (%02x)\n", temp);
}
-   dev_dbg(&piix4_adapter.dev, "Transaction (post): CNT=%02x, CMD=%02x, "
+   dev_dbg(&adap->dev, "Transaction (post): CNT=%02x, CMD=%02x, "
"ADD=%02x, DAT0=%02x, DAT1=%02x\n", i

Re: [PATCH] i2c multiplexer driver for Proliant microserver N36L

2012-02-24 Thread Thomas Brandon
Jean Delvare  writes:
> You don't need a multiplexer device at all. Please just have i2c-piix4
> driver register 4 i2c_adapter devices for the SB800. This would be a
> 3-step process:
> 
> 1* Turn piix4_adapter to an array, so that it can hold up to 4
>i2c_adapter structures.
> 2* Add a mutex to prevent concurrent access to the register set. It
>should be initialized in piix4_setup_sb800(), taken at the very
>beginning of piix4_access() and released at the very end of this
>function.
> 3* Add support for ports 1, 2 and 3 of the SB800.
> 
> This would ideally be 3 incremental patches to make testing and review
> easy. I can help with parts 1 and 2 if you want, as this can be tested
> without a SB800. But it should be fairly easy overall.
> 
I have reworked the original patch to (hopefully) fit the structure you suggest.
However I have encountered issues with it that I'm not sure how to solve. The
behaviour is the same under both the original and the modified version of the
patch. When running sensors-detect, SDA0 (i2c-0) and SDA2 (i2c-1) (SDA1 is
reserved for ASF devices and accessed through a seperate controller) scan fine
with the following (edited) output:
Next adapter: SMBus piix4 adapter (SDA0) (i2c-0)
Do you want to scan it? (YES/no/selectively): y
Client found at address 0x18
Probing for `Microchip MCP98243'... Success!
(confidence 5, driver `jc42')
Client found at address 0x19
Probing for `Microchip MCP98243'... Success!
(confidence 5, driver `jc42')
Client found at address 0x50
Probing for `SPD EEPROM'... Yes
(confidence 8, not a hardware monitoring chip)
Client found at address 0x51
Probing for `SPD EEPROM'... Yes
(confidence 8, not a hardware monitoring chip)
Next adapter: SMBus piix4 adapter (SDA2) (i2c-1)
Do you want to scan it? (YES/no/selectively): y
Client found at address 0x2f
Probing for `Nuvoton W83795G/ADG'...Success!
(confidence 8, driver `w83795')

However while scanning SDA3 (i2c-2) sensors-detect finds a client at address
0x4c but no probes are successful and you get kernel output like:
i2c i2c-2: Transaction (pre): CNT=04, CMD=00, ADD=99, DAT0=ff, DAT1=01
i2c i2c-2: Transaction (post): CNT=04, CMD=00, ADD=99, DAT0=00, DAT1=01
i2c i2c-2: Transaction (pre): CNT=04, CMD=00, ADD=99, DAT0=00, DAT1=01
i2c i2c-2: Transaction (post): CNT=04, CMD=00, ADD=99, DAT0=00, DAT1=01
[SNIP]
i2c i2c-2: Transaction (pre): CNT=08, CMD=ac, ADD=99, DAT0=00, DAT1=01
i2c i2c-2: Transaction (post): CNT=08, CMD=ac, ADD=99, DAT0=00, DAT1=01
i2c i2c-2: Transaction (pre): CNT=0c, CMD=aa, ADD=99, DAT0=00, DAT1=01
i2c i2c-2: Transaction (pre): CNT=0c, CMD=aa, ADD=99, DAT0=00, DAT1=01
i2c i2c-2: SMBus Timeout!
i2c i2c-2: Bus collision! SMBus may be locked until next hard reset. (sorry!)
i2c i2c-2: Failed reset at end of transaction (01)
i2c i2c-2: Transaction (post): CNT=0c, CMD=aa, ADD=99, DAT0=00, DAT1=80

Then all subsequent access attempts before a hard reset result in output like:
i2c i2c-2: Transaction (pre): CNT=08, CMD=03, ADD=99, DAT0=00, DAT1=80
i2c i2c-2: SMBus busy (01). Resetting...
i2c i2c-2: Failed! (01)

Additionally, shutdown/restart commands now fail, as does using the power button
on the machine (it turns off but on powering back up the screen doesn't return).
The power cord must be removed before the server will restart. This is as
reported by the original submitter and another tester when the thread was posted
on the lm_sensors list
(http://lists.lm-sensors.org/pipermail/lm-sensors/2011-November/034259.html).
After restarting sensors now work as reported by others.

I'm not quite sure how best to proceed. Any tips on debugging/fixing this are
welcome.

Thomas Brandon

--
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 RESEND] i2c: Add Device Tree support to versatile-i2c driver

2012-02-24 Thread Pawel Moll
On Fri, 2012-02-24 at 10:58 +, Wolfram Sang wrote:
> > +static struct of_device_id i2c_versatile_match[] = {
> > +   { .compatible = "arm,versatile-i2c", },
> > +   {},
> > +};
> > +MODULE_DEVICE_TABLE(of, i2c_versatile_match);
> 
> const here, but I fixed it up already.

Sure thing, thanks!

Paweł


--
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/designware: dw_i2c_init_driver as subsys initcall

2012-02-24 Thread Baruch Siach
Hi Viresh,

On Fri, Feb 24, 2012 at 04:32:08PM +0530, Viresh Kumar wrote:
> On 11/16/2011 1:52 PM, Baruch Siach wrote:
> > Dependencies should be stated explicitly. Since this subsys_initcall thing 
> > is 
> > quite common among the i2c masters I'm willing to ack this one for now. But 
> > the real solution is to make the dependencies between devices clear and 
> > explicit.
> 
> Baruch,
> 
> Did you apply this patch?

Nope. If you want it applied please end to the I2C subsystem maintainers.

baruch

-- 
 http://baruch.siach.name/blog/  ~. .~   Tk Open Systems
=}ooO--U--Ooo{=
   - bar...@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
--
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 v6] I2C: add CSR SiRFprimaII on-chip I2C controllers driver

2012-02-24 Thread Wolfram Sang
Barry,

On Thu, Feb 16, 2012 at 10:24:00PM +0530, Shubhrajyoti Datta wrote:

please consider these comments.

Thanks,

   Wolfram

> Hello,
> 
> On Wed, Feb 8, 2012 at 8:58 PM, Barry Song <21cn...@gmail.com> wrote:
> > From: Zhiwu Song 
> >
> > SiRFprimaII is the latest generation application processor from CSR’s
> > multi-function SoC product family.
> > The SoC support codes are in arch/arm/mach-prima2 from Linux mainline
> > 3.0.
> > There are two I2C controllers on primaII, features include:
> > * Two I2C controller modules are on chip
> > * RISC I/O bus read write register
> > * Up to 16 bytes data buffer for issuing commands and writing data
> >  at the same time
> > * Up to 16 commands, and receiving read data 16 bytes at a time
> > * Error INT report (ACK check)
> > * No-ACK bus protocols (SCCB bus protocols)
> >
> > Signed-off-by: Zhiwu Song 
> > Signed-off-by: Xiangzhen Ye 
> > Signed-off-by: Yuping Luo 
> > Signed-off-by: Barry Song 
> > ---
> >  -v6:
> >  fix/cleanup lots of minor issues pointed out by wolfram;
> >  add OF property clock-frequency to support freq setting by DT;
> >  add lost devicetree binding document;
> >
> >  Documentation/devicetree/bindings/i2c/sirf-i2c.txt |   19 +
> >  drivers/i2c/busses/Kconfig                         |   10 +
> >  drivers/i2c/busses/Makefile                        |    1 +
> >  drivers/i2c/busses/i2c-sirf.c                      |  459 
> > 
> >  4 files changed, 489 insertions(+), 0 deletions(-)
> >  create mode 100644 Documentation/devicetree/bindings/i2c/sirf-i2c.txt
> >  create mode 100644 drivers/i2c/busses/i2c-sirf.c
> >
> > diff --git a/Documentation/devicetree/bindings/i2c/sirf-i2c.txt 
> > b/Documentation/devicetree/bindings/i2c/sirf-i2c.txt
> > new file mode 100644
> > index 000..7baf9e1
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/i2c/sirf-i2c.txt
> 
> 
> > +
> > +               if (i2c_stat & SIRFSOC_I2C_STAT_NACK)
> > +                       dev_err(&siic->adapter.dev, "ACK not received\n");
> Could we send stop here?
> > +               else
> > +                       dev_err(&siic->adapter.dev, "I2C error\n");
> > +
> > +               complete(&siic->done);
> 
> 
> > +static int i2c_sirfsoc_resume(struct device *dev)
> > +{
> > +       struct platform_device *pdev = to_platform_device(dev);
> > +       struct i2c_adapter *adapter = platform_get_drvdata(pdev);
> > +       struct sirfsoc_i2c *siic = adapter->algo_data;
> > +
> > +       clk_enable(siic->clk);
> > +       writel(SIRFSOC_I2C_RESET, siic->base + SIRFSOC_I2C_CTRL);
> Could you explain why is a reset needed.
> Or am I missing something.
> 
> > +       writel(SIRFSOC_I2C_CORE_EN | SIRFSOC_I2C_MASTER_MODE,
> > +               siic->base + SIRFSOC_I2C_CTRL);
> > +       writel(siic->clk_div, siic->base + SIRFSOC_I2C_CLK_CTRL);
> > +       writel(siic->sda_delay, siic->base + SIRFSOC_I2C_SDA_DELAY);
> > +       clk_disable(siic->clk);
> > +       return 0;
> > +}
> > +
> > +static const struct dev_pm_ops i2c_sirfsoc_pm_ops = {
> > +       .suspend = i2c_sirfsoc_suspend,
> > +       .resume = i2c_sirfsoc_resume,
> Could we use simple dev_pm ops here?
> 
> > +};
> > +#endif
> > +
> > +static const struct of_device_id sirfsoc_i2c_of_match[] __devinitconst = {
> > +       { .compatible = "sirf,prima2-i2c", },
> --
> 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

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


signature.asc
Description: Digital signature


Re: [PATCH v2] i2c-isch: Add module parameter which actually set the clock divider

2012-02-24 Thread Wolfram Sang
On Wed, Feb 15, 2012 at 03:36:49PM +0100, Alexander Stein wrote:
> It was observed the Host Clock Divider was not written by the driver. It
> was still set to (default) 0, if not already set by BIOS, which caused
> garbage on SMBus.
> This driver adds 2 parameters which are used to calculate the divider
> appropriately. This new divider is only applied if the clock divider is
> still default 0.
> 
> Signed-off-by: Alexander Stein 
> Tested-by: Adam Pribyl 
> ---

I don't know the hardware: Can it have multiple SmBusses? Then, a module
parameter would force all of them to the selected mode. Do you really
need the parameter? Maybe defaulting to 100Kbps is sane enough?

@Jean: Is this an embedded driver? :)

> Changes in v2:
> * HSTCLK register is 16 Bit, not 8 Bit. Thanks to Adam for detecting
> 
>  drivers/i2c/busses/i2c-isch.c |   12 
>  1 files changed, 12 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-isch.c b/drivers/i2c/busses/i2c-isch.c
> index 6561d27..bdfddf8 100644
> --- a/drivers/i2c/busses/i2c-isch.c
> +++ b/drivers/i2c/busses/i2c-isch.c
> @@ -40,6 +40,7 @@
>  /* SCH SMBus address offsets */
>  #define SMBHSTCNT(0 + sch_smba)
>  #define SMBHSTSTS(1 + sch_smba)
> +#define SMBHSTCLK(2 + sch_smba)
>  #define SMBHSTADD(4 + sch_smba) /* TSA */
>  #define SMBHSTCMD(5 + sch_smba)
>  #define SMBHSTDAT0   (6 + sch_smba)
> @@ -58,6 +59,8 @@
>  
>  static unsigned short sch_smba;
>  static struct i2c_adapter sch_adapter;
> +static int smbus_speed = 100; /* SMBus bus speed in Kbps */
> +static int backbone_speed = 33000; /* backbone speed in KHz */
>  
>  /*
>   * Start the i2c transaction -- the i2c_access will prepare the transaction
> @@ -156,6 +159,13 @@ static s32 sch_access(struct i2c_adapter *adap, u16 addr,
>   dev_dbg(&sch_adapter.dev, "SMBus busy (%02x)\n", temp);
>   return -EAGAIN;
>   }
> + temp = inw(SMBHSTCLK);
> + if (!temp) {
> + dev_notice(&sch_adapter.dev, "clock divider unitialized. 
> Setting module defaults\n");
> + dev_dbg(&sch_adapter.dev, "access speed: %d KHz\n", 
> smbus_speed);
> + outw((backbone_speed / 4) / smbus_speed, SMBHSTCLK);
> + }
> +
>   dev_dbg(&sch_adapter.dev, "access size: %d %s\n", size,
>   (read_write)?"READ":"WRITE");
>   switch (size) {
> @@ -312,3 +322,5 @@ MODULE_AUTHOR("Jacob Pan ");
>  MODULE_DESCRIPTION("Intel SCH SMBus driver");
>  MODULE_LICENSE("GPL");
>  MODULE_ALIAS("platform:isch_smbus");
> +module_param(smbus_speed, int, (S_IRUSR | S_IWUSR));
> +module_param(backbone_speed, int, (S_IRUSR | S_IWUSR));
> -- 
> 1.7.3.4
> 

Regards,

   Wolfram

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


signature.asc
Description: Digital signature


Re: [PATCH v2] i2c-eg20t: Rework pch_i2c_wait_for_bus_idle to reduce wait time

2012-02-24 Thread Wolfram Sang
On Mon, Feb 20, 2012 at 09:14:16AM +0100, Alexander Stein wrote:
> If you insert several i2c transfers, the driver might start the next one
> while the STOP bit of the previous transfer is still on the bus, marking
> the bus as busy.
> pch_i2c_wait_for_bus_idle does an msleep(20) delaying the next transfer
> by >=20ms. Reduce wait time by actively waiting 5 us once, then using
> usleep_range.
> 
> Signed-off-by: Alexander Stein 

Tomoya, are you happy with it? (I hope he reads the list, since his
companies mailserver doesn't seem to accept my mails).

Regards,

   Wolfram

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


signature.asc
Description: Digital signature


[PATCH 2/2] i2c/designware: Provide optional i2c bus recovery function

2012-02-24 Thread Viresh Kumar
From: Vincenzo Frascino 

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

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.

Signed-off-by: Vincenzo Frascino 
Signed-off-by: Shiraz Hashim 
Signed-off-by: Viresh Kumar 
---
 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_DISABLE0x40
 
-
 /**
  * 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 inttx_fifo_depth;
unsigned intrx_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 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -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 000..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 
+ *
+ * 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 
+
+/* 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 

[PATCH 1/2] i2c/busses: Add PM support

2012-02-24 Thread Viresh Kumar
From: Deepak Sikri 

This patch adds in support for standby/S2R/hybernate for i2c-designware driver.

Signed-off-by: Deepak Sikri 
Signed-off-by: Rajeev Kumar 
---
 drivers/i2c/busses/i2c-designware-platdrv.c |   27 +++
 1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c 
b/drivers/i2c/busses/i2c-designware-platdrv.c
index 5244c47..c5ac2dc 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -36,6 +36,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include "i2c-designware-core.h"
@@ -198,6 +199,31 @@ static const struct of_device_id dw_i2c_of_match[] = {
 MODULE_DEVICE_TABLE(of, dw_i2c_of_match);
 #endif
 
+#ifdef CONFIG_PM
+static int dw_i2c_suspend(struct device *dev)
+{
+   struct platform_device *pdev = to_platform_device(dev);
+   struct dw_i2c_dev *i_dev = platform_get_drvdata(pdev);
+
+   clk_disable(i_dev->clk);
+
+   return 0;
+}
+
+static int dw_i2c_resume(struct device *dev)
+{
+   struct platform_device *pdev = to_platform_device(dev);
+   struct dw_i2c_dev *i_dev = platform_get_drvdata(pdev);
+
+   clk_enable(i_dev->clk);
+   i2c_dw_init(i_dev);
+
+   return 0;
+}
+#endif
+
+static SIMPLE_DEV_PM_OPS(dw_i2c_dev_pm_ops, dw_i2c_suspend, dw_i2c_resume);
+
 /* work with hotplug and coldplug */
 MODULE_ALIAS("platform:i2c_designware");
 
@@ -207,6 +233,7 @@ static struct platform_driver dw_i2c_driver = {
.name   = "i2c_designware",
.owner  = THIS_MODULE,
.of_match_table = of_match_ptr(dw_i2c_of_match),
+   .pm = &dw_i2c_dev_pm_ops,
},
 };
 
-- 
1.7.8.110.g4cb5d

--
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/busses: (mpc) Add support for SMBUS_READ_BLOCK_DATA

2012-02-24 Thread Wolfram Sang
On Thu, Feb 23, 2012 at 05:42:45PM +0800, b29...@freescale.com wrote:
> From: Tang Yuantian 
> 
> Add support for SMBUS_READ_BLOCK_DATA to the i2c-mpc bus driver.
> 
> Signed-off-by: Tang Yuantian 

Thanks, picked.

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


signature.asc
Description: Digital signature


Re: [PATCH] i2c/designware: dw_i2c_init_driver as subsys initcall

2012-02-24 Thread Viresh Kumar
On 11/16/2011 1:52 PM, Baruch Siach wrote:
> Dependencies should be stated explicitly. Since this subsys_initcall thing is 
> quite common among the i2c masters I'm willing to ack this one for now. But 
> the real solution is to make the dependencies between devices clear and 
> explicit.

Baruch,

Did you apply this patch?

-- 
viresh
--
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 RESEND] i2c: Add Device Tree support to versatile-i2c driver

2012-02-24 Thread Wolfram Sang

> +static struct of_device_id i2c_versatile_match[] = {
> + { .compatible = "arm,versatile-i2c", },
> + {},
> +};
> +MODULE_DEVICE_TABLE(of, i2c_versatile_match);

const here, but I fixed it up already.

Thanks.

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


signature.asc
Description: Digital signature


Re: [PATCH 00/10] I2C updates

2012-02-24 Thread Shubhrajyoti
On Friday 10 February 2012 07:29 PM, Shubhrajyoti D wrote:
> This patch series colates the various i2c updates into
> a series.  Since it is collection of various patches
> the version info is not retained, however most of them undergone
> multiple versions.
If there are no further comments can this be queued.

> This is rebased to linus head commit 63082402968f4b73f10b28a8ac1f3da821aeb82d
>
> The patch series does the following 
>
> - Warn fixes if CONFIG_PM_RUNTIME is not selected.
> - I2C register restore only if context if the context is lost
> - Bus busy recovery mechanism.
> - the reset is not done in init.
>
> Tested on omap4sdp and omap3sdp. 
>
>
> Cc: Kevin Hilman 
> Cc: Ben Dooks 
>
> Jon Hunter (1):
>   I2C: OMAP: Correct I2C revision for OMAP3
>
> Shubhrajyoti D (8):
>   I2C : OMAP : make omap_i2c_unidle/idle functions depend on
> CONFIG_PM_RUNTIME
>   OMAP : I2C : Remove reset at init
>   OMAP: I2C: I2C register restore only if context is lost
>   OMAP: I2C: Fix the interrupt clearing in OMAP4
>   OMAP: I2C: Fix the mismatch of pm_runtime enable and disable
>   OMAP: I2C: Optimise the remove code
>   OMAP: I2C: Fix the error handling
>   I2C: OMAP: Don't check if wait_for_completion_timeout() returns less
> than zero
>
> Vikram Pandita (1):
>   I2C: OMAP: Recover from Bus Busy condition
>
>  drivers/i2c/busses/i2c-omap.c |  173 
> -
>  1 files changed, 101 insertions(+), 72 deletions(-)
>

--
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 00/10] I2C updates

2012-02-24 Thread Shubhrajyoti
On Friday 10 February 2012 07:29 PM, Shubhrajyoti D wrote:
> This patch series colates the various i2c updates into
> a series.  Since it is collection of various patches
> the version info is not retained, however most of them undergone
> multiple versions.
If there are no further comments can this be queued.
> This is rebased to linus head commit 63082402968f4b73f10b28a8ac1f3da821aeb82d
>
> The patch series does the following 
>
> - Warn fixes if CONFIG_PM_RUNTIME is not selected.
> - I2C register restore only if context if the context is lost
> - Bus busy recovery mechanism.
> - the reset is not done in init.
>
> Tested on omap4sdp and omap3sdp. 
>
>
> Cc: Kevin Hilman 
> Cc: Ben Dooks 
>
> Jon Hunter (1):
>   I2C: OMAP: Correct I2C revision for OMAP3
>
> Shubhrajyoti D (8):
>   I2C : OMAP : make omap_i2c_unidle/idle functions depend on
> CONFIG_PM_RUNTIME
>   OMAP : I2C : Remove reset at init
>   OMAP: I2C: I2C register restore only if context is lost
>   OMAP: I2C: Fix the interrupt clearing in OMAP4
>   OMAP: I2C: Fix the mismatch of pm_runtime enable and disable
>   OMAP: I2C: Optimise the remove code
>   OMAP: I2C: Fix the error handling
>   I2C: OMAP: Don't check if wait_for_completion_timeout() returns less
> than zero
>
> Vikram Pandita (1):
>   I2C: OMAP: Recover from Bus Busy condition
>
>  drivers/i2c/busses/i2c-omap.c |  173 
> -
>  1 files changed, 101 insertions(+), 72 deletions(-)
>

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