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

pinctrl: at91: add support for OUTPUT config

Add support for pin output control through the pinctrl config:
- support enabling/disabling output on a given pin
- support output level setting (high or low)

Signed-off-by: Boris BREZILLON <b.brezillon@overkiz.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Boris BREZILLON and committed by
Linus Walleij
96bb12de e11dee2e

+25
+2
Documentation/devicetree/bindings/pinctrl/atmel,at91-pinctrl.txt
··· 98 98 01 - Low 99 99 10 - Medium 100 100 11 - High 101 + OUTPUT (1 << 7): indicate this pin need to be configured as an output. 102 + OUTPUT_VAL (1 << 8): output val (1 = high, 0 = low) 101 103 DEBOUNCE (1 << 16): indicate this pin needs debounce. 102 104 DEBOUNCE_VAL (0x3fff << 17): debounce value. 103 105
+21
drivers/pinctrl/pinctrl-at91.c
··· 56 56 #define DRIVE_STRENGTH_SHIFT 5 57 57 #define DRIVE_STRENGTH_MASK 0x3 58 58 #define DRIVE_STRENGTH (DRIVE_STRENGTH_MASK << DRIVE_STRENGTH_SHIFT) 59 + #define OUTPUT (1 << 7) 60 + #define OUTPUT_VAL_SHIFT 8 61 + #define OUTPUT_VAL (0x1 << OUTPUT_VAL_SHIFT) 59 62 #define DEBOUNCE (1 << 16) 60 63 #define DEBOUNCE_VAL_SHIFT 17 61 64 #define DEBOUNCE_VAL (0x3fff << DEBOUNCE_VAL_SHIFT) ··· 376 373 writel_relaxed(mask, pio + PIO_PPDDR); 377 374 378 375 writel_relaxed(mask, pio + (on ? PIO_PUER : PIO_PUDR)); 376 + } 377 + 378 + static bool at91_mux_get_output(void __iomem *pio, unsigned int pin, bool *val) 379 + { 380 + *val = (readl_relaxed(pio + PIO_ODSR) >> pin) & 0x1; 381 + return (readl_relaxed(pio + PIO_OSR) >> pin) & 0x1; 382 + } 383 + 384 + static void at91_mux_set_output(void __iomem *pio, unsigned int mask, 385 + bool is_on, bool val) 386 + { 387 + writel_relaxed(mask, pio + (val ? PIO_SODR : PIO_CODR)); 388 + writel_relaxed(mask, pio + (is_on ? PIO_OER : PIO_ODR)); 379 389 } 380 390 381 391 static unsigned at91_mux_get_multidrive(void __iomem *pio, unsigned pin) ··· 864 848 void __iomem *pio; 865 849 unsigned pin; 866 850 int div; 851 + bool out; 867 852 868 853 *config = 0; 869 854 dev_dbg(info->dev, "%s:%d, pin_id=%d", __func__, __LINE__, pin_id); ··· 892 875 if (info->ops->get_drivestrength) 893 876 *config |= (info->ops->get_drivestrength(pio, pin) 894 877 << DRIVE_STRENGTH_SHIFT); 878 + if (at91_mux_get_output(pio, pin, &out)) 879 + *config |= OUTPUT | (out << OUTPUT_VAL_SHIFT); 895 880 896 881 return 0; 897 882 } ··· 926 907 if (config & PULL_UP && config & PULL_DOWN) 927 908 return -EINVAL; 928 909 910 + at91_mux_set_output(pio, mask, config & OUTPUT, 911 + (config & OUTPUT_VAL) >> OUTPUT_VAL_SHIFT); 929 912 at91_mux_set_pullup(pio, mask, config & PULL_UP); 930 913 at91_mux_set_multidrive(pio, mask, config & MULTI_DRIVE); 931 914 if (info->ops->set_deglitch)
+2
include/dt-bindings/pinctrl/at91.h
··· 15 15 #define AT91_PINCTRL_DEGLITCH (1 << 2) 16 16 #define AT91_PINCTRL_PULL_DOWN (1 << 3) 17 17 #define AT91_PINCTRL_DIS_SCHMIT (1 << 4) 18 + #define AT91_PINCTRL_OUTPUT (1 << 7) 19 + #define AT91_PINCTRL_OUTPUT_VAL(x) ((x & 0x1) << 8) 18 20 #define AT91_PINCTRL_DEBOUNCE (1 << 16) 19 21 #define AT91_PINCTRL_DEBOUNCE_VAL(x) (x << 17) 20 22