From patchwork Mon May 27 19:11:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Sewior X-Patchwork-Id: 2621301 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 2FA8FDFF69 for ; Mon, 27 May 2013 19:12:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756624Ab3E0TMY (ORCPT ); Mon, 27 May 2013 15:12:24 -0400 Received: from www.linutronix.de ([62.245.132.108]:48373 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756785Ab3E0TMX (ORCPT ); Mon, 27 May 2013 15:12:23 -0400 Received: from localhost ([127.0.0.1] helo=localhost.localdomain) by Galois.linutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1Uh2qE-0008KD-9C; Mon, 27 May 2013 21:12:22 +0200 From: Sebastian Andrzej Siewior To: linux-input@vger.kernel.org, linux-iio@vger.kernel.org Cc: Samuel Ortiz , Jonathan Cameron , Dmitry Torokhov , Felipe Balbi , "Patil, Rachna" , Pantelis Antoniou , Sebastian Andrzej Siewior Subject: [PATCH 09/19] mfd: ti_am335x_tscadc: Add DT support Date: Mon, 27 May 2013 21:11:56 +0200 Message-Id: <1369681926-22185-10-git-send-email-bigeasy@linutronix.de> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1369681926-22185-1-git-send-email-bigeasy@linutronix.de> References: <1369681926-22185-1-git-send-email-bigeasy@linutronix.de> X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1, SHORTCIRCUIT=-0.0001 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: "Patil, Rachna" Make changes to add DT support in the MFD core driver. [ panto@antoniou-consulting.com : use of_get_child_by_name instead of of_find_node_by_name ] Signed-off-by: Pantelis Antoniou Signed-off-by: Patil, Rachna Signed-off-by: Felipe Balbi Signed-off-by: Sebastian Andrzej Siewior --- drivers/mfd/ti_am335x_tscadc.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c index e9f3fb5..7a4edc0 100644 --- a/drivers/mfd/ti_am335x_tscadc.c +++ b/drivers/mfd/ti_am335x_tscadc.c @@ -22,6 +22,8 @@ #include #include #include +#include +#include #include #include @@ -64,20 +66,31 @@ static int ti_tscadc_probe(struct platform_device *pdev) struct resource *res; struct clk *clk; struct mfd_tscadc_board *pdata = pdev->dev.platform_data; + struct device_node *node = pdev->dev.of_node; struct mfd_cell *cell; int err, ctrl; int clk_value, clock_rate; - int tsc_wires, adc_channels = 0, total_channels; + int tsc_wires = 0, adc_channels = 0, total_channels; - if (!pdata) { + if (!pdata && !pdev->dev.of_node) { dev_err(&pdev->dev, "Could not find platform data\n"); return -EINVAL; } - if (pdata->adc_init) - adc_channels = pdata->adc_init->adc_channels; + if (pdev->dev.platform_data) { + if (pdata->tsc_init) + tsc_wires = pdata->tsc_init->wires; + + if (pdata->adc_init) + adc_channels = pdata->adc_init->adc_channels; + } else { + node = of_get_child_by_name(pdev->dev.of_node, "tsc"); + of_property_read_u32(node, "ti,wires", &tsc_wires); + + node = of_get_child_by_name(pdev->dev.of_node, "adc"); + of_property_read_u32(node, "ti,adc-channels", &adc_channels); + } - tsc_wires = pdata->tsc_init->wires; total_channels = tsc_wires + adc_channels; if (total_channels > 8) { @@ -256,11 +269,17 @@ static const struct dev_pm_ops tscadc_pm_ops = { #define TSCADC_PM_OPS NULL #endif +static const struct of_device_id ti_tscadc_dt_ids[] = { + { .compatible = "ti,ti-tscadc", }, + { } +}; + static struct platform_driver ti_tscadc_driver = { .driver = { .name = "ti_tscadc", .owner = THIS_MODULE, .pm = TSCADC_PM_OPS, + .of_match_table = of_match_ptr(ti_tscadc_dt_ids), }, .probe = ti_tscadc_probe, .remove = ti_tscadc_remove,