Commit 4e767983 authored by Masahiro Yamada's avatar Masahiro Yamada Committed by Linus Walleij

pinctrl: uniphier: omit redundant input enable bit information

For LD11/20 SoCs (capable of per-pin input enable), the iectrl bit
number matches its pin number.  So, this is redundant information.
Instead, we just need a flag to know if the iectrl gating exists or not.

With this refactoring, 5 bits in pin data will be saved.
Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 7f6ee0a5
...@@ -138,10 +138,11 @@ static const struct pinctrl_ops uniphier_pctlops = { ...@@ -138,10 +138,11 @@ static const struct pinctrl_ops uniphier_pctlops = {
}; };
static int uniphier_conf_pin_bias_get(struct pinctrl_dev *pctldev, static int uniphier_conf_pin_bias_get(struct pinctrl_dev *pctldev,
const struct pin_desc *desc, unsigned int pin,
enum pin_config_param param) enum pin_config_param param)
{ {
struct uniphier_pinctrl_priv *priv = pinctrl_dev_get_drvdata(pctldev); struct uniphier_pinctrl_priv *priv = pinctrl_dev_get_drvdata(pctldev);
const struct pin_desc *desc = pin_desc_get(pctldev, pin);
enum uniphier_pin_pull_dir pull_dir = enum uniphier_pin_pull_dir pull_dir =
uniphier_pin_get_pull_dir(desc->drv_data); uniphier_pin_get_pull_dir(desc->drv_data);
unsigned int pupdctrl, reg, shift, val; unsigned int pupdctrl, reg, shift, val;
...@@ -188,10 +189,10 @@ static int uniphier_conf_pin_bias_get(struct pinctrl_dev *pctldev, ...@@ -188,10 +189,10 @@ static int uniphier_conf_pin_bias_get(struct pinctrl_dev *pctldev,
} }
static int uniphier_conf_pin_drive_get(struct pinctrl_dev *pctldev, static int uniphier_conf_pin_drive_get(struct pinctrl_dev *pctldev,
const struct pin_desc *desc, unsigned int pin, u16 *strength)
u16 *strength)
{ {
struct uniphier_pinctrl_priv *priv = pinctrl_dev_get_drvdata(pctldev); struct uniphier_pinctrl_priv *priv = pinctrl_dev_get_drvdata(pctldev);
const struct pin_desc *desc = pin_desc_get(pctldev, pin);
enum uniphier_pin_drv_type type = enum uniphier_pin_drv_type type =
uniphier_pin_get_drv_type(desc->drv_data); uniphier_pin_get_drv_type(desc->drv_data);
const unsigned int strength_1bit[] = {4, 8}; const unsigned int strength_1bit[] = {4, 8};
...@@ -248,9 +249,10 @@ static int uniphier_conf_pin_drive_get(struct pinctrl_dev *pctldev, ...@@ -248,9 +249,10 @@ static int uniphier_conf_pin_drive_get(struct pinctrl_dev *pctldev,
} }
static int uniphier_conf_pin_input_enable_get(struct pinctrl_dev *pctldev, static int uniphier_conf_pin_input_enable_get(struct pinctrl_dev *pctldev,
const struct pin_desc *desc) unsigned int pin)
{ {
struct uniphier_pinctrl_priv *priv = pinctrl_dev_get_drvdata(pctldev); struct uniphier_pinctrl_priv *priv = pinctrl_dev_get_drvdata(pctldev);
const struct pin_desc *desc = pin_desc_get(pctldev, pin);
unsigned int iectrl = uniphier_pin_get_iectrl(desc->drv_data); unsigned int iectrl = uniphier_pin_get_iectrl(desc->drv_data);
unsigned int reg, mask, val; unsigned int reg, mask, val;
int ret; int ret;
...@@ -259,6 +261,9 @@ static int uniphier_conf_pin_input_enable_get(struct pinctrl_dev *pctldev, ...@@ -259,6 +261,9 @@ static int uniphier_conf_pin_input_enable_get(struct pinctrl_dev *pctldev,
/* This pin is always input-enabled. */ /* This pin is always input-enabled. */
return 0; return 0;
if (priv->socdata->caps & UNIPHIER_PINCTRL_CAPS_PERPIN_IECTRL)
iectrl = pin;
reg = UNIPHIER_PINCTRL_IECTRL_BASE + iectrl / 32 * 4; reg = UNIPHIER_PINCTRL_IECTRL_BASE + iectrl / 32 * 4;
mask = BIT(iectrl % 32); mask = BIT(iectrl % 32);
...@@ -273,7 +278,6 @@ static int uniphier_conf_pin_config_get(struct pinctrl_dev *pctldev, ...@@ -273,7 +278,6 @@ static int uniphier_conf_pin_config_get(struct pinctrl_dev *pctldev,
unsigned pin, unsigned pin,
unsigned long *configs) unsigned long *configs)
{ {
const struct pin_desc *desc = pin_desc_get(pctldev, pin);
enum pin_config_param param = pinconf_to_config_param(*configs); enum pin_config_param param = pinconf_to_config_param(*configs);
bool has_arg = false; bool has_arg = false;
u16 arg; u16 arg;
...@@ -283,14 +287,14 @@ static int uniphier_conf_pin_config_get(struct pinctrl_dev *pctldev, ...@@ -283,14 +287,14 @@ static int uniphier_conf_pin_config_get(struct pinctrl_dev *pctldev,
case PIN_CONFIG_BIAS_DISABLE: case PIN_CONFIG_BIAS_DISABLE:
case PIN_CONFIG_BIAS_PULL_UP: case PIN_CONFIG_BIAS_PULL_UP:
case PIN_CONFIG_BIAS_PULL_DOWN: case PIN_CONFIG_BIAS_PULL_DOWN:
ret = uniphier_conf_pin_bias_get(pctldev, desc, param); ret = uniphier_conf_pin_bias_get(pctldev, pin, param);
break; break;
case PIN_CONFIG_DRIVE_STRENGTH: case PIN_CONFIG_DRIVE_STRENGTH:
ret = uniphier_conf_pin_drive_get(pctldev, desc, &arg); ret = uniphier_conf_pin_drive_get(pctldev, pin, &arg);
has_arg = true; has_arg = true;
break; break;
case PIN_CONFIG_INPUT_ENABLE: case PIN_CONFIG_INPUT_ENABLE:
ret = uniphier_conf_pin_input_enable_get(pctldev, desc); ret = uniphier_conf_pin_input_enable_get(pctldev, pin);
break; break;
default: default:
/* unsupported parameter */ /* unsupported parameter */
...@@ -305,10 +309,11 @@ static int uniphier_conf_pin_config_get(struct pinctrl_dev *pctldev, ...@@ -305,10 +309,11 @@ static int uniphier_conf_pin_config_get(struct pinctrl_dev *pctldev,
} }
static int uniphier_conf_pin_bias_set(struct pinctrl_dev *pctldev, static int uniphier_conf_pin_bias_set(struct pinctrl_dev *pctldev,
const struct pin_desc *desc, unsigned int pin,
enum pin_config_param param, u32 arg) enum pin_config_param param, u32 arg)
{ {
struct uniphier_pinctrl_priv *priv = pinctrl_dev_get_drvdata(pctldev); struct uniphier_pinctrl_priv *priv = pinctrl_dev_get_drvdata(pctldev);
const struct pin_desc *desc = pin_desc_get(pctldev, pin);
enum uniphier_pin_pull_dir pull_dir = enum uniphier_pin_pull_dir pull_dir =
uniphier_pin_get_pull_dir(desc->drv_data); uniphier_pin_get_pull_dir(desc->drv_data);
unsigned int pupdctrl, reg, shift; unsigned int pupdctrl, reg, shift;
...@@ -379,10 +384,10 @@ static int uniphier_conf_pin_bias_set(struct pinctrl_dev *pctldev, ...@@ -379,10 +384,10 @@ static int uniphier_conf_pin_bias_set(struct pinctrl_dev *pctldev,
} }
static int uniphier_conf_pin_drive_set(struct pinctrl_dev *pctldev, static int uniphier_conf_pin_drive_set(struct pinctrl_dev *pctldev,
const struct pin_desc *desc, unsigned int pin, u16 strength)
u16 strength)
{ {
struct uniphier_pinctrl_priv *priv = pinctrl_dev_get_drvdata(pctldev); struct uniphier_pinctrl_priv *priv = pinctrl_dev_get_drvdata(pctldev);
const struct pin_desc *desc = pin_desc_get(pctldev, pin);
enum uniphier_pin_drv_type type = enum uniphier_pin_drv_type type =
uniphier_pin_get_drv_type(desc->drv_data); uniphier_pin_get_drv_type(desc->drv_data);
const unsigned int strength_1bit[] = {4, 8, -1}; const unsigned int strength_1bit[] = {4, 8, -1};
...@@ -440,10 +445,10 @@ static int uniphier_conf_pin_drive_set(struct pinctrl_dev *pctldev, ...@@ -440,10 +445,10 @@ static int uniphier_conf_pin_drive_set(struct pinctrl_dev *pctldev,
} }
static int uniphier_conf_pin_input_enable(struct pinctrl_dev *pctldev, static int uniphier_conf_pin_input_enable(struct pinctrl_dev *pctldev,
const struct pin_desc *desc, unsigned int pin, u16 enable)
u16 enable)
{ {
struct uniphier_pinctrl_priv *priv = pinctrl_dev_get_drvdata(pctldev); struct uniphier_pinctrl_priv *priv = pinctrl_dev_get_drvdata(pctldev);
const struct pin_desc *desc = pin_desc_get(pctldev, pin);
unsigned int iectrl = uniphier_pin_get_iectrl(desc->drv_data); unsigned int iectrl = uniphier_pin_get_iectrl(desc->drv_data);
unsigned int reg, mask; unsigned int reg, mask;
...@@ -459,6 +464,9 @@ static int uniphier_conf_pin_input_enable(struct pinctrl_dev *pctldev, ...@@ -459,6 +464,9 @@ static int uniphier_conf_pin_input_enable(struct pinctrl_dev *pctldev,
if (iectrl == UNIPHIER_PIN_IECTRL_NONE) if (iectrl == UNIPHIER_PIN_IECTRL_NONE)
return enable ? 0 : -EINVAL; return enable ? 0 : -EINVAL;
if (priv->socdata->caps & UNIPHIER_PINCTRL_CAPS_PERPIN_IECTRL)
iectrl = pin;
reg = UNIPHIER_PINCTRL_IECTRL_BASE + iectrl / 32 * 4; reg = UNIPHIER_PINCTRL_IECTRL_BASE + iectrl / 32 * 4;
mask = BIT(iectrl % 32); mask = BIT(iectrl % 32);
...@@ -470,7 +478,6 @@ static int uniphier_conf_pin_config_set(struct pinctrl_dev *pctldev, ...@@ -470,7 +478,6 @@ static int uniphier_conf_pin_config_set(struct pinctrl_dev *pctldev,
unsigned long *configs, unsigned long *configs,
unsigned num_configs) unsigned num_configs)
{ {
const struct pin_desc *desc = pin_desc_get(pctldev, pin);
int i, ret; int i, ret;
for (i = 0; i < num_configs; i++) { for (i = 0; i < num_configs; i++) {
...@@ -483,15 +490,14 @@ static int uniphier_conf_pin_config_set(struct pinctrl_dev *pctldev, ...@@ -483,15 +490,14 @@ static int uniphier_conf_pin_config_set(struct pinctrl_dev *pctldev,
case PIN_CONFIG_BIAS_PULL_UP: case PIN_CONFIG_BIAS_PULL_UP:
case PIN_CONFIG_BIAS_PULL_DOWN: case PIN_CONFIG_BIAS_PULL_DOWN:
case PIN_CONFIG_BIAS_PULL_PIN_DEFAULT: case PIN_CONFIG_BIAS_PULL_PIN_DEFAULT:
ret = uniphier_conf_pin_bias_set(pctldev, desc, ret = uniphier_conf_pin_bias_set(pctldev, pin,
param, arg); param, arg);
break; break;
case PIN_CONFIG_DRIVE_STRENGTH: case PIN_CONFIG_DRIVE_STRENGTH:
ret = uniphier_conf_pin_drive_set(pctldev, desc, arg); ret = uniphier_conf_pin_drive_set(pctldev, pin, arg);
break; break;
case PIN_CONFIG_INPUT_ENABLE: case PIN_CONFIG_INPUT_ENABLE:
ret = uniphier_conf_pin_input_enable(pctldev, desc, ret = uniphier_conf_pin_input_enable(pctldev, pin, arg);
arg);
break; break;
default: default:
dev_err(pctldev->dev, dev_err(pctldev->dev,
...@@ -571,8 +577,7 @@ static int uniphier_pmx_set_one_mux(struct pinctrl_dev *pctldev, unsigned pin, ...@@ -571,8 +577,7 @@ static int uniphier_pmx_set_one_mux(struct pinctrl_dev *pctldev, unsigned pin,
int ret; int ret;
/* some pins need input-enabling */ /* some pins need input-enabling */
ret = uniphier_conf_pin_input_enable(pctldev, ret = uniphier_conf_pin_input_enable(pctldev, pin, 1);
pin_desc_get(pctldev, pin), 1);
if (ret) if (ret)
return ret; return ret;
......
...@@ -25,7 +25,7 @@ struct platform_device; ...@@ -25,7 +25,7 @@ struct platform_device;
/* input enable control register bit */ /* input enable control register bit */
#define UNIPHIER_PIN_IECTRL_SHIFT 0 #define UNIPHIER_PIN_IECTRL_SHIFT 0
#define UNIPHIER_PIN_IECTRL_BITS 8 #define UNIPHIER_PIN_IECTRL_BITS 3
#define UNIPHIER_PIN_IECTRL_MASK ((1UL << (UNIPHIER_PIN_IECTRL_BITS)) \ #define UNIPHIER_PIN_IECTRL_MASK ((1UL << (UNIPHIER_PIN_IECTRL_BITS)) \
- 1) - 1)
...@@ -62,6 +62,7 @@ struct platform_device; ...@@ -62,6 +62,7 @@ struct platform_device;
#endif #endif
#define UNIPHIER_PIN_IECTRL_NONE (UNIPHIER_PIN_IECTRL_MASK) #define UNIPHIER_PIN_IECTRL_NONE (UNIPHIER_PIN_IECTRL_MASK)
#define UNIPHIER_PIN_IECTRL_EXIST 0
/* drive control type */ /* drive control type */
enum uniphier_pin_drv_type { enum uniphier_pin_drv_type {
......
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