All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pinctrl/amd: Configure GPIO register using BIOS settings
@ 2016-09-09 15:18 Agrawal, Nitesh-kumar
  2016-09-13  8:24 ` Linus Walleij
  2017-09-28  6:58 ` Dmitry Torokhov
  0 siblings, 2 replies; 6+ messages in thread
From: Agrawal, Nitesh-kumar @ 2016-09-09 15:18 UTC (permalink / raw)
  To: linus.walleij@linaro.org
  Cc: Sen, Pankaj, S-k, Shyam-sundar, linux-gpio@vger.kernel.org


In the function amd_gpio_irq_set_type, use the settings provided by
the BIOS,when the LevelTrig is Edge and activeLevel is HIGH, to configure
the GPIO registers. Ignore the settings from client.

Reviewed-by: Pankaj Sen <Pankaj.Sen@amd.com>
Signed-off-by: Nitesh Kumar Agrawal <Nitesh-kumar.Agrawal@amd.com>
---
 drivers/pinctrl/pinctrl-amd.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/pinctrl/pinctrl-amd.c b/drivers/pinctrl/pinctrl-amd.c
index 828148d..6408dda 100644
--- a/drivers/pinctrl/pinctrl-amd.c
+++ b/drivers/pinctrl/pinctrl-amd.c
@@ -384,6 +384,8 @@ static int amd_gpio_irq_set_type(struct irq_data *d, unsigned int type)
 {
 	int ret = 0;
 	u32 pin_reg;
+	bool level_trig;
+	u32 active_level;
 	unsigned long flags;
 	struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
 	struct amd_gpio *gpio_dev = gpiochip_get_data(gc);
@@ -391,6 +393,18 @@ static int amd_gpio_irq_set_type(struct irq_data *d, unsigned int type)
 	spin_lock_irqsave(&gpio_dev->lock, flags);
 	pin_reg = readl(gpio_dev->base + (d->hwirq)*4);
 
+	/*
+	* Use the settings provided by the BIOS, when the LevelTrig is
+	* EDGE and the activeLevel is HIGH, ignore the settings coming
+	* from the client to configure the GPIO register.
+	*/
+	level_trig = !(pin_reg & (LEVEL_TRIGGER << LEVEL_TRIG_OFF));
+	active_level = pin_reg & (ACTIVE_LEVEL_MASK << ACTIVE_LEVEL_OFF);
+
+	if (level_trig && ((active_level >> ACTIVE_LEVEL_OFF) == ACTIVE_HIGH)) {
+		type = IRQ_TYPE_EDGE_FALLING;
+	}
+
 	switch (type & IRQ_TYPE_SENSE_MASK) {
 	case IRQ_TYPE_EDGE_RISING:
 		pin_reg &= ~BIT(LEVEL_TRIG_OFF);
-- 
2.7.4

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

* Re: [PATCH] pinctrl/amd: Configure GPIO register using BIOS settings
  2016-09-09 15:18 [PATCH] pinctrl/amd: Configure GPIO register using BIOS settings Agrawal, Nitesh-kumar
@ 2016-09-13  8:24 ` Linus Walleij
  2017-09-28  6:58 ` Dmitry Torokhov
  1 sibling, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2016-09-13  8:24 UTC (permalink / raw)
  To: Agrawal, Nitesh-kumar
  Cc: Sen, Pankaj, S-k, Shyam-sundar, linux-gpio@vger.kernel.org

On Fri, Sep 9, 2016 at 5:18 PM, Agrawal, Nitesh-kumar
<Nitesh-kumar.Agrawal@amd.com> wrote:

> In the function amd_gpio_irq_set_type, use the settings provided by
> the BIOS,when the LevelTrig is Edge and activeLevel is HIGH, to configure
> the GPIO registers. Ignore the settings from client.
>
> Reviewed-by: Pankaj Sen <Pankaj.Sen@amd.com>
> Signed-off-by: Nitesh Kumar Agrawal <Nitesh-kumar.Agrawal@amd.com>

Thanks! It turns out I left a partly resolved commit in the tree
so applied parts of this patch as a fixup.

Sorry for my screw-ups.

Yours,
Linus Walleij

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

* Re: pinctrl/amd: Configure GPIO register using BIOS settings
  2016-09-09 15:18 [PATCH] pinctrl/amd: Configure GPIO register using BIOS settings Agrawal, Nitesh-kumar
  2016-09-13  8:24 ` Linus Walleij
@ 2017-09-28  6:58 ` Dmitry Torokhov
  2017-09-28  7:46   ` Agrawal, Nitesh-kumar
  1 sibling, 1 reply; 6+ messages in thread
From: Dmitry Torokhov @ 2017-09-28  6:58 UTC (permalink / raw)
  To: Agrawal, Nitesh-kumar
  Cc: linus.walleij@linaro.org, Sen, Pankaj, S-k, Shyam-sundar,
	linux-gpio@vger.kernel.org

On Fri, Sep 09, 2016 at 03:18:09PM +0000, Agrawal, Nitesh-kumar wrote:
> In the function amd_gpio_irq_set_type, use the settings provided by
> the BIOS,when the LevelTrig is Edge and activeLevel is HIGH, to configure
> the GPIO registers. Ignore the settings from client.
> 
> Reviewed-by: Pankaj Sen <Pankaj.Sen@amd.com>
> Signed-off-by: Nitesh Kumar Agrawal <Nitesh-kumar.Agrawal@amd.com>

Just found this patch in the tree. Can you please explain why it is
needed (the patch description unfortunately tells what the patch does,
but not why).

I would expect that we either allow reprogramming the trigger as client
wishes or would error out and let the upper layers know. Silently
"fixing" the settings is wrong course of action in my opinion.

If this was trying to work around Elan touchpad drivers not working on
AMD platforms it needs to be solved in Elan driver, not here.

Thanks!

> ---
>  drivers/pinctrl/pinctrl-amd.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/drivers/pinctrl/pinctrl-amd.c b/drivers/pinctrl/pinctrl-amd.c
> index 828148d..6408dda 100644
> --- a/drivers/pinctrl/pinctrl-amd.c
> +++ b/drivers/pinctrl/pinctrl-amd.c
> @@ -384,6 +384,8 @@ static int amd_gpio_irq_set_type(struct irq_data *d, unsigned int type)
>  {
>  	int ret = 0;
>  	u32 pin_reg;
> +	bool level_trig;
> +	u32 active_level;
>  	unsigned long flags;
>  	struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
>  	struct amd_gpio *gpio_dev = gpiochip_get_data(gc);
> @@ -391,6 +393,18 @@ static int amd_gpio_irq_set_type(struct irq_data *d, unsigned int type)
>  	spin_lock_irqsave(&gpio_dev->lock, flags);
>  	pin_reg = readl(gpio_dev->base + (d->hwirq)*4);
>  
> +	/*
> +	* Use the settings provided by the BIOS, when the LevelTrig is
> +	* EDGE and the activeLevel is HIGH, ignore the settings coming
> +	* from the client to configure the GPIO register.
> +	*/
> +	level_trig = !(pin_reg & (LEVEL_TRIGGER << LEVEL_TRIG_OFF));
> +	active_level = pin_reg & (ACTIVE_LEVEL_MASK << ACTIVE_LEVEL_OFF);
> +
> +	if (level_trig && ((active_level >> ACTIVE_LEVEL_OFF) == ACTIVE_HIGH)) {
> +		type = IRQ_TYPE_EDGE_FALLING;
> +	}
> +
>  	switch (type & IRQ_TYPE_SENSE_MASK) {
>  	case IRQ_TYPE_EDGE_RISING:
>  		pin_reg &= ~BIT(LEVEL_TRIG_OFF);

-- 
Dmitry

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

* RE: pinctrl/amd: Configure GPIO register using BIOS settings
  2017-09-28  6:58 ` Dmitry Torokhov
@ 2017-09-28  7:46   ` Agrawal, Nitesh-kumar
  2017-09-28 17:07     ` Dmitry Torokhov
  0 siblings, 1 reply; 6+ messages in thread
From: Agrawal, Nitesh-kumar @ 2017-09-28  7:46 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: linus.walleij@linaro.org, Sen, Pankaj, S-k, Shyam-sundar,
	linux-gpio@vger.kernel.org

-----Original Message-----
From: Dmitry Torokhov [mailto:dmitry.torokhov@gmail.com] 
Sent: Thursday, September 28, 2017 12:28 PM
To: Agrawal, Nitesh-kumar <Nitesh-kumar.Agrawal@amd.com>
Cc: linus.walleij@linaro.org; Sen, Pankaj <Pankaj.Sen@amd.com>; S-k, Shyam-sundar <Shyam-sundar.S-k@amd.com>; linux-gpio@vger.kernel.org
Subject: Re: pinctrl/amd: Configure GPIO register using BIOS settings

On Fri, Sep 09, 2016 at 03:18:09PM +0000, Agrawal, Nitesh-kumar wrote:
> In the function amd_gpio_irq_set_type, use the settings provided by 
> the BIOS,when the LevelTrig is Edge and activeLevel is HIGH, to 
> configure the GPIO registers. Ignore the settings from client.
> 
> Reviewed-by: Pankaj Sen <Pankaj.Sen@amd.com>
> Signed-off-by: Nitesh Kumar Agrawal <Nitesh-kumar.Agrawal@amd.com>

Just found this patch in the tree. Can you please explain why it is needed (the patch description unfortunately tells what the patch does, but not why).

I would expect that we either allow reprogramming the trigger as client wishes or would error out and let the upper layers know. Silently "fixing" the settings is wrong course of action in my opinion.

If this was trying to work around Elan touchpad drivers not working on AMD platforms it needs to be solved in Elan driver, not here.

[Nitesh]We have reverted the patch in the later version of the patch.


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

* Re: pinctrl/amd: Configure GPIO register using BIOS settings
  2017-09-28  7:46   ` Agrawal, Nitesh-kumar
@ 2017-09-28 17:07     ` Dmitry Torokhov
  2017-10-03  4:52       ` Agrawal, Nitesh-kumar
  0 siblings, 1 reply; 6+ messages in thread
From: Dmitry Torokhov @ 2017-09-28 17:07 UTC (permalink / raw)
  To: Agrawal, Nitesh-kumar
  Cc: linus.walleij@linaro.org, Sen, Pankaj, S-k, Shyam-sundar,
	linux-gpio@vger.kernel.org

Hi Nitesh,

On Thu, Sep 28, 2017 at 12:46 AM, Agrawal, Nitesh-kumar
<Nitesh-kumar.Agrawal@amd.com> wrote:
> -----Original Message-----
> From: Dmitry Torokhov [mailto:dmitry.torokhov@gmail.com]
> Sent: Thursday, September 28, 2017 12:28 PM
> To: Agrawal, Nitesh-kumar <Nitesh-kumar.Agrawal@amd.com>
> Cc: linus.walleij@linaro.org; Sen, Pankaj <Pankaj.Sen@amd.com>; S-k, Shyam-sundar <Shyam-sundar.S-k@amd.com>; linux-gpio@vger.kernel.org
> Subject: Re: pinctrl/amd: Configure GPIO register using BIOS settings
>
> On Fri, Sep 09, 2016 at 03:18:09PM +0000, Agrawal, Nitesh-kumar wrote:
>> In the function amd_gpio_irq_set_type, use the settings provided by
>> the BIOS,when the LevelTrig is Edge and activeLevel is HIGH, to
>> configure the GPIO registers. Ignore the settings from client.
>>
>> Reviewed-by: Pankaj Sen <Pankaj.Sen@amd.com>
>> Signed-off-by: Nitesh Kumar Agrawal <Nitesh-kumar.Agrawal@amd.com>
>
> Just found this patch in the tree. Can you please explain why it is needed (the patch description unfortunately tells what the patch does, but not why).
>
> I would expect that we either allow reprogramming the trigger as client wishes or would error out and let the upper layers know. Silently "fixing" the settings is wrong course of action in my opinion.
>
> If this was trying to work around Elan touchpad drivers not working on AMD platforms it needs to be solved in Elan driver, not here.
>
> [Nitesh]We have reverted the patch in the later version of the patch.
>

Where was it reverted? I am looking at today's linux-next, and I am
still seeing this comment in pinctrl-amd.c:

        /* Ignore the settings coming from the client and
        * read the values from the ACPI tables
        * while setting the trigger type
        */

Thanks.

-- 
Dmitry

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

* RE: pinctrl/amd: Configure GPIO register using BIOS settings
  2017-09-28 17:07     ` Dmitry Torokhov
@ 2017-10-03  4:52       ` Agrawal, Nitesh-kumar
  0 siblings, 0 replies; 6+ messages in thread
From: Agrawal, Nitesh-kumar @ 2017-10-03  4:52 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: linus.walleij@linaro.org, Sen, Pankaj, S-k, Shyam-sundar,
	linux-gpio@vger.kernel.org

Hi Dmitry,

On Thu, Sep 28, 2017 at 12:46 AM, Agrawal, Nitesh-kumar <Nitesh-kumar.Agrawal@amd.com> wrote:
> -----Original Message-----
> From: Dmitry Torokhov [mailto:dmitry.torokhov@gmail.com]
> Sent: Thursday, September 28, 2017 12:28 PM
> To: Agrawal, Nitesh-kumar <Nitesh-kumar.Agrawal@amd.com>
> Cc: linus.walleij@linaro.org; Sen, Pankaj <Pankaj.Sen@amd.com>; S-k, 
> Shyam-sundar <Shyam-sundar.S-k@amd.com>; linux-gpio@vger.kernel.org
> Subject: Re: pinctrl/amd: Configure GPIO register using BIOS settings
>
> On Fri, Sep 09, 2016 at 03:18:09PM +0000, Agrawal, Nitesh-kumar wrote:
>> In the function amd_gpio_irq_set_type, use the settings provided by 
>> the BIOS,when the LevelTrig is Edge and activeLevel is HIGH, to 
>> configure the GPIO registers. Ignore the settings from client.
>>
>> Reviewed-by: Pankaj Sen <Pankaj.Sen@amd.com>
>> Signed-off-by: Nitesh Kumar Agrawal <Nitesh-kumar.Agrawal@amd.com>
>
> Just found this patch in the tree. Can you please explain why it is needed (the patch description unfortunately tells what the patch does, but not why).
>
> I would expect that we either allow reprogramming the trigger as client wishes or would error out and let the upper layers know. Silently "fixing" the settings is wrong course of action in my opinion.
>
> If this was trying to work around Elan touchpad drivers not working on AMD platforms it needs to be solved in Elan driver, not here.
>
> [Nitesh]We have reverted the patch in the later version of the patch.
>

Where was it reverted? I am looking at today's linux-next, and I am still seeing this comment in pinctrl-amd.c:

        /* Ignore the settings coming from the client and
        * read the values from the ACPI tables
        * while setting the trigger type
        */


Ok. We have reverted the code but the comments are still there. We will submit a patch to revert the comments also. Thanks for reviewing the patch.

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

end of thread, other threads:[~2017-10-03  4:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-09 15:18 [PATCH] pinctrl/amd: Configure GPIO register using BIOS settings Agrawal, Nitesh-kumar
2016-09-13  8:24 ` Linus Walleij
2017-09-28  6:58 ` Dmitry Torokhov
2017-09-28  7:46   ` Agrawal, Nitesh-kumar
2017-09-28 17:07     ` Dmitry Torokhov
2017-10-03  4:52       ` Agrawal, Nitesh-kumar

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.