From patchwork Fri Dec 14 16:34:06 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 1879761 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id B88FD40079 for ; Fri, 14 Dec 2012 16:46:04 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TjYKo-0000NY-E3; Fri, 14 Dec 2012 16:42:02 +0000 Received: from devils.ext.ti.com ([198.47.26.153]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TjYKE-0000I3-O8 for linux-arm-kernel@lists.infradead.org; Fri, 14 Dec 2012 16:41:27 +0000 Received: from dlelxv30.itg.ti.com ([172.17.2.17]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id qBEGfP1t019871; Fri, 14 Dec 2012 10:41:25 -0600 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv30.itg.ti.com (8.13.8/8.13.8) with ESMTP id qBEGfPJc031685; Fri, 14 Dec 2012 10:41:25 -0600 Received: from dlelxv22.itg.ti.com (172.17.1.197) by dfle72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.1.323.3; Fri, 14 Dec 2012 10:41:25 -0600 Received: from localhost (h79-2.vpn.ti.com [172.24.79.2]) by dlelxv22.itg.ti.com (8.13.8/8.13.8) with ESMTP id qBEGfOkl013164; Fri, 14 Dec 2012 10:41:25 -0600 From: Felipe Balbi To: Wolfram Sang Subject: [PATCH REBASE 3/6] i2c: omap: improve 'rev' a little bit Date: Fri, 14 Dec 2012 18:34:06 +0200 Message-ID: <1355502849-9289-4-git-send-email-balbi@ti.com> X-Mailer: git-send-email 1.8.1.rc1.5.g7e0651a In-Reply-To: <1355502849-9289-1-git-send-email-balbi@ti.com> References: <1355502849-9289-1-git-send-email-balbi@ti.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121214_114126_917112_019DF687 X-CRM114-Status: GOOD ( 13.87 ) X-Spam-Score: -7.6 (-------) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-7.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [198.47.26.153 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Tony Lindgren , Linux OMAP Mailing List , Felipe Balbi , linux-i2c@vger.kernel.org, Linux ARM Kernel Mailing List X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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 --- 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;