summaryrefslogtreecommitdiff
path: root/drivers/pinctrl
diff options
context:
space:
mode:
authorLaxman Dewangan <ldewangan@nvidia.com>2014-02-11 16:05:29 +0530
committerLaxman Dewangan <ldewangan@nvidia.com>2014-02-11 22:03:26 -0800
commitf21771abc8b3ddee81b1223a0451e1751a41fe39 (patch)
tree5403493fb6d85af0d8219d3681730c7893190590 /drivers/pinctrl
parent4efafb9f75241766459b5f4e8e4cd7bd746336c3 (diff)
pinctrl: as3722: add support for setting output value
Add support for setting the pins in output mode with state from generic pinconf DT properties output-high and output-low. bug 1444223 Change-Id: Id263779e4e797bb1d1ad1744b272a896a857c695 Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Reviewed-on: http://git-master/r/365887
Diffstat (limited to 'drivers/pinctrl')
-rw-r--r--drivers/pinctrl/pinctrl-as3722.c44
1 files changed, 30 insertions, 14 deletions
diff --git a/drivers/pinctrl/pinctrl-as3722.c b/drivers/pinctrl/pinctrl-as3722.c
index c09c6b529719..130766210dc4 100644
--- a/drivers/pinctrl/pinctrl-as3722.c
+++ b/drivers/pinctrl/pinctrl-as3722.c
@@ -326,6 +326,26 @@ static int as3722_pinctrl_gpio_set_direction(struct pinctrl_dev *pctldev,
AS3722_GPIO_MODE_MASK, mode);
}
+static void as3722_gpio_set_value(struct as3722_pctrl_info *as_pci,
+ unsigned offset, int value)
+{
+ struct as3722 *as3722 = as_pci->as3722;
+ int en_invert = as_pci->gpio_control[offset].enable_gpio_invert;
+ u32 val;
+ int ret;
+
+ if (value)
+ val = (en_invert) ? 0 : AS3722_GPIOn_SIGNAL(offset);
+ else
+ val = (en_invert) ? AS3722_GPIOn_SIGNAL(offset) : 0;
+
+ ret = as3722_update_bits(as3722, AS3722_GPIO_SIGNAL_OUT_REG,
+ AS3722_GPIOn_SIGNAL(offset), val);
+ if (ret < 0)
+ dev_err(as_pci->dev,
+ "GPIO_SIGNAL_OUT_REG update failed: %d\n", ret);
+}
+
static const struct pinmux_ops as3722_pinmux_ops = {
.get_functions_count = as3722_pinctrl_get_funcs_count,
.get_function_name = as3722_pinctrl_get_func_name,
@@ -385,7 +405,9 @@ static int as3722_pinconf_set(struct pinctrl_dev *pctldev,
{
struct as3722_pctrl_info *as_pci = pinctrl_dev_get_drvdata(pctldev);
enum pin_config_param param = pinconf_to_config_param(config);
+ u16 param_val = pinconf_to_config_argument(config);
int mode_prop = as_pci->gpio_control[pin].mode_prop;
+ int ret;
switch (param) {
case PIN_CONFIG_BIAS_PULL_PIN_DEFAULT:
@@ -411,6 +433,13 @@ static int as3722_pinconf_set(struct pinctrl_dev *pctldev,
mode_prop |= AS3722_GPIO_MODE_OPEN_DRAIN;
break;
+ case PIN_CONFIG_OUTPUT:
+ as3722_gpio_set_value(as_pci, pin, param_val);
+ ret = as3722_pinctrl_gpio_set_direction(pctldev, NULL, pin, 0);
+ if (ret < 0)
+ dev_err(as_pci->dev, "Not able to set direction\n");
+ return ret;
+
default:
dev_err(as_pci->dev, "Properties not supported\n");
return -ENOTSUPP;
@@ -488,21 +517,8 @@ static void as3722_gpio_set(struct gpio_chip *chip, unsigned offset,
int value)
{
struct as3722_pctrl_info *as_pci = to_as_pci(chip);
- struct as3722 *as3722 = as_pci->as3722;
- int en_invert = as_pci->gpio_control[offset].enable_gpio_invert;
- u32 val;
- int ret;
-
- if (value)
- val = (en_invert) ? 0 : AS3722_GPIOn_SIGNAL(offset);
- else
- val = (en_invert) ? AS3722_GPIOn_SIGNAL(offset) : 0;
- ret = as3722_update_bits(as3722, AS3722_GPIO_SIGNAL_OUT_REG,
- AS3722_GPIOn_SIGNAL(offset), val);
- if (ret < 0)
- dev_err(as_pci->dev,
- "GPIO_SIGNAL_OUT_REG update failed: %d\n", ret);
+ as3722_gpio_set_value(as_pci, offset, value);
}
static int as3722_gpio_direction_input(struct gpio_chip *chip, unsigned offset)