From patchwork Wed Sep 5 07:33:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 1405771 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id B1D8640220 for ; Wed, 5 Sep 2012 07:36:05 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1T9A76-0005cj-Sm; Wed, 05 Sep 2012 07:33:29 +0000 Received: from mail-ee0-f49.google.com ([74.125.83.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1T9A73-0005cB-OZ for linux-arm-kernel@lists.infradead.org; Wed, 05 Sep 2012 07:33:26 +0000 Received: by eekc13 with SMTP id c13so64218eek.36 for ; Wed, 05 Sep 2012 00:33:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent :x-gm-message-state; bh=8WaV3Anc/+x2bawxndFYm4tyVck7SMEFzUNqTRWL+zE=; b=ocK7fHNCRywiQ4Byl63x+LvYCenecYf4Ly4KyZSmzcOg1PQguCtHlq4PPBnPQXJBYR m/hyBolry99Ghuh5PnDDg3j2IrtZdZwuY3tIRPwGliv7twSPfJkYWmEY6M+seYUe/SH7 5llekpD3YBI8LPtvnxYOYKL8lqmga6t7SrQKXZDST4oFA0f7XYIE4nMKSsvg0qPdTvU5 67rWPxyMm310oRS3i07WM7k+kG97kbwzfMQZLXd9KLaMWzRrJb4Jdj9m6Z7LttJBjpyB 6HtZXAxlg8kQegzbUifgazbgWJ6iss+HWpkZcDxkEtNfXQAO0+ysIzT5Q2GUdZOZM3Kn gJ+g== Received: by 10.14.0.198 with SMTP id 46mr29368805eeb.30.1346830403811; Wed, 05 Sep 2012 00:33:23 -0700 (PDT) Received: from gmail.com (cpc1-aztw13-0-0-cust473.18-1.cable.virginmedia.com. [77.102.241.218]) by mx.google.com with ESMTPS id e7sm1812207eep.2.2012.09.05.00.33.22 (version=SSLv3 cipher=OTHER); Wed, 05 Sep 2012 00:33:23 -0700 (PDT) Date: Wed, 5 Sep 2012 08:33:20 +0100 From: Lee Jones To: Wolfram Sang Subject: Re: [PATCH 3/3] i2c: nomadik: Add Device Tree support to the Nomadik I2C driver Message-ID: <20120905073319.GF4233@gmail.com> References: <1345734087-21803-1-git-send-email-lee.jones@linaro.org> <1345734087-21803-3-git-send-email-lee.jones@linaro.org> <20120831112258.GA2624@pengutronix.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20120831112258.GA2624@pengutronix.de> User-Agent: Mutt/1.5.21 (2010-09-15) X-Gm-Message-State: ALoCoQndjJwb9hvrwevXkGEQG+jp8V07i0vYeRX3qESICTiladKl8CTJ93M0bFANgVU2ympzBQ/K X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.83.49 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: linus.walleij@stericsson.com, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, STEricsson_nomadik_linux@list.st.com, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Author: Lee Jones Date: Mon Aug 6 11:09:57 2012 +0100 i2c: nomadik: Add Device Tree support to the Nomadik I2C driver Here we apply the bindings required for successful Device Tree probing of the i2c-nomadik driver. Cc: linux-i2c@vger.kernel.org Signed-off-by: Lee Jones Reviewed-by: Linus Walleij diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c index 61b00ed..5d1a970 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,18 +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) +{ + of_property_read_u32(np, "clock-frequency", &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 (!pdata) - /* No i2c configuration found, using the default. */ - pdata = &u8500_i2c; + if (!pdata) { + if (np) { + pdata = devm_kzalloc(&adev->dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) { + ret = -ENOMEM; + goto err_no_mem; + } + /* Provide the default configuration as a base. */ + memcpy(pdata, &u8500_i2c, sizeof(struct nmk_i2c_controller)); + nmk_i2c_of_probe(np, pdata); + } else + /* No i2c configuration found, using the default. */ + pdata = &u8500_i2c; + } dev = kzalloc(sizeof(struct nmk_i2c_dev), GFP_KERNEL); if (!dev) { diff --git a/include/linux/platform_data/i2c-nomadik.h b/include/linux/platform_data/i2c-nomadik.h index c2303c3..3a8be9c 100644 --- a/include/linux/platform_data/i2c-nomadik.h +++ b/include/linux/platform_data/i2c-nomadik.h @@ -28,7 +28,7 @@ enum i2c_freq_mode { * @sm: speed mode */ struct nmk_i2c_controller { - unsigned long clk_freq; + u32 clk_freq; unsigned short slsu; unsigned char tft; unsigned char rft;