From patchwork Mon Jun 11 15:25:02 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 9201 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 8109A23EB4 for ; Mon, 11 Jun 2012 15:25:42 +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 50976A186CC for ; Mon, 11 Jun 2012 15:25:42 +0000 (UTC) Received: by mail-gg0-f180.google.com with SMTP id f1so2843382ggn.11 for ; Mon, 11 Jun 2012 08:25:42 -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=CrZ4l66tcLEVrtYqmsTDuAEbjpykBWbCsi6noHx5kSQ=; b=iYcHxg8tQVMeNPU6yJGJ4OLXdq7Y4gNxjygA++9CzVQ17mw5PD+UEzavGtpQDMIuRq QwoIHfvtSPgPqzXYSul3c/R3V3EFgVnjjCt4z77SjbK02bc1BMp2X/Nj9RLXeWKqIQT5 /DwsTPKniFwUWbg3V8x/q+mHtEQ5SlRgIiXkGAcW4ZmidVQcwATfBZfr0Sob9Q60Tasi mm4WDfpwHwD0z4ONMltzkpsQwv7QwMrD3+gmcCBYdEZajIqqfmrqk3/rEHgVcJAV5Gmw 0V0siJjkHnXvyui1zfhwZlHhLnxj4CoPK3Q3QruBoOxXkKLmdybEx6G3kyl7yvhTMH/A B+VQ== Received: by 10.50.163.99 with SMTP id yh3mr6495439igb.53.1339428341784; Mon, 11 Jun 2012 08:25:41 -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.231.24.148 with SMTP id v20csp115738ibb; Mon, 11 Jun 2012 08:25:40 -0700 (PDT) Received: by 10.204.129.17 with SMTP id m17mr10402578bks.4.1339428340380; Mon, 11 Jun 2012 08:25:40 -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 n17si24385167wee.46.2012.06.11.08.25.39 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 11 Jun 2012 08:25:40 -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 ds11so3345479wgb.31 for ; Mon, 11 Jun 2012 08:25:39 -0700 (PDT) Received: by 10.216.208.80 with SMTP id p58mr6375453weo.139.1339428339631; Mon, 11 Jun 2012 08:25:39 -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 ch9sm39413606wib.8.2012.06.11.08.25.37 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 11 Jun 2012 08:25:38 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: linus.walleij@stericsson.com, arnd@arndb.de, grant.likely@secretlab.ca, Lee Jones , linux-i2c@vger.kernel.org Subject: [PATCH 09/14] i2c: Add Device Tree support to the Nomadik I2C driver Date: Mon, 11 Jun 2012 16:25:02 +0100 Message-Id: <1339428307-3850-10-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1339428307-3850-1-git-send-email-lee.jones@linaro.org> References: <1339428307-3850-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQlBE7KgSW1ngoY6/GopbrXW06N0P8Lu0jL6PCTQBDcoN/7mfWfvQ+9K8mjg/RT9oVz1arbP Here we move the i2c-nomadik's default settings into the driver rather than specifying them from platform code. At the time of this writing we only have one user, the u8500. As new users are added, it is expected that they will be Device Tree compliant. If this is the case, we will look up their initialisation values by compatible entry, then apply them forthwith. Cc: linux-i2c@vger.kernel.org Acked-by: Linus Walleij Signed-off-by: Lee Jones --- drivers/i2c/busses/i2c-nomadik.c | 40 +++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c index a92440d..1ffdf67 100644 --- a/drivers/i2c/busses/i2c-nomadik.c +++ b/drivers/i2c/busses/i2c-nomadik.c @@ -23,6 +23,7 @@ #include #include #include +#include #include @@ -899,15 +900,51 @@ static const struct i2c_algorithm nmk_i2c_algo = { .functionality = nmk_i2c_functionality }; +static struct nmk_i2c_controller u8500_i2c = { + /* + * slave data setup time, which is + * 250 ns,100ns,10ns which is 14,6,2 + * respectively for a 48 Mhz + * i2c clock + */ + .slsu = 0xe, + /* Tx FIFO threshold */ + .tft = 1, + /* Rx FIFO threshold */ + .rft = 8, + /* std. mode operation */ + .clk_freq = 100000, + /* Slave response timeout(ms) */ + .timeout = 200, + .sm = I2C_FREQ_MODE_FAST, +}; + + +static const struct of_device_id nmk_gpio_match[] = { + { .compatible = "st,nomadik-i2c", .data = &u8500_i2c, }, + {} +}; + static int __devinit nmk_i2c_probe(struct platform_device *pdev) { int ret = 0; struct resource *res; - struct nmk_i2c_controller *pdata = + const struct nmk_i2c_controller *pdata = pdev->dev.platform_data; + const struct of_device_id *of_id = + of_match_device(nmk_gpio_match, &pdev->dev); struct nmk_i2c_dev *dev; struct i2c_adapter *adap; + if (!pdata) { + if (of_id && of_id->data) + /* Looks like we're booting via Device Tree. */ + pdata = of_id->data; + else + /* 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"); @@ -1043,6 +1080,7 @@ static struct platform_driver nmk_i2c_driver = { .owner = THIS_MODULE, .name = DRIVER_NAME, .pm = &nmk_i2c_pm, + .of_match_table = nmk_gpio_match, }, .probe = nmk_i2c_probe, .remove = __devexit_p(nmk_i2c_remove),