All of lore.kernel.org
 help / color / mirror / Atom feed
From: nikita.shubin@maquefel.me
To: "linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	hsweeten@visionengravers.com,
	Alexander Sverdlin <alexander.sverdlin@gmail.com>,
	bgolaszewski@baylibre.com
Subject: RFC Need advice on reworking gpio-ep93xx.c to DT support
Date: Mon, 22 Mar 2021 15:19:34 +0300	[thread overview]
Message-ID: <1042421616413081@mail.yandex.ru> (raw)

Dear all, after studying the question i've came up with the following suggestion:

- split ep93xx_gpio_resource into per port platform device:

So instead of:
```
static struct resource ep93xx_gpio_resource[] = {
DEFINE_RES_MEM(EP93XX_GPIO_PHYS_BASE, 0xcc),
DEFINE_RES_IRQ(IRQ_EP93XX_GPIO_AB),
DEFINE_RES_IRQ(IRQ_EP93XX_GPIO0MUX),
DEFINE_RES_IRQ(IRQ_EP93XX_GPIO1MUX),
DEFINE_RES_IRQ(IRQ_EP93XX_GPIO2MUX),
DEFINE_RES_IRQ(IRQ_EP93XX_GPIO3MUX),
DEFINE_RES_IRQ(IRQ_EP93XX_GPIO4MUX),
DEFINE_RES_IRQ(IRQ_EP93XX_GPIO5MUX),
DEFINE_RES_IRQ(IRQ_EP93XX_GPIO6MUX),
DEFINE_RES_IRQ(IRQ_EP93XX_GPIO7MUX),
};

static struct platform_device ep93xx_gpio_device = {
.name = "gpio-ep93xx",
.id = -1,
.num_resources = ARRAY_SIZE(ep93xx_gpio_resource),
.resource = ep93xx_gpio_resource,
};
```

We will have something like this for each port:
```
static struct resource ep93xx_gpio_A_resource[] = {
DEFINE_RES_MEM(EP93XX_GPIO_PHYS_BASE + DATA, 0x04),
DEFINE_RES_MEM(EP93XX_GPIO_PHYS_BASE + DIRECTION, 0x04),
DEFINE_RES_MEM(EP93XX_GPIO_PHYS_BASE + INTERRUPT, 0x2c), /** only port A/B/F*/
DEFINE_RES_IRQ(IRQ_EP93XX_GPIO_AB), /** only port A/B*/
... /* IRQS only for port F*/
};

static struct platform_device ep93xx_gpio_A_device = {
.name = "gpio-ep93xx",
.id = -1,
.num_resources = ARRAY_SIZE(ep93xx_gpio_A_resource),
.resource = ep93xx_gpio_A_resource,
};
```

And they will registered separately.

I think this will allow more transparent transition to DT

- rework gpio-ep93xx.c to handle each platform device instance separately
- add processing for the following device tree (example):

Showing only ports A, F and no interrupt capable C:
```
gpio0: gpio@80840000 {
compatible = "cirrus,ep93xx-gpio-a", "cirrus,ep93xx-gpio";
label = "A";
reg = <0x80840000 0x04>,
<0x80840010 0x04>,
<0x80840090 0x1c>;
reg-names = "data", "dir", "int";
gpio-controller;
interrupt-controller;
interrupt-parent = <&vic1>;
interrupts = <27>;
};

gpio2: gpio@80840008 {
compatible = "cirrus,ep93xx-gpio";
label = "C";
reg = <0x80840008 0x04>,
<0x80840018 0x04>;
reg-names = "data", "dir";
gpio-controller;
};

gpio5: gpio@80840030 {
compatible = "cirrus,ep93xx-gpio-f", "cirrus,ep93xx-gpio";
label = "F";
reg = <0x80840030 0x04>,
<0x80840034 0x04>,
<0x8084004C 0x1c>;
reg-names = "data", "dir", "int";
gpio-controller;
interrupt-controller;
interrupts-extended= <&vic0 19 20 21 22>,
<&vic1 15 16 17 18>;
};
```

So the work will be split into 2 stages:
- breaking gpio platform data into pieces, adapting gpio-ep93xx.c
- adding DT support for gpio-ep93xx.c

Please advise me on this issue.

             reply	other threads:[~2021-03-22 12:27 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-22 12:19 nikita.shubin [this message]
2021-03-22 12:25 ` RFC Need advice on reworking gpio-ep93xx.c to DT support Linus Walleij
2021-03-22 15:43 ` Hartley Sweeten
2021-03-22 15:59   ` Alexander Sverdlin
2021-03-22 16:14     ` Hartley Sweeten
2021-03-22 16:48       ` nikita.shubin
2021-03-22 17:00         ` Alexander Sverdlin
2021-03-22 22:31           ` Arnd Bergmann
2021-03-23  6:57             ` Alexander Sverdlin
2021-03-23  8:45               ` Arnd Bergmann
2021-05-25  8:44             ` Geert Uytterhoeven
2021-03-23  8:21     ` Linus Walleij
2021-03-22 16:20   ` nikita.shubin

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=1042421616413081@mail.yandex.ru \
    --to=nikita.shubin@maquefel.me \
    --cc=alexander.sverdlin@gmail.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=hsweeten@visionengravers.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    /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.