* [PATCH] pinctrl/amd: Set the level based on ACPI tables
@ 2016-12-08 12:01 Shyam Sundar S K
2016-12-28 12:32 ` Linus Walleij
0 siblings, 1 reply; 2+ messages in thread
From: Shyam Sundar S K @ 2016-12-08 12:01 UTC (permalink / raw)
To: Linus Walleij
Cc: linux-gpio, Agrawal, Nitesh-kumar, Sen, Pankaj, Shah, Nehal-bakulchandra
In the function amd_gpio_irq_set_type, read the values from
the ACPI table to set the level and drop the settings passed
by the client.
Reviewed-by: Pankaj Sen <Pankaj.Sen@amd.com>
Reviewed-by: Nitesh Kumar Agrawal <Nitesh-kumar.Agrawal@amd.com>
Reviewed-by: Shah, Nehal-bakulchandra <Nehal-bakulchandra.Shah@amd.com>
Signed-off-by: Shyam-sundar S-k <Shyam-sundar.S-k@amd.com>
---
drivers/pinctrl/pinctrl-amd.c | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-amd.c b/drivers/pinctrl/pinctrl-amd.c
index aea310a..c9a1469 100644
--- a/drivers/pinctrl/pinctrl-amd.c
+++ b/drivers/pinctrl/pinctrl-amd.c
@@ -382,26 +382,21 @@ static int amd_gpio_irq_set_type(struct irq_data *d, unsigned int type)
{
int ret = 0;
u32 pin_reg;
- unsigned long flags;
- bool level_trig;
- u32 active_level;
+ unsigned long flags, irq_flags;
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct amd_gpio *gpio_dev = gpiochip_get_data(gc);
spin_lock_irqsave(&gpio_dev->lock, flags);
pin_reg = readl(gpio_dev->base + (d->hwirq)*4);
- /*
- * When level_trig is set EDGE and active_level is set HIGH in BIOS
- * default settings, ignore incoming settings from client and use
- * BIOS settings to configure GPIO register.
+ /* Ignore the settings coming from the client and
+ * read the values from the ACPI tables
+ * while setting the trigger type
*/
- 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;
+ irq_flags = irq_get_trigger_type(d->irq);
+ if (irq_flags != IRQ_TYPE_NONE)
+ type = irq_flags;
switch (type & IRQ_TYPE_SENSE_MASK) {
case IRQ_TYPE_EDGE_RISING:
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] pinctrl/amd: Set the level based on ACPI tables
2016-12-08 12:01 [PATCH] pinctrl/amd: Set the level based on ACPI tables Shyam Sundar S K
@ 2016-12-28 12:32 ` Linus Walleij
0 siblings, 0 replies; 2+ messages in thread
From: Linus Walleij @ 2016-12-28 12:32 UTC (permalink / raw)
To: Shyam Sundar S K
Cc: linux-gpio, Agrawal, Nitesh-kumar, Sen, Pankaj, Shah, Nehal-bakulchandra
On Thu, Dec 8, 2016 at 1:01 PM, Shyam Sundar S K <ssundark@amd.com> wrote:
> In the function amd_gpio_irq_set_type, read the values from
> the ACPI table to set the level and drop the settings passed
> by the client.
>
> Reviewed-by: Pankaj Sen <Pankaj.Sen@amd.com>
> Reviewed-by: Nitesh Kumar Agrawal <Nitesh-kumar.Agrawal@amd.com>
> Reviewed-by: Shah, Nehal-bakulchandra <Nehal-bakulchandra.Shah@amd.com>
> Signed-off-by: Shyam-sundar S-k <Shyam-sundar.S-k@amd.com>
Patch applied. The code makes a lot more sense now, too.
> - /*
> - * When level_trig is set EDGE and active_level is set HIGH in BIOS
> - * default settings, ignore incoming settings from client and use
> - * BIOS settings to configure GPIO register.
> + /* Ignore the settings coming from the client and
> + * read the values from the ACPI tables
> + * while setting the trigger type
In my book you do the exact opposite: the client/consumer is the device
making use of this IRQ, and that defines what trigger to set.
Before this, you let the hardware power-on defaults define the trigger, which
was probably not such a good idea.
But it's just a comment so I don't care much.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-12-28 12:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-08 12:01 [PATCH] pinctrl/amd: Set the level based on ACPI tables Shyam Sundar S K
2016-12-28 12:32 ` Linus Walleij
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.