pinctrl: amd: fix incorrect way to disable debounce filter
Subsystems (3)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v2 1/4 pinctrl: amd: fix incorrect way to disable debounce filter
The correct way to disable debounce filter is to clear bit 5 and 6 of the register.
--- drivers/pinctrl/pinctrl-amd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pinctrl/pinctrl-amd.c +2 -2
@@ -166,14 +166,14 @@ static int amd_gpio_set_debounce(struct gpio_chip *gc, unsigned offset, pin_reg |=BIT (DB_TMR_OUT_UNIT_OFF ); pin_reg |=BIT (DB_TMR_LARGE_OFF ); }else { - pin_reg &= ~DB_CNTRl_MASK; + pin_reg &= ~(DB_CNTRl_MASK <<DB_CNTRL_OFF ); ret = -EINVAL ; } }else { pin_reg &= ~BIT (DB_TMR_OUT_UNIT_OFF ); pin_reg &= ~BIT (DB_TMR_LARGE_OFF ); pin_reg &= ~DB_TMR_OUT_MASK ; - pin_reg &= ~DB_CNTRl_MASK; + pin_reg &= ~(DB_CNTRl_MASK <<DB_CNTRL_OFF ); }writel (pin_reg, gpio_dev->base + offset *4 );raw_spin_unlock_irqrestore (&gpio_dev->lock, flags);
Signature · 1 line
2.28.0
PATCH v2 2/4 pinctrl: amd: use higher precision for 512 RtcClk
In reply to a message not in the archiveRTC is 32.768kHz thus 512 RtcClk equals 15625 usec.
--- drivers/pinctrl/pinctrl-amd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/pinctrl-amd.c +1 -1
@@ -156,7 +156,7 @@ static int amd_gpio_set_debounce(struct gpio_chip *gc, unsigned offset, pin_reg |=BIT (DB_TMR_OUT_UNIT_OFF ); pin_reg &= ~BIT (DB_TMR_LARGE_OFF ); }else if (debounce <250000 ) { - time = debounce /15600 ; + time = debounce /15625 ; pin_reg |= time &DB_TMR_OUT_MASK ; pin_reg &= ~BIT (DB_TMR_OUT_UNIT_OFF ); pin_reg |=BIT (DB_TMR_LARGE_OFF );
--
2.28.0
Re: [PATCH v2 2/4] pinctrl: amd: use higher precision for 512 RtcClk
Quoted 2 lines · Coiby Xu
RTC is 32.768kHz thus 512 RtcClk equals 15625 usec.
I could add that the documentation likely has dropped precision and that's why the driver mistakenly took the slightly deviated value.
Anyway.
Quoted 24 lines
Suggested-by Andy Shevchenko <[email protected]>Suggested-by Hans de Goede <[email protected]>Signed-off-by Coiby Xu <[email protected]>--- drivers/pinctrl/pinctrl-amd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pinctrl/pinctrl-amd.c +1
-2@@ -156,7 +156,7 @@ static int amd_gpio_set_debounce(struct gpio_chip *gc, unsigned offset, pin_reg |=BIT (DB_TMR_OUT_UNIT_OFF ); pin_reg &= ~BIT (DB_TMR_LARGE_OFF ); }else if (debounce <250000 ) { - time = debounce /15600 ; + time = debounce /15625 ; pin_reg |= time &DB_TMR_OUT_MASK ; pin_reg &= ~BIT (DB_TMR_OUT_UNIT_OFF ); pin_reg |=BIT (DB_TMR_LARGE_OFF ); --2.28.0
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v2 2/4] pinctrl: amd: use higher precision for 512 RtcClk
Quoted 7 lines · Andy Shevchenko
Quoted 2 lines · Coiby Xu
RTC is 32.768kHz thus 512 RtcClk equals 15625 usec.
I could add that the documentation likely has dropped precision and that's why the driver mistakenly took the slightly deviated value.
Thank you for the suggestion and other fixes in patch 4/4. Applied in v3.
Quoted 24 lines
Anyway.
Reviewed-by Andy Shevchenko <[email protected]>Quoted 21 lines
Suggested-by Andy Shevchenko <[email protected]>Suggested-by Hans de Goede <[email protected]>Signed-off-by Coiby Xu <[email protected]>--- drivers/pinctrl/pinctrl-amd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pinctrl/pinctrl-amd.c +1
-1@@ -156,7 +156,7 @@ static int amd_gpio_set_debounce(struct gpio_chip *gc, unsigned offset, pin_reg |=BIT (DB_TMR_OUT_UNIT_OFF ); pin_reg &= ~BIT (DB_TMR_LARGE_OFF ); }else if (debounce <250000 ) { - time = debounce /15600 ; + time = debounce /15625 ; pin_reg |= time &DB_TMR_OUT_MASK ; pin_reg &= ~BIT (DB_TMR_OUT_UNIT_OFF ); pin_reg |=BIT (DB_TMR_LARGE_OFF );
Quoted 8 lines
Quoted 3 lines
--
2.28.0--
With Best Regards,
Andy Shevchenko
--
Best regards,
Coiby
PATCH v2 3/4 pinctrl: amd: print debounce filter info in debugfs
In reply to a message not in the archivePrint the status of debounce filter as follows,
$ cat /sys/kernel/debug/gpio
pin129 interrupt is disabled| interrupt is masked| disable wakeup in S0i3 state| disable wakeup in S3 state|
disable wakeup in S4/S5 state| input is high| pull-up is disabled| Pull-down is disabled| output is disabled| debouncing filter disabled| 0x50000
^^^^^^^^^^^^^^^^^^^^^^^^^^
pin130 interrupt is disabled| interrupt is masked| disable wakeup in S0i3 state| disable wakeup in S3 state|
disable wakeup in S4/S5 state| input is high| pull-up is disabled| Pull-down is disabled| output is disabled| debouncing filter (high) enabled| debouncing timeout is 124800 (us)| 0x503c8
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Cc: Andy Shevchenko <[email protected]>
Signed-off-by: Coiby Xu <[email protected]>
---
drivers/pinctrl/pinctrl-amd.c | 43 +++++++++++++++++++++++++++++++++--
1 file changed, 41 insertions(+), 2 deletions(-)drivers/pinctrl/pinctrl-amd.c +41 -2
@@ -197,10 +197,16 @@ static int amd_gpio_set_config(struct gpio_chip *gc, unsigned offset,static void amd_gpio_dbg_show (struct seq_file *s,struct gpio_chip *gc) {u32 pin_reg; +u32 db_cntrl;unsigned long flags;unsigned int bank, i, pin_num;struct amd_gpio *gpio_dev =gpiochip_get_data (gc); +bool tmr_out_unit; +unsigned int time; +unsigned int unit; +bool tmr_large; +char *level_trig;char *active_level;char *interrupt_enable;
@@ -214,6 +220,8 @@ static void amd_gpio_dbg_show(struct seq_file *s, struct gpio_chip *gc)char *pull_down_enable;char *output_value;char *output_enable; +char debounce_value[40 ]; +char *debounce_enable;for (bank =0 ; bank < gpio_dev->hwbank_num; bank++) {seq_printf (s,"GPIO bank%d\t" , bank);
@@ -327,13 +335,44 @@ static void amd_gpio_dbg_show(struct seq_file *s, struct gpio_chip *gc) pin_sts ="input is low|" ; } + db_cntrl = (DB_CNTRl_MASK <<DB_CNTRL_OFF ) & pin_reg; +if (db_cntrl) { + tmr_out_unit = pin_reg &BIT (DB_TMR_OUT_UNIT_OFF ); + tmr_large = pin_reg &BIT (DB_TMR_LARGE_OFF ); + time = pin_reg &DB_TMR_OUT_MASK ; +if (tmr_large) { +if (tmr_out_unit) + unit =62500 ; +else + unit =15625 ; + }else { +if (tmr_out_unit) + unit =244 ; +else + unit =61 ; + } +if ((DB_TYPE_REMOVE_GLITCH <<DB_CNTRL_OFF ) == db_cntrl) + debounce_enable ="debouncing filter (high and low) enabled|" ; +else if ((DB_TYPE_PRESERVE_LOW_GLITCH <<DB_CNTRL_OFF ) == db_cntrl) + debounce_enable ="debouncing filter (low) enabled|" ; +else + debounce_enable ="debouncing filter (high) enabled|" ; + +snprintf (debounce_value,sizeof (debounce_value), +"debouncing timeout is %u (us)|" , time * unit); + }else { + debounce_enable ="debouncing filter disabled|" ; +snprintf (debounce_value,sizeof (debounce_value)," " ); + } +seq_printf (s,"%s %s %s %s %s %s\n" -" %s %s %s %s %s %s %s 0x%x\n" , +" %s %s %s %s %s %s %s %s %s 0x%x\n" , level_trig, active_level, interrupt_enable, interrupt_mask, wake_cntrl0, wake_cntrl1, wake_cntrl2, pin_sts, pull_up_sel, pull_up_enable, pull_down_enable, - output_value, output_enable, pin_reg); + output_value, output_enable, + debounce_enable, debounce_value, pin_reg); } } }
--
2.28.0
PATCH v2 4/4 pinctrl: amd: remove debounce filter setting in irq type setting
In reply to a message not in the archiveDebounce filter setting should be independent from irq type setting because according to the ACPI specs, there are separate arguments for specifying debounce timeout and irq type in GpioIo and GpioInt.
This will fix broken touchpads for Lenovo Legion-5 AMD gaming laptops including 15ARH05 (R7000) and R7000P whose BIOS set the debounce timeout to 124.8ms which led to the kernel receiving only ~7 HID reports per second.
--- drivers/pinctrl/pinctrl-amd.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/pinctrl/pinctrl-amd.c +0 -7
@@ -468,7 +468,6 @@ static int amd_gpio_irq_set_type(struct irq_data *d, unsigned int type) pin_reg &= ~BIT (LEVEL_TRIG_OFF ); pin_reg &= ~(ACTIVE_LEVEL_MASK <<ACTIVE_LEVEL_OFF ); pin_reg |=ACTIVE_HIGH <<ACTIVE_LEVEL_OFF ; - pin_reg |=DB_TYPE_REMOVE_GLITCH <<DB_CNTRL_OFF ;irq_set_handler_locked (d, handle_edge_irq);break ;
@@ -476,7 +475,6 @@ static int amd_gpio_irq_set_type(struct irq_data *d, unsigned int type) pin_reg &= ~BIT (LEVEL_TRIG_OFF ); pin_reg &= ~(ACTIVE_LEVEL_MASK <<ACTIVE_LEVEL_OFF ); pin_reg |=ACTIVE_LOW <<ACTIVE_LEVEL_OFF ; - pin_reg |=DB_TYPE_REMOVE_GLITCH <<DB_CNTRL_OFF ;irq_set_handler_locked (d, handle_edge_irq);break ;
@@ -484,7 +482,6 @@ static int amd_gpio_irq_set_type(struct irq_data *d, unsigned int type) pin_reg &= ~BIT (LEVEL_TRIG_OFF ); pin_reg &= ~(ACTIVE_LEVEL_MASK <<ACTIVE_LEVEL_OFF ); pin_reg |=BOTH_EADGE <<ACTIVE_LEVEL_OFF ; - pin_reg |=DB_TYPE_REMOVE_GLITCH <<DB_CNTRL_OFF ;irq_set_handler_locked (d, handle_edge_irq);break ;
@@ -492,8 +489,6 @@ static int amd_gpio_irq_set_type(struct irq_data *d, unsigned int type) pin_reg |=LEVEL_TRIGGER <<LEVEL_TRIG_OFF ; pin_reg &= ~(ACTIVE_LEVEL_MASK <<ACTIVE_LEVEL_OFF ); pin_reg |=ACTIVE_HIGH <<ACTIVE_LEVEL_OFF ; - pin_reg &= ~(DB_CNTRl_MASK <<DB_CNTRL_OFF ); - pin_reg |=DB_TYPE_PRESERVE_LOW_GLITCH <<DB_CNTRL_OFF ;irq_set_handler_locked (d, handle_level_irq);break ;
@@ -501,8 +496,6 @@ static int amd_gpio_irq_set_type(struct irq_data *d, unsigned int type) pin_reg |=LEVEL_TRIGGER <<LEVEL_TRIG_OFF ; pin_reg &= ~(ACTIVE_LEVEL_MASK <<ACTIVE_LEVEL_OFF ); pin_reg |=ACTIVE_LOW <<ACTIVE_LEVEL_OFF ; - pin_reg &= ~(DB_CNTRl_MASK <<DB_CNTRL_OFF ); - pin_reg |=DB_TYPE_PRESERVE_HIGH_GLITCH <<DB_CNTRL_OFF ;irq_set_handler_locked (d, handle_level_irq);break ;
Signature · 1 line
2.28.0
Re: [PATCH v2 4/4] pinctrl: amd: remove debounce filter setting in irq type setting
Quoted 4 lines · Coiby Xu
Debounce filter setting should be independent from irq type setting because according to the ACPI specs, there are separate arguments for specifying debounce timeout and irq type in GpioIo and GpioInt.
irq -> IRQGpioIo()GpioInt()
Quoted 4 lines
This will fix broken touchpads for Lenovo Legion-5 AMD gaming laptops including 15ARH05 (R7000) and R7000P whose BIOS set the debounce timeout to 124.8ms which led to the kernel receiving only ~7 HID reports per second.
Quoted 59 lines
Cc Hans de Goede <[email protected]>Cc Andy Shevchenko <[email protected]>Cc Benjamin Tissoires <[email protected]>Link https://lore.kernel.org/linux-gpio/CAHp75VcwiGREBUJ0A06EEw-SyabqYsp%2Bdqs2DpSrhaY-2GVdAA%40mail.gmail.com/ open hereSigned-off-by Coiby Xu <[email protected]>--- drivers/pinctrl/pinctrl-amd.c | 7 ------- 1 file changed, 7 deletions(-)drivers/pinctrl/pinctrl-amd.c +0
-8@@ -468,7 +468,6 @@ static int amd_gpio_irq_set_type(struct irq_data *d, unsigned int type) pin_reg &= ~BIT (LEVEL_TRIG_OFF ); pin_reg &= ~(ACTIVE_LEVEL_MASK <<ACTIVE_LEVEL_OFF ); pin_reg |=ACTIVE_HIGH <<ACTIVE_LEVEL_OFF ; - pin_reg |=DB_TYPE_REMOVE_GLITCH <<DB_CNTRL_OFF ;irq_set_handler_locked (d, handle_edge_irq);break ;@@ -476,7 +475,6 @@ static int amd_gpio_irq_set_type(struct irq_data *d, unsigned int type) pin_reg &= ~BIT (LEVEL_TRIG_OFF ); pin_reg &= ~(ACTIVE_LEVEL_MASK <<ACTIVE_LEVEL_OFF ); pin_reg |=ACTIVE_LOW <<ACTIVE_LEVEL_OFF ; - pin_reg |=DB_TYPE_REMOVE_GLITCH <<DB_CNTRL_OFF ;irq_set_handler_locked (d, handle_edge_irq);break ;@@ -484,7 +482,6 @@ static int amd_gpio_irq_set_type(struct irq_data *d, unsigned int type) pin_reg &= ~BIT (LEVEL_TRIG_OFF ); pin_reg &= ~(ACTIVE_LEVEL_MASK <<ACTIVE_LEVEL_OFF ); pin_reg |=BOTH_EADGE <<ACTIVE_LEVEL_OFF ; - pin_reg |=DB_TYPE_REMOVE_GLITCH <<DB_CNTRL_OFF ;irq_set_handler_locked (d, handle_edge_irq);break ;@@ -492,8 +489,6 @@ static int amd_gpio_irq_set_type(struct irq_data *d, unsigned int type) pin_reg |=LEVEL_TRIGGER <<LEVEL_TRIG_OFF ; pin_reg &= ~(ACTIVE_LEVEL_MASK <<ACTIVE_LEVEL_OFF ); pin_reg |=ACTIVE_HIGH <<ACTIVE_LEVEL_OFF ; - pin_reg &= ~(DB_CNTRl_MASK <<DB_CNTRL_OFF ); - pin_reg |=DB_TYPE_PRESERVE_LOW_GLITCH <<DB_CNTRL_OFF ;irq_set_handler_locked (d, handle_level_irq);break ;@@ -501,8 +496,6 @@ static int amd_gpio_irq_set_type(struct irq_data *d, unsigned int type) pin_reg |=LEVEL_TRIGGER <<LEVEL_TRIG_OFF ; pin_reg &= ~(ACTIVE_LEVEL_MASK <<ACTIVE_LEVEL_OFF ); pin_reg |=ACTIVE_LOW <<ACTIVE_LEVEL_OFF ; - pin_reg &= ~(DB_CNTRl_MASK <<DB_CNTRL_OFF ); - pin_reg |=DB_TYPE_PRESERVE_HIGH_GLITCH <<DB_CNTRL_OFF ;irq_set_handler_locked (d, handle_level_irq);break ; --2.28.0
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v2 0/4] pinctrl: amd: debounce filter fixes
In reply to a message not in the archiveMissed mailing list.
Quoted 19 lines · Coiby Xu
There are three fixes (and one improvement) that fix the debounce filter issues in pinctrl-amd.
Changelog v2:
- Message-Id to Link and grammar fixes for commit messages [Andy Shevchenko]Coiby Xu (4):
pinctrl: amd: fix incorrect way to disable debounce filter
pinctrl: amd: use higher precision for 512 RtcClk
pinctrl: amd: print debounce filter info in debugfs
pinctrl: amd: remove debounce filter setting in irq type settingdrivers/pinctrl/pinctrl-amd.c | 56 +++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 12 deletions(-)--
2.28.0
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v2 0/4] pinctrl: amd: debounce filter fixes
Quoted 1 line · Andy Shevchenko
Missed mailing list.
Sorry, I don't understand this comment. Which mailing list was missed?
Quoted 18 lines · Coiby Xu
Quoted 16 lines
There are three fixes (and one improvement) that fix the debounce filter issues in pinctrl-amd.
Changelog v2:
- Message-Id to Link and grammar fixes for commit messages [Andy Shevchenko]Coiby Xu (4):
pinctrl: amd: fix incorrect way to disable debounce filter
pinctrl: amd: use higher precision for 512 RtcClk
pinctrl: amd: print debounce filter info in debugfs
pinctrl: amd: remove debounce filter setting in irq type settingdrivers/pinctrl/pinctrl-amd.c | 56 +++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 12 deletions(-)
Quoted 8 lines
Quoted 3 lines
--
2.28.0--
With Best Regards,
Andy Shevchenko
--
Best regards,
Coiby
Re: [PATCH v2 0/4] pinctrl: amd: debounce filter fixes
Quoted 5 lines · Coiby Xu
Quoted 1 line · Andy Shevchenko
Missed mailing list.
Sorry, I don't understand this comment. Which mailing list was missed?
The cover letter (this message) has missed the mailing list AFAICT. How I see it is a private message addressed to me and Linus personally.
Quoted 29 lines
Quoted 17 lines · Coiby Xu
Quoted 16 lines
There are three fixes (and one improvement) that fix the debounce filter issues in pinctrl-amd.
Changelog v2:
- Message-Id to Link and grammar fixes for commit messages [Andy Shevchenko]Coiby Xu (4):
pinctrl: amd: fix incorrect way to disable debounce filter
pinctrl: amd: use higher precision for 512 RtcClk
pinctrl: amd: print debounce filter info in debugfs
pinctrl: amd: remove debounce filter setting in irq type settingdrivers/pinctrl/pinctrl-amd.c | 56 +++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 12 deletions(-)Quoted 8 lines
Quoted 3 lines
--
2.28.0--
With Best Regards,
Andy Shevchenko--
Best regards,
Coiby
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v2 0/4] pinctrl: amd: debounce filter fixes
Quoted 10 lines · Andy Shevchenko
Quoted 5 lines · Coiby Xu
Quoted 1 line · Andy Shevchenko
Missed mailing list.
Sorry, I don't understand this comment. Which mailing list was missed?
The cover letter (this message) has missed the mailing list AFAICT. How I see it is a private message addressed to me and Linus personally.
Thank you for the explanation! I was looking at your previous reply which had the missing [email protected] added by you thus failed to understand you comment.
Quoted 32 lines
Quoted 22 lines
Quoted 22 lines · Coiby Xu
Quoted 19 lines
There are three fixes (and one improvement) that fix the debounce filter issues in pinctrl-amd.
Changelog v2:
- Message-Id to Link and grammar fixes for commit messages [Andy Shevchenko]Coiby Xu (4):
pinctrl: amd: fix incorrect way to disable debounce filter
pinctrl: amd: use higher precision for 512 RtcClk
pinctrl: amd: print debounce filter info in debugfs
pinctrl: amd: remove debounce filter setting in irq type settingdrivers/pinctrl/pinctrl-amd.c | 56 +++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 12 deletions(-)--
2.28.0Quoted 7 lines
Quoted 3 lines
--
With Best Regards,
Andy Shevchenko--
Best regards,
Coiby
Quoted 3 lines
--
With Best Regards,
Andy Shevchenko
--
Best regards,
Coiby