All of lore.kernel.org
 help / color / mirror / Atom feed
* I2C support for Sodaville
@ 2010-11-24 21:20 ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 48+ messages in thread
From: Sebastian Andrzej Siewior @ 2010-11-24 21:20 UTC (permalink / raw)
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	sodaville-hfZtesqFncYOwBW4kG4KsQ, tglx-hfZtesqFncYOwBW4kG4KsQ,
	eric.y.miao-Re5JQEeQqe8AvxtiuMwx3w, linux-lFZ/pmaqli7XmaaqVzeoHQ,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg

The I2C core inside Sodaville is very much the same as in PXA25x.
I Cc the ARM folks because patch 2 reorganizes some files so that they
can be accessed from x86.
The I2C device is behind a PCI bus. The PCI probe code simply creates
three platform devices so we don't have much changes to the platform
driver. There is no clock framework on x86 and the peripherals don't
support changing their clocks or to enable/disable them. So I provided
dummy function which keep the driver happy.
This series indirectly depends on the SPI series I've sent earlier
because both modify include files and the spi & i2c includes are sometimes
too close to each other.

The patch series has been created with the -M option so file moves can
be easily noticed. The whole series (including spi) is also available at
  git://git.linutronix.de/users/bigeasy/soda.git spi-i2c

Sebastian Andrzej Siewior (7):
      i2c/pxa2xx: Don't touch ISAR if not in slave mode
      arm/pxa2xx: reorganize I2C files
      i2c/pxa2xx: Add PCI support for PXA I2C controller
      i2c/pxa2xx: add support for shared IRQ handler
      i2c/pxa2xx: check timeout correctly
      i2c/pxa2xx: reset the chip if the bus is not free
      i2c/pxa2xx: pass of_node from platform driver to adapter

 arch/arm/include/asm/pxa_i2c.h                     |   19 +++
 arch/arm/mach-mmp/include/mach/mmp2.h              |    2 +-
 arch/arm/mach-mmp/include/mach/pxa168.h            |    2 +-
 arch/arm/mach-mmp/include/mach/pxa910.h            |    2 +-
 arch/arm/mach-pxa/balloon3.c                       |    3 +-
 arch/arm/mach-pxa/cm-x300.c                        |    2 +-
 arch/arm/mach-pxa/colibri-pxa270-income.c          |    3 +-
 arch/arm/mach-pxa/corgi.c                          |    2 +-
 arch/arm/mach-pxa/csb726.c                         |    2 +-
 arch/arm/mach-pxa/devices.c                        |    2 +-
 arch/arm/mach-pxa/em-x270.c                        |    2 +-
 arch/arm/mach-pxa/ezx.c                            |    2 +-
 arch/arm/mach-pxa/hx4700.c                         |    2 +-
 arch/arm/mach-pxa/littleton.c                      |    2 +-
 arch/arm/mach-pxa/magician.c                       |    2 +-
 arch/arm/mach-pxa/mainstone.c                      |    2 +-
 arch/arm/mach-pxa/mioa701.c                        |    2 +-
 arch/arm/mach-pxa/mxm8x10.c                        |    2 +-
 arch/arm/mach-pxa/palm27x.c                        |    3 +-
 arch/arm/mach-pxa/pcm990-baseboard.c               |    2 +-
 arch/arm/mach-pxa/poodle.c                         |    2 +-
 arch/arm/mach-pxa/pxa27x.c                         |    2 +-
 arch/arm/mach-pxa/pxa3xx.c                         |    2 +-
 arch/arm/mach-pxa/raumfeld.c                       |    2 +-
 arch/arm/mach-pxa/saar.c                           |    2 +-
 arch/arm/mach-pxa/spitz.c                          |    3 +-
 arch/arm/mach-pxa/stargate2.c                      |    2 +-
 arch/arm/mach-pxa/tavorevb3.c                      |    3 +-
 arch/arm/mach-pxa/tosa.c                           |    2 +-
 arch/arm/mach-pxa/trizeps4.c                       |    2 +-
 arch/arm/mach-pxa/viper.c                          |    2 +-
 arch/arm/mach-pxa/vpac270.c                        |    3 +-
 arch/arm/mach-pxa/xcep.c                           |    3 +-
 arch/arm/mach-pxa/z2.c                             |    3 +-
 arch/arm/mach-pxa/zeus.c                           |    3 +-
 arch/arm/mach-pxa/zylonite_pxa300.c                |    2 +-
 arch/x86/include/asm/pxa_i2c.h                     |   24 +++
 drivers/i2c/busses/Kconfig                         |    7 +-
 drivers/i2c/busses/Makefile                        |    1 +
 drivers/i2c/busses/i2c-pxa-pci.c                   |  160 ++++++++++++++++++++
 drivers/i2c/busses/i2c-pxa.c                       |   70 +++++----
 .../plat/i2c.h => include/linux/i2c/pxa-i2c.h      |    1 +
 42 files changed, 282 insertions(+), 79 deletions(-)
 create mode 100644 arch/arm/include/asm/pxa_i2c.h
 create mode 100644 arch/x86/include/asm/pxa_i2c.h
 create mode 100644 drivers/i2c/busses/i2c-pxa-pci.c
 rename arch/arm/plat-pxa/include/plat/i2c.h => include/linux/i2c/pxa-i2c.h (99%)

Sebastian

^ permalink raw reply	[flat|nested] 48+ messages in thread

* I2C support for Sodaville
@ 2010-11-24 21:20 ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 48+ messages in thread
From: Sebastian Andrzej Siewior @ 2010-11-24 21:20 UTC (permalink / raw)
  To: linux-arm-kernel

The I2C core inside Sodaville is very much the same as in PXA25x.
I Cc the ARM folks because patch 2 reorganizes some files so that they
can be accessed from x86.
The I2C device is behind a PCI bus. The PCI probe code simply creates
three platform devices so we don't have much changes to the platform
driver. There is no clock framework on x86 and the peripherals don't
support changing their clocks or to enable/disable them. So I provided
dummy function which keep the driver happy.
This series indirectly depends on the SPI series I've sent earlier
because both modify include files and the spi & i2c includes are sometimes
too close to each other.

The patch series has been created with the -M option so file moves can
be easily noticed. The whole series (including spi) is also available at
  git://git.linutronix.de/users/bigeasy/soda.git spi-i2c

Sebastian Andrzej Siewior (7):
      i2c/pxa2xx: Don't touch ISAR if not in slave mode
      arm/pxa2xx: reorganize I2C files
      i2c/pxa2xx: Add PCI support for PXA I2C controller
      i2c/pxa2xx: add support for shared IRQ handler
      i2c/pxa2xx: check timeout correctly
      i2c/pxa2xx: reset the chip if the bus is not free
      i2c/pxa2xx: pass of_node from platform driver to adapter

 arch/arm/include/asm/pxa_i2c.h                     |   19 +++
 arch/arm/mach-mmp/include/mach/mmp2.h              |    2 +-
 arch/arm/mach-mmp/include/mach/pxa168.h            |    2 +-
 arch/arm/mach-mmp/include/mach/pxa910.h            |    2 +-
 arch/arm/mach-pxa/balloon3.c                       |    3 +-
 arch/arm/mach-pxa/cm-x300.c                        |    2 +-
 arch/arm/mach-pxa/colibri-pxa270-income.c          |    3 +-
 arch/arm/mach-pxa/corgi.c                          |    2 +-
 arch/arm/mach-pxa/csb726.c                         |    2 +-
 arch/arm/mach-pxa/devices.c                        |    2 +-
 arch/arm/mach-pxa/em-x270.c                        |    2 +-
 arch/arm/mach-pxa/ezx.c                            |    2 +-
 arch/arm/mach-pxa/hx4700.c                         |    2 +-
 arch/arm/mach-pxa/littleton.c                      |    2 +-
 arch/arm/mach-pxa/magician.c                       |    2 +-
 arch/arm/mach-pxa/mainstone.c                      |    2 +-
 arch/arm/mach-pxa/mioa701.c                        |    2 +-
 arch/arm/mach-pxa/mxm8x10.c                        |    2 +-
 arch/arm/mach-pxa/palm27x.c                        |    3 +-
 arch/arm/mach-pxa/pcm990-baseboard.c               |    2 +-
 arch/arm/mach-pxa/poodle.c                         |    2 +-
 arch/arm/mach-pxa/pxa27x.c                         |    2 +-
 arch/arm/mach-pxa/pxa3xx.c                         |    2 +-
 arch/arm/mach-pxa/raumfeld.c                       |    2 +-
 arch/arm/mach-pxa/saar.c                           |    2 +-
 arch/arm/mach-pxa/spitz.c                          |    3 +-
 arch/arm/mach-pxa/stargate2.c                      |    2 +-
 arch/arm/mach-pxa/tavorevb3.c                      |    3 +-
 arch/arm/mach-pxa/tosa.c                           |    2 +-
 arch/arm/mach-pxa/trizeps4.c                       |    2 +-
 arch/arm/mach-pxa/viper.c                          |    2 +-
 arch/arm/mach-pxa/vpac270.c                        |    3 +-
 arch/arm/mach-pxa/xcep.c                           |    3 +-
 arch/arm/mach-pxa/z2.c                             |    3 +-
 arch/arm/mach-pxa/zeus.c                           |    3 +-
 arch/arm/mach-pxa/zylonite_pxa300.c                |    2 +-
 arch/x86/include/asm/pxa_i2c.h                     |   24 +++
 drivers/i2c/busses/Kconfig                         |    7 +-
 drivers/i2c/busses/Makefile                        |    1 +
 drivers/i2c/busses/i2c-pxa-pci.c                   |  160 ++++++++++++++++++++
 drivers/i2c/busses/i2c-pxa.c                       |   70 +++++----
 .../plat/i2c.h => include/linux/i2c/pxa-i2c.h      |    1 +
 42 files changed, 282 insertions(+), 79 deletions(-)
 create mode 100644 arch/arm/include/asm/pxa_i2c.h
 create mode 100644 arch/x86/include/asm/pxa_i2c.h
 create mode 100644 drivers/i2c/busses/i2c-pxa-pci.c
 rename arch/arm/plat-pxa/include/plat/i2c.h => include/linux/i2c/pxa-i2c.h (99%)

Sebastian

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [PATCH 1/7] i2c/pxa2xx: Don't touch ISAR if not in slave mode
  2010-11-24 21:20 ` Sebastian Andrzej Siewior
@ 2010-11-24 21:20     ` Sebastian Andrzej Siewior
  -1 siblings, 0 replies; 48+ messages in thread
From: Sebastian Andrzej Siewior @ 2010-11-24 21:20 UTC (permalink / raw)
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	sodaville-hfZtesqFncYOwBW4kG4KsQ, tglx-hfZtesqFncYOwBW4kG4KsQ,
	eric.y.miao-Re5JQEeQqe8AvxtiuMwx3w, linux-lFZ/pmaqli7XmaaqVzeoHQ,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, Sebastian Andrzej Siewior,
	Dirk Brandewie

The reset functions sets writes the slave address even in not slave
mode. I don't see any reason in writting it if slave mode is not
enabled.
I have here a PXA-I2C variant where this register is not availbale and
as such can not be touched.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
Signed-off-by: Dirk Brandewie <dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/i2c/busses/i2c-pxa.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index f4c19a9..579c8a8 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -418,7 +418,9 @@ static void i2c_pxa_reset(struct pxa_i2c *i2c)
 	writel(I2C_ISR_INIT, _ISR(i2c));
 	writel(readl(_ICR(i2c)) & ~ICR_UR, _ICR(i2c));
 
+#ifdef CONFIG_I2C_PXA_SLAVE
 	writel(i2c->slave_addr, _ISAR(i2c));
+#endif
 
 	/* set control register values */
 	writel(I2C_ICR_INIT | (i2c->fast_mode ? ICR_FM : 0), _ICR(i2c));
-- 
1.7.3.2

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 1/7] i2c/pxa2xx: Don't touch ISAR if not in slave mode
@ 2010-11-24 21:20     ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 48+ messages in thread
From: Sebastian Andrzej Siewior @ 2010-11-24 21:20 UTC (permalink / raw)
  To: linux-arm-kernel

The reset functions sets writes the slave address even in not slave
mode. I don't see any reason in writting it if slave mode is not
enabled.
I have here a PXA-I2C variant where this register is not availbale and
as such can not be touched.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Dirk Brandewie <dirk.brandewie@gmail.com>
---
 drivers/i2c/busses/i2c-pxa.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index f4c19a9..579c8a8 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -418,7 +418,9 @@ static void i2c_pxa_reset(struct pxa_i2c *i2c)
 	writel(I2C_ISR_INIT, _ISR(i2c));
 	writel(readl(_ICR(i2c)) & ~ICR_UR, _ICR(i2c));
 
+#ifdef CONFIG_I2C_PXA_SLAVE
 	writel(i2c->slave_addr, _ISAR(i2c));
+#endif
 
 	/* set control register values */
 	writel(I2C_ICR_INIT | (i2c->fast_mode ? ICR_FM : 0), _ICR(i2c));
-- 
1.7.3.2

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 2/7] arm/pxa2xx: reorganize I2C files
  2010-11-24 21:20 ` Sebastian Andrzej Siewior
@ 2010-11-24 21:20     ` Sebastian Andrzej Siewior
  -1 siblings, 0 replies; 48+ messages in thread
From: Sebastian Andrzej Siewior @ 2010-11-24 21:20 UTC (permalink / raw)
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	sodaville-hfZtesqFncYOwBW4kG4KsQ, tglx-hfZtesqFncYOwBW4kG4KsQ,
	eric.y.miao-Re5JQEeQqe8AvxtiuMwx3w, linux-lFZ/pmaqli7XmaaqVzeoHQ,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, Sebastian Andrzej Siewior,
	Dirk Brandewie

This patch moves the register definitions into include/asm so it can be
accessed from X86 the same way as on ARM. This move also alters the
unused register offset definitins (IBMR, ...) and uses them in the
calculation macros (_IBMR,...).
The header file from plat-pxa is moved the include/linux for the same
reason.
This change should make no functional change to the PXA code. The move
is verified by building the following defconfigs:
  cm_x2xx_defconfig corgi_defconfig em_x270_defconfig ezx_defconfig
  imote2_defconfig pxa3xx_defconfig spitz_defconfig zeus_defconfig
  raumfeld_defconfig magician_defconfig mmp2_defconfig pxa168_defconfig
  pxa910_defconfig

Signed-off-by: Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
Signed-off-by: Dirk Brandewie <dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 arch/arm/include/asm/pxa_i2c.h                     |   19 +++++++++++++++++++
 arch/arm/mach-mmp/include/mach/mmp2.h              |    2 +-
 arch/arm/mach-mmp/include/mach/pxa168.h            |    2 +-
 arch/arm/mach-mmp/include/mach/pxa910.h            |    2 +-
 arch/arm/mach-pxa/balloon3.c                       |    3 +--
 arch/arm/mach-pxa/cm-x300.c                        |    2 +-
 arch/arm/mach-pxa/colibri-pxa270-income.c          |    3 +--
 arch/arm/mach-pxa/corgi.c                          |    2 +-
 arch/arm/mach-pxa/csb726.c                         |    2 +-
 arch/arm/mach-pxa/devices.c                        |    2 +-
 arch/arm/mach-pxa/em-x270.c                        |    2 +-
 arch/arm/mach-pxa/ezx.c                            |    2 +-
 arch/arm/mach-pxa/hx4700.c                         |    2 +-
 arch/arm/mach-pxa/littleton.c                      |    2 +-
 arch/arm/mach-pxa/magician.c                       |    2 +-
 arch/arm/mach-pxa/mainstone.c                      |    2 +-
 arch/arm/mach-pxa/mioa701.c                        |    2 +-
 arch/arm/mach-pxa/mxm8x10.c                        |    2 +-
 arch/arm/mach-pxa/palm27x.c                        |    3 +--
 arch/arm/mach-pxa/pcm990-baseboard.c               |    2 +-
 arch/arm/mach-pxa/poodle.c                         |    2 +-
 arch/arm/mach-pxa/pxa27x.c                         |    2 +-
 arch/arm/mach-pxa/pxa3xx.c                         |    2 +-
 arch/arm/mach-pxa/raumfeld.c                       |    2 +-
 arch/arm/mach-pxa/saar.c                           |    2 +-
 arch/arm/mach-pxa/spitz.c                          |    3 +--
 arch/arm/mach-pxa/stargate2.c                      |    2 +-
 arch/arm/mach-pxa/tavorevb3.c                      |    3 +--
 arch/arm/mach-pxa/tosa.c                           |    2 +-
 arch/arm/mach-pxa/trizeps4.c                       |    2 +-
 arch/arm/mach-pxa/viper.c                          |    2 +-
 arch/arm/mach-pxa/vpac270.c                        |    3 +--
 arch/arm/mach-pxa/xcep.c                           |    3 +--
 arch/arm/mach-pxa/z2.c                             |    3 +--
 arch/arm/mach-pxa/zeus.c                           |    3 +--
 arch/arm/mach-pxa/zylonite_pxa300.c                |    2 +-
 drivers/i2c/busses/i2c-pxa.c                       |   16 ++--------------
 .../plat/i2c.h => include/linux/i2c/pxa-i2c.h      |    1 +
 38 files changed, 57 insertions(+), 58 deletions(-)
 create mode 100644 arch/arm/include/asm/pxa_i2c.h
 rename arch/arm/plat-pxa/include/plat/i2c.h => include/linux/i2c/pxa-i2c.h (99%)

diff --git a/arch/arm/include/asm/pxa_i2c.h b/arch/arm/include/asm/pxa_i2c.h
new file mode 100644
index 0000000..f6da8a1
--- /dev/null
+++ b/arch/arm/include/asm/pxa_i2c.h
@@ -0,0 +1,19 @@
+#ifndef __ASM_PXA_I2C_H__
+#define __ASM_PXA_I2C_H__
+
+/*
+ * I2C registers definitions
+ */
+#define IBMR		(0x00)
+#define IDBR		(0x04)
+#define ICR		(0x08)
+#define ISR		(0x0c)
+#define ISAR		(0x10)
+
+#define _IBMR(i2c)	((i2c)->reg_base + (IBMR << (i2c)->reg_shift))
+#define _IDBR(i2c)	((i2c)->reg_base + (IDBR << (i2c)->reg_shift))
+#define _ICR(i2c)	((i2c)->reg_base + (ICR << (i2c)->reg_shift))
+#define _ISR(i2c)	((i2c)->reg_base + (ISR << (i2c)->reg_shift))
+#define _ISAR(i2c)	((i2c)->reg_base + (ISAR << (i2c)->reg_shift))
+
+#endif
diff --git a/arch/arm/mach-mmp/include/mach/mmp2.h b/arch/arm/mach-mmp/include/mach/mmp2.h
index dbba6e8..95adfea 100644
--- a/arch/arm/mach-mmp/include/mach/mmp2.h
+++ b/arch/arm/mach-mmp/include/mach/mmp2.h
@@ -9,8 +9,8 @@ extern void __init mmp2_init_irq(void);
 extern void mmp2_clear_pmic_int(void);
 
 #include <linux/i2c.h>
+#include <linux/i2c/pxa-i2c.h>
 #include <mach/devices.h>
-#include <plat/i2c.h>
 
 extern struct pxa_device_desc mmp2_device_uart1;
 extern struct pxa_device_desc mmp2_device_uart2;
diff --git a/arch/arm/mach-mmp/include/mach/pxa168.h b/arch/arm/mach-mmp/include/mach/pxa168.h
index 1801e42..a52b3d2 100644
--- a/arch/arm/mach-mmp/include/mach/pxa168.h
+++ b/arch/arm/mach-mmp/include/mach/pxa168.h
@@ -8,8 +8,8 @@ extern void __init pxa168_init_irq(void);
 extern void pxa168_clear_keypad_wakeup(void);
 
 #include <linux/i2c.h>
+#include <linux/i2c/pxa-i2c.h>
 #include <mach/devices.h>
-#include <plat/i2c.h>
 #include <plat/pxa3xx_nand.h>
 #include <video/pxa168fb.h>
 #include <plat/pxa27x_keypad.h>
diff --git a/arch/arm/mach-mmp/include/mach/pxa910.h b/arch/arm/mach-mmp/include/mach/pxa910.h
index f13c49d..91be755 100644
--- a/arch/arm/mach-mmp/include/mach/pxa910.h
+++ b/arch/arm/mach-mmp/include/mach/pxa910.h
@@ -7,8 +7,8 @@ extern struct sys_timer pxa910_timer;
 extern void __init pxa910_init_irq(void);
 
 #include <linux/i2c.h>
+#include <linux/i2c/pxa-i2c.h>
 #include <mach/devices.h>
-#include <plat/i2c.h>
 #include <plat/pxa3xx_nand.h>
 
 extern struct pxa_device_desc pxa910_device_uart1;
diff --git a/arch/arm/mach-pxa/balloon3.c b/arch/arm/mach-pxa/balloon3.c
index 21e1889..c137e45 100644
--- a/arch/arm/mach-pxa/balloon3.c
+++ b/arch/arm/mach-pxa/balloon3.c
@@ -27,6 +27,7 @@
 #include <linux/mtd/partitions.h>
 #include <linux/types.h>
 #include <linux/i2c/pcf857x.h>
+#include <linux/i2c/pxa-i2c.h>
 #include <linux/mtd/nand.h>
 #include <linux/mtd/physmap.h>
 #include <linux/regulator/max1586.h>
@@ -51,8 +52,6 @@
 #include <mach/irda.h>
 #include <mach/ohci.h>
 
-#include <plat/i2c.h>
-
 #include "generic.h"
 #include "devices.h"
 
diff --git a/arch/arm/mach-pxa/cm-x300.c b/arch/arm/mach-pxa/cm-x300.c
index 922b107..fb12504 100644
--- a/arch/arm/mach-pxa/cm-x300.c
+++ b/arch/arm/mach-pxa/cm-x300.c
@@ -29,6 +29,7 @@
 
 #include <linux/i2c.h>
 #include <linux/i2c/pca953x.h>
+#include <linux/i2c/pxa-i2c.h>
 
 #include <linux/mfd/da903x.h>
 #include <linux/regulator/machine.h>
@@ -48,7 +49,6 @@
 #include <mach/pxafb.h>
 #include <mach/mmc.h>
 #include <mach/ohci.h>
-#include <plat/i2c.h>
 #include <plat/pxa3xx_nand.h>
 #include <mach/audio.h>
 #include <mach/pxa3xx-u2d.h>
diff --git a/arch/arm/mach-pxa/colibri-pxa270-income.c b/arch/arm/mach-pxa/colibri-pxa270-income.c
index 37f0f3e..c2e1955 100644
--- a/arch/arm/mach-pxa/colibri-pxa270-income.c
+++ b/arch/arm/mach-pxa/colibri-pxa270-income.c
@@ -21,6 +21,7 @@
 #include <linux/kernel.h>
 #include <linux/platform_device.h>
 #include <linux/pwm_backlight.h>
+#include <linux/i2c/pxa-i2c.h>
 #include <linux/sysdev.h>
 
 #include <asm/irq.h>
@@ -33,8 +34,6 @@
 #include <mach/pxa27x-udc.h>
 #include <mach/pxafb.h>
 
-#include <plat/i2c.h>
-
 #include "devices.h"
 #include "generic.h"
 
diff --git a/arch/arm/mach-pxa/corgi.c b/arch/arm/mach-pxa/corgi.c
index 3b8dcac..c96c37b 100644
--- a/arch/arm/mach-pxa/corgi.c
+++ b/arch/arm/mach-pxa/corgi.c
@@ -24,6 +24,7 @@
 #include <linux/gpio.h>
 #include <linux/backlight.h>
 #include <linux/i2c.h>
+#include <linux/i2c/pxa-i2c.h>
 #include <linux/io.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/ads7846.h>
@@ -45,7 +46,6 @@
 #include <asm/mach/irq.h>
 
 #include <mach/pxa25x.h>
-#include <plat/i2c.h>
 #include <mach/irda.h>
 #include <mach/mmc.h>
 #include <mach/udc.h>
diff --git a/arch/arm/mach-pxa/csb726.c b/arch/arm/mach-pxa/csb726.c
index 57cacaf..7cdc8e0 100644
--- a/arch/arm/mach-pxa/csb726.c
+++ b/arch/arm/mach-pxa/csb726.c
@@ -17,12 +17,12 @@
 #include <linux/mtd/partitions.h>
 #include <linux/sm501.h>
 #include <linux/smsc911x.h>
+#include <linux/i2c/pxa-i2c.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 #include <mach/csb726.h>
 #include <mach/mfp-pxa27x.h>
-#include <plat/i2c.h>
 #include <mach/mmc.h>
 #include <mach/ohci.h>
 #include <mach/pxa2xx-regs.h>
diff --git a/arch/arm/mach-pxa/devices.c b/arch/arm/mach-pxa/devices.c
index c4f9c71..0af4119 100644
--- a/arch/arm/mach-pxa/devices.c
+++ b/arch/arm/mach-pxa/devices.c
@@ -4,6 +4,7 @@
 #include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
 #include <linux/spi/pxa2xx_spi.h>
+#include <linux/i2c/pxa-i2c.h>
 
 #include <asm/pmu.h>
 #include <mach/udc.h>
@@ -16,7 +17,6 @@
 #include <mach/camera.h>
 #include <mach/audio.h>
 #include <mach/hardware.h>
-#include <plat/i2c.h>
 #include <plat/pxa3xx_nand.h>
 
 #include "devices.h"
diff --git a/arch/arm/mach-pxa/em-x270.c b/arch/arm/mach-pxa/em-x270.c
index b20b944..c89eaf7 100644
--- a/arch/arm/mach-pxa/em-x270.c
+++ b/arch/arm/mach-pxa/em-x270.c
@@ -31,6 +31,7 @@
 #include <linux/apm-emulation.h>
 #include <linux/i2c.h>
 #include <linux/i2c/pca953x.h>
+#include <linux/i2c/pxa-i2c.h>
 #include <linux/regulator/userspace-consumer.h>
 
 #include <media/soc_camera.h>
@@ -45,7 +46,6 @@
 #include <mach/ohci.h>
 #include <mach/mmc.h>
 #include <plat/pxa27x_keypad.h>
-#include <plat/i2c.h>
 #include <mach/camera.h>
 
 #include "generic.h"
diff --git a/arch/arm/mach-pxa/ezx.c b/arch/arm/mach-pxa/ezx.c
index 142c711..15cbf6b 100644
--- a/arch/arm/mach-pxa/ezx.c
+++ b/arch/arm/mach-pxa/ezx.c
@@ -20,6 +20,7 @@
 #include <linux/gpio.h>
 #include <linux/gpio_keys.h>
 #include <linux/leds-lp3944.h>
+#include <linux/i2c/pxa-i2c.h>
 
 #include <media/soc_camera.h>
 
@@ -30,7 +31,6 @@
 #include <mach/pxa27x.h>
 #include <mach/pxafb.h>
 #include <mach/ohci.h>
-#include <plat/i2c.h>
 #include <mach/hardware.h>
 #include <plat/pxa27x_keypad.h>
 #include <mach/camera.h>
diff --git a/arch/arm/mach-pxa/hx4700.c b/arch/arm/mach-pxa/hx4700.c
index f09526f..0f48649 100644
--- a/arch/arm/mach-pxa/hx4700.c
+++ b/arch/arm/mach-pxa/hx4700.c
@@ -35,6 +35,7 @@
 #include <linux/spi/spi.h>
 #include <linux/spi/pxa2xx_spi.h>
 #include <linux/usb/gpio_vbus.h>
+#include <linux/i2c/pxa-i2c.h>
 
 #include <mach/hardware.h>
 #include <asm/mach-types.h>
@@ -42,7 +43,6 @@
 
 #include <mach/pxa27x.h>
 #include <mach/hx4700.h>
-#include <plat/i2c.h>
 #include <mach/irda.h>
 
 #include <video/platform_lcd.h>
diff --git a/arch/arm/mach-pxa/littleton.c b/arch/arm/mach-pxa/littleton.c
index 8051925..abed4ef 100644
--- a/arch/arm/mach-pxa/littleton.c
+++ b/arch/arm/mach-pxa/littleton.c
@@ -28,6 +28,7 @@
 #include <linux/leds.h>
 #include <linux/mfd/da903x.h>
 #include <linux/i2c/max732x.h>
+#include <linux/i2c/pxa-i2c.h>
 
 #include <asm/types.h>
 #include <asm/setup.h>
@@ -45,7 +46,6 @@
 #include <mach/mmc.h>
 #include <plat/pxa27x_keypad.h>
 #include <mach/littleton.h>
-#include <plat/i2c.h>
 #include <plat/pxa3xx_nand.h>
 
 #include "generic.h"
diff --git a/arch/arm/mach-pxa/magician.c b/arch/arm/mach-pxa/magician.c
index 9066376..e025dd3 100644
--- a/arch/arm/mach-pxa/magician.c
+++ b/arch/arm/mach-pxa/magician.c
@@ -28,6 +28,7 @@
 #include <linux/regulator/bq24022.h>
 #include <linux/regulator/machine.h>
 #include <linux/usb/gpio_vbus.h>
+#include <linux/i2c/pxa-i2c.h>
 
 #include <mach/hardware.h>
 #include <asm/mach-types.h>
@@ -36,7 +37,6 @@
 #include <mach/pxa27x.h>
 #include <mach/magician.h>
 #include <mach/pxafb.h>
-#include <plat/i2c.h>
 #include <mach/mmc.h>
 #include <mach/irda.h>
 #include <mach/ohci.h>
diff --git a/arch/arm/mach-pxa/mainstone.c b/arch/arm/mach-pxa/mainstone.c
index a980a5c..7740148 100644
--- a/arch/arm/mach-pxa/mainstone.c
+++ b/arch/arm/mach-pxa/mainstone.c
@@ -27,6 +27,7 @@
 #include <linux/gpio_keys.h>
 #include <linux/pwm_backlight.h>
 #include <linux/smc91x.h>
+#include <linux/i2c/pxa-i2c.h>
 
 #include <asm/types.h>
 #include <asm/setup.h>
@@ -46,7 +47,6 @@
 #include <mach/mainstone.h>
 #include <mach/audio.h>
 #include <mach/pxafb.h>
-#include <plat/i2c.h>
 #include <mach/mmc.h>
 #include <mach/irda.h>
 #include <mach/ohci.h>
diff --git a/arch/arm/mach-pxa/mioa701.c b/arch/arm/mach-pxa/mioa701.c
index f5fb915..3b851f7 100644
--- a/arch/arm/mach-pxa/mioa701.c
+++ b/arch/arm/mach-pxa/mioa701.c
@@ -39,6 +39,7 @@
 #include <linux/usb/gpio_vbus.h>
 #include <linux/regulator/max1586.h>
 #include <linux/slab.h>
+#include <linux/i2c/pxa-i2c.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -50,7 +51,6 @@
 #include <mach/mmc.h>
 #include <mach/udc.h>
 #include <mach/pxa27x-udc.h>
-#include <plat/i2c.h>
 #include <mach/camera.h>
 #include <mach/audio.h>
 #include <media/soc_camera.h>
diff --git a/arch/arm/mach-pxa/mxm8x10.c b/arch/arm/mach-pxa/mxm8x10.c
index 462167a..7cb415a 100644
--- a/arch/arm/mach-pxa/mxm8x10.c
+++ b/arch/arm/mach-pxa/mxm8x10.c
@@ -22,8 +22,8 @@
 #include <linux/serial_8250.h>
 #include <linux/dm9000.h>
 #include <linux/gpio.h>
+#include <linux/i2c/pxa-i2c.h>
 
-#include <plat/i2c.h>
 #include <plat/pxa3xx_nand.h>
 
 #include <mach/pxafb.h>
diff --git a/arch/arm/mach-pxa/palm27x.c b/arch/arm/mach-pxa/palm27x.c
index 405b92a..ad077e8 100644
--- a/arch/arm/mach-pxa/palm27x.c
+++ b/arch/arm/mach-pxa/palm27x.c
@@ -22,6 +22,7 @@
 #include <linux/power_supply.h>
 #include <linux/usb/gpio_vbus.h>
 #include <linux/regulator/max1586.h>
+#include <linux/i2c/pxa-i2c.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -36,8 +37,6 @@
 #include <mach/palmasoc.h>
 #include <mach/palm27x.h>
 
-#include <plat/i2c.h>
-
 #include "generic.h"
 #include "devices.h"
 
diff --git a/arch/arm/mach-pxa/pcm990-baseboard.c b/arch/arm/mach-pxa/pcm990-baseboard.c
index f33647a..8d3c7a9 100644
--- a/arch/arm/mach-pxa/pcm990-baseboard.c
+++ b/arch/arm/mach-pxa/pcm990-baseboard.c
@@ -23,12 +23,12 @@
 #include <linux/irq.h>
 #include <linux/platform_device.h>
 #include <linux/i2c.h>
+#include <linux/i2c/pxa-i2c.h>
 #include <linux/pwm_backlight.h>
 
 #include <media/soc_camera.h>
 
 #include <asm/gpio.h>
-#include <plat/i2c.h>
 #include <mach/camera.h>
 #include <asm/mach/map.h>
 #include <mach/pxa27x.h>
diff --git a/arch/arm/mach-pxa/poodle.c b/arch/arm/mach-pxa/poodle.c
index c05eee3..90c265f 100644
--- a/arch/arm/mach-pxa/poodle.c
+++ b/arch/arm/mach-pxa/poodle.c
@@ -23,6 +23,7 @@
 #include <linux/mtd/physmap.h>
 #include <linux/gpio.h>
 #include <linux/i2c.h>
+#include <linux/i2c/pxa-i2c.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/ads7846.h>
 #include <linux/spi/pxa2xx_spi.h>
@@ -44,7 +45,6 @@
 #include <mach/irda.h>
 #include <mach/poodle.h>
 #include <mach/pxafb.h>
-#include <plat/i2c.h>
 
 #include <asm/hardware/scoop.h>
 #include <asm/hardware/locomo.h>
diff --git a/arch/arm/mach-pxa/pxa27x.c b/arch/arm/mach-pxa/pxa27x.c
index d1fbf29..1c77e89 100644
--- a/arch/arm/mach-pxa/pxa27x.c
+++ b/arch/arm/mach-pxa/pxa27x.c
@@ -17,6 +17,7 @@
 #include <linux/suspend.h>
 #include <linux/platform_device.h>
 #include <linux/sysdev.h>
+#include <linux/i2c/pxa-i2c.h>
 
 #include <mach/hardware.h>
 #include <asm/irq.h>
@@ -27,7 +28,6 @@
 #include <mach/ohci.h>
 #include <mach/pm.h>
 #include <mach/dma.h>
-#include <plat/i2c.h>
 
 #include "generic.h"
 #include "devices.h"
diff --git a/arch/arm/mach-pxa/pxa3xx.c b/arch/arm/mach-pxa/pxa3xx.c
index d1c747c..c9d9729 100644
--- a/arch/arm/mach-pxa/pxa3xx.c
+++ b/arch/arm/mach-pxa/pxa3xx.c
@@ -21,6 +21,7 @@
 #include <linux/irq.h>
 #include <linux/io.h>
 #include <linux/sysdev.h>
+#include <linux/i2c/pxa-i2c.h>
 
 #include <mach/hardware.h>
 #include <mach/gpio.h>
@@ -30,7 +31,6 @@
 #include <mach/pm.h>
 #include <mach/dma.h>
 #include <mach/regs-intc.h>
-#include <plat/i2c.h>
 
 #include "generic.h"
 #include "devices.h"
diff --git a/arch/arm/mach-pxa/raumfeld.c b/arch/arm/mach-pxa/raumfeld.c
index 4121d03..dc35d85 100644
--- a/arch/arm/mach-pxa/raumfeld.c
+++ b/arch/arm/mach-pxa/raumfeld.c
@@ -32,6 +32,7 @@
 #include <linux/sched.h>
 #include <linux/pwm_backlight.h>
 #include <linux/i2c.h>
+#include <linux/i2c/pxa-i2c.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/spi_gpio.h>
 #include <linux/lis3lv02d.h>
@@ -53,7 +54,6 @@
 #include <mach/ohci.h>
 #include <mach/pxafb.h>
 #include <mach/mmc.h>
-#include <plat/i2c.h>
 #include <plat/pxa3xx_nand.h>
 
 #include "generic.h"
diff --git a/arch/arm/mach-pxa/saar.c b/arch/arm/mach-pxa/saar.c
index ffa50e6..6f65b79 100644
--- a/arch/arm/mach-pxa/saar.c
+++ b/arch/arm/mach-pxa/saar.c
@@ -20,6 +20,7 @@
 #include <linux/delay.h>
 #include <linux/fb.h>
 #include <linux/i2c.h>
+#include <linux/i2c/pxa-i2c.h>
 #include <linux/smc91x.h>
 #include <linux/mfd/da903x.h>
 #include <linux/mtd/mtd.h>
@@ -31,7 +32,6 @@
 #include <asm/mach/flash.h>
 
 #include <mach/pxa930.h>
-#include <plat/i2c.h>
 #include <mach/pxafb.h>
 
 #include "devices.h"
diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c
index 4fd5572..109a2a4 100644
--- a/arch/arm/mach-pxa/spitz.c
+++ b/arch/arm/mach-pxa/spitz.c
@@ -19,6 +19,7 @@
 #include <linux/gpio.h>
 #include <linux/leds.h>
 #include <linux/i2c.h>
+#include <linux/i2c/pxa-i2c.h>
 #include <linux/i2c/pca953x.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/ads7846.h>
@@ -44,8 +45,6 @@
 #include <mach/spitz.h>
 #include <mach/sharpsl_pm.h>
 
-#include <plat/i2c.h>
-
 #include "generic.h"
 #include "devices.h"
 
diff --git a/arch/arm/mach-pxa/stargate2.c b/arch/arm/mach-pxa/stargate2.c
index 325f6ac..797471c 100644
--- a/arch/arm/mach-pxa/stargate2.c
+++ b/arch/arm/mach-pxa/stargate2.c
@@ -25,6 +25,7 @@
 #include <linux/mtd/plat-ram.h>
 #include <linux/mtd/partitions.h>
 
+#include <linux/i2c/pxa-i2c.h>
 #include <linux/i2c/pcf857x.h>
 #include <linux/i2c/at24.h>
 #include <linux/smc91x.h>
@@ -43,7 +44,6 @@
 #include <asm/mach/flash.h>
 
 #include <mach/pxa27x.h>
-#include <plat/i2c.h>
 #include <mach/mmc.h>
 #include <mach/udc.h>
 #include <mach/pxa27x-udc.h>
diff --git a/arch/arm/mach-pxa/tavorevb3.c b/arch/arm/mach-pxa/tavorevb3.c
index dc30116..11b8c3e 100644
--- a/arch/arm/mach-pxa/tavorevb3.c
+++ b/arch/arm/mach-pxa/tavorevb3.c
@@ -15,6 +15,7 @@
 #include <linux/platform_device.h>
 #include <linux/interrupt.h>
 #include <linux/i2c.h>
+#include <linux/i2c/pxa-i2c.h>
 #include <linux/gpio.h>
 #include <linux/mfd/88pm860x.h>
 
@@ -23,8 +24,6 @@
 
 #include <mach/pxa930.h>
 
-#include <plat/i2c.h>
-
 #include "devices.h"
 #include "generic.h"
 
diff --git a/arch/arm/mach-pxa/tosa.c b/arch/arm/mach-pxa/tosa.c
index 7b5765d..d48881d 100644
--- a/arch/arm/mach-pxa/tosa.c
+++ b/arch/arm/mach-pxa/tosa.c
@@ -34,6 +34,7 @@
 #include <linux/spi/spi.h>
 #include <linux/spi/pxa2xx_spi.h>
 #include <linux/input/matrix_keypad.h>
+#include <linux/i2c/pxa-i2c.h>
 
 #include <asm/setup.h>
 #include <asm/mach-types.h>
@@ -41,7 +42,6 @@
 #include <mach/pxa25x.h>
 #include <mach/reset.h>
 #include <mach/irda.h>
-#include <plat/i2c.h>
 #include <mach/mmc.h>
 #include <mach/udc.h>
 #include <mach/tosa_bt.h>
diff --git a/arch/arm/mach-pxa/trizeps4.c b/arch/arm/mach-pxa/trizeps4.c
index bdb02a0..995e671 100644
--- a/arch/arm/mach-pxa/trizeps4.c
+++ b/arch/arm/mach-pxa/trizeps4.c
@@ -26,6 +26,7 @@
 #include <linux/dm9000.h>
 #include <linux/mtd/physmap.h>
 #include <linux/mtd/partitions.h>
+#include <linux/i2c/pxa-i2c.h>
 
 #include <asm/types.h>
 #include <asm/setup.h>
@@ -46,7 +47,6 @@
 #include <mach/mmc.h>
 #include <mach/irda.h>
 #include <mach/ohci.h>
-#include <plat/i2c.h>
 
 #include "generic.h"
 #include "devices.h"
diff --git a/arch/arm/mach-pxa/viper.c b/arch/arm/mach-pxa/viper.c
index 438fc9a..d36baac 100644
--- a/arch/arm/mach-pxa/viper.c
+++ b/arch/arm/mach-pxa/viper.c
@@ -36,6 +36,7 @@
 #include <linux/gpio.h>
 #include <linux/jiffies.h>
 #include <linux/i2c-gpio.h>
+#include <linux/i2c/pxa-i2c.h>
 #include <linux/serial_8250.h>
 #include <linux/smc91x.h>
 #include <linux/pwm_backlight.h>
@@ -47,7 +48,6 @@
 #include <mach/pxa25x.h>
 #include <mach/audio.h>
 #include <mach/pxafb.h>
-#include <plat/i2c.h>
 #include <mach/regs-uart.h>
 #include <mach/arcom-pcmcia.h>
 #include <mach/viper.h>
diff --git a/arch/arm/mach-pxa/vpac270.c b/arch/arm/mach-pxa/vpac270.c
index f45ac09..4c812f9 100644
--- a/arch/arm/mach-pxa/vpac270.c
+++ b/arch/arm/mach-pxa/vpac270.c
@@ -26,6 +26,7 @@
 #include <linux/ucb1400.h>
 #include <linux/ata_platform.h>
 #include <linux/regulator/max1586.h>
+#include <linux/i2c/pxa-i2c.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -40,8 +41,6 @@
 #include <mach/udc.h>
 #include <mach/pata_pxa.h>
 
-#include <plat/i2c.h>
-
 #include "generic.h"
 #include "devices.h"
 
diff --git a/arch/arm/mach-pxa/xcep.c b/arch/arm/mach-pxa/xcep.c
index 3260ce7..e2bd5ce 100644
--- a/arch/arm/mach-pxa/xcep.c
+++ b/arch/arm/mach-pxa/xcep.c
@@ -16,6 +16,7 @@
 
 #include <linux/platform_device.h>
 #include <linux/i2c.h>
+#include <linux/i2c/pxa-i2c.h>
 #include <linux/smc91x.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/partitions.h>
@@ -26,8 +27,6 @@
 #include <asm/mach/irq.h>
 #include <asm/mach/map.h>
 
-#include <plat/i2c.h>
-
 #include <mach/hardware.h>
 #include <mach/pxa2xx-regs.h>
 #include <mach/mfp-pxa25x.h>
diff --git a/arch/arm/mach-pxa/z2.c b/arch/arm/mach-pxa/z2.c
index 1b8b71b..07c93a7 100644
--- a/arch/arm/mach-pxa/z2.c
+++ b/arch/arm/mach-pxa/z2.c
@@ -29,6 +29,7 @@
 #include <linux/gpio_keys.h>
 #include <linux/delay.h>
 #include <linux/regulator/machine.h>
+#include <linux/i2c/pxa-i2c.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -40,8 +41,6 @@
 #include <mach/mmc.h>
 #include <plat/pxa27x_keypad.h>
 
-#include <plat/i2c.h>
-
 #include "generic.h"
 #include "devices.h"
 
diff --git a/arch/arm/mach-pxa/zeus.c b/arch/arm/mach-pxa/zeus.c
index f5c9f30..838cafb 100644
--- a/arch/arm/mach-pxa/zeus.c
+++ b/arch/arm/mach-pxa/zeus.c
@@ -25,6 +25,7 @@
 #include <linux/mtd/partitions.h>
 #include <linux/mtd/physmap.h>
 #include <linux/i2c.h>
+#include <linux/i2c/pxa-i2c.h>
 #include <linux/i2c/pca953x.h>
 #include <linux/apm-emulation.h>
 #include <linux/can/platform/mcp251x.h>
@@ -33,8 +34,6 @@
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
 
-#include <plat/i2c.h>
-
 #include <mach/pxa2xx-regs.h>
 #include <mach/regs-uart.h>
 #include <mach/ohci.h>
diff --git a/arch/arm/mach-pxa/zylonite_pxa300.c b/arch/arm/mach-pxa/zylonite_pxa300.c
index 3aa73b3..93c64d8 100644
--- a/arch/arm/mach-pxa/zylonite_pxa300.c
+++ b/arch/arm/mach-pxa/zylonite_pxa300.c
@@ -17,11 +17,11 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/i2c.h>
+#include <linux/i2c/pxa-i2c.h>
 #include <linux/i2c/pca953x.h>
 #include <linux/gpio.h>
 
 #include <mach/pxa300.h>
-#include <plat/i2c.h>
 #include <mach/zylonite.h>
 
 #include "generic.h"
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index 579c8a8..dc66fde 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -34,9 +34,9 @@
 #include <linux/clk.h>
 #include <linux/slab.h>
 #include <linux/io.h>
+#include <linux/i2c/pxa-i2c.h>
 
 #include <asm/irq.h>
-#include <plat/i2c.h>
 
 /*
  * I2C register offsets will be shifted 0 or 1 bit left, depending on
@@ -54,14 +54,8 @@ static const struct platform_device_id i2c_pxa_id_table[] = {
 MODULE_DEVICE_TABLE(platform, i2c_pxa_id_table);
 
 /*
- * I2C registers and bit definitions
+ * I2C bit definitions
  */
-#define IBMR		(0x00)
-#define IDBR		(0x08)
-#define ICR		(0x10)
-#define ISR		(0x18)
-#define ISAR		(0x20)
-
 #define ICR_START	(1 << 0)	   /* start bit */
 #define ICR_STOP	(1 << 1)	   /* stop bit */
 #define ICR_ACKNAK	(1 << 2)	   /* send ACK(0) or NAK(1) */
@@ -121,12 +115,6 @@ struct pxa_i2c {
 	unsigned int		fast_mode :1;
 };
 
-#define _IBMR(i2c)	((i2c)->reg_base + (0x0 << (i2c)->reg_shift))
-#define _IDBR(i2c)	((i2c)->reg_base + (0x4 << (i2c)->reg_shift))
-#define _ICR(i2c)	((i2c)->reg_base + (0x8 << (i2c)->reg_shift))
-#define _ISR(i2c)	((i2c)->reg_base + (0xc << (i2c)->reg_shift))
-#define _ISAR(i2c)	((i2c)->reg_base + (0x10 << (i2c)->reg_shift))
-
 /*
  * I2C Slave mode address
  */
diff --git a/arch/arm/plat-pxa/include/plat/i2c.h b/include/linux/i2c/pxa-i2c.h
similarity index 99%
rename from arch/arm/plat-pxa/include/plat/i2c.h
rename to include/linux/i2c/pxa-i2c.h
index 1a9f65e..f751aa0 100644
--- a/arch/arm/plat-pxa/include/plat/i2c.h
+++ b/include/linux/i2c/pxa-i2c.h
@@ -10,6 +10,7 @@
  */
 #ifndef _I2C_PXA_H_
 #define _I2C_PXA_H_
+#include <asm/pxa_i2c.h>
 
 #if 0
 #define DEF_TIMEOUT             3
-- 
1.7.3.2

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 2/7] arm/pxa2xx: reorganize I2C files
@ 2010-11-24 21:20     ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 48+ messages in thread
From: Sebastian Andrzej Siewior @ 2010-11-24 21:20 UTC (permalink / raw)
  To: linux-arm-kernel

This patch moves the register definitions into include/asm so it can be
accessed from X86 the same way as on ARM. This move also alters the
unused register offset definitins (IBMR, ...) and uses them in the
calculation macros (_IBMR,...).
The header file from plat-pxa is moved the include/linux for the same
reason.
This change should make no functional change to the PXA code. The move
is verified by building the following defconfigs:
  cm_x2xx_defconfig corgi_defconfig em_x270_defconfig ezx_defconfig
  imote2_defconfig pxa3xx_defconfig spitz_defconfig zeus_defconfig
  raumfeld_defconfig magician_defconfig mmp2_defconfig pxa168_defconfig
  pxa910_defconfig

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Dirk Brandewie <dirk.brandewie@gmail.com>
---
 arch/arm/include/asm/pxa_i2c.h                     |   19 +++++++++++++++++++
 arch/arm/mach-mmp/include/mach/mmp2.h              |    2 +-
 arch/arm/mach-mmp/include/mach/pxa168.h            |    2 +-
 arch/arm/mach-mmp/include/mach/pxa910.h            |    2 +-
 arch/arm/mach-pxa/balloon3.c                       |    3 +--
 arch/arm/mach-pxa/cm-x300.c                        |    2 +-
 arch/arm/mach-pxa/colibri-pxa270-income.c          |    3 +--
 arch/arm/mach-pxa/corgi.c                          |    2 +-
 arch/arm/mach-pxa/csb726.c                         |    2 +-
 arch/arm/mach-pxa/devices.c                        |    2 +-
 arch/arm/mach-pxa/em-x270.c                        |    2 +-
 arch/arm/mach-pxa/ezx.c                            |    2 +-
 arch/arm/mach-pxa/hx4700.c                         |    2 +-
 arch/arm/mach-pxa/littleton.c                      |    2 +-
 arch/arm/mach-pxa/magician.c                       |    2 +-
 arch/arm/mach-pxa/mainstone.c                      |    2 +-
 arch/arm/mach-pxa/mioa701.c                        |    2 +-
 arch/arm/mach-pxa/mxm8x10.c                        |    2 +-
 arch/arm/mach-pxa/palm27x.c                        |    3 +--
 arch/arm/mach-pxa/pcm990-baseboard.c               |    2 +-
 arch/arm/mach-pxa/poodle.c                         |    2 +-
 arch/arm/mach-pxa/pxa27x.c                         |    2 +-
 arch/arm/mach-pxa/pxa3xx.c                         |    2 +-
 arch/arm/mach-pxa/raumfeld.c                       |    2 +-
 arch/arm/mach-pxa/saar.c                           |    2 +-
 arch/arm/mach-pxa/spitz.c                          |    3 +--
 arch/arm/mach-pxa/stargate2.c                      |    2 +-
 arch/arm/mach-pxa/tavorevb3.c                      |    3 +--
 arch/arm/mach-pxa/tosa.c                           |    2 +-
 arch/arm/mach-pxa/trizeps4.c                       |    2 +-
 arch/arm/mach-pxa/viper.c                          |    2 +-
 arch/arm/mach-pxa/vpac270.c                        |    3 +--
 arch/arm/mach-pxa/xcep.c                           |    3 +--
 arch/arm/mach-pxa/z2.c                             |    3 +--
 arch/arm/mach-pxa/zeus.c                           |    3 +--
 arch/arm/mach-pxa/zylonite_pxa300.c                |    2 +-
 drivers/i2c/busses/i2c-pxa.c                       |   16 ++--------------
 .../plat/i2c.h => include/linux/i2c/pxa-i2c.h      |    1 +
 38 files changed, 57 insertions(+), 58 deletions(-)
 create mode 100644 arch/arm/include/asm/pxa_i2c.h
 rename arch/arm/plat-pxa/include/plat/i2c.h => include/linux/i2c/pxa-i2c.h (99%)

diff --git a/arch/arm/include/asm/pxa_i2c.h b/arch/arm/include/asm/pxa_i2c.h
new file mode 100644
index 0000000..f6da8a1
--- /dev/null
+++ b/arch/arm/include/asm/pxa_i2c.h
@@ -0,0 +1,19 @@
+#ifndef __ASM_PXA_I2C_H__
+#define __ASM_PXA_I2C_H__
+
+/*
+ * I2C registers definitions
+ */
+#define IBMR		(0x00)
+#define IDBR		(0x04)
+#define ICR		(0x08)
+#define ISR		(0x0c)
+#define ISAR		(0x10)
+
+#define _IBMR(i2c)	((i2c)->reg_base + (IBMR << (i2c)->reg_shift))
+#define _IDBR(i2c)	((i2c)->reg_base + (IDBR << (i2c)->reg_shift))
+#define _ICR(i2c)	((i2c)->reg_base + (ICR << (i2c)->reg_shift))
+#define _ISR(i2c)	((i2c)->reg_base + (ISR << (i2c)->reg_shift))
+#define _ISAR(i2c)	((i2c)->reg_base + (ISAR << (i2c)->reg_shift))
+
+#endif
diff --git a/arch/arm/mach-mmp/include/mach/mmp2.h b/arch/arm/mach-mmp/include/mach/mmp2.h
index dbba6e8..95adfea 100644
--- a/arch/arm/mach-mmp/include/mach/mmp2.h
+++ b/arch/arm/mach-mmp/include/mach/mmp2.h
@@ -9,8 +9,8 @@ extern void __init mmp2_init_irq(void);
 extern void mmp2_clear_pmic_int(void);
 
 #include <linux/i2c.h>
+#include <linux/i2c/pxa-i2c.h>
 #include <mach/devices.h>
-#include <plat/i2c.h>
 
 extern struct pxa_device_desc mmp2_device_uart1;
 extern struct pxa_device_desc mmp2_device_uart2;
diff --git a/arch/arm/mach-mmp/include/mach/pxa168.h b/arch/arm/mach-mmp/include/mach/pxa168.h
index 1801e42..a52b3d2 100644
--- a/arch/arm/mach-mmp/include/mach/pxa168.h
+++ b/arch/arm/mach-mmp/include/mach/pxa168.h
@@ -8,8 +8,8 @@ extern void __init pxa168_init_irq(void);
 extern void pxa168_clear_keypad_wakeup(void);
 
 #include <linux/i2c.h>
+#include <linux/i2c/pxa-i2c.h>
 #include <mach/devices.h>
-#include <plat/i2c.h>
 #include <plat/pxa3xx_nand.h>
 #include <video/pxa168fb.h>
 #include <plat/pxa27x_keypad.h>
diff --git a/arch/arm/mach-mmp/include/mach/pxa910.h b/arch/arm/mach-mmp/include/mach/pxa910.h
index f13c49d..91be755 100644
--- a/arch/arm/mach-mmp/include/mach/pxa910.h
+++ b/arch/arm/mach-mmp/include/mach/pxa910.h
@@ -7,8 +7,8 @@ extern struct sys_timer pxa910_timer;
 extern void __init pxa910_init_irq(void);
 
 #include <linux/i2c.h>
+#include <linux/i2c/pxa-i2c.h>
 #include <mach/devices.h>
-#include <plat/i2c.h>
 #include <plat/pxa3xx_nand.h>
 
 extern struct pxa_device_desc pxa910_device_uart1;
diff --git a/arch/arm/mach-pxa/balloon3.c b/arch/arm/mach-pxa/balloon3.c
index 21e1889..c137e45 100644
--- a/arch/arm/mach-pxa/balloon3.c
+++ b/arch/arm/mach-pxa/balloon3.c
@@ -27,6 +27,7 @@
 #include <linux/mtd/partitions.h>
 #include <linux/types.h>
 #include <linux/i2c/pcf857x.h>
+#include <linux/i2c/pxa-i2c.h>
 #include <linux/mtd/nand.h>
 #include <linux/mtd/physmap.h>
 #include <linux/regulator/max1586.h>
@@ -51,8 +52,6 @@
 #include <mach/irda.h>
 #include <mach/ohci.h>
 
-#include <plat/i2c.h>
-
 #include "generic.h"
 #include "devices.h"
 
diff --git a/arch/arm/mach-pxa/cm-x300.c b/arch/arm/mach-pxa/cm-x300.c
index 922b107..fb12504 100644
--- a/arch/arm/mach-pxa/cm-x300.c
+++ b/arch/arm/mach-pxa/cm-x300.c
@@ -29,6 +29,7 @@
 
 #include <linux/i2c.h>
 #include <linux/i2c/pca953x.h>
+#include <linux/i2c/pxa-i2c.h>
 
 #include <linux/mfd/da903x.h>
 #include <linux/regulator/machine.h>
@@ -48,7 +49,6 @@
 #include <mach/pxafb.h>
 #include <mach/mmc.h>
 #include <mach/ohci.h>
-#include <plat/i2c.h>
 #include <plat/pxa3xx_nand.h>
 #include <mach/audio.h>
 #include <mach/pxa3xx-u2d.h>
diff --git a/arch/arm/mach-pxa/colibri-pxa270-income.c b/arch/arm/mach-pxa/colibri-pxa270-income.c
index 37f0f3e..c2e1955 100644
--- a/arch/arm/mach-pxa/colibri-pxa270-income.c
+++ b/arch/arm/mach-pxa/colibri-pxa270-income.c
@@ -21,6 +21,7 @@
 #include <linux/kernel.h>
 #include <linux/platform_device.h>
 #include <linux/pwm_backlight.h>
+#include <linux/i2c/pxa-i2c.h>
 #include <linux/sysdev.h>
 
 #include <asm/irq.h>
@@ -33,8 +34,6 @@
 #include <mach/pxa27x-udc.h>
 #include <mach/pxafb.h>
 
-#include <plat/i2c.h>
-
 #include "devices.h"
 #include "generic.h"
 
diff --git a/arch/arm/mach-pxa/corgi.c b/arch/arm/mach-pxa/corgi.c
index 3b8dcac..c96c37b 100644
--- a/arch/arm/mach-pxa/corgi.c
+++ b/arch/arm/mach-pxa/corgi.c
@@ -24,6 +24,7 @@
 #include <linux/gpio.h>
 #include <linux/backlight.h>
 #include <linux/i2c.h>
+#include <linux/i2c/pxa-i2c.h>
 #include <linux/io.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/ads7846.h>
@@ -45,7 +46,6 @@
 #include <asm/mach/irq.h>
 
 #include <mach/pxa25x.h>
-#include <plat/i2c.h>
 #include <mach/irda.h>
 #include <mach/mmc.h>
 #include <mach/udc.h>
diff --git a/arch/arm/mach-pxa/csb726.c b/arch/arm/mach-pxa/csb726.c
index 57cacaf..7cdc8e0 100644
--- a/arch/arm/mach-pxa/csb726.c
+++ b/arch/arm/mach-pxa/csb726.c
@@ -17,12 +17,12 @@
 #include <linux/mtd/partitions.h>
 #include <linux/sm501.h>
 #include <linux/smsc911x.h>
+#include <linux/i2c/pxa-i2c.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 #include <mach/csb726.h>
 #include <mach/mfp-pxa27x.h>
-#include <plat/i2c.h>
 #include <mach/mmc.h>
 #include <mach/ohci.h>
 #include <mach/pxa2xx-regs.h>
diff --git a/arch/arm/mach-pxa/devices.c b/arch/arm/mach-pxa/devices.c
index c4f9c71..0af4119 100644
--- a/arch/arm/mach-pxa/devices.c
+++ b/arch/arm/mach-pxa/devices.c
@@ -4,6 +4,7 @@
 #include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
 #include <linux/spi/pxa2xx_spi.h>
+#include <linux/i2c/pxa-i2c.h>
 
 #include <asm/pmu.h>
 #include <mach/udc.h>
@@ -16,7 +17,6 @@
 #include <mach/camera.h>
 #include <mach/audio.h>
 #include <mach/hardware.h>
-#include <plat/i2c.h>
 #include <plat/pxa3xx_nand.h>
 
 #include "devices.h"
diff --git a/arch/arm/mach-pxa/em-x270.c b/arch/arm/mach-pxa/em-x270.c
index b20b944..c89eaf7 100644
--- a/arch/arm/mach-pxa/em-x270.c
+++ b/arch/arm/mach-pxa/em-x270.c
@@ -31,6 +31,7 @@
 #include <linux/apm-emulation.h>
 #include <linux/i2c.h>
 #include <linux/i2c/pca953x.h>
+#include <linux/i2c/pxa-i2c.h>
 #include <linux/regulator/userspace-consumer.h>
 
 #include <media/soc_camera.h>
@@ -45,7 +46,6 @@
 #include <mach/ohci.h>
 #include <mach/mmc.h>
 #include <plat/pxa27x_keypad.h>
-#include <plat/i2c.h>
 #include <mach/camera.h>
 
 #include "generic.h"
diff --git a/arch/arm/mach-pxa/ezx.c b/arch/arm/mach-pxa/ezx.c
index 142c711..15cbf6b 100644
--- a/arch/arm/mach-pxa/ezx.c
+++ b/arch/arm/mach-pxa/ezx.c
@@ -20,6 +20,7 @@
 #include <linux/gpio.h>
 #include <linux/gpio_keys.h>
 #include <linux/leds-lp3944.h>
+#include <linux/i2c/pxa-i2c.h>
 
 #include <media/soc_camera.h>
 
@@ -30,7 +31,6 @@
 #include <mach/pxa27x.h>
 #include <mach/pxafb.h>
 #include <mach/ohci.h>
-#include <plat/i2c.h>
 #include <mach/hardware.h>
 #include <plat/pxa27x_keypad.h>
 #include <mach/camera.h>
diff --git a/arch/arm/mach-pxa/hx4700.c b/arch/arm/mach-pxa/hx4700.c
index f09526f..0f48649 100644
--- a/arch/arm/mach-pxa/hx4700.c
+++ b/arch/arm/mach-pxa/hx4700.c
@@ -35,6 +35,7 @@
 #include <linux/spi/spi.h>
 #include <linux/spi/pxa2xx_spi.h>
 #include <linux/usb/gpio_vbus.h>
+#include <linux/i2c/pxa-i2c.h>
 
 #include <mach/hardware.h>
 #include <asm/mach-types.h>
@@ -42,7 +43,6 @@
 
 #include <mach/pxa27x.h>
 #include <mach/hx4700.h>
-#include <plat/i2c.h>
 #include <mach/irda.h>
 
 #include <video/platform_lcd.h>
diff --git a/arch/arm/mach-pxa/littleton.c b/arch/arm/mach-pxa/littleton.c
index 8051925..abed4ef 100644
--- a/arch/arm/mach-pxa/littleton.c
+++ b/arch/arm/mach-pxa/littleton.c
@@ -28,6 +28,7 @@
 #include <linux/leds.h>
 #include <linux/mfd/da903x.h>
 #include <linux/i2c/max732x.h>
+#include <linux/i2c/pxa-i2c.h>
 
 #include <asm/types.h>
 #include <asm/setup.h>
@@ -45,7 +46,6 @@
 #include <mach/mmc.h>
 #include <plat/pxa27x_keypad.h>
 #include <mach/littleton.h>
-#include <plat/i2c.h>
 #include <plat/pxa3xx_nand.h>
 
 #include "generic.h"
diff --git a/arch/arm/mach-pxa/magician.c b/arch/arm/mach-pxa/magician.c
index 9066376..e025dd3 100644
--- a/arch/arm/mach-pxa/magician.c
+++ b/arch/arm/mach-pxa/magician.c
@@ -28,6 +28,7 @@
 #include <linux/regulator/bq24022.h>
 #include <linux/regulator/machine.h>
 #include <linux/usb/gpio_vbus.h>
+#include <linux/i2c/pxa-i2c.h>
 
 #include <mach/hardware.h>
 #include <asm/mach-types.h>
@@ -36,7 +37,6 @@
 #include <mach/pxa27x.h>
 #include <mach/magician.h>
 #include <mach/pxafb.h>
-#include <plat/i2c.h>
 #include <mach/mmc.h>
 #include <mach/irda.h>
 #include <mach/ohci.h>
diff --git a/arch/arm/mach-pxa/mainstone.c b/arch/arm/mach-pxa/mainstone.c
index a980a5c..7740148 100644
--- a/arch/arm/mach-pxa/mainstone.c
+++ b/arch/arm/mach-pxa/mainstone.c
@@ -27,6 +27,7 @@
 #include <linux/gpio_keys.h>
 #include <linux/pwm_backlight.h>
 #include <linux/smc91x.h>
+#include <linux/i2c/pxa-i2c.h>
 
 #include <asm/types.h>
 #include <asm/setup.h>
@@ -46,7 +47,6 @@
 #include <mach/mainstone.h>
 #include <mach/audio.h>
 #include <mach/pxafb.h>
-#include <plat/i2c.h>
 #include <mach/mmc.h>
 #include <mach/irda.h>
 #include <mach/ohci.h>
diff --git a/arch/arm/mach-pxa/mioa701.c b/arch/arm/mach-pxa/mioa701.c
index f5fb915..3b851f7 100644
--- a/arch/arm/mach-pxa/mioa701.c
+++ b/arch/arm/mach-pxa/mioa701.c
@@ -39,6 +39,7 @@
 #include <linux/usb/gpio_vbus.h>
 #include <linux/regulator/max1586.h>
 #include <linux/slab.h>
+#include <linux/i2c/pxa-i2c.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -50,7 +51,6 @@
 #include <mach/mmc.h>
 #include <mach/udc.h>
 #include <mach/pxa27x-udc.h>
-#include <plat/i2c.h>
 #include <mach/camera.h>
 #include <mach/audio.h>
 #include <media/soc_camera.h>
diff --git a/arch/arm/mach-pxa/mxm8x10.c b/arch/arm/mach-pxa/mxm8x10.c
index 462167a..7cb415a 100644
--- a/arch/arm/mach-pxa/mxm8x10.c
+++ b/arch/arm/mach-pxa/mxm8x10.c
@@ -22,8 +22,8 @@
 #include <linux/serial_8250.h>
 #include <linux/dm9000.h>
 #include <linux/gpio.h>
+#include <linux/i2c/pxa-i2c.h>
 
-#include <plat/i2c.h>
 #include <plat/pxa3xx_nand.h>
 
 #include <mach/pxafb.h>
diff --git a/arch/arm/mach-pxa/palm27x.c b/arch/arm/mach-pxa/palm27x.c
index 405b92a..ad077e8 100644
--- a/arch/arm/mach-pxa/palm27x.c
+++ b/arch/arm/mach-pxa/palm27x.c
@@ -22,6 +22,7 @@
 #include <linux/power_supply.h>
 #include <linux/usb/gpio_vbus.h>
 #include <linux/regulator/max1586.h>
+#include <linux/i2c/pxa-i2c.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -36,8 +37,6 @@
 #include <mach/palmasoc.h>
 #include <mach/palm27x.h>
 
-#include <plat/i2c.h>
-
 #include "generic.h"
 #include "devices.h"
 
diff --git a/arch/arm/mach-pxa/pcm990-baseboard.c b/arch/arm/mach-pxa/pcm990-baseboard.c
index f33647a..8d3c7a9 100644
--- a/arch/arm/mach-pxa/pcm990-baseboard.c
+++ b/arch/arm/mach-pxa/pcm990-baseboard.c
@@ -23,12 +23,12 @@
 #include <linux/irq.h>
 #include <linux/platform_device.h>
 #include <linux/i2c.h>
+#include <linux/i2c/pxa-i2c.h>
 #include <linux/pwm_backlight.h>
 
 #include <media/soc_camera.h>
 
 #include <asm/gpio.h>
-#include <plat/i2c.h>
 #include <mach/camera.h>
 #include <asm/mach/map.h>
 #include <mach/pxa27x.h>
diff --git a/arch/arm/mach-pxa/poodle.c b/arch/arm/mach-pxa/poodle.c
index c05eee3..90c265f 100644
--- a/arch/arm/mach-pxa/poodle.c
+++ b/arch/arm/mach-pxa/poodle.c
@@ -23,6 +23,7 @@
 #include <linux/mtd/physmap.h>
 #include <linux/gpio.h>
 #include <linux/i2c.h>
+#include <linux/i2c/pxa-i2c.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/ads7846.h>
 #include <linux/spi/pxa2xx_spi.h>
@@ -44,7 +45,6 @@
 #include <mach/irda.h>
 #include <mach/poodle.h>
 #include <mach/pxafb.h>
-#include <plat/i2c.h>
 
 #include <asm/hardware/scoop.h>
 #include <asm/hardware/locomo.h>
diff --git a/arch/arm/mach-pxa/pxa27x.c b/arch/arm/mach-pxa/pxa27x.c
index d1fbf29..1c77e89 100644
--- a/arch/arm/mach-pxa/pxa27x.c
+++ b/arch/arm/mach-pxa/pxa27x.c
@@ -17,6 +17,7 @@
 #include <linux/suspend.h>
 #include <linux/platform_device.h>
 #include <linux/sysdev.h>
+#include <linux/i2c/pxa-i2c.h>
 
 #include <mach/hardware.h>
 #include <asm/irq.h>
@@ -27,7 +28,6 @@
 #include <mach/ohci.h>
 #include <mach/pm.h>
 #include <mach/dma.h>
-#include <plat/i2c.h>
 
 #include "generic.h"
 #include "devices.h"
diff --git a/arch/arm/mach-pxa/pxa3xx.c b/arch/arm/mach-pxa/pxa3xx.c
index d1c747c..c9d9729 100644
--- a/arch/arm/mach-pxa/pxa3xx.c
+++ b/arch/arm/mach-pxa/pxa3xx.c
@@ -21,6 +21,7 @@
 #include <linux/irq.h>
 #include <linux/io.h>
 #include <linux/sysdev.h>
+#include <linux/i2c/pxa-i2c.h>
 
 #include <mach/hardware.h>
 #include <mach/gpio.h>
@@ -30,7 +31,6 @@
 #include <mach/pm.h>
 #include <mach/dma.h>
 #include <mach/regs-intc.h>
-#include <plat/i2c.h>
 
 #include "generic.h"
 #include "devices.h"
diff --git a/arch/arm/mach-pxa/raumfeld.c b/arch/arm/mach-pxa/raumfeld.c
index 4121d03..dc35d85 100644
--- a/arch/arm/mach-pxa/raumfeld.c
+++ b/arch/arm/mach-pxa/raumfeld.c
@@ -32,6 +32,7 @@
 #include <linux/sched.h>
 #include <linux/pwm_backlight.h>
 #include <linux/i2c.h>
+#include <linux/i2c/pxa-i2c.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/spi_gpio.h>
 #include <linux/lis3lv02d.h>
@@ -53,7 +54,6 @@
 #include <mach/ohci.h>
 #include <mach/pxafb.h>
 #include <mach/mmc.h>
-#include <plat/i2c.h>
 #include <plat/pxa3xx_nand.h>
 
 #include "generic.h"
diff --git a/arch/arm/mach-pxa/saar.c b/arch/arm/mach-pxa/saar.c
index ffa50e6..6f65b79 100644
--- a/arch/arm/mach-pxa/saar.c
+++ b/arch/arm/mach-pxa/saar.c
@@ -20,6 +20,7 @@
 #include <linux/delay.h>
 #include <linux/fb.h>
 #include <linux/i2c.h>
+#include <linux/i2c/pxa-i2c.h>
 #include <linux/smc91x.h>
 #include <linux/mfd/da903x.h>
 #include <linux/mtd/mtd.h>
@@ -31,7 +32,6 @@
 #include <asm/mach/flash.h>
 
 #include <mach/pxa930.h>
-#include <plat/i2c.h>
 #include <mach/pxafb.h>
 
 #include "devices.h"
diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c
index 4fd5572..109a2a4 100644
--- a/arch/arm/mach-pxa/spitz.c
+++ b/arch/arm/mach-pxa/spitz.c
@@ -19,6 +19,7 @@
 #include <linux/gpio.h>
 #include <linux/leds.h>
 #include <linux/i2c.h>
+#include <linux/i2c/pxa-i2c.h>
 #include <linux/i2c/pca953x.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/ads7846.h>
@@ -44,8 +45,6 @@
 #include <mach/spitz.h>
 #include <mach/sharpsl_pm.h>
 
-#include <plat/i2c.h>
-
 #include "generic.h"
 #include "devices.h"
 
diff --git a/arch/arm/mach-pxa/stargate2.c b/arch/arm/mach-pxa/stargate2.c
index 325f6ac..797471c 100644
--- a/arch/arm/mach-pxa/stargate2.c
+++ b/arch/arm/mach-pxa/stargate2.c
@@ -25,6 +25,7 @@
 #include <linux/mtd/plat-ram.h>
 #include <linux/mtd/partitions.h>
 
+#include <linux/i2c/pxa-i2c.h>
 #include <linux/i2c/pcf857x.h>
 #include <linux/i2c/at24.h>
 #include <linux/smc91x.h>
@@ -43,7 +44,6 @@
 #include <asm/mach/flash.h>
 
 #include <mach/pxa27x.h>
-#include <plat/i2c.h>
 #include <mach/mmc.h>
 #include <mach/udc.h>
 #include <mach/pxa27x-udc.h>
diff --git a/arch/arm/mach-pxa/tavorevb3.c b/arch/arm/mach-pxa/tavorevb3.c
index dc30116..11b8c3e 100644
--- a/arch/arm/mach-pxa/tavorevb3.c
+++ b/arch/arm/mach-pxa/tavorevb3.c
@@ -15,6 +15,7 @@
 #include <linux/platform_device.h>
 #include <linux/interrupt.h>
 #include <linux/i2c.h>
+#include <linux/i2c/pxa-i2c.h>
 #include <linux/gpio.h>
 #include <linux/mfd/88pm860x.h>
 
@@ -23,8 +24,6 @@
 
 #include <mach/pxa930.h>
 
-#include <plat/i2c.h>
-
 #include "devices.h"
 #include "generic.h"
 
diff --git a/arch/arm/mach-pxa/tosa.c b/arch/arm/mach-pxa/tosa.c
index 7b5765d..d48881d 100644
--- a/arch/arm/mach-pxa/tosa.c
+++ b/arch/arm/mach-pxa/tosa.c
@@ -34,6 +34,7 @@
 #include <linux/spi/spi.h>
 #include <linux/spi/pxa2xx_spi.h>
 #include <linux/input/matrix_keypad.h>
+#include <linux/i2c/pxa-i2c.h>
 
 #include <asm/setup.h>
 #include <asm/mach-types.h>
@@ -41,7 +42,6 @@
 #include <mach/pxa25x.h>
 #include <mach/reset.h>
 #include <mach/irda.h>
-#include <plat/i2c.h>
 #include <mach/mmc.h>
 #include <mach/udc.h>
 #include <mach/tosa_bt.h>
diff --git a/arch/arm/mach-pxa/trizeps4.c b/arch/arm/mach-pxa/trizeps4.c
index bdb02a0..995e671 100644
--- a/arch/arm/mach-pxa/trizeps4.c
+++ b/arch/arm/mach-pxa/trizeps4.c
@@ -26,6 +26,7 @@
 #include <linux/dm9000.h>
 #include <linux/mtd/physmap.h>
 #include <linux/mtd/partitions.h>
+#include <linux/i2c/pxa-i2c.h>
 
 #include <asm/types.h>
 #include <asm/setup.h>
@@ -46,7 +47,6 @@
 #include <mach/mmc.h>
 #include <mach/irda.h>
 #include <mach/ohci.h>
-#include <plat/i2c.h>
 
 #include "generic.h"
 #include "devices.h"
diff --git a/arch/arm/mach-pxa/viper.c b/arch/arm/mach-pxa/viper.c
index 438fc9a..d36baac 100644
--- a/arch/arm/mach-pxa/viper.c
+++ b/arch/arm/mach-pxa/viper.c
@@ -36,6 +36,7 @@
 #include <linux/gpio.h>
 #include <linux/jiffies.h>
 #include <linux/i2c-gpio.h>
+#include <linux/i2c/pxa-i2c.h>
 #include <linux/serial_8250.h>
 #include <linux/smc91x.h>
 #include <linux/pwm_backlight.h>
@@ -47,7 +48,6 @@
 #include <mach/pxa25x.h>
 #include <mach/audio.h>
 #include <mach/pxafb.h>
-#include <plat/i2c.h>
 #include <mach/regs-uart.h>
 #include <mach/arcom-pcmcia.h>
 #include <mach/viper.h>
diff --git a/arch/arm/mach-pxa/vpac270.c b/arch/arm/mach-pxa/vpac270.c
index f45ac09..4c812f9 100644
--- a/arch/arm/mach-pxa/vpac270.c
+++ b/arch/arm/mach-pxa/vpac270.c
@@ -26,6 +26,7 @@
 #include <linux/ucb1400.h>
 #include <linux/ata_platform.h>
 #include <linux/regulator/max1586.h>
+#include <linux/i2c/pxa-i2c.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -40,8 +41,6 @@
 #include <mach/udc.h>
 #include <mach/pata_pxa.h>
 
-#include <plat/i2c.h>
-
 #include "generic.h"
 #include "devices.h"
 
diff --git a/arch/arm/mach-pxa/xcep.c b/arch/arm/mach-pxa/xcep.c
index 3260ce7..e2bd5ce 100644
--- a/arch/arm/mach-pxa/xcep.c
+++ b/arch/arm/mach-pxa/xcep.c
@@ -16,6 +16,7 @@
 
 #include <linux/platform_device.h>
 #include <linux/i2c.h>
+#include <linux/i2c/pxa-i2c.h>
 #include <linux/smc91x.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/partitions.h>
@@ -26,8 +27,6 @@
 #include <asm/mach/irq.h>
 #include <asm/mach/map.h>
 
-#include <plat/i2c.h>
-
 #include <mach/hardware.h>
 #include <mach/pxa2xx-regs.h>
 #include <mach/mfp-pxa25x.h>
diff --git a/arch/arm/mach-pxa/z2.c b/arch/arm/mach-pxa/z2.c
index 1b8b71b..07c93a7 100644
--- a/arch/arm/mach-pxa/z2.c
+++ b/arch/arm/mach-pxa/z2.c
@@ -29,6 +29,7 @@
 #include <linux/gpio_keys.h>
 #include <linux/delay.h>
 #include <linux/regulator/machine.h>
+#include <linux/i2c/pxa-i2c.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -40,8 +41,6 @@
 #include <mach/mmc.h>
 #include <plat/pxa27x_keypad.h>
 
-#include <plat/i2c.h>
-
 #include "generic.h"
 #include "devices.h"
 
diff --git a/arch/arm/mach-pxa/zeus.c b/arch/arm/mach-pxa/zeus.c
index f5c9f30..838cafb 100644
--- a/arch/arm/mach-pxa/zeus.c
+++ b/arch/arm/mach-pxa/zeus.c
@@ -25,6 +25,7 @@
 #include <linux/mtd/partitions.h>
 #include <linux/mtd/physmap.h>
 #include <linux/i2c.h>
+#include <linux/i2c/pxa-i2c.h>
 #include <linux/i2c/pca953x.h>
 #include <linux/apm-emulation.h>
 #include <linux/can/platform/mcp251x.h>
@@ -33,8 +34,6 @@
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
 
-#include <plat/i2c.h>
-
 #include <mach/pxa2xx-regs.h>
 #include <mach/regs-uart.h>
 #include <mach/ohci.h>
diff --git a/arch/arm/mach-pxa/zylonite_pxa300.c b/arch/arm/mach-pxa/zylonite_pxa300.c
index 3aa73b3..93c64d8 100644
--- a/arch/arm/mach-pxa/zylonite_pxa300.c
+++ b/arch/arm/mach-pxa/zylonite_pxa300.c
@@ -17,11 +17,11 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/i2c.h>
+#include <linux/i2c/pxa-i2c.h>
 #include <linux/i2c/pca953x.h>
 #include <linux/gpio.h>
 
 #include <mach/pxa300.h>
-#include <plat/i2c.h>
 #include <mach/zylonite.h>
 
 #include "generic.h"
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index 579c8a8..dc66fde 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -34,9 +34,9 @@
 #include <linux/clk.h>
 #include <linux/slab.h>
 #include <linux/io.h>
+#include <linux/i2c/pxa-i2c.h>
 
 #include <asm/irq.h>
-#include <plat/i2c.h>
 
 /*
  * I2C register offsets will be shifted 0 or 1 bit left, depending on
@@ -54,14 +54,8 @@ static const struct platform_device_id i2c_pxa_id_table[] = {
 MODULE_DEVICE_TABLE(platform, i2c_pxa_id_table);
 
 /*
- * I2C registers and bit definitions
+ * I2C bit definitions
  */
-#define IBMR		(0x00)
-#define IDBR		(0x08)
-#define ICR		(0x10)
-#define ISR		(0x18)
-#define ISAR		(0x20)
-
 #define ICR_START	(1 << 0)	   /* start bit */
 #define ICR_STOP	(1 << 1)	   /* stop bit */
 #define ICR_ACKNAK	(1 << 2)	   /* send ACK(0) or NAK(1) */
@@ -121,12 +115,6 @@ struct pxa_i2c {
 	unsigned int		fast_mode :1;
 };
 
-#define _IBMR(i2c)	((i2c)->reg_base + (0x0 << (i2c)->reg_shift))
-#define _IDBR(i2c)	((i2c)->reg_base + (0x4 << (i2c)->reg_shift))
-#define _ICR(i2c)	((i2c)->reg_base + (0x8 << (i2c)->reg_shift))
-#define _ISR(i2c)	((i2c)->reg_base + (0xc << (i2c)->reg_shift))
-#define _ISAR(i2c)	((i2c)->reg_base + (0x10 << (i2c)->reg_shift))
-
 /*
  * I2C Slave mode address
  */
diff --git a/arch/arm/plat-pxa/include/plat/i2c.h b/include/linux/i2c/pxa-i2c.h
similarity index 99%
rename from arch/arm/plat-pxa/include/plat/i2c.h
rename to include/linux/i2c/pxa-i2c.h
index 1a9f65e..f751aa0 100644
--- a/arch/arm/plat-pxa/include/plat/i2c.h
+++ b/include/linux/i2c/pxa-i2c.h
@@ -10,6 +10,7 @@
  */
 #ifndef _I2C_PXA_H_
 #define _I2C_PXA_H_
+#include <asm/pxa_i2c.h>
 
 #if 0
 #define DEF_TIMEOUT             3
-- 
1.7.3.2

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 3/7] i2c/pxa2xx: Add PCI support for PXA I2C controller
  2010-11-24 21:20 ` Sebastian Andrzej Siewior
@ 2010-11-24 21:20     ` Sebastian Andrzej Siewior
  -1 siblings, 0 replies; 48+ messages in thread
From: Sebastian Andrzej Siewior @ 2010-11-24 21:20 UTC (permalink / raw)
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	sodaville-hfZtesqFncYOwBW4kG4KsQ, tglx-hfZtesqFncYOwBW4kG4KsQ,
	eric.y.miao-Re5JQEeQqe8AvxtiuMwx3w, linux-lFZ/pmaqli7XmaaqVzeoHQ,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, Sebastian Andrzej Siewior,
	Dirk Brandewie

The Sodaville I2C controller is almost the same as found on PXA2xx. The
difference:
- the register are at a different spot
- no slave support

The PCI probe code adds three platform devices which are probed then by
the platform code.
The X86 part also adds dummy clock defines because we don't have HW
clock support.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
Signed-off-by: Dirk Brandewie <dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 arch/x86/include/asm/pxa_i2c.h   |   24 ++++++
 drivers/i2c/busses/Kconfig       |    7 +-
 drivers/i2c/busses/Makefile      |    1 +
 drivers/i2c/busses/i2c-pxa-pci.c |  160 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 190 insertions(+), 2 deletions(-)
 create mode 100644 arch/x86/include/asm/pxa_i2c.h
 create mode 100644 drivers/i2c/busses/i2c-pxa-pci.c

diff --git a/arch/x86/include/asm/pxa_i2c.h b/arch/x86/include/asm/pxa_i2c.h
new file mode 100644
index 0000000..9f73b3de
--- /dev/null
+++ b/arch/x86/include/asm/pxa_i2c.h
@@ -0,0 +1,24 @@
+#ifndef __ASM_PXA_I2C_H__
+#define __ASM_PXA_I2C_H__
+
+/*
+ * I2C registers definitions
+ */
+#define IBMR            (0x14)
+#define IDBR            (0x0c)
+#define ICR             (0x00)
+#define ISR             (0x04)
+
+#define _IBMR(i2c)	((i2c)->reg_base + IBMR)
+#define _IDBR(i2c)	((i2c)->reg_base + IDBR)
+#define _ICR(i2c)	((i2c)->reg_base + ICR)
+#define _ISR(i2c)	((i2c)->reg_base + ISR)
+
+struct clk;
+
+#define clk_get(dev, id)	NULL
+#define clk_put(clk)		do { } while (0)
+#define clk_disable(clk)	do { } while (0)
+#define clk_enable(clk)		do { } while (0)
+
+#endif
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 3a6321c..76b5f15 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -525,15 +525,18 @@ config I2C_PNX
 
 config I2C_PXA
 	tristate "Intel PXA2XX I2C adapter"
-	depends on ARCH_PXA || ARCH_MMP
+	depends on ARCH_PXA || ARCH_MMP || (X86 && PCI)
 	help
 	  If you have devices in the PXA I2C bus, say yes to this option.
 	  This driver can also be built as a module.  If so, the module
 	  will be called i2c-pxa.
 
+config I2C_PXA_PCI
+	def_bool I2C_PXA && X86 && PCI
+
 config I2C_PXA_SLAVE
 	bool "Intel PXA2XX I2C Slave comms support"
-	depends on I2C_PXA
+	depends on I2C_PXA && !X86
 	help
 	  Support I2C slave mode communications on the PXA I2C bus.  This
 	  is necessary for systems where the PXA may be a target on the
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 84cb16a..78db2e3 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -52,6 +52,7 @@ obj-$(CONFIG_I2C_PCA_PLATFORM)	+= i2c-pca-platform.o
 obj-$(CONFIG_I2C_PMCMSP)	+= i2c-pmcmsp.o
 obj-$(CONFIG_I2C_PNX)		+= i2c-pnx.o
 obj-$(CONFIG_I2C_PXA)		+= i2c-pxa.o
+obj-$(CONFIG_I2C_PXA_PCI)	+= i2c-pxa-pci.o
 obj-$(CONFIG_I2C_S3C2410)	+= i2c-s3c2410.o
 obj-$(CONFIG_I2C_S6000)		+= i2c-s6000.o
 obj-$(CONFIG_I2C_SH7760)	+= i2c-sh7760.o
diff --git a/drivers/i2c/busses/i2c-pxa-pci.c b/drivers/i2c/busses/i2c-pxa-pci.c
new file mode 100644
index 0000000..9ab7a36
--- /dev/null
+++ b/drivers/i2c/busses/i2c-pxa-pci.c
@@ -0,0 +1,160 @@
+/*
+ * The CE4100's I2C device is more or less the same one as found on PXA.
+ * It does not support slave mode, the register slightly moved. This PCI
+ * device provides three bars, every contains a single I2C controller.
+ */
+#include <linux/pci.h>
+#include <linux/platform_device.h>
+#include <linux/i2c/pxa-i2c.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+
+#define CE4100_PCI_I2C_DEVS	3
+
+struct ce4100_i2c_device {
+	struct platform_device pdev;
+	struct resource res[2];
+	struct i2c_pxa_platform_data pdata;
+};
+
+struct ce4100_devices {
+	struct ce4100_i2c_device sd[CE4100_PCI_I2C_DEVS];
+};
+
+static void plat_dev_release(struct device *dev)
+{
+	struct ce4100_i2c_device *sd = container_of(dev,
+			struct ce4100_i2c_device, pdev.dev);
+
+	of_device_node_put(&sd->pdev.dev);
+}
+
+static int add_i2c_device(struct pci_dev *dev, int bar,
+		struct ce4100_i2c_device *sd)
+{
+	struct platform_device *pdev = &sd->pdev;
+	struct i2c_pxa_platform_data *pdata = &sd->pdata;
+
+	pdev->name = "pxa2xx-i2c";
+	pdev->dev.release = plat_dev_release;
+	/*
+	 * We assume one PCI bus here. devfn uses the lower 8 bits. To remain
+	 * unique we encode the also bar
+	 */
+	pdev->id = dev->devfn << 3 | bar;
+	pdev->dev.parent = &dev->dev;
+#ifdef CONFIG_OF
+	if (dev->dev.of_node) {
+		struct device_node *child;
+
+		for_each_child_of_node(dev->dev.of_node, child) {
+			const void *prop;
+			u32 child_reg;
+
+			prop = of_get_property(child, "reg", NULL);
+			if (!prop)
+				continue;
+			child_reg = be32_to_cpup(prop);
+			if (child_reg == bar) {
+				pdev->dev.of_node = child;
+				break;
+			}
+		}
+	}
+#endif
+	pdev->dev.platform_data = pdata;
+	pdev->resource = sd->res;
+
+	sd->res[0].flags = IORESOURCE_MEM;
+	sd->res[0].start = pci_resource_start(dev, bar);
+	sd->res[0].end = pci_resource_end(dev, bar);
+
+	sd->res[1].flags = IORESOURCE_IRQ;
+	sd->res[1].start = dev->irq;
+	sd->res[1].end = dev->irq;
+
+	pdev->num_resources = 2;
+
+	return platform_device_register(pdev);
+}
+
+static int __devinit ce4100_i2c_probe(struct pci_dev *dev,
+		const struct pci_device_id *ent)
+{
+	int ret;
+	int i;
+	struct ce4100_devices *sds;
+
+	sds = kzalloc(sizeof(*sds), GFP_KERNEL);
+	if (!sds)
+		return -ENOMEM;
+
+	ret = pci_enable_device_mem(dev);
+	if (ret)
+		goto en_dev;
+
+	pci_set_drvdata(dev, sds);
+
+	for (i = 0; i < CE4100_PCI_I2C_DEVS; i++) {
+		ret = add_i2c_device(dev, i, &sds->sd[i]);
+		if (ret) {
+			while (--i >= 0)
+				platform_device_unregister(&sds->sd[i].pdev);
+
+			goto err_dev_add;
+		}
+	}
+
+	return 0;
+
+err_dev_add:
+	pci_set_drvdata(dev, NULL);
+	pci_disable_device(dev);
+en_dev:
+	kfree(sds);
+	return ret;
+}
+
+static void __devexit ce4100_i2c_remove(struct pci_dev *dev)
+{
+	struct ce4100_devices *sds;
+	unsigned int i;
+
+	sds = pci_get_drvdata(dev);
+	pci_set_drvdata(dev, NULL);
+
+	for (i = 0; i < CE4100_PCI_I2C_DEVS; i++)
+		platform_device_unregister(&sds->sd[i].pdev);
+
+	pci_disable_device(dev);
+	kfree(sds);
+}
+
+static struct pci_device_id ce4100_i2c_devices[] __devinitdata = {
+	{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x2e68)},
+	{ },
+};
+MODULE_DEVICE_TABLE(pci, ce4100_i2c_devices);
+
+static struct pci_driver ce4100_i2c_driver = {
+	.name           = "ce4100_i2c",
+	.id_table       = ce4100_i2c_devices,
+	.probe          = ce4100_i2c_probe,
+	.remove         = __devexit_p(ce4100_i2c_remove),
+};
+
+static int __init ce4100_i2c_init(void)
+{
+	return pci_register_driver(&ce4100_i2c_driver);
+}
+module_init(ce4100_i2c_init);
+
+static void __exit ce4100_i2c_exit(void)
+{
+	pci_unregister_driver(&ce4100_i2c_driver);
+}
+module_exit(ce4100_i2c_exit);
+
+MODULE_DESCRIPTION("CE4100 PCI-I2C glue code for PXA's driver");
+MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR("Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>");
-- 
1.7.3.2

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 3/7] i2c/pxa2xx: Add PCI support for PXA I2C controller
@ 2010-11-24 21:20     ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 48+ messages in thread
From: Sebastian Andrzej Siewior @ 2010-11-24 21:20 UTC (permalink / raw)
  To: linux-arm-kernel

The Sodaville I2C controller is almost the same as found on PXA2xx. The
difference:
- the register are at a different spot
- no slave support

The PCI probe code adds three platform devices which are probed then by
the platform code.
The X86 part also adds dummy clock defines because we don't have HW
clock support.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Dirk Brandewie <dirk.brandewie@gmail.com>
---
 arch/x86/include/asm/pxa_i2c.h   |   24 ++++++
 drivers/i2c/busses/Kconfig       |    7 +-
 drivers/i2c/busses/Makefile      |    1 +
 drivers/i2c/busses/i2c-pxa-pci.c |  160 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 190 insertions(+), 2 deletions(-)
 create mode 100644 arch/x86/include/asm/pxa_i2c.h
 create mode 100644 drivers/i2c/busses/i2c-pxa-pci.c

diff --git a/arch/x86/include/asm/pxa_i2c.h b/arch/x86/include/asm/pxa_i2c.h
new file mode 100644
index 0000000..9f73b3de
--- /dev/null
+++ b/arch/x86/include/asm/pxa_i2c.h
@@ -0,0 +1,24 @@
+#ifndef __ASM_PXA_I2C_H__
+#define __ASM_PXA_I2C_H__
+
+/*
+ * I2C registers definitions
+ */
+#define IBMR            (0x14)
+#define IDBR            (0x0c)
+#define ICR             (0x00)
+#define ISR             (0x04)
+
+#define _IBMR(i2c)	((i2c)->reg_base + IBMR)
+#define _IDBR(i2c)	((i2c)->reg_base + IDBR)
+#define _ICR(i2c)	((i2c)->reg_base + ICR)
+#define _ISR(i2c)	((i2c)->reg_base + ISR)
+
+struct clk;
+
+#define clk_get(dev, id)	NULL
+#define clk_put(clk)		do { } while (0)
+#define clk_disable(clk)	do { } while (0)
+#define clk_enable(clk)		do { } while (0)
+
+#endif
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 3a6321c..76b5f15 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -525,15 +525,18 @@ config I2C_PNX
 
 config I2C_PXA
 	tristate "Intel PXA2XX I2C adapter"
-	depends on ARCH_PXA || ARCH_MMP
+	depends on ARCH_PXA || ARCH_MMP || (X86 && PCI)
 	help
 	  If you have devices in the PXA I2C bus, say yes to this option.
 	  This driver can also be built as a module.  If so, the module
 	  will be called i2c-pxa.
 
+config I2C_PXA_PCI
+	def_bool I2C_PXA && X86 && PCI
+
 config I2C_PXA_SLAVE
 	bool "Intel PXA2XX I2C Slave comms support"
-	depends on I2C_PXA
+	depends on I2C_PXA && !X86
 	help
 	  Support I2C slave mode communications on the PXA I2C bus.  This
 	  is necessary for systems where the PXA may be a target on the
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 84cb16a..78db2e3 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -52,6 +52,7 @@ obj-$(CONFIG_I2C_PCA_PLATFORM)	+= i2c-pca-platform.o
 obj-$(CONFIG_I2C_PMCMSP)	+= i2c-pmcmsp.o
 obj-$(CONFIG_I2C_PNX)		+= i2c-pnx.o
 obj-$(CONFIG_I2C_PXA)		+= i2c-pxa.o
+obj-$(CONFIG_I2C_PXA_PCI)	+= i2c-pxa-pci.o
 obj-$(CONFIG_I2C_S3C2410)	+= i2c-s3c2410.o
 obj-$(CONFIG_I2C_S6000)		+= i2c-s6000.o
 obj-$(CONFIG_I2C_SH7760)	+= i2c-sh7760.o
diff --git a/drivers/i2c/busses/i2c-pxa-pci.c b/drivers/i2c/busses/i2c-pxa-pci.c
new file mode 100644
index 0000000..9ab7a36
--- /dev/null
+++ b/drivers/i2c/busses/i2c-pxa-pci.c
@@ -0,0 +1,160 @@
+/*
+ * The CE4100's I2C device is more or less the same one as found on PXA.
+ * It does not support slave mode, the register slightly moved. This PCI
+ * device provides three bars, every contains a single I2C controller.
+ */
+#include <linux/pci.h>
+#include <linux/platform_device.h>
+#include <linux/i2c/pxa-i2c.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+
+#define CE4100_PCI_I2C_DEVS	3
+
+struct ce4100_i2c_device {
+	struct platform_device pdev;
+	struct resource res[2];
+	struct i2c_pxa_platform_data pdata;
+};
+
+struct ce4100_devices {
+	struct ce4100_i2c_device sd[CE4100_PCI_I2C_DEVS];
+};
+
+static void plat_dev_release(struct device *dev)
+{
+	struct ce4100_i2c_device *sd = container_of(dev,
+			struct ce4100_i2c_device, pdev.dev);
+
+	of_device_node_put(&sd->pdev.dev);
+}
+
+static int add_i2c_device(struct pci_dev *dev, int bar,
+		struct ce4100_i2c_device *sd)
+{
+	struct platform_device *pdev = &sd->pdev;
+	struct i2c_pxa_platform_data *pdata = &sd->pdata;
+
+	pdev->name = "pxa2xx-i2c";
+	pdev->dev.release = plat_dev_release;
+	/*
+	 * We assume one PCI bus here. devfn uses the lower 8 bits. To remain
+	 * unique we encode the also bar
+	 */
+	pdev->id = dev->devfn << 3 | bar;
+	pdev->dev.parent = &dev->dev;
+#ifdef CONFIG_OF
+	if (dev->dev.of_node) {
+		struct device_node *child;
+
+		for_each_child_of_node(dev->dev.of_node, child) {
+			const void *prop;
+			u32 child_reg;
+
+			prop = of_get_property(child, "reg", NULL);
+			if (!prop)
+				continue;
+			child_reg = be32_to_cpup(prop);
+			if (child_reg == bar) {
+				pdev->dev.of_node = child;
+				break;
+			}
+		}
+	}
+#endif
+	pdev->dev.platform_data = pdata;
+	pdev->resource = sd->res;
+
+	sd->res[0].flags = IORESOURCE_MEM;
+	sd->res[0].start = pci_resource_start(dev, bar);
+	sd->res[0].end = pci_resource_end(dev, bar);
+
+	sd->res[1].flags = IORESOURCE_IRQ;
+	sd->res[1].start = dev->irq;
+	sd->res[1].end = dev->irq;
+
+	pdev->num_resources = 2;
+
+	return platform_device_register(pdev);
+}
+
+static int __devinit ce4100_i2c_probe(struct pci_dev *dev,
+		const struct pci_device_id *ent)
+{
+	int ret;
+	int i;
+	struct ce4100_devices *sds;
+
+	sds = kzalloc(sizeof(*sds), GFP_KERNEL);
+	if (!sds)
+		return -ENOMEM;
+
+	ret = pci_enable_device_mem(dev);
+	if (ret)
+		goto en_dev;
+
+	pci_set_drvdata(dev, sds);
+
+	for (i = 0; i < CE4100_PCI_I2C_DEVS; i++) {
+		ret = add_i2c_device(dev, i, &sds->sd[i]);
+		if (ret) {
+			while (--i >= 0)
+				platform_device_unregister(&sds->sd[i].pdev);
+
+			goto err_dev_add;
+		}
+	}
+
+	return 0;
+
+err_dev_add:
+	pci_set_drvdata(dev, NULL);
+	pci_disable_device(dev);
+en_dev:
+	kfree(sds);
+	return ret;
+}
+
+static void __devexit ce4100_i2c_remove(struct pci_dev *dev)
+{
+	struct ce4100_devices *sds;
+	unsigned int i;
+
+	sds = pci_get_drvdata(dev);
+	pci_set_drvdata(dev, NULL);
+
+	for (i = 0; i < CE4100_PCI_I2C_DEVS; i++)
+		platform_device_unregister(&sds->sd[i].pdev);
+
+	pci_disable_device(dev);
+	kfree(sds);
+}
+
+static struct pci_device_id ce4100_i2c_devices[] __devinitdata = {
+	{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x2e68)},
+	{ },
+};
+MODULE_DEVICE_TABLE(pci, ce4100_i2c_devices);
+
+static struct pci_driver ce4100_i2c_driver = {
+	.name           = "ce4100_i2c",
+	.id_table       = ce4100_i2c_devices,
+	.probe          = ce4100_i2c_probe,
+	.remove         = __devexit_p(ce4100_i2c_remove),
+};
+
+static int __init ce4100_i2c_init(void)
+{
+	return pci_register_driver(&ce4100_i2c_driver);
+}
+module_init(ce4100_i2c_init);
+
+static void __exit ce4100_i2c_exit(void)
+{
+	pci_unregister_driver(&ce4100_i2c_driver);
+}
+module_exit(ce4100_i2c_exit);
+
+MODULE_DESCRIPTION("CE4100 PCI-I2C glue code for PXA's driver");
+MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR("Sebastian Andrzej Siewior <bigeasy@linutronix.de>");
-- 
1.7.3.2

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 4/7] i2c/pxa2xx: add support for shared IRQ handler
  2010-11-24 21:20 ` Sebastian Andrzej Siewior
@ 2010-11-24 21:20     ` Sebastian Andrzej Siewior
  -1 siblings, 0 replies; 48+ messages in thread
From: Sebastian Andrzej Siewior @ 2010-11-24 21:20 UTC (permalink / raw)
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	sodaville-hfZtesqFncYOwBW4kG4KsQ, tglx-hfZtesqFncYOwBW4kG4KsQ,
	eric.y.miao-Re5JQEeQqe8AvxtiuMwx3w, linux-lFZ/pmaqli7XmaaqVzeoHQ,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, Sebastian Andrzej Siewior,
	Dirk Brandewie

Sodaville has three of them on a single IRQ. IRQF_DISABLED is removed
because it is a NOP allready and scheduled for removal.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
Signed-off-by: Dirk Brandewie <dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/i2c/busses/i2c-pxa.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index dc66fde..7647361 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -905,11 +905,17 @@ static void i2c_pxa_irq_rxfull(struct pxa_i2c *i2c, u32 isr)
 	writel(icr, _ICR(i2c));
 }
 
+#define VALID_INT_SOURCE	(ISR_SSD | ISR_ALD | ISR_ITE | ISR_IRF | \
+				ISR_SAD | ISR_BED)
 static irqreturn_t i2c_pxa_handler(int this_irq, void *dev_id)
 {
 	struct pxa_i2c *i2c = dev_id;
 	u32 isr = readl(_ISR(i2c));
 
+	isr &= VALID_INT_SOURCE;
+	if (!isr)
+		return IRQ_NONE;
+
 	if (i2c_debug > 2 && 0) {
 		dev_dbg(&i2c->adap.dev, "%s: ISR=%08x, ICR=%08x, IBMR=%02x\n",
 			__func__, isr, readl(_ICR(i2c)), readl(_IBMR(i2c)));
@@ -924,7 +930,7 @@ static irqreturn_t i2c_pxa_handler(int this_irq, void *dev_id)
 	/*
 	 * Always clear all pending IRQs.
 	 */
-	writel(isr & (ISR_SSD|ISR_ALD|ISR_ITE|ISR_IRF|ISR_SAD|ISR_BED), _ISR(i2c));
+	writel(isr, _ISR(i2c));
 
 	if (isr & ISR_SAD)
 		i2c_pxa_slave_start(i2c, isr);
@@ -1062,7 +1068,7 @@ static int i2c_pxa_probe(struct platform_device *dev)
 		i2c->adap.algo = &i2c_pxa_pio_algorithm;
 	} else {
 		i2c->adap.algo = &i2c_pxa_algorithm;
-		ret = request_irq(irq, i2c_pxa_handler, IRQF_DISABLED,
+		ret = request_irq(irq, i2c_pxa_handler, IRQF_SHARED,
 				  i2c->adap.name, i2c);
 		if (ret)
 			goto ereqirq;
-- 
1.7.3.2

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 4/7] i2c/pxa2xx: add support for shared IRQ handler
@ 2010-11-24 21:20     ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 48+ messages in thread
From: Sebastian Andrzej Siewior @ 2010-11-24 21:20 UTC (permalink / raw)
  To: linux-arm-kernel

Sodaville has three of them on a single IRQ. IRQF_DISABLED is removed
because it is a NOP allready and scheduled for removal.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Dirk Brandewie <dirk.brandewie@gmail.com>
---
 drivers/i2c/busses/i2c-pxa.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index dc66fde..7647361 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -905,11 +905,17 @@ static void i2c_pxa_irq_rxfull(struct pxa_i2c *i2c, u32 isr)
 	writel(icr, _ICR(i2c));
 }
 
+#define VALID_INT_SOURCE	(ISR_SSD | ISR_ALD | ISR_ITE | ISR_IRF | \
+				ISR_SAD | ISR_BED)
 static irqreturn_t i2c_pxa_handler(int this_irq, void *dev_id)
 {
 	struct pxa_i2c *i2c = dev_id;
 	u32 isr = readl(_ISR(i2c));
 
+	isr &= VALID_INT_SOURCE;
+	if (!isr)
+		return IRQ_NONE;
+
 	if (i2c_debug > 2 && 0) {
 		dev_dbg(&i2c->adap.dev, "%s: ISR=%08x, ICR=%08x, IBMR=%02x\n",
 			__func__, isr, readl(_ICR(i2c)), readl(_IBMR(i2c)));
@@ -924,7 +930,7 @@ static irqreturn_t i2c_pxa_handler(int this_irq, void *dev_id)
 	/*
 	 * Always clear all pending IRQs.
 	 */
-	writel(isr & (ISR_SSD|ISR_ALD|ISR_ITE|ISR_IRF|ISR_SAD|ISR_BED), _ISR(i2c));
+	writel(isr, _ISR(i2c));
 
 	if (isr & ISR_SAD)
 		i2c_pxa_slave_start(i2c, isr);
@@ -1062,7 +1068,7 @@ static int i2c_pxa_probe(struct platform_device *dev)
 		i2c->adap.algo = &i2c_pxa_pio_algorithm;
 	} else {
 		i2c->adap.algo = &i2c_pxa_algorithm;
-		ret = request_irq(irq, i2c_pxa_handler, IRQF_DISABLED,
+		ret = request_irq(irq, i2c_pxa_handler, IRQF_SHARED,
 				  i2c->adap.name, i2c);
 		if (ret)
 			goto ereqirq;
-- 
1.7.3.2

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 5/7] i2c/pxa2xx: check timeout correctly
  2010-11-24 21:20 ` Sebastian Andrzej Siewior
@ 2010-11-24 21:20     ` Sebastian Andrzej Siewior
  -1 siblings, 0 replies; 48+ messages in thread
From: Sebastian Andrzej Siewior @ 2010-11-24 21:20 UTC (permalink / raw)
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	sodaville-hfZtesqFncYOwBW4kG4KsQ, tglx-hfZtesqFncYOwBW4kG4KsQ,
	eric.y.miao-Re5JQEeQqe8AvxtiuMwx3w, linux-lFZ/pmaqli7XmaaqVzeoHQ,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, Sebastian Andrzej Siewior,
	Dirk Brandewie

timeout here maybe 0 if the event occured and a task with a higher
priority stole the cpu and we were sleeping longer than the timeout
value we specified.
In case of a real timeout I changed the error code to I2C_RETRY so we
retry the transfer.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
Signed-off-by: Dirk Brandewie <dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/i2c/busses/i2c-pxa.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index 7647361..bd4b885 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -719,8 +719,10 @@ static int i2c_pxa_do_xfer(struct pxa_i2c *i2c, struct i2c_msg *msg, int num)
 	 */
 	ret = i2c->msg_idx;
 
-	if (timeout == 0)
+	if (!timeout && i2c->msg_num) {
 		i2c_pxa_scream_blue_murder(i2c, "timeout");
+		ret = I2C_RETRY;
+	}
 
  out:
 	return ret;
-- 
1.7.3.2

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 5/7] i2c/pxa2xx: check timeout correctly
@ 2010-11-24 21:20     ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 48+ messages in thread
From: Sebastian Andrzej Siewior @ 2010-11-24 21:20 UTC (permalink / raw)
  To: linux-arm-kernel

timeout here maybe 0 if the event occured and a task with a higher
priority stole the cpu and we were sleeping longer than the timeout
value we specified.
In case of a real timeout I changed the error code to I2C_RETRY so we
retry the transfer.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Dirk Brandewie <dirk.brandewie@gmail.com>
---
 drivers/i2c/busses/i2c-pxa.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index 7647361..bd4b885 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -719,8 +719,10 @@ static int i2c_pxa_do_xfer(struct pxa_i2c *i2c, struct i2c_msg *msg, int num)
 	 */
 	ret = i2c->msg_idx;
 
-	if (timeout == 0)
+	if (!timeout && i2c->msg_num) {
 		i2c_pxa_scream_blue_murder(i2c, "timeout");
+		ret = I2C_RETRY;
+	}
 
  out:
 	return ret;
-- 
1.7.3.2

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 6/7] i2c/pxa2xx: reset the chip if the bus is not free
  2010-11-24 21:20 ` Sebastian Andrzej Siewior
@ 2010-11-24 21:20     ` Sebastian Andrzej Siewior
  -1 siblings, 0 replies; 48+ messages in thread
From: Sebastian Andrzej Siewior @ 2010-11-24 21:20 UTC (permalink / raw)
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	sodaville-hfZtesqFncYOwBW4kG4KsQ, tglx-hfZtesqFncYOwBW4kG4KsQ,
	eric.y.miao-Re5JQEeQqe8AvxtiuMwx3w, linux-lFZ/pmaqli7XmaaqVzeoHQ,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, Sebastian Andrzej Siewior,
	Dirk Brandewie

I haven't seen this (yet) during a normal transfer but starting
i2cdetect seems to hang the bus. On my Sodaville board, i2cdetect runs
fine on bus zero and runs into timeouts on bus one and two. The chip
never recovers from this condition. The following transfers hang as
well. The ISR_UB never disappears.
Issuing a chip reset fixes the timeout and following transfer succeed.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
Signed-off-by: Dirk Brandewie <dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/i2c/busses/i2c-pxa.c |   35 +++++++++++++++++++----------------
 1 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index bd4b885..1a48470 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -257,23 +257,7 @@ static void i2c_pxa_abort(struct pxa_i2c *i2c)
 	       _ICR(i2c));
 }
 
-static int i2c_pxa_wait_bus_not_busy(struct pxa_i2c *i2c)
-{
-	int timeout = DEF_TIMEOUT;
 
-	while (timeout-- && readl(_ISR(i2c)) & (ISR_IBB | ISR_UB)) {
-		if ((readl(_ISR(i2c)) & ISR_SAD) != 0)
-			timeout += 4;
-
-		msleep(2);
-		show_state(i2c);
-	}
-
-	if (timeout < 0)
-		show_state(i2c);
-
-	return timeout < 0 ? I2C_RETRY : 0;
-}
 
 static int i2c_pxa_wait_master(struct pxa_i2c *i2c)
 {
@@ -425,6 +409,25 @@ static void i2c_pxa_reset(struct pxa_i2c *i2c)
 	udelay(100);
 }
 
+static int i2c_pxa_wait_bus_not_busy(struct pxa_i2c *i2c)
+{
+	int timeout = DEF_TIMEOUT;
+
+	while (timeout-- && readl(_ISR(i2c)) & (ISR_IBB | ISR_UB)) {
+		if ((readl(_ISR(i2c)) & ISR_SAD) != 0)
+			timeout += 4;
+
+		msleep(2);
+		show_state(i2c);
+	}
+
+	if (timeout < 0) {
+		show_state(i2c);
+		i2c_pxa_reset(i2c);
+	}
+
+	return timeout < 0 ? I2C_RETRY : 0;
+}
 
 #ifdef CONFIG_I2C_PXA_SLAVE
 /*
-- 
1.7.3.2

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 6/7] i2c/pxa2xx: reset the chip if the bus is not free
@ 2010-11-24 21:20     ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 48+ messages in thread
From: Sebastian Andrzej Siewior @ 2010-11-24 21:20 UTC (permalink / raw)
  To: linux-arm-kernel

I haven't seen this (yet) during a normal transfer but starting
i2cdetect seems to hang the bus. On my Sodaville board, i2cdetect runs
fine on bus zero and runs into timeouts on bus one and two. The chip
never recovers from this condition. The following transfers hang as
well. The ISR_UB never disappears.
Issuing a chip reset fixes the timeout and following transfer succeed.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Dirk Brandewie <dirk.brandewie@gmail.com>
---
 drivers/i2c/busses/i2c-pxa.c |   35 +++++++++++++++++++----------------
 1 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index bd4b885..1a48470 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -257,23 +257,7 @@ static void i2c_pxa_abort(struct pxa_i2c *i2c)
 	       _ICR(i2c));
 }
 
-static int i2c_pxa_wait_bus_not_busy(struct pxa_i2c *i2c)
-{
-	int timeout = DEF_TIMEOUT;
 
-	while (timeout-- && readl(_ISR(i2c)) & (ISR_IBB | ISR_UB)) {
-		if ((readl(_ISR(i2c)) & ISR_SAD) != 0)
-			timeout += 4;
-
-		msleep(2);
-		show_state(i2c);
-	}
-
-	if (timeout < 0)
-		show_state(i2c);
-
-	return timeout < 0 ? I2C_RETRY : 0;
-}
 
 static int i2c_pxa_wait_master(struct pxa_i2c *i2c)
 {
@@ -425,6 +409,25 @@ static void i2c_pxa_reset(struct pxa_i2c *i2c)
 	udelay(100);
 }
 
+static int i2c_pxa_wait_bus_not_busy(struct pxa_i2c *i2c)
+{
+	int timeout = DEF_TIMEOUT;
+
+	while (timeout-- && readl(_ISR(i2c)) & (ISR_IBB | ISR_UB)) {
+		if ((readl(_ISR(i2c)) & ISR_SAD) != 0)
+			timeout += 4;
+
+		msleep(2);
+		show_state(i2c);
+	}
+
+	if (timeout < 0) {
+		show_state(i2c);
+		i2c_pxa_reset(i2c);
+	}
+
+	return timeout < 0 ? I2C_RETRY : 0;
+}
 
 #ifdef CONFIG_I2C_PXA_SLAVE
 /*
-- 
1.7.3.2

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 7/7] i2c/pxa2xx: pass of_node from platform driver to adapter
  2010-11-24 21:20 ` Sebastian Andrzej Siewior
@ 2010-11-24 21:20     ` Sebastian Andrzej Siewior
  -1 siblings, 0 replies; 48+ messages in thread
From: Sebastian Andrzej Siewior @ 2010-11-24 21:20 UTC (permalink / raw)
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	sodaville-hfZtesqFncYOwBW4kG4KsQ, tglx-hfZtesqFncYOwBW4kG4KsQ,
	eric.y.miao-Re5JQEeQqe8AvxtiuMwx3w, linux-lFZ/pmaqli7XmaaqVzeoHQ,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, Sebastian Andrzej Siewior,
	grant.likely-s3s/WqlpOiPyB63q8FvJNQ, Dirk Brandewie

the of_node will auto-publish devices which are added to the device
tree.

Cc: grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
Signed-off-by: Dirk Brandewie <dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/i2c/busses/i2c-pxa.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index 1a48470..dd6ed77 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -1083,6 +1083,9 @@ static int i2c_pxa_probe(struct platform_device *dev)
 
 	i2c->adap.algo_data = i2c;
 	i2c->adap.dev.parent = &dev->dev;
+#ifdef CONFIG_OF
+	i2c->adap.dev.of_node = dev->dev.of_node;
+#endif
 
 	ret = i2c_add_numbered_adapter(&i2c->adap);
 	if (ret < 0) {
-- 
1.7.3.2

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH 7/7] i2c/pxa2xx: pass of_node from platform driver to adapter
@ 2010-11-24 21:20     ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 48+ messages in thread
From: Sebastian Andrzej Siewior @ 2010-11-24 21:20 UTC (permalink / raw)
  To: linux-arm-kernel

the of_node will auto-publish devices which are added to the device
tree.

Cc: grant.likely at secretlab.ca
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Dirk Brandewie <dirk.brandewie@gmail.com>
---
 drivers/i2c/busses/i2c-pxa.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index 1a48470..dd6ed77 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -1083,6 +1083,9 @@ static int i2c_pxa_probe(struct platform_device *dev)
 
 	i2c->adap.algo_data = i2c;
 	i2c->adap.dev.parent = &dev->dev;
+#ifdef CONFIG_OF
+	i2c->adap.dev.of_node = dev->dev.of_node;
+#endif
 
 	ret = i2c_add_numbered_adapter(&i2c->adap);
 	if (ret < 0) {
-- 
1.7.3.2

^ permalink raw reply related	[flat|nested] 48+ messages in thread

* Re: [PATCH 4/7] i2c/pxa2xx: add support for shared IRQ handler
  2010-11-24 21:20     ` Sebastian Andrzej Siewior
@ 2010-11-25  2:26         ` Haojian Zhuang
  -1 siblings, 0 replies; 48+ messages in thread
From: Haojian Zhuang @ 2010-11-25  2:26 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	eric.y.miao-Re5JQEeQqe8AvxtiuMwx3w,
	sodaville-hfZtesqFncYOwBW4kG4KsQ,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, Dirk Brandewie,
	linux-lFZ/pmaqli7XmaaqVzeoHQ, tglx-hfZtesqFncYOwBW4kG4KsQ,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

On Thu, Nov 25, 2010 at 5:20 AM, Sebastian Andrzej Siewior
<bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org> wrote:
> Sodaville has three of them on a single IRQ. IRQF_DISABLED is removed
> because it is a NOP allready and scheduled for removal.
>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
> Signed-off-by: Dirk Brandewie <dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
>  drivers/i2c/busses/i2c-pxa.c |   10 ++++++++--
>  1 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
> index dc66fde..7647361 100644
> --- a/drivers/i2c/busses/i2c-pxa.c
> +++ b/drivers/i2c/busses/i2c-pxa.c
> @@ -905,11 +905,17 @@ static void i2c_pxa_irq_rxfull(struct pxa_i2c *i2c, u32 isr)
>        writel(icr, _ICR(i2c));
>  }
>
> +#define VALID_INT_SOURCE       (ISR_SSD | ISR_ALD | ISR_ITE | ISR_IRF | \
> +                               ISR_SAD | ISR_BED)
>  static irqreturn_t i2c_pxa_handler(int this_irq, void *dev_id)
>  {
>        struct pxa_i2c *i2c = dev_id;
>        u32 isr = readl(_ISR(i2c));
>
> +       isr &= VALID_INT_SOURCE;
> +       if (!isr)
> +               return IRQ_NONE;
> +

If you return at here, the valid interrupt status event won't be
cleared in IRQ handler. So I2C interrupt handler will be triggered at
next time.

>        if (i2c_debug > 2 && 0) {
>                dev_dbg(&i2c->adap.dev, "%s: ISR=%08x, ICR=%08x, IBMR=%02x\n",
>                        __func__, isr, readl(_ICR(i2c)), readl(_IBMR(i2c)));
> @@ -924,7 +930,7 @@ static irqreturn_t i2c_pxa_handler(int this_irq, void *dev_id)
>        /*
>         * Always clear all pending IRQs.
>         */
> -       writel(isr & (ISR_SSD|ISR_ALD|ISR_ITE|ISR_IRF|ISR_SAD|ISR_BED), _ISR(i2c));
> +       writel(isr, _ISR(i2c));
>
>        if (isr & ISR_SAD)
>                i2c_pxa_slave_start(i2c, isr);
> @@ -1062,7 +1068,7 @@ static int i2c_pxa_probe(struct platform_device *dev)
>                i2c->adap.algo = &i2c_pxa_pio_algorithm;
>        } else {
>                i2c->adap.algo = &i2c_pxa_algorithm;
> -               ret = request_irq(irq, i2c_pxa_handler, IRQF_DISABLED,
> +               ret = request_irq(irq, i2c_pxa_handler, IRQF_SHARED,
>                                  i2c->adap.name, i2c);
>                if (ret)
>                        goto ereqirq;
> --
> 1.7.3.2
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [PATCH 4/7] i2c/pxa2xx: add support for shared IRQ handler
@ 2010-11-25  2:26         ` Haojian Zhuang
  0 siblings, 0 replies; 48+ messages in thread
From: Haojian Zhuang @ 2010-11-25  2:26 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Nov 25, 2010 at 5:20 AM, Sebastian Andrzej Siewior
<bigeasy@linutronix.de> wrote:
> Sodaville has three of them on a single IRQ. IRQF_DISABLED is removed
> because it is a NOP allready and scheduled for removal.
>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Signed-off-by: Dirk Brandewie <dirk.brandewie@gmail.com>
> ---
> ?drivers/i2c/busses/i2c-pxa.c | ? 10 ++++++++--
> ?1 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
> index dc66fde..7647361 100644
> --- a/drivers/i2c/busses/i2c-pxa.c
> +++ b/drivers/i2c/busses/i2c-pxa.c
> @@ -905,11 +905,17 @@ static void i2c_pxa_irq_rxfull(struct pxa_i2c *i2c, u32 isr)
> ? ? ? ?writel(icr, _ICR(i2c));
> ?}
>
> +#define VALID_INT_SOURCE ? ? ? (ISR_SSD | ISR_ALD | ISR_ITE | ISR_IRF | \
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ISR_SAD | ISR_BED)
> ?static irqreturn_t i2c_pxa_handler(int this_irq, void *dev_id)
> ?{
> ? ? ? ?struct pxa_i2c *i2c = dev_id;
> ? ? ? ?u32 isr = readl(_ISR(i2c));
>
> + ? ? ? isr &= VALID_INT_SOURCE;
> + ? ? ? if (!isr)
> + ? ? ? ? ? ? ? return IRQ_NONE;
> +

If you return at here, the valid interrupt status event won't be
cleared in IRQ handler. So I2C interrupt handler will be triggered at
next time.

> ? ? ? ?if (i2c_debug > 2 && 0) {
> ? ? ? ? ? ? ? ?dev_dbg(&i2c->adap.dev, "%s: ISR=%08x, ICR=%08x, IBMR=%02x\n",
> ? ? ? ? ? ? ? ? ? ? ? ?__func__, isr, readl(_ICR(i2c)), readl(_IBMR(i2c)));
> @@ -924,7 +930,7 @@ static irqreturn_t i2c_pxa_handler(int this_irq, void *dev_id)
> ? ? ? ?/*
> ? ? ? ? * Always clear all pending IRQs.
> ? ? ? ? */
> - ? ? ? writel(isr & (ISR_SSD|ISR_ALD|ISR_ITE|ISR_IRF|ISR_SAD|ISR_BED), _ISR(i2c));
> + ? ? ? writel(isr, _ISR(i2c));
>
> ? ? ? ?if (isr & ISR_SAD)
> ? ? ? ? ? ? ? ?i2c_pxa_slave_start(i2c, isr);
> @@ -1062,7 +1068,7 @@ static int i2c_pxa_probe(struct platform_device *dev)
> ? ? ? ? ? ? ? ?i2c->adap.algo = &i2c_pxa_pio_algorithm;
> ? ? ? ?} else {
> ? ? ? ? ? ? ? ?i2c->adap.algo = &i2c_pxa_algorithm;
> - ? ? ? ? ? ? ? ret = request_irq(irq, i2c_pxa_handler, IRQF_DISABLED,
> + ? ? ? ? ? ? ? ret = request_irq(irq, i2c_pxa_handler, IRQF_SHARED,
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?i2c->adap.name, i2c);
> ? ? ? ? ? ? ? ?if (ret)
> ? ? ? ? ? ? ? ? ? ? ? ?goto ereqirq;
> --
> 1.7.3.2
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 6/7] i2c/pxa2xx: reset the chip if the bus is not free
  2010-11-24 21:20     ` Sebastian Andrzej Siewior
@ 2010-11-25  2:30         ` Haojian Zhuang
  -1 siblings, 0 replies; 48+ messages in thread
From: Haojian Zhuang @ 2010-11-25  2:30 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	eric.y.miao-Re5JQEeQqe8AvxtiuMwx3w,
	sodaville-hfZtesqFncYOwBW4kG4KsQ,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, Dirk Brandewie,
	linux-lFZ/pmaqli7XmaaqVzeoHQ, tglx-hfZtesqFncYOwBW4kG4KsQ,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

On Thu, Nov 25, 2010 at 5:20 AM, Sebastian Andrzej Siewior
<bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org> wrote:
> I haven't seen this (yet) during a normal transfer but starting
> i2cdetect seems to hang the bus. On my Sodaville board, i2cdetect runs
> fine on bus zero and runs into timeouts on bus one and two. The chip
> never recovers from this condition. The following transfers hang as
> well. The ISR_UB never disappears.
> Issuing a chip reset fixes the timeout and following transfer succeed.
>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
> Signed-off-by: Dirk Brandewie <dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
>  drivers/i2c/busses/i2c-pxa.c |   35 +++++++++++++++++++----------------
>  1 files changed, 19 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
> index bd4b885..1a48470 100644
> --- a/drivers/i2c/busses/i2c-pxa.c
> +++ b/drivers/i2c/busses/i2c-pxa.c
> @@ -257,23 +257,7 @@ static void i2c_pxa_abort(struct pxa_i2c *i2c)
>               _ICR(i2c));
>  }
>
> -static int i2c_pxa_wait_bus_not_busy(struct pxa_i2c *i2c)
> -{
> -       int timeout = DEF_TIMEOUT;
>
> -       while (timeout-- && readl(_ISR(i2c)) & (ISR_IBB | ISR_UB)) {
> -               if ((readl(_ISR(i2c)) & ISR_SAD) != 0)
> -                       timeout += 4;
> -
> -               msleep(2);
> -               show_state(i2c);
> -       }
> -
> -       if (timeout < 0)
> -               show_state(i2c);
> -
> -       return timeout < 0 ? I2C_RETRY : 0;
> -}
>
>  static int i2c_pxa_wait_master(struct pxa_i2c *i2c)
>  {
> @@ -425,6 +409,25 @@ static void i2c_pxa_reset(struct pxa_i2c *i2c)
>        udelay(100);
>  }
>
> +static int i2c_pxa_wait_bus_not_busy(struct pxa_i2c *i2c)
> +{
> +       int timeout = DEF_TIMEOUT;
> +
> +       while (timeout-- && readl(_ISR(i2c)) & (ISR_IBB | ISR_UB)) {
> +               if ((readl(_ISR(i2c)) & ISR_SAD) != 0)
> +                       timeout += 4;
> +
> +               msleep(2);
> +               show_state(i2c);
> +       }
> +
> +       if (timeout < 0) {
> +               show_state(i2c);
> +               i2c_pxa_reset(i2c);
> +       }

Even you reset I2C controller, it shouldn't help you since bus isn't
free. I thinkt that you should reset I2C bus before you reseting I2C
controller.

> +
> +       return timeout < 0 ? I2C_RETRY : 0;
> +}
>
>  #ifdef CONFIG_I2C_PXA_SLAVE
>  /*
> --
> 1.7.3.2
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [PATCH 6/7] i2c/pxa2xx: reset the chip if the bus is not free
@ 2010-11-25  2:30         ` Haojian Zhuang
  0 siblings, 0 replies; 48+ messages in thread
From: Haojian Zhuang @ 2010-11-25  2:30 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Nov 25, 2010 at 5:20 AM, Sebastian Andrzej Siewior
<bigeasy@linutronix.de> wrote:
> I haven't seen this (yet) during a normal transfer but starting
> i2cdetect seems to hang the bus. On my Sodaville board, i2cdetect runs
> fine on bus zero and runs into timeouts on bus one and two. The chip
> never recovers from this condition. The following transfers hang as
> well. The ISR_UB never disappears.
> Issuing a chip reset fixes the timeout and following transfer succeed.
>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Signed-off-by: Dirk Brandewie <dirk.brandewie@gmail.com>
> ---
> ?drivers/i2c/busses/i2c-pxa.c | ? 35 +++++++++++++++++++----------------
> ?1 files changed, 19 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
> index bd4b885..1a48470 100644
> --- a/drivers/i2c/busses/i2c-pxa.c
> +++ b/drivers/i2c/busses/i2c-pxa.c
> @@ -257,23 +257,7 @@ static void i2c_pxa_abort(struct pxa_i2c *i2c)
> ? ? ? ? ? ? ? _ICR(i2c));
> ?}
>
> -static int i2c_pxa_wait_bus_not_busy(struct pxa_i2c *i2c)
> -{
> - ? ? ? int timeout = DEF_TIMEOUT;
>
> - ? ? ? while (timeout-- && readl(_ISR(i2c)) & (ISR_IBB | ISR_UB)) {
> - ? ? ? ? ? ? ? if ((readl(_ISR(i2c)) & ISR_SAD) != 0)
> - ? ? ? ? ? ? ? ? ? ? ? timeout += 4;
> -
> - ? ? ? ? ? ? ? msleep(2);
> - ? ? ? ? ? ? ? show_state(i2c);
> - ? ? ? }
> -
> - ? ? ? if (timeout < 0)
> - ? ? ? ? ? ? ? show_state(i2c);
> -
> - ? ? ? return timeout < 0 ? I2C_RETRY : 0;
> -}
>
> ?static int i2c_pxa_wait_master(struct pxa_i2c *i2c)
> ?{
> @@ -425,6 +409,25 @@ static void i2c_pxa_reset(struct pxa_i2c *i2c)
> ? ? ? ?udelay(100);
> ?}
>
> +static int i2c_pxa_wait_bus_not_busy(struct pxa_i2c *i2c)
> +{
> + ? ? ? int timeout = DEF_TIMEOUT;
> +
> + ? ? ? while (timeout-- && readl(_ISR(i2c)) & (ISR_IBB | ISR_UB)) {
> + ? ? ? ? ? ? ? if ((readl(_ISR(i2c)) & ISR_SAD) != 0)
> + ? ? ? ? ? ? ? ? ? ? ? timeout += 4;
> +
> + ? ? ? ? ? ? ? msleep(2);
> + ? ? ? ? ? ? ? show_state(i2c);
> + ? ? ? }
> +
> + ? ? ? if (timeout < 0) {
> + ? ? ? ? ? ? ? show_state(i2c);
> + ? ? ? ? ? ? ? i2c_pxa_reset(i2c);
> + ? ? ? }

Even you reset I2C controller, it shouldn't help you since bus isn't
free. I thinkt that you should reset I2C bus before you reseting I2C
controller.

> +
> + ? ? ? return timeout < 0 ? I2C_RETRY : 0;
> +}
>
> ?#ifdef CONFIG_I2C_PXA_SLAVE
> ?/*
> --
> 1.7.3.2
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 6/7] i2c/pxa2xx: reset the chip if the bus is not free
  2010-11-25  2:30         ` Haojian Zhuang
@ 2010-11-25  2:49             ` Haojian Zhuang
  -1 siblings, 0 replies; 48+ messages in thread
From: Haojian Zhuang @ 2010-11-25  2:49 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	eric.y.miao-Re5JQEeQqe8AvxtiuMwx3w,
	sodaville-hfZtesqFncYOwBW4kG4KsQ,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, Dirk Brandewie,
	linux-lFZ/pmaqli7XmaaqVzeoHQ, tglx-hfZtesqFncYOwBW4kG4KsQ,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

On Thu, Nov 25, 2010 at 10:30 AM, Haojian Zhuang
<haojian.zhuang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> On Thu, Nov 25, 2010 at 5:20 AM, Sebastian Andrzej Siewior
> <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org> wrote:
>> I haven't seen this (yet) during a normal transfer but starting
>> i2cdetect seems to hang the bus. On my Sodaville board, i2cdetect runs
>> fine on bus zero and runs into timeouts on bus one and two. The chip
>> never recovers from this condition. The following transfers hang as
>> well. The ISR_UB never disappears.
>> Issuing a chip reset fixes the timeout and following transfer succeed.
>>
>> Signed-off-by: Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
>> Signed-off-by: Dirk Brandewie <dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>> ---
>>  drivers/i2c/busses/i2c-pxa.c |   35 +++++++++++++++++++----------------
>>  1 files changed, 19 insertions(+), 16 deletions(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
>> index bd4b885..1a48470 100644
>> --- a/drivers/i2c/busses/i2c-pxa.c
>> +++ b/drivers/i2c/busses/i2c-pxa.c
>> @@ -257,23 +257,7 @@ static void i2c_pxa_abort(struct pxa_i2c *i2c)
>>               _ICR(i2c));
>>  }
>>
>> -static int i2c_pxa_wait_bus_not_busy(struct pxa_i2c *i2c)
>> -{
>> -       int timeout = DEF_TIMEOUT;
>>
>> -       while (timeout-- && readl(_ISR(i2c)) & (ISR_IBB | ISR_UB)) {
>> -               if ((readl(_ISR(i2c)) & ISR_SAD) != 0)
>> -                       timeout += 4;
>> -
>> -               msleep(2);
>> -               show_state(i2c);
>> -       }
>> -
>> -       if (timeout < 0)
>> -               show_state(i2c);
>> -
>> -       return timeout < 0 ? I2C_RETRY : 0;
>> -}
>>
>>  static int i2c_pxa_wait_master(struct pxa_i2c *i2c)
>>  {
>> @@ -425,6 +409,25 @@ static void i2c_pxa_reset(struct pxa_i2c *i2c)
>>        udelay(100);
>>  }
>>
>> +static int i2c_pxa_wait_bus_not_busy(struct pxa_i2c *i2c)
>> +{
>> +       int timeout = DEF_TIMEOUT;
>> +
>> +       while (timeout-- && readl(_ISR(i2c)) & (ISR_IBB | ISR_UB)) {
>> +               if ((readl(_ISR(i2c)) & ISR_SAD) != 0)
>> +                       timeout += 4;
>> +
>> +               msleep(2);
>> +               show_state(i2c);
>> +       }
>> +
>> +       if (timeout < 0) {
>> +               show_state(i2c);
>> +               i2c_pxa_reset(i2c);
>> +       }
>
> Even you reset I2C controller, it shouldn't help you since bus isn't
> free. I thinkt that you should reset I2C bus before you reseting I2C
> controller.
>
Excuse me that my previous comments are for PXA master mode.

I think that you're focused on pxa working on slave mode. But if pxa
is working in master mode, it seems that we needn't reset I2C
controller since it doesn't help.

>> +
>> +       return timeout < 0 ? I2C_RETRY : 0;
>> +}
>>
>>  #ifdef CONFIG_I2C_PXA_SLAVE
>>  /*
>> --
>> 1.7.3.2
>>
>>
>> _______________________________________________
>> linux-arm-kernel mailing list
>> linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>>
>

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [PATCH 6/7] i2c/pxa2xx: reset the chip if the bus is not free
@ 2010-11-25  2:49             ` Haojian Zhuang
  0 siblings, 0 replies; 48+ messages in thread
From: Haojian Zhuang @ 2010-11-25  2:49 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Nov 25, 2010 at 10:30 AM, Haojian Zhuang
<haojian.zhuang@gmail.com> wrote:
> On Thu, Nov 25, 2010 at 5:20 AM, Sebastian Andrzej Siewior
> <bigeasy@linutronix.de> wrote:
>> I haven't seen this (yet) during a normal transfer but starting
>> i2cdetect seems to hang the bus. On my Sodaville board, i2cdetect runs
>> fine on bus zero and runs into timeouts on bus one and two. The chip
>> never recovers from this condition. The following transfers hang as
>> well. The ISR_UB never disappears.
>> Issuing a chip reset fixes the timeout and following transfer succeed.
>>
>> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
>> Signed-off-by: Dirk Brandewie <dirk.brandewie@gmail.com>
>> ---
>> ?drivers/i2c/busses/i2c-pxa.c | ? 35 +++++++++++++++++++----------------
>> ?1 files changed, 19 insertions(+), 16 deletions(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
>> index bd4b885..1a48470 100644
>> --- a/drivers/i2c/busses/i2c-pxa.c
>> +++ b/drivers/i2c/busses/i2c-pxa.c
>> @@ -257,23 +257,7 @@ static void i2c_pxa_abort(struct pxa_i2c *i2c)
>> ? ? ? ? ? ? ? _ICR(i2c));
>> ?}
>>
>> -static int i2c_pxa_wait_bus_not_busy(struct pxa_i2c *i2c)
>> -{
>> - ? ? ? int timeout = DEF_TIMEOUT;
>>
>> - ? ? ? while (timeout-- && readl(_ISR(i2c)) & (ISR_IBB | ISR_UB)) {
>> - ? ? ? ? ? ? ? if ((readl(_ISR(i2c)) & ISR_SAD) != 0)
>> - ? ? ? ? ? ? ? ? ? ? ? timeout += 4;
>> -
>> - ? ? ? ? ? ? ? msleep(2);
>> - ? ? ? ? ? ? ? show_state(i2c);
>> - ? ? ? }
>> -
>> - ? ? ? if (timeout < 0)
>> - ? ? ? ? ? ? ? show_state(i2c);
>> -
>> - ? ? ? return timeout < 0 ? I2C_RETRY : 0;
>> -}
>>
>> ?static int i2c_pxa_wait_master(struct pxa_i2c *i2c)
>> ?{
>> @@ -425,6 +409,25 @@ static void i2c_pxa_reset(struct pxa_i2c *i2c)
>> ? ? ? ?udelay(100);
>> ?}
>>
>> +static int i2c_pxa_wait_bus_not_busy(struct pxa_i2c *i2c)
>> +{
>> + ? ? ? int timeout = DEF_TIMEOUT;
>> +
>> + ? ? ? while (timeout-- && readl(_ISR(i2c)) & (ISR_IBB | ISR_UB)) {
>> + ? ? ? ? ? ? ? if ((readl(_ISR(i2c)) & ISR_SAD) != 0)
>> + ? ? ? ? ? ? ? ? ? ? ? timeout += 4;
>> +
>> + ? ? ? ? ? ? ? msleep(2);
>> + ? ? ? ? ? ? ? show_state(i2c);
>> + ? ? ? }
>> +
>> + ? ? ? if (timeout < 0) {
>> + ? ? ? ? ? ? ? show_state(i2c);
>> + ? ? ? ? ? ? ? i2c_pxa_reset(i2c);
>> + ? ? ? }
>
> Even you reset I2C controller, it shouldn't help you since bus isn't
> free. I thinkt that you should reset I2C bus before you reseting I2C
> controller.
>
Excuse me that my previous comments are for PXA master mode.

I think that you're focused on pxa working on slave mode. But if pxa
is working in master mode, it seems that we needn't reset I2C
controller since it doesn't help.

>> +
>> + ? ? ? return timeout < 0 ? I2C_RETRY : 0;
>> +}
>>
>> ?#ifdef CONFIG_I2C_PXA_SLAVE
>> ?/*
>> --
>> 1.7.3.2
>>
>>
>> _______________________________________________
>> linux-arm-kernel mailing list
>> linux-arm-kernel at lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>>
>

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 6/7] i2c/pxa2xx: reset the chip if the bus is not free
  2010-11-25  2:49             ` Haojian Zhuang
@ 2010-11-25  6:43                 ` Igor Grinberg
  -1 siblings, 0 replies; 48+ messages in thread
From: Igor Grinberg @ 2010-11-25  6:43 UTC (permalink / raw)
  To: Haojian Zhuang
  Cc: Sebastian Andrzej Siewior, eric.y.miao-Re5JQEeQqe8AvxtiuMwx3w,
	sodaville-hfZtesqFncYOwBW4kG4KsQ,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, Dirk Brandewie,
	linux-lFZ/pmaqli7XmaaqVzeoHQ, tglx-hfZtesqFncYOwBW4kG4KsQ,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

 Hi,

On 11/25/10 04:49, Haojian Zhuang wrote:
> On Thu, Nov 25, 2010 at 10:30 AM, Haojian Zhuang
> <haojian.zhuang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>> On Thu, Nov 25, 2010 at 5:20 AM, Sebastian Andrzej Siewior
>> <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org> wrote:
>>> I haven't seen this (yet) during a normal transfer but starting
>>> i2cdetect seems to hang the bus. On my Sodaville board, i2cdetect runs
>>> fine on bus zero and runs into timeouts on bus one and two. The chip
>>> never recovers from this condition. The following transfers hang as
>>> well. The ISR_UB never disappears.
>>> Issuing a chip reset fixes the timeout and following transfer succeed.
>>>
>>> Signed-off-by: Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
>>> Signed-off-by: Dirk Brandewie <dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>>> ---
>>>  drivers/i2c/busses/i2c-pxa.c |   35 +++++++++++++++++++----------------
>>>  1 files changed, 19 insertions(+), 16 deletions(-)
>>>
>>> diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
>>> index bd4b885..1a48470 100644
>>> --- a/drivers/i2c/busses/i2c-pxa.c
>>> +++ b/drivers/i2c/busses/i2c-pxa.c
>>> @@ -257,23 +257,7 @@ static void i2c_pxa_abort(struct pxa_i2c *i2c)
>>>               _ICR(i2c));
>>>  }
>>>
>>> -static int i2c_pxa_wait_bus_not_busy(struct pxa_i2c *i2c)
>>> -{
>>> -       int timeout = DEF_TIMEOUT;
>>>
>>> -       while (timeout-- && readl(_ISR(i2c)) & (ISR_IBB | ISR_UB)) {
>>> -               if ((readl(_ISR(i2c)) & ISR_SAD) != 0)
>>> -                       timeout += 4;
>>> -
>>> -               msleep(2);
>>> -               show_state(i2c);
>>> -       }
>>> -
>>> -       if (timeout < 0)
>>> -               show_state(i2c);
>>> -
>>> -       return timeout < 0 ? I2C_RETRY : 0;
>>> -}
>>>
>>>  static int i2c_pxa_wait_master(struct pxa_i2c *i2c)
>>>  {
>>> @@ -425,6 +409,25 @@ static void i2c_pxa_reset(struct pxa_i2c *i2c)
>>>        udelay(100);
>>>  }
>>>
>>> +static int i2c_pxa_wait_bus_not_busy(struct pxa_i2c *i2c)
>>> +{
>>> +       int timeout = DEF_TIMEOUT;
>>> +
>>> +       while (timeout-- && readl(_ISR(i2c)) & (ISR_IBB | ISR_UB)) {
>>> +               if ((readl(_ISR(i2c)) & ISR_SAD) != 0)
>>> +                       timeout += 4;
>>> +
>>> +               msleep(2);
>>> +               show_state(i2c);
>>> +       }
>>> +
>>> +       if (timeout < 0) {
>>> +               show_state(i2c);
>>> +               i2c_pxa_reset(i2c);
>>> +       }
>> Even you reset I2C controller, it shouldn't help you since bus isn't
>> free. I thinkt that you should reset I2C bus before you reseting I2C
>> controller.
>>
> Excuse me that my previous comments are for PXA master mode.
>
> I think that you're focused on pxa working on slave mode. But if pxa
> is working in master mode, it seems that we needn't reset I2C
> controller since it doesn't help.

As for PXA3xx, the Developer Manual states:
"Software must ensure that the TWSI unit is not busy (ISR[UB] = 0)
before it asserts a reset. Software must also ensure that the TWSI bus is idle (ISR[IBB] = 0)
when the unit is enabled after reset."

>From my experience, in master mode resetting the controller
does not help and if the bus is busy for too much time,
there always was a h/w problem involved.

>>> +
>>> +       return timeout < 0 ? I2C_RETRY : 0;
>>> +}
>>>
>>>  #ifdef CONFIG_I2C_PXA_SLAVE
>>>  /*
>>> --
>>> 1.7.3.2
>>>
>>>
>>> _______________________________________________
>>> linux-arm-kernel mailing list
>>> linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
>>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>>>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>

-- 
Regards,
Igor.

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [PATCH 6/7] i2c/pxa2xx: reset the chip if the bus is not free
@ 2010-11-25  6:43                 ` Igor Grinberg
  0 siblings, 0 replies; 48+ messages in thread
From: Igor Grinberg @ 2010-11-25  6:43 UTC (permalink / raw)
  To: linux-arm-kernel

 Hi,

On 11/25/10 04:49, Haojian Zhuang wrote:
> On Thu, Nov 25, 2010 at 10:30 AM, Haojian Zhuang
> <haojian.zhuang@gmail.com> wrote:
>> On Thu, Nov 25, 2010 at 5:20 AM, Sebastian Andrzej Siewior
>> <bigeasy@linutronix.de> wrote:
>>> I haven't seen this (yet) during a normal transfer but starting
>>> i2cdetect seems to hang the bus. On my Sodaville board, i2cdetect runs
>>> fine on bus zero and runs into timeouts on bus one and two. The chip
>>> never recovers from this condition. The following transfers hang as
>>> well. The ISR_UB never disappears.
>>> Issuing a chip reset fixes the timeout and following transfer succeed.
>>>
>>> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
>>> Signed-off-by: Dirk Brandewie <dirk.brandewie@gmail.com>
>>> ---
>>>  drivers/i2c/busses/i2c-pxa.c |   35 +++++++++++++++++++----------------
>>>  1 files changed, 19 insertions(+), 16 deletions(-)
>>>
>>> diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
>>> index bd4b885..1a48470 100644
>>> --- a/drivers/i2c/busses/i2c-pxa.c
>>> +++ b/drivers/i2c/busses/i2c-pxa.c
>>> @@ -257,23 +257,7 @@ static void i2c_pxa_abort(struct pxa_i2c *i2c)
>>>               _ICR(i2c));
>>>  }
>>>
>>> -static int i2c_pxa_wait_bus_not_busy(struct pxa_i2c *i2c)
>>> -{
>>> -       int timeout = DEF_TIMEOUT;
>>>
>>> -       while (timeout-- && readl(_ISR(i2c)) & (ISR_IBB | ISR_UB)) {
>>> -               if ((readl(_ISR(i2c)) & ISR_SAD) != 0)
>>> -                       timeout += 4;
>>> -
>>> -               msleep(2);
>>> -               show_state(i2c);
>>> -       }
>>> -
>>> -       if (timeout < 0)
>>> -               show_state(i2c);
>>> -
>>> -       return timeout < 0 ? I2C_RETRY : 0;
>>> -}
>>>
>>>  static int i2c_pxa_wait_master(struct pxa_i2c *i2c)
>>>  {
>>> @@ -425,6 +409,25 @@ static void i2c_pxa_reset(struct pxa_i2c *i2c)
>>>        udelay(100);
>>>  }
>>>
>>> +static int i2c_pxa_wait_bus_not_busy(struct pxa_i2c *i2c)
>>> +{
>>> +       int timeout = DEF_TIMEOUT;
>>> +
>>> +       while (timeout-- && readl(_ISR(i2c)) & (ISR_IBB | ISR_UB)) {
>>> +               if ((readl(_ISR(i2c)) & ISR_SAD) != 0)
>>> +                       timeout += 4;
>>> +
>>> +               msleep(2);
>>> +               show_state(i2c);
>>> +       }
>>> +
>>> +       if (timeout < 0) {
>>> +               show_state(i2c);
>>> +               i2c_pxa_reset(i2c);
>>> +       }
>> Even you reset I2C controller, it shouldn't help you since bus isn't
>> free. I thinkt that you should reset I2C bus before you reseting I2C
>> controller.
>>
> Excuse me that my previous comments are for PXA master mode.
>
> I think that you're focused on pxa working on slave mode. But if pxa
> is working in master mode, it seems that we needn't reset I2C
> controller since it doesn't help.

As for PXA3xx, the Developer Manual states:
"Software must ensure that the TWSI unit is not busy (ISR[UB] = 0)
before it asserts a reset. Software must also ensure that the TWSI bus is idle (ISR[IBB] = 0)
when the unit is enabled after reset."

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 6/7] i2c/pxa2xx: reset the chip if the bus is not free
  2010-11-25  6:43                 ` Igor Grinberg
@ 2010-11-25  7:04                     ` Haojian Zhuang
  -1 siblings, 0 replies; 48+ messages in thread
From: Haojian Zhuang @ 2010-11-25  7:04 UTC (permalink / raw)
  To: Igor Grinberg
  Cc: Sebastian Andrzej Siewior, eric.y.miao, sodaville, linux-i2c,
	ben-linux, Dirk Brandewie, linux, tglx, linux-arm-kernel

On Thu, Nov 25, 2010 at 2:43 PM, Igor Grinberg <grinberg-UTxiZqZC01RS1MOuV/RT9w@public.gmane.org> wrote:
>  Hi,
>
> On 11/25/10 04:49, Haojian Zhuang wrote:
>> On Thu, Nov 25, 2010 at 10:30 AM, Haojian Zhuang
>> <haojian.zhuang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>>> On Thu, Nov 25, 2010 at 5:20 AM, Sebastian Andrzej Siewior
>>> <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org> wrote:
>>>> I haven't seen this (yet) during a normal transfer but starting
>>>> i2cdetect seems to hang the bus. On my Sodaville board, i2cdetect runs
>>>> fine on bus zero and runs into timeouts on bus one and two. The chip
>>>> never recovers from this condition. The following transfers hang as
>>>> well. The ISR_UB never disappears.
>>>> Issuing a chip reset fixes the timeout and following transfer succeed.
>>>>
>>>> Signed-off-by: Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
>>>> Signed-off-by: Dirk Brandewie <dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>>>> ---
>>>>  drivers/i2c/busses/i2c-pxa.c |   35 +++++++++++++++++++----------------
>>>>  1 files changed, 19 insertions(+), 16 deletions(-)
>>>>
>>>> diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
>>>> index bd4b885..1a48470 100644
>>>> --- a/drivers/i2c/busses/i2c-pxa.c
>>>> +++ b/drivers/i2c/busses/i2c-pxa.c
>>>> @@ -257,23 +257,7 @@ static void i2c_pxa_abort(struct pxa_i2c *i2c)
>>>>               _ICR(i2c));
>>>>  }
>>>>
>>>> -static int i2c_pxa_wait_bus_not_busy(struct pxa_i2c *i2c)
>>>> -{
>>>> -       int timeout = DEF_TIMEOUT;
>>>>
>>>> -       while (timeout-- && readl(_ISR(i2c)) & (ISR_IBB | ISR_UB)) {
>>>> -               if ((readl(_ISR(i2c)) & ISR_SAD) != 0)
>>>> -                       timeout += 4;
>>>> -
>>>> -               msleep(2);
>>>> -               show_state(i2c);
>>>> -       }
>>>> -
>>>> -       if (timeout < 0)
>>>> -               show_state(i2c);
>>>> -
>>>> -       return timeout < 0 ? I2C_RETRY : 0;
>>>> -}
>>>>
>>>>  static int i2c_pxa_wait_master(struct pxa_i2c *i2c)
>>>>  {
>>>> @@ -425,6 +409,25 @@ static void i2c_pxa_reset(struct pxa_i2c *i2c)
>>>>        udelay(100);
>>>>  }
>>>>
>>>> +static int i2c_pxa_wait_bus_not_busy(struct pxa_i2c *i2c)
>>>> +{
>>>> +       int timeout = DEF_TIMEOUT;
>>>> +
>>>> +       while (timeout-- && readl(_ISR(i2c)) & (ISR_IBB | ISR_UB)) {
>>>> +               if ((readl(_ISR(i2c)) & ISR_SAD) != 0)
>>>> +                       timeout += 4;
>>>> +
>>>> +               msleep(2);
>>>> +               show_state(i2c);
>>>> +       }
>>>> +
>>>> +       if (timeout < 0) {
>>>> +               show_state(i2c);
>>>> +               i2c_pxa_reset(i2c);
>>>> +       }
>>> Even you reset I2C controller, it shouldn't help you since bus isn't
>>> free. I thinkt that you should reset I2C bus before you reseting I2C
>>> controller.
>>>
>> Excuse me that my previous comments are for PXA master mode.
>>
>> I think that you're focused on pxa working on slave mode. But if pxa
>> is working in master mode, it seems that we needn't reset I2C
>> controller since it doesn't help.
>
> As for PXA3xx, the Developer Manual states:
> "Software must ensure that the TWSI unit is not busy (ISR[UB] = 0)
> before it asserts a reset. Software must also ensure that the TWSI bus is idle (ISR[IBB] = 0)
> when the unit is enabled after reset."
>
> From my experience, in master mode resetting the controller
> does not help and if the bus is busy for too much time,
> there always was a h/w problem involved.
>

Yes, it's true. Actually there's some not smart firmware on some I2C
client devices that they may fetch wrong data as slave address and
command. There're two solutions for this bus busy issue. One is _not_
using this kind of client device. The other one is sending enough dump
clock to push these client device back to idle state.

>>>> +
>>>> +       return timeout < 0 ? I2C_RETRY : 0;
>>>> +}
>>>>
>>>>  #ifdef CONFIG_I2C_PXA_SLAVE
>>>>  /*
>>>> --
>>>> 1.7.3.2
>>>>
>>>>
>>>> _______________________________________________
>>>> linux-arm-kernel mailing list
>>>> linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
>>>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>>>>
>> _______________________________________________
>> linux-arm-kernel mailing list
>> linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>>
>
> --
> Regards,
> Igor.
>
>

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [PATCH 6/7] i2c/pxa2xx: reset the chip if the bus is not free
@ 2010-11-25  7:04                     ` Haojian Zhuang
  0 siblings, 0 replies; 48+ messages in thread
From: Haojian Zhuang @ 2010-11-25  7:04 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Nov 25, 2010 at 2:43 PM, Igor Grinberg <grinberg@compulab.co.il> wrote:
> ?Hi,
>
> On 11/25/10 04:49, Haojian Zhuang wrote:
>> On Thu, Nov 25, 2010 at 10:30 AM, Haojian Zhuang
>> <haojian.zhuang@gmail.com> wrote:
>>> On Thu, Nov 25, 2010 at 5:20 AM, Sebastian Andrzej Siewior
>>> <bigeasy@linutronix.de> wrote:
>>>> I haven't seen this (yet) during a normal transfer but starting
>>>> i2cdetect seems to hang the bus. On my Sodaville board, i2cdetect runs
>>>> fine on bus zero and runs into timeouts on bus one and two. The chip
>>>> never recovers from this condition. The following transfers hang as
>>>> well. The ISR_UB never disappears.
>>>> Issuing a chip reset fixes the timeout and following transfer succeed.
>>>>
>>>> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
>>>> Signed-off-by: Dirk Brandewie <dirk.brandewie@gmail.com>
>>>> ---
>>>> ?drivers/i2c/busses/i2c-pxa.c | ? 35 +++++++++++++++++++----------------
>>>> ?1 files changed, 19 insertions(+), 16 deletions(-)
>>>>
>>>> diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
>>>> index bd4b885..1a48470 100644
>>>> --- a/drivers/i2c/busses/i2c-pxa.c
>>>> +++ b/drivers/i2c/busses/i2c-pxa.c
>>>> @@ -257,23 +257,7 @@ static void i2c_pxa_abort(struct pxa_i2c *i2c)
>>>> ? ? ? ? ? ? ? _ICR(i2c));
>>>> ?}
>>>>
>>>> -static int i2c_pxa_wait_bus_not_busy(struct pxa_i2c *i2c)
>>>> -{
>>>> - ? ? ? int timeout = DEF_TIMEOUT;
>>>>
>>>> - ? ? ? while (timeout-- && readl(_ISR(i2c)) & (ISR_IBB | ISR_UB)) {
>>>> - ? ? ? ? ? ? ? if ((readl(_ISR(i2c)) & ISR_SAD) != 0)
>>>> - ? ? ? ? ? ? ? ? ? ? ? timeout += 4;
>>>> -
>>>> - ? ? ? ? ? ? ? msleep(2);
>>>> - ? ? ? ? ? ? ? show_state(i2c);
>>>> - ? ? ? }
>>>> -
>>>> - ? ? ? if (timeout < 0)
>>>> - ? ? ? ? ? ? ? show_state(i2c);
>>>> -
>>>> - ? ? ? return timeout < 0 ? I2C_RETRY : 0;
>>>> -}
>>>>
>>>> ?static int i2c_pxa_wait_master(struct pxa_i2c *i2c)
>>>> ?{
>>>> @@ -425,6 +409,25 @@ static void i2c_pxa_reset(struct pxa_i2c *i2c)
>>>> ? ? ? ?udelay(100);
>>>> ?}
>>>>
>>>> +static int i2c_pxa_wait_bus_not_busy(struct pxa_i2c *i2c)
>>>> +{
>>>> + ? ? ? int timeout = DEF_TIMEOUT;
>>>> +
>>>> + ? ? ? while (timeout-- && readl(_ISR(i2c)) & (ISR_IBB | ISR_UB)) {
>>>> + ? ? ? ? ? ? ? if ((readl(_ISR(i2c)) & ISR_SAD) != 0)
>>>> + ? ? ? ? ? ? ? ? ? ? ? timeout += 4;
>>>> +
>>>> + ? ? ? ? ? ? ? msleep(2);
>>>> + ? ? ? ? ? ? ? show_state(i2c);
>>>> + ? ? ? }
>>>> +
>>>> + ? ? ? if (timeout < 0) {
>>>> + ? ? ? ? ? ? ? show_state(i2c);
>>>> + ? ? ? ? ? ? ? i2c_pxa_reset(i2c);
>>>> + ? ? ? }
>>> Even you reset I2C controller, it shouldn't help you since bus isn't
>>> free. I thinkt that you should reset I2C bus before you reseting I2C
>>> controller.
>>>
>> Excuse me that my previous comments are for PXA master mode.
>>
>> I think that you're focused on pxa working on slave mode. But if pxa
>> is working in master mode, it seems that we needn't reset I2C
>> controller since it doesn't help.
>
> As for PXA3xx, the Developer Manual states:
> "Software must ensure that the TWSI unit is not busy (ISR[UB] = 0)
> before it asserts a reset. Software must also ensure that the TWSI bus is idle (ISR[IBB] = 0)
> when the unit is enabled after reset."
>
> From my experience, in master mode resetting the controller
> does not help and if the bus is busy for too much time,
> there always was a h/w problem involved.
>

Yes, it's true. Actually there's some not smart firmware on some I2C
client devices that they may fetch wrong data as slave address and
command. There're two solutions for this bus busy issue. One is _not_
using this kind of client device. The other one is sending enough dump
clock to push these client device back to idle state.

>>>> +
>>>> + ? ? ? return timeout < 0 ? I2C_RETRY : 0;
>>>> +}
>>>>
>>>> ?#ifdef CONFIG_I2C_PXA_SLAVE
>>>> ?/*
>>>> --
>>>> 1.7.3.2
>>>>
>>>>
>>>> _______________________________________________
>>>> linux-arm-kernel mailing list
>>>> linux-arm-kernel at lists.infradead.org
>>>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>>>>
>> _______________________________________________
>> linux-arm-kernel mailing list
>> linux-arm-kernel at lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>>
>
> --
> Regards,
> Igor.
>
>

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 4/7] i2c/pxa2xx: add support for shared IRQ handler
  2010-11-25  2:26         ` Haojian Zhuang
@ 2010-11-25 10:48           ` Sebastian Andrzej Siewior
  -1 siblings, 0 replies; 48+ messages in thread
From: Sebastian Andrzej Siewior @ 2010-11-25 10:48 UTC (permalink / raw)
  To: Haojian Zhuang
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	eric.y.miao-Re5JQEeQqe8AvxtiuMwx3w,
	sodaville-hfZtesqFncYOwBW4kG4KsQ,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, Dirk Brandewie,
	linux-lFZ/pmaqli7XmaaqVzeoHQ, tglx-hfZtesqFncYOwBW4kG4KsQ,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

Haojian Zhuang wrote:
>> diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
>> index dc66fde..7647361 100644
>> --- a/drivers/i2c/busses/i2c-pxa.c
>> +++ b/drivers/i2c/busses/i2c-pxa.c
>> @@ -905,11 +905,17 @@ static void i2c_pxa_irq_rxfull(struct pxa_i2c *i2c, u32 isr)
>>        writel(icr, _ICR(i2c));
>>  }
>>
>> +#define VALID_INT_SOURCE       (ISR_SSD | ISR_ALD | ISR_ITE | ISR_IRF | \
>> +                               ISR_SAD | ISR_BED)
>>  static irqreturn_t i2c_pxa_handler(int this_irq, void *dev_id)
>>  {
>>        struct pxa_i2c *i2c = dev_id;
>>        u32 isr = readl(_ISR(i2c));
>>
>> +       isr &= VALID_INT_SOURCE;
>> +       if (!isr)
>> +               return IRQ_NONE;
>> +
> 
> If you return at here, the valid interrupt status event won't be
> cleared in IRQ handler. So I2C interrupt handler will be triggered at
> next time.

The point here is that I have a shared handler and I have to know if my
i2c device issued an interrupt or another device. If I return here then it
was not my i2c device bot some other device hanging on the same interrupt
line.
I can't simply test for !isr (without VALID_INT_SOURCE) because some bits
in this register have nothing todo with the interrupt status as it.

Sebastian

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [PATCH 4/7] i2c/pxa2xx: add support for shared IRQ handler
@ 2010-11-25 10:48           ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 48+ messages in thread
From: Sebastian Andrzej Siewior @ 2010-11-25 10:48 UTC (permalink / raw)
  To: linux-arm-kernel

Haojian Zhuang wrote:
>> diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
>> index dc66fde..7647361 100644
>> --- a/drivers/i2c/busses/i2c-pxa.c
>> +++ b/drivers/i2c/busses/i2c-pxa.c
>> @@ -905,11 +905,17 @@ static void i2c_pxa_irq_rxfull(struct pxa_i2c *i2c, u32 isr)
>>        writel(icr, _ICR(i2c));
>>  }
>>
>> +#define VALID_INT_SOURCE       (ISR_SSD | ISR_ALD | ISR_ITE | ISR_IRF | \
>> +                               ISR_SAD | ISR_BED)
>>  static irqreturn_t i2c_pxa_handler(int this_irq, void *dev_id)
>>  {
>>        struct pxa_i2c *i2c = dev_id;
>>        u32 isr = readl(_ISR(i2c));
>>
>> +       isr &= VALID_INT_SOURCE;
>> +       if (!isr)
>> +               return IRQ_NONE;
>> +
> 
> If you return at here, the valid interrupt status event won't be
> cleared in IRQ handler. So I2C interrupt handler will be triggered at
> next time.

The point here is that I have a shared handler and I have to know if my
i2c device issued an interrupt or another device. If I return here then it
was not my i2c device bot some other device hanging on the same interrupt
line.
I can't simply test for !isr (without VALID_INT_SOURCE) because some bits
in this register have nothing todo with the interrupt status as it.

Sebastian

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 6/7] i2c/pxa2xx: reset the chip if the bus is not free
  2010-11-25  6:43                 ` Igor Grinberg
@ 2010-11-25 12:24                     ` Sebastian Andrzej Siewior
  -1 siblings, 0 replies; 48+ messages in thread
From: Sebastian Andrzej Siewior @ 2010-11-25 12:24 UTC (permalink / raw)
  To: Igor Grinberg
  Cc: Haojian Zhuang, eric.y.miao-Re5JQEeQqe8AvxtiuMwx3w,
	sodaville-hfZtesqFncYOwBW4kG4KsQ,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, Dirk Brandewie,
	linux-lFZ/pmaqli7XmaaqVzeoHQ, tglx-hfZtesqFncYOwBW4kG4KsQ,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

Igor Grinberg wrote:
>  Hi,
Hi,

>>> Even you reset I2C controller, it shouldn't help you since bus isn't
>>> free. I thinkt that you should reset I2C bus before you reseting I2C
>>> controller.

According to the register, IBB (bus busy) is cleared at this point. The
only remaining flag is UB (unit busy) and RW mode.

>> Excuse me that my previous comments are for PXA master mode.
I am in master mode.

>> I think that you're focused on pxa working on slave mode. But if pxa
>> is working in master mode, it seems that we needn't reset I2C
>> controller since it doesn't help.
> 
> As for PXA3xx, the Developer Manual states:
> "Software must ensure that the TWSI unit is not busy (ISR[UB] = 0)
> before it asserts a reset. Software must also ensure that the TWSI bus is idle (ISR[IBB] = 0)
> when the unit is enabled after reset."

My manual says more or less the same thing. It says "unit not busy" but
quotes the IBB bit in braces. It is probably a typo.
The register say: ISR=00000005, ICR=000017e0, IBMR=01
So according to this I am not allowed to reset the I2C unit while it is
busy.

I tracked it down to the following: i2cdetect tries to read a byte from
address 47. This fails because there is no device. Then it goes for 48
which returns 0 (there is a device). The following read always fails. So I
guess the device at 48 is still sending data. What is general rule of
thumb in such a case?

>>From my experience, in master mode resetting the controller
> does not help and if the bus is busy for too much time,
> there always was a h/w problem involved.

Looks like it.

Sebastian

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [PATCH 6/7] i2c/pxa2xx: reset the chip if the bus is not free
@ 2010-11-25 12:24                     ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 48+ messages in thread
From: Sebastian Andrzej Siewior @ 2010-11-25 12:24 UTC (permalink / raw)
  To: linux-arm-kernel

Igor Grinberg wrote:
>  Hi,
Hi,

>>> Even you reset I2C controller, it shouldn't help you since bus isn't
>>> free. I thinkt that you should reset I2C bus before you reseting I2C
>>> controller.

According to the register, IBB (bus busy) is cleared at this point. The
only remaining flag is UB (unit busy) and RW mode.

>> Excuse me that my previous comments are for PXA master mode.
I am in master mode.

>> I think that you're focused on pxa working on slave mode. But if pxa
>> is working in master mode, it seems that we needn't reset I2C
>> controller since it doesn't help.
> 
> As for PXA3xx, the Developer Manual states:
> "Software must ensure that the TWSI unit is not busy (ISR[UB] = 0)
> before it asserts a reset. Software must also ensure that the TWSI bus is idle (ISR[IBB] = 0)
> when the unit is enabled after reset."

My manual says more or less the same thing. It says "unit not busy" but
quotes the IBB bit in braces. It is probably a typo.
The register say: ISR=00000005, ICR=000017e0, IBMR=01
So according to this I am not allowed to reset the I2C unit while it is
busy.

I tracked it down to the following: i2cdetect tries to read a byte from
address 47. This fails because there is no device. Then it goes for 48
which returns 0 (there is a device). The following read always fails. So I
guess the device at 48 is still sending data. What is general rule of
thumb in such a case?

>>From my experience, in master mode resetting the controller
> does not help and if the bus is busy for too much time,
> there always was a h/w problem involved.

Looks like it.

Sebastian

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 6/7] i2c/pxa2xx: reset the chip if the bus is not free
  2010-11-25 12:24                     ` Sebastian Andrzej Siewior
@ 2010-11-25 13:10                         ` Igor Grinberg
  -1 siblings, 0 replies; 48+ messages in thread
From: Igor Grinberg @ 2010-11-25 13:10 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: Haojian Zhuang, eric.y.miao-Re5JQEeQqe8AvxtiuMwx3w,
	sodaville-hfZtesqFncYOwBW4kG4KsQ,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, Dirk Brandewie,
	linux-lFZ/pmaqli7XmaaqVzeoHQ, tglx-hfZtesqFncYOwBW4kG4KsQ,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

 On 11/25/10 14:24, Sebastian Andrzej Siewior wrote:
> Igor Grinberg wrote:
>>  Hi,
> Hi,
>
>>>> Even you reset I2C controller, it shouldn't help you since bus isn't
>>>> free. I thinkt that you should reset I2C bus before you reseting I2C
>>>> controller.
>
> According to the register, IBB (bus busy) is cleared at this point. The
> only remaining flag is UB (unit busy) and RW mode.
>
>>> Excuse me that my previous comments are for PXA master mode.
> I am in master mode.
>
>>> I think that you're focused on pxa working on slave mode. But if pxa
>>> is working in master mode, it seems that we needn't reset I2C
>>> controller since it doesn't help.
>>
>> As for PXA3xx, the Developer Manual states:
>> "Software must ensure that the TWSI unit is not busy (ISR[UB] = 0)
>> before it asserts a reset. Software must also ensure that the TWSI bus is idle (ISR[IBB] = 0)
>> when the unit is enabled after reset."
>
> My manual says more or less the same thing. It says "unit not busy" but
> quotes the IBB bit in braces. It is probably a typo.
> The register say: ISR=00000005, ICR=000017e0, IBMR=01
> So according to this I am not allowed to reset the I2C unit while it is
> busy.
>
> I tracked it down to the following: i2cdetect tries to read a byte from
> address 47. This fails because there is no device. Then it goes for 48
> which returns 0 (there is a device). The following read always fails. So I
> guess the device at 48 is still sending data. What is general rule of
> thumb in such a case?

I don't think there is such a rule for this case, as if we "believe" the
Developer Manual, but do the opposite - we can get into trouble...
IMHO, at least we need to report a problem.

Or may be in some way reset the slave device,
if there is such an option available outside the i2c scope...
(Yeah, I know this is a crazy idea...)

>
>>> From my experience, in master mode resetting the controller
>> does not help and if the bus is busy for too much time,
>> there always was a h/w problem involved.
>
> Looks like it.

1) Well, you should check if you have a pull-up resistors on that bus.
2) Or if the slave device chip is broken, then it should be replaced.

>
> Sebastian
>

-- 
Regards,
Igor.

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [PATCH 6/7] i2c/pxa2xx: reset the chip if the bus is not free
@ 2010-11-25 13:10                         ` Igor Grinberg
  0 siblings, 0 replies; 48+ messages in thread
From: Igor Grinberg @ 2010-11-25 13:10 UTC (permalink / raw)
  To: linux-arm-kernel

 On 11/25/10 14:24, Sebastian Andrzej Siewior wrote:
> Igor Grinberg wrote:
>>  Hi,
> Hi,
>
>>>> Even you reset I2C controller, it shouldn't help you since bus isn't
>>>> free. I thinkt that you should reset I2C bus before you reseting I2C
>>>> controller.
>
> According to the register, IBB (bus busy) is cleared at this point. The
> only remaining flag is UB (unit busy) and RW mode.
>
>>> Excuse me that my previous comments are for PXA master mode.
> I am in master mode.
>
>>> I think that you're focused on pxa working on slave mode. But if pxa
>>> is working in master mode, it seems that we needn't reset I2C
>>> controller since it doesn't help.
>>
>> As for PXA3xx, the Developer Manual states:
>> "Software must ensure that the TWSI unit is not busy (ISR[UB] = 0)
>> before it asserts a reset. Software must also ensure that the TWSI bus is idle (ISR[IBB] = 0)
>> when the unit is enabled after reset."
>
> My manual says more or less the same thing. It says "unit not busy" but
> quotes the IBB bit in braces. It is probably a typo.
> The register say: ISR=00000005, ICR=000017e0, IBMR=01
> So according to this I am not allowed to reset the I2C unit while it is
> busy.
>
> I tracked it down to the following: i2cdetect tries to read a byte from
> address 47. This fails because there is no device. Then it goes for 48
> which returns 0 (there is a device). The following read always fails. So I
> guess the device at 48 is still sending data. What is general rule of
> thumb in such a case?

I don't think there is such a rule for this case, as if we "believe" the
Developer Manual, but do the opposite - we can get into trouble...
IMHO, at least we need to report a problem.

Or may be in some way reset the slave device,
if there is such an option available outside the i2c scope...
(Yeah, I know this is a crazy idea...)

>
>>> From my experience, in master mode resetting the controller
>> does not help and if the bus is busy for too much time,
>> there always was a h/w problem involved.
>
> Looks like it.

1) Well, you should check if you have a pull-up resistors on that bus.
2) Or if the slave device chip is broken, then it should be replaced.

>
> Sebastian
>

-- 
Regards,
Igor.

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 6/7] i2c/pxa2xx: reset the chip if the bus is not free
  2010-11-25 13:10                         ` Igor Grinberg
@ 2010-11-25 13:39                             ` Sebastian Andrzej Siewior
  -1 siblings, 0 replies; 48+ messages in thread
From: Sebastian Andrzej Siewior @ 2010-11-25 13:39 UTC (permalink / raw)
  To: Igor Grinberg
  Cc: Haojian Zhuang, eric.y.miao-Re5JQEeQqe8AvxtiuMwx3w,
	sodaville-hfZtesqFncYOwBW4kG4KsQ,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, Dirk Brandewie,
	linux-lFZ/pmaqli7XmaaqVzeoHQ, tglx-hfZtesqFncYOwBW4kG4KsQ,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

Igor Grinberg wrote:
> I don't think there is such a rule for this case, as if we "believe" the
> Developer Manual, but do the opposite - we can get into trouble...
> IMHO, at least we need to report a problem.
>
> Or may be in some way reset the slave device,
> if there is such an option available outside the i2c scope...
> (Yeah, I know this is a crazy idea...)

Doing the oposite what the manual says is not a good idea. Let's discard 
the patch for now.

>>>> From my experience, in master mode resetting the controller
>>> does not help and if the bus is busy for too much time,
>>> there always was a h/w problem involved.
>> Looks like it.
> 
> 1) Well, you should check if you have a pull-up resistors on that bus.
> 2) Or if the slave device chip is broken, then it should be replaced.

Thanks for the hint. I try to check the HW and see if there can be done
something about it.

Sebastian

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [PATCH 6/7] i2c/pxa2xx: reset the chip if the bus is not free
@ 2010-11-25 13:39                             ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 48+ messages in thread
From: Sebastian Andrzej Siewior @ 2010-11-25 13:39 UTC (permalink / raw)
  To: linux-arm-kernel

Igor Grinberg wrote:
> I don't think there is such a rule for this case, as if we "believe" the
> Developer Manual, but do the opposite - we can get into trouble...
> IMHO, at least we need to report a problem.
>
> Or may be in some way reset the slave device,
> if there is such an option available outside the i2c scope...
> (Yeah, I know this is a crazy idea...)

Doing the oposite what the manual says is not a good idea. Let's discard 
the patch for now.

>>>> From my experience, in master mode resetting the controller
>>> does not help and if the bus is busy for too much time,
>>> there always was a h/w problem involved.
>> Looks like it.
> 
> 1) Well, you should check if you have a pull-up resistors on that bus.
> 2) Or if the slave device chip is broken, then it should be replaced.

Thanks for the hint. I try to check the HW and see if there can be done
something about it.

Sebastian

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 1/7] i2c/pxa2xx: Don't touch ISAR if not in slave mode
  2010-11-24 21:20     ` Sebastian Andrzej Siewior
@ 2010-11-25 23:52         ` Ben Dooks
  -1 siblings, 0 replies; 48+ messages in thread
From: Ben Dooks @ 2010-11-25 23:52 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	sodaville-hfZtesqFncYOwBW4kG4KsQ, tglx-hfZtesqFncYOwBW4kG4KsQ,
	eric.y.miao-Re5JQEeQqe8AvxtiuMwx3w, linux-lFZ/pmaqli7XmaaqVzeoHQ,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, Dirk Brandewie

On Wed, Nov 24, 2010 at 10:20:11PM +0100, Sebastian Andrzej Siewior wrote:
> The reset functions sets writes the slave address even in not slave
> mode. I don't see any reason in writting it if slave mode is not
> enabled.
> I have here a PXA-I2C variant where this register is not availbale and
> as such can not be touched.
> 
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
> Signed-off-by: Dirk Brandewie <dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
>  drivers/i2c/busses/i2c-pxa.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
> index f4c19a9..579c8a8 100644
> --- a/drivers/i2c/busses/i2c-pxa.c
> +++ b/drivers/i2c/busses/i2c-pxa.c
> @@ -418,7 +418,9 @@ static void i2c_pxa_reset(struct pxa_i2c *i2c)
>  	writel(I2C_ISR_INIT, _ISR(i2c));
>  	writel(readl(_ICR(i2c)) & ~ICR_UR, _ICR(i2c));
>  
> +#ifdef CONFIG_I2C_PXA_SLAVE
>  	writel(i2c->slave_addr, _ISAR(i2c));
> +#endif

I was thinking about whether to add a flag to this to say whether the
slave_addr field is valid, but to keep full compatiblity with the existing
pxa users, we'd have to go and change every board using it.

-- 
Ben

Q:      What's a light-year?
A:      One-third less calories than a regular year.

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [PATCH 1/7] i2c/pxa2xx: Don't touch ISAR if not in slave mode
@ 2010-11-25 23:52         ` Ben Dooks
  0 siblings, 0 replies; 48+ messages in thread
From: Ben Dooks @ 2010-11-25 23:52 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Nov 24, 2010 at 10:20:11PM +0100, Sebastian Andrzej Siewior wrote:
> The reset functions sets writes the slave address even in not slave
> mode. I don't see any reason in writting it if slave mode is not
> enabled.
> I have here a PXA-I2C variant where this register is not availbale and
> as such can not be touched.
> 
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Signed-off-by: Dirk Brandewie <dirk.brandewie@gmail.com>
> ---
>  drivers/i2c/busses/i2c-pxa.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
> index f4c19a9..579c8a8 100644
> --- a/drivers/i2c/busses/i2c-pxa.c
> +++ b/drivers/i2c/busses/i2c-pxa.c
> @@ -418,7 +418,9 @@ static void i2c_pxa_reset(struct pxa_i2c *i2c)
>  	writel(I2C_ISR_INIT, _ISR(i2c));
>  	writel(readl(_ICR(i2c)) & ~ICR_UR, _ICR(i2c));
>  
> +#ifdef CONFIG_I2C_PXA_SLAVE
>  	writel(i2c->slave_addr, _ISAR(i2c));
> +#endif

I was thinking about whether to add a flag to this to say whether the
slave_addr field is valid, but to keep full compatiblity with the existing
pxa users, we'd have to go and change every board using it.

-- 
Ben

Q:      What's a light-year?
A:      One-third less calories than a regular year.

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 2/7] arm/pxa2xx: reorganize I2C files
  2010-11-24 21:20     ` Sebastian Andrzej Siewior
@ 2010-11-25 23:55         ` Ben Dooks
  -1 siblings, 0 replies; 48+ messages in thread
From: Ben Dooks @ 2010-11-25 23:55 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	sodaville-hfZtesqFncYOwBW4kG4KsQ, tglx-hfZtesqFncYOwBW4kG4KsQ,
	eric.y.miao-Re5JQEeQqe8AvxtiuMwx3w, linux-lFZ/pmaqli7XmaaqVzeoHQ,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, Dirk Brandewie

On Wed, Nov 24, 2010 at 10:20:12PM +0100, Sebastian Andrzej Siewior wrote:
> This patch moves the register definitions into include/asm so it can be
> accessed from X86 the same way as on ARM. This move also alters the
> unused register offset definitins (IBMR, ...) and uses them in the
> calculation macros (_IBMR,...).
> The header file from plat-pxa is moved the include/linux for the same
> reason.
> This change should make no functional change to the PXA code. The move
> is verified by building the following defconfigs:
>   cm_x2xx_defconfig corgi_defconfig em_x270_defconfig ezx_defconfig
>   imote2_defconfig pxa3xx_defconfig spitz_defconfig zeus_defconfig
>   raumfeld_defconfig magician_defconfig mmp2_defconfig pxa168_defconfig
>   pxa910_defconfig
> 
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
> Signed-off-by: Dirk Brandewie <dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
>  arch/arm/include/asm/pxa_i2c.h                     |   19 +++++++++++++++++++
>  arch/arm/mach-mmp/include/mach/mmp2.h              |    2 +-
>  arch/arm/mach-mmp/include/mach/pxa168.h            |    2 +-
>  arch/arm/mach-mmp/include/mach/pxa910.h            |    2 +-
>  arch/arm/mach-pxa/balloon3.c                       |    3 +--
>  arch/arm/mach-pxa/cm-x300.c                        |    2 +-
>  arch/arm/mach-pxa/colibri-pxa270-income.c          |    3 +--
>  arch/arm/mach-pxa/corgi.c                          |    2 +-
>  arch/arm/mach-pxa/csb726.c                         |    2 +-
>  arch/arm/mach-pxa/devices.c                        |    2 +-
>  arch/arm/mach-pxa/em-x270.c                        |    2 +-
>  arch/arm/mach-pxa/ezx.c                            |    2 +-
>  arch/arm/mach-pxa/hx4700.c                         |    2 +-
>  arch/arm/mach-pxa/littleton.c                      |    2 +-
>  arch/arm/mach-pxa/magician.c                       |    2 +-
>  arch/arm/mach-pxa/mainstone.c                      |    2 +-
>  arch/arm/mach-pxa/mioa701.c                        |    2 +-
>  arch/arm/mach-pxa/mxm8x10.c                        |    2 +-
>  arch/arm/mach-pxa/palm27x.c                        |    3 +--
>  arch/arm/mach-pxa/pcm990-baseboard.c               |    2 +-
>  arch/arm/mach-pxa/poodle.c                         |    2 +-
>  arch/arm/mach-pxa/pxa27x.c                         |    2 +-
>  arch/arm/mach-pxa/pxa3xx.c                         |    2 +-
>  arch/arm/mach-pxa/raumfeld.c                       |    2 +-
>  arch/arm/mach-pxa/saar.c                           |    2 +-
>  arch/arm/mach-pxa/spitz.c                          |    3 +--
>  arch/arm/mach-pxa/stargate2.c                      |    2 +-
>  arch/arm/mach-pxa/tavorevb3.c                      |    3 +--
>  arch/arm/mach-pxa/tosa.c                           |    2 +-
>  arch/arm/mach-pxa/trizeps4.c                       |    2 +-
>  arch/arm/mach-pxa/viper.c                          |    2 +-
>  arch/arm/mach-pxa/vpac270.c                        |    3 +--
>  arch/arm/mach-pxa/xcep.c                           |    3 +--
>  arch/arm/mach-pxa/z2.c                             |    3 +--
>  arch/arm/mach-pxa/zeus.c                           |    3 +--
>  arch/arm/mach-pxa/zylonite_pxa300.c                |    2 +-
>  drivers/i2c/busses/i2c-pxa.c                       |   16 ++--------------
>  .../plat/i2c.h => include/linux/i2c/pxa-i2c.h      |    1 +
>  38 files changed, 57 insertions(+), 58 deletions(-)
>  create mode 100644 arch/arm/include/asm/pxa_i2c.h
>  rename arch/arm/plat-pxa/include/plat/i2c.h => include/linux/i2c/pxa-i2c.h (99%)
> 
> diff --git a/arch/arm/include/asm/pxa_i2c.h b/arch/arm/include/asm/pxa_i2c.h
> new file mode 100644
> index 0000000..f6da8a1
> --- /dev/null
> +++ b/arch/arm/include/asm/pxa_i2c.h
> @@ -0,0 +1,19 @@
> +#ifndef __ASM_PXA_I2C_H__
> +#define __ASM_PXA_I2C_H__
> +
> +/*
> + * I2C registers definitions
> + */
> +#define IBMR		(0x00)
> +#define IDBR		(0x04)
> +#define ICR		(0x08)
> +#define ISR		(0x0c)
> +#define ISAR		(0x10)
> +
> +#define _IBMR(i2c)	((i2c)->reg_base + (IBMR << (i2c)->reg_shift))
> +#define _IDBR(i2c)	((i2c)->reg_base + (IDBR << (i2c)->reg_shift))
> +#define _ICR(i2c)	((i2c)->reg_base + (ICR << (i2c)->reg_shift))
> +#define _ISR(i2c)	((i2c)->reg_base + (ISR << (i2c)->reg_shift))
> +#define _ISAR(i2c)	((i2c)->reg_base + (ISAR << (i2c)->reg_shift))
> +
> +#endif
> diff --git a/arch/arm/mach-mmp/include/mach/mmp2.h b/arch/arm/mach-mmp/include/mach/mmp2.h
> index dbba6e8..95adfea 100644
> --- a/arch/arm/mach-mmp/include/mach/mmp2.h
> +++ b/arch/arm/mach-mmp/include/mach/mmp2.h
> @@ -9,8 +9,8 @@ extern void __init mmp2_init_irq(void);
>  extern void mmp2_clear_pmic_int(void);
>  
>  #include <linux/i2c.h>
> +#include <linux/i2c/pxa-i2c.h>
>  #include <mach/devices.h>
> -#include <plat/i2c.h>

Anyone an opinion on whther to alter all arch-arm machine includes
or add a re-direct of plat/i2c.h to linux/i2c/pxa-i2c.h


-- 
Ben

Q:      What's a light-year?
A:      One-third less calories than a regular year.

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [PATCH 2/7] arm/pxa2xx: reorganize I2C files
@ 2010-11-25 23:55         ` Ben Dooks
  0 siblings, 0 replies; 48+ messages in thread
From: Ben Dooks @ 2010-11-25 23:55 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Nov 24, 2010 at 10:20:12PM +0100, Sebastian Andrzej Siewior wrote:
> This patch moves the register definitions into include/asm so it can be
> accessed from X86 the same way as on ARM. This move also alters the
> unused register offset definitins (IBMR, ...) and uses them in the
> calculation macros (_IBMR,...).
> The header file from plat-pxa is moved the include/linux for the same
> reason.
> This change should make no functional change to the PXA code. The move
> is verified by building the following defconfigs:
>   cm_x2xx_defconfig corgi_defconfig em_x270_defconfig ezx_defconfig
>   imote2_defconfig pxa3xx_defconfig spitz_defconfig zeus_defconfig
>   raumfeld_defconfig magician_defconfig mmp2_defconfig pxa168_defconfig
>   pxa910_defconfig
> 
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Signed-off-by: Dirk Brandewie <dirk.brandewie@gmail.com>
> ---
>  arch/arm/include/asm/pxa_i2c.h                     |   19 +++++++++++++++++++
>  arch/arm/mach-mmp/include/mach/mmp2.h              |    2 +-
>  arch/arm/mach-mmp/include/mach/pxa168.h            |    2 +-
>  arch/arm/mach-mmp/include/mach/pxa910.h            |    2 +-
>  arch/arm/mach-pxa/balloon3.c                       |    3 +--
>  arch/arm/mach-pxa/cm-x300.c                        |    2 +-
>  arch/arm/mach-pxa/colibri-pxa270-income.c          |    3 +--
>  arch/arm/mach-pxa/corgi.c                          |    2 +-
>  arch/arm/mach-pxa/csb726.c                         |    2 +-
>  arch/arm/mach-pxa/devices.c                        |    2 +-
>  arch/arm/mach-pxa/em-x270.c                        |    2 +-
>  arch/arm/mach-pxa/ezx.c                            |    2 +-
>  arch/arm/mach-pxa/hx4700.c                         |    2 +-
>  arch/arm/mach-pxa/littleton.c                      |    2 +-
>  arch/arm/mach-pxa/magician.c                       |    2 +-
>  arch/arm/mach-pxa/mainstone.c                      |    2 +-
>  arch/arm/mach-pxa/mioa701.c                        |    2 +-
>  arch/arm/mach-pxa/mxm8x10.c                        |    2 +-
>  arch/arm/mach-pxa/palm27x.c                        |    3 +--
>  arch/arm/mach-pxa/pcm990-baseboard.c               |    2 +-
>  arch/arm/mach-pxa/poodle.c                         |    2 +-
>  arch/arm/mach-pxa/pxa27x.c                         |    2 +-
>  arch/arm/mach-pxa/pxa3xx.c                         |    2 +-
>  arch/arm/mach-pxa/raumfeld.c                       |    2 +-
>  arch/arm/mach-pxa/saar.c                           |    2 +-
>  arch/arm/mach-pxa/spitz.c                          |    3 +--
>  arch/arm/mach-pxa/stargate2.c                      |    2 +-
>  arch/arm/mach-pxa/tavorevb3.c                      |    3 +--
>  arch/arm/mach-pxa/tosa.c                           |    2 +-
>  arch/arm/mach-pxa/trizeps4.c                       |    2 +-
>  arch/arm/mach-pxa/viper.c                          |    2 +-
>  arch/arm/mach-pxa/vpac270.c                        |    3 +--
>  arch/arm/mach-pxa/xcep.c                           |    3 +--
>  arch/arm/mach-pxa/z2.c                             |    3 +--
>  arch/arm/mach-pxa/zeus.c                           |    3 +--
>  arch/arm/mach-pxa/zylonite_pxa300.c                |    2 +-
>  drivers/i2c/busses/i2c-pxa.c                       |   16 ++--------------
>  .../plat/i2c.h => include/linux/i2c/pxa-i2c.h      |    1 +
>  38 files changed, 57 insertions(+), 58 deletions(-)
>  create mode 100644 arch/arm/include/asm/pxa_i2c.h
>  rename arch/arm/plat-pxa/include/plat/i2c.h => include/linux/i2c/pxa-i2c.h (99%)
> 
> diff --git a/arch/arm/include/asm/pxa_i2c.h b/arch/arm/include/asm/pxa_i2c.h
> new file mode 100644
> index 0000000..f6da8a1
> --- /dev/null
> +++ b/arch/arm/include/asm/pxa_i2c.h
> @@ -0,0 +1,19 @@
> +#ifndef __ASM_PXA_I2C_H__
> +#define __ASM_PXA_I2C_H__
> +
> +/*
> + * I2C registers definitions
> + */
> +#define IBMR		(0x00)
> +#define IDBR		(0x04)
> +#define ICR		(0x08)
> +#define ISR		(0x0c)
> +#define ISAR		(0x10)
> +
> +#define _IBMR(i2c)	((i2c)->reg_base + (IBMR << (i2c)->reg_shift))
> +#define _IDBR(i2c)	((i2c)->reg_base + (IDBR << (i2c)->reg_shift))
> +#define _ICR(i2c)	((i2c)->reg_base + (ICR << (i2c)->reg_shift))
> +#define _ISR(i2c)	((i2c)->reg_base + (ISR << (i2c)->reg_shift))
> +#define _ISAR(i2c)	((i2c)->reg_base + (ISAR << (i2c)->reg_shift))
> +
> +#endif
> diff --git a/arch/arm/mach-mmp/include/mach/mmp2.h b/arch/arm/mach-mmp/include/mach/mmp2.h
> index dbba6e8..95adfea 100644
> --- a/arch/arm/mach-mmp/include/mach/mmp2.h
> +++ b/arch/arm/mach-mmp/include/mach/mmp2.h
> @@ -9,8 +9,8 @@ extern void __init mmp2_init_irq(void);
>  extern void mmp2_clear_pmic_int(void);
>  
>  #include <linux/i2c.h>
> +#include <linux/i2c/pxa-i2c.h>
>  #include <mach/devices.h>
> -#include <plat/i2c.h>

Anyone an opinion on whther to alter all arch-arm machine includes
or add a re-direct of plat/i2c.h to linux/i2c/pxa-i2c.h


-- 
Ben

Q:      What's a light-year?
A:      One-third less calories than a regular year.

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 3/7] i2c/pxa2xx: Add PCI support for PXA I2C controller
  2010-11-24 21:20     ` Sebastian Andrzej Siewior
@ 2010-11-25 23:59         ` Ben Dooks
  -1 siblings, 0 replies; 48+ messages in thread
From: Ben Dooks @ 2010-11-25 23:59 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	sodaville-hfZtesqFncYOwBW4kG4KsQ, tglx-hfZtesqFncYOwBW4kG4KsQ,
	eric.y.miao-Re5JQEeQqe8AvxtiuMwx3w, linux-lFZ/pmaqli7XmaaqVzeoHQ,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, Dirk Brandewie

On Wed, Nov 24, 2010 at 10:20:13PM +0100, Sebastian Andrzej Siewior wrote:
> The Sodaville I2C controller is almost the same as found on PXA2xx. The
> difference:
> - the register are at a different spot
> - no slave support
> 
> The PCI probe code adds three platform devices which are probed then by
> the platform code.
> The X86 part also adds dummy clock defines because we don't have HW
> clock support.
> 
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
> Signed-off-by: Dirk Brandewie <dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
>  arch/x86/include/asm/pxa_i2c.h   |   24 ++++++
>  drivers/i2c/busses/Kconfig       |    7 +-
>  drivers/i2c/busses/Makefile      |    1 +
>  drivers/i2c/busses/i2c-pxa-pci.c |  160 ++++++++++++++++++++++++++++++++++++++
>  4 files changed, 190 insertions(+), 2 deletions(-)
>  create mode 100644 arch/x86/include/asm/pxa_i2c.h
>  create mode 100644 drivers/i2c/busses/i2c-pxa-pci.c
> 
> diff --git a/arch/x86/include/asm/pxa_i2c.h b/arch/x86/include/asm/pxa_i2c.h
> new file mode 100644
> index 0000000..9f73b3de
> --- /dev/null
> +++ b/arch/x86/include/asm/pxa_i2c.h
> @@ -0,0 +1,24 @@
> +#ifndef __ASM_PXA_I2C_H__
> +#define __ASM_PXA_I2C_H__
> +
> +/*
> + * I2C registers definitions
> + */
> +#define IBMR            (0x14)
> +#define IDBR            (0x0c)
> +#define ICR             (0x00)
> +#define ISR             (0x04)
> +
> +#define _IBMR(i2c)	((i2c)->reg_base + IBMR)
> +#define _IDBR(i2c)	((i2c)->reg_base + IDBR)
> +#define _ICR(i2c)	((i2c)->reg_base + ICR)
> +#define _ISR(i2c)	((i2c)->reg_base + ISR)

couldn't these be in common code?

> +struct clk;
> +
> +#define clk_get(dev, id)	NULL
> +#define clk_put(clk)		do { } while (0)
> +#define clk_disable(clk)	do { } while (0)
> +#define clk_enable(clk)		do { } while (0)
> +
> +#endif
> diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
> index 3a6321c..76b5f15 100644
> --- a/drivers/i2c/busses/Kconfig
> +++ b/drivers/i2c/busses/Kconfig
> @@ -525,15 +525,18 @@ config I2C_PNX
>  
>  config I2C_PXA
>  	tristate "Intel PXA2XX I2C adapter"
> -	depends on ARCH_PXA || ARCH_MMP
> +	depends on ARCH_PXA || ARCH_MMP || (X86 && PCI)
>  	help
>  	  If you have devices in the PXA I2C bus, say yes to this option.
>  	  This driver can also be built as a module.  If so, the module
>  	  will be called i2c-pxa.
>  
> +config I2C_PXA_PCI
> +	def_bool I2C_PXA && X86 && PCI
> +
>  config I2C_PXA_SLAVE
>  	bool "Intel PXA2XX I2C Slave comms support"
> -	depends on I2C_PXA
> +	depends on I2C_PXA && !X86
>  	help
>  	  Support I2C slave mode communications on the PXA I2C bus.  This
>  	  is necessary for systems where the PXA may be a target on the
> diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
> index 84cb16a..78db2e3 100644
> --- a/drivers/i2c/busses/Makefile
> +++ b/drivers/i2c/busses/Makefile
> @@ -52,6 +52,7 @@ obj-$(CONFIG_I2C_PCA_PLATFORM)	+= i2c-pca-platform.o
>  obj-$(CONFIG_I2C_PMCMSP)	+= i2c-pmcmsp.o
>  obj-$(CONFIG_I2C_PNX)		+= i2c-pnx.o
>  obj-$(CONFIG_I2C_PXA)		+= i2c-pxa.o
> +obj-$(CONFIG_I2C_PXA_PCI)	+= i2c-pxa-pci.o
>  obj-$(CONFIG_I2C_S3C2410)	+= i2c-s3c2410.o
>  obj-$(CONFIG_I2C_S6000)		+= i2c-s6000.o
>  obj-$(CONFIG_I2C_SH7760)	+= i2c-sh7760.o
> diff --git a/drivers/i2c/busses/i2c-pxa-pci.c b/drivers/i2c/busses/i2c-pxa-pci.c
> new file mode 100644
> index 0000000..9ab7a36
> --- /dev/null
> +++ b/drivers/i2c/busses/i2c-pxa-pci.c
> @@ -0,0 +1,160 @@
> +/*
> + * The CE4100's I2C device is more or less the same one as found on PXA.
> + * It does not support slave mode, the register slightly moved. This PCI
> + * device provides three bars, every contains a single I2C controller.
> + */
> +#include <linux/pci.h>
> +#include <linux/platform_device.h>
> +#include <linux/i2c/pxa-i2c.h>
> +#include <linux/of.h>
> +#include <linux/of_device.h>
> +
> +#define CE4100_PCI_I2C_DEVS	3
> +
> +struct ce4100_i2c_device {
> +	struct platform_device pdev;
> +	struct resource res[2];
> +	struct i2c_pxa_platform_data pdata;
> +};
> +
> +struct ce4100_devices {
> +	struct ce4100_i2c_device sd[CE4100_PCI_I2C_DEVS];
> +};
> +
> +static void plat_dev_release(struct device *dev)
> +{
> +	struct ce4100_i2c_device *sd = container_of(dev,
> +			struct ce4100_i2c_device, pdev.dev);
> +
> +	of_device_node_put(&sd->pdev.dev);
> +}
> +
> +static int add_i2c_device(struct pci_dev *dev, int bar,
> +		struct ce4100_i2c_device *sd)
> +{
> +	struct platform_device *pdev = &sd->pdev;
> +	struct i2c_pxa_platform_data *pdata = &sd->pdata;
> +
> +	pdev->name = "pxa2xx-i2c";
> +	pdev->dev.release = plat_dev_release;
> +	/*
> +	 * We assume one PCI bus here. devfn uses the lower 8 bits. To remain
> +	 * unique we encode the also bar
> +	 */
> +	pdev->id = dev->devfn << 3 | bar;
> +	pdev->dev.parent = &dev->dev;
> +#ifdef CONFIG_OF
> +	if (dev->dev.of_node) {
> +		struct device_node *child;
> +
> +		for_each_child_of_node(dev->dev.of_node, child) {
> +			const void *prop;
> +			u32 child_reg;
> +
> +			prop = of_get_property(child, "reg", NULL);
> +			if (!prop)
> +				continue;
> +			child_reg = be32_to_cpup(prop);
> +			if (child_reg == bar) {
> +				pdev->dev.of_node = child;
> +				break;
> +			}
> +		}
> +	}
> +#endif
> +	pdev->dev.platform_data = pdata;
> +	pdev->resource = sd->res;
> +
> +	sd->res[0].flags = IORESOURCE_MEM;
> +	sd->res[0].start = pci_resource_start(dev, bar);
> +	sd->res[0].end = pci_resource_end(dev, bar);
> +
> +	sd->res[1].flags = IORESOURCE_IRQ;
> +	sd->res[1].start = dev->irq;
> +	sd->res[1].end = dev->irq;
> +
> +	pdev->num_resources = 2;
> +
> +	return platform_device_register(pdev);
> +}
> +
> +static int __devinit ce4100_i2c_probe(struct pci_dev *dev,
> +		const struct pci_device_id *ent)
> +{
> +	int ret;
> +	int i;
> +	struct ce4100_devices *sds;
> +
> +	sds = kzalloc(sizeof(*sds), GFP_KERNEL);
> +	if (!sds)
> +		return -ENOMEM;
> +
> +	ret = pci_enable_device_mem(dev);
> +	if (ret)
> +		goto en_dev;
> +
> +	pci_set_drvdata(dev, sds);
> +
> +	for (i = 0; i < CE4100_PCI_I2C_DEVS; i++) {
> +		ret = add_i2c_device(dev, i, &sds->sd[i]);
> +		if (ret) {
> +			while (--i >= 0)
> +				platform_device_unregister(&sds->sd[i].pdev);
> +
> +			goto err_dev_add;
> +		}
> +	}
> +
> +	return 0;
> +
> +err_dev_add:
> +	pci_set_drvdata(dev, NULL);
> +	pci_disable_device(dev);
> +en_dev:
> +	kfree(sds);
> +	return ret;
> +}
> +
> +static void __devexit ce4100_i2c_remove(struct pci_dev *dev)
> +{
> +	struct ce4100_devices *sds;
> +	unsigned int i;
> +
> +	sds = pci_get_drvdata(dev);
> +	pci_set_drvdata(dev, NULL);
> +
> +	for (i = 0; i < CE4100_PCI_I2C_DEVS; i++)
how about using ARRAY_SIZE of sds->sd[i] ?

> +		platform_device_unregister(&sds->sd[i].pdev);
> +
> +	pci_disable_device(dev);
> +	kfree(sds);
> +}
> +
> +static struct pci_device_id ce4100_i2c_devices[] __devinitdata = {
> +	{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x2e68)},
> +	{ },
> +};
> +MODULE_DEVICE_TABLE(pci, ce4100_i2c_devices);
> +
> +static struct pci_driver ce4100_i2c_driver = {
> +	.name           = "ce4100_i2c",
> +	.id_table       = ce4100_i2c_devices,
> +	.probe          = ce4100_i2c_probe,
> +	.remove         = __devexit_p(ce4100_i2c_remove),
> +};
> +
> +static int __init ce4100_i2c_init(void)
> +{
> +	return pci_register_driver(&ce4100_i2c_driver);
> +}
> +module_init(ce4100_i2c_init);
> +
> +static void __exit ce4100_i2c_exit(void)
> +{
> +	pci_unregister_driver(&ce4100_i2c_driver);
> +}
> +module_exit(ce4100_i2c_exit);
> +
> +MODULE_DESCRIPTION("CE4100 PCI-I2C glue code for PXA's driver");
> +MODULE_LICENSE("GPL v2");
> +MODULE_AUTHOR("Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>");
> -- 
> 1.7.3.2
> 
> --
> 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

-- 
-- 
Ben

Q:      What's a light-year?
A:      One-third less calories than a regular year.

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [PATCH 3/7] i2c/pxa2xx: Add PCI support for PXA I2C controller
@ 2010-11-25 23:59         ` Ben Dooks
  0 siblings, 0 replies; 48+ messages in thread
From: Ben Dooks @ 2010-11-25 23:59 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Nov 24, 2010 at 10:20:13PM +0100, Sebastian Andrzej Siewior wrote:
> The Sodaville I2C controller is almost the same as found on PXA2xx. The
> difference:
> - the register are at a different spot
> - no slave support
> 
> The PCI probe code adds three platform devices which are probed then by
> the platform code.
> The X86 part also adds dummy clock defines because we don't have HW
> clock support.
> 
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Signed-off-by: Dirk Brandewie <dirk.brandewie@gmail.com>
> ---
>  arch/x86/include/asm/pxa_i2c.h   |   24 ++++++
>  drivers/i2c/busses/Kconfig       |    7 +-
>  drivers/i2c/busses/Makefile      |    1 +
>  drivers/i2c/busses/i2c-pxa-pci.c |  160 ++++++++++++++++++++++++++++++++++++++
>  4 files changed, 190 insertions(+), 2 deletions(-)
>  create mode 100644 arch/x86/include/asm/pxa_i2c.h
>  create mode 100644 drivers/i2c/busses/i2c-pxa-pci.c
> 
> diff --git a/arch/x86/include/asm/pxa_i2c.h b/arch/x86/include/asm/pxa_i2c.h
> new file mode 100644
> index 0000000..9f73b3de
> --- /dev/null
> +++ b/arch/x86/include/asm/pxa_i2c.h
> @@ -0,0 +1,24 @@
> +#ifndef __ASM_PXA_I2C_H__
> +#define __ASM_PXA_I2C_H__
> +
> +/*
> + * I2C registers definitions
> + */
> +#define IBMR            (0x14)
> +#define IDBR            (0x0c)
> +#define ICR             (0x00)
> +#define ISR             (0x04)
> +
> +#define _IBMR(i2c)	((i2c)->reg_base + IBMR)
> +#define _IDBR(i2c)	((i2c)->reg_base + IDBR)
> +#define _ICR(i2c)	((i2c)->reg_base + ICR)
> +#define _ISR(i2c)	((i2c)->reg_base + ISR)

couldn't these be in common code?

> +struct clk;
> +
> +#define clk_get(dev, id)	NULL
> +#define clk_put(clk)		do { } while (0)
> +#define clk_disable(clk)	do { } while (0)
> +#define clk_enable(clk)		do { } while (0)
> +
> +#endif
> diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
> index 3a6321c..76b5f15 100644
> --- a/drivers/i2c/busses/Kconfig
> +++ b/drivers/i2c/busses/Kconfig
> @@ -525,15 +525,18 @@ config I2C_PNX
>  
>  config I2C_PXA
>  	tristate "Intel PXA2XX I2C adapter"
> -	depends on ARCH_PXA || ARCH_MMP
> +	depends on ARCH_PXA || ARCH_MMP || (X86 && PCI)
>  	help
>  	  If you have devices in the PXA I2C bus, say yes to this option.
>  	  This driver can also be built as a module.  If so, the module
>  	  will be called i2c-pxa.
>  
> +config I2C_PXA_PCI
> +	def_bool I2C_PXA && X86 && PCI
> +
>  config I2C_PXA_SLAVE
>  	bool "Intel PXA2XX I2C Slave comms support"
> -	depends on I2C_PXA
> +	depends on I2C_PXA && !X86
>  	help
>  	  Support I2C slave mode communications on the PXA I2C bus.  This
>  	  is necessary for systems where the PXA may be a target on the
> diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
> index 84cb16a..78db2e3 100644
> --- a/drivers/i2c/busses/Makefile
> +++ b/drivers/i2c/busses/Makefile
> @@ -52,6 +52,7 @@ obj-$(CONFIG_I2C_PCA_PLATFORM)	+= i2c-pca-platform.o
>  obj-$(CONFIG_I2C_PMCMSP)	+= i2c-pmcmsp.o
>  obj-$(CONFIG_I2C_PNX)		+= i2c-pnx.o
>  obj-$(CONFIG_I2C_PXA)		+= i2c-pxa.o
> +obj-$(CONFIG_I2C_PXA_PCI)	+= i2c-pxa-pci.o
>  obj-$(CONFIG_I2C_S3C2410)	+= i2c-s3c2410.o
>  obj-$(CONFIG_I2C_S6000)		+= i2c-s6000.o
>  obj-$(CONFIG_I2C_SH7760)	+= i2c-sh7760.o
> diff --git a/drivers/i2c/busses/i2c-pxa-pci.c b/drivers/i2c/busses/i2c-pxa-pci.c
> new file mode 100644
> index 0000000..9ab7a36
> --- /dev/null
> +++ b/drivers/i2c/busses/i2c-pxa-pci.c
> @@ -0,0 +1,160 @@
> +/*
> + * The CE4100's I2C device is more or less the same one as found on PXA.
> + * It does not support slave mode, the register slightly moved. This PCI
> + * device provides three bars, every contains a single I2C controller.
> + */
> +#include <linux/pci.h>
> +#include <linux/platform_device.h>
> +#include <linux/i2c/pxa-i2c.h>
> +#include <linux/of.h>
> +#include <linux/of_device.h>
> +
> +#define CE4100_PCI_I2C_DEVS	3
> +
> +struct ce4100_i2c_device {
> +	struct platform_device pdev;
> +	struct resource res[2];
> +	struct i2c_pxa_platform_data pdata;
> +};
> +
> +struct ce4100_devices {
> +	struct ce4100_i2c_device sd[CE4100_PCI_I2C_DEVS];
> +};
> +
> +static void plat_dev_release(struct device *dev)
> +{
> +	struct ce4100_i2c_device *sd = container_of(dev,
> +			struct ce4100_i2c_device, pdev.dev);
> +
> +	of_device_node_put(&sd->pdev.dev);
> +}
> +
> +static int add_i2c_device(struct pci_dev *dev, int bar,
> +		struct ce4100_i2c_device *sd)
> +{
> +	struct platform_device *pdev = &sd->pdev;
> +	struct i2c_pxa_platform_data *pdata = &sd->pdata;
> +
> +	pdev->name = "pxa2xx-i2c";
> +	pdev->dev.release = plat_dev_release;
> +	/*
> +	 * We assume one PCI bus here. devfn uses the lower 8 bits. To remain
> +	 * unique we encode the also bar
> +	 */
> +	pdev->id = dev->devfn << 3 | bar;
> +	pdev->dev.parent = &dev->dev;
> +#ifdef CONFIG_OF
> +	if (dev->dev.of_node) {
> +		struct device_node *child;
> +
> +		for_each_child_of_node(dev->dev.of_node, child) {
> +			const void *prop;
> +			u32 child_reg;
> +
> +			prop = of_get_property(child, "reg", NULL);
> +			if (!prop)
> +				continue;
> +			child_reg = be32_to_cpup(prop);
> +			if (child_reg == bar) {
> +				pdev->dev.of_node = child;
> +				break;
> +			}
> +		}
> +	}
> +#endif
> +	pdev->dev.platform_data = pdata;
> +	pdev->resource = sd->res;
> +
> +	sd->res[0].flags = IORESOURCE_MEM;
> +	sd->res[0].start = pci_resource_start(dev, bar);
> +	sd->res[0].end = pci_resource_end(dev, bar);
> +
> +	sd->res[1].flags = IORESOURCE_IRQ;
> +	sd->res[1].start = dev->irq;
> +	sd->res[1].end = dev->irq;
> +
> +	pdev->num_resources = 2;
> +
> +	return platform_device_register(pdev);
> +}
> +
> +static int __devinit ce4100_i2c_probe(struct pci_dev *dev,
> +		const struct pci_device_id *ent)
> +{
> +	int ret;
> +	int i;
> +	struct ce4100_devices *sds;
> +
> +	sds = kzalloc(sizeof(*sds), GFP_KERNEL);
> +	if (!sds)
> +		return -ENOMEM;
> +
> +	ret = pci_enable_device_mem(dev);
> +	if (ret)
> +		goto en_dev;
> +
> +	pci_set_drvdata(dev, sds);
> +
> +	for (i = 0; i < CE4100_PCI_I2C_DEVS; i++) {
> +		ret = add_i2c_device(dev, i, &sds->sd[i]);
> +		if (ret) {
> +			while (--i >= 0)
> +				platform_device_unregister(&sds->sd[i].pdev);
> +
> +			goto err_dev_add;
> +		}
> +	}
> +
> +	return 0;
> +
> +err_dev_add:
> +	pci_set_drvdata(dev, NULL);
> +	pci_disable_device(dev);
> +en_dev:
> +	kfree(sds);
> +	return ret;
> +}
> +
> +static void __devexit ce4100_i2c_remove(struct pci_dev *dev)
> +{
> +	struct ce4100_devices *sds;
> +	unsigned int i;
> +
> +	sds = pci_get_drvdata(dev);
> +	pci_set_drvdata(dev, NULL);
> +
> +	for (i = 0; i < CE4100_PCI_I2C_DEVS; i++)
how about using ARRAY_SIZE of sds->sd[i] ?

> +		platform_device_unregister(&sds->sd[i].pdev);
> +
> +	pci_disable_device(dev);
> +	kfree(sds);
> +}
> +
> +static struct pci_device_id ce4100_i2c_devices[] __devinitdata = {
> +	{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x2e68)},
> +	{ },
> +};
> +MODULE_DEVICE_TABLE(pci, ce4100_i2c_devices);
> +
> +static struct pci_driver ce4100_i2c_driver = {
> +	.name           = "ce4100_i2c",
> +	.id_table       = ce4100_i2c_devices,
> +	.probe          = ce4100_i2c_probe,
> +	.remove         = __devexit_p(ce4100_i2c_remove),
> +};
> +
> +static int __init ce4100_i2c_init(void)
> +{
> +	return pci_register_driver(&ce4100_i2c_driver);
> +}
> +module_init(ce4100_i2c_init);
> +
> +static void __exit ce4100_i2c_exit(void)
> +{
> +	pci_unregister_driver(&ce4100_i2c_driver);
> +}
> +module_exit(ce4100_i2c_exit);
> +
> +MODULE_DESCRIPTION("CE4100 PCI-I2C glue code for PXA's driver");
> +MODULE_LICENSE("GPL v2");
> +MODULE_AUTHOR("Sebastian Andrzej Siewior <bigeasy@linutronix.de>");
> -- 
> 1.7.3.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
-- 
Ben

Q:      What's a light-year?
A:      One-third less calories than a regular year.

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 2/7] arm/pxa2xx: reorganize I2C files
  2010-11-25 23:55         ` Ben Dooks
@ 2010-11-26  0:03             ` Russell King - ARM Linux
  -1 siblings, 0 replies; 48+ messages in thread
From: Russell King - ARM Linux @ 2010-11-26  0:03 UTC (permalink / raw)
  To: Ben Dooks
  Cc: Sebastian Andrzej Siewior, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	sodaville-hfZtesqFncYOwBW4kG4KsQ, tglx-hfZtesqFncYOwBW4kG4KsQ,
	eric.y.miao-Re5JQEeQqe8AvxtiuMwx3w,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, Dirk Brandewie

On Thu, Nov 25, 2010 at 11:55:20PM +0000, Ben Dooks wrote:
> > diff --git a/arch/arm/include/asm/pxa_i2c.h b/arch/arm/include/asm/pxa_i2c.h
> > new file mode 100644
> > index 0000000..f6da8a1
> > --- /dev/null
> > +++ b/arch/arm/include/asm/pxa_i2c.h
>
> Anyone an opinion on whther to alter all arch-arm machine includes
> or add a re-direct of plat/i2c.h to linux/i2c/pxa-i2c.h

We're not going to litter arch/arm/include/asm with SoC specific includes.
If we start doing this, we'll end up with thousands of files in
arch/arm/include/asm which have no real business being there.

So there's not much option but to NAK this patch before it gets out of
hand.

The reason for this change seems to be because x86 has a different register
layout, and x86 doesn't have the clk API.  For the former, that can be
dealt with an ifdef along side the register definitions.

For the latter, why not just implement a simple clk API implementation
which always returns success, rather than requiring special headers
for various ARM drivers?

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [PATCH 2/7] arm/pxa2xx: reorganize I2C files
@ 2010-11-26  0:03             ` Russell King - ARM Linux
  0 siblings, 0 replies; 48+ messages in thread
From: Russell King - ARM Linux @ 2010-11-26  0:03 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Nov 25, 2010 at 11:55:20PM +0000, Ben Dooks wrote:
> > diff --git a/arch/arm/include/asm/pxa_i2c.h b/arch/arm/include/asm/pxa_i2c.h
> > new file mode 100644
> > index 0000000..f6da8a1
> > --- /dev/null
> > +++ b/arch/arm/include/asm/pxa_i2c.h
>
> Anyone an opinion on whther to alter all arch-arm machine includes
> or add a re-direct of plat/i2c.h to linux/i2c/pxa-i2c.h

We're not going to litter arch/arm/include/asm with SoC specific includes.
If we start doing this, we'll end up with thousands of files in
arch/arm/include/asm which have no real business being there.

So there's not much option but to NAK this patch before it gets out of
hand.

The reason for this change seems to be because x86 has a different register
layout, and x86 doesn't have the clk API.  For the former, that can be
dealt with an ifdef along side the register definitions.

For the latter, why not just implement a simple clk API implementation
which always returns success, rather than requiring special headers
for various ARM drivers?

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 2/7] arm/pxa2xx: reorganize I2C files
  2010-11-26  0:03             ` Russell King - ARM Linux
@ 2010-11-26 14:11                 ` Sebastian Andrzej Siewior
  -1 siblings, 0 replies; 48+ messages in thread
From: Sebastian Andrzej Siewior @ 2010-11-26 14:11 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: Ben Dooks, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	sodaville-hfZtesqFncYOwBW4kG4KsQ, tglx-hfZtesqFncYOwBW4kG4KsQ,
	eric.y.miao-Re5JQEeQqe8AvxtiuMwx3w,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, Dirk Brandewie

Russell King - ARM Linux wrote:
> On Thu, Nov 25, 2010 at 11:55:20PM +0000, Ben Dooks wrote:
>>> diff --git a/arch/arm/include/asm/pxa_i2c.h b/arch/arm/include/asm/pxa_i2c.h
>>> new file mode 100644
>>> index 0000000..f6da8a1
>>> --- /dev/null
>>> +++ b/arch/arm/include/asm/pxa_i2c.h
>> Anyone an opinion on whther to alter all arch-arm machine includes
>> or add a re-direct of plat/i2c.h to linux/i2c/pxa-i2c.h
> 
> We're not going to litter arch/arm/include/asm with SoC specific includes.
> If we start doing this, we'll end up with thousands of files in
> arch/arm/include/asm which have no real business being there.
> 
> So there's not much option but to NAK this patch before it gets out of
> hand.
> 
> The reason for this change seems to be because x86 has a different register
> layout, and x86 doesn't have the clk API. 

And I need to access structs / defines which are defined in arch/arm.

> For the former, that can be
> dealt with an ifdef along side the register definitions.
Sure. The register definition was moved outside the driver into
arch/../include/asm. So I keep them within the driver and ifdef it.

> For the latter, why not just implement a simple clk API implementation
> which always returns success, rather than requiring special headers
> for various ARM drivers?
This has been done. Patch 3/7 creates arch/x86/include/asm/pxa_i2c.h
which defines clk_get(). So it does not require special header files in 
regard to the clk api.

So I'm eliminating arch/./arm/inclide/asm/ files which I introduced.

Sebastian

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [PATCH 2/7] arm/pxa2xx: reorganize I2C files
@ 2010-11-26 14:11                 ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 48+ messages in thread
From: Sebastian Andrzej Siewior @ 2010-11-26 14:11 UTC (permalink / raw)
  To: linux-arm-kernel

Russell King - ARM Linux wrote:
> On Thu, Nov 25, 2010 at 11:55:20PM +0000, Ben Dooks wrote:
>>> diff --git a/arch/arm/include/asm/pxa_i2c.h b/arch/arm/include/asm/pxa_i2c.h
>>> new file mode 100644
>>> index 0000000..f6da8a1
>>> --- /dev/null
>>> +++ b/arch/arm/include/asm/pxa_i2c.h
>> Anyone an opinion on whther to alter all arch-arm machine includes
>> or add a re-direct of plat/i2c.h to linux/i2c/pxa-i2c.h
> 
> We're not going to litter arch/arm/include/asm with SoC specific includes.
> If we start doing this, we'll end up with thousands of files in
> arch/arm/include/asm which have no real business being there.
> 
> So there's not much option but to NAK this patch before it gets out of
> hand.
> 
> The reason for this change seems to be because x86 has a different register
> layout, and x86 doesn't have the clk API. 

And I need to access structs / defines which are defined in arch/arm.

> For the former, that can be
> dealt with an ifdef along side the register definitions.
Sure. The register definition was moved outside the driver into
arch/../include/asm. So I keep them within the driver and ifdef it.

> For the latter, why not just implement a simple clk API implementation
> which always returns success, rather than requiring special headers
> for various ARM drivers?
This has been done. Patch 3/7 creates arch/x86/include/asm/pxa_i2c.h
which defines clk_get(). So it does not require special header files in 
regard to the clk api.

So I'm eliminating arch/./arm/inclide/asm/ files which I introduced.

Sebastian

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH 3/7] i2c/pxa2xx: Add PCI support for PXA I2C controller
  2010-11-25 23:59         ` Ben Dooks
@ 2010-11-26 14:16             ` Sebastian Andrzej Siewior
  -1 siblings, 0 replies; 48+ messages in thread
From: Sebastian Andrzej Siewior @ 2010-11-26 14:16 UTC (permalink / raw)
  To: Ben Dooks
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	sodaville-hfZtesqFncYOwBW4kG4KsQ, tglx-hfZtesqFncYOwBW4kG4KsQ,
	eric.y.miao-Re5JQEeQqe8AvxtiuMwx3w, linux-lFZ/pmaqli7XmaaqVzeoHQ,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, Dirk Brandewie

Ben Dooks wrote:
>> +#define IBMR            (0x14)
>> +#define IDBR            (0x0c)
>> +#define ICR             (0x00)
>> +#define ISR             (0x04)
>> +
>> +#define _IBMR(i2c)	((i2c)->reg_base + IBMR)
>> +#define _IDBR(i2c)	((i2c)->reg_base + IDBR)
>> +#define _ICR(i2c)	((i2c)->reg_base + ICR)
>> +#define _ISR(i2c)	((i2c)->reg_base + ISR)
> 
> couldn't these be in common code?

Yes. I'm going to move these back into the driver and ifdef x86 & arm
specific.

>> --- /dev/null
>> +++ b/drivers/i2c/busses/i2c-pxa-pci.c
>> +static void __devexit ce4100_i2c_remove(struct pci_dev *dev)
>> +{
>> +	struct ce4100_devices *sds;
>> +	unsigned int i;
>> +
>> +	sds = pci_get_drvdata(dev);
>> +	pci_set_drvdata(dev, NULL);
>> +
>> +	for (i = 0; i < CE4100_PCI_I2C_DEVS; i++)
> how about using ARRAY_SIZE of sds->sd[i] ?

I'm still thinking whether to use this or pci_select_bars() as Florian
suggested.

Sebastian

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [PATCH 3/7] i2c/pxa2xx: Add PCI support for PXA I2C controller
@ 2010-11-26 14:16             ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 48+ messages in thread
From: Sebastian Andrzej Siewior @ 2010-11-26 14:16 UTC (permalink / raw)
  To: linux-arm-kernel

Ben Dooks wrote:
>> +#define IBMR            (0x14)
>> +#define IDBR            (0x0c)
>> +#define ICR             (0x00)
>> +#define ISR             (0x04)
>> +
>> +#define _IBMR(i2c)	((i2c)->reg_base + IBMR)
>> +#define _IDBR(i2c)	((i2c)->reg_base + IDBR)
>> +#define _ICR(i2c)	((i2c)->reg_base + ICR)
>> +#define _ISR(i2c)	((i2c)->reg_base + ISR)
> 
> couldn't these be in common code?

Yes. I'm going to move these back into the driver and ifdef x86 & arm
specific.

>> --- /dev/null
>> +++ b/drivers/i2c/busses/i2c-pxa-pci.c
>> +static void __devexit ce4100_i2c_remove(struct pci_dev *dev)
>> +{
>> +	struct ce4100_devices *sds;
>> +	unsigned int i;
>> +
>> +	sds = pci_get_drvdata(dev);
>> +	pci_set_drvdata(dev, NULL);
>> +
>> +	for (i = 0; i < CE4100_PCI_I2C_DEVS; i++)
> how about using ARRAY_SIZE of sds->sd[i] ?

I'm still thinking whether to use this or pci_select_bars() as Florian
suggested.

Sebastian

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [sodaville] [PATCH 1/7] i2c/pxa2xx: Don't touch ISAR if not in slave mode
  2010-11-25 23:52         ` Ben Dooks
@ 2010-11-26 18:28             ` Sebastian Andrzej Siewior
  -1 siblings, 0 replies; 48+ messages in thread
From: Sebastian Andrzej Siewior @ 2010-11-26 18:28 UTC (permalink / raw)
  To: Ben Dooks
  Cc: eric.y.miao-Re5JQEeQqe8AvxtiuMwx3w,
	sodaville-hfZtesqFncYOwBW4kG4KsQ,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	ben-linux-elnMNo+KYs3YtjvyW6yDsg, linux-lFZ/pmaqli7XmaaqVzeoHQ,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

Ben Dooks wrote:
>> +#ifdef CONFIG_I2C_PXA_SLAVE
>>  	writel(i2c->slave_addr, _ISAR(i2c));
>> +#endif
> 
> I was thinking about whether to add a flag to this to say whether the
> slave_addr field is valid, but to keep full compatiblity with the existing
> pxa users, we'd have to go and change every board using it.

i2c->slave_addr is 1 if slave mode is not enabled. Why should this value
be used in master mode?

Sebastian

^ permalink raw reply	[flat|nested] 48+ messages in thread

* [sodaville] [PATCH 1/7] i2c/pxa2xx: Don't touch ISAR if not in slave mode
@ 2010-11-26 18:28             ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 48+ messages in thread
From: Sebastian Andrzej Siewior @ 2010-11-26 18:28 UTC (permalink / raw)
  To: linux-arm-kernel

Ben Dooks wrote:
>> +#ifdef CONFIG_I2C_PXA_SLAVE
>>  	writel(i2c->slave_addr, _ISAR(i2c));
>> +#endif
> 
> I was thinking about whether to add a flag to this to say whether the
> slave_addr field is valid, but to keep full compatiblity with the existing
> pxa users, we'd have to go and change every board using it.

i2c->slave_addr is 1 if slave mode is not enabled. Why should this value
be used in master mode?

Sebastian

^ permalink raw reply	[flat|nested] 48+ messages in thread

end of thread, other threads:[~2010-11-26 18:28 UTC | newest]

Thread overview: 48+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-24 21:20 I2C support for Sodaville Sebastian Andrzej Siewior
2010-11-24 21:20 ` Sebastian Andrzej Siewior
     [not found] ` <1290633617-15311-1-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2010-11-24 21:20   ` [PATCH 1/7] i2c/pxa2xx: Don't touch ISAR if not in slave mode Sebastian Andrzej Siewior
2010-11-24 21:20     ` Sebastian Andrzej Siewior
     [not found]     ` <1290633617-15311-2-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2010-11-25 23:52       ` Ben Dooks
2010-11-25 23:52         ` Ben Dooks
     [not found]         ` <20101125235255.GB15948-SMNkleLxa3Z6Wcw2j4pizdi2O/JbrIOy@public.gmane.org>
2010-11-26 18:28           ` [sodaville] " Sebastian Andrzej Siewior
2010-11-26 18:28             ` Sebastian Andrzej Siewior
2010-11-24 21:20   ` [PATCH 2/7] arm/pxa2xx: reorganize I2C files Sebastian Andrzej Siewior
2010-11-24 21:20     ` Sebastian Andrzej Siewior
     [not found]     ` <1290633617-15311-3-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2010-11-25 23:55       ` Ben Dooks
2010-11-25 23:55         ` Ben Dooks
     [not found]         ` <20101125235520.GC15948-SMNkleLxa3Z6Wcw2j4pizdi2O/JbrIOy@public.gmane.org>
2010-11-26  0:03           ` Russell King - ARM Linux
2010-11-26  0:03             ` Russell King - ARM Linux
     [not found]             ` <20101126000341.GB9310-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org>
2010-11-26 14:11               ` Sebastian Andrzej Siewior
2010-11-26 14:11                 ` Sebastian Andrzej Siewior
2010-11-24 21:20   ` [PATCH 3/7] i2c/pxa2xx: Add PCI support for PXA I2C controller Sebastian Andrzej Siewior
2010-11-24 21:20     ` Sebastian Andrzej Siewior
     [not found]     ` <1290633617-15311-4-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2010-11-25 23:59       ` Ben Dooks
2010-11-25 23:59         ` Ben Dooks
     [not found]         ` <20101125235933.GD15948-SMNkleLxa3Z6Wcw2j4pizdi2O/JbrIOy@public.gmane.org>
2010-11-26 14:16           ` Sebastian Andrzej Siewior
2010-11-26 14:16             ` Sebastian Andrzej Siewior
2010-11-24 21:20   ` [PATCH 4/7] i2c/pxa2xx: add support for shared IRQ handler Sebastian Andrzej Siewior
2010-11-24 21:20     ` Sebastian Andrzej Siewior
     [not found]     ` <1290633617-15311-5-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2010-11-25  2:26       ` Haojian Zhuang
2010-11-25  2:26         ` Haojian Zhuang
2010-11-25 10:48         ` Sebastian Andrzej Siewior
2010-11-25 10:48           ` Sebastian Andrzej Siewior
2010-11-24 21:20   ` [PATCH 5/7] i2c/pxa2xx: check timeout correctly Sebastian Andrzej Siewior
2010-11-24 21:20     ` Sebastian Andrzej Siewior
2010-11-24 21:20   ` [PATCH 6/7] i2c/pxa2xx: reset the chip if the bus is not free Sebastian Andrzej Siewior
2010-11-24 21:20     ` Sebastian Andrzej Siewior
     [not found]     ` <1290633617-15311-7-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2010-11-25  2:30       ` Haojian Zhuang
2010-11-25  2:30         ` Haojian Zhuang
     [not found]         ` <AANLkTikvN+==eTkoh7CTQyN0mbfvPhH6Uh9NX5QW7WFx-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-11-25  2:49           ` Haojian Zhuang
2010-11-25  2:49             ` Haojian Zhuang
     [not found]             ` <AANLkTi=8Xy3M7QGO54nt_r0_12z3+o8G5fAqQmxkTH4o-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-11-25  6:43               ` Igor Grinberg
2010-11-25  6:43                 ` Igor Grinberg
     [not found]                 ` <4CEE05A4.6030201-UTxiZqZC01RS1MOuV/RT9w@public.gmane.org>
2010-11-25  7:04                   ` Haojian Zhuang
2010-11-25  7:04                     ` Haojian Zhuang
2010-11-25 12:24                   ` Sebastian Andrzej Siewior
2010-11-25 12:24                     ` Sebastian Andrzej Siewior
     [not found]                     ` <4CEE5587.90109-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2010-11-25 13:10                       ` Igor Grinberg
2010-11-25 13:10                         ` Igor Grinberg
     [not found]                         ` <4CEE602D.5090501-UTxiZqZC01RS1MOuV/RT9w@public.gmane.org>
2010-11-25 13:39                           ` Sebastian Andrzej Siewior
2010-11-25 13:39                             ` Sebastian Andrzej Siewior
2010-11-24 21:20   ` [PATCH 7/7] i2c/pxa2xx: pass of_node from platform driver to adapter Sebastian Andrzej Siewior
2010-11-24 21:20     ` Sebastian Andrzej Siewior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.