From: Felipe Balbi <balbi@ti.com>
To: Wolfram Sang <w.sang@pengutronix.de>
Cc: linux-i2c@vger.kernel.org,
Linux OMAP Mailing List <linux-omap@vger.kernel.org>,
Linux ARM Kernel Mailing List
<linux-arm-kernel@lists.infradead.org>,
Tony Lindgren <tony@atomide.com>, Felipe Balbi <balbi@ti.com>
Subject: [PATCH REBASE 3/6] i2c: omap: improve 'rev' a little bit
Date: Fri, 14 Dec 2012 18:34:06 +0200 [thread overview]
Message-ID: <1355502849-9289-4-git-send-email-balbi@ti.com> (raw)
In-Reply-To: <1355502849-9289-1-git-send-email-balbi@ti.com>
a later patch will use scheme detection at
another part of the code, but current scheme
detection implementation relies on the fact that
we still hold scheme on the first 16 bits of our
rev variable, which won't be true as soon as
we move away from probe() because we left shift
it by 16 in case of newer IP versions in order
to fit other revision data in the lower 16 bits.
To fix that, we are changing scheme implementation
to assume scheme is always placed on the top 16
bits.
While at that, also move those macro definitions
to the top of the source file, where they should've
been to start with, because a later patch will use
them.
Signed-off-by: Felipe Balbi <balbi@ti.com>
---
drivers/i2c/busses/i2c-omap.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index fcecb0b..c93eb17 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -60,6 +60,17 @@
/* timeout for pm runtime autosuspend */
#define OMAP_I2C_PM_TIMEOUT 1000 /* ms */
+#define OMAP_I2C_SCHEME(rev) ((rev & 0xc0000000) >> 30)
+
+#define OMAP_I2C_SCHEME_0 0
+#define OMAP_I2C_SCHEME_1 1
+
+#define OMAP_I2C_REV_SCHEME_0_MAJOR(rev) (rev >> 4)
+#define OMAP_I2C_REV_SCHEME_0_MINOR(rev) (rev & 0xf)
+
+#define OMAP_I2C_REV_SCHEME_1_MAJOR(rev) ((rev & 0x0700) >> 7)
+#define OMAP_I2C_REV_SCHEME_1_MINOR(rev) (rev & 0x1f)
+
/* For OMAP3 I2C_IV has changed to I2C_WE (wakeup enable) */
enum {
OMAP_I2C_REV_REG = 0,
@@ -1058,16 +1069,6 @@ static const struct of_device_id omap_i2c_of_match[] = {
MODULE_DEVICE_TABLE(of, omap_i2c_of_match);
#endif
-#define OMAP_I2C_SCHEME(rev) ((rev & 0xc000) >> 14)
-
-#define OMAP_I2C_REV_SCHEME_0_MAJOR(rev) (rev >> 4)
-#define OMAP_I2C_REV_SCHEME_0_MINOR(rev) (rev & 0xf)
-
-#define OMAP_I2C_REV_SCHEME_1_MAJOR(rev) ((rev & 0x0700) >> 7)
-#define OMAP_I2C_REV_SCHEME_1_MINOR(rev) (rev & 0x1f)
-#define OMAP_I2C_SCHEME_0 0
-#define OMAP_I2C_SCHEME_1 1
-
static int __devinit
omap_i2c_probe(struct platform_device *pdev)
{
@@ -1158,7 +1159,7 @@ omap_i2c_probe(struct platform_device *pdev)
* Also since the omap_i2c_read_reg uses reg_map_ip_* a
* raw_readw is done.
*/
- rev = __raw_readw(dev->base + 0x04);
+ rev = __raw_readw(dev->base + 0x04) << 16;
scheme = OMAP_I2C_SCHEME(rev);
switch (scheme) {
@@ -1172,8 +1173,7 @@ omap_i2c_probe(struct platform_device *pdev)
/* FALLTHROUGH */
default:
dev->regs = (u8 *)reg_map_ip_v2;
- rev = (rev << 16) |
- omap_i2c_read_reg(dev, OMAP_I2C_IP_V2_REVNB_LO);
+ rev |= omap_i2c_read_reg(dev, OMAP_I2C_IP_V2_REVNB_LO);
minor = OMAP_I2C_REV_SCHEME_1_MINOR(rev);
major = OMAP_I2C_REV_SCHEME_1_MAJOR(rev);
dev->rev = rev;
--
1.8.1.rc1.5.g7e0651a
next prev parent reply other threads:[~2012-12-14 16:34 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-14 16:34 [PATCH REBASE 0/6] i2c: omap: misc changes Felipe Balbi
2012-12-14 16:34 ` [PATCH REBASE 1/6] i2c: omap: no need to access platform_device Felipe Balbi
[not found] ` <1355502849-9289-1-git-send-email-balbi-l0cyMroinI0@public.gmane.org>
2012-12-14 16:34 ` [PATCH REBASE 2/6] i2c: omap: also complete() when stat becomes zero Felipe Balbi
2012-12-14 16:34 ` [PATCH REBASE 4/6] i2c: omap: in case of VERSION_2 read IRQSTATUS_RAW but write to IRQSTATUS Felipe Balbi
2012-12-14 16:34 ` [PATCH REBASE 5/6] i2c: omap: wait for transfer completion before sending STP bit Felipe Balbi
2013-01-14 19:16 ` [PATCH REBASE 0/6] i2c: omap: misc changes Felipe Balbi
[not found] ` <20130114191628.GB9402-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org>
2013-01-23 9:58 ` Wolfram Sang
2013-01-23 10:23 ` [PATCH 0/6] i2c: deferred STP Felipe Balbi
2013-01-23 10:23 ` [PATCH 2/6] i2c: omap: also complete() when stat becomes zero Felipe Balbi
2013-01-24 9:05 ` Aaro Koskinen
2013-01-24 9:13 ` Felipe Balbi
[not found] ` <20130124091339.GF27304-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org>
2013-01-24 9:37 ` Felipe Balbi
2013-01-24 9:56 ` Aaro Koskinen
2013-01-23 10:23 ` [PATCH 3/6] i2c: omap: improve 'rev' a little bit Felipe Balbi
[not found] ` <1358936588-16375-1-git-send-email-balbi-l0cyMroinI0@public.gmane.org>
2013-01-23 10:23 ` [PATCH 1/6] i2c: omap: no need to access platform_device Felipe Balbi
2013-01-23 10:23 ` [PATCH 4/6] i2c: omap: in case of VERSION_2 read IRQSTATUS_RAW but write to IRQSTATUS Felipe Balbi
2013-01-23 10:23 ` [PATCH 5/6] i2c: omap: wait for transfer completion before sending STP bit Felipe Balbi
2013-01-23 20:10 ` Aaro Koskinen
2013-01-24 7:35 ` Felipe Balbi
2013-01-24 7:42 ` [PATCH 5/6 v2] " Felipe Balbi
2013-01-23 10:23 ` [PATCH 6/6] i2c: omap: get rid of b_hw flag Felipe Balbi
2013-01-23 20:05 ` [PATCH 0/6] i2c: deferred STP Aaro Koskinen
[not found] ` <20130123200540.GE23057-R3WNPi76c83LsdW6vOPryG4HOFkwEHDbMR2xtNvyitY@public.gmane.org>
2013-01-24 16:11 ` Aaro Koskinen
2012-12-14 16:34 ` Felipe Balbi [this message]
2012-12-14 16:34 ` [PATCH REBASE 6/6] i2c: omap: get rid of b_hw flag Felipe Balbi
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=1355502849-9289-4-git-send-email-balbi@ti.com \
--to=balbi@ti.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=tony@atomide.com \
--cc=w.sang@pengutronix.de \
/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).