All of lore.kernel.org
 help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij@linaro.org>
To: "Wang, Kuiying" <kuiying.wang@intel.com>
Cc: Joel Stanley <joel@jms.id.au>, Andrew Jeffery <andrew@aj.id.au>,
	 Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	 "open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
	Andrew Geissler <geissonator@gmail.com>,
	 OpenBMC Maillist <openbmc@lists.ozlabs.org>,
	"Mauery, Vernon" <vernon.mauery@intel.com>,
	 "Feist, James" <james.feist@intel.com>,
	"Yoo, Jae Hyun" <jae.hyun.yoo@intel.com>,
	 "Nguyen, Hai V" <hai.v.nguyen@intel.com>,
	"Khetan, Sharad" <sharad.khetan@intel.com>
Subject: Re: Enable buttons GPIO passthrough
Date: Mon, 28 Jan 2019 14:25:08 +0100	[thread overview]
Message-ID: <CACRpkda6PZnoF83mYeTDYxqaFYLTp2jn=E6WJe6KptRuYbFLuQ@mail.gmail.com> (raw)
In-Reply-To: <959CAFA1E282D14FB901BE9A7BF4E7724E440ABF@shsmsx102.ccr.corp.intel.com>

Hi Kwin!

On Tue, Jan 22, 2019 at 11:39 AM Wang, Kuiying <kuiying.wang@intel.com> wrote:
>
> Hi Linus,
> Let me attach a draft patch, it will be easy to understand.
>
> if someone wanna enable passthrough just need to override like " gpio->chip.direction_passthrough = aspeed_gpio_dir_passthrough;"
> else passthrough is disabled.
>
> In app level, just need to echo "passthrough" to enable passthrough like "echo passthrough > /sys/class/gpio/gpio35/direction"

Sorry, but the sysfs ABI is deprecated since over three years
and we will not add any new interesting features to it. Most
major distributions don't even compile it in to the kernel
anymore.

Your only option to control anything like this from userspace would
be through the new gpio character device ABI, see examples
in tools/gpio to see how to use this new ABI.

>  static int aspeed_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
>  {
>         struct aspeed_gpio *gpio = gpiochip_get_data(gc);
> @@ -1188,6 +1215,7 @@ static int __init aspeed_gpio_probe(struct platform_device *pdev)
>         gpio->chip.parent = &pdev->dev;
>         gpio->chip.direction_input = aspeed_gpio_dir_in;
>         gpio->chip.direction_output = aspeed_gpio_dir_out;
> +       gpio->chip.direction_passthrough = aspeed_gpio_dir_passthrough;

As stated earlier, do not add new callbacks for this. Use the
existing .set_config, extend generic config options with
a passthrough attribute.

> +       else if (sysfs_streq(buf, "passthrough"))
> +               status = gpiod_direction_passthrough(desc);

NACK on this sorry. This is the wrong design approach.

The Aspeed GPIO driver already contains a .set_config
callback. Use this.

It is this function:

static int aspeed_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
                                  unsigned long config)
{
        unsigned long param = pinconf_to_config_param(config);
        u32 arg = pinconf_to_config_argument(config);

        if (param == PIN_CONFIG_INPUT_DEBOUNCE)
                return set_debounce(chip, offset, arg);
        else if (param == PIN_CONFIG_BIAS_DISABLE ||
                        param == PIN_CONFIG_BIAS_PULL_DOWN ||
                        param == PIN_CONFIG_DRIVE_STRENGTH)
                return pinctrl_gpio_set_config(offset, config);
        else if (param == PIN_CONFIG_DRIVE_OPEN_DRAIN ||
                        param == PIN_CONFIG_DRIVE_OPEN_SOURCE)
                /* Return -ENOTSUPP to trigger emulation, as per datasheet */
                return -ENOTSUPP;
        else if (param == PIN_CONFIG_PERSIST_STATE)
                return aspeed_gpio_reset_tolerance(chip, offset, arg);

Here add

else if (param == PIN_CONFIG_PASSTHROUGH)
   ....

And work from there.

Yours,
Linus Walleij

  reply	other threads:[~2019-01-28 13:25 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-11  8:02 Enable buttons GPIO passthrough Wang, Kuiying
2018-12-13  1:21 ` Joel Stanley
2018-12-24  2:56   ` Wang, Kuiying
2019-01-11  9:01   ` Linus Walleij
2019-01-14  2:59     ` Andrew Jeffery
2019-01-14  8:19       ` Linus Walleij
2019-01-15  7:21         ` Wang, Kuiying
2019-01-15 12:04           ` Linus Walleij
2019-01-15  9:52         ` Wang, Kuiying
2019-01-15 12:09           ` Linus Walleij
2019-01-16 14:30             ` Wang, Kuiying
2019-01-21 13:09               ` Linus Walleij
2019-01-22 10:39                 ` Wang, Kuiying
2019-01-28 13:25                   ` Linus Walleij [this message]
2019-01-31 15:11                     ` Wang, Kuiying
2019-02-08 12:01                       ` Linus Walleij
2019-02-11  4:54                         ` Andrew Jeffery
2019-02-11  8:08                           ` Linus Walleij
2019-02-12  3:04                             ` Wang, Kuiying

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='CACRpkda6PZnoF83mYeTDYxqaFYLTp2jn=E6WJe6KptRuYbFLuQ@mail.gmail.com' \
    --to=linus.walleij@linaro.org \
    --cc=andrew@aj.id.au \
    --cc=geissonator@gmail.com \
    --cc=hai.v.nguyen@intel.com \
    --cc=jae.hyun.yoo@intel.com \
    --cc=james.feist@intel.com \
    --cc=joel@jms.id.au \
    --cc=kuiying.wang@intel.com \
    --cc=linux-gpio@vger.kernel.org \
    --cc=openbmc@lists.ozlabs.org \
    --cc=sharad.khetan@intel.com \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=vernon.mauery@intel.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.