diff options
author | Claudiu Beznea <claudiu.beznea@microchip.com> | 2019-02-07 04:24:46 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2019-02-08 07:04:41 -0500 |
commit | b67328e1cf9735d2491ef9402fb7439db1d6e2ae (patch) | |
tree | 8a8adb44cd54613dc86a6a96b6ca52af70cdeae2 | |
parent | 85e4e6881dbaae42bbac935c346753bea412ab76 (diff) |
pinctrl: at91: add option to use drive strength bits
SAM9X60 uses high and low drive strengths. To implement this, in
at91_pinctrl_mux_ops::set_drivestrength and
at91_pinctrl_mux_ops::get_drivestrength we need bit numbers of
drive strengths (1 for low, 2 for high), thus change the code to
allow the usage of drive strength bit numbers.
Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r-- | drivers/pinctrl/pinctrl-at91.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c index 3d49bbbcdbc7..e907093b5b13 100644 --- a/drivers/pinctrl/pinctrl-at91.c +++ b/drivers/pinctrl/pinctrl-at91.c | |||
@@ -72,10 +72,15 @@ static int gpio_banks; | |||
72 | * DRIVE_STRENGTH_DEFAULT is just a placeholder to avoid changing the drive | 72 | * DRIVE_STRENGTH_DEFAULT is just a placeholder to avoid changing the drive |
73 | * strength when there is no dt config for it. | 73 | * strength when there is no dt config for it. |
74 | */ | 74 | */ |
75 | #define DRIVE_STRENGTH_DEFAULT (0 << DRIVE_STRENGTH_SHIFT) | 75 | enum drive_strength_bit { |
76 | #define DRIVE_STRENGTH_LOW (1 << DRIVE_STRENGTH_SHIFT) | 76 | DRIVE_STRENGTH_BIT_DEF, |
77 | #define DRIVE_STRENGTH_MED (2 << DRIVE_STRENGTH_SHIFT) | 77 | DRIVE_STRENGTH_BIT_LOW, |
78 | #define DRIVE_STRENGTH_HI (3 << DRIVE_STRENGTH_SHIFT) | 78 | DRIVE_STRENGTH_BIT_MED, |
79 | DRIVE_STRENGTH_BIT_HI, | ||
80 | }; | ||
81 | |||
82 | #define DRIVE_STRENGTH_BIT_MSK(name) (DRIVE_STRENGTH_BIT_##name << \ | ||
83 | DRIVE_STRENGTH_SHIFT) | ||
79 | 84 | ||
80 | /** | 85 | /** |
81 | * struct at91_pmx_func - describes AT91 pinmux functions | 86 | * struct at91_pmx_func - describes AT91 pinmux functions |
@@ -551,7 +556,7 @@ static unsigned at91_mux_sama5d3_get_drivestrength(void __iomem *pio, | |||
551 | /* SAMA5 strength is 1:1 with our defines, | 556 | /* SAMA5 strength is 1:1 with our defines, |
552 | * except 0 is equivalent to low per datasheet */ | 557 | * except 0 is equivalent to low per datasheet */ |
553 | if (!tmp) | 558 | if (!tmp) |
554 | tmp = DRIVE_STRENGTH_LOW; | 559 | tmp = DRIVE_STRENGTH_BIT_MSK(LOW); |
555 | 560 | ||
556 | return tmp; | 561 | return tmp; |
557 | } | 562 | } |
@@ -564,7 +569,7 @@ static unsigned at91_mux_sam9x5_get_drivestrength(void __iomem *pio, | |||
564 | 569 | ||
565 | /* strength is inverse in SAM9x5s hardware with the pinctrl defines | 570 | /* strength is inverse in SAM9x5s hardware with the pinctrl defines |
566 | * hardware: 0 = hi, 1 = med, 2 = low, 3 = rsvd */ | 571 | * hardware: 0 = hi, 1 = med, 2 = low, 3 = rsvd */ |
567 | tmp = DRIVE_STRENGTH_HI - tmp; | 572 | tmp = DRIVE_STRENGTH_BIT_MSK(HI) - tmp; |
568 | 573 | ||
569 | return tmp; | 574 | return tmp; |
570 | } | 575 | } |
@@ -600,7 +605,7 @@ static void at91_mux_sam9x5_set_drivestrength(void __iomem *pio, unsigned pin, | |||
600 | 605 | ||
601 | /* strength is inverse on SAM9x5s with our defines | 606 | /* strength is inverse on SAM9x5s with our defines |
602 | * 0 = hi, 1 = med, 2 = low, 3 = rsvd */ | 607 | * 0 = hi, 1 = med, 2 = low, 3 = rsvd */ |
603 | setting = DRIVE_STRENGTH_HI - setting; | 608 | setting = DRIVE_STRENGTH_BIT_MSK(HI) - setting; |
604 | 609 | ||
605 | set_drive_strength(pio + at91sam9x5_get_drive_register(pin), pin, | 610 | set_drive_strength(pio + at91sam9x5_get_drive_register(pin), pin, |
606 | setting); | 611 | setting); |
@@ -959,11 +964,11 @@ static int at91_pinconf_set(struct pinctrl_dev *pctldev, | |||
959 | } \ | 964 | } \ |
960 | } while (0) | 965 | } while (0) |
961 | 966 | ||
962 | #define DBG_SHOW_FLAG_MASKED(mask,flag) do { \ | 967 | #define DBG_SHOW_FLAG_MASKED(mask, flag, name) do { \ |
963 | if ((config & mask) == flag) { \ | 968 | if ((config & mask) == flag) { \ |
964 | if (num_conf) \ | 969 | if (num_conf) \ |
965 | seq_puts(s, "|"); \ | 970 | seq_puts(s, "|"); \ |
966 | seq_puts(s, #flag); \ | 971 | seq_puts(s, #name); \ |
967 | num_conf++; \ | 972 | num_conf++; \ |
968 | } \ | 973 | } \ |
969 | } while (0) | 974 | } while (0) |
@@ -981,9 +986,12 @@ static void at91_pinconf_dbg_show(struct pinctrl_dev *pctldev, | |||
981 | DBG_SHOW_FLAG(PULL_DOWN); | 986 | DBG_SHOW_FLAG(PULL_DOWN); |
982 | DBG_SHOW_FLAG(DIS_SCHMIT); | 987 | DBG_SHOW_FLAG(DIS_SCHMIT); |
983 | DBG_SHOW_FLAG(DEGLITCH); | 988 | DBG_SHOW_FLAG(DEGLITCH); |
984 | DBG_SHOW_FLAG_MASKED(DRIVE_STRENGTH, DRIVE_STRENGTH_LOW); | 989 | DBG_SHOW_FLAG_MASKED(DRIVE_STRENGTH, DRIVE_STRENGTH_BIT_MSK(LOW), |
985 | DBG_SHOW_FLAG_MASKED(DRIVE_STRENGTH, DRIVE_STRENGTH_MED); | 990 | DRIVE_STRENGTH_LOW); |
986 | DBG_SHOW_FLAG_MASKED(DRIVE_STRENGTH, DRIVE_STRENGTH_HI); | 991 | DBG_SHOW_FLAG_MASKED(DRIVE_STRENGTH, DRIVE_STRENGTH_BIT_MSK(MED), |
992 | DRIVE_STRENGTH_MED); | ||
993 | DBG_SHOW_FLAG_MASKED(DRIVE_STRENGTH, DRIVE_STRENGTH_BIT_MSK(HI), | ||
994 | DRIVE_STRENGTH_HI); | ||
987 | DBG_SHOW_FLAG(DEBOUNCE); | 995 | DBG_SHOW_FLAG(DEBOUNCE); |
988 | if (config & DEBOUNCE) { | 996 | if (config & DEBOUNCE) { |
989 | val = config >> DEBOUNCE_VAL_SHIFT; | 997 | val = config >> DEBOUNCE_VAL_SHIFT; |