[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1577022724.7468.20.camel@mtkswgap22>
Date: Sun, 22 Dec 2019 21:52:04 +0800
From: Hanks Chen <hanks.chen@...iatek.com>
To: Linus Walleij <linus.walleij@...aro.org>
CC: Mars Cheng <mars.cheng@...iatek.com>,
Matthias Brugger <matthias.bgg@...il.com>,
Rob Herring <robh@...nel.org>,
Marc Zyngier <marc.zyngier@....com>,
Stephen Boyd <sboyd@...nel.org>,
Sean Wang <sean.wang@...nel.org>,
CC Hwang <cc.hwang@...iatek.com>,
Loda Chou <loda.chou@...iatek.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"moderated list:ARM/Mediatek SoC support"
<linux-mediatek@...ts.infradead.org>,
"open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS"
<devicetree@...r.kernel.org>, <wsd_upstream@...iatek.com>,
mtk01761 <wendell.lin@...iatek.com>,
linux-clk <linux-clk@...r.kernel.org>
Subject: Re: [PATCH v2 05/11] pinctrl: mediatek: avoid virtual gpio trying
to set reg
On Fri, 2019-08-23 at 10:57 +0200, Linus Walleij wrote:
> On Mon, Aug 19, 2019 at 11:22 AM Mars Cheng <mars.cheng@...iatek.com> wrote:
>
> > for virtual gpios, they should not do reg setting and
> > should behave as expected for eint function.
> >
> > Signed-off-by: Mars Cheng <mars.cheng@...iatek.com>
>
> This does not explain what a "virtual GPIO" is in this
> context, so please elaborate. What is this? Why does
> it exist? What is it used for?
>
> GPIO is "general purpose input/output" and it is a
> pretty rubbery category already as it is, so we need
> to define our terms pretty strictly.
>
Virtual GPIO only used inside SOC and not being exported to outside SOC
in MTK platform. Some modules use virtual GPIO as eint (e.g. pmic or
usb).
In MTK platform, external interrupt (EINT) and GPIO is 1-1 mapping and
we can set GPIO as eint.
But some modules use specific eint which doesn't have real GPIO pin.
So we use virtual GPIO to map it.
> > +bool mtk_is_virt_gpio(struct mtk_pinctrl *hw, unsigned int gpio_n)
> > +{
> > + const struct mtk_pin_desc *desc;
> > + bool virt_gpio = false;
> > +
> > + if (gpio_n >= hw->soc->npins)
> > + return virt_gpio;
> > +
> > + desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio_n];
> > +
> > + if (desc->funcs &&
> > + desc->funcs[desc->eint.eint_m].name == 0)
>
> NULL check is done like this:
>
> if (desc->funcs && !desc->funcs[desc->eint.eint_m].name)
>
> > + virt_gpio = true;
>
got it, will fix it in v3. Thanks for reviewing.
> So why is this GPIO "virtual" because it does not have
> a name in the funcs table?
>
yes, it doesn't have real GPIO pin and name, so we set it as virtual GPIO.
> > @@ -278,6 +295,9 @@ static int mtk_xt_set_gpio_as_eint(void *data, unsigned long eint_n)
> > if (err)
> > return err;
> >
> > + if (mtk_is_virt_gpio(hw, gpio_n))
> > + return 0;
>
> So does this mean we always succeed in setting a GPIO as eint
> if it is virtual? Why? Explanatory comment is needed.
>
yes, we use virtual GPIO to map it.
> > @@ -693,6 +693,9 @@ static int mtk_gpio_get_direction(struct gpio_chip *chip, unsigned int gpio)
> > const struct mtk_pin_desc *desc;
> > int value, err;
> >
> > + if (mtk_is_virt_gpio(hw, gpio))
> > + return 1;
>
> Why are "virtual GPIOs" always inputs?
>
We set virtual GPIO as eint.
It mean virtual GPIO only used inside SOC and not being exported to
outside SOC.
> Yours,
> Linus Walleij
Sorry for the late reply.
I'm the new bsp contact of mtk phone project.
I will be taking over from Mars.
Thanks for reviewing.
Powered by blists - more mailing lists