mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] pinctrl: resurrect verbose pinmux-pins
@ 2012-03-02 16:31 Linus Walleij
  2012-03-02 17:22 ` Stephen Warren
  0 siblings, 1 reply; 5+ messages in thread
From: Linus Walleij @ 2012-03-02 16:31 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel
  Cc: Stephen Warren, Grant Likely, Barry Song, Shawn Guo,
	Thomas Abraham, Dong Aisheng, Rajendra Nayak, Haojian Zhuang,
	Linus Walleij

From: Linus Walleij <linus.walleij@linaro.org>

This reintroduces the verbosity in the pinmux-pins file, now this
file will list all pins, their names, owning device (and if it's
a hog) and also in applicable cases the function and group making
use of that pin right now.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/pinctrl/core.h   |    4 ++++
 drivers/pinctrl/pinmux.c |   34 +++++++++++++++++++++++++++++-----
 2 files changed, 33 insertions(+), 5 deletions(-)

diff --git a/drivers/pinctrl/core.h b/drivers/pinctrl/core.h
index e1dfdb3..0a52e39 100644
--- a/drivers/pinctrl/core.h
+++ b/drivers/pinctrl/core.h
@@ -12,6 +12,7 @@
 #include <linux/pinctrl/pinconf.h>
 
 struct pinctrl_gpio_range;
+struct pinmux_group;
 
 /**
  * struct pinctrl_dev - pin control class device
@@ -77,6 +78,8 @@ struct pinctrl {
  * @dynamic_name: if the name of this pin was dynamically allocated
  * @lock: a lock to protect the descriptor structure
  * @owner: the device holding this pin or NULL of no device has claimed it
+ * @grp: the pinmux group used for this pin if it is used by a pin group
+ *	or NULL
  */
 struct pin_desc {
 	struct pinctrl_dev *pctldev;
@@ -86,6 +89,7 @@ struct pin_desc {
 	/* These fields only added when supporting pinmux drivers */
 #ifdef CONFIG_PINMUX
 	const char *owner;
+	struct pinmux_group *grp;
 #endif
 };
 
diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
index f409f16..5785b09 100644
--- a/drivers/pinctrl/pinmux.c
+++ b/drivers/pinctrl/pinmux.c
@@ -76,11 +76,14 @@ int pinmux_check_ops(struct pinctrl_dev *pctldev)
  * @pin: the pin number in the global pin space
  * @owner: a representation of the owner of this pin; typically the device
  *	name that controls its mux function, or the requested GPIO name
+ * @grp: the pinmux group used for this pin or NULL of it is requested as
+ *	a GPIO pin
  * @gpio_range: the range matching the GPIO pin if this is a request for a
  *	single GPIO pin
  */
 static int pin_request(struct pinctrl_dev *pctldev,
 		       int pin, const char *owner,
+		       struct pinmux_group *grp,
 		       struct pinctrl_gpio_range *gpio_range)
 {
 	struct pin_desc *desc;
@@ -104,6 +107,7 @@ static int pin_request(struct pinctrl_dev *pctldev,
 		goto out;
 	}
 	desc->owner = owner;
+	desc->grp = grp;
 	spin_unlock(&desc->lock);
 
 	/* Let each pin increase references to this module */
@@ -181,6 +185,7 @@ static const char *pin_free(struct pinctrl_dev *pctldev, int pin,
 	spin_lock(&desc->lock);
 	owner = desc->owner;
 	desc->owner = NULL;
+	desc->grp = NULL;
 	spin_unlock(&desc->lock);
 	module_put(pctldev->owner);
 
@@ -208,7 +213,7 @@ int pinmux_request_gpio(struct pinctrl_dev *pctldev,
 	if (!owner)
 		return -EINVAL;
 
-	ret = pin_request(pctldev, pin, owner, range);
+	ret = pin_request(pctldev, pin, owner, NULL, range);
 	if (ret < 0)
 		kfree(owner);
 
@@ -259,10 +264,12 @@ int pinmux_gpio_direction(struct pinctrl_dev *pctldev,
  * @pctldev: the device to take the pins on
  * @owner: a representation of the owner of this pin; typically the device
  *	name that controls its mux function
+ * @grp: the pinmux group that will use the pins
  * @group_selector: the group selector containing the pins to acquire
  */
 static int acquire_pins(struct pinctrl_dev *pctldev,
 			const char *owner,
+			struct pinmux_group *grp,
 			unsigned group_selector)
 {
 	const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
@@ -281,7 +288,7 @@ static int acquire_pins(struct pinctrl_dev *pctldev,
 
 	/* Try to allocate all pins in this group, one by one */
 	for (i = 0; i < num_pins; i++) {
-		ret = pin_request(pctldev, pins[i], owner, NULL);
+		ret = pin_request(pctldev, pins[i], owner, grp, NULL);
 		if (ret) {
 			dev_err(pctldev->dev,
 				"could not get request pin %d on device %s - conflicting mux mappings?\n",
@@ -485,7 +492,7 @@ static int pinmux_enable_muxmap(struct pinctrl_dev *pctldev,
 		return -ENOMEM;
 	grp->func_selector = func_selector;
 	grp->group_selector = group_selector;
-	ret = acquire_pins(pctldev, devname, group_selector);
+	ret = acquire_pins(pctldev, devname, grp, group_selector);
 	if (ret) {
 		kfree(grp);
 		return ret;
@@ -606,13 +613,25 @@ static int pinmux_functions_show(struct seq_file *s, void *what)
 	return 0;
 }
 
+static void pinmux_pins_show_groupinfo(struct seq_file *s,
+				       struct pinctrl_dev *pctldev,
+				       struct pinmux_group *grp)
+{
+	const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
+	const struct pinmux_ops *pmxops = pctldev->desc->pmxops;
+
+	seq_printf(s, " function: \"%s\" group: \"%s\"\n",
+		   pmxops->get_function_name(pctldev, grp->func_selector),
+		   pctlops->get_group_name(pctldev, grp->group_selector));
+}
+
 static int pinmux_pins_show(struct seq_file *s, void *what)
 {
 	struct pinctrl_dev *pctldev = s->private;
 	unsigned i, pin;
 
 	seq_puts(s, "Pinmux settings per pin\n");
-	seq_puts(s, "Format: pin (name): owner\n");
+	seq_puts(s, "Format: pin (name): owner [function]\n");
 
 	/* The pin number can be retrived from the pin controller descriptor */
 	for (i = 0; i < pctldev->desc->npins; i++) {
@@ -629,10 +648,15 @@ 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->grp)
+			pinmux_pins_show_groupinfo(s, pctldev, desc->grp);
+		else
+			seq_printf(s, "\n");
 	}
 
 	return 0;
-- 
1.7.8


^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] pinctrl: resurrect verbose pinmux-pins
  2012-03-02 16:31 [PATCH] pinctrl: resurrect verbose pinmux-pins Linus Walleij
@ 2012-03-02 17:22 ` Stephen Warren
  2012-03-02 17:41   ` Stephen Warren
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Warren @ 2012-03-02 17:22 UTC (permalink / raw)
  To: Linus Walleij, linux-kernel, linux-arm-kernel
  Cc: Grant Likely, Barry Song, Shawn Guo, Thomas Abraham,
	Dong Aisheng, Rajendra Nayak, Haojian Zhuang, Linus Walleij

Linus Walleij wrote at riday, March 02, 2012 9:31 AM:
> From: Linus Walleij <linus.walleij@linaro.org>
> 
> This reintroduces the verbosity in the pinmux-pins file, now this
> file will list all pins, their names, owning device (and if it's
> a hog) and also in applicable cases the function and group making
> use of that pin right now.
> 
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

It'd be nice if we could defer this fix until after all the API rework,
because it'll cause all kinds of conflicts otherwise.

The type "struct pinmux_group" you added to struct pin_desc is removed by
patches in my series. If this patch goes in before my series, it'd be best
if it just stored the char* for the function instead of that type, so the
rework by my patche series will be smaller.

I don't think it make sense to store a "group" as owning a pin; each pin
should be part of one muxing group as defined by the hardware so there isn't
a concept of "which group acquired the pin", just "which function is
programmed on the pin". Even if multiple "virtual groups" contain a pin
(which I think would be a bad idea) then the important information from a
HW perspective is the function and not the arbitrary group name.

-- 
nvpublic


^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] pinctrl: resurrect verbose pinmux-pins
  2012-03-02 17:22 ` Stephen Warren
@ 2012-03-02 17:41   ` Stephen Warren
  2012-03-02 18:24     ` Stephen Warren
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Warren @ 2012-03-02 17:41 UTC (permalink / raw)
  To: Stephen Warren, Linus Walleij, linux-kernel, linux-arm-kernel
  Cc: Grant Likely, Barry Song, Shawn Guo, Thomas Abraham,
	Dong Aisheng, Rajendra Nayak, Haojian Zhuang, Linus Walleij

Stephen Warren wrote at Friday, March 02, 2012 10:22 AM:
> Linus Walleij wrote at riday, March 02, 2012 9:31 AM:
> > From: Linus Walleij <linus.walleij@linaro.org>
> >
> > This reintroduces the verbosity in the pinmux-pins file, now this
> > file will list all pins, their names, owning device (and if it's
> > a hog) and also in applicable cases the function and group making
> > use of that pin right now.
> >
> > Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> 
> It'd be nice if we could defer this fix until after all the API rework,
> because it'll cause all kinds of conflicts otherwise.

Oh, I see this patch is in your for-next branch already before I had a chance
to comment on it. I guess I'll have write a patch to convert the removed struct
type to char*s and rebase on top of it:-(

--
nvpublic


^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] pinctrl: resurrect verbose pinmux-pins
  2012-03-02 17:41   ` Stephen Warren
@ 2012-03-02 18:24     ` Stephen Warren
  2012-03-05 10:15       ` Linus Walleij
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Warren @ 2012-03-02 18:24 UTC (permalink / raw)
  To: Linus Walleij, linux-kernel, linux-arm-kernel
  Cc: Grant Likely, Barry Song, Shawn Guo, Thomas Abraham,
	Dong Aisheng, Rajendra Nayak, Haojian Zhuang, Linus Walleij

Stephen Warren wrote at Friday, March 02, 2012 10:41 AM:
> Stephen Warren wrote at Friday, March 02, 2012 10:22 AM:
> > Linus Walleij wrote at riday, March 02, 2012 9:31 AM:
> > > From: Linus Walleij <linus.walleij@linaro.org>
> > >
> > > This reintroduces the verbosity in the pinmux-pins file, now this
> > > file will list all pins, their names, owning device (and if it's
> > > a hog) and also in applicable cases the function and group making
> > > use of that pin right now.
> > >
> > > Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> >
> > It'd be nice if we could defer this fix until after all the API rework,
> > because it'll cause all kinds of conflicts otherwise.
> 
> Oh, I see this patch is in your for-next branch already before I had a chance
> to comment on it. I guess I'll have write a patch to convert the removed struct
> type to char*s and rebase on top of it:-(

I take that back. Can we please drop this patch and I'll provide an
equivalent in my API rework series?

The main reason is that before the API rework (i.e. what's currently in
pinctrl's for-next branch where the patch was written), the function/group
are set during pinctrl_get(state), whereas after the API rework they aren't
known or set until pinctrl_select_state(state). This is exactly why I
removed the code that saved the function value in the per-pin data-structure
from pinctrl_get() in the first place.

If we don't drop the patch, once of my patches is going to have to
basically include a revert of it, and then a reimplementation of this
patch in the correct place anyway, so we may as well just not apply it
in the first place.

Thanks.

-- 
nvpublic


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] pinctrl: resurrect verbose pinmux-pins
  2012-03-02 18:24     ` Stephen Warren
@ 2012-03-05 10:15       ` Linus Walleij
  0 siblings, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2012-03-05 10:15 UTC (permalink / raw)
  To: Stephen Warren
  Cc: Linus Walleij, linux-kernel, linux-arm-kernel, Grant Likely,
	Barry Song, Shawn Guo, Thomas Abraham, Dong Aisheng,
	Rajendra Nayak, Haojian Zhuang

On Fri, Mar 2, 2012 at 7:24 PM, Stephen Warren <swarren@nvidia.com> wrote:
> Stephen Warren wrote at Friday, March 02, 2012 10:41 AM:
>> Stephen Warren wrote at Friday, March 02, 2012 10:22 AM:
>> > Linus Walleij wrote at riday, March 02, 2012 9:31 AM:
>> > > From: Linus Walleij <linus.walleij@linaro.org>
>> > >
>> > > This reintroduces the verbosity in the pinmux-pins file, now this
>> > > file will list all pins, their names, owning device (and if it's
>> > > a hog) and also in applicable cases the function and group making
>> > > use of that pin right now.
>> > >
>> > > Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
>> >
>> > It'd be nice if we could defer this fix until after all the API rework,
>> > because it'll cause all kinds of conflicts otherwise.
>>
>> Oh, I see this patch is in your for-next branch already before I had a chance
>> to comment on it. I guess I'll have write a patch to convert the removed struct
>> type to char*s and rebase on top of it:-(

Mainly because I saw it as a regression fix.

> I take that back. Can we please drop this patch and I'll provide an
> equivalent in my API rework series?

Yeah no problem, if the rest of the v3 patch set is OK I'll just
remove that patch.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-03-05 10:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-02 16:31 [PATCH] pinctrl: resurrect verbose pinmux-pins Linus Walleij
2012-03-02 17:22 ` Stephen Warren
2012-03-02 17:41   ` Stephen Warren
2012-03-02 18:24     ` Stephen Warren
2012-03-05 10:15       ` Linus Walleij

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®