diff mbox

[RFC,08/12] gpio/tegra: Add device tree support

Message ID 1313189697-21287-9-git-send-email-swarren@nvidia.com (mailing list archive)
State New, archived
Headers show

Commit Message

Stephen Warren Aug. 12, 2011, 10:54 p.m. UTC
Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 drivers/gpio/gpio-tegra.c |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)

Comments

Belisko Marek Aug. 13, 2011, 9:49 a.m. UTC | #1
On Sat, Aug 13, 2011 at 12:54 AM, Stephen Warren <swarren@nvidia.com> wrote:
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
> ---
>  drivers/gpio/gpio-tegra.c |   31 +++++++++++++++++++++++++++++++
>  1 files changed, 31 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c
> index 4da4839..923b413 100644
> --- a/drivers/gpio/gpio-tegra.c
> +++ b/drivers/gpio/gpio-tegra.c
> @@ -326,6 +326,29 @@ static struct irq_chip tegra_gpio_irq_chip = {
>  #endif
>  };
>
> +#ifdef CONFIG_OF
> +static void __init tegra_gpio_probe_dt(struct platform_device *pdev)
> +{
> +       const __be32 *gpios;
> +       u32 gpioslen;
> +       int i;
> +
> +       gpios = of_get_property(pdev->dev.of_node, "nvidia,gpios", &gpioslen);
> +       if (gpios == NULL)
> +               return;
> +
> +       gpioslen /= sizeof(*gpios);
> +       for (i = 0; i < gpioslen; i++, gpios++) {
> +               u32 gpio = be32_to_cpup(gpios);
> +               dev_err(&pdev->dev, "Enabling GPIO %d\n", gpio);
Is really necessary to print all enabled gpio's to console? Also seen
same in pinmux probe.
> +               tegra_gpio_enable(gpio);
> +       }
> +}
> +#else
> +static inline void __init tegra_gpio_probe_dt(struct platform_device *pdev)
> +{
> +}
> +#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 +394,21 @@ static int __init tegra_gpio_probe(struct platform_device *pdev)
>                        spin_lock_init(&bank->lvl_lock[j]);
>        }
>
> +       tegra_gpio_probe_dt(pdev);
> +
>        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
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>

regards,

marek
Stephen Warren Aug. 15, 2011, 3:47 p.m. UTC | #2
Belisko Marek wrote at Saturday, August 13, 2011 3:49 AM:
> On Sat, Aug 13, 2011 at 12:54 AM, Stephen Warren <swarren@nvidia.com> wrote:
> > Signed-off-by: Stephen Warren <swarren@nvidia.com>
> > ---
> >  drivers/gpio/gpio-tegra.c |   31 +++++++++++++++++++++++++++++++
> >  1 files changed, 31 insertions(+), 0 deletions(-)
> >
> > diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c
...
> > +static void __init tegra_gpio_probe_dt(struct platform_device *pdev)
> > +{
> > +       const __be32 *gpios;
> > +       u32 gpioslen;
> > +       int i;
> > +
> > +       gpios = of_get_property(pdev->dev.of_node, "nvidia,gpios", &gpioslen);
> > +       if (gpios == NULL)
> > +               return;
> > +
> > +       gpioslen /= sizeof(*gpios);
> > +       for (i = 0; i < gpioslen; i++, gpios++) {
> > +               u32 gpio = be32_to_cpup(gpios);
> > +               dev_err(&pdev->dev, "Enabling GPIO %d\n", gpio);
>
> Is really necessary to print all enabled gpio's to console? Also seen
> same in pinmux probe.

Oops, that's certainly not necessary. That was debugging code, and I meant
to convert to dev_dbg before posting.
diff mbox

Patch

diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c
index 4da4839..923b413 100644
--- a/drivers/gpio/gpio-tegra.c
+++ b/drivers/gpio/gpio-tegra.c
@@ -326,6 +326,29 @@  static struct irq_chip tegra_gpio_irq_chip = {
 #endif
 };
 
+#ifdef CONFIG_OF
+static void __init tegra_gpio_probe_dt(struct platform_device *pdev)
+{
+	const __be32 *gpios;
+	u32 gpioslen;
+	int i;
+
+	gpios = of_get_property(pdev->dev.of_node, "nvidia,gpios", &gpioslen);
+	if (gpios == NULL)
+		return;
+
+	gpioslen /= sizeof(*gpios);
+	for (i = 0; i < gpioslen; i++, gpios++) {
+		u32 gpio = be32_to_cpup(gpios);
+		dev_err(&pdev->dev, "Enabling GPIO %d\n", gpio);
+		tegra_gpio_enable(gpio);
+	}
+}
+#else
+static inline void __init tegra_gpio_probe_dt(struct platform_device *pdev)
+{
+}
+#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 +394,21 @@  static int __init tegra_gpio_probe(struct platform_device *pdev)
 			spin_lock_init(&bank->lvl_lock[j]);
 	}
 
+	tegra_gpio_probe_dt(pdev);
+
 	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,
 };