Commit b67328e1 authored by Claudiu Beznea's avatar Claudiu Beznea Committed by Linus Walleij

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: default avatarClaudiu Beznea <claudiu.beznea@microchip.com>
Acked-by: default avatarLudovic Desroches <ludovic.desroches@microchip.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 85e4e688
...@@ -72,10 +72,15 @@ static int gpio_banks; ...@@ -72,10 +72,15 @@ static int gpio_banks;
* DRIVE_STRENGTH_DEFAULT is just a placeholder to avoid changing the drive * DRIVE_STRENGTH_DEFAULT is just a placeholder to avoid changing the drive
* strength when there is no dt config for it. * strength when there is no dt config for it.
*/ */
#define DRIVE_STRENGTH_DEFAULT (0 << DRIVE_STRENGTH_SHIFT) enum drive_strength_bit {
#define DRIVE_STRENGTH_LOW (1 << DRIVE_STRENGTH_SHIFT) DRIVE_STRENGTH_BIT_DEF,
#define DRIVE_STRENGTH_MED (2 << DRIVE_STRENGTH_SHIFT) DRIVE_STRENGTH_BIT_LOW,
#define DRIVE_STRENGTH_HI (3 << DRIVE_STRENGTH_SHIFT) DRIVE_STRENGTH_BIT_MED,
DRIVE_STRENGTH_BIT_HI,
};
#define DRIVE_STRENGTH_BIT_MSK(name) (DRIVE_STRENGTH_BIT_##name << \
DRIVE_STRENGTH_SHIFT)
/** /**
* struct at91_pmx_func - describes AT91 pinmux functions * struct at91_pmx_func - describes AT91 pinmux functions
...@@ -551,7 +556,7 @@ static unsigned at91_mux_sama5d3_get_drivestrength(void __iomem *pio, ...@@ -551,7 +556,7 @@ static unsigned at91_mux_sama5d3_get_drivestrength(void __iomem *pio,
/* SAMA5 strength is 1:1 with our defines, /* SAMA5 strength is 1:1 with our defines,
* except 0 is equivalent to low per datasheet */ * except 0 is equivalent to low per datasheet */
if (!tmp) if (!tmp)
tmp = DRIVE_STRENGTH_LOW; tmp = DRIVE_STRENGTH_BIT_MSK(LOW);
return tmp; return tmp;
} }
...@@ -564,7 +569,7 @@ static unsigned at91_mux_sam9x5_get_drivestrength(void __iomem *pio, ...@@ -564,7 +569,7 @@ static unsigned at91_mux_sam9x5_get_drivestrength(void __iomem *pio,
/* strength is inverse in SAM9x5s hardware with the pinctrl defines /* strength is inverse in SAM9x5s hardware with the pinctrl defines
* hardware: 0 = hi, 1 = med, 2 = low, 3 = rsvd */ * hardware: 0 = hi, 1 = med, 2 = low, 3 = rsvd */
tmp = DRIVE_STRENGTH_HI - tmp; tmp = DRIVE_STRENGTH_BIT_MSK(HI) - tmp;
return tmp; return tmp;
} }
...@@ -600,7 +605,7 @@ static void at91_mux_sam9x5_set_drivestrength(void __iomem *pio, unsigned pin, ...@@ -600,7 +605,7 @@ static void at91_mux_sam9x5_set_drivestrength(void __iomem *pio, unsigned pin,
/* strength is inverse on SAM9x5s with our defines /* strength is inverse on SAM9x5s with our defines
* 0 = hi, 1 = med, 2 = low, 3 = rsvd */ * 0 = hi, 1 = med, 2 = low, 3 = rsvd */
setting = DRIVE_STRENGTH_HI - setting; setting = DRIVE_STRENGTH_BIT_MSK(HI) - setting;
set_drive_strength(pio + at91sam9x5_get_drive_register(pin), pin, set_drive_strength(pio + at91sam9x5_get_drive_register(pin), pin,
setting); setting);
...@@ -959,11 +964,11 @@ static int at91_pinconf_set(struct pinctrl_dev *pctldev, ...@@ -959,11 +964,11 @@ static int at91_pinconf_set(struct pinctrl_dev *pctldev,
} \ } \
} while (0) } while (0)
#define DBG_SHOW_FLAG_MASKED(mask,flag) do { \ #define DBG_SHOW_FLAG_MASKED(mask, flag, name) do { \
if ((config & mask) == flag) { \ if ((config & mask) == flag) { \
if (num_conf) \ if (num_conf) \
seq_puts(s, "|"); \ seq_puts(s, "|"); \
seq_puts(s, #flag); \ seq_puts(s, #name); \
num_conf++; \ num_conf++; \
} \ } \
} while (0) } while (0)
...@@ -981,9 +986,12 @@ static void at91_pinconf_dbg_show(struct pinctrl_dev *pctldev, ...@@ -981,9 +986,12 @@ static void at91_pinconf_dbg_show(struct pinctrl_dev *pctldev,
DBG_SHOW_FLAG(PULL_DOWN); DBG_SHOW_FLAG(PULL_DOWN);
DBG_SHOW_FLAG(DIS_SCHMIT); DBG_SHOW_FLAG(DIS_SCHMIT);
DBG_SHOW_FLAG(DEGLITCH); DBG_SHOW_FLAG(DEGLITCH);
DBG_SHOW_FLAG_MASKED(DRIVE_STRENGTH, DRIVE_STRENGTH_LOW); DBG_SHOW_FLAG_MASKED(DRIVE_STRENGTH, DRIVE_STRENGTH_BIT_MSK(LOW),
DBG_SHOW_FLAG_MASKED(DRIVE_STRENGTH, DRIVE_STRENGTH_MED); DRIVE_STRENGTH_LOW);
DBG_SHOW_FLAG_MASKED(DRIVE_STRENGTH, DRIVE_STRENGTH_HI); DBG_SHOW_FLAG_MASKED(DRIVE_STRENGTH, DRIVE_STRENGTH_BIT_MSK(MED),
DRIVE_STRENGTH_MED);
DBG_SHOW_FLAG_MASKED(DRIVE_STRENGTH, DRIVE_STRENGTH_BIT_MSK(HI),
DRIVE_STRENGTH_HI);
DBG_SHOW_FLAG(DEBOUNCE); DBG_SHOW_FLAG(DEBOUNCE);
if (config & DEBOUNCE) { if (config & DEBOUNCE) {
val = config >> DEBOUNCE_VAL_SHIFT; val = config >> DEBOUNCE_VAL_SHIFT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment