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

pinctrl: at91-pio4: add support for slew-rate

SAMA7G5 supports slew rate configuration. Adapt the driver for this.
For output switching frequencies lower than 50MHz the slew rate needs to
be enabled. Since most of the pins on SAMA7G5 fall into this category
enabled the slew rate by default.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Link: https://lore.kernel.org/r/1611747945-29960-3-git-send-email-claudiu.beznea@microchip.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Claudiu Beznea and committed by
Linus Walleij
c709135e aad018aa

+27
+27
drivers/pinctrl/pinctrl-at91-pio4.c
··· 36 36 #define ATMEL_PIO_DIR_MASK BIT(8) 37 37 #define ATMEL_PIO_PUEN_MASK BIT(9) 38 38 #define ATMEL_PIO_PDEN_MASK BIT(10) 39 + #define ATMEL_PIO_SR_MASK BIT(11) 39 40 #define ATMEL_PIO_IFEN_MASK BIT(12) 40 41 #define ATMEL_PIO_IFSCEN_MASK BIT(13) 41 42 #define ATMEL_PIO_OPD_MASK BIT(14) ··· 77 76 * @nbanks: number of PIO banks 78 77 * @last_bank_count: number of lines in the last bank (can be less than 79 78 * the rest of the banks). 79 + * @slew_rate_support: slew rate support 80 80 */ 81 81 struct atmel_pioctrl_data { 82 82 unsigned nbanks; 83 83 unsigned last_bank_count; 84 + unsigned int slew_rate_support; 84 85 }; 85 86 86 87 struct atmel_group { ··· 120 117 * @pm_suspend_backup: backup/restore register values on suspend/resume 121 118 * @dev: device entry for the Atmel PIO controller. 122 119 * @node: node of the Atmel PIO controller. 120 + * @slew_rate_support: slew rate support 123 121 */ 124 122 struct atmel_pioctrl { 125 123 void __iomem *reg_base; ··· 142 138 } *pm_suspend_backup; 143 139 struct device *dev; 144 140 struct device_node *node; 141 + unsigned int slew_rate_support; 145 142 }; 146 143 147 144 static const char * const atmel_functions[] = { ··· 765 760 return -EINVAL; 766 761 arg = 1; 767 762 break; 763 + case PIN_CONFIG_SLEW_RATE: 764 + if (!atmel_pioctrl->slew_rate_support) 765 + return -EOPNOTSUPP; 766 + if (!(res & ATMEL_PIO_SR_MASK)) 767 + return -EINVAL; 768 + arg = 1; 769 + break; 768 770 case ATMEL_PIN_CONFIG_DRIVE_STRENGTH: 769 771 if (!(res & ATMEL_PIO_DRVSTR_MASK)) 770 772 return -EINVAL; ··· 804 792 805 793 dev_dbg(pctldev->dev, "%s: pin=%u, config=0x%lx\n", 806 794 __func__, pin_id, configs[i]); 795 + 796 + /* Keep slew rate enabled by default. */ 797 + if (atmel_pioctrl->slew_rate_support) 798 + conf |= ATMEL_PIO_SR_MASK; 807 799 808 800 switch (param) { 809 801 case PIN_CONFIG_BIAS_DISABLE: ··· 866 850 ATMEL_PIO_SODR); 867 851 } 868 852 break; 853 + case PIN_CONFIG_SLEW_RATE: 854 + if (!atmel_pioctrl->slew_rate_support) 855 + break; 856 + /* And remove it if explicitly requested. */ 857 + if (arg == 0) 858 + conf &= ~ATMEL_PIO_SR_MASK; 859 + break; 869 860 case ATMEL_PIN_CONFIG_DRIVE_STRENGTH: 870 861 switch (arg) { 871 862 case ATMEL_PIO_DRVSTR_LO: ··· 924 901 seq_printf(s, "%s ", "open-drain"); 925 902 if (conf & ATMEL_PIO_SCHMITT_MASK) 926 903 seq_printf(s, "%s ", "schmitt"); 904 + if (atmel_pioctrl->slew_rate_support && (conf & ATMEL_PIO_SR_MASK)) 905 + seq_printf(s, "%s ", "slew-rate"); 927 906 if (conf & ATMEL_PIO_DRVSTR_MASK) { 928 907 switch ((conf & ATMEL_PIO_DRVSTR_MASK) >> ATMEL_PIO_DRVSTR_OFFSET) { 929 908 case ATMEL_PIO_DRVSTR_ME: ··· 1019 994 static const struct atmel_pioctrl_data microchip_sama7g5_pioctrl_data = { 1020 995 .nbanks = 5, 1021 996 .last_bank_count = 8, /* sama7g5 has only PE0 to PE7 */ 997 + .slew_rate_support = 1, 1022 998 }; 1023 999 1024 1000 static const struct of_device_id atmel_pctrl_of_match[] = { ··· 1065 1039 atmel_pioctrl->npins -= ATMEL_PIO_NPINS_PER_BANK; 1066 1040 atmel_pioctrl->npins += atmel_pioctrl_data->last_bank_count; 1067 1041 } 1042 + atmel_pioctrl->slew_rate_support = atmel_pioctrl_data->slew_rate_support; 1068 1043 1069 1044 atmel_pioctrl->reg_base = devm_platform_ioremap_resource(pdev, 0); 1070 1045 if (IS_ERR(atmel_pioctrl->reg_base))