From patchwork Thu May 17 13:45:06 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 8738 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 5C88523E23 for ; Thu, 17 May 2012 13:45:56 +0000 (UTC) Received: from mail-yx0-f180.google.com (mail-yx0-f180.google.com [209.85.213.180]) by fiordland.canonical.com (Postfix) with ESMTP id 171BFA183E2 for ; Thu, 17 May 2012 13:45:56 +0000 (UTC) Received: by yenq6 with SMTP id q6so2146812yen.11 for ; Thu, 17 May 2012 06:45:55 -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=FzLiefT5WL5XUxGszrTGISl1GPAy6NobMX3S1XfT/tA=; b=Ns++VzO0K5WmAjVwIJSTE3UxNZBXNWpit0U2JoJsyqCFhwQay1dBTMaTeMaXswiB7m /2kLu8R7OMTepqiD6A9NIJ73mfRkod9yRQjGDy6DUbdoFpZTOzsJsa8gMPHQAh/FcyKD yD51Sho9/b+UiHfPU0GgcbPWnarAhoUEEgThg8Y9GcKrZiZWKICuai/Tyuul87V8Rm3q ZZS7r/gUcBcfPuZ/aBQYvvXq2A4AOb2oifeJ+OTO3LUs4RiakZ/BK24+OND70XSbOn80 Punm49hQok3NpK9Jzu+ymcOXdkH0UrE/No68zdKc3s99o9x0PCtpZ1GJ10W/WVpJnf2b vJWg== Received: by 10.42.119.129 with SMTP id b1mr4292256icr.48.1337262355483; Thu, 17 May 2012 06:45:55 -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.35.72 with SMTP id o8csp28976ibd; Thu, 17 May 2012 06:45:54 -0700 (PDT) Received: by 10.180.107.104 with SMTP id hb8mr18488156wib.8.1337262354246; Thu, 17 May 2012 06:45:54 -0700 (PDT) Received: from mail-wi0-f170.google.com (mail-wi0-f170.google.com [209.85.212.170]) by mx.google.com with ESMTPS id p10si33508516wip.24.2012.05.17.06.45.53 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 17 May 2012 06:45:54 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.170 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.212.170; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.170 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) smtp.mail=lee.jones@linaro.org Received: by wibhm6 with SMTP id hm6so4412808wib.1 for ; Thu, 17 May 2012 06:45:53 -0700 (PDT) Received: by 10.180.92.130 with SMTP id cm2mr18585252wib.4.1337262353338; Thu, 17 May 2012 06:45:53 -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 h8sm21166277wix.4.2012.05.17.06.45.44 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 17 May 2012 06:45:52 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, arnd@arndb.de, linus.walleij@stericsson.com, grant.likely@secretlab.ca, cjb@laptop.org, broonie@opensource.wolfsonmicro.com, sameo@linux.intel.com Cc: Lee Jones , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 01/18] i2c: Add Device Tree support to the Nomadik I2C driver Date: Thu, 17 May 2012 14:45:06 +0100 Message-Id: <1337262323-27692-2-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1337262323-27692-1-git-send-email-lee.jones@linaro.org> References: <1337262323-27692-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQnJKu4Wd5cTxqvqN/Rr6Weook5QC1BFzD9l+Hmfm23HA74No/gfZQWkpsBbWHxVA5M02CVb 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 Cc: linux-kernel@vger.kernel.org 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 5267ab9..cd45563 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"); @@ -1044,6 +1081,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),