From patchwork Fri Mar 2 16:31:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 7066 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 5F2331D0E53 for ; Fri, 2 Mar 2012 17:01:56 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 070E0A18444 for ; Fri, 2 Mar 2012 17:01:55 +0000 (UTC) Received: by iage36 with SMTP id e36so3406027iag.11 for ; Fri, 02 Mar 2012 09:01:55 -0800 (PST) Received: from mr.google.com ([10.42.131.129]) by 10.42.131.129 with SMTP id z1mr7296256ics.53.1330707715515 (num_hops = 1); Fri, 02 Mar 2012 09:01:55 -0800 (PST) Received: by 10.42.131.129 with SMTP id z1mr5985325ics.53.1330707715454; Fri, 02 Mar 2012 09:01:55 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.53.18 with SMTP id k18csp14265ibg; Fri, 2 Mar 2012 09:01:54 -0800 (PST) Received: by 10.14.182.2 with SMTP id n2mr4869837eem.75.1330707714270; Fri, 02 Mar 2012 09:01:54 -0800 (PST) Received: from eu1sys200aog105.obsmtp.com (eu1sys200aog105.obsmtp.com. [207.126.144.119]) by mx.google.com with SMTP id s16si5825325eeb.8.2012.03.02.09.01.40 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 02 Mar 2012 09:01:54 -0800 (PST) Received-SPF: neutral (google.com: 207.126.144.119 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.119; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.119 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) smtp.mail=linus.walleij@stericsson.com Received: from beta.dmz-ap.st.com ([138.198.100.35]) (using TLSv1) by eu1sys200aob105.postini.com ([207.126.147.11]) with SMTP ID DSNKT1D88lDmm25aWzBiax7xeOE1TjjhLs78@postini.com; Fri, 02 Mar 2012 17:01:53 UTC Received: from zeta.dmz-ap.st.com (ns6.st.com [138.198.234.13]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id C29F0CB; Fri, 2 Mar 2012 16:22:54 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 03DB08AB; Fri, 2 Mar 2012 16:31:19 +0000 (GMT) Received: from exdcvycastm022.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm022", Issuer "exdcvycastm022" (not verified)) by relay2.stm.gmessaging.net (Postfix) with ESMTPS id 0E7C9A8065; Fri, 2 Mar 2012 17:31:12 +0100 (CET) Received: from steludxu4075.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.30) with Microsoft SMTP Server (TLS) id 8.3.83.0; Fri, 2 Mar 2012 17:31:17 +0100 From: Linus Walleij To: , Cc: Stephen Warren , Grant Likely , Barry Song <21cnbao@gmail.com>, Shawn Guo , Thomas Abraham , Dong Aisheng , Rajendra Nayak , Haojian Zhuang , Linus Walleij Subject: [PATCH] pinctrl: resurrect verbose pinmux-pins Date: Fri, 2 Mar 2012 17:31:13 +0100 Message-ID: <1330705873-10798-1-git-send-email-linus.walleij@stericsson.com> X-Mailer: git-send-email 1.7.8 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQlnAnpVFqwrmoVNDJagZ0/OHof9NnPT/lFjUY2Q68Gq1f/WsvSRXF4mT+YQ0Q1XNwFPR0Wz From: Linus Walleij 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 --- 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 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;