[PATCH v11 0/4] AT91: replace old i2c-at91.c TWI driver

2012-08-29 Thread Nikolaus Voss
The old driver has two main deficencies:
i)  No repeated start (Sr) condiction is possible, this makes it unusable
e.g. for most SMBus transfers.
ii) I/O was done with polling/busy waiting what caused over-/underruns
even at light system loads and clock speeds.

The new driver overcomes these deficencies and in addition allows for
more than one TWI interface.

A remaining limitation is the fact, that only one repeated start is
possible (two concatenated messages). This limitation is imposed by
the hardware. However, this should not be a problem as all common
i2c-client communication does not rely on more than one repeated start.

Changes since v11:
- corrected wrong id_entry on sam9261 twi gpio pdev

Nikolaus Voss (4):
  drivers/i2c/busses/i2c-at91.c: remove old polling driver
  Replace clk_lookup.con_id with clk_lookup.dev_id entries for twi clk
  drivers/i2c/busses/i2c-at91.c: add new driver
  G45 TWI: remove open drain setting for twi function gpios

 arch/arm/mach-at91/at91rm9200.c|1 +
 arch/arm/mach-at91/at91rm9200_devices.c|9 +
 arch/arm/mach-at91/at91sam9260.c   |1 +
 arch/arm/mach-at91/at91sam9261.c   |1 +
 arch/arm/mach-at91/at91sam9261_devices.c   |9 +
 arch/arm/mach-at91/at91sam9263.c   |1 +
 arch/arm/mach-at91/at91sam9g45.c   |2 +
 arch/arm/mach-at91/at91sam9g45_devices.c   |6 -
 arch/arm/mach-at91/at91sam9rl.c|2 +
 arch/arm/mach-at91/at91sam9x5.c|3 +
 arch/arm/mach-at91/include/mach/at91_twi.h |   68 
 drivers/i2c/busses/Kconfig |   11 +-
 drivers/i2c/busses/i2c-at91.c  |  591 ++--
 13 files changed, 418 insertions(+), 287 deletions(-)
 delete mode 100644 arch/arm/mach-at91/include/mach/at91_twi.h

-- 
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 v11 4/4] G45 TWI: remove open drain setting for twi function gpios

2012-08-29 Thread Nikolaus Voss
The G45 datasheets explicitly states that setting the open drain property
on peripheral function gpios is not allowed. (How about other A91 chips?)

Signed-off-by: Nikolaus Voss n.v...@weinmann.de
---
 arch/arm/mach-at91/at91sam9g45_devices.c |6 --
 1 file changed, 6 deletions(-)

diff --git a/arch/arm/mach-at91/at91sam9g45_devices.c 
b/arch/arm/mach-at91/at91sam9g45_devices.c
index eec5eb6..2134663 100644
--- a/arch/arm/mach-at91/at91sam9g45_devices.c
+++ b/arch/arm/mach-at91/at91sam9g45_devices.c
@@ -686,18 +686,12 @@ void __init at91_add_device_i2c(short i2c_id, struct 
i2c_board_info *devices, in
/* pins used for TWI interface */
if (i2c_id == 0) {
at91_set_A_periph(AT91_PIN_PA20, 0);/* TWD */
-   at91_set_multi_drive(AT91_PIN_PA20, 1);
-
at91_set_A_periph(AT91_PIN_PA21, 0);/* TWCK */
-   at91_set_multi_drive(AT91_PIN_PA21, 1);
 
platform_device_register(at91sam9g45_twi0_device);
} else {
at91_set_A_periph(AT91_PIN_PB10, 0);/* TWD */
-   at91_set_multi_drive(AT91_PIN_PB10, 1);
-
at91_set_A_periph(AT91_PIN_PB11, 0);/* TWCK */
-   at91_set_multi_drive(AT91_PIN_PB11, 1);
 
platform_device_register(at91sam9g45_twi1_device);
}
-- 
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 v11 3/4] drivers/i2c/busses/i2c-at91.c: add new driver

2012-08-29 Thread Nikolaus Voss
This driver has the following properties compared to the old driver:
1. Support for multiple interfaces.
2. Interrupt driven I/O as opposed to polling/busy waiting.
3. Support for _one_ repeated start (Sr) condition, which is enough
   for most real-world applications including all SMBus transfer types.
   (The hardware does not support issuing arbitrary Sr conditions on the
bus.)

testing: SoC: at91sam9g45
 - BQ20Z80 battery SMBus client.
 - on a 2.6.38 kernel with several i2c clients (temp-sensor,
   audio-codec, touchscreen-controller, w1-bridge, io-expanders)

Signed-off-by: Nikolaus Voss n.v...@weinmann.de
Reviewed-by: Felipe Balbi ba...@ti.com
Tested-by: Hubert Feurstein h.feurst...@gmail.com

v12: - corrected wrong id_entry on sam9261 twi gpio pdev
v11: - fix for flags persistency suggested by Carsten Behling
 - calc_twi_clock fix for sam9261 by Ludovic Desroches
v10: - applied fix for RXRDY overrun bug submitted by Hubert Feurstein
 - applied fix for calculating twi_clk
v9: - merge i2c-at91.c patches to single patch
- rewrite cwgr reg after timeout
v8: - remove local include
- remove cpu_is_rm9200() and put twi hw bug info in platform_device
- use readl/writel_relaxed instead of __raw_readl/writel
v7: i)  fix bug if internal address  1 byte
ii) send stop when len == 1 (both reported by Carsten Behling)
v6: support for I2C_SMBUS_BLOCK_DATA transfers.
Better use of clk_(un)prepare().
More sensible transfer timeout.
v5: Another round of review comments from Ryan Mallon, Felipe Balbi
and Russell King: convert twi clk to use .dev_id, cleanups
v4: Integrated more review comments from Ryan Mallon and Felipe Balbi:
Moved register include file to local include, code cleanups
v3: Integrated review comments from Ryan Mallon and Felipe Balbi
v2: Fixed whitespace issue
---
 arch/arm/mach-at91/at91rm9200_devices.c  |9 +
 arch/arm/mach-at91/at91sam9261_devices.c |9 +
 drivers/i2c/busses/Kconfig   |   11 +-
 drivers/i2c/busses/Makefile  |1 +
 drivers/i2c/busses/i2c-at91.c|  493 ++
 5 files changed, 516 insertions(+), 7 deletions(-)
 create mode 100644 drivers/i2c/busses/i2c-at91.c

diff --git a/arch/arm/mach-at91/at91rm9200_devices.c 
b/arch/arm/mach-at91/at91rm9200_devices.c
index e6b7d05..2977a2d 100644
--- a/arch/arm/mach-at91/at91rm9200_devices.c
+++ b/arch/arm/mach-at91/at91rm9200_devices.c
@@ -494,9 +494,18 @@ static struct resource twi_resources[] = {
},
 };
 
+static const struct platform_device_id twi_ip_type = {
+   /*
+* driver_data is 1 for RM9200 compatible ip, see enum twi_ip_id in
+* drivers/i2c/busses/i2c-at91.c
+*/
+   .driver_data= 1,
+};
+
 static struct platform_device at91rm9200_twi_device = {
.name   = at91_i2c,
.id = -1,
+   .id_entry   = twi_ip_type,
.resource   = twi_resources,
.num_resources  = ARRAY_SIZE(twi_resources),
 };
diff --git a/arch/arm/mach-at91/at91sam9261_devices.c 
b/arch/arm/mach-at91/at91sam9261_devices.c
index 9295e90..aeb2eed 100644
--- a/arch/arm/mach-at91/at91sam9261_devices.c
+++ b/arch/arm/mach-at91/at91sam9261_devices.c
@@ -316,9 +316,18 @@ static struct resource twi_resources[] = {
},
 };
 
+static const struct platform_device_id twi_ip_type = {
+   /*
+* driver_data is 2 for SAM9261 compatible ip, see enum twi_ip_id in
+* drivers/i2c/busses/i2c-at91.c
+*/
+   .driver_data= 2,
+};
+
 static struct platform_device at91sam9261_twi_device = {
.name   = at91_i2c,
.id = -1,
+   .id_entry   = twi_ip_type,
.resource   = twi_resources,
.num_resources  = ARRAY_SIZE(twi_resources),
 };
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 7244c8b..6b74287 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -286,18 +286,15 @@ comment I2C system bus drivers (mostly embedded / 
system-on-chip)
 
 config I2C_AT91
tristate Atmel AT91 I2C Two-Wire interface (TWI)
-   depends on ARCH_AT91  EXPERIMENTAL  BROKEN
+   depends on ARCH_AT91  EXPERIMENTAL
help
  This supports the use of the I2C interface on Atmel AT91
  processors.
 
- This driver is BROKEN because the controller which it uses
- will easily trigger RX overrun and TX underrun errors.  Using
- low I2C clock rates may partially work around those issues
- on some systems.  Another serious problem is that there is no
- documented way to issue repeated START conditions, as needed
+ A serious problem is that there is no documented way to issue
+ repeated START conditions for more than two messages, as needed
  to support combined I2C messages.  Use the i2c-gpio driver
- unless your system can cope with those limitations.

[PATCH v11 1/4] drivers/i2c/busses/i2c-at91.c: remove old polling driver

2012-08-29 Thread Nikolaus Voss
Signed-off-by: Nikolaus Voss n.v...@weinmann.de
---
 arch/arm/mach-at91/include/mach/at91_twi.h |   68 --
 drivers/i2c/busses/Makefile|1 -
 drivers/i2c/busses/i2c-at91.c  |  314 
 3 files changed, 383 deletions(-)
 delete mode 100644 arch/arm/mach-at91/include/mach/at91_twi.h
 delete mode 100644 drivers/i2c/busses/i2c-at91.c

diff --git a/arch/arm/mach-at91/include/mach/at91_twi.h 
b/arch/arm/mach-at91/include/mach/at91_twi.h
deleted file mode 100644
index bb2880f..000
--- a/arch/arm/mach-at91/include/mach/at91_twi.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * arch/arm/mach-at91/include/mach/at91_twi.h
- *
- * Copyright (C) 2005 Ivan Kokshaysky
- * Copyright (C) SAN People
- *
- * Two-wire Interface (TWI) registers.
- * Based on AT91RM9200 datasheet revision E.
- *
- * 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 AT91_TWI_H
-#define AT91_TWI_H
-
-#defineAT91_TWI_CR 0x00/* Control Register */
-#defineAT91_TWI_START  (1   0)   /* Send a Start 
Condition */
-#defineAT91_TWI_STOP   (1   1)   /* Send a Stop 
Condition */
-#defineAT91_TWI_MSEN   (1   2)   /* Master 
Transfer Enable */
-#defineAT91_TWI_MSDIS  (1   3)   /* Master 
Transfer Disable */
-#defineAT91_TWI_SVEN   (1   4)   /* Slave 
Transfer Enable [SAM9260 only] */
-#defineAT91_TWI_SVDIS  (1   5)   /* Slave 
Transfer Disable [SAM9260 only] */
-#defineAT91_TWI_SWRST  (1   7)   /* Software 
Reset */
-
-#defineAT91_TWI_MMR0x04/* Master Mode Register 
*/
-#defineAT91_TWI_IADRSZ (3  8)/* Internal 
Device Address Size */
-#defineAT91_TWI_IADRSZ_NO  (0  8)
-#defineAT91_TWI_IADRSZ_1   (1  8)
-#defineAT91_TWI_IADRSZ_2   (2  8)
-#defineAT91_TWI_IADRSZ_3   (3  8)
-#defineAT91_TWI_MREAD  (1 12)/* Master Read 
Direction */
-#defineAT91_TWI_DADR   (0x7f  16)/* Device 
Address */
-
-#defineAT91_TWI_SMR0x08/* Slave Mode Register 
[SAM9260 only] */
-#defineAT91_TWI_SADR   (0x7f  16)/* Slave 
Address */
-
-#defineAT91_TWI_IADR   0x0c/* Internal Address 
Register */
-
-#defineAT91_TWI_CWGR   0x10/* Clock Waveform 
Generator Register */
-#defineAT91_TWI_CLDIV  (0xff   0)/* Clock Low 
Divisor */
-#defineAT91_TWI_CHDIV  (0xff   8)/* Clock High 
Divisor */
-#defineAT91_TWI_CKDIV  (7 16)/* Clock 
Divider */
-
-#defineAT91_TWI_SR 0x20/* Status Register */
-#defineAT91_TWI_TXCOMP (1   0)   /* Transmission 
Complete */
-#defineAT91_TWI_RXRDY  (1   1)   /* Receive 
Holding Register Ready */
-#defineAT91_TWI_TXRDY  (1   2)   /* Transmit 
Holding Register Ready */
-#defineAT91_TWI_SVREAD (1   3)   /* Slave Read 
[SAM9260 only] */
-#defineAT91_TWI_SVACC  (1   4)   /* Slave Access 
[SAM9260 only] */
-#defineAT91_TWI_GACC   (1   5)   /* General Call 
Access [SAM9260 only] */
-#defineAT91_TWI_OVRE   (1   6)   /* Overrun 
Error [AT91RM9200 only] */
-#defineAT91_TWI_UNRE   (1   7)   /* Underrun 
Error [AT91RM9200 only] */
-#defineAT91_TWI_NACK   (1   8)   /* Not 
Acknowledged */
-#defineAT91_TWI_ARBLST (1   9)   /* Arbitration 
Lost [SAM9260 only] */
-#defineAT91_TWI_SCLWS  (1  10)   /* Clock Wait 
State [SAM9260 only] */
-#defineAT91_TWI_EOSACC (1  11)   /* End of Slave 
Address [SAM9260 only] */
-
-#defineAT91_TWI_IER0x24/* Interrupt Enable 
Register */
-#defineAT91_TWI_IDR0x28/* Interrupt Disable 
Register */
-#defineAT91_TWI_IMR0x2c/* Interrupt Mask 
Register */
-#defineAT91_TWI_RHR0x30/* Receive Holding 
Register */
-#defineAT91_TWI_THR0x34/* Transmit Holding 
Register */
-
-#endif
-
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index ce3c2be..4f46873 100644
--- 

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

2012-08-29 Thread Jean Delvare
Eddi, Thomas,

On Wed, 14 Mar 2012 09:28:54 +0100, Eddi De Pieri wrote:
 Hi Thomas,
 
  With the updated patch and the modified sensors-detect I have been
  able to probe all ports and have not encountered the power issue
  again. If no further issues are identified I will seperate the patch
  into stages and submit for review.
 
 I confirm that your patch works well on my proliant n36l and solve the
 power issue.
 
 Thank you for rewrote my patch.

Recent mainline changes to the i2c-piix4 driver make the patch no
longer apply, so I can't push it upstream. Can either of you please
rebase the patch on top of Linus' latest kernel and resubmit?

Thanks,
-- 
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 4/5] i2c-i801: Add Device IDs for Intel Lynx Point-LP PCH

2012-08-29 Thread Jean Delvare
Hi James,

Quite a long Cc list for such a trivial patch...

On Thu,  9 Aug 2012 09:43:52 -0700, james.d.rals...@intel.com wrote:
 From: James Ralston james.d.rals...@intel.com
 
 This patch adds the SMBus Device IDs for the Intel Lynx Point-LP PCH. The 
 Device IDs are defined in drivers/i2c/busses/i2c-i801.c

I'm curious what the LP stands for. Low power?

 
 Signed-off-by: James Ralston james.d.rals...@intel.com
 ---
  Documentation/i2c/busses/i2c-i801 |1 +
  drivers/i2c/busses/Kconfig|1 +
  drivers/i2c/busses/i2c-i801.c |3 +++
  3 files changed, 5 insertions(+), 0 deletions(-)
 
 diff --git a/Documentation/i2c/busses/i2c-i801 
 b/Documentation/i2c/busses/i2c-i801
 index 615142d..53207df 100644
 --- a/Documentation/i2c/busses/i2c-i801
 +++ b/Documentation/i2c/busses/i2c-i801
 @@ -21,6 +21,7 @@ Supported adapters:
* Intel DH89xxCC (PCH)
* Intel Panther Point (PCH)
* Intel Lynx Point (PCH)
 +  * Intel Lynx Point_LP (PCH)

You spelled it Lynx Point-LP (with dash not underscore) in the patch
summary. Consistency in naming would be preferred. I'll use a dash
everywhere and apply your patch.

 Datasheets: Publicly available at the Intel website
  
  On Intel Patsburg and later chipsets, both the normal host SMBus controller
 diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
 index 2e7530a..3500af7 100644
 --- a/drivers/i2c/busses/Kconfig
 +++ b/drivers/i2c/busses/Kconfig
 @@ -104,6 +104,7 @@ config I2C_I801
   DH89xxCC (PCH)
   Panther Point (PCH)
   Lynx Point (PCH)
 + Lynx Point_LP (PCH)
  
 This driver can also be built as a module.  If so, the module
 will be called i2c-i801.
 diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
 index 898dcf9..c467038 100644
 --- a/drivers/i2c/busses/i2c-i801.c
 +++ b/drivers/i2c/busses/i2c-i801.c
 @@ -52,6 +52,7 @@
DH89xxCC (PCH)0x2330 32 hard yes yes yes
Panther Point (PCH)   0x1e22 32 hard yes yes yes
Lynx Point (PCH)  0x8c22 32 hard yes yes yes
 +  Lynx Point_LP (PCH)   0x9c22 32 hard yes yes yes
  
Features supported by this driver:
Software PEC no
 @@ -155,6 +156,7 @@
  #define PCI_DEVICE_ID_INTEL_DH89XXCC_SMBUS   0x2330
  #define PCI_DEVICE_ID_INTEL_5_3400_SERIES_SMBUS  0x3b30
  #define PCI_DEVICE_ID_INTEL_LYNXPOINT_SMBUS  0x8c22
 +#define PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_SMBUS   0x9c22
  
  struct i801_priv {
   struct i2c_adapter adapter;
 @@ -771,6 +773,7 @@ static DEFINE_PCI_DEVICE_TABLE(i801_ids) = {
   { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_DH89XXCC_SMBUS) },
   { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 
 PCI_DEVICE_ID_INTEL_PANTHERPOINT_SMBUS) },
   { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_LYNXPOINT_SMBUS) 
 },
 + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 
 PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_SMBUS) },
   { 0, }
  };
  


-- 
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: omap: Prevent NULL pointer dereference in remove

2012-08-29 Thread Jean Delvare
On Thu, 23 Aug 2012 19:51:26 +0530, Shubhrajyoti D wrote:
 Prevent the NULL pointer access of pdev-dev in remove. The platform_device 
 is anyways
 deleted so remove  platform_set_drvdata(pdev, NULL);.

No, the platform device isn't deleted. The i2c adapters are deleted but
the underlying platform device is not.

 
 [  654.961761] Unable to handle kernel NULL pointer dereference at virtual 
 address 0070
 [  654.970611] pgd = df254000
 [  654.973480] [0070] *pgd=9f1da831, *pte=, *ppte=
 [  654.980163] Internal error: Oops: 17 [#1] SMP ARM
 [  654.985076] Modules linked in:
 [  654.988281] CPU: 1Not tainted  (3.6.0-rc1-00031-ge547de1-dirty #339)
 [  654.995330] PC is at omap_i2c_runtime_resume+0x8/0x148
 [  655.000732] LR is at omap_i2c_runtime_resume+0x8/0x148
 
 Signed-off-by: Shubhrajyoti D shubhrajy...@ti.com
 ---
  drivers/i2c/busses/i2c-omap.c |3 ---
  1 files changed, 0 insertions(+), 3 deletions(-)
 
 diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
 index 5d19a49..84fbef6 100644
 --- a/drivers/i2c/busses/i2c-omap.c
 +++ b/drivers/i2c/busses/i2c-omap.c
 @@ -1098,7 +1098,6 @@ err_unuse_clocks:
   iounmap(dev-base);
   pm_runtime_disable(pdev-dev);
  err_free_mem:
 - platform_set_drvdata(pdev, NULL);
   kfree(dev);
  err_release_region:
   release_mem_region(mem-start, resource_size(mem));

This can't be right. You're about to free the memory, so if anyone
still can access it through platform_get_drvdata(), you're in trouble
anyway. But I don't think this is the case here.

 @@ -1112,8 +,6 @@ static int __devexit omap_i2c_remove(struct 
 platform_device *pdev)
   struct resource *mem;
   int ret;
  
 - platform_set_drvdata(pdev, NULL);
 -

This OTOH is a good catch. But the problem isn't with calling
platform_set_drvdata(pdev, NULL) per se. The problem is with calling it
too early. It should be called after i2c_del_adapter(), and ideally
before freeing the memory.

   free_irq(dev-irq, dev);
   i2c_del_adapter(dev-adapter);
   ret = pm_runtime_get_sync(pdev-dev);


-- 
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: [RFC PATCH 1/5] i2c: introduce i2c-cbus driver

2012-08-29 Thread Tony Lindgren
* Aaro Koskinen aaro.koski...@iki.fi [120828 14:35]:
 Add i2c driver to enable access to devices behind CBUS on Nokia Internet
 Tablets.

Can you please do also a separate patch for the device tree binding for
getting the GPIO pins for this controller? 

Other than that thanks for doing this and:

Acked-by: Tony Lindgren t...@atomide.com
--
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