Commit e5c2c9db authored by Doug Anderson's avatar Doug Anderson Committed by Heiko Stuebner

pinctrl: rockchip: Don't call pinctrl_gpio_direction_output() in pin_config_set()

The Rockchip pinctrl driver was calling
rockchip_gpio_direction_output() in the pin_config_set() callback.
This was just a shortcut for:
* rockchip_gpio_set()
* pinctrl_gpio_direction_output()

Unfortunately it's not so good to call pinctrl_gpio_direction_output()
from pin_config_set().  Specifically when initting hogs you'll get an
error.

Let's refactor a little so we can call
_rockchip_pmx_gpio_set_direction() directly.
Signed-off-by: default avatarDoug Anderson <dianders@chromium.org>
Tested-by: default avatarChris Zhong <zyw@rock-chips.com>
Signed-off-by: default avatarHeiko Stuebner <heiko@sntech.de>
parent 876d716b
...@@ -856,22 +856,14 @@ static int rockchip_pmx_set(struct pinctrl_dev *pctldev, unsigned selector, ...@@ -856,22 +856,14 @@ static int rockchip_pmx_set(struct pinctrl_dev *pctldev, unsigned selector,
* leads to this function call (via the pinctrl_gpio_direction_{input|output}() * leads to this function call (via the pinctrl_gpio_direction_{input|output}()
* function called from the gpiolib interface). * function called from the gpiolib interface).
*/ */
static int rockchip_pmx_gpio_set_direction(struct pinctrl_dev *pctldev, static int _rockchip_pmx_gpio_set_direction(struct gpio_chip *chip,
struct pinctrl_gpio_range *range, int pin, bool input)
unsigned offset, bool input)
{ {
struct rockchip_pinctrl *info = pinctrl_dev_get_drvdata(pctldev);
struct rockchip_pin_bank *bank; struct rockchip_pin_bank *bank;
struct gpio_chip *chip; int ret;
int pin, ret;
u32 data; u32 data;
chip = range->gc;
bank = gc_to_pin_bank(chip); bank = gc_to_pin_bank(chip);
pin = offset - chip->base;
dev_dbg(info->dev, "gpio_direction for pin %u as %s-%d to %s\n",
offset, range->name, pin, input ? "input" : "output");
ret = rockchip_set_mux(bank, pin, RK_FUNC_GPIO); ret = rockchip_set_mux(bank, pin, RK_FUNC_GPIO);
if (ret < 0) if (ret < 0)
...@@ -888,6 +880,23 @@ static int rockchip_pmx_gpio_set_direction(struct pinctrl_dev *pctldev, ...@@ -888,6 +880,23 @@ static int rockchip_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,
return 0; return 0;
} }
static int rockchip_pmx_gpio_set_direction(struct pinctrl_dev *pctldev,
struct pinctrl_gpio_range *range,
unsigned offset, bool input)
{
struct rockchip_pinctrl *info = pinctrl_dev_get_drvdata(pctldev);
struct gpio_chip *chip;
int pin;
chip = range->gc;
pin = offset - chip->base;
dev_dbg(info->dev, "gpio_direction for pin %u as %s-%d to %s\n",
offset, range->name, pin, input ? "input" : "output");
return _rockchip_pmx_gpio_set_direction(chip, offset - chip->base,
input);
}
static const struct pinmux_ops rockchip_pmx_ops = { static const struct pinmux_ops rockchip_pmx_ops = {
.get_functions_count = rockchip_pmx_get_funcs_count, .get_functions_count = rockchip_pmx_get_funcs_count,
.get_function_name = rockchip_pmx_get_func_name, .get_function_name = rockchip_pmx_get_func_name,
...@@ -917,8 +926,7 @@ static bool rockchip_pinconf_pull_valid(struct rockchip_pin_ctrl *ctrl, ...@@ -917,8 +926,7 @@ static bool rockchip_pinconf_pull_valid(struct rockchip_pin_ctrl *ctrl,
return false; return false;
} }
static int rockchip_gpio_direction_output(struct gpio_chip *gc, static void rockchip_gpio_set(struct gpio_chip *gc, unsigned offset, int value);
unsigned offset, int value);
static int rockchip_gpio_get(struct gpio_chip *gc, unsigned offset); static int rockchip_gpio_get(struct gpio_chip *gc, unsigned offset);
/* set the pin config settings for a specified pin */ /* set the pin config settings for a specified pin */
...@@ -959,9 +967,10 @@ static int rockchip_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin, ...@@ -959,9 +967,10 @@ static int rockchip_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
return rc; return rc;
break; break;
case PIN_CONFIG_OUTPUT: case PIN_CONFIG_OUTPUT:
rc = rockchip_gpio_direction_output(&bank->gpio_chip, rockchip_gpio_set(&bank->gpio_chip,
pin - bank->pin_base, pin - bank->pin_base, arg);
arg); rc = _rockchip_pmx_gpio_set_direction(&bank->gpio_chip,
pin - bank->pin_base, false);
if (rc) if (rc)
return rc; return rc;
break; break;
......
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