mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Shawn Guo <shawn.guo@freescale.com>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: Barry Song <21cnbao@gmail.com>,
	Linus Walleij <linus.walleij@stericsson.com>,
	<linux-kernel@vger.kernel.org>,
	Stephen Warren <swarren@nvidia.com>,
	Linaro Dev <linaro-dev@lists.linaro.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	David Brown <davidb@codeaurora.org>,
	Grant Likely <grant.likely@secretlab.ca>
Subject: Re: [PATCH 2/2] pinctrl: add a generic control interface
Date: Sun, 23 Oct 2011 16:51:14 +0800	[thread overview]
Message-ID: <20111023085113.GC1401@S2100-06.ap.freescale.net> (raw)
In-Reply-To: <CACRpkdYah+MSPCcHKhD+Wh11u2V3XR_3T8aCFxKpL0Znh+gh9g@mail.gmail.com>

On Thu, Oct 20, 2011 at 04:18:49PM +0200, Linus Walleij wrote:
> On Thu, Oct 20, 2011 at 3:10 PM, Shawn Guo <shawn.guo@freescale.com> wrote:
> 
> >> without the common definition from  PIN_CONFIG_PULL to
> >> PIN_CONFIG_USER, many platforms will need to definite them repeatedly.
> >> that is what we hate.
> >>
> > I prefer to completely leave the encoding of this 'u32 param' to pinctrl
> > drivers, so that they can map the bit definition of 'param' to the
> > controller register as much as they can. On imx, we have one register
> > accommodating all pin configuration options for one pin, so we can
> > write 'param' directly into register with exactly same bit definition
> > as register.
> 
> I understand this argument, because it makes it more convenient to
> write drivers and you can cut a few corners.
> 
> However I would prefer to keep things more abstract, and the reason
> is that we strive to have drivers reused across SoCs. For example
> drivers/tty/serial/amba-pl011.c is used on a multitude of SoCs,
> U300, Nomadik, Ux500, ARM Versatile, ARM Vexpress, LPC32XX
> etc etc.
> 
> What if this common driver suddenly need to bias a pin? Is it:
> 
> #include <linus/pinctrl/pinctrl.h>
> 
> ret = pin_config(pctldev, pin, PIN_CONFIG_BIAS_HIGH, 0);
> 
> Or (OK silly example but you get the point):
> 
> #include <linus/pinctrl/pinctrl.h>
> 
> if (machine_is_u300())
>     ret = pin_config(pctldev, pin, PIN_CONFIG_U300_BIAS_VDD, 0);
> else if (machine_is_nomadik())
>     ret = pin_config(pctldev, pin, PIN_CONFIG_NOMADIK_BIAS_UP, 0);
> else if (machine_is_ux500())
>     ret = pin_config(pctldev, pin, PIN_CONFIG_UX500_PULLHIGH, 0);
> else if (machine_is_versatile())
>     ret = pin_config(pctldev, pin, PIN_CONFIG_VERSATILE_POW, 0);
> else if (machine_is_vexpress())
>     ret = pin_config(pctldev, pin, PIN_CONFIG_VEXPRESS_XTRA, 0);
> else if (machine_is_lpc32xx())
>     ret = pin_config(pctldev, pin, PIN_CONFIG_LPC_SUPPLY, 0);
> ...
> 
> IMO we have enough strange and custom things in the kernel
> already and we need to make things more abstract, not the least
> so that people can understand what the code is doing.
> 
To me, pin_config() and its parameters should be invisible to client
drivers.  For amba-pl011 example, do you think any of those SoCs will
need multiple sets of uart pin configurations to switch for different
working modes?  If that's case, the individual SoC pinctrl driver
should be responsible for mapping particular pin configuration to
specific pl011 working mode.  Otherwise, the amba-pl011 can simply
call pinmux_enable(...) to have both mux and cfg set up.

-- 
Regards,
Shawn


  reply	other threads:[~2011-10-23  8:40 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-19 16:21 Linus Walleij
2011-10-19 23:04 ` Stephen Warren
2011-10-20  2:45   ` Shawn Guo
2011-10-20 13:44     ` Linus Walleij
2011-10-20 18:41       ` Stephen Warren
2011-10-20 13:46     ` Linus Walleij
2011-10-20 10:24   ` Linus Walleij
2011-10-20 18:46     ` Stephen Warren
2011-10-20  2:31 ` Shawn Guo
2011-10-20  9:17   ` Barry Song
2011-10-20 13:10     ` Shawn Guo
2011-10-20 14:18       ` Linus Walleij
2011-10-23  8:51         ` Shawn Guo [this message]
2011-10-25  4:49           ` Stephen Warren
2011-10-20 14:04     ` Linus Walleij
2011-10-20 14:18       ` Mark Brown
2011-10-20 14:43         ` Linus Walleij
2011-10-20 15:42           ` Mark Brown
2011-10-21 12:28             ` Linus Walleij
2011-10-21 12:30               ` Mark Brown
2011-10-21 12:51                 ` Linus Walleij
2011-10-21 12:55                   ` Mark Brown
2011-10-21 12:57                     ` Linus Walleij
2011-10-21 15:24                       ` Mark Brown
2011-10-20 17:26   ` Stephen Warren
2011-10-23  8:25     ` Shawn Guo
2011-10-25  4:43       ` Stephen Warren

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=20111023085113.GC1401@S2100-06.ap.freescale.net \
    --to=shawn.guo@freescale.com \
    --cc=21cnbao@gmail.com \
    --cc=davidb@codeaurora.org \
    --cc=grant.likely@secretlab.ca \
    --cc=linaro-dev@lists.linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linus.walleij@stericsson.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=swarren@nvidia.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

all inboxes | Powered by JetHome®