From: Jean-Hugues Deschenes <jean-hugues.deschenes-YGVykHU+fedBDgjK7y7TUQ@public.gmane.org>
To: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Ben Dooks <ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org>,
Baruch Siach <baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org>,
Shinya Kuribayashi
<shinya.kuribayashi-jaWZhaxaiAMAvxtiuMwx3w@public.gmane.org>,
Jean-Hugues Deschenes
<jean-hugues.deschenes-YGVykHU+fedBDgjK7y7TUQ@public.gmane.org>
Subject: [PATCH v2 3/3] i2c-designware: Allow mixed endianness accesses
Date: Tue, 19 Jan 2010 09:02:37 -0500 [thread overview]
Message-ID: <20100119140234.937928000@octasic.com> (raw)
In-Reply-To: 20100119140234.689304000@octasic.com
[-- Attachment #1: allow_mixed_endianness --]
[-- Type: text/plain, Size: 2176 bytes --]
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-YGVykHU+fedBDgjK7y7TUQ@public.gmane.org>
---
drivers/i2c/busses/i2c-designware.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
Index: linux-2.6_i2c/drivers/i2c/busses/i2c-designware.c
===================================================================
--- linux-2.6_i2c.orig/drivers/i2c/busses/i2c-designware.c
+++ linux-2.6_i2c/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
{
u32 comp_type = dw_readl(dev, DW_IC_COMP_TYPE);
- if (comp_type != 0x44570140) {
+ if (comp_type == ___constant_swab32(0x44570140))
+ dev->swab = 1;
+ else if (comp_type != 0x44570140) {
dev_err(&pdev->dev, "Unknown Synopsys component type: "
"0x%08x\n", comp_type);
r = -ENODEV;
--
next prev parent reply other threads:[~2010-01-19 14:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-19 14:02 [PATCH v2 0/3] i2c-designware: Allow mixed endianness Jean-Hugues Deschenes
2010-01-19 14:02 ` [PATCH v2 1/3] i2c-designware: Use local version of readl & writel Jean-Hugues Deschenes
2010-01-19 14:02 ` [PATCH v2 2/3] i2c-designware: Check component type register Jean-Hugues Deschenes
[not found] ` <20100119140234.870830000-YGVykHU+fedBDgjK7y7TUQ@public.gmane.org>
2010-01-24 15:40 ` Ben Dooks
2010-01-19 14:02 ` Jean-Hugues Deschenes [this message]
[not found] ` <20100119140234.689304000-YGVykHU+fedBDgjK7y7TUQ@public.gmane.org>
2010-01-21 5:25 ` [PATCH v2 0/3] i2c-designware: Allow mixed endianness Shinya Kuribayashi
[not found] ` <4B57E54D.8020909-jaWZhaxaiAMAvxtiuMwx3w@public.gmane.org>
2010-01-21 5:46 ` Shinya Kuribayashi
2010-01-24 15:41 ` Ben Dooks
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100119140234.937928000@octasic.com \
--to=jean-hugues.deschenes-ygvykhu+fedbdgjk7y7tuq@public.gmane.org \
--cc=baruch-NswTu9S1W3P6gbPvEgmw2w@public.gmane.org \
--cc=ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=shinya.kuribayashi-jaWZhaxaiAMAvxtiuMwx3w@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).