All of lore.kernel.org
 help / color / mirror / Atom feed
From: Martyn Welch <martyn.welch@ge.com>
To: Linus Walleij <linus.walleij@linaro.org>,
	Kamlakant Patel <kamlakant.patel@linaro.org>,
	Martyn Welch <martyn.welch@gefanuc.com>
Cc: Alexandre Courbot <gnurou@gmail.com>,
	"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>
Subject: Re: [PATCH v1 4/5] gpio: ge: convert to use basic mmio gpio library
Date: Wed, 14 Jan 2015 09:37:53 +0000	[thread overview]
Message-ID: <54B638F1.9080600@ge.com> (raw)
In-Reply-To: <CACRpkdbVgBiciT4RUux7bBxR0dzfp+xv1oxRH6j9K-e6U-uOgQ@mail.gmail.com>

Hi Linus,

Sorry for the delayed response, little bit snowed under.

I'm not going to get a chance to test it, but it looks sane to me. I'm 
happy for this to be applied.

Thanks for your patience,

Martyn

On 09/01/15 09:21, Linus Walleij wrote:
> Martyn,
>
> do you have some feedback on this patch? Can you test it?
> Shall I just apply it?
>
> Yours,
> Linus Walleij
>
> On Mon, Dec 1, 2014 at 1:09 PM,  <kamlakant.patel@linaro.org> wrote:
>> From: Kamlakant Patel <kamlakant.patel@linaro.org>
>>
>> This patch converts GE GPIO driver to use basic_mmio_gpio
>> generic library.
>>
>> Signed-off-by: Kamlakant Patel <kamlakant.patel@linaro.org>
>> ---
>>   drivers/gpio/Kconfig   |  1 +
>>   drivers/gpio/gpio-ge.c | 96 ++++++++++++++++++++------------------------------
>>   2 files changed, 40 insertions(+), 57 deletions(-)
>>
>> diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
>> index 8cbc3ab..35a315d 100644
>> --- a/drivers/gpio/Kconfig
>> +++ b/drivers/gpio/Kconfig
>> @@ -429,6 +429,7 @@ config GPIO_VX855
>>   config GPIO_GE_FPGA
>>          bool "GE FPGA based GPIO"
>>          depends on GE_FPGA
>> +       select GPIO_GENERIC
>>          help
>>            Support for common GPIO functionality provided on some GE Single Board
>>            Computers.
>> diff --git a/drivers/gpio/gpio-ge.c b/drivers/gpio/gpio-ge.c
>> index 1237a73..7579d2e 100644
>> --- a/drivers/gpio/gpio-ge.c
>> +++ b/drivers/gpio/gpio-ge.c
>> @@ -21,7 +21,9 @@
>>   #include <linux/io.h>
>>   #include <linux/of_device.h>
>>   #include <linux/of_gpio.h>
>> +#include <linux/of_address.h>
>>   #include <linux/module.h>
>> +#include <linux/basic_mmio_gpio.h>
>>
>>   #define GEF_GPIO_DIRECT                0x00
>>   #define GEF_GPIO_IN            0x04
>> @@ -33,53 +35,6 @@
>>   #define GEF_GPIO_OVERRUN       0x1C
>>   #define GEF_GPIO_MODE          0x20
>>
>> -static void gef_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
>> -{
>> -       struct of_mm_gpio_chip *mmchip = to_of_mm_gpio_chip(chip);
>> -       unsigned int data;
>> -
>> -       data = ioread32be(mmchip->regs + GEF_GPIO_OUT);
>> -       if (value)
>> -               data = data | BIT(offset);
>> -       else
>> -               data = data & ~BIT(offset);
>> -       iowrite32be(data, mmchip->regs + GEF_GPIO_OUT);
>> -}
>> -
>> -static int gef_gpio_dir_in(struct gpio_chip *chip, unsigned offset)
>> -{
>> -       unsigned int data;
>> -       struct of_mm_gpio_chip *mmchip = to_of_mm_gpio_chip(chip);
>> -
>> -       data = ioread32be(mmchip->regs + GEF_GPIO_DIRECT);
>> -       data = data | BIT(offset);
>> -       iowrite32be(data, mmchip->regs + GEF_GPIO_DIRECT);
>> -
>> -       return 0;
>> -}
>> -
>> -static int gef_gpio_dir_out(struct gpio_chip *chip, unsigned offset, int value)
>> -{
>> -       unsigned int data;
>> -       struct of_mm_gpio_chip *mmchip = to_of_mm_gpio_chip(chip);
>> -
>> -       /* Set value before switching to output */
>> -       gef_gpio_set(mmchip->regs + GEF_GPIO_OUT, offset, value);
>> -
>> -       data = ioread32be(mmchip->regs + GEF_GPIO_DIRECT);
>> -       data = data & ~BIT(offset);
>> -       iowrite32be(data, mmchip->regs + GEF_GPIO_DIRECT);
>> -
>> -       return 0;
>> -}
>> -
>> -static int gef_gpio_get(struct gpio_chip *chip, unsigned offset)
>> -{
>> -       struct of_mm_gpio_chip *mmchip = to_of_mm_gpio_chip(chip);
>> -
>> -       return !!(ioread32be(mmchip->regs + GEF_GPIO_IN) & BIT(offset));
>> -}
>> -
>>   static const struct of_device_id gef_gpio_ids[] = {
>>          {
>>                  .compatible     = "gef,sbc610-gpio",
>> @@ -99,22 +54,49 @@ static int __init gef_gpio_probe(struct platform_device *pdev)
>>   {
>>          const struct of_device_id *of_id =
>>                  of_match_device(gef_gpio_ids, &pdev->dev);
>> -       struct of_mm_gpio_chip *mmchip;
>> +       struct bgpio_chip *bgc;
>> +       void __iomem *regs;
>> +       int ret;
>>
>> -       mmchip = devm_kzalloc(&pdev->dev, sizeof(*mmchip), GFP_KERNEL);
>> -       if (!mmchip)
>> +       bgc = devm_kzalloc(&pdev->dev, sizeof(*bgc), GFP_KERNEL);
>> +       if (!bgc)
>>                  return -ENOMEM;
>>
>> +       regs = of_iomap(pdev->dev.of_node, 0);
>> +       if (!regs)
>> +               return -ENOMEM;
>> +
>> +       ret = bgpio_init(bgc, &pdev->dev, 4, regs + GEF_GPIO_IN,
>> +                        regs + GEF_GPIO_OUT, NULL, NULL,
>> +                        regs + GEF_GPIO_DIRECT, BGPIOF_BIG_ENDIAN_BYTE_ORDER);
>> +       if (ret) {
>> +               dev_err(&pdev->dev, "bgpio_init failed\n");
>> +               goto err0;
>> +       }
>> +
>>          /* Setup pointers to chip functions */
>> -       mmchip->gc.ngpio = (u16)(uintptr_t)of_id->data;
>> -       mmchip->gc.of_gpio_n_cells = 2;
>> -       mmchip->gc.direction_input = gef_gpio_dir_in;
>> -       mmchip->gc.direction_output = gef_gpio_dir_out;
>> -       mmchip->gc.get = gef_gpio_get;
>> -       mmchip->gc.set = gef_gpio_set;
>> +       bgc->gc.label = kstrdup(pdev->dev.of_node->full_name, GFP_KERNEL);
>> +       if (!bgc->gc.label)
>> +               goto err0;
>> +
>> +       bgc->gc.base = -1;
>> +       bgc->gc.ngpio = (u16)(uintptr_t)of_id->data;
>> +       bgc->gc.of_gpio_n_cells = 2;
>> +       bgc->gc.of_node = pdev->dev.of_node;
>>
>>          /* This function adds a memory mapped GPIO chip */
>> -       return of_mm_gpiochip_add(pdev->dev.of_node, mmchip);
>> +       ret = gpiochip_add(&bgc->gc);
>> +       if (ret)
>> +               goto err1;
>> +
>> +       return 0;
>> +err1:
>> +       kfree(bgc->gc.label);
>> +err0:
>> +       iounmap(regs);
>> +       pr_err("%s: GPIO chip registration failed\n",
>> +                       pdev->dev.of_node->full_name);
>> +       return ret;
>>   };
>>
>>   static struct platform_driver gef_gpio_driver = {
>> --
>> 1.9.1
>>

-- 
Martyn Welch (Lead Software Engineer)  | Registered in England and Wales
GE Intelligent Platforms               | (3828642) at 100 Barbirolli Square
T +44(0)1327322748                     | Manchester, M2 3AB
E martyn.welch@ge.com                  | VAT:GB 927559189

  reply	other threads:[~2015-01-14 11:01 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-01 12:09 [PATCH v1 0/5] convert to use basic mmio gpio library kamlakant.patel
2014-12-01 12:09 ` [PATCH v1 1/5] gpio: moxart: " kamlakant.patel
2014-12-04  9:17   ` Alexandre Courbot
2014-12-16  5:17     ` Kamlakant Patel
2014-12-17  2:33       ` Alexandre Courbot
2015-01-09  9:25   ` Linus Walleij
2014-12-01 12:09 ` [PATCH v1 2/5] gpio: timberdale: " kamlakant.patel
2015-01-09  9:16   ` Linus Walleij
2014-12-01 12:09 ` [PATCH v1 3/5] gpio: iop: " kamlakant.patel
2015-01-09  9:19   ` Linus Walleij
2015-01-12 13:39     ` Arnaud Patard
2014-12-01 12:09 ` [PATCH v1 4/5] gpio: ge: " kamlakant.patel
2015-01-09  9:21   ` Linus Walleij
2015-01-14  9:37     ` Martyn Welch [this message]
2015-01-16 15:26   ` Linus Walleij
2014-12-01 12:09 ` [PATCH v1 5/5] gpio: document " kamlakant.patel
2014-12-04  9:12   ` Alexandre Courbot
2014-12-04 12:22     ` Kamlakant Patel
2014-12-18 13:44       ` Kamlakant Patel
2015-01-14  5:22         ` Alexandre Courbot

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=54B638F1.9080600@ge.com \
    --to=martyn.welch@ge.com \
    --cc=gnurou@gmail.com \
    --cc=kamlakant.patel@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=martyn.welch@gefanuc.com \
    /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.