From patchwork Thu Sep 1 17:21:18 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benoit Cousson X-Patchwork-Id: 1119732 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p81HMVIH025019 for ; Thu, 1 Sep 2011 17:22:33 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755872Ab1IARWc (ORCPT ); Thu, 1 Sep 2011 13:22:32 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:35297 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755085Ab1IARWa (ORCPT ); Thu, 1 Sep 2011 13:22:30 -0400 Received: from dlep36.itg.ti.com ([157.170.170.91]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id p81HMOE9030051 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 1 Sep 2011 12:22:24 -0500 Received: from dlep26.itg.ti.com (smtp-le.itg.ti.com [157.170.170.27]) by dlep36.itg.ti.com (8.13.8/8.13.8) with ESMTP id p81HMORT019992; Thu, 1 Sep 2011 12:22:24 -0500 (CDT) Received: from DLEE74.ent.ti.com (localhost [127.0.0.1]) by dlep26.itg.ti.com (8.13.8/8.13.8) with ESMTP id p81HMOcn017789; Thu, 1 Sep 2011 12:22:24 -0500 (CDT) Received: from dlelxv22.itg.ti.com (172.17.1.197) by DLEE74.ent.ti.com (157.170.170.8) with Microsoft SMTP Server id 14.1.323.3; Thu, 1 Sep 2011 12:22:24 -0500 Received: from localhost.localdomain (lncpu04.tif.ti.com [137.167.102.15]) by dlelxv22.itg.ti.com (8.13.8/8.13.8) with ESMTP id p81HLa50016431; Thu, 1 Sep 2011 12:22:22 -0500 From: Benoit Cousson To: , CC: , , , , Benoit Cousson Subject: [PATCH 02/13] i2c: OMAP: Add DT support for i2c controller Date: Thu, 1 Sep 2011 19:21:18 +0200 Message-ID: <1314897689-17791-3-git-send-email-b-cousson@ti.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1314897689-17791-1-git-send-email-b-cousson@ti.com> References: <1314897689-17791-1-git-send-email-b-cousson@ti.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Thu, 01 Sep 2011 17:22:33 +0000 (UTC) From: G, Manjunath Kondaiah Add initial DT support to retrieve the frequency using a DT attribute instead of the pdata pointer if CONFIG_OF is enabled. These changes will not affect non DT builds and existing functionality is retained. Signed-off-by: G, Manjunath Kondaiah [b-cousson@ti.com: fix the wrong freq calculation] Signed-off-by: Benoit Cousson --- drivers/i2c/busses/i2c-omap.c | 23 ++++++++++++++++++++--- 1 files changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c index 2a072ff..4052279 100644 --- a/drivers/i2c/busses/i2c-omap.c +++ b/drivers/i2c/busses/i2c-omap.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -972,6 +973,16 @@ static const struct i2c_algorithm omap_i2c_algo = { .functionality = omap_i2c_func, }; +#if defined(CONFIG_OF) +static const struct of_device_id omap_i2c_of_match[] = { + {.compatible = "ti,omap-i2c", }, + {}, +} +MODULE_DEVICE_TABLE(of, omap_i2c_of_match); +#else +#define omap_i2c_of_match NULL +#endif + static int __devinit omap_i2c_probe(struct platform_device *pdev) { @@ -1008,12 +1019,17 @@ omap_i2c_probe(struct platform_device *pdev) goto err_release_region; } + speed = 100; /* Default speed */ if (pdata != NULL) { speed = pdata->clkrate; dev->set_mpu_wkup_lat = pdata->set_mpu_wkup_lat; - } else { - speed = 100; /* Default speed */ - dev->set_mpu_wkup_lat = NULL; +#if defined(CONFIG_OF) + } else if (pdev->dev.of_node) { + u32 prop; + if (!of_property_read_u32(pdev->dev.of_node, "clock-frequency", + &prop)) + speed = prop / 1000; /* convert Hz into kHz */ +#endif } dev->speed = speed; @@ -1178,6 +1194,7 @@ static struct platform_driver omap_i2c_driver = { .name = "omap_i2c", .owner = THIS_MODULE, .pm = OMAP_I2C_PM_OPS, + .of_match_table = omap_i2c_of_match, }, };