diff mbox series

[U-Boot] pinctrl: meson: Fix GPIO direction registers access

Message ID 20181203180042.18278-1-ccaione@baylibre.com
State Accepted, archived
Commit fb19c7bade45e97112f65671dd0c5855c727675a
Delegated to: Neil Armstrong
Headers show
Series [U-Boot] pinctrl: meson: Fix GPIO direction registers access | expand

Commit Message

Carlo Caione Dec. 3, 2018, 6 p.m. UTC
The macros used to set the direction of the GPIO pins are misused,
resulting in a wrong behavior when trying to read the GPIO input level
from U-Boot.

A better macro is also used when setting the output direction.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
---
 drivers/pinctrl/meson/pinctrl-meson.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Jerome Brunet Dec. 5, 2018, 7:44 a.m. UTC | #1
On Mon, 2018-12-03 at 18:00 +0000, Carlo Caione wrote:
> The macros used to set the direction of the GPIO pins are misused,
> resulting in a wrong behavior when trying to read the GPIO input level
> from U-Boot.
> 
> A better macro is also used when setting the output direction.
> 
> Signed-off-by: Carlo Caione <ccaione@baylibre.com>
> ---
>  drivers/pinctrl/meson/pinctrl-meson.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/pinctrl/meson/pinctrl-meson.c
> b/drivers/pinctrl/meson/pinctrl-meson.c
> index 0bd6152803..b539749752 100644
> --- a/drivers/pinctrl/meson/pinctrl-meson.c
> +++ b/drivers/pinctrl/meson/pinctrl-meson.c
> @@ -136,7 +136,7 @@ int meson_gpio_direction_input(struct udevice *dev,
> unsigned int offset)
>  	if (ret)
>  		return ret;
>  
> -	clrsetbits_le32(priv->reg_gpio + reg, BIT(bit), 1);
> +	setbits_le32(priv->reg_gpio + reg, BIT(bit));
>  
>  	return 0;
>  }
> @@ -152,7 +152,7 @@ int meson_gpio_direction_output(struct udevice *dev,
>  	if (ret)
>  		return ret;
>  
> -	clrsetbits_le32(priv->reg_gpio + reg, BIT(bit), 0);
> +	clrbits_le32(priv->reg_gpio + reg, BIT(bit));
>  
>  	ret = meson_gpio_calc_reg_and_bit(dev, offset, REG_OUT, &reg, &bit);
>  	if (ret)

Reviewed-by: Jerome Brunet <jbrunet@baylibre.com>
Neil Armstrong Dec. 5, 2018, 9:37 a.m. UTC | #2
On 05/12/2018 08:44, Jerome Brunet wrote:
> On Mon, 2018-12-03 at 18:00 +0000, Carlo Caione wrote:
>> The macros used to set the direction of the GPIO pins are misused,
>> resulting in a wrong behavior when trying to read the GPIO input level
>> from U-Boot.
>>
>> A better macro is also used when setting the output direction.
>>
>> Signed-off-by: Carlo Caione <ccaione@baylibre.com>
>> ---
>>  drivers/pinctrl/meson/pinctrl-meson.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/pinctrl/meson/pinctrl-meson.c
>> b/drivers/pinctrl/meson/pinctrl-meson.c
>> index 0bd6152803..b539749752 100644
>> --- a/drivers/pinctrl/meson/pinctrl-meson.c
>> +++ b/drivers/pinctrl/meson/pinctrl-meson.c
>> @@ -136,7 +136,7 @@ int meson_gpio_direction_input(struct udevice *dev,
>> unsigned int offset)
>>  	if (ret)
>>  		return ret;
>>  
>> -	clrsetbits_le32(priv->reg_gpio + reg, BIT(bit), 1);
>> +	setbits_le32(priv->reg_gpio + reg, BIT(bit));
>>  
>>  	return 0;
>>  }
>> @@ -152,7 +152,7 @@ int meson_gpio_direction_output(struct udevice *dev,
>>  	if (ret)
>>  		return ret;
>>  
>> -	clrsetbits_le32(priv->reg_gpio + reg, BIT(bit), 0);
>> +	clrbits_le32(priv->reg_gpio + reg, BIT(bit));
>>  
>>  	ret = meson_gpio_calc_reg_and_bit(dev, offset, REG_OUT, &reg, &bit);
>>  	if (ret)
> 
> Reviewed-by: Jerome Brunet <jbrunet@baylibre.com>
> 

Thanks,

Applied !

Neil
diff mbox series

Patch

diff --git a/drivers/pinctrl/meson/pinctrl-meson.c b/drivers/pinctrl/meson/pinctrl-meson.c
index 0bd6152803..b539749752 100644
--- a/drivers/pinctrl/meson/pinctrl-meson.c
+++ b/drivers/pinctrl/meson/pinctrl-meson.c
@@ -136,7 +136,7 @@  int meson_gpio_direction_input(struct udevice *dev, unsigned int offset)
 	if (ret)
 		return ret;
 
-	clrsetbits_le32(priv->reg_gpio + reg, BIT(bit), 1);
+	setbits_le32(priv->reg_gpio + reg, BIT(bit));
 
 	return 0;
 }
@@ -152,7 +152,7 @@  int meson_gpio_direction_output(struct udevice *dev,
 	if (ret)
 		return ret;
 
-	clrsetbits_le32(priv->reg_gpio + reg, BIT(bit), 0);
+	clrbits_le32(priv->reg_gpio + reg, BIT(bit));
 
 	ret = meson_gpio_calc_reg_and_bit(dev, offset, REG_OUT, &reg, &bit);
 	if (ret)