From: Timur Tabi <timur@codeaurora.org> To: Stephen Boyd <sboyd@codeaurora.org> Cc: Linus Walleij <linus.walleij@linaro.org>, Andy Gross <andy.gross@linaro.org>, David Brown <david.brown@linaro.org>, anjiandi@codeaurora.org, Bjorn Andersson <bjorn.andersson@linaro.org>, "linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>, "linux-arm-kernel@lists.infradead.org" <linux-arm-kernel@lists.infradead.org>, "linux-arm-msm@vger.kernel.org" <linux-arm-msm@vger.kernel.org>, "thierry.reding@gmail.com" <thierry.reding@gmail.com>, Mika Westerberg <mika.westerberg@linux.intel.com>, Andy Shevchenko <andriy.shevchenko@linux.intel.com> Subject: Re: [PATCH 0/2] [v5] pinctrl: qcom: add support for sparse GPIOs Date: Fri, 13 Oct 2017 18:26:23 -0500 [thread overview] Message-ID: <4f067c09-9ecf-9266-baa0-18575bca94eb@codeaurora.org> (raw) In-Reply-To: <20171003220311.GU457@codeaurora.org> On 10/03/2017 05:03 PM, Stephen Boyd wrote: > I don't see any value > beyond system wide debug in figuring out the default pin > configuration of a pin that doesn't have a consumer in Linux. I can agree with that. > Could we remove the pin direction finding part here in > gpiochip_add_pin_range() and lazily resolve the pin direction > when a pin is requested? We would need a similar check in the msm > specific debugfs code where we skip pins that aren't requested. > This is basically a revert of commit 72d320006177 ("gpio: set up > initial state from .get_direction()"). > > ACPI can still describe only the pin ranges that they care about > exposing, but from the devicetree side it's been working well > enough to not touch pins that aren't used by anything in Linux. > > ---8<---- > diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c > index cd003b74512f..673028823bc5 100644 > --- a/drivers/gpio/gpiolib.c > +++ b/drivers/gpio/gpiolib.c > @@ -1210,16 +1210,7 @@ int gpiochip_add_data(struct gpio_chip *chip, void *data) > * wrong direction in sysfs. > */ > > - if (chip->get_direction) { > - /* > - * If we have .get_direction, set up the initial > - * direction flag from the hardware. > - */ > - int dir = chip->get_direction(chip, i); > - > - if (!dir) > - set_bit(FLAG_IS_OUT, &desc->flags); > - } else if (!chip->direction_input) { > + if (!chip->direction_input) { > /* > * If the chip lacks the .direction_input callback > * we logically assume all lines are outputs. > diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c > index 273badd92561..4a0aeceb42f1 100644 > --- a/drivers/pinctrl/qcom/pinctrl-msm.c > +++ b/drivers/pinctrl/qcom/pinctrl-msm.c > @@ -24,7 +24,7 @@ > #include <linux/pinctrl/pinconf.h> > #include <linux/pinctrl/pinconf-generic.h> > #include <linux/slab.h> > -#include <linux/gpio.h> > +#include <linux/gpio/driver.h> > #include <linux/interrupt.h> > #include <linux/spinlock.h> > #include <linux/reboot.h> > @@ -494,6 +494,12 @@ static void msm_gpio_dbg_show_one(struct seq_file *s, > }; > > g = &pctrl->soc->groups[offset]; > + > + if (!gpiochip_is_requested(chip, gpio)) { > + seq_printf(s, " %-8s:", g->name); > + return; > + } > + > ctl_reg = readl(pctrl->regs + g->ctl_reg); > > is_out = !!(ctl_reg & BIT(g->oe_bit)); In order for this to work, I had to add this function from patch #1: static int msm_gpio_request(struct gpio_chip *chip, unsigned int offset) { struct msm_pinctrl *pctrl = gpiochip_get_data(chip); const struct msm_pingroup *g = &pctrl->soc->groups[offset]; if (!g->npins) return -ENODEV; return gpiochip_generic_request(chip, offset); } The problem with this is that none of the GPIOs are "requested", so it displays an output like this: # cat /sys/kernel/debug/gpio gpiochip0: GPIOs 0-149, parent: platform/QCOM8002:00, QCOM8002:00: (null) : (null) : (null) : [... truncated ]] (null) : (null) : (null) : (null) : gpio36 : gpio37 : gpio38 : gpio39 : (null) : (null) : It can't differentiate between GPIOs that don't exist and GPIOs that haven't been requested. Plus, the "(null)" entries are what I've been trying to avoid in the first place. So overall, this patch seems okay, although it needs a little work. However, it doesn't address Bjorn's complaint that he doesn't want me to use pin ranges at all. -- Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
WARNING: multiple messages have this Message-ID (diff)
From: timur@codeaurora.org (Timur Tabi) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 0/2] [v5] pinctrl: qcom: add support for sparse GPIOs Date: Fri, 13 Oct 2017 18:26:23 -0500 [thread overview] Message-ID: <4f067c09-9ecf-9266-baa0-18575bca94eb@codeaurora.org> (raw) In-Reply-To: <20171003220311.GU457@codeaurora.org> On 10/03/2017 05:03 PM, Stephen Boyd wrote: > I don't see any value > beyond system wide debug in figuring out the default pin > configuration of a pin that doesn't have a consumer in Linux. I can agree with that. > Could we remove the pin direction finding part here in > gpiochip_add_pin_range() and lazily resolve the pin direction > when a pin is requested? We would need a similar check in the msm > specific debugfs code where we skip pins that aren't requested. > This is basically a revert of commit 72d320006177 ("gpio: set up > initial state from .get_direction()"). > > ACPI can still describe only the pin ranges that they care about > exposing, but from the devicetree side it's been working well > enough to not touch pins that aren't used by anything in Linux. > > ---8<---- > diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c > index cd003b74512f..673028823bc5 100644 > --- a/drivers/gpio/gpiolib.c > +++ b/drivers/gpio/gpiolib.c > @@ -1210,16 +1210,7 @@ int gpiochip_add_data(struct gpio_chip *chip, void *data) > * wrong direction in sysfs. > */ > > - if (chip->get_direction) { > - /* > - * If we have .get_direction, set up the initial > - * direction flag from the hardware. > - */ > - int dir = chip->get_direction(chip, i); > - > - if (!dir) > - set_bit(FLAG_IS_OUT, &desc->flags); > - } else if (!chip->direction_input) { > + if (!chip->direction_input) { > /* > * If the chip lacks the .direction_input callback > * we logically assume all lines are outputs. > diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c > index 273badd92561..4a0aeceb42f1 100644 > --- a/drivers/pinctrl/qcom/pinctrl-msm.c > +++ b/drivers/pinctrl/qcom/pinctrl-msm.c > @@ -24,7 +24,7 @@ > #include <linux/pinctrl/pinconf.h> > #include <linux/pinctrl/pinconf-generic.h> > #include <linux/slab.h> > -#include <linux/gpio.h> > +#include <linux/gpio/driver.h> > #include <linux/interrupt.h> > #include <linux/spinlock.h> > #include <linux/reboot.h> > @@ -494,6 +494,12 @@ static void msm_gpio_dbg_show_one(struct seq_file *s, > }; > > g = &pctrl->soc->groups[offset]; > + > + if (!gpiochip_is_requested(chip, gpio)) { > + seq_printf(s, " %-8s:", g->name); > + return; > + } > + > ctl_reg = readl(pctrl->regs + g->ctl_reg); > > is_out = !!(ctl_reg & BIT(g->oe_bit)); In order for this to work, I had to add this function from patch #1: static int msm_gpio_request(struct gpio_chip *chip, unsigned int offset) { struct msm_pinctrl *pctrl = gpiochip_get_data(chip); const struct msm_pingroup *g = &pctrl->soc->groups[offset]; if (!g->npins) return -ENODEV; return gpiochip_generic_request(chip, offset); } The problem with this is that none of the GPIOs are "requested", so it displays an output like this: # cat /sys/kernel/debug/gpio gpiochip0: GPIOs 0-149, parent: platform/QCOM8002:00, QCOM8002:00: (null) : (null) : (null) : [... truncated ]] (null) : (null) : (null) : (null) : gpio36 : gpio37 : gpio38 : gpio39 : (null) : (null) : It can't differentiate between GPIOs that don't exist and GPIOs that haven't been requested. Plus, the "(null)" entries are what I've been trying to avoid in the first place. So overall, this patch seems okay, although it needs a little work. However, it doesn't address Bjorn's complaint that he doesn't want me to use pin ranges at all. -- Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
next prev parent reply other threads:[~2017-10-13 23:26 UTC|newest] Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-09-07 15:33 [PATCH 0/2] [v5] pinctrl: qcom: add support for sparse GPIOs Timur Tabi 2017-09-07 15:33 ` Timur Tabi 2017-09-07 15:33 ` [PATCH 1/2] [v5] pinctrl: qcom: disable GPIO groups with no pins Timur Tabi 2017-09-07 15:33 ` Timur Tabi 2017-10-02 17:44 ` Bjorn Andersson 2017-10-02 17:44 ` Bjorn Andersson 2017-10-02 20:47 ` Timur Tabi 2017-10-02 20:47 ` Timur Tabi 2017-10-07 11:07 ` Linus Walleij 2017-10-07 11:07 ` Linus Walleij 2017-10-13 23:35 ` Timur Tabi 2017-10-13 23:35 ` Timur Tabi 2017-10-19 22:44 ` Timur Tabi 2017-10-19 22:44 ` Timur Tabi 2017-10-16 8:01 ` Thierry Reding 2017-10-16 8:01 ` Thierry Reding 2017-10-16 13:52 ` Timur Tabi 2017-10-16 13:52 ` Timur Tabi 2017-09-07 15:33 ` [PATCH 2/2] [v3] pinctrl: qcom: qdf2xxx: add support for new ACPI HID QCOM8002 Timur Tabi 2017-09-07 15:33 ` Timur Tabi 2017-09-08 12:50 ` [PATCH 0/2] [v5] pinctrl: qcom: add support for sparse GPIOs Linus Walleij 2017-09-08 12:50 ` Linus Walleij 2017-09-13 17:09 ` Timur Tabi 2017-09-13 17:09 ` Timur Tabi 2017-09-19 7:04 ` Stephen Boyd 2017-09-19 7:04 ` Stephen Boyd 2017-09-19 8:15 ` Linus Walleij 2017-09-19 8:15 ` Linus Walleij 2017-09-19 12:32 ` Timur Tabi 2017-09-19 12:32 ` Timur Tabi 2017-09-20 11:43 ` Linus Walleij 2017-09-20 11:43 ` Linus Walleij 2017-09-20 13:04 ` Timur Tabi 2017-09-20 13:04 ` Timur Tabi 2017-09-21 12:08 ` Linus Walleij 2017-09-21 12:08 ` Linus Walleij 2017-09-21 12:12 ` Timur Tabi 2017-09-21 12:12 ` Timur Tabi 2017-09-22 13:29 ` Linus Walleij 2017-09-22 13:29 ` Linus Walleij 2017-09-22 13:37 ` Timur Tabi 2017-09-22 13:37 ` Timur Tabi 2017-10-03 22:03 ` Stephen Boyd 2017-10-03 22:03 ` Stephen Boyd 2017-10-03 22:12 ` Timur Tabi 2017-10-03 22:12 ` Timur Tabi 2017-10-04 21:50 ` Stephen Boyd 2017-10-04 21:50 ` Stephen Boyd 2017-10-04 22:41 ` Timur Tabi 2017-10-04 22:41 ` Timur Tabi 2017-10-05 21:30 ` Stephen Boyd 2017-10-05 21:30 ` Stephen Boyd 2017-10-11 7:51 ` Linus Walleij 2017-10-11 7:51 ` Linus Walleij 2017-10-12 7:39 ` Stephen Boyd 2017-10-12 7:39 ` Stephen Boyd 2017-10-14 22:43 ` Linus Walleij 2017-10-14 22:43 ` Linus Walleij 2017-10-16 13:42 ` Timur Tabi 2017-10-16 13:42 ` Timur Tabi 2017-10-13 23:26 ` Timur Tabi [this message] 2017-10-13 23:26 ` Timur Tabi 2017-10-15 20:18 ` Thierry Reding 2017-10-15 20:18 ` Thierry Reding 2017-10-15 21:09 ` Timur Tabi 2017-10-15 21:09 ` Timur Tabi 2017-10-02 16:02 ` Timur Tabi 2017-10-02 16:02 ` Timur Tabi
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=4f067c09-9ecf-9266-baa0-18575bca94eb@codeaurora.org \ --to=timur@codeaurora.org \ --cc=andriy.shevchenko@linux.intel.com \ --cc=andy.gross@linaro.org \ --cc=anjiandi@codeaurora.org \ --cc=bjorn.andersson@linaro.org \ --cc=david.brown@linaro.org \ --cc=linus.walleij@linaro.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-arm-msm@vger.kernel.org \ --cc=linux-gpio@vger.kernel.org \ --cc=mika.westerberg@linux.intel.com \ --cc=sboyd@codeaurora.org \ --cc=thierry.reding@gmail.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: 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.