All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dong Aisheng <aisheng.dong@freescale.com>
To: Stephen Warren <swarren@nvidia.com>
Cc: Linus Walleij <linus.walleij@stericsson.com>,
	<B29396@freescale.com>, <s.hauer@pengutronix.de>,
	<dongas86@gmail.com>, <shawn.guo@linaro.org>,
	<thomas.abraham@linaro.org>, <tony@atomide.com>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 20/20] pinctrl: Enhance mapping table to support pin config operations
Date: Mon, 27 Feb 2012 20:21:18 +0800	[thread overview]
Message-ID: <20120227122117.GA15593@shlinux2.ap.freescale.net> (raw)
In-Reply-To: <1329720360-23227-21-git-send-email-swarren@nvidia.com>

On Sun, Feb 19, 2012 at 11:46:00PM -0700, Stephen Warren wrote:
> The pinctrl mapping table can now contain entries to:
> * Set the mux function of a pin group
> * Apply a set of pin config options to a pin or a group
> 
> This allows pinctrl_select_state() to apply pin configs settings as well
> as mux settings.
> 
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
....
> -       PIN_MAP("default", "pinctrl-foo", "i2c0", "foo-i2c.0"),
> +	PIN_MAP_MUX_GROUP("foo-i2c.o", "default", "pinctrl-foo", NULL, "i2c0"),
> +};
> +
> +The mapping table may also contain pin configuration entries. It's common for
> +each pin/group to have a number of configuration entries that affect it, so
> +the table entries for configuration reference an array of config parameters
> +and values. An example using the convenience macros is shown below:
> +
> +static unsigned long i2c_grp_configs[] = {
> +	FOO_PIN_DRIVEN,
> +	FOO_PIN_PULLUP,
> +};
> +
> +static unsigned long i2c_pin_configs[] = {
> +	FOO_OPEN_COLLECTOR,
> +	FOO_SLEW_RATE_SLOW,
> +};
> +
> +static struct pinctrl_map __initdata mapping[] = {
> +	PIN_MAP_MUX_GROUP("foo-i2c.0", "default", "pinctrl-foo", "i2c0", "i2c0"),
> +	PIN_MAP_MUX_CONFIGS_GROUP("foo-i2c.0", "default", "pinctrl-foo", "i2c0", i2c_grp_configs),
> +	PIN_MAP_MUX_CONFIGS_PIN("foo-i2c.0", "default", "pinctrl-foo", "i2c0scl", i2c_pin_configs),
> +	PIN_MAP_MUX_CONFIGS_PIN("foo-i2c.0", "default", "pinctrl-foo", "i2c0sda", i2c_pin_configs),
I still have not read all over this patch.
But one question i'm considering is that
will this way here also work for "virtual" group?
For example, the virtual group "i2c_grp_configs" may actually contains
the config for each pin in that group?
The core will handle this difference or let each driver to handle it?

> @@ -1022,7 +1074,7 @@ Since it may be common to request the core to hog a few always-applicable
>  mux settings on the primary pin controller, there is a convenience macro for
>  this:
>  
> -PIN_MAP_SYS_HOG("active", "pinctrl-foo", "power_func")
Hmm?
Why remove this one?

> +PIN_MAP_MUX_GROUP("pinctrl-foo", "active", "pinctrl-foo", NULL, "power_func")
>  
>  This gives the exact same result as the above construction.
>  
> diff --git a/arch/arm/mach-u300/core.c b/arch/arm/mach-u300/core.c
> index eb79a49..599aa79 100644
> --- a/arch/arm/mach-u300/core.c
> +++ b/arch/arm/mach-u300/core.c
> @@ -1554,13 +1554,13 @@ static struct platform_device pinmux_device = {
>  /* Pinmux settings */
>  static struct pinctrl_map __initdata u300_pinmux_map[] = {
>  	/* anonymous maps for chip power and EMIFs */
> -	PIN_MAP_SYS_HOG("default", "pinmux-u300", "power"),
> -	PIN_MAP_SYS_HOG("default", "pinmux-u300", "emif0"),
> -	PIN_MAP_SYS_HOG("default", "pinmux-u300", "emif1"),
> +	PIN_MAP_MUX_GROUP("pinmux-u300", "default", "pinmux-u300", NULL, "power"),
> +	PIN_MAP_MUX_GROUP("pinmux-u300", "default", "pinmux-u300", NULL, "emif0"),
> +	PIN_MAP_MUX_GROUP("pinmux-u300", "default", "pinmux-u300", NULL, "emif1"),
>  	/* per-device maps for MMC/SD, SPI and UART */
> -	PIN_MAP("default", "pinmux-u300", "mmc0", "mmci"),
> -	PIN_MAP("default", "pinmux-u300", "spi0", "pl022"),
> -	PIN_MAP("default", "pinmux-u300", "uart0", "uart0"),
> +	PIN_MAP_MUX_GROUP("mmci",  "default", "pinmux-u300", NULL, "mmc0"),
> +	PIN_MAP_MUX_GROUP("pl022", "default", "pinmux-u300", NULL, "spi0"),
> +	PIN_MAP_MUX_GROUP("uart0", "default", "pinmux-u300", NULL, "uart0"),
>  };
>  
>  struct u300_mux_hog {
> diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
> index bab1a69..af4ebe9 100644
> --- a/drivers/pinctrl/core.c
> +++ b/drivers/pinctrl/core.c
> @@ -341,6 +341,31 @@ int pinctrl_get_group_selector(struct pinctrl_dev *pctldev,
>  }
>  
>  /**
> + * pinctrl_get_pin_id() - returns the group selector for a group
> + * @pctldev: the pin controller handling the group
> + * @pin_group: the pin group to look up
The comment seems not correct here.

> + */
> +int pinctrl_get_pin_id(struct pinctrl_dev *pctldev,
> +		       const char *pin)
> +{
> +	unsigned int i;
> +
> +	for (i = 0; i < pctldev->desc->npins; i++) {
> +		if (pctldev->desc->pins[i].name == NULL)
> +			continue;
> +		if (!strcmp(pin, pctldev->desc->pins[i].name)) {
> +			dev_dbg(pctldev->dev, "found pin id %u for %s\n",
> +				i, pin);
> +			return i;
It looks actually this is not a PIN id.
It's just the index of the pin array.
Pin has its own id:
struct pinctrl_pin_desc {
	unsigned number;
	const char *name;
};

>  static int pin_config_get_for_pin(struct pinctrl_dev *pctldev, unsigned pin,
>  			   unsigned long *config)
>  {
> @@ -260,8 +278,154 @@ unlock:
>  }
>  EXPORT_SYMBOL(pin_config_group_set);
>  
> +int pinconf_map_to_setting(struct pinctrl_map const *map,
> +			  struct pinctrl_setting *setting)
> +{
> +	struct pinctrl_dev *pctldev = setting->pctldev;
> +
> +	switch (setting->type) {
> +	case PIN_MAP_TYPE_CONFIGS_PIN:
> +		setting->data.configs.group_or_pin =
> +			pinctrl_get_pin_id(pctldev,
> +					   map->data.configs.group_or_pin);
> +		if (setting->data.configs.group_or_pin < 0)
> +			return setting->data.configs.group_or_pin;
> +		break;
> +		break;
Two break here.

Regards
Dong Aisheng


  parent reply	other threads:[~2012-02-27 12:14 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-20  6:45 [PATCH 00/20] pinctrl: API change, config in mapping table Stephen Warren
2012-02-20  6:45 ` [PATCH 01/20] pinctrl: pinctrl_register_mappings() shouldn't be __init Stephen Warren
2012-02-20 21:01   ` Linus Walleij
2012-02-20  6:45 ` [PATCH 02/20] pinctrl: use list_add_tail instead of list_add Stephen Warren
2012-02-20 21:03   ` Linus Walleij
2012-02-20  6:45 ` [PATCH 03/20] pinctrl: Store mapping table as a list of chunks Stephen Warren
2012-02-20 21:08   ` Linus Walleij
2012-02-20  6:45 ` [PATCH 04/20] pinctrl: Record a pin owner, not mux function, when requesting pins Stephen Warren
2012-02-20 21:15   ` Linus Walleij
2012-02-21 17:23     ` Stephen Warren
2012-02-22  6:17       ` Linus Walleij
2012-02-20  6:45 ` [PATCH 05/20] pinctrl: Re-order pinmux.[ch] to match each-other Stephen Warren
2012-02-20 21:17   ` Linus Walleij
2012-02-20  6:45 ` [PATCH 06/20] pinctrl: Re-order pinconf.[ch] " Stephen Warren
2012-02-20 21:18   ` Linus Walleij
2012-02-20  6:45 ` [PATCH 07/20] pinctrl: core.c/h cleanups Stephen Warren
2012-02-20 21:20   ` Linus Walleij
2012-02-20  6:45 ` [PATCH 08/20] pinctrl: Assume map table entries can't have a NULL name field Stephen Warren
2012-02-20 21:42   ` Linus Walleij
2012-02-21 13:09     ` Dong Aisheng
2012-02-21 13:12       ` Linus Walleij
2012-02-21 17:46     ` Stephen Warren
2012-02-22  6:13       ` Linus Walleij
2012-02-22  6:34       ` Dong Aisheng
2012-02-22 18:05         ` Stephen Warren
2012-02-23  3:35           ` Dong Aisheng
2012-02-23  3:39             ` Stephen Warren
2012-02-23  3:56               ` Dong Aisheng
2012-02-23  3:53                 ` Stephen Warren
2012-02-23  4:48                   ` Dong Aisheng
2012-02-23 16:39                     ` Stephen Warren
2012-02-24  8:40                       ` Dong Aisheng
2012-02-21 13:08   ` Dong Aisheng
2012-02-21 17:38     ` Stephen Warren
2012-02-22  6:21       ` Dong Aisheng
2012-02-20  6:45 ` [PATCH 09/20] pinctrl: Disallow map table entries with NULL dev_name field Stephen Warren
2012-02-20 21:49   ` Linus Walleij
2012-02-22  6:46   ` Dong Aisheng
2012-02-20  6:45 ` [PATCH 10/20] pinctrl: Assume map table entries can't have a NULL ctrl_dev_name field Stephen Warren
2012-02-21 13:36   ` Linus Walleij
2012-02-22  6:49   ` Dong Aisheng
2012-02-20  6:45 ` [PATCH 11/20] pinctrl: Downgrade pinctrl_get warning when no maps are found Stephen Warren
2012-02-21 13:51   ` Linus Walleij
2012-02-22  5:54     ` Shawn Guo
2012-02-22  6:56     ` Dong Aisheng
2012-02-22 17:21       ` Stephen Warren
2012-02-23  3:48         ` Dong Aisheng
2012-02-20  6:45 ` [PATCH 12/20] pinctrl: Use dev_*() instead of pr_*(), add some msgs, minor cleanups Stephen Warren
2012-02-22  6:23   ` Linus Walleij
2012-02-22  7:01   ` Dong Aisheng
2012-02-20  6:45 ` [PATCH 13/20] pinctrl: Error if mapping table's control dev can't be found Stephen Warren
2012-02-21 13:58   ` Linus Walleij
2012-02-21 17:50     ` Stephen Warren
2012-02-20  6:45 ` [PATCH 14/20] pinctrl: Allocate sizeof(*p) instead of sizeof(struct foo) Stephen Warren
2012-02-22  6:25   ` Linus Walleij
2012-02-22  7:04   ` Dong Aisheng
2012-02-20  6:45 ` [PATCH 15/20] pinctrl: Fix and simplify locking Stephen Warren
2012-02-22 17:38   ` Linus Walleij
2012-02-22 18:26     ` Stephen Warren
2012-02-23  0:18       ` Stephen Warren
2012-02-20  6:45 ` [PATCH 16/20] pinctrl: Refactor struct pinctrl handling in core.c vs pinmux.c Stephen Warren
2012-02-22 17:18   ` Linus Walleij
2012-02-24 16:55   ` Dong Aisheng
2012-02-20  6:45 ` [PATCH 17/20] pinctrl: Add usecount to pins for muxing Stephen Warren
2012-02-22 17:21   ` Linus Walleij
2012-02-27  7:11   ` Dong Aisheng
2012-02-27 18:21     ` Stephen Warren
2012-02-20  6:45 ` [PATCH 18/20] pinctrl: Fix pinconf_groups_show() to emit newline Stephen Warren
2012-02-22 17:43   ` Linus Walleij
2012-02-20  6:45 ` [PATCH 19/20] pinctrl: API changes to support multiple states per device Stephen Warren
2012-02-23  5:54   ` Linus Walleij
2012-02-23 16:46     ` Stephen Warren
2012-02-27  9:07   ` Dong Aisheng
2012-02-27 18:37     ` Stephen Warren
2012-02-28  3:18       ` Dong Aisheng
2012-02-28 17:04         ` Stephen Warren
2012-02-29  2:26           ` Dong Aisheng
2012-02-20  6:46 ` [PATCH 20/20] pinctrl: Enhance mapping table to support pin config operations Stephen Warren
2012-02-23  6:08   ` Linus Walleij
2012-02-23 16:48     ` Stephen Warren
2012-02-23 21:13     ` Stephen Warren
2012-02-27 12:21   ` Dong Aisheng [this message]
2012-02-27 19:02     ` Stephen Warren
2012-02-28  3:41       ` Dong Aisheng
2012-02-20 21:51 ` [PATCH 00/20] pinctrl: API change, config in mapping table 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=20120227122117.GA15593@shlinux2.ap.freescale.net \
    --to=aisheng.dong@freescale.com \
    --cc=B29396@freescale.com \
    --cc=dongas86@gmail.com \
    --cc=linus.walleij@stericsson.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=shawn.guo@linaro.org \
    --cc=swarren@nvidia.com \
    --cc=thomas.abraham@linaro.org \
    --cc=tony@atomide.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.