diff mbox series

[1/3] pinctrl: at91-pio4: Enable Push-Pull configuration

Message ID d898c31277f6bce6f7d830edf4332ff605498c7b.1684313910.git.Ryan.Wanner@microchip.com (mailing list archive)
State New, archived
Headers show
Series AT91 PIO4 push-pull enable | expand

Commit Message

Ryan.Wanner@microchip.com May 17, 2023, 11:54 a.m. UTC
From: Ryan Wanner <Ryan.Wanner@microchip.com>

Enable push-pull configuration. Remove integer value argument from
open-drain configuration as it is discarded when pinconf function is
called from gpiolib. Add push-pull do debug and get functions.

Signed-off-by: Ryan Wanner <Ryan.Wanner@microchip.com>
---
 drivers/pinctrl/pinctrl-at91-pio4.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

Comments

Claudiu Beznea May 18, 2023, 5:40 a.m. UTC | #1
On 17.05.2023 14:54, Ryan.Wanner@microchip.com wrote:
> From: Ryan Wanner <Ryan.Wanner@microchip.com>
> 
> Enable push-pull configuration. Remove integer value argument from
> open-drain configuration as it is discarded when pinconf function is
> called from gpiolib.

AFAICT it is still taken into account when passed tough drive-open-drain DT
property but at the moment there are no device trees using this property.

> Add push-pull do debug and get functions.
> 
> Signed-off-by: Ryan Wanner <Ryan.Wanner@microchip.com>
> ---
>  drivers/pinctrl/pinctrl-at91-pio4.c | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c
> index 2fe40acb6a3e..3c39d62bbc3c 100644
> --- a/drivers/pinctrl/pinctrl-at91-pio4.c
> +++ b/drivers/pinctrl/pinctrl-at91-pio4.c
> @@ -762,6 +762,11 @@ static int atmel_conf_pin_config_group_get(struct pinctrl_dev *pctldev,
>  			return -EINVAL;
>  		arg = 1;
>  		break;
> +	case PIN_CONFIG_DRIVE_PUSH_PULL:
> +		if (res & ATMEL_PIO_OPD_MASK)
> +			return -EINVAL;
> +		arg = 1;
> +		break;
>  	case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
>  		if (!(res & ATMEL_PIO_SCHMITT_MASK))
>  			return -EINVAL;
> @@ -827,10 +832,10 @@ static int atmel_conf_pin_config_group_set(struct pinctrl_dev *pctldev,
>  			conf &= (~ATMEL_PIO_PUEN_MASK);
>  			break;
>  		case PIN_CONFIG_DRIVE_OPEN_DRAIN:
> -			if (arg == 0)
> -				conf &= (~ATMEL_PIO_OPD_MASK);
> -			else
> -				conf |= ATMEL_PIO_OPD_MASK;
> +			conf |= ATMEL_PIO_OPD_MASK;
> +			break;
> +		case PIN_CONFIG_DRIVE_PUSH_PULL:
> +			conf &= (~ATMEL_PIO_OPD_MASK);
>  			break;
>  		case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
>  			if (arg == 0)
> @@ -948,6 +953,8 @@ static void atmel_conf_pin_config_dbg_show(struct pinctrl_dev *pctldev,
>  		seq_printf(s, "%s ", "debounce");
>  	if (conf & ATMEL_PIO_OPD_MASK)
>  		seq_printf(s, "%s ", "open-drain");
> +	if (!(conf & ATMEL_PIO_OPD_MASK))

else would fit better here.

> +		seq_printf(s, "%s ", "push-pull");
>  	if (conf & ATMEL_PIO_SCHMITT_MASK)
>  		seq_printf(s, "%s ", "schmitt");
>  	if (atmel_pioctrl->slew_rate_support && (conf & ATMEL_PIO_SR_MASK))
Claudiu Beznea May 18, 2023, 5:54 a.m. UTC | #2
On 18.05.2023 08:40, Claudiu Beznea - M18063 wrote:
> On 17.05.2023 14:54, Ryan.Wanner@microchip.com wrote:
>> From: Ryan Wanner <Ryan.Wanner@microchip.com>
>>
>> Enable push-pull configuration. Remove integer value argument from
>> open-drain configuration as it is discarded when pinconf function is
>> called from gpiolib.
> 
> AFAICT it is still taken into account when passed tough drive-open-drain DT
> property but at the moment there are no device trees using this property.

ah, ignore this as I've just saw your question about this here:
https://lore.kernel.org/all/120117b6-feda-e7aa-4f09-a126a0747388@microchip.com/

> 
>> Add push-pull do debug and get functions.
>>
>> Signed-off-by: Ryan Wanner <Ryan.Wanner@microchip.com>
>> ---
>>  drivers/pinctrl/pinctrl-at91-pio4.c | 15 +++++++++++----
>>  1 file changed, 11 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c
>> index 2fe40acb6a3e..3c39d62bbc3c 100644
>> --- a/drivers/pinctrl/pinctrl-at91-pio4.c
>> +++ b/drivers/pinctrl/pinctrl-at91-pio4.c
>> @@ -762,6 +762,11 @@ static int atmel_conf_pin_config_group_get(struct pinctrl_dev *pctldev,
>>  			return -EINVAL;
>>  		arg = 1;
>>  		break;
>> +	case PIN_CONFIG_DRIVE_PUSH_PULL:
>> +		if (res & ATMEL_PIO_OPD_MASK)
>> +			return -EINVAL;
>> +		arg = 1;
>> +		break;
>>  	case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
>>  		if (!(res & ATMEL_PIO_SCHMITT_MASK))
>>  			return -EINVAL;
>> @@ -827,10 +832,10 @@ static int atmel_conf_pin_config_group_set(struct pinctrl_dev *pctldev,
>>  			conf &= (~ATMEL_PIO_PUEN_MASK);
>>  			break;
>>  		case PIN_CONFIG_DRIVE_OPEN_DRAIN:
>> -			if (arg == 0)
>> -				conf &= (~ATMEL_PIO_OPD_MASK);
>> -			else
>> -				conf |= ATMEL_PIO_OPD_MASK;
>> +			conf |= ATMEL_PIO_OPD_MASK;
>> +			break;
>> +		case PIN_CONFIG_DRIVE_PUSH_PULL:
>> +			conf &= (~ATMEL_PIO_OPD_MASK);
>>  			break;
>>  		case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
>>  			if (arg == 0)
>> @@ -948,6 +953,8 @@ static void atmel_conf_pin_config_dbg_show(struct pinctrl_dev *pctldev,
>>  		seq_printf(s, "%s ", "debounce");
>>  	if (conf & ATMEL_PIO_OPD_MASK)
>>  		seq_printf(s, "%s ", "open-drain");
>> +	if (!(conf & ATMEL_PIO_OPD_MASK))
> 
> else would fit better here.
> 
>> +		seq_printf(s, "%s ", "push-pull");
>>  	if (conf & ATMEL_PIO_SCHMITT_MASK)
>>  		seq_printf(s, "%s ", "schmitt");
>>  	if (atmel_pioctrl->slew_rate_support && (conf & ATMEL_PIO_SR_MASK))
>
Nicolas Ferre May 22, 2023, 9:18 a.m. UTC | #3
On 17/05/2023 at 13:54, Ryan.Wanner@microchip.com wrote:
> From: Ryan Wanner <Ryan.Wanner@microchip.com>
> 
> Enable push-pull configuration. Remove integer value argument from
> open-drain configuration as it is discarded when pinconf function is
> called from gpiolib. Add push-pull do debug and get functions.
> 
> Signed-off-by: Ryan Wanner <Ryan.Wanner@microchip.com>

Looks good to me:
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>

Thanks,
   Nicolas

> ---
>   drivers/pinctrl/pinctrl-at91-pio4.c | 15 +++++++++++----
>   1 file changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c
> index 2fe40acb6a3e..3c39d62bbc3c 100644
> --- a/drivers/pinctrl/pinctrl-at91-pio4.c
> +++ b/drivers/pinctrl/pinctrl-at91-pio4.c
> @@ -762,6 +762,11 @@ static int atmel_conf_pin_config_group_get(struct pinctrl_dev *pctldev,
>   			return -EINVAL;
>   		arg = 1;
>   		break;
> +	case PIN_CONFIG_DRIVE_PUSH_PULL:
> +		if (res & ATMEL_PIO_OPD_MASK)
> +			return -EINVAL;
> +		arg = 1;
> +		break;
>   	case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
>   		if (!(res & ATMEL_PIO_SCHMITT_MASK))
>   			return -EINVAL;
> @@ -827,10 +832,10 @@ static int atmel_conf_pin_config_group_set(struct pinctrl_dev *pctldev,
>   			conf &= (~ATMEL_PIO_PUEN_MASK);
>   			break;
>   		case PIN_CONFIG_DRIVE_OPEN_DRAIN:
> -			if (arg == 0)
> -				conf &= (~ATMEL_PIO_OPD_MASK);
> -			else
> -				conf |= ATMEL_PIO_OPD_MASK;
> +			conf |= ATMEL_PIO_OPD_MASK;
> +			break;
> +		case PIN_CONFIG_DRIVE_PUSH_PULL:
> +			conf &= (~ATMEL_PIO_OPD_MASK);
>   			break;
>   		case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
>   			if (arg == 0)
> @@ -948,6 +953,8 @@ static void atmel_conf_pin_config_dbg_show(struct pinctrl_dev *pctldev,
>   		seq_printf(s, "%s ", "debounce");
>   	if (conf & ATMEL_PIO_OPD_MASK)
>   		seq_printf(s, "%s ", "open-drain");
> +	if (!(conf & ATMEL_PIO_OPD_MASK))
> +		seq_printf(s, "%s ", "push-pull");
>   	if (conf & ATMEL_PIO_SCHMITT_MASK)
>   		seq_printf(s, "%s ", "schmitt");
>   	if (atmel_pioctrl->slew_rate_support && (conf & ATMEL_PIO_SR_MASK))
Andy Shevchenko May 23, 2023, 4:27 p.m. UTC | #4
Wed, May 17, 2023 at 01:54:04PM +0200, Ryan.Wanner@microchip.com kirjoitti:
> From: Ryan Wanner <Ryan.Wanner@microchip.com>
> 
> Enable push-pull configuration. Remove integer value argument from
> open-drain configuration as it is discarded when pinconf function is
> called from gpiolib. Add push-pull do debug and get functions.

Right, thank you for fixing this!
Other comments below.

...

> +		case PIN_CONFIG_DRIVE_PUSH_PULL:
> +			conf &= (~ATMEL_PIO_OPD_MASK);

Parentheses are redundant.

>  			break;

...

>  	if (conf & ATMEL_PIO_OPD_MASK)
>  		seq_printf(s, "%s ", "open-drain");
> +	if (!(conf & ATMEL_PIO_OPD_MASK))
> +		seq_printf(s, "%s ", "push-pull");

As commented already by others, the else would be better.
Linus Walleij May 24, 2023, 8:50 a.m. UTC | #5
On Wed, May 17, 2023 at 1:54 PM <Ryan.Wanner@microchip.com> wrote:

> From: Ryan Wanner <Ryan.Wanner@microchip.com>
>
> Enable push-pull configuration. Remove integer value argument from
> open-drain configuration as it is discarded when pinconf function is
> called from gpiolib. Add push-pull do debug and get functions.
>
> Signed-off-by: Ryan Wanner <Ryan.Wanner@microchip.com>

I fixed up the two style issues pointed out by Andy and applied.
No need to resend.

Yours,
Linus Walleij
diff mbox series

Patch

diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c
index 2fe40acb6a3e..3c39d62bbc3c 100644
--- a/drivers/pinctrl/pinctrl-at91-pio4.c
+++ b/drivers/pinctrl/pinctrl-at91-pio4.c
@@ -762,6 +762,11 @@  static int atmel_conf_pin_config_group_get(struct pinctrl_dev *pctldev,
 			return -EINVAL;
 		arg = 1;
 		break;
+	case PIN_CONFIG_DRIVE_PUSH_PULL:
+		if (res & ATMEL_PIO_OPD_MASK)
+			return -EINVAL;
+		arg = 1;
+		break;
 	case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
 		if (!(res & ATMEL_PIO_SCHMITT_MASK))
 			return -EINVAL;
@@ -827,10 +832,10 @@  static int atmel_conf_pin_config_group_set(struct pinctrl_dev *pctldev,
 			conf &= (~ATMEL_PIO_PUEN_MASK);
 			break;
 		case PIN_CONFIG_DRIVE_OPEN_DRAIN:
-			if (arg == 0)
-				conf &= (~ATMEL_PIO_OPD_MASK);
-			else
-				conf |= ATMEL_PIO_OPD_MASK;
+			conf |= ATMEL_PIO_OPD_MASK;
+			break;
+		case PIN_CONFIG_DRIVE_PUSH_PULL:
+			conf &= (~ATMEL_PIO_OPD_MASK);
 			break;
 		case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
 			if (arg == 0)
@@ -948,6 +953,8 @@  static void atmel_conf_pin_config_dbg_show(struct pinctrl_dev *pctldev,
 		seq_printf(s, "%s ", "debounce");
 	if (conf & ATMEL_PIO_OPD_MASK)
 		seq_printf(s, "%s ", "open-drain");
+	if (!(conf & ATMEL_PIO_OPD_MASK))
+		seq_printf(s, "%s ", "push-pull");
 	if (conf & ATMEL_PIO_SCHMITT_MASK)
 		seq_printf(s, "%s ", "schmitt");
 	if (atmel_pioctrl->slew_rate_support && (conf & ATMEL_PIO_SR_MASK))