>From 5b6da7b5189c4c2f8c83a3a3c9472ff9c7d5fa77 Mon Sep 17 00:00:00 2001
From: Marcus Meissner <meissner@suse.de>
Date: Thu, 26 Jul 2012 15:16:28 +0200
Subject: [PATCH] added i2c-coredesign patch

---
 patches.fixes/i2c-coredesign |  196 ++++++++++++++++++++++++++++++++++++++++++
 series.conf                  |    2 +
 2 files changed, 198 insertions(+)
 create mode 100644 patches.fixes/i2c-coredesign

diff --git a/patches.fixes/i2c-coredesign b/patches.fixes/i2c-coredesign
new file mode 100644
index 0000000..b6c0c1e
--- /dev/null
+++ b/patches.fixes/i2c-coredesign
@@ -0,0 +1,196 @@
+Patch-mainline: not yet
+
+
+URL: http://marc.info/?l=linux-i2c&m=133959209902331&w=2
+
+
+List:       <a href="?l=linux-i2c&r=1&w=2">linux-i2c</a>
+Subject:    <a href="?t=133959210700011&r=1&w=2">[PATCH RFC/RFT] i2c/busses: Fix build error if CONFIG_I2C_DESIGNWARE_PLATFORM=y &amp;&amp; CONFIG_I2C_DESIGN</a>
+From:       <a href="?a=123260876100001&r=1&w=2">Axel Lin &lt;axel.lin () gmail ! com&gt;</a>
+Date:       <a href="?l=linux-i2c&r=1&w=2&b=201206">2012-06-13 12:51:37</a>
+Message-ID: <a href="?i=1339591897.9672.6.camel%20()%20phoenix">1339591897.9672.6.camel () phoenix</a></font>
+[<a href="?l=linux-i2c&m=133959209902331&q=raw">Download message RAW</a>]</b>
+
+This patch adds config I2C_DESIGNWARE_CORE in Kconfig, and let
+I2C_DESIGNWARE_PLATFORM and I2C_DESIGNWARE_PCI select I2C_DESIGNWARE_CORE.
+
+Because both I2C_DESIGNWARE_PLATFORM and I2C_DESIGNWARE_PCI can be built as
+built-in or module, we also need to export the functions in i2c-designware-core.
+
+This fixes below build error when CONFIG_I2C_DESIGNWARE_PLATFORM=y &amp;&amp; CONFIG_I2C_DESIGNWARE_PCI=y:
+
+  LD      drivers/i2c/busses/built-in.o
+drivers/i2c/busses/i2c-designware-pci.o: In function `i2c_dw_clear_int':
+i2c-designware-core.c:(.text+0xa10): multiple definition of `i2c_dw_clear_int'
+drivers/i2c/busses/i2c-designware-platform.o:i2c-designware-platdrv.c:(.text+0x928): first defined here
+drivers/i2c/busses/i2c-designware-pci.o: In function `i2c_dw_init':
+i2c-designware-core.c:(.text+0x178): multiple definition of `i2c_dw_init'
+drivers/i2c/busses/i2c-designware-platform.o:i2c-designware-platdrv.c:(.text+0x90): first defined here
+drivers/i2c/busses/i2c-designware-pci.o: In function `dw_readl':
+i2c-designware-core.c:(.text+0xe8): multiple definition of `dw_readl'
+drivers/i2c/busses/i2c-designware-platform.o:i2c-designware-platdrv.c:(.text+0x0): first defined here
+drivers/i2c/busses/i2c-designware-pci.o: In function `i2c_dw_isr':
+i2c-designware-core.c:(.text+0x724): multiple definition of `i2c_dw_isr'
+drivers/i2c/busses/i2c-designware-platform.o:i2c-designware-platdrv.c:(.text+0x63c): first defined here
+drivers/i2c/busses/i2c-designware-pci.o: In function `i2c_dw_xfer':
+i2c-designware-core.c:(.text+0x4b0): multiple definition of `i2c_dw_xfer'
+drivers/i2c/busses/i2c-designware-platform.o:i2c-designware-platdrv.c:(.text+0x3c8): first defined here
+drivers/i2c/busses/i2c-designware-pci.o: In function `i2c_dw_is_enabled':
+i2c-designware-core.c:(.text+0x9d4): multiple definition of `i2c_dw_is_enabled'
+drivers/i2c/busses/i2c-designware-platform.o:i2c-designware-platdrv.c:(.text+0x8ec): first defined here
+drivers/i2c/busses/i2c-designware-pci.o: In function `dw_writel':
+i2c-designware-core.c:(.text+0x124): multiple definition of `dw_writel'
+drivers/i2c/busses/i2c-designware-platform.o:i2c-designware-platdrv.c:(.text+0x3c): first defined here
+drivers/i2c/busses/i2c-designware-pci.o: In function `i2c_dw_xfer_msg':
+i2c-designware-core.c:(.text+0x2e8): multiple definition of `i2c_dw_xfer_msg'
+drivers/i2c/busses/i2c-designware-platform.o:i2c-designware-platdrv.c:(.text+0x200): first defined here
+drivers/i2c/busses/i2c-designware-pci.o: In function `i2c_dw_enable':
+i2c-designware-core.c:(.text+0x9c8): multiple definition of `i2c_dw_enable'
+drivers/i2c/busses/i2c-designware-platform.o:i2c-designware-platdrv.c:(.text+0x8e0): first defined here
+drivers/i2c/busses/i2c-designware-pci.o: In function `i2c_dw_read_comp_param':
+i2c-designware-core.c:(.text+0xa24): multiple definition of `i2c_dw_read_comp_param'
+drivers/i2c/busses/i2c-designware-platform.o:i2c-designware-platdrv.c:(.text+0x93c): first defined here
+drivers/i2c/busses/i2c-designware-pci.o: In function `i2c_dw_disable':
+i2c-designware-core.c:(.text+0x9dc): multiple definition of `i2c_dw_disable'
+drivers/i2c/busses/i2c-designware-platform.o:i2c-designware-platdrv.c:(.text+0x8f4): first defined here
+drivers/i2c/busses/i2c-designware-pci.o: In function `i2c_dw_func':
+i2c-designware-core.c:(.text+0x710): multiple definition of `i2c_dw_func'
+drivers/i2c/busses/i2c-designware-platform.o:i2c-designware-platdrv.c:(.text+0x628): first defined here
+drivers/i2c/busses/i2c-designware-pci.o: In function `i2c_dw_disable_int':
+i2c-designware-core.c:(.text+0xa18): multiple definition of `i2c_dw_disable_int'
+drivers/i2c/busses/i2c-designware-platform.o:i2c-designware-platdrv.c:(.text+0x930): first defined here
+make<A NAME="-3"></A><A HREF="#3">[3]</A>: *** [drivers/i2c/busses/built-in.o] Error 1
+make<A NAME="-2"></A><A HREF="#2">[2]</A>: *** [drivers/i2c/busses] Error 2
+make<A NAME="-1"></A><A HREF="#1">[1]</A>: *** [drivers/i2c] Error 2
+make: *** [drivers] Error 2
+
+Signed-off-by: Axel Lin <axel.lin@gmail.com>
+Signed-off-by: Marcus Meissner <meissner@suse.de>
+---
+I don't have this hardware, just try to fix the build error I found.
+
+Axel
+ drivers/i2c/busses/Kconfig               |    5 +++++
+ drivers/i2c/busses/Makefile              |    5 +++--
+ drivers/i2c/busses/i2c-designware-core.c |   11 +++++++++++
+ 3 files changed, 19 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
+index ce3c2be..37c4182 100644
+--- a/drivers/i2c/busses/Makefile
++++ b/drivers/i2c/busses/Makefile
+@@ -33,10 +33,11 @@ obj-$(CONFIG_I2C_AU1550)	+= i2c-au1550.o
+ obj-$(CONFIG_I2C_BLACKFIN_TWI)	+= i2c-bfin-twi.o
+ obj-$(CONFIG_I2C_CPM)		+= i2c-cpm.o
+ obj-$(CONFIG_I2C_DAVINCI)	+= i2c-davinci.o
++obj-$(CONFIG_I2C_DESIGNWARE_CORE)	+= i2c-designware-core.o
+ obj-$(CONFIG_I2C_DESIGNWARE_PLATFORM)	+= i2c-designware-platform.o
+-i2c-designware-platform-objs := i2c-designware-platdrv.o i2c-designware-core.o
++i2c-designware-platform-objs := i2c-designware-platdrv.o
+ obj-$(CONFIG_I2C_DESIGNWARE_PCI)	+= i2c-designware-pci.o
+-i2c-designware-pci-objs := i2c-designware-pcidrv.o i2c-designware-core.o
++i2c-designware-pci-objs := i2c-designware-pcidrv.o
+ obj-$(CONFIG_I2C_EG20T)		+= i2c-eg20t.o
+ obj-$(CONFIG_I2C_GPIO)		+= i2c-gpio.o
+ obj-$(CONFIG_I2C_HIGHLANDER)	+= i2c-highlander.o
+--- linux-3.4.6-0/drivers/i2c/busses/Kconfig.xx	2012-07-26 10:41:50.000000000 +0000
++++ linux-3.4.6-0/drivers/i2c/busses/Kconfig	2012-07-26 10:43:57.000000000 +0000
+@@ -350,9 +350,13 @@
+ 	  devices such as DaVinci NIC.
+ 	  For details please see http://www.ti.com/davinci
+ 
++config I2C_DESIGNWARE_CORE
++	tristate
++
+ config I2C_DESIGNWARE_PLATFORM
+ 	tristate "Synopsys DesignWare Platfrom"
+ 	depends on HAVE_CLK
++	select I2C_DESIGNWARE_CORE
+ 	help
+ 	  If you say yes to this option, support will be included for the
+ 	  Synopsys DesignWare I2C adapter. Only master mode is supported.
+@@ -363,6 +367,7 @@
+ config I2C_DESIGNWARE_PCI
+ 	tristate "Synopsys DesignWare PCI"
+ 	depends on PCI
++	select I2C_DESIGNWARE_CORE
+ 	help
+ 	  If you say yes to this option, support will be included for the
+ 	  Synopsys DesignWare I2C adapter. Only master mode is supported.
+--- linux-3.4.6-0/drivers/i2c/busses/i2c-designware-core.c.xx	2012-07-26 10:41:58.000000000 +0000
++++ linux-3.4.6-0/drivers/i2c/busses/i2c-designware-core.c	2012-07-26 10:45:18.000000000 +0000
+@@ -25,6 +25,7 @@
+  * ----------------------------------------------------------------------------
+  *
+  */
++#include <linux/export.h>
+ #include <linux/clk.h>
+ #include <linux/errno.h>
+ #include <linux/err.h>
+@@ -305,6 +306,7 @@
+ 	dw_writel(dev, dev->master_cfg , DW_IC_CON);
+ 	return 0;
+ }
++EXPORT_SYMBOL_GPL(i2c_dw_init);
+ 
+ /*
+  * Waiting for bus not busy
+@@ -557,12 +559,14 @@
+ 
+ 	return ret;
+ }
++EXPORT_SYMBOL_GPL(i2c_dw_xfer);
+ 
+ u32 i2c_dw_func(struct i2c_adapter *adap)
+ {
+ 	struct dw_i2c_dev *dev = i2c_get_adapdata(adap);
+ 	return dev->functionality;
+ }
++EXPORT_SYMBOL_GPL(i2c_dw_func);
+ 
+ static u32 i2c_dw_read_clear_intrbits(struct dw_i2c_dev *dev)
+ {
+@@ -667,17 +671,20 @@
+ 
+ 	return IRQ_HANDLED;
+ }
++EXPORT_SYMBOL_GPL(i2c_dw_isr);
+ 
+ void i2c_dw_enable(struct dw_i2c_dev *dev)
+ {
+        /* Enable the adapter */
+ 	dw_writel(dev, 1, DW_IC_ENABLE);
+ }
++EXPORT_SYMBOL_GPL(i2c_dw_enable);
+ 
+ u32 i2c_dw_is_enabled(struct dw_i2c_dev *dev)
+ {
+ 	return dw_readl(dev, DW_IC_ENABLE);
+ }
++EXPORT_SYMBOL_GPL(i2c_dw_is_enabled);
+ 
+ void i2c_dw_disable(struct dw_i2c_dev *dev)
+ {
+@@ -688,18 +695,22 @@
+ 	dw_writel(dev, 0, DW_IC_INTR_MASK);
+ 	dw_readl(dev, DW_IC_CLR_INTR);
+ }
++EXPORT_SYMBOL_GPL(i2c_dw_disable);
+ 
+ void i2c_dw_clear_int(struct dw_i2c_dev *dev)
+ {
+ 	dw_readl(dev, DW_IC_CLR_INTR);
+ }
++EXPORT_SYMBOL_GPL(i2c_dw_clear_int);
+ 
+ void i2c_dw_disable_int(struct dw_i2c_dev *dev)
+ {
+ 	dw_writel(dev, 0, DW_IC_INTR_MASK);
+ }
++EXPORT_SYMBOL_GPL(i2c_dw_disable_int);
+ 
+ u32 i2c_dw_read_comp_param(struct dw_i2c_dev *dev)
+ {
+ 	return dw_readl(dev, DW_IC_COMP_PARAM_1);
+ }
++EXPORT_SYMBOL_GPL(i2c_dw_read_comp_param);
diff --git a/series.conf b/series.conf
index 63f75ba..f40e2a9 100644
--- a/series.conf
+++ b/series.conf
@@ -441,6 +441,8 @@
 	# I2C
 	########################################################
 
+	patches.fixes/i2c-coredesign
+
 	########################################################
 	# Input & Console
 	########################################################
-- 
1.7.9.2

