From patchwork Tue Jan 12 01:50:54 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cory Maccarrone X-Patchwork-Id: 72295 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.2) with ESMTP id o0C1pJ4s005041 for ; Tue, 12 Jan 2010 01:51:19 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752910Ab0ALBvS (ORCPT ); Mon, 11 Jan 2010 20:51:18 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751946Ab0ALBvS (ORCPT ); Mon, 11 Jan 2010 20:51:18 -0500 Received: from mail-pw0-f42.google.com ([209.85.160.42]:42044 "EHLO mail-pw0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751912Ab0ALBvR (ORCPT ); Mon, 11 Jan 2010 20:51:17 -0500 Received: by pwj9 with SMTP id 9so1775519pwj.21 for ; Mon, 11 Jan 2010 17:51:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:cc:content-type; bh=fnr0Dl4msWpoRHERoQQAw7HdZPran7L7j4RjAbdaTKo=; b=fSzIBKvqEKngrH6mHHK0jaK3UA5gtWtWzlHBNxj7YvoplcKYG/MF94GRg2PNap2jzM T8D36NPNBUqej0dABPm1EU/JQ/h+DvRDzRu6yfbBPme2io42EmBaugMJ7PUk0H15iz/b Stc57xVMlR/D+6b1bM1TfzAJRemYfIeQBQE20= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=W2fWYUeJ8sECQTA2/9SZ/SyBqTUHLn55WyKTKZfN5TaAGbiYeE5+5UCqNuTUVg2UVu wMLDxyrf+7Vm2uBtmjZTPQFiftVd+S2lxoHsL2ZD88yOpkMhW8kcb3z5AHMF2QGfbRcI imf7T+QAnqaYOKjqqs7RDbRnJaZsO9yhyR1wg= MIME-Version: 1.0 Received: by 10.142.74.7 with SMTP id w7mr343740wfa.149.1263261075296; Mon, 11 Jan 2010 17:51:15 -0800 (PST) In-Reply-To: <20100112012814.GK5055@atomide.com> References: <1260669242-29865-1-git-send-email-darkstar6262@gmail.com> <6cb013311001090947m2268833cv3784f469dc8b861d@mail.gmail.com> <20100109183321.GH2879@atomide.com> <6cb013311001091035x54321b3aqb814f476200980af@mail.gmail.com> <20100112012814.GK5055@atomide.com> From: Cory Maccarrone Date: Mon, 11 Jan 2010 17:50:54 -0800 Message-ID: <6cb013311001111750m17430092p8d9bd1102152db8b@mail.gmail.com> Subject: Re: [PATCH v2] [I2C-OMAP] Add support for 16-bit registers To: Tony Lindgren Cc: linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org From 7c693afce8ffa3978b4fcecc56cd7d4a9d9d3b75 Mon Sep 17 00:00:00 2001 From: Cory Maccarrone Date: Sat, 5 Dec 2009 22:00:25 -0800 Subject: [PATCH] [I2C-OMAP] Add support for 16-bit registers The current i2c-omap driver is set up for 32-bit registers, which corresponds to most OMAP devices. However, OMAP730/850 based devices use a 16-bit register size. This change modifies the driver to perform a runtime CPU type check to determine the register sizes, and uses a bit shift of either 1 or 2 bits to compute the proper register sizes for all registers. Signed-off-by: Cory Maccarrone --- drivers/i2c/busses/i2c-omap.c | 45 +++++++++++++++++++++++----------------- 1 files changed, 26 insertions(+), 19 deletions(-) diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c index 0037e31..9c3ce4d 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c @@ -49,24 +49,24 @@ #define OMAP_I2C_TIMEOUT (msecs_to_jiffies(1000)) #define OMAP_I2C_REV_REG 0x00 -#define OMAP_I2C_IE_REG 0x04 -#define OMAP_I2C_STAT_REG 0x08 -#define OMAP_I2C_IV_REG 0x0c +#define OMAP_I2C_IE_REG 0x01 +#define OMAP_I2C_STAT_REG 0x02 +#define OMAP_I2C_IV_REG 0x03 /* For OMAP3 I2C_IV has changed to I2C_WE (wakeup enable) */ -#define OMAP_I2C_WE_REG 0x0c -#define OMAP_I2C_SYSS_REG 0x10 -#define OMAP_I2C_BUF_REG 0x14 -#define OMAP_I2C_CNT_REG 0x18 -#define OMAP_I2C_DATA_REG 0x1c -#define OMAP_I2C_SYSC_REG 0x20 -#define OMAP_I2C_CON_REG 0x24 -#define OMAP_I2C_OA_REG 0x28 -#define OMAP_I2C_SA_REG 0x2c -#define OMAP_I2C_PSC_REG 0x30 -#define OMAP_I2C_SCLL_REG 0x34 -#define OMAP_I2C_SCLH_REG 0x38 -#define OMAP_I2C_SYSTEST_REG 0x3c -#define OMAP_I2C_BUFSTAT_REG 0x40 +#define OMAP_I2C_WE_REG 0x03 +#define OMAP_I2C_SYSS_REG 0x04 +#define OMAP_I2C_BUF_REG 0x05 +#define OMAP_I2C_CNT_REG 0x06 +#define OMAP_I2C_DATA_REG 0x07 +#define OMAP_I2C_SYSC_REG 0x08 +#define OMAP_I2C_CON_REG 0x09 +#define OMAP_I2C_OA_REG 0x0a +#define OMAP_I2C_SA_REG 0x0b +#define OMAP_I2C_PSC_REG 0x0c +#define OMAP_I2C_SCLL_REG 0x0d +#define OMAP_I2C_SCLH_REG 0x0e +#define OMAP_I2C_SYSTEST_REG 0x0f +#define OMAP_I2C_BUFSTAT_REG 0x10 /* I2C Interrupt Enable Register (OMAP_I2C_IE): */ #define OMAP_I2C_IE_XDR (1 << 14) /* TX Buffer drain int enable */ @@ -161,6 +161,7 @@ struct omap_i2c_dev { struct device *dev; void __iomem *base; /* virtual */ int irq; + int reg_shift; /* bit shift for I2C register addresses */ struct clk *iclk; /* Interface clock */ struct clk *fclk; /* Functional clock */ struct completion cmd_complete; @@ -189,12 +190,12 @@ struct omap_i2c_dev { static inline void omap_i2c_write_reg(struct omap_i2c_dev *i2c_dev, int reg, u16 val) { - __raw_writew(val, i2c_dev->base + reg); + __raw_writew(val, i2c_dev->base + (reg << i2c_dev->reg_shift)); } static inline u16 omap_i2c_read_reg(struct omap_i2c_dev *i2c_dev, int reg) { - return __raw_readw(i2c_dev->base + reg); + return __raw_readw(i2c_dev->base + (reg << i2c_dev->reg_shift)); } static int __init omap_i2c_get_clocks(struct omap_i2c_dev *dev) @@ -893,6 +894,12 @@ omap_i2c_probe(struct platform_device *pdev) dev->idle = 1; dev->dev = &pdev->dev; dev->irq = irq->start; + + if (cpu_is_omap7xx()) + dev->reg_shift = 1; + else + dev->reg_shift = 2; + dev->base = ioremap(mem->start, resource_size(mem)); if (!dev->base) { r = -ENOMEM; -- 1.6.3.3