Skip to content

Commit 1d66dcd

Browse files
committed
pinctrl: at91-pio4: add support for drive-strength property
Add support for the drive-strength property. Usually its value is expressed in mA. Since the numeric value depends on VDDIOP voltage, the controller uses low, medium and high to define the drive-strengh. The pio controller accepts two values for the low drive: 0 or 1. As most of the time it is not needed to change the drive, 0 is considered as the default value. The low-drive value won't be advertised through pinconf-pins file excepted if it has been set explicitly in the device tree. Signed-off-by: Ludovic Desroches <ludovic.desroches@microchip.com>
1 parent ee92ac1 commit 1d66dcd

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

drivers/pinctrl/pinctrl-at91-pio4.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* GNU General Public License for more details.
1515
*/
1616

17+
#include <dt-bindings/pinctrl/at91.h>
1718
#include <linux/clk.h>
1819
#include <linux/gpio/driver.h>
1920
/* FIXME: needed for gpio_to_irq(), get rid of this */
@@ -49,6 +50,8 @@
4950
#define ATMEL_PIO_IFSCEN_MASK BIT(13)
5051
#define ATMEL_PIO_OPD_MASK BIT(14)
5152
#define ATMEL_PIO_SCHMITT_MASK BIT(15)
53+
#define ATMEL_PIO_DRVSTR_MASK GENMASK(17, 16)
54+
#define ATMEL_PIO_DRVSTR_OFFSET 16
5255
#define ATMEL_PIO_CFGR_EVTSEL_MASK GENMASK(26, 24)
5356
#define ATMEL_PIO_CFGR_EVTSEL_FALLING (0 << 24)
5457
#define ATMEL_PIO_CFGR_EVTSEL_RISING (1 << 24)
@@ -682,6 +685,11 @@ static int atmel_conf_pin_config_group_get(struct pinctrl_dev *pctldev,
682685
return -EINVAL;
683686
arg = 1;
684687
break;
688+
case PIN_CONFIG_DRIVE_STRENGTH:
689+
if (!(res & ATMEL_PIO_DRVSTR_MASK))
690+
return -EINVAL;
691+
arg = (res & ATMEL_PIO_DRVSTR_MASK) >> ATMEL_PIO_DRVSTR_OFFSET;
692+
break;
685693
case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
686694
if (!(res & ATMEL_PIO_SCHMITT_MASK))
687695
return -EINVAL;
@@ -734,6 +742,18 @@ static int atmel_conf_pin_config_group_set(struct pinctrl_dev *pctldev,
734742
else
735743
conf |= ATMEL_PIO_OPD_MASK;
736744
break;
745+
case PIN_CONFIG_DRIVE_STRENGTH:
746+
switch (arg) {
747+
case ATMEL_PIO_DRVSTR_LO:
748+
case ATMEL_PIO_DRVSTR_ME:
749+
case ATMEL_PIO_DRVSTR_HI:
750+
conf &= (~ATMEL_PIO_DRVSTR_MASK);
751+
conf |= arg << ATMEL_PIO_DRVSTR_OFFSET;
752+
break;
753+
default:
754+
dev_warn(pctldev->dev, "drive strength not updated (incorrect value)\n");
755+
}
756+
break;
737757
case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
738758
if (arg == 0)
739759
conf |= ATMEL_PIO_SCHMITT_MASK;
@@ -811,6 +831,19 @@ static void atmel_conf_pin_config_dbg_show(struct pinctrl_dev *pctldev,
811831
seq_printf(s, "%s ", "open-drain");
812832
if (conf & ATMEL_PIO_SCHMITT_MASK)
813833
seq_printf(s, "%s ", "schmitt");
834+
if (conf & ATMEL_PIO_DRVSTR_MASK) {
835+
switch ((conf & ATMEL_PIO_DRVSTR_MASK) >> ATMEL_PIO_DRVSTR_OFFSET) {
836+
case ATMEL_PIO_DRVSTR_LO:
837+
seq_printf(s, "%s ", "low-drive");
838+
break;
839+
case ATMEL_PIO_DRVSTR_ME:
840+
seq_printf(s, "%s ", "medium-drive");
841+
break;
842+
case ATMEL_PIO_DRVSTR_HI:
843+
seq_printf(s, "%s ", "high-drive");
844+
break;
845+
}
846+
}
814847
}
815848

816849
static const struct pinconf_ops atmel_confops = {

include/dt-bindings/pinctrl/at91.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,8 @@
3939
#define AT91_PERIPH_C 3
4040
#define AT91_PERIPH_D 4
4141

42+
#define ATMEL_PIO_DRVSTR_LO 1
43+
#define ATMEL_PIO_DRVSTR_ME 2
44+
#define ATMEL_PIO_DRVSTR_HI 3
45+
4246
#endif /* __DT_BINDINGS_AT91_PINCTRL_H__ */

0 commit comments

Comments
 (0)