From patchwork Mon Aug 6 12:25:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 10540 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 95CFD23F61 for ; Mon, 6 Aug 2012 12:26:00 +0000 (UTC) Received: from mail-gg0-f180.google.com (mail-gg0-f180.google.com [209.85.161.180]) by fiordland.canonical.com (Postfix) with ESMTP id 5B8E8A18D4A for ; Mon, 6 Aug 2012 12:26:00 +0000 (UTC) Received: by ggnf1 with SMTP id f1so2393096ggn.11 for ; Mon, 06 Aug 2012 05:25:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:x-gm-message-state; bh=r/MVVMScsv+9a4TRtbvh0/am84JYSrHJjW3S3100jUQ=; b=S8wTpPyp9NPankUjV6QuUNJCx6k8/nAP7CdP1aJELyOkiAwflntocWjwO3DyxZy5Iz tR1WB3xhsToSS+BqbYzBO32dEGFZ06HXjkYeNj2WzKrRR/6i7DQ2GFbmB7Qr0zqswA1M hPKX+dcEOLeTRW2I3sJnvJNkZB0gpDxfvt6VoL2gRosXdoB46zx6AYz6rG6bYDoT4tkN nfy4AGyJ++kAKaiKwkgeZ1b9hxMyRt1qh8MtpCPsocvu7pHKY7L1EwuUSCgwoXuz1jLm zKGfZC5s66cHZxm52oTzIPIcN3yZcbI8nw5l6U7RB88Uq3n2qoiw2XrfuAdLapSX/JCG wqqg== Received: by 10.43.46.194 with SMTP id up2mr8881688icb.22.1344255959561; Mon, 06 Aug 2012 05:25:59 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.87.40 with SMTP id u8csp438005igz; Mon, 6 Aug 2012 05:25:58 -0700 (PDT) Received: by 10.180.98.138 with SMTP id ei10mr18099910wib.1.1344255957947; Mon, 06 Aug 2012 05:25:57 -0700 (PDT) Received: from mail-we0-f178.google.com (mail-we0-f178.google.com [74.125.82.178]) by mx.google.com with ESMTPS id fc10si17214047wib.2.2012.08.06.05.25.57 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 06 Aug 2012 05:25:57 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.178 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.82.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.178 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) smtp.mail=lee.jones@linaro.org Received: by weyu7 with SMTP id u7so2428972wey.37 for ; Mon, 06 Aug 2012 05:25:57 -0700 (PDT) Received: by 10.216.123.69 with SMTP id u47mr5619963weh.89.1344255957014; Mon, 06 Aug 2012 05:25:57 -0700 (PDT) Received: from localhost.localdomain (cpc1-aztw13-0-0-cust473.18-1.cable.virginmedia.com. [77.102.241.218]) by mx.google.com with ESMTPS id l5sm22617728wix.5.2012.08.06.05.25.55 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 06 Aug 2012 05:25:56 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: STEricsson_nomadik_linux@list.st.com, linus.walleij@stericsson.com, arnd@arndb.de, w.sang@pengutronix.de, srinidhi.kasagar@stericsson.com, Lee Jones , linux-i2c@vger.kernel.org Subject: [PATCH 1/1] i2c: Add default configuration into the Nomadik I2C driver. Date: Mon, 6 Aug 2012 13:25:47 +0100 Message-Id: <1344255947-10062-1-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-Gm-Message-State: ALoCoQnMFrye+BY+mebx2VTP1o1YsAjkR9GdOA1pZBqWb6Ultpl8ekA6le0yShXhucXEk2l3NNLo At this moment in time there is only one known configuration for the Nomadik I2C driver. By not holding that configuration in the driver adds some unnecessary overhead in platform code. The configuration as already been removed from platform code, this patch checks for any over-riding configurations. If there aren't any, the default is used. Cc: linux-i2c@vger.kernel.org Acked-by: srinidhi kasagar Acked-by: Linus Walleij Signed-off-by: Lee Jones --- drivers/i2c/busses/i2c-nomadik.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c index a92440d..34ab587 100644 --- a/drivers/i2c/busses/i2c-nomadik.c +++ b/drivers/i2c/busses/i2c-nomadik.c @@ -333,10 +333,6 @@ static void setup_i2c_controller(struct nmk_i2c_dev *dev) i2c_clk = clk_get_rate(dev->clk); - /* fallback to std. mode if machine has not provided it */ - if (dev->cfg.clk_freq == 0) - dev->cfg.clk_freq = 100000; - /* * The spec says, in case of std. mode the divider is * 2 whereas it is 3 for fast and fastplus mode of @@ -899,15 +895,31 @@ static const struct i2c_algorithm nmk_i2c_algo = { .functionality = nmk_i2c_functionality }; +static struct nmk_i2c_controller u8500_i2c = { + /* + * Slave data setup time; 250ns, 100ns, and 10ns, which + * is 14, 6 and 2 respectively for a 48Mhz i2c clock. + */ + .slsu = 0xe, + .tft = 1, /* Tx FIFO threshold */ + .rft = 8, /* Rx FIFO threshold */ + .clk_freq = 400000, /* fast mode operation */ + .timeout = 200, /* Slave response timeout(ms) */ + .sm = I2C_FREQ_MODE_FAST, +}; + static int __devinit nmk_i2c_probe(struct platform_device *pdev) { int ret = 0; struct resource *res; - struct nmk_i2c_controller *pdata = - pdev->dev.platform_data; + struct nmk_i2c_controller *pdata = pdev->dev.platform_data; struct nmk_i2c_dev *dev; struct i2c_adapter *adap; + if (!pdata) + /* No i2c configuration found, using the default. */ + pdata = &u8500_i2c; + dev = kzalloc(sizeof(struct nmk_i2c_dev), GFP_KERNEL); if (!dev) { dev_err(&pdev->dev, "cannot allocate memory\n");