linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij@linaro.org>
To: Yves Lefloch <YvesMarie_Lefloch@sigmadesigns.com>
Cc: Thibaud Cornic <thibaud_cornic@sigmadesigns.com>,
	"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
	Alexandre Courbot <gnurou@gmail.com>, Mason <slash.tmp@free.fr>
Subject: Re: Right amount of info in the DT
Date: Fri, 9 Jun 2017 10:14:52 +0200	[thread overview]
Message-ID: <CACRpkda-ZMMR5WbgVF-BXx1HiYY8VrkLN1QC64fvY4xS4zNUJA@mail.gmail.com> (raw)
In-Reply-To: <d6ac5fea-5324-7321-744f-6b248ac7320c@sigmadesigns.com>

On Wed, May 31, 2017 at 6:36 PM, Yves Lefloch
<YvesMarie_Lefloch@sigmadesigns.com> wrote:

> I tried to carry on and add the other IPs' pins, and I've got a question
> regarding pin requesting.
> See, adding the smartcard's pins was easy because we don't have a driver for
> it yet, so the pins are just straightforward GPIOs, which the user-space can
> request using /sys/class/gpio/export.

Please do not use sysfs for userspace tests, familiarize yourself with
tools/gpio in the kernel and use these for testing using the ioctl()s.

> But that's not the case for the ethernet device, whose pins are already in
> use, although not requested explicitly by its driver
> (drivers/net/ethernet/aurora/nb8800.c). Which means user-space can also
> request/set them within the sysfs, and that is wrong.

It is common that a device allows simultaneous use of a pin for
GPIO and a certain device. (E.g. so that GPIO can "spy" on the pin
or similar.)

If on a certain system, this is not allowed, one shall set
.strict = true on the struct pinmux_ops, see
include/linux/pinctrl/pinmux.h

> - Is there a mechanism in the device tree to automatically request some pins
> for a driver once it gets loaded? I have looked at the `stateN_nodeM' thing
> in the documentation, but that doesn't seem to do the job without changes in
> the ethernet driver's code.

Yes those are called pin control hogs. Then the pins get associated with the
pin controller itself. Try first to associate the pins with the device actually
using them if possible.

> - Should the pins be declared at all if we know they are not going to be used
> for anything else than, for instance, ethernet? What about some removable
> device then, for instance UART as Thibaud pointed out previously?

I guess it depends on how much control of things you need in your system.

Also you might not need it now, but later on it turns out that in order to
properly deal with things like suspend/resume, you all of a sudden need
to switch pin control states when going to sleep and then it is nice if
the driver can handle these pins.

When in doubt, implement a driver for everything you have hardware
registers for, anything that is software controlled, I guess.

Yours,
Linus Walleij

  reply	other threads:[~2017-06-09  8:14 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-20  9:54 Right amount of info in the DT Yves Lefloch
2017-04-24  8:23 ` Linus Walleij
2017-04-24 13:03   ` Yves Lefloch
2017-04-24 16:45     ` Linus Walleij
2017-04-26 15:47       ` Yves Lefloch
2017-05-07 10:26         ` Linus Walleij
2017-05-09 10:49           ` Yves Lefloch
2017-05-11 15:22             ` Linus Walleij
2017-05-12 15:31               ` Yves Lefloch
2017-05-22 15:12                 ` Linus Walleij
2017-05-24  9:41                   ` Thibaud Cornic
2017-05-29 10:02                     ` Linus Walleij
2017-05-30 13:59                       ` Yves Lefloch
2017-05-31  0:24                         ` Linus Walleij
2017-05-31 16:36                           ` Yves Lefloch
2017-06-09  8:14                             ` Linus Walleij [this message]
2017-06-14 13:51                               ` Yves Lefloch

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=CACRpkda-ZMMR5WbgVF-BXx1HiYY8VrkLN1QC64fvY4xS4zNUJA@mail.gmail.com \
    --to=linus.walleij@linaro.org \
    --cc=YvesMarie_Lefloch@sigmadesigns.com \
    --cc=gnurou@gmail.com \
    --cc=linux-gpio@vger.kernel.org \
    --cc=slash.tmp@free.fr \
    --cc=thibaud_cornic@sigmadesigns.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 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).