From patchwork Thu Mar 11 10:06:02 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 84843 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2BA68Id006756 for ; Thu, 11 Mar 2010 10:06:08 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756488Ab0CKKGH (ORCPT ); Thu, 11 Mar 2010 05:06:07 -0500 Received: from mail-gy0-f174.google.com ([209.85.160.174]:35247 "EHLO mail-gy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756432Ab0CKKGD (ORCPT ); Thu, 11 Mar 2010 05:06:03 -0500 Received: by gyd8 with SMTP id 8so1074454gyd.19 for ; Thu, 11 Mar 2010 02:06:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:date:message-id :in-reply-to:references:subject; bh=jjofQwKrC/fgJBtfSZbB6OimA8ujC2XHtxq+9SWjR48=; b=kU/AYSzKOqFcQznZi8JDFzA7h2j/77b20ulY24uYnboqQTGKLLDDg7DKItMW+LzDgr gc2VvYeCv5lR48u/U+otp9DhtNE0KdrNcUEo2KDvdA7b/WX7V6GV8Z8ULKn6I66Mi8MQ qorEYjSgfj6968ULumO5cUEbGmZex+Qm4Zejs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:date:message-id:in-reply-to:references:subject; b=qfdKjA8hAPQpG6xC5JAjq2E3OOHqkVOg7C7HnHSvAHGqMGaSZmZ2eSaQVCGrAIdOhc dWTcWEW/a1lfI8XXJXtl2sDfN6M71wbMyUP6ceUt48K12WuqWoO2Spz1lh6q0W+5SZfw QCGiE385ELPMfuc5eGyt8MEtqhahtX2y8ROE0= Received: by 10.101.58.5 with SMTP id l5mr3483735ank.73.1268301962914; Thu, 11 Mar 2010 02:06:02 -0800 (PST) Received: from [127.0.0.1] (49.14.32.202.bf.2iij.net [202.32.14.49]) by mx.google.com with ESMTPS id 13sm5857406gxk.12.2010.03.11.02.06.00 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 11 Mar 2010 02:06:02 -0800 (PST) From: Magnus Damm To: linux-i2c@vger.kernel.org Cc: linux-sh@vger.kernel.org, nishimoto.hiroki@renesas.com, morimoto.kuninori@renesas.com, lethal@linux-sh.org, khali@linux-fr.org, Magnus Damm Date: Thu, 11 Mar 2010 19:06:02 +0900 Message-Id: <20100311100602.15227.88236.sendpatchset@t400s> In-Reply-To: <20100311100526.15227.50813.sendpatchset@t400s> References: <20100311100526.15227.50813.sendpatchset@t400s> Subject: [PATCH 02/03] i2c: i2c-sh_mobile support for new ICIC bits Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 11 Mar 2010 10:06:08 +0000 (UTC) --- 0026/drivers/i2c/busses/i2c-sh_mobile.c +++ work/drivers/i2c/busses/i2c-sh_mobile.c 2010-03-11 15:33:09.000000000 +0900 @@ -118,8 +118,10 @@ struct sh_mobile_i2c_data { struct i2c_adapter adap; struct clk *clk; + u_int8_t icic; u_int8_t iccl; u_int8_t icch; + u_int8_t flags; spinlock_t lock; wait_queue_head_t wait; @@ -128,6 +130,8 @@ struct sh_mobile_i2c_data { int sr; }; +#define IIC_FLAG_HAS_ICIC67 (1 << 0) + #define NORMAL_SPEED 100000 /* FAST_SPEED 400000 */ /* Register offsets */ @@ -154,6 +158,8 @@ struct sh_mobile_i2c_data { #define ICSR_WAIT 0x02 #define ICSR_DTE 0x01 +#define ICIC_ICCLB8 0x80 +#define ICIC_ICCHB8 0x40 #define ICIC_ALE 0x08 #define ICIC_TACKE 0x04 #define ICIC_WAITE 0x02 @@ -161,6 +167,9 @@ struct sh_mobile_i2c_data { static void iic_wr(struct sh_mobile_i2c_data *pd, int offs, unsigned char data) { + if (offs == ICIC) + data |= pd->icic; + iowrite8(data, pd->reg + offs); } @@ -202,6 +211,14 @@ static void activate_ch(struct sh_mobile else pd->iccl = (u_int8_t)(num/denom); + /* one more bit of ICCL in ICIC */ + if (pd->flags & IIC_FLAG_HAS_ICIC67) { + if ((num/denom) > 0xff) + pd->icic |= ICIC_ICCLB8; + else + pd->icic &= ~ICIC_ICCLB8; + } + /* Calculate the value for icch. From the data sheet: icch = (p clock / transfer rate) * (H / (L + H)) */ num = i2c_clk * 4; @@ -211,6 +228,14 @@ static void activate_ch(struct sh_mobile else pd->icch = (u_int8_t)(num/denom); + /* one more bit of ICCH in ICIC */ + if (pd->flags & IIC_FLAG_HAS_ICIC67) { + if ((num/denom) > 0xff) + pd->icic |= ICIC_ICCHB8; + else + pd->icic &= ~ICIC_ICCHB8; + } + /* Enable channel and configure rx ack */ iic_set_clr(pd, ICCR, ICCR_ICE, 0); @@ -591,6 +616,12 @@ static int sh_mobile_i2c_probe(struct pl goto err_irq; } + /* The IIC blocks on SH-Mobile ARM processors + * come with two new bits in ICIC. + */ + if (size > 0x17) + pd->flags |= IIC_FLAG_HAS_ICIC67; + /* Enable Runtime PM for this device. * * Also tell the Runtime PM core to ignore children