From f0c191798e53167458a4f8ce85dd9e844a0da3cc Mon Sep 17 00:00:00 2001 From: Xingyu Chen Date: Mon, 4 Jun 2018 16:53:44 +0800 Subject: [PATCH] pinctrl: fixed abnormal pulse signal problem PD#167713: pinctrl: fixed abnormal pulse signal problem GPIO_O: control output level, and available in output mode GPIO_OEN: control output enable; GPIO_OEN=0: output, GPIO_OEN=1: input Precondition: - GPIO_OEN=1 - GPIO_O=1 - Low level on pin if we use the interface below to set pin to output mode and output low level, the pin will generate abnormal pulse signal with about 1us. gpio_direction_output(pin, GPIOF_OUT_INIT_LOW) low -> high -> low GPIO_OEN=1 GPIO_OEN=0 GPIO_OEN=0 GPIO_O=1 GPIO_O=1 GPIO_O=0 to solve the problem, we must ensure that the GPIO_O is set before the GPIO_OEN. low -> low -> low GPIO_OEN=1 GPIO_OEN=1 GPIO_OEN=0 GPIO_O=1 GPIO_O=0 GPIO_O=0 Change-Id: I02bdcc46a40aeb7378799ecbafda3825704d1003 Signed-off-by: Xingyu Chen --- drivers/amlogic/pinctrl/pinctrl-meson.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/amlogic/pinctrl/pinctrl-meson.c b/drivers/amlogic/pinctrl/pinctrl-meson.c index 53facea..60daef2b1 100644 --- a/drivers/amlogic/pinctrl/pinctrl-meson.c +++ b/drivers/amlogic/pinctrl/pinctrl-meson.c @@ -447,14 +447,14 @@ static int meson_gpio_direction_output(struct gpio_chip *chip, if (ret) return ret; - meson_calc_reg_and_bit(bank, gpio, REG_DIR, ®, &bit); - ret = regmap_update_bits(pc->reg_gpio, reg, BIT(bit), 0); + meson_calc_reg_and_bit(bank, gpio, REG_OUT, ®, &bit); + ret = regmap_update_bits(pc->reg_gpio, reg, BIT(bit), + value ? BIT(bit) : 0); if (ret) return ret; - meson_calc_reg_and_bit(bank, gpio, REG_OUT, ®, &bit); - return regmap_update_bits(pc->reg_gpio, reg, BIT(bit), - value ? BIT(bit) : 0); + meson_calc_reg_and_bit(bank, gpio, REG_DIR, ®, &bit); + return regmap_update_bits(pc->reg_gpio, reg, BIT(bit), 0); } static void meson_gpio_set(struct gpio_chip *chip, unsigned int gpio, -- 2.7.4