From: Shawn Guo <shawn.guo@freescale.com>
To: Stefan Agner <stefan@agner.ch>
Cc: linus.walleij@linaro.org, gnurou@gmail.com,
kernel@pengutronix.de, linux-gpio@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, bpringlemeir@nbsps.com
Subject: Re: [PATCH v2 3/5] gpio: vf610: add gpiolib/IRQ chip driver for Vybrid
Date: Thu, 25 Sep 2014 13:55:03 +0800 [thread overview]
Message-ID: <20140925055446.GC6405@dragon> (raw)
In-Reply-To: <81b47949f0806a335f380be916ec88f07b31290a.1411492954.git.stefan@agner.ch>
On Tue, Sep 23, 2014 at 07:37:55PM +0200, Stefan Agner wrote:
> diff --git a/drivers/gpio/gpio-vf610.c b/drivers/gpio/gpio-vf610.c
> new file mode 100644
> index 0000000..6649a13
> --- /dev/null
> +++ b/drivers/gpio/gpio-vf610.c
> @@ -0,0 +1,284 @@
> +/*
> + * vf610 GPIO support through PORT and GPIO module
> + *
> + * Copyright (c) 2014 Toradex AG.
> + *
> + * Author: Stefan Agner <stefan@agner.ch>.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation; either version 2
> + * of the License, or (at your option) any later version.
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + */
> +
> +#include <linux/err.h>
> +#include <linux/init.h>
> +#include <linux/interrupt.h>
> +#include <linux/io.h>
> +#include <linux/irq.h>
> +#include <linux/bitops.h>
> +#include <linux/gpio.h>
You might want to have the headers sort alphabetically.
> +#include <linux/platform_device.h>
> +#include <linux/slab.h>
> +#include <linux/of.h>
> +#include <linux/of_device.h>
> +#include <linux/of_irq.h>
> +#include <linux/module.h>
> +#include <asm-generic/bug.h>
Why do we need this header?
> +
> +
One new line is enough.
> +#define VF610_GPIO_PER_PORT 32
> +
> +struct vf610_gpio_port {
> + struct gpio_chip gc;
> + void __iomem *base;
> + void __iomem *gpio_base;
> + u8 irqc[VF610_GPIO_PER_PORT];
> +};
> +
> +#define GPIO_PDOR 0x00
> +#define GPIO_PSOR 0x04
> +#define GPIO_PCOR 0x08
> +#define GPIO_PTOR 0x0c
> +#define GPIO_PDIR 0x10
> +
> +#define PORT_PCR(n) (n * 0x4)
s/n/(n)
...
> +static int vf610_gpio_probe(struct platform_device *pdev)
> +{
> + struct device *dev = &pdev->dev;
> + struct device_node *np = dev->of_node;
> + struct vf610_gpio_port *port;
> + struct resource *iores;
> + struct gpio_chip *gc;
> + int irq, ret;
> +
> + port = devm_kzalloc(&pdev->dev, sizeof(*port), GFP_KERNEL);
> + if (!port)
> + return -ENOMEM;
> +
> + iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + port->base = devm_ioremap_resource(dev, iores);
> + if (IS_ERR(port->base))
> + return PTR_ERR(port->base);
> +
> + iores = platform_get_resource(pdev, IORESOURCE_MEM, 1);
> + port->gpio_base = devm_ioremap_resource(dev, iores);
> + if (IS_ERR(port->gpio_base))
> + return PTR_ERR(port->gpio_base);
> +
> + irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
Why not platform_get_irq()?
> + if (irq == NO_IRQ)
> + return -ENODEV;
Instead of using NO_IRQ, we should check if irq is a negative value and
propagate the value as the return, something like:
if (irq < 0)
return irq;
Shawn
> +
> + gc = &port->gc;
> + gc->of_node = np;
> + gc->dev = dev;
> + gc->label = "vf610-gpio",
> + gc->ngpio = VF610_GPIO_PER_PORT,
> + gc->base = of_alias_get_id(np, "gpio") * VF610_GPIO_PER_PORT;
> +
> + gc->request = vf610_gpio_request,
> + gc->free = vf610_gpio_free,
> + gc->direction_input = vf610_gpio_direction_input,
> + gc->get = vf610_gpio_get,
> + gc->direction_output = vf610_gpio_direction_output,
> + gc->set = vf610_gpio_set,
> +
> + ret = gpiochip_add(gc);
> + if (ret < 0)
> + return ret;
> +
> + /* Clear the interrupt status register for all GPIO's */
> + vf610_gpio_writel(~0, port->base + PORT_ISFR);
> +
> + ret = gpiochip_irqchip_add(gc, &vf610_gpio_irq_chip, 0,
> + handle_simple_irq, IRQ_TYPE_NONE);
> + if (ret) {
> + dev_err(dev, "failed to add irqchip\n");
> + gpiochip_remove(gc);
> + return ret;
> + }
> + gpiochip_set_chained_irqchip(gc, &vf610_gpio_irq_chip, irq,
> + vf610_gpio_irq_handler);
> +
> + return 0;
> +}
> +
> +static struct platform_driver vf610_gpio_driver = {
> + .driver = {
> + .name = "gpio-vf610",
> + .owner = THIS_MODULE,
> + .of_match_table = vf610_gpio_dt_ids,
> + },
> + .probe = vf610_gpio_probe,
> +};
> +
> +static int __init gpio_vf610_init(void)
> +{
> + return platform_driver_register(&vf610_gpio_driver);
> +}
> +subsys_initcall(gpio_vf610_init);
> +
> +MODULE_AUTHOR("Stefan Agner <stefan@agner.ch>");
> +MODULE_DESCRIPTION("Freescale VF610 GPIO");
> +MODULE_LICENSE("GPL v2");
> --
> 2.1.0
>
WARNING: multiple messages have this Message-ID (diff)
From: shawn.guo@freescale.com (Shawn Guo)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 3/5] gpio: vf610: add gpiolib/IRQ chip driver for Vybrid
Date: Thu, 25 Sep 2014 13:55:03 +0800 [thread overview]
Message-ID: <20140925055446.GC6405@dragon> (raw)
In-Reply-To: <81b47949f0806a335f380be916ec88f07b31290a.1411492954.git.stefan@agner.ch>
On Tue, Sep 23, 2014 at 07:37:55PM +0200, Stefan Agner wrote:
> diff --git a/drivers/gpio/gpio-vf610.c b/drivers/gpio/gpio-vf610.c
> new file mode 100644
> index 0000000..6649a13
> --- /dev/null
> +++ b/drivers/gpio/gpio-vf610.c
> @@ -0,0 +1,284 @@
> +/*
> + * vf610 GPIO support through PORT and GPIO module
> + *
> + * Copyright (c) 2014 Toradex AG.
> + *
> + * Author: Stefan Agner <stefan@agner.ch>.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation; either version 2
> + * of the License, or (at your option) any later version.
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + */
> +
> +#include <linux/err.h>
> +#include <linux/init.h>
> +#include <linux/interrupt.h>
> +#include <linux/io.h>
> +#include <linux/irq.h>
> +#include <linux/bitops.h>
> +#include <linux/gpio.h>
You might want to have the headers sort alphabetically.
> +#include <linux/platform_device.h>
> +#include <linux/slab.h>
> +#include <linux/of.h>
> +#include <linux/of_device.h>
> +#include <linux/of_irq.h>
> +#include <linux/module.h>
> +#include <asm-generic/bug.h>
Why do we need this header?
> +
> +
One new line is enough.
> +#define VF610_GPIO_PER_PORT 32
> +
> +struct vf610_gpio_port {
> + struct gpio_chip gc;
> + void __iomem *base;
> + void __iomem *gpio_base;
> + u8 irqc[VF610_GPIO_PER_PORT];
> +};
> +
> +#define GPIO_PDOR 0x00
> +#define GPIO_PSOR 0x04
> +#define GPIO_PCOR 0x08
> +#define GPIO_PTOR 0x0c
> +#define GPIO_PDIR 0x10
> +
> +#define PORT_PCR(n) (n * 0x4)
s/n/(n)
...
> +static int vf610_gpio_probe(struct platform_device *pdev)
> +{
> + struct device *dev = &pdev->dev;
> + struct device_node *np = dev->of_node;
> + struct vf610_gpio_port *port;
> + struct resource *iores;
> + struct gpio_chip *gc;
> + int irq, ret;
> +
> + port = devm_kzalloc(&pdev->dev, sizeof(*port), GFP_KERNEL);
> + if (!port)
> + return -ENOMEM;
> +
> + iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + port->base = devm_ioremap_resource(dev, iores);
> + if (IS_ERR(port->base))
> + return PTR_ERR(port->base);
> +
> + iores = platform_get_resource(pdev, IORESOURCE_MEM, 1);
> + port->gpio_base = devm_ioremap_resource(dev, iores);
> + if (IS_ERR(port->gpio_base))
> + return PTR_ERR(port->gpio_base);
> +
> + irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
Why not platform_get_irq()?
> + if (irq == NO_IRQ)
> + return -ENODEV;
Instead of using NO_IRQ, we should check if irq is a negative value and
propagate the value as the return, something like:
if (irq < 0)
return irq;
Shawn
> +
> + gc = &port->gc;
> + gc->of_node = np;
> + gc->dev = dev;
> + gc->label = "vf610-gpio",
> + gc->ngpio = VF610_GPIO_PER_PORT,
> + gc->base = of_alias_get_id(np, "gpio") * VF610_GPIO_PER_PORT;
> +
> + gc->request = vf610_gpio_request,
> + gc->free = vf610_gpio_free,
> + gc->direction_input = vf610_gpio_direction_input,
> + gc->get = vf610_gpio_get,
> + gc->direction_output = vf610_gpio_direction_output,
> + gc->set = vf610_gpio_set,
> +
> + ret = gpiochip_add(gc);
> + if (ret < 0)
> + return ret;
> +
> + /* Clear the interrupt status register for all GPIO's */
> + vf610_gpio_writel(~0, port->base + PORT_ISFR);
> +
> + ret = gpiochip_irqchip_add(gc, &vf610_gpio_irq_chip, 0,
> + handle_simple_irq, IRQ_TYPE_NONE);
> + if (ret) {
> + dev_err(dev, "failed to add irqchip\n");
> + gpiochip_remove(gc);
> + return ret;
> + }
> + gpiochip_set_chained_irqchip(gc, &vf610_gpio_irq_chip, irq,
> + vf610_gpio_irq_handler);
> +
> + return 0;
> +}
> +
> +static struct platform_driver vf610_gpio_driver = {
> + .driver = {
> + .name = "gpio-vf610",
> + .owner = THIS_MODULE,
> + .of_match_table = vf610_gpio_dt_ids,
> + },
> + .probe = vf610_gpio_probe,
> +};
> +
> +static int __init gpio_vf610_init(void)
> +{
> + return platform_driver_register(&vf610_gpio_driver);
> +}
> +subsys_initcall(gpio_vf610_init);
> +
> +MODULE_AUTHOR("Stefan Agner <stefan@agner.ch>");
> +MODULE_DESCRIPTION("Freescale VF610 GPIO");
> +MODULE_LICENSE("GPL v2");
> --
> 2.1.0
>
WARNING: multiple messages have this Message-ID (diff)
From: Shawn Guo <shawn.guo@freescale.com>
To: Stefan Agner <stefan@agner.ch>
Cc: <linus.walleij@linaro.org>, <gnurou@gmail.com>,
<kernel@pengutronix.de>, <linux-gpio@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <bpringlemeir@nbsps.com>
Subject: Re: [PATCH v2 3/5] gpio: vf610: add gpiolib/IRQ chip driver for Vybrid
Date: Thu, 25 Sep 2014 13:55:03 +0800 [thread overview]
Message-ID: <20140925055446.GC6405@dragon> (raw)
In-Reply-To: <81b47949f0806a335f380be916ec88f07b31290a.1411492954.git.stefan@agner.ch>
On Tue, Sep 23, 2014 at 07:37:55PM +0200, Stefan Agner wrote:
> diff --git a/drivers/gpio/gpio-vf610.c b/drivers/gpio/gpio-vf610.c
> new file mode 100644
> index 0000000..6649a13
> --- /dev/null
> +++ b/drivers/gpio/gpio-vf610.c
> @@ -0,0 +1,284 @@
> +/*
> + * vf610 GPIO support through PORT and GPIO module
> + *
> + * Copyright (c) 2014 Toradex AG.
> + *
> + * Author: Stefan Agner <stefan@agner.ch>.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation; either version 2
> + * of the License, or (at your option) any later version.
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + */
> +
> +#include <linux/err.h>
> +#include <linux/init.h>
> +#include <linux/interrupt.h>
> +#include <linux/io.h>
> +#include <linux/irq.h>
> +#include <linux/bitops.h>
> +#include <linux/gpio.h>
You might want to have the headers sort alphabetically.
> +#include <linux/platform_device.h>
> +#include <linux/slab.h>
> +#include <linux/of.h>
> +#include <linux/of_device.h>
> +#include <linux/of_irq.h>
> +#include <linux/module.h>
> +#include <asm-generic/bug.h>
Why do we need this header?
> +
> +
One new line is enough.
> +#define VF610_GPIO_PER_PORT 32
> +
> +struct vf610_gpio_port {
> + struct gpio_chip gc;
> + void __iomem *base;
> + void __iomem *gpio_base;
> + u8 irqc[VF610_GPIO_PER_PORT];
> +};
> +
> +#define GPIO_PDOR 0x00
> +#define GPIO_PSOR 0x04
> +#define GPIO_PCOR 0x08
> +#define GPIO_PTOR 0x0c
> +#define GPIO_PDIR 0x10
> +
> +#define PORT_PCR(n) (n * 0x4)
s/n/(n)
...
> +static int vf610_gpio_probe(struct platform_device *pdev)
> +{
> + struct device *dev = &pdev->dev;
> + struct device_node *np = dev->of_node;
> + struct vf610_gpio_port *port;
> + struct resource *iores;
> + struct gpio_chip *gc;
> + int irq, ret;
> +
> + port = devm_kzalloc(&pdev->dev, sizeof(*port), GFP_KERNEL);
> + if (!port)
> + return -ENOMEM;
> +
> + iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + port->base = devm_ioremap_resource(dev, iores);
> + if (IS_ERR(port->base))
> + return PTR_ERR(port->base);
> +
> + iores = platform_get_resource(pdev, IORESOURCE_MEM, 1);
> + port->gpio_base = devm_ioremap_resource(dev, iores);
> + if (IS_ERR(port->gpio_base))
> + return PTR_ERR(port->gpio_base);
> +
> + irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
Why not platform_get_irq()?
> + if (irq == NO_IRQ)
> + return -ENODEV;
Instead of using NO_IRQ, we should check if irq is a negative value and
propagate the value as the return, something like:
if (irq < 0)
return irq;
Shawn
> +
> + gc = &port->gc;
> + gc->of_node = np;
> + gc->dev = dev;
> + gc->label = "vf610-gpio",
> + gc->ngpio = VF610_GPIO_PER_PORT,
> + gc->base = of_alias_get_id(np, "gpio") * VF610_GPIO_PER_PORT;
> +
> + gc->request = vf610_gpio_request,
> + gc->free = vf610_gpio_free,
> + gc->direction_input = vf610_gpio_direction_input,
> + gc->get = vf610_gpio_get,
> + gc->direction_output = vf610_gpio_direction_output,
> + gc->set = vf610_gpio_set,
> +
> + ret = gpiochip_add(gc);
> + if (ret < 0)
> + return ret;
> +
> + /* Clear the interrupt status register for all GPIO's */
> + vf610_gpio_writel(~0, port->base + PORT_ISFR);
> +
> + ret = gpiochip_irqchip_add(gc, &vf610_gpio_irq_chip, 0,
> + handle_simple_irq, IRQ_TYPE_NONE);
> + if (ret) {
> + dev_err(dev, "failed to add irqchip\n");
> + gpiochip_remove(gc);
> + return ret;
> + }
> + gpiochip_set_chained_irqchip(gc, &vf610_gpio_irq_chip, irq,
> + vf610_gpio_irq_handler);
> +
> + return 0;
> +}
> +
> +static struct platform_driver vf610_gpio_driver = {
> + .driver = {
> + .name = "gpio-vf610",
> + .owner = THIS_MODULE,
> + .of_match_table = vf610_gpio_dt_ids,
> + },
> + .probe = vf610_gpio_probe,
> +};
> +
> +static int __init gpio_vf610_init(void)
> +{
> + return platform_driver_register(&vf610_gpio_driver);
> +}
> +subsys_initcall(gpio_vf610_init);
> +
> +MODULE_AUTHOR("Stefan Agner <stefan@agner.ch>");
> +MODULE_DESCRIPTION("Freescale VF610 GPIO");
> +MODULE_LICENSE("GPL v2");
> --
> 2.1.0
>
next prev parent reply other threads:[~2014-09-25 5:55 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-23 17:37 [PATCH v2 0/5] vf610: Add GPIO support Stefan Agner
2014-09-23 17:37 ` Stefan Agner
2014-09-23 17:37 ` [PATCH v2 1/5] pinctrl: imx: detect uninitialized pins Stefan Agner
2014-09-23 17:37 ` Stefan Agner
2014-09-25 2:15 ` Shawn Guo
2014-09-25 2:15 ` Shawn Guo
2014-09-25 2:15 ` Shawn Guo
2014-09-23 17:37 ` [PATCH v2 2/5] pinctrl: imx: add gpio pinmux support for vf610 Stefan Agner
2014-09-23 17:37 ` Stefan Agner
2014-09-25 2:47 ` Shawn Guo
2014-09-25 2:47 ` Shawn Guo
2014-09-25 2:47 ` Shawn Guo
2014-09-25 7:00 ` Stefan Agner
2014-09-25 7:00 ` Stefan Agner
2014-09-25 9:07 ` Shawn Guo
2014-09-25 9:07 ` Shawn Guo
2014-09-25 9:07 ` Shawn Guo
2014-09-25 9:36 ` Stefan Agner
2014-09-25 9:36 ` Stefan Agner
2014-09-25 16:43 ` Bill Pringlemeir
2014-09-25 16:43 ` Bill Pringlemeir
2014-09-26 10:50 ` Stefan Agner
2014-09-26 10:50 ` Stefan Agner
2014-09-29 15:05 ` Bill Pringlemeir
2014-09-29 15:05 ` Bill Pringlemeir
2014-09-29 15:05 ` Bill Pringlemeir
2014-09-29 17:25 ` Stefan Agner
2014-09-29 17:25 ` Stefan Agner
2014-09-23 17:37 ` [PATCH v2 3/5] gpio: vf610: add gpiolib/IRQ chip driver for Vybrid Stefan Agner
2014-09-23 17:37 ` Stefan Agner
2014-09-23 17:37 ` Stefan Agner
2014-09-25 5:55 ` Shawn Guo [this message]
2014-09-25 5:55 ` Shawn Guo
2014-09-25 5:55 ` Shawn Guo
2014-09-25 8:10 ` Stefan Agner
2014-09-25 8:10 ` Stefan Agner
2014-09-23 17:37 ` [PATCH v2 4/5] ARM: dts: vf610: use new GPIO support Stefan Agner
2014-09-23 17:37 ` Stefan Agner
2014-09-23 17:37 ` [PATCH v2 5/5] Documentation: dts: Add bindings for Vybrid GPIO/PORT module Stefan Agner
2014-09-23 17:37 ` Stefan Agner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140925055446.GC6405@dragon \
--to=shawn.guo@freescale.com \
--cc=bpringlemeir@nbsps.com \
--cc=gnurou@gmail.com \
--cc=kernel@pengutronix.de \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stefan@agner.ch \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.