pinctrl-at91.c (fe0f59c41255d339f4f059be62c350c3c48a3f95) | pinctrl-at91.c (96bb12deadac74ad1053d6bb704aaa33417b85a6) |
---|---|
1/* 2 * at91 pinctrl driver based on at91 pinmux core 3 * 4 * Copyright (C) 2011-2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> 5 * 6 * Under GPLv2 only 7 */ 8 --- 42 unchanged lines hidden (view full) --- 51#define PULL_UP (1 << 0) 52#define MULTI_DRIVE (1 << 1) 53#define DEGLITCH (1 << 2) 54#define PULL_DOWN (1 << 3) 55#define DIS_SCHMIT (1 << 4) 56#define DRIVE_STRENGTH_SHIFT 5 57#define DRIVE_STRENGTH_MASK 0x3 58#define DRIVE_STRENGTH (DRIVE_STRENGTH_MASK << DRIVE_STRENGTH_SHIFT) | 1/* 2 * at91 pinctrl driver based on at91 pinmux core 3 * 4 * Copyright (C) 2011-2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> 5 * 6 * Under GPLv2 only 7 */ 8 --- 42 unchanged lines hidden (view full) --- 51#define PULL_UP (1 << 0) 52#define MULTI_DRIVE (1 << 1) 53#define DEGLITCH (1 << 2) 54#define PULL_DOWN (1 << 3) 55#define DIS_SCHMIT (1 << 4) 56#define DRIVE_STRENGTH_SHIFT 5 57#define DRIVE_STRENGTH_MASK 0x3 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#define DEBOUNCE (1 << 16) 60#define DEBOUNCE_VAL_SHIFT 17 61#define DEBOUNCE_VAL (0x3fff << DEBOUNCE_VAL_SHIFT) 62 63/** 64 * These defines will translated the dt binding settings to our internal 65 * settings. They are not necessarily the same value as the register setting. 66 * The actual drive strength current of low, medium and high must be looked up --- 303 unchanged lines hidden (view full) --- 370static void at91_mux_set_pullup(void __iomem *pio, unsigned mask, bool on) 371{ 372 if (on) 373 writel_relaxed(mask, pio + PIO_PPDDR); 374 375 writel_relaxed(mask, pio + (on ? PIO_PUER : PIO_PUDR)); 376} 377 | 62#define DEBOUNCE (1 << 16) 63#define DEBOUNCE_VAL_SHIFT 17 64#define DEBOUNCE_VAL (0x3fff << DEBOUNCE_VAL_SHIFT) 65 66/** 67 * These defines will translated the dt binding settings to our internal 68 * settings. They are not necessarily the same value as the register setting. 69 * The actual drive strength current of low, medium and high must be looked up --- 303 unchanged lines hidden (view full) --- 373static void at91_mux_set_pullup(void __iomem *pio, unsigned mask, bool on) 374{ 375 if (on) 376 writel_relaxed(mask, pio + PIO_PPDDR); 377 378 writel_relaxed(mask, pio + (on ? PIO_PUER : PIO_PUDR)); 379} 380 |
381static bool at91_mux_get_output(void __iomem *pio, unsigned int pin, bool *val) 382{ 383 *val = (readl_relaxed(pio + PIO_ODSR) >> pin) & 0x1; 384 return (readl_relaxed(pio + PIO_OSR) >> pin) & 0x1; 385} 386 387static void at91_mux_set_output(void __iomem *pio, unsigned int mask, 388 bool is_on, bool val) 389{ 390 writel_relaxed(mask, pio + (val ? PIO_SODR : PIO_CODR)); 391 writel_relaxed(mask, pio + (is_on ? PIO_OER : PIO_ODR)); 392} 393 |
|
378static unsigned at91_mux_get_multidrive(void __iomem *pio, unsigned pin) 379{ 380 return (readl_relaxed(pio + PIO_MDSR) >> pin) & 0x1; 381} 382 383static void at91_mux_set_multidrive(void __iomem *pio, unsigned mask, bool on) 384{ 385 writel_relaxed(mask, pio + (on ? PIO_MDER : PIO_MDDR)); --- 457 unchanged lines hidden (view full) --- 843 844static int at91_pinconf_get(struct pinctrl_dev *pctldev, 845 unsigned pin_id, unsigned long *config) 846{ 847 struct at91_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); 848 void __iomem *pio; 849 unsigned pin; 850 int div; | 394static unsigned at91_mux_get_multidrive(void __iomem *pio, unsigned pin) 395{ 396 return (readl_relaxed(pio + PIO_MDSR) >> pin) & 0x1; 397} 398 399static void at91_mux_set_multidrive(void __iomem *pio, unsigned mask, bool on) 400{ 401 writel_relaxed(mask, pio + (on ? PIO_MDER : PIO_MDDR)); --- 457 unchanged lines hidden (view full) --- 859 860static int at91_pinconf_get(struct pinctrl_dev *pctldev, 861 unsigned pin_id, unsigned long *config) 862{ 863 struct at91_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); 864 void __iomem *pio; 865 unsigned pin; 866 int div; |
867 bool out; |
|
851 852 *config = 0; 853 dev_dbg(info->dev, "%s:%d, pin_id=%d", __func__, __LINE__, pin_id); 854 pio = pin_to_controller(info, pin_to_bank(pin_id)); 855 856 if (!pio) 857 return -EINVAL; 858 --- 11 unchanged lines hidden (view full) --- 870 *config |= DEBOUNCE | (div << DEBOUNCE_VAL_SHIFT); 871 if (info->ops->get_pulldown && info->ops->get_pulldown(pio, pin)) 872 *config |= PULL_DOWN; 873 if (info->ops->get_schmitt_trig && info->ops->get_schmitt_trig(pio, pin)) 874 *config |= DIS_SCHMIT; 875 if (info->ops->get_drivestrength) 876 *config |= (info->ops->get_drivestrength(pio, pin) 877 << DRIVE_STRENGTH_SHIFT); | 868 869 *config = 0; 870 dev_dbg(info->dev, "%s:%d, pin_id=%d", __func__, __LINE__, pin_id); 871 pio = pin_to_controller(info, pin_to_bank(pin_id)); 872 873 if (!pio) 874 return -EINVAL; 875 --- 11 unchanged lines hidden (view full) --- 887 *config |= DEBOUNCE | (div << DEBOUNCE_VAL_SHIFT); 888 if (info->ops->get_pulldown && info->ops->get_pulldown(pio, pin)) 889 *config |= PULL_DOWN; 890 if (info->ops->get_schmitt_trig && info->ops->get_schmitt_trig(pio, pin)) 891 *config |= DIS_SCHMIT; 892 if (info->ops->get_drivestrength) 893 *config |= (info->ops->get_drivestrength(pio, pin) 894 << DRIVE_STRENGTH_SHIFT); |
895 if (at91_mux_get_output(pio, pin, &out)) 896 *config |= OUTPUT | (out << OUTPUT_VAL_SHIFT); |
|
878 879 return 0; 880} 881 882static int at91_pinconf_set(struct pinctrl_dev *pctldev, 883 unsigned pin_id, unsigned long *configs, 884 unsigned num_configs) 885{ --- 16 unchanged lines hidden (view full) --- 902 return -EINVAL; 903 904 pin = pin_id % MAX_NB_GPIO_PER_BANK; 905 mask = pin_to_mask(pin); 906 907 if (config & PULL_UP && config & PULL_DOWN) 908 return -EINVAL; 909 | 897 898 return 0; 899} 900 901static int at91_pinconf_set(struct pinctrl_dev *pctldev, 902 unsigned pin_id, unsigned long *configs, 903 unsigned num_configs) 904{ --- 16 unchanged lines hidden (view full) --- 921 return -EINVAL; 922 923 pin = pin_id % MAX_NB_GPIO_PER_BANK; 924 mask = pin_to_mask(pin); 925 926 if (config & PULL_UP && config & PULL_DOWN) 927 return -EINVAL; 928 |
929 at91_mux_set_output(pio, mask, config & OUTPUT, 930 (config & OUTPUT_VAL) >> OUTPUT_VAL_SHIFT); |
|
910 at91_mux_set_pullup(pio, mask, config & PULL_UP); 911 at91_mux_set_multidrive(pio, mask, config & MULTI_DRIVE); 912 if (info->ops->set_deglitch) 913 info->ops->set_deglitch(pio, mask, config & DEGLITCH); 914 if (info->ops->set_debounce) 915 info->ops->set_debounce(pio, mask, config & DEBOUNCE, 916 (config & DEBOUNCE_VAL) >> DEBOUNCE_VAL_SHIFT); 917 if (info->ops->set_pulldown) --- 902 unchanged lines hidden --- | 931 at91_mux_set_pullup(pio, mask, config & PULL_UP); 932 at91_mux_set_multidrive(pio, mask, config & MULTI_DRIVE); 933 if (info->ops->set_deglitch) 934 info->ops->set_deglitch(pio, mask, config & DEGLITCH); 935 if (info->ops->set_debounce) 936 info->ops->set_debounce(pio, mask, config & DEBOUNCE, 937 (config & DEBOUNCE_VAL) >> DEBOUNCE_VAL_SHIFT); 938 if (info->ops->set_pulldown) --- 902 unchanged lines hidden --- |