From: Stephen Warren <swarren@nvidia.com>
To: Linus Walleij <linus.walleij@linaro.org>
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>,
Stephen Warren <swarren@nvidia.com>
Subject: [PATCH V3 6/7] pinctrl: Show selected function and group in pinmux-pins debugfs
Date: Fri, 2 Mar 2012 13:05:49 -0700 [thread overview]
Message-ID: <1330718750-15217-7-git-send-email-swarren@nvidia.com> (raw)
In-Reply-To: <1330718750-15217-1-git-send-email-swarren@nvidia.com>
Until recently, the pinctrl pinmux-pins debugfs file displayed the
selected function for each owned pin. This feature was removed during
restructing in support of recent API rework. This change restoreds this
feature, and also displays the group that the function was selected on,
in case a pin is a member of multiple groups.
Based on work by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
v3: New patch
---
drivers/pinctrl/core.h | 2 +
drivers/pinctrl/pinmux.c | 68 +++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 69 insertions(+), 1 deletions(-)
diff --git a/drivers/pinctrl/core.h b/drivers/pinctrl/core.h
index 1cae372..5b3ff13 100644
--- a/drivers/pinctrl/core.h
+++ b/drivers/pinctrl/core.h
@@ -126,6 +126,7 @@ struct pinctrl_setting {
* @owner: The name of the entity owning the pin. Typically, this is the name
* of the device that called pinctrl_get(). Alternatively, it may be the
* name of the GPIO passed to pinctrl_request_gpio().
+ * @mux_setting: The most recent selected mux setting for this pin, if any.
*/
struct pin_desc {
struct pinctrl_dev *pctldev;
@@ -135,6 +136,7 @@ struct pin_desc {
#ifdef CONFIG_PINMUX
unsigned usecount;
const char *owner;
+ const struct pinctrl_setting_mux *mux_setting;
#endif
};
diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
index 4852ebe..86e4017 100644
--- a/drivers/pinctrl/pinmux.c
+++ b/drivers/pinctrl/pinmux.c
@@ -187,6 +187,7 @@ static const char *pin_free(struct pinctrl_dev *pctldev, int pin,
owner = desc->owner;
desc->owner = NULL;
+ desc->mux_setting = NULL;
module_put(pctldev->owner);
return owner;
@@ -378,7 +379,34 @@ void pinmux_free_setting(struct pinctrl_setting const *setting)
int pinmux_enable_setting(struct pinctrl_setting const *setting)
{
struct pinctrl_dev *pctldev = setting->pctldev;
+ const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
const struct pinmux_ops *ops = pctldev->desc->pmxops;
+ int ret;
+ const unsigned *pins;
+ unsigned num_pins;
+ int i;
+ struct pin_desc *desc;
+
+ ret = pctlops->get_group_pins(pctldev, setting->data.mux.group,
+ &pins, &num_pins);
+ if (ret) {
+ /* errors only affect debug data, so just warn */
+ dev_warn(pctldev->dev,
+ "could not get pins for group selector %d\n",
+ setting->data.mux.group);
+ num_pins = 0;
+ }
+
+ for (i = 0; i < num_pins; i++) {
+ desc = pin_desc_get(pctldev, pins[i]);
+ if (desc == NULL) {
+ dev_warn(pctldev->dev,
+ "could not get pin desc for pin %d\n",
+ pins[i]);
+ continue;
+ }
+ desc->mux_setting = &(setting->data.mux);
+ }
return ops->enable(pctldev, setting->data.mux.func,
setting->data.mux.group);
@@ -387,7 +415,34 @@ int pinmux_enable_setting(struct pinctrl_setting const *setting)
void pinmux_disable_setting(struct pinctrl_setting const *setting)
{
struct pinctrl_dev *pctldev = setting->pctldev;
+ const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
const struct pinmux_ops *ops = pctldev->desc->pmxops;
+ int ret;
+ const unsigned *pins;
+ unsigned num_pins;
+ int i;
+ struct pin_desc *desc;
+
+ ret = pctlops->get_group_pins(pctldev, setting->data.mux.group,
+ &pins, &num_pins);
+ if (ret) {
+ /* errors only affect debug data, so just warn */
+ dev_warn(pctldev->dev,
+ "could not get pins for group selector %d\n",
+ setting->data.mux.group);
+ num_pins = 0;
+ }
+
+ for (i = 0; i < num_pins; i++) {
+ desc = pin_desc_get(pctldev, pins[i]);
+ if (desc == NULL) {
+ dev_warn(pctldev->dev,
+ "could not get pin desc for pin %d\n",
+ pins[i]);
+ continue;
+ }
+ desc->mux_setting = NULL;
+ }
ops->disable(pctldev, setting->data.mux.func, setting->data.mux.group);
}
@@ -433,6 +488,8 @@ static int pinmux_functions_show(struct seq_file *s, void *what)
static int pinmux_pins_show(struct seq_file *s, void *what)
{
struct pinctrl_dev *pctldev = s->private;
+ const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
+ const struct pinmux_ops *pmxops = pctldev->desc->pmxops;
unsigned i, pin;
seq_puts(s, "Pinmux settings per pin\n");
@@ -455,10 +512,19 @@ static int pinmux_pins_show(struct seq_file *s, void *what)
!strcmp(desc->owner, pinctrl_dev_get_name(pctldev)))
is_hog = true;
- seq_printf(s, "pin %d (%s): %s%s\n", pin,
+ seq_printf(s, "pin %d (%s): %s%s", pin,
desc->name ? desc->name : "unnamed",
desc->owner ? desc->owner : "UNCLAIMED",
is_hog ? " (HOG)" : "");
+
+ if (desc->mux_setting)
+ seq_printf(s, " function %s group %s\n",
+ pmxops->get_function_name(pctldev,
+ desc->mux_setting->func),
+ pctlops->get_group_name(pctldev,
+ desc->mux_setting->group));
+ else
+ seq_printf(s, "\n");
}
mutex_unlock(&pinctrl_mutex);
--
1.7.0.4
next prev parent reply other threads:[~2012-03-02 20:06 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-02 20:05 [PATCH V3 0/7] pinctrl: API rework, pinconfig in mapping table, Stephen Warren
2012-03-02 20:05 ` [PATCH V3 1/7] pinctrl: Fix and simplify locking Stephen Warren
2012-03-02 20:05 ` [PATCH V3 2/7] pinctrl: Refactor struct pinctrl handling in core.c vs pinmux.c Stephen Warren
2012-03-02 20:05 ` [PATCH V3 3/7] pinctrl: Add usecount to pins for muxing Stephen Warren
2012-03-02 20:05 ` [PATCH V3 4/7] pinctrl: API changes to support multiple states per device Stephen Warren
2012-03-05 8:03 ` Dong Aisheng
2012-03-02 20:05 ` [PATCH V3 5/7] pinctrl: Enhance mapping table to support pin config operations Stephen Warren
2012-03-02 20:05 ` Stephen Warren [this message]
2012-03-02 20:05 ` [PATCH V3 7/7] pinctrl: fix case of Tegra30's foo_groups[] arrays Stephen Warren
2012-03-05 10:34 ` Linus Walleij
2012-03-05 18:15 ` Stephen Warren
2012-03-05 10:39 ` [PATCH V3 0/7] pinctrl: API rework, pinconfig in mapping table, Linus Walleij
2012-03-05 18:25 ` 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=1330718750-15217-7-git-send-email-swarren@nvidia.com \
--to=swarren@nvidia.com \
--cc=B29396@freescale.com \
--cc=dongas86@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linus.walleij@stericsson.com \
--cc=linux-kernel@vger.kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawn.guo@linaro.org \
--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 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®