summaryrefslogtreecommitdiff
path: root/drivers/i2c
diff options
context:
space:
mode:
authorJean-Hugues Deschenes <jean-hugues.deschenes@octasic.com>2010-01-27 14:19:52 -0500
committerBen Dooks <ben-linux@fluff.org>2010-02-03 02:35:59 +0000
commit545eb087465eec1d656f766941a85d68189fee84 (patch)
treee2a3077976a37fdb448a6528a7c0e74554e37542 /drivers/i2c
parent3b1dc6496526f51974f9f41eb1056fa93ad79f56 (diff)
i2c-designware: Allow mixed endianness accesses
Allows CPUs of a given endianness to access a dw controller of a different endianness. Endianncess difference is detected at run time through the dw component type register. Signed-off-by: Jean-Hugues Deschenes <jean-hugues.deschenes@octasic.com> Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/busses/i2c-designware.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/drivers/i2c/busses/i2c-designware.c b/drivers/i2c/busses/i2c-designware.c
index 32f6232ba6af..8c2f64224a4a 100644
--- a/drivers/i2c/busses/i2c-designware.c
+++ b/drivers/i2c/busses/i2c-designware.c
@@ -36,6 +36,7 @@
#include <linux/interrupt.h>
#include <linux/platform_device.h>
#include <linux/io.h>
+#include <linux/swab.h>
/*
* Registers offset
@@ -192,6 +193,7 @@ static char *abort_sources[] = {
* @status: i2c master status, one of STATUS_*
* @abort_source: copy of the TX_ABRT_SOURCE register
* @irq: interrupt number for the i2c master
+ * @swab: true if the instantiated IP is of different endianess
* @adapter: i2c subsystem adapter node
* @tx_fifo_depth: depth of the hardware tx fifo
* @rx_fifo_depth: depth of the hardware rx fifo
@@ -215,6 +217,7 @@ struct dw_i2c_dev {
unsigned int status;
u32 abort_source;
int irq;
+ int swab;
struct i2c_adapter adapter;
unsigned int tx_fifo_depth;
unsigned int rx_fifo_depth;
@@ -222,11 +225,19 @@ struct dw_i2c_dev {
static u32 dw_readl(struct dw_i2c_dev *dev, int offset)
{
- return readl(dev->base + offset);
+ u32 value = readl(dev->base + offset);
+
+ if (dev->swab)
+ return swab32(value);
+ else
+ return value;
}
static void dw_writel(struct dw_i2c_dev *dev, u32 b, int offset)
{
+ if (dev->swab)
+ b = swab32(b);
+
writel(b, dev->base + offset);
}
@@ -759,7 +770,9 @@ static int __devinit dw_i2c_probe(struct platform_device *pdev)
}
reg = dw_readl(dev, DW_IC_COMP_TYPE);
- if (reg != 0x44570140) {
+ if (reg == ___constant_swab32(0x44570140))
+ dev->swab = 1;
+ else if (reg != 0x44570140) {
dev_err(&pdev->dev, "Unknown Synopsys component type: "
"0x%08x\n", reg);
r = -ENODEV;