From patchwork Thu Jan 24 03:45:11 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Patil, Rachna" X-Patchwork-Id: 2029021 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id D550DDF264 for ; Thu, 24 Jan 2013 03:49:35 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TyDmc-0006xL-LL; Thu, 24 Jan 2013 03:47:22 +0000 Received: from devils.ext.ti.com ([198.47.26.153]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TyDkf-0005vA-0P for linux-arm-kernel@lists.infradead.org; Thu, 24 Jan 2013 03:45:25 +0000 Received: from dbdp20.itg.ti.com ([172.24.170.38]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id r0O3jC5I030431; Wed, 23 Jan 2013 21:45:12 -0600 Received: from DBDE71.ent.ti.com (localhost [127.0.0.1]) by dbdp20.itg.ti.com (8.13.8/8.13.8) with ESMTP id r0O3jBWu002888; Thu, 24 Jan 2013 09:15:11 +0530 (IST) Received: from dbdp32.itg.ti.com (172.24.170.251) by DBDE71.ent.ti.com (172.24.170.149) with Microsoft SMTP Server id 14.1.323.3; Thu, 24 Jan 2013 09:15:11 +0530 Received: from ucmsshproxy.india.ext.ti.com (dbdp20.itg.ti.com [172.24.170.38]) by dbdp32.itg.ti.com (8.13.8/8.13.8) with SMTP id r0O3jAXs016174; Thu, 24 Jan 2013 09:15:10 +0530 Received: from symphony.india.ext.ti.com (unknown [192.168.247.13]) by ucmsshproxy.india.ext.ti.com (Postfix) with ESMTP id 79401158003; Thu, 24 Jan 2013 09:15:10 +0530 (IST) Received: from ubuntu-psp-linux.india.ext.ti.com (ubuntu-psp-linux [192.168.247.46]) by symphony.india.ext.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id r0O3jAR15518; Thu, 24 Jan 2013 09:15:10 +0530 (IST) From: "Patil, Rachna" To: , , , , , , Subject: [PATCH v4 7/8] IIO: ti_am335x_adc: Add DT support Date: Thu, 24 Jan 2013 09:15:11 +0530 Message-ID: <1358999112-31192-8-git-send-email-rachna@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1358999112-31192-1-git-send-email-rachna@ti.com> References: <1358999112-31192-1-git-send-email-rachna@ti.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130123_224521_227515_B73E3065 X-CRM114-Status: GOOD ( 14.23 ) X-Spam-Score: -4.6 (----) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-4.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [198.47.26.153 listed in list.dnswl.org] 3.0 KHOP_BIG_TO_CC Sent to 10+ recipients instaed of Bcc or a list -0.0 SPF_PASS SPF: sender matches SPF record -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Russell King , Samuel Ortiz , Tony Lindgren , Dmitry Torokhov , Dmitry Torokhov , Rob Herring , gururaja.hebbar@ti.com, Grant Likely , Jonathan Cameron , Rob Landley , "Patil, Rachna" , Benit Cousson 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 From: "Patil, Rachna" Add DT support for client ADC driver. Signed-off-by: Patil, Rachna --- Changes in v4: Non-standard properties prefixed with vendor name. drivers/iio/adc/ti_am335x_adc.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c index cd030e1..8e7b089 100644 --- a/drivers/iio/adc/ti_am335x_adc.c +++ b/drivers/iio/adc/ti_am335x_adc.c @@ -22,6 +22,8 @@ #include #include #include +#include +#include #include #include @@ -141,11 +143,12 @@ static int tiadc_probe(struct platform_device *pdev) struct iio_dev *indio_dev; struct tiadc_device *adc_dev; struct ti_tscadc_dev *tscadc_dev = pdev->dev.platform_data; - struct mfd_tscadc_board *pdata; + struct mfd_tscadc_board *pdata = tscadc_dev->dev->platform_data; + struct device_node *node = tscadc_dev->dev->of_node; int err; + u32 val32; - pdata = tscadc_dev->dev->platform_data; - if (!pdata || !pdata->adc_init) { + if (!pdata && !node) { dev_err(&pdev->dev, "Could not find platform data\n"); return -EINVAL; } @@ -159,7 +162,22 @@ static int tiadc_probe(struct platform_device *pdev) adc_dev = iio_priv(indio_dev); adc_dev->mfd_tscadc = tscadc_dev; - adc_dev->channels = pdata->adc_init->adc_channels; + + if (pdata) + adc_dev->channels = pdata->adc_init->adc_channels; + else { + node = of_find_node_by_name(node, "adc"); + if (!node) + return -EINVAL; + else { + err = of_property_read_u32(node, + "ti,adc-channels", &val32); + if (err < 0) + goto err_free_device; + else + adc_dev->channels = val32; + } + } indio_dev->dev.parent = &pdev->dev; indio_dev->name = dev_name(&pdev->dev);