From patchwork Fri Aug 30 12:37:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulrich Hecht X-Patchwork-Id: 2851962 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D52E99F313 for ; Fri, 30 Aug 2013 12:39:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B48BC2039A for ; Fri, 30 Aug 2013 12:39:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3EA97203B4 for ; Fri, 30 Aug 2013 12:39:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756051Ab3H3MjI (ORCPT ); Fri, 30 Aug 2013 08:39:08 -0400 Received: from mail-ee0-f51.google.com ([74.125.83.51]:65359 "EHLO mail-ee0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756039Ab3H3MjF (ORCPT ); Fri, 30 Aug 2013 08:39:05 -0400 Received: by mail-ee0-f51.google.com with SMTP id c1so889313eek.10 for ; Fri, 30 Aug 2013 05:39:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kQV4/EngbBOeMV0dx1MJSaUWybOPUXIAEluLRe39boE=; b=NgdKohWIpgCnjT1jpE9ldCMDdX6ij+cRtJ66gh2JcB/c4uAe7oXFH1JmuLHalyGOWI NUDBfxxdwzAgsvIdxy6745jyBSs+MDC/M7UZilevAI//VpeHpt45WFrNBKY96YeuEbqZ YD7sMqiHnhB1/Ad/N9TPiqmfNVxmXgixM1SgPUqBmXCuu8xyhgzg22J0OUfrs80s1Z1T o8ymQNwxHgRNqeczzLuzF/2AaykGJaXSBObV8inhAVMyBCACPlsbReFQDxde7WDgUNcG lPwPWuXmK5F8R85C73pMz6TlwncVQ4fc8jmUlPdlmn/aXeJaFx0aFKcmkbPIjyaxdsbL m4FA== X-Received: by 10.14.4.1 with SMTP id 1mr12571407eei.21.1377866344313; Fri, 30 Aug 2013 05:39:04 -0700 (PDT) Received: from groucho.site ([109.201.152.242]) by mx.google.com with ESMTPSA id j7sm54444384eeo.15.1969.12.31.16.00.00 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 30 Aug 2013 05:39:03 -0700 (PDT) From: Ulrich Hecht To: linux-sh@vger.kernel.org Cc: magnus.damm@gmail.com, Nguyen Viet Dung Subject: [RFC 04/10] i2c: rcar: modify I2C driver Date: Fri, 30 Aug 2013 14:37:38 +0200 Message-Id: <1377866264-21110-5-git-send-email-ulrich.hecht@gmail.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1377866264-21110-1-git-send-email-ulrich.hecht@gmail.com> References: <1377866264-21110-1-git-send-email-ulrich.hecht@gmail.com> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-8.9 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Nguyen Viet Dung This patch modify calculate for clock in I2C driver. Signed-off-by: Nguyen Viet Dung --- drivers/i2c/busses/i2c-rcar.c | 17 +++++++++++++++-- include/linux/i2c/i2c-rcar.h | 4 ++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c index 0fc5858..c4fb69c 100644 --- a/drivers/i2c/busses/i2c-rcar.c +++ b/drivers/i2c/busses/i2c-rcar.c @@ -221,15 +221,28 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv, struct device *dev) { struct clk *clkp = clk_get(NULL, "peripheral_clk"); + struct i2c_rcar_platform_data *pdata = dev->platform_data; u32 scgd, cdf; u32 round, ick; u32 scl; + u32 cdf_width; + u32 flags = pdata ? pdata->flags : 0; if (!clkp) { dev_err(dev, "there is no peripheral_clk\n"); return -EIO; } + switch (flags & I2C_RCAR_FLAGS_ICCCR_MASK) { + default: + case I2C_RCAR_FLAGS_ICCCR_IS_2BIT: + cdf_width = 2; + break; + case I2C_RCAR_FLAGS_ICCCR_IS_3BIT: + cdf_width = 3; + break; + } + /* * calculate SCL clock * see @@ -245,7 +258,7 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv, * clkp : peripheral_clk * F[] : integer up-valuation */ - for (cdf = 0; cdf < 4; cdf++) { + for (cdf = 0; cdf < (1 << cdf_width); cdf++) { ick = clk_get_rate(clkp) / (1 + cdf); if (ick < 20000000) goto ick_find; @@ -287,7 +300,7 @@ scgd_find: /* * keep icccr value */ - priv->icccr = (scgd << 2 | cdf); + priv->icccr = (scgd << (cdf_width) | cdf); return 0; } diff --git a/include/linux/i2c/i2c-rcar.h b/include/linux/i2c/i2c-rcar.h index 496f5c2..572a6e5 100644 --- a/include/linux/i2c/i2c-rcar.h +++ b/include/linux/i2c/i2c-rcar.h @@ -5,6 +5,10 @@ struct i2c_rcar_platform_data { u32 bus_speed; + u32 flags; +#define I2C_RCAR_FLAGS_ICCCR_MASK (0xF << 0) +#define I2C_RCAR_FLAGS_ICCCR_IS_2BIT (0 << 0) /* default */ +#define I2C_RCAR_FLAGS_ICCCR_IS_3BIT (1 << 0) }; #endif /* __I2C_R_CAR_H__ */