From: Tony Lindgren <tony@atomide.com> To: linus.walleij@linaro.org Cc: linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Stephen Warren <swarren@wwwdotorg.org> Subject: [PATCH 2/4] pinctrl: Allow pinctrl to have multiple active states Date: Tue, 16 Jul 2013 02:05:34 -0700 [thread overview] Message-ID: <20130716090534.5541.60381.stgit@localhost> (raw) In-Reply-To: <20130716090310.5541.36777.stgit@localhost> It's quite common that we need to dynamically change some pins for a device for runtime PM, or toggle a pin between rx and tx. Changing all the pins for a device is not efficient way of doing it. So let's allow setting up multiple active states for pinctrl. Currently we only need PINCTRL_STATIC and PINCTRL_DYNAMIC, where PINCTRL_STATIC covers the current default pins, and PINCTRL_DYNAMIC holds the dynamic pins that need to be toggled. Cc: Stephen Warren <swarren@wwwdotorg.org> Signed-off-by: Tony Lindgren <tony@atomide.com> --- drivers/pinctrl/core.c | 18 ++++++++++-------- drivers/pinctrl/core.h | 10 ++++++++-- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index bda2c61..8da11d5 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c @@ -885,7 +885,8 @@ static void pinctrl_free(struct pinctrl *p, bool inlist) mutex_lock(&pinctrl_list_mutex); list_for_each_entry_safe(state, n1, &p->states, node) { list_for_each_entry_safe(setting, n2, &state->settings, node) { - pinctrl_free_setting(state == p->state, setting); + pinctrl_free_setting(state == p->state[PINCTRL_STATIC], + setting); list_del(&setting->node); kfree(setting); } @@ -955,13 +956,13 @@ EXPORT_SYMBOL_GPL(pinctrl_lookup_state); int pinctrl_select_state(struct pinctrl *p, struct pinctrl_state *state) { struct pinctrl_setting *setting, *setting2; - struct pinctrl_state *old_state = p->state; + struct pinctrl_state *old_state = p->state[PINCTRL_STATIC]; int ret; - if (p->state == state) + if (old_state == state) return 0; - if (p->state) { + if (old_state) { /* * The set of groups with a mux configuration in the old state * may not be identical to the set of groups with a mux setting @@ -971,7 +972,7 @@ int pinctrl_select_state(struct pinctrl *p, struct pinctrl_state *state) * but not in the new state, this code puts that group into a * safe/disabled state. */ - list_for_each_entry(setting, &p->state->settings, node) { + list_for_each_entry(setting, &old_state->settings, node) { bool found = false; if (setting->type != PIN_MAP_TYPE_MUX_GROUP) continue; @@ -989,7 +990,7 @@ int pinctrl_select_state(struct pinctrl *p, struct pinctrl_state *state) } } - p->state = NULL; + p->state[PINCTRL_STATIC] = NULL; /* Apply all the settings for the new state */ list_for_each_entry(setting, &state->settings, node) { @@ -1011,7 +1012,7 @@ int pinctrl_select_state(struct pinctrl *p, struct pinctrl_state *state) } } - p->state = state; + p->state[PINCTRL_STATIC] = state; return 0; @@ -1484,7 +1485,8 @@ static int pinctrl_show(struct seq_file *s, void *what) list_for_each_entry(p, &pinctrl_list, node) { seq_printf(s, "device: %s current state: %s\n", dev_name(p->dev), - p->state ? p->state->name : "none"); + p->state[PINCTRL_STATIC] ? + p->state[PINCTRL_STATIC]->name : "none"); list_for_each_entry(state, &p->states, node) { seq_printf(s, " state: %s\n", state->name); diff --git a/drivers/pinctrl/core.h b/drivers/pinctrl/core.h index 75476b3..b99e4b3 100644 --- a/drivers/pinctrl/core.h +++ b/drivers/pinctrl/core.h @@ -53,12 +53,18 @@ struct pinctrl_dev { #endif }; +enum pinctr_states { + PINCTRL_STATIC, + PINCTRL_DYNAMIC, + PINCTRL_NR_STATES, +}; + /** * struct pinctrl - per-device pin control state holder * @node: global list node * @dev: the device using this pin control handle * @states: a list of states for this device - * @state: the current state + * @state: the current state(s) * @dt_maps: the mapping table chunks dynamically parsed from device tree for * this device, if any * @users: reference count @@ -67,7 +73,7 @@ struct pinctrl { struct list_head node; struct device *dev; struct list_head states; - struct pinctrl_state *state; + struct pinctrl_state *state[PINCTRL_NR_STATES]; struct list_head dt_maps; struct kref users; };
WARNING: multiple messages have this Message-ID (diff)
From: tony@atomide.com (Tony Lindgren) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/4] pinctrl: Allow pinctrl to have multiple active states Date: Tue, 16 Jul 2013 02:05:34 -0700 [thread overview] Message-ID: <20130716090534.5541.60381.stgit@localhost> (raw) In-Reply-To: <20130716090310.5541.36777.stgit@localhost> It's quite common that we need to dynamically change some pins for a device for runtime PM, or toggle a pin between rx and tx. Changing all the pins for a device is not efficient way of doing it. So let's allow setting up multiple active states for pinctrl. Currently we only need PINCTRL_STATIC and PINCTRL_DYNAMIC, where PINCTRL_STATIC covers the current default pins, and PINCTRL_DYNAMIC holds the dynamic pins that need to be toggled. Cc: Stephen Warren <swarren@wwwdotorg.org> Signed-off-by: Tony Lindgren <tony@atomide.com> --- drivers/pinctrl/core.c | 18 ++++++++++-------- drivers/pinctrl/core.h | 10 ++++++++-- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index bda2c61..8da11d5 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c @@ -885,7 +885,8 @@ static void pinctrl_free(struct pinctrl *p, bool inlist) mutex_lock(&pinctrl_list_mutex); list_for_each_entry_safe(state, n1, &p->states, node) { list_for_each_entry_safe(setting, n2, &state->settings, node) { - pinctrl_free_setting(state == p->state, setting); + pinctrl_free_setting(state == p->state[PINCTRL_STATIC], + setting); list_del(&setting->node); kfree(setting); } @@ -955,13 +956,13 @@ EXPORT_SYMBOL_GPL(pinctrl_lookup_state); int pinctrl_select_state(struct pinctrl *p, struct pinctrl_state *state) { struct pinctrl_setting *setting, *setting2; - struct pinctrl_state *old_state = p->state; + struct pinctrl_state *old_state = p->state[PINCTRL_STATIC]; int ret; - if (p->state == state) + if (old_state == state) return 0; - if (p->state) { + if (old_state) { /* * The set of groups with a mux configuration in the old state * may not be identical to the set of groups with a mux setting @@ -971,7 +972,7 @@ int pinctrl_select_state(struct pinctrl *p, struct pinctrl_state *state) * but not in the new state, this code puts that group into a * safe/disabled state. */ - list_for_each_entry(setting, &p->state->settings, node) { + list_for_each_entry(setting, &old_state->settings, node) { bool found = false; if (setting->type != PIN_MAP_TYPE_MUX_GROUP) continue; @@ -989,7 +990,7 @@ int pinctrl_select_state(struct pinctrl *p, struct pinctrl_state *state) } } - p->state = NULL; + p->state[PINCTRL_STATIC] = NULL; /* Apply all the settings for the new state */ list_for_each_entry(setting, &state->settings, node) { @@ -1011,7 +1012,7 @@ int pinctrl_select_state(struct pinctrl *p, struct pinctrl_state *state) } } - p->state = state; + p->state[PINCTRL_STATIC] = state; return 0; @@ -1484,7 +1485,8 @@ static int pinctrl_show(struct seq_file *s, void *what) list_for_each_entry(p, &pinctrl_list, node) { seq_printf(s, "device: %s current state: %s\n", dev_name(p->dev), - p->state ? p->state->name : "none"); + p->state[PINCTRL_STATIC] ? + p->state[PINCTRL_STATIC]->name : "none"); list_for_each_entry(state, &p->states, node) { seq_printf(s, " state: %s\n", state->name); diff --git a/drivers/pinctrl/core.h b/drivers/pinctrl/core.h index 75476b3..b99e4b3 100644 --- a/drivers/pinctrl/core.h +++ b/drivers/pinctrl/core.h @@ -53,12 +53,18 @@ struct pinctrl_dev { #endif }; +enum pinctr_states { + PINCTRL_STATIC, + PINCTRL_DYNAMIC, + PINCTRL_NR_STATES, +}; + /** * struct pinctrl - per-device pin control state holder * @node: global list node * @dev: the device using this pin control handle * @states: a list of states for this device - * @state: the current state + * @state: the current state(s) * @dt_maps: the mapping table chunks dynamically parsed from device tree for * this device, if any * @users: reference count @@ -67,7 +73,7 @@ struct pinctrl { struct list_head node; struct device *dev; struct list_head states; - struct pinctrl_state *state; + struct pinctrl_state *state[PINCTRL_NR_STATES]; struct list_head dt_maps; struct kref users; };
next prev parent reply other threads:[~2013-07-16 9:06 UTC|newest] Thread overview: 95+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-07-16 9:05 [PATCH 0/4] improved support for runtime muxing for pinctrl Tony Lindgren 2013-07-16 9:05 ` Tony Lindgren 2013-07-16 9:05 ` [PATCH 1/4] pinctrl: Remove duplicate code in pinctrl_pm_select_state functions Tony Lindgren 2013-07-16 9:05 ` Tony Lindgren 2013-07-16 13:15 ` Grygorii Strashko 2013-07-16 13:15 ` Grygorii Strashko 2013-07-16 13:15 ` Grygorii Strashko 2013-07-16 13:41 ` Tony Lindgren 2013-07-16 13:41 ` Tony Lindgren 2013-07-16 14:25 ` Grygorii Strashko 2013-07-16 14:25 ` Grygorii Strashko 2013-07-16 14:25 ` Grygorii Strashko 2013-07-17 6:31 ` Tony Lindgren 2013-07-17 6:31 ` Tony Lindgren 2013-07-16 9:05 ` Tony Lindgren [this message] 2013-07-16 9:05 ` [PATCH 2/4] pinctrl: Allow pinctrl to have multiple active states Tony Lindgren 2013-07-17 20:55 ` Stephen Warren 2013-07-17 20:55 ` Stephen Warren 2013-07-16 9:05 ` [PATCH 3/4] pinctrl: Add support for additional dynamic states Tony Lindgren 2013-07-16 9:05 ` Tony Lindgren 2013-07-16 9:35 ` Felipe Balbi 2013-07-16 9:35 ` Felipe Balbi 2013-07-16 9:35 ` Felipe Balbi 2013-07-16 12:06 ` Tony Lindgren 2013-07-16 12:06 ` Tony Lindgren 2013-07-17 21:14 ` Stephen Warren 2013-07-17 21:14 ` Stephen Warren 2013-07-18 7:25 ` Tony Lindgren 2013-07-18 7:25 ` Tony Lindgren 2013-07-18 10:53 ` Tony Lindgren 2013-07-18 10:53 ` Tony Lindgren 2013-07-18 19:21 ` Stephen Warren 2013-07-18 19:21 ` Stephen Warren 2013-07-19 7:29 ` Tony Lindgren 2013-07-19 7:29 ` Tony Lindgren 2013-07-19 18:52 ` Stephen Warren 2013-07-19 18:52 ` Stephen Warren 2013-07-29 9:05 ` Tony Lindgren 2013-07-29 9:05 ` Tony Lindgren 2013-07-29 22:01 ` Stephen Warren 2013-07-29 22:01 ` Stephen Warren 2013-08-14 16:41 ` Linus Walleij 2013-08-14 16:41 ` Linus Walleij 2013-08-14 16:41 ` Linus Walleij 2013-07-17 21:23 ` Stephen Warren 2013-07-17 21:23 ` Stephen Warren 2013-07-18 7:36 ` Tony Lindgren 2013-07-18 7:36 ` Tony Lindgren 2013-07-18 19:26 ` Stephen Warren 2013-07-18 19:26 ` Stephen Warren 2013-07-19 7:39 ` Tony Lindgren 2013-07-19 7:39 ` Tony Lindgren 2013-07-19 10:29 ` Grygorii Strashko 2013-07-19 10:29 ` Grygorii Strashko 2013-07-19 10:29 ` Grygorii Strashko 2013-07-19 19:03 ` Stephen Warren 2013-07-19 19:03 ` Stephen Warren 2013-07-22 23:15 ` Linus Walleij 2013-07-22 23:15 ` Linus Walleij 2013-07-22 23:15 ` Linus Walleij 2013-07-29 9:08 ` Tony Lindgren 2013-07-29 9:08 ` Tony Lindgren 2013-07-19 18:58 ` Stephen Warren 2013-07-19 18:58 ` Stephen Warren 2013-07-29 9:21 ` Tony Lindgren 2013-07-29 9:21 ` Tony Lindgren 2013-07-29 22:08 ` Stephen Warren 2013-07-29 22:08 ` Stephen Warren 2013-07-22 23:07 ` Linus Walleij 2013-07-22 23:07 ` Linus Walleij 2013-07-22 23:07 ` Linus Walleij 2013-07-29 9:31 ` Tony Lindgren 2013-07-29 9:31 ` Tony Lindgren 2013-07-29 9:31 ` Tony Lindgren 2013-07-16 9:05 ` [PATCH 4/4] drivers: Add pinctrl handling for dynamic pin states Tony Lindgren 2013-07-16 9:05 ` Tony Lindgren 2013-07-17 21:21 ` Stephen Warren 2013-07-17 21:21 ` Stephen Warren 2013-07-18 7:50 ` Tony Lindgren 2013-07-18 7:50 ` Tony Lindgren 2013-07-18 13:48 ` Tony Lindgren 2013-07-18 13:48 ` Tony Lindgren 2013-07-16 9:14 ` [PATCH 0/4] improved support for runtime muxing for pinctrl Tony Lindgren 2013-07-16 9:14 ` Tony Lindgren 2013-07-17 11:49 ` Grygorii Strashko 2013-07-17 11:49 ` Grygorii Strashko 2013-07-17 11:49 ` Grygorii Strashko 2013-07-18 15:15 [PATCHv2 " Tony Lindgren 2013-07-18 15:15 ` [PATCH 2/4] pinctrl: Allow pinctrl to have multiple active states Tony Lindgren 2013-07-18 15:15 ` Tony Lindgren 2013-07-22 22:54 ` Linus Walleij 2013-07-22 22:54 ` Linus Walleij 2013-07-22 22:54 ` Linus Walleij 2013-07-29 9:45 ` Tony Lindgren 2013-07-29 9:45 ` Tony Lindgren 2013-07-29 9:45 ` Tony Lindgren
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=20130716090534.5541.60381.stgit@localhost \ --to=tony@atomide.com \ --cc=linus.walleij@linaro.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-omap@vger.kernel.org \ --cc=swarren@wwwdotorg.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: linkBe 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.