From patchwork Thu Aug 23 15:01:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 10908 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 1DEEA23F27 for ; Thu, 23 Aug 2012 15:01:46 +0000 (UTC) Received: from mail-ob0-f180.google.com (mail-ob0-f180.google.com [209.85.214.180]) by fiordland.canonical.com (Postfix) with ESMTP id 35538A19040 for ; Thu, 23 Aug 2012 15:01:31 +0000 (UTC) Received: by obceq6 with SMTP id eq6so1760141obc.11 for ; Thu, 23 Aug 2012 08:01:45 -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:in-reply-to:references :x-gm-message-state; bh=ckunbVZjQtfbJzySZmJ0YIehFjx61XNpI70zvsGzPcM=; b=eqkgY1Uz185OaNbP8mIJGt05GyRPQSnPtilz0mSVRZK0aVQg2d12L8YeMjkRaB/1dA 6Cs+ZMvcF6C0Fd0ISDLf5e6aITqJ5aBgmtiEREp/7drxTKfFw4QA6VQ+DKNafEzfe+aD JiNfXs/S7AQobORBHa5SO/WiBUKd0r58ILEKZwpajBwVQ2fy2PWrQ1kKufktO0fSjYau XgiptG1l9OSBRVzegU1KoxtQ1tHGLkxOpDn0Btgz6bcB7ko3Nc+kc6eTaEdCF4ljIZzN h0LeMbqVegPRAcOwQNq2utDZR+7y9LY+TWk9x5KKBOoPN5PzpO+qEaHYyynb2GHwQB19 LfIQ== Received: by 10.50.182.161 with SMTP id ef1mr6369775igc.0.1345734104680; Thu, 23 Aug 2012 08:01:44 -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.184.232 with SMTP id ex8csp266886igc; Thu, 23 Aug 2012 08:01:43 -0700 (PDT) Received: by 10.180.81.165 with SMTP id b5mr15639848wiy.17.1345734102957; Thu, 23 Aug 2012 08:01:42 -0700 (PDT) Received: from mail-wg0-f50.google.com (mail-wg0-f50.google.com [74.125.82.50]) by mx.google.com with ESMTPS id m51si10443202wea.41.2012.08.23.08.01.42 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 23 Aug 2012 08:01:42 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.50 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.82.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.50 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) smtp.mail=lee.jones@linaro.org Received: by mail-wg0-f50.google.com with SMTP id ds11so602145wgb.31 for ; Thu, 23 Aug 2012 08:01:42 -0700 (PDT) Received: by 10.216.226.36 with SMTP id a36mr927953weq.58.1345734102272; Thu, 23 Aug 2012 08:01:42 -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 dv1sm3371017wib.10.2012.08.23.08.01.40 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 23 Aug 2012 08:01:41 -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, Lee Jones , linux-i2c@vger.kernel.org Subject: [PATCH 3/3] i2c: nomadik: Add Device Tree support to the Nomadik I2C driver Date: Thu, 23 Aug 2012 16:01:27 +0100 Message-Id: <1345734087-21803-3-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1345734087-21803-1-git-send-email-lee.jones@linaro.org> References: <1345734087-21803-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQm6Bvi0QWdr7Pd0DRYoZ3NnDOvT4cE2xCz0VwCNqYEcDcfaaPr+Ql/FhuHw8yFeJPdZcW4k Here we apply the bindings required for successful Device Tree probing of the i2c-nomadik driver. Cc: linux-i2c@vger.kernel.org Acked-by: srinidhi kasagar Signed-off-by: Lee Jones --- drivers/i2c/busses/i2c-nomadik.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c index 61b00ed..8168389 100644 --- a/drivers/i2c/busses/i2c-nomadik.c +++ b/drivers/i2c/busses/i2c-nomadik.c @@ -25,6 +25,7 @@ #include #include #include +#include #define DRIVER_NAME "nmk-i2c" @@ -920,15 +921,42 @@ static struct nmk_i2c_controller u8500_i2c = { .sm = I2C_FREQ_MODE_FAST, }; +static void nmk_i2c_of_probe(struct device_node *np, + struct nmk_i2c_controller *pdata) +{ + /* Provide the default configuration as a base. */ + pdata = &u8500_i2c; + + of_property_read_u32(np, "clock-frequency", (u32*)&pdata->clk_freq); + + /* This driver only supports 'standard' and 'fast' modes of operation. */ + if (pdata->clk_freq <= 100000) + pdata->sm = I2C_FREQ_MODE_STANDARD; + else + pdata->sm = I2C_FREQ_MODE_FAST; +} + static atomic_t adapter_id = ATOMIC_INIT(0); static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id) { int ret = 0; struct nmk_i2c_controller *pdata = adev->dev.platform_data; + struct device_node *np = adev->dev.of_node; struct nmk_i2c_dev *dev; struct i2c_adapter *adap; + if (np) { + if (!pdata) { + pdata = devm_kzalloc(&adev->dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) { + ret = -ENOMEM; + goto err_no_mem; + } + } + nmk_i2c_of_probe(np, pdata); + } + if (!pdata) /* No i2c configuration found, using the default. */ pdata = &u8500_i2c;