From patchwork Mon Oct 31 19:58:54 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Dietrich X-Patchwork-Id: 122932 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id E84B5B6F87 for ; Tue, 1 Nov 2011 06:59:31 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932627Ab1JaT7b (ORCPT ); Mon, 31 Oct 2011 15:59:31 -0400 Received: from mailout-de.gmx.net ([213.165.64.23]:37921 "HELO mailout-de.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S932571Ab1JaT7b (ORCPT ); Mon, 31 Oct 2011 15:59:31 -0400 Received: (qmail invoked by alias); 31 Oct 2011 19:59:29 -0000 Received: from pD9E5C411.dip0.t-ipconnect.de (EHLO localhost.localdomain) [217.229.196.17] by mail.gmx.net (mp049) with SMTP; 31 Oct 2011 20:59:29 +0100 X-Authenticated: #9962044 X-Provags-ID: V01U2FsdGVkX197kWUHNBF7YXFRDORuFYDwHz1qup6GSh9r9/GGlM SpJYOQQxi3YOzU From: Marc Dietrich To: linux-tegra@vger.kernel.org Cc: Olof Johansson , Colin Cross , Stephen Warren , linux-arm-kernel , Marc Dietrich , devel@driverdev.osuosl.org, Greg KH , Julian Andres Klode , Grant Likely Subject: [PATCH 2/3] staging: nvec: add device tree support Date: Mon, 31 Oct 2011 20:58:54 +0100 Message-Id: <04ffd9770698b7efb119b92fa379eb2e2698e223.1320088857.git.marvin24@gmx.de> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: References: In-Reply-To: References: X-Y-GMX-Trusted: 0 Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org This adds device tree support to the nvec driver. By using this method it is no longer necessary to specify platform data through a board file. Cc: devel@driverdev.osuosl.org Cc: Greg KH Cc: Julian Andres Klode Cc: Grant Likely Signed-off-by: Marc Dietrich --- .../devicetree/bindings/nvec/nvec_nvidia.txt | 9 +++++ drivers/staging/nvec/nvec.c | 35 ++++++++++++++++++- 2 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 Documentation/devicetree/bindings/nvec/nvec_nvidia.txt diff --git a/Documentation/devicetree/bindings/nvec/nvec_nvidia.txt b/Documentation/devicetree/bindings/nvec/nvec_nvidia.txt new file mode 100644 index 0000000..5aeee53 --- /dev/null +++ b/Documentation/devicetree/bindings/nvec/nvec_nvidia.txt @@ -0,0 +1,9 @@ +NVIDIA compliant embedded controller + +Required properties: +- compatible : should be "nvidia,nvec". +- reg : the iomem of the i2c slave controller +- interrupts : the interrupt line of the i2c slave controller +- clock-frequency : the frequency of the i2c bus +- gpios : the gpio used for ec request +- slave-addr: the i2c address of the slave controller diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c index e06b867..ffb73c0 100644 --- a/drivers/staging/nvec/nvec.c +++ b/drivers/staging/nvec/nvec.c @@ -27,6 +27,8 @@ #include #include #include +#include +#include #include #include #include @@ -36,6 +38,8 @@ #include #include +#include + #include #include @@ -719,6 +723,7 @@ static int __devinit tegra_nvec_probe(struct platform_device *pdev) struct resource *res; struct resource *iomem; void __iomem *base; + const unsigned int *prop; nvec = kzalloc(sizeof(struct nvec_chip), GFP_KERNEL); if (nvec == NULL) { @@ -727,8 +732,26 @@ static int __devinit tegra_nvec_probe(struct platform_device *pdev) } platform_set_drvdata(pdev, nvec); nvec->dev = &pdev->dev; - nvec->gpio = pdata->gpio; - nvec->i2c_addr = pdata->i2c_addr; + + if (pdata) { + nvec->gpio = pdata->gpio; + nvec->i2c_addr = pdata->i2c_addr; + } else if (nvec->dev->of_node) { + nvec->gpio = of_get_named_gpio(nvec->dev->of_node, "request-gpios", 0); + if (nvec->gpio < 0) { + dev_err(&pdev->dev, "no gpio specified"); + goto failed; + } + prop = of_get_property(nvec->dev->of_node, "slave-addr", NULL); + if (!prop) { + dev_err(&pdev->dev, "no i2c address specified"); + goto failed; + } + nvec->i2c_addr = be32_to_cpup(prop); + } else { + dev_err(&pdev->dev, "no platform data\n"); + goto failed; + } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { @@ -893,6 +916,13 @@ static int tegra_nvec_resume(struct platform_device *pdev) #define tegra_nvec_resume NULL #endif +/* Match table for of_platform binding */ +static const struct of_device_id nvidia_nvec_of_match[] __devinitconst = { + { .compatible = "nvidia,nvec", }, + {}, +}; +MODULE_DEVICE_TABLE(of, nvidia_nvec_of_match); + static struct platform_driver nvec_device_driver = { .probe = tegra_nvec_probe, .remove = __devexit_p(tegra_nvec_remove), @@ -901,6 +931,7 @@ static struct platform_driver nvec_device_driver = { .driver = { .name = "nvec", .owner = THIS_MODULE, + .of_match_table = nvidia_nvec_of_match, } };