Commit 9eaa98a6 authored by Masahiro Yamada's avatar Masahiro Yamada Committed by Linus Walleij

pinctrl: uniphier: rename macros for drive strength control

The new ARMv8 SoC, PH1-LD20, supports more fine-grained drive
strength control.  Some of the configuration registers on it have
3-bit width.

The feature will be supported in the next commit, but a problem is
that macro names are getting longer and longer in the current naming
scheme.

Before moving forward, this commit renames macros as follows:

  UNIPHIER_PIN_DRV_4_8        -> UNIPHIER_PIN_DRV_1BIT
  UNIPHIER_PIN_DRV_8_12_16_20 -> UNIPHIER_PIN_DRV_2BIT
  UNIPHIER_PIN_DRV_FIXED_4    -> UNIPHIER_PIN_DRV_FIXED4
  UNIPHIER_PIN_DRV_FIXED_5    -> UNIPHIER_PIN_DRV_FIXED5
  UNIPHIER_PIN_DRV_FIXED_8    -> UNIPHIER_PIN_DRV_FIXED8
Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent fc78a566
...@@ -65,7 +65,7 @@ static void uniphier_pctl_pin_dbg_show(struct pinctrl_dev *pctldev, ...@@ -65,7 +65,7 @@ static void uniphier_pctl_pin_dbg_show(struct pinctrl_dev *pctldev,
struct seq_file *s, unsigned offset) struct seq_file *s, unsigned offset)
{ {
const struct pinctrl_pin_desc *pin = &pctldev->desc->pins[offset]; const struct pinctrl_pin_desc *pin = &pctldev->desc->pins[offset];
const char *pull_dir, *drv_str; const char *pull_dir, *drv_type;
switch (uniphier_pin_get_pull_dir(pin->drv_data)) { switch (uniphier_pin_get_pull_dir(pin->drv_data)) {
case UNIPHIER_PIN_PULL_UP: case UNIPHIER_PIN_PULL_UP:
...@@ -87,30 +87,30 @@ static void uniphier_pctl_pin_dbg_show(struct pinctrl_dev *pctldev, ...@@ -87,30 +87,30 @@ static void uniphier_pctl_pin_dbg_show(struct pinctrl_dev *pctldev,
BUG(); BUG();
} }
switch (uniphier_pin_get_drv_str(pin->drv_data)) { switch (uniphier_pin_get_drv_type(pin->drv_data)) {
case UNIPHIER_PIN_DRV_4_8: case UNIPHIER_PIN_DRV_1BIT:
drv_str = "4/8(mA)"; drv_type = "4/8(mA)";
break; break;
case UNIPHIER_PIN_DRV_8_12_16_20: case UNIPHIER_PIN_DRV_2BIT:
drv_str = "8/12/16/20(mA)"; drv_type = "8/12/16/20(mA)";
break; break;
case UNIPHIER_PIN_DRV_FIXED_4: case UNIPHIER_PIN_DRV_FIXED4:
drv_str = "4(mA)"; drv_type = "4(mA)";
break; break;
case UNIPHIER_PIN_DRV_FIXED_5: case UNIPHIER_PIN_DRV_FIXED5:
drv_str = "5(mA)"; drv_type = "5(mA)";
break; break;
case UNIPHIER_PIN_DRV_FIXED_8: case UNIPHIER_PIN_DRV_FIXED8:
drv_str = "8(mA)"; drv_type = "8(mA)";
break; break;
case UNIPHIER_PIN_DRV_NONE: case UNIPHIER_PIN_DRV_NONE:
drv_str = "NONE"; drv_type = "NONE";
break; break;
default: default:
BUG(); BUG();
} }
seq_printf(s, " PULL_DIR=%s DRV_STR=%s", pull_dir, drv_str); seq_printf(s, " PULL_DIR=%s DRV_TYPE=%s", pull_dir, drv_type);
} }
#endif #endif
...@@ -180,30 +180,30 @@ static int uniphier_conf_pin_drive_get(struct pinctrl_dev *pctldev, ...@@ -180,30 +180,30 @@ static int uniphier_conf_pin_drive_get(struct pinctrl_dev *pctldev,
u16 *strength) u16 *strength)
{ {
struct uniphier_pinctrl_priv *priv = pinctrl_dev_get_drvdata(pctldev); struct uniphier_pinctrl_priv *priv = pinctrl_dev_get_drvdata(pctldev);
enum uniphier_pin_drv_str drv_str = enum uniphier_pin_drv_type type =
uniphier_pin_get_drv_str(pin->drv_data); uniphier_pin_get_drv_type(pin->drv_data);
const unsigned int strength_4_8[] = {4, 8}; const unsigned int strength_1bit[] = {4, 8};
const unsigned int strength_8_12_16_20[] = {8, 12, 16, 20}; const unsigned int strength_2bit[] = {8, 12, 16, 20};
const unsigned int *supported_strength; const unsigned int *supported_strength;
unsigned int drvctrl, reg, shift, mask, width, val; unsigned int drvctrl, reg, shift, mask, width, val;
int ret; int ret;
switch (drv_str) { switch (type) {
case UNIPHIER_PIN_DRV_4_8: case UNIPHIER_PIN_DRV_1BIT:
supported_strength = strength_4_8; supported_strength = strength_1bit;
width = 1; width = 1;
break; break;
case UNIPHIER_PIN_DRV_8_12_16_20: case UNIPHIER_PIN_DRV_2BIT:
supported_strength = strength_8_12_16_20; supported_strength = strength_2bit;
width = 2; width = 2;
break; break;
case UNIPHIER_PIN_DRV_FIXED_4: case UNIPHIER_PIN_DRV_FIXED4:
*strength = 4; *strength = 4;
return 0; return 0;
case UNIPHIER_PIN_DRV_FIXED_5: case UNIPHIER_PIN_DRV_FIXED5:
*strength = 5; *strength = 5;
return 0; return 0;
case UNIPHIER_PIN_DRV_FIXED_8: case UNIPHIER_PIN_DRV_FIXED8:
*strength = 8; *strength = 8;
return 0; return 0;
default: default:
...@@ -364,20 +364,20 @@ static int uniphier_conf_pin_drive_set(struct pinctrl_dev *pctldev, ...@@ -364,20 +364,20 @@ static int uniphier_conf_pin_drive_set(struct pinctrl_dev *pctldev,
u16 strength) u16 strength)
{ {
struct uniphier_pinctrl_priv *priv = pinctrl_dev_get_drvdata(pctldev); struct uniphier_pinctrl_priv *priv = pinctrl_dev_get_drvdata(pctldev);
enum uniphier_pin_drv_str drv_str = enum uniphier_pin_drv_type type =
uniphier_pin_get_drv_str(pin->drv_data); uniphier_pin_get_drv_type(pin->drv_data);
const unsigned int strength_4_8[] = {4, 8, -1}; const unsigned int strength_1bit[] = {4, 8, -1};
const unsigned int strength_8_12_16_20[] = {8, 12, 16, 20, -1}; const unsigned int strength_2bit[] = {8, 12, 16, 20, -1};
const unsigned int *supported_strength; const unsigned int *supported_strength;
unsigned int drvctrl, reg, shift, mask, width, val; unsigned int drvctrl, reg, shift, mask, width, val;
switch (drv_str) { switch (type) {
case UNIPHIER_PIN_DRV_4_8: case UNIPHIER_PIN_DRV_1BIT:
supported_strength = strength_4_8; supported_strength = strength_1bit;
width = 1; width = 1;
break; break;
case UNIPHIER_PIN_DRV_8_12_16_20: case UNIPHIER_PIN_DRV_2BIT:
supported_strength = strength_8_12_16_20; supported_strength = strength_2bit;
width = 2; width = 2;
break; break;
default: default:
......
...@@ -41,16 +41,16 @@ struct platform_device; ...@@ -41,16 +41,16 @@ struct platform_device;
#define UNIPHIER_PIN_DRVCTRL_MASK ((1UL << (UNIPHIER_PIN_DRVCTRL_BITS)) \ #define UNIPHIER_PIN_DRVCTRL_MASK ((1UL << (UNIPHIER_PIN_DRVCTRL_BITS)) \
- 1) - 1)
/* supported drive strength (mA) */ /* drive control type */
#define UNIPHIER_PIN_DRV_STR_SHIFT ((UNIPHIER_PIN_DRVCTRL_SHIFT) + \ #define UNIPHIER_PIN_DRV_TYPE_SHIFT ((UNIPHIER_PIN_DRVCTRL_SHIFT) + \
(UNIPHIER_PIN_DRVCTRL_BITS)) (UNIPHIER_PIN_DRVCTRL_BITS))
#define UNIPHIER_PIN_DRV_STR_BITS 3 #define UNIPHIER_PIN_DRV_TYPE_BITS 3
#define UNIPHIER_PIN_DRV_STR_MASK ((1UL << (UNIPHIER_PIN_DRV_STR_BITS)) \ #define UNIPHIER_PIN_DRV_TYPE_MASK ((1UL << (UNIPHIER_PIN_DRV_TYPE_BITS)) \
- 1) - 1)
/* pull-up / pull-down register number */ /* pull-up / pull-down register number */
#define UNIPHIER_PIN_PUPDCTRL_SHIFT ((UNIPHIER_PIN_DRV_STR_SHIFT) + \ #define UNIPHIER_PIN_PUPDCTRL_SHIFT ((UNIPHIER_PIN_DRV_TYPE_SHIFT) + \
(UNIPHIER_PIN_DRV_STR_BITS)) (UNIPHIER_PIN_DRV_TYPE_BITS))
#define UNIPHIER_PIN_PUPDCTRL_BITS 9 #define UNIPHIER_PIN_PUPDCTRL_BITS 9
#define UNIPHIER_PIN_PUPDCTRL_MASK ((1UL << (UNIPHIER_PIN_PUPDCTRL_BITS))\ #define UNIPHIER_PIN_PUPDCTRL_MASK ((1UL << (UNIPHIER_PIN_PUPDCTRL_BITS))\
- 1) - 1)
...@@ -68,13 +68,13 @@ struct platform_device; ...@@ -68,13 +68,13 @@ struct platform_device;
#define UNIPHIER_PIN_IECTRL_NONE (UNIPHIER_PIN_IECTRL_MASK) #define UNIPHIER_PIN_IECTRL_NONE (UNIPHIER_PIN_IECTRL_MASK)
/* selectable drive strength */ /* drive control type */
enum uniphier_pin_drv_str { enum uniphier_pin_drv_type {
UNIPHIER_PIN_DRV_4_8, /* 2 level control: 4/8 mA */ UNIPHIER_PIN_DRV_1BIT, /* 2 level control: 4/8 mA */
UNIPHIER_PIN_DRV_8_12_16_20, /* 4 level control: 8/12/16/20 mA */ UNIPHIER_PIN_DRV_2BIT, /* 4 level control: 8/12/16/20 mA */
UNIPHIER_PIN_DRV_FIXED_4, /* fixed to 4mA */ UNIPHIER_PIN_DRV_FIXED4, /* fixed to 4mA */
UNIPHIER_PIN_DRV_FIXED_5, /* fixed to 5mA */ UNIPHIER_PIN_DRV_FIXED5, /* fixed to 5mA */
UNIPHIER_PIN_DRV_FIXED_8, /* fixed to 8mA */ UNIPHIER_PIN_DRV_FIXED8, /* fixed to 8mA */
UNIPHIER_PIN_DRV_NONE, /* no support (input only pin) */ UNIPHIER_PIN_DRV_NONE, /* no support (input only pin) */
}; };
...@@ -91,17 +91,17 @@ enum uniphier_pin_pull_dir { ...@@ -91,17 +91,17 @@ enum uniphier_pin_pull_dir {
(((x) & (UNIPHIER_PIN_IECTRL_MASK)) << (UNIPHIER_PIN_IECTRL_SHIFT)) (((x) & (UNIPHIER_PIN_IECTRL_MASK)) << (UNIPHIER_PIN_IECTRL_SHIFT))
#define UNIPHIER_PIN_DRVCTRL(x) \ #define UNIPHIER_PIN_DRVCTRL(x) \
(((x) & (UNIPHIER_PIN_DRVCTRL_MASK)) << (UNIPHIER_PIN_DRVCTRL_SHIFT)) (((x) & (UNIPHIER_PIN_DRVCTRL_MASK)) << (UNIPHIER_PIN_DRVCTRL_SHIFT))
#define UNIPHIER_PIN_DRV_STR(x) \ #define UNIPHIER_PIN_DRV_TYPE(x) \
(((x) & (UNIPHIER_PIN_DRV_STR_MASK)) << (UNIPHIER_PIN_DRV_STR_SHIFT)) (((x) & (UNIPHIER_PIN_DRV_TYPE_MASK)) << (UNIPHIER_PIN_DRV_TYPE_SHIFT))
#define UNIPHIER_PIN_PUPDCTRL(x) \ #define UNIPHIER_PIN_PUPDCTRL(x) \
(((x) & (UNIPHIER_PIN_PUPDCTRL_MASK)) << (UNIPHIER_PIN_PUPDCTRL_SHIFT)) (((x) & (UNIPHIER_PIN_PUPDCTRL_MASK)) << (UNIPHIER_PIN_PUPDCTRL_SHIFT))
#define UNIPHIER_PIN_PULL_DIR(x) \ #define UNIPHIER_PIN_PULL_DIR(x) \
(((x) & (UNIPHIER_PIN_PULL_DIR_MASK)) << (UNIPHIER_PIN_PULL_DIR_SHIFT)) (((x) & (UNIPHIER_PIN_PULL_DIR_MASK)) << (UNIPHIER_PIN_PULL_DIR_SHIFT))
#define UNIPHIER_PIN_ATTR_PACKED(iectrl, drvctrl, drv_str, pupdctrl, pull_dir)\ #define UNIPHIER_PIN_ATTR_PACKED(iectrl, drvctrl, drv_type, pupdctrl, pull_dir)\
(UNIPHIER_PIN_IECTRL(iectrl) | \ (UNIPHIER_PIN_IECTRL(iectrl) | \
UNIPHIER_PIN_DRVCTRL(drvctrl) | \ UNIPHIER_PIN_DRVCTRL(drvctrl) | \
UNIPHIER_PIN_DRV_STR(drv_str) | \ UNIPHIER_PIN_DRV_TYPE(drv_type) | \
UNIPHIER_PIN_PUPDCTRL(pupdctrl) | \ UNIPHIER_PIN_PUPDCTRL(pupdctrl) | \
UNIPHIER_PIN_PULL_DIR(pull_dir)) UNIPHIER_PIN_PULL_DIR(pull_dir))
...@@ -117,10 +117,10 @@ static inline unsigned int uniphier_pin_get_drvctrl(void *drv_data) ...@@ -117,10 +117,10 @@ static inline unsigned int uniphier_pin_get_drvctrl(void *drv_data)
UNIPHIER_PIN_DRVCTRL_MASK; UNIPHIER_PIN_DRVCTRL_MASK;
} }
static inline unsigned int uniphier_pin_get_drv_str(void *drv_data) static inline unsigned int uniphier_pin_get_drv_type(void *drv_data)
{ {
return ((unsigned long)drv_data >> UNIPHIER_PIN_DRV_STR_SHIFT) & return ((unsigned long)drv_data >> UNIPHIER_PIN_DRV_TYPE_SHIFT) &
UNIPHIER_PIN_DRV_STR_MASK; UNIPHIER_PIN_DRV_TYPE_MASK;
} }
static inline unsigned int uniphier_pin_get_pupdctrl(void *drv_data) static inline unsigned int uniphier_pin_get_pupdctrl(void *drv_data)
......
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