linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij@linaro.org>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Linux Input <linux-input@vger.kernel.org>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 0/5] Make gpio_keys accept board descriptors
Date: Thu, 30 Nov 2017 16:44:05 +0100	[thread overview]
Message-ID: <CACRpkdYCn0EuJSXgzEq3+OFpxPtSkO8AEECnusXympAvmdE9cA@mail.gmail.com> (raw)
In-Reply-To: <20171125233324.afdt4netamvkrkm2@dtor-ws>

On Sun, Nov 26, 2017 at 12:33 AM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:

> I think this is a worthy goal, but I wonder if we could get static GPIO
> descriptors work with fwnode_get_named_gpiod()

I think that will just work, I can try it on something and see.

> so we could retire the
> platform data parsing altogether. We'd need to extend static device
> properties to have notion of children though.

So we are talking about these static device properties I assume?

/**
 * struct gpiod_lookup - lookup table
 * @chip_label: name of the chip the GPIO belongs to
 * @chip_hwnum: hardware number (i.e. relative to the chip) of the GPIO
 * @con_id: name of the GPIO from the device's point of view
 * @idx: index of the GPIO in case several GPIOs share the same name
 * @flags: mask of GPIO_* values
 *
 * gpiod_lookup is a lookup table for associating GPIOs to specific devices and
 * functions using platform data.
 */
struct gpiod_lookup {
        const char *chip_label;
        u16 chip_hwnum;
        const char *con_id;
        unsigned int idx;
        enum gpio_lookup_flags flags;
};

struct gpiod_lookup_table {
        struct list_head list;
        const char *dev_id;
        struct gpiod_lookup table[];
};

The fact that keys are modeled as children in DTS/ACPI DSDT
more of a pecularity to these description languages
providing opaque configuration nodes.

E.g. these children reflects struct gpio_keys_button being a child of
struct gpio_keys_platform_data in the board files. But
it is only one device, "gpio-keys" in the Linux device
model. The buttons/keys are not devices.

Likewise, in device tree the buttons are not really
devices under the "gpio-keys" device, they are just property
nodes in the device tree conveniently set in a hierarchy to
contain the information. I bet ACPI works the same.

Since GPIO descriptors (like clocks, regulators ...) are
associated with the device, this becomes problematic: these
children are not devices. So they need to be associated
with the device to begin with.

In that case, I would opt to just use the
unsigned int idx field for determining child number from
the descriptor table, use con_id for naming the child and
we are back at essentially the same structure as a backend
for fwnode.

Due to the complexity of fwnode requireing an entire
parser for fwnode_operations etc it's a bit of heavy lifting
so I need to think and experiment some more.

Yours,
Linus Walleij

  reply	other threads:[~2017-11-30 15:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-24  9:30 [PATCH 0/5] Make gpio_keys accept board descriptors Linus Walleij
2017-11-24  9:30 ` [PATCH 1/5] Input: gpio-keys: Support getting descriptors from board Linus Walleij
2017-11-24  9:30 ` [PATCH 2/5] gpio: pca953x: Name the gpiochip after the I2C address Linus Walleij
2017-11-24 14:26   ` Andrew Lunn
2017-11-30 14:45     ` Linus Walleij
2017-11-24  9:30 ` [PATCH 3/5] ARM: davinci: Switch DA850EVM to use GPIO descriptors Linus Walleij
2017-11-24  9:30 ` [PATCH 4/5] ARM: imx: Give all GPIO chips a unique name Linus Walleij
2017-11-24  9:30 ` [PATCH 5/5] ARM: imx: Use GPIO descriptors for gpio_keys Linus Walleij
2017-11-25 23:33 ` [PATCH 0/5] Make gpio_keys accept board descriptors Dmitry Torokhov
2017-11-30 15:44   ` Linus Walleij [this message]
2020-08-26 13:20   ` Linus Walleij
2020-08-26 14:35     ` Heikki Krogerus
2020-08-26 16:12       ` Dmitry Torokhov
2020-08-26 23:31         ` Linus Walleij

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=CACRpkdYCn0EuJSXgzEq3+OFpxPtSkO8AEECnusXympAvmdE9cA@mail.gmail.com \
    --to=linus.walleij@linaro.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-input@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).