Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

pinctrl: at91: fix sam9x5 debounce/deglitch functions

Replace at91_mux_get_deglitch with at91_mux_pio3_get_deglitch when using
sam9x5 (pio3) IP.
at91_mux_get_deglitch only test the activation of the "Input Filter" which
may be overloaded by the activation of the "Input Filter Slow Clock" to use
the input filter as a debounce filter instead of a deglitch filter.

Fix at91_mux_pio3_get_debounce to test the activation of the Input Filter
before testing the activation of the debounce filter (Input Filter Slow
Clock depends on Input Filter).

Fix at91_mux_pio3_set_debounce function to avoid disabling the deglitch
filter ("Input Filter") when debounce filter is disabled.

Signed-off-by: Boris BREZILLON <b.brezillon@overkiz.com>
Acked-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Boris BREZILLON and committed by
Linus Walleij
c8dba02e 77966ad7

+13 -5
+13 -5
drivers/pinctrl/pinctrl-at91.c
··· 417 417 __raw_writel(mask, pio + (is_on ? PIO_IFER : PIO_IFDR)); 418 418 } 419 419 420 + static bool at91_mux_pio3_get_deglitch(void __iomem *pio, unsigned pin) 421 + { 422 + if ((__raw_readl(pio + PIO_IFSR) >> pin) & 0x1) 423 + return !((__raw_readl(pio + PIO_IFSCSR) >> pin) & 0x1); 424 + 425 + return false; 426 + } 427 + 420 428 static void at91_mux_pio3_set_deglitch(void __iomem *pio, unsigned mask, bool is_on) 421 429 { 422 430 if (is_on) ··· 436 428 { 437 429 *div = __raw_readl(pio + PIO_SCDR); 438 430 439 - return (__raw_readl(pio + PIO_IFSCSR) >> pin) & 0x1; 431 + return ((__raw_readl(pio + PIO_IFSR) >> pin) & 0x1) && 432 + ((__raw_readl(pio + PIO_IFSCSR) >> pin) & 0x1); 440 433 } 441 434 442 435 static void at91_mux_pio3_set_debounce(void __iomem *pio, unsigned mask, ··· 447 438 __raw_writel(mask, pio + PIO_IFSCER); 448 439 __raw_writel(div & PIO_SCDR_DIV, pio + PIO_SCDR); 449 440 __raw_writel(mask, pio + PIO_IFER); 450 - } else { 451 - __raw_writel(mask, pio + PIO_IFDR); 452 - } 441 + } else 442 + __raw_writel(mask, pio + PIO_IFSCDR); 453 443 } 454 444 455 445 static bool at91_mux_pio3_get_pulldown(void __iomem *pio, unsigned pin) ··· 486 478 .mux_B_periph = at91_mux_pio3_set_B_periph, 487 479 .mux_C_periph = at91_mux_pio3_set_C_periph, 488 480 .mux_D_periph = at91_mux_pio3_set_D_periph, 489 - .get_deglitch = at91_mux_get_deglitch, 481 + .get_deglitch = at91_mux_pio3_get_deglitch, 490 482 .set_deglitch = at91_mux_pio3_set_deglitch, 491 483 .get_debounce = at91_mux_pio3_get_debounce, 492 484 .set_debounce = at91_mux_pio3_set_debounce,