From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Warren Subject: [PATCH v3 08/13] gpio/tegra: Add device tree support Date: Thu, 25 Aug 2011 17:43:39 -0600 Message-ID: <1314315824-9687-9-git-send-email-swarren@nvidia.com> References: <1314315824-9687-1-git-send-email-swarren@nvidia.com> Return-path: In-Reply-To: <1314315824-9687-1-git-send-email-swarren@nvidia.com> Sender: linux-kernel-owner@vger.kernel.org To: Grant Likely , Colin Cross , Erik Gilling , Olof Johansson Cc: Russell King , Arnd Bergmann , devicetree-discuss@lists.ozlabs.org, linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Belisko Marek , Jamie Iles , Shawn Guo , Sergei Shtylyov , Linus Walleij , Stephen Warren List-Id: linux-tegra@vger.kernel.org Signed-off-by: Stephen Warren --- drivers/gpio/gpio-tegra.c | 23 ++++++++++++++++++++++- 1 files changed, 22 insertions(+), 1 deletions(-) diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c index 4da4839..a95b23a 100644 --- a/drivers/gpio/gpio-tegra.c +++ b/drivers/gpio/gpio-tegra.c @@ -326,7 +326,6 @@ static struct irq_chip tegra_gpio_irq_chip = { #endif }; - /* This lock class tells lockdep that GPIO irqs are in a different * category than their parents, so it won't report false recursion. */ @@ -371,13 +370,35 @@ static int __init tegra_gpio_probe(struct platform_device *pdev) spin_lock_init(&bank->lvl_lock[j]); } + if (pdev->dev.of_node != NULL) { + const __be32 *gpios; + u32 gpioslen; + + gpios = of_get_property(pdev->dev.of_node, + "nvidia,enabled-gpios", &gpioslen); + if (gpios != NULL) { + gpioslen /= sizeof(*gpios); + for (i = 0; i < gpioslen; i++, gpios++) { + u32 gpio = be32_to_cpup(gpios); + dev_dbg(&pdev->dev, "Enabling GPIO %d\n", gpio); + tegra_gpio_enable(gpio); + } + } + } + return 0; } +static struct of_device_id tegra_gpio_of_match[] __devinitdata = { + { .compatible = "nvidia,tegra20-gpio", }, + { }, +}; + static struct platform_driver tegra_gpio_driver = { .driver = { .name = "tegra-gpio", .owner = THIS_MODULE, + .of_match_table = tegra_gpio_of_match, }, .probe = tegra_gpio_probe, }; -- 1.7.0.4 From mboxrd@z Thu Jan 1 00:00:00 1970 From: swarren@nvidia.com (Stephen Warren) Date: Thu, 25 Aug 2011 17:43:39 -0600 Subject: [PATCH v3 08/13] gpio/tegra: Add device tree support In-Reply-To: <1314315824-9687-1-git-send-email-swarren@nvidia.com> References: <1314315824-9687-1-git-send-email-swarren@nvidia.com> Message-ID: <1314315824-9687-9-git-send-email-swarren@nvidia.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Signed-off-by: Stephen Warren --- drivers/gpio/gpio-tegra.c | 23 ++++++++++++++++++++++- 1 files changed, 22 insertions(+), 1 deletions(-) diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c index 4da4839..a95b23a 100644 --- a/drivers/gpio/gpio-tegra.c +++ b/drivers/gpio/gpio-tegra.c @@ -326,7 +326,6 @@ static struct irq_chip tegra_gpio_irq_chip = { #endif }; - /* This lock class tells lockdep that GPIO irqs are in a different * category than their parents, so it won't report false recursion. */ @@ -371,13 +370,35 @@ static int __init tegra_gpio_probe(struct platform_device *pdev) spin_lock_init(&bank->lvl_lock[j]); } + if (pdev->dev.of_node != NULL) { + const __be32 *gpios; + u32 gpioslen; + + gpios = of_get_property(pdev->dev.of_node, + "nvidia,enabled-gpios", &gpioslen); + if (gpios != NULL) { + gpioslen /= sizeof(*gpios); + for (i = 0; i < gpioslen; i++, gpios++) { + u32 gpio = be32_to_cpup(gpios); + dev_dbg(&pdev->dev, "Enabling GPIO %d\n", gpio); + tegra_gpio_enable(gpio); + } + } + } + return 0; } +static struct of_device_id tegra_gpio_of_match[] __devinitdata = { + { .compatible = "nvidia,tegra20-gpio", }, + { }, +}; + static struct platform_driver tegra_gpio_driver = { .driver = { .name = "tegra-gpio", .owner = THIS_MODULE, + .of_match_table = tegra_gpio_of_match, }, .probe = tegra_gpio_probe, }; -- 1.7.0.4