mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH linux-can/testing] can: tcan4x5x: Disable the INH pin device-state GPIO is unavailable
@ 2019-12-12 16:15 Dan Murphy
  2019-12-29 15:32 ` Marc Kleine-Budde
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Murphy @ 2019-12-12 16:15 UTC (permalink / raw)
  To: linux-kernel, mkl, linux-can, wg, sriram.dash; +Cc: Dan Murphy

If the device state GPIO is not connected to the host then disable the
INH output from the TCAN device per section 8.3.5 of the data sheet.

Signed-off-by: Dan Murphy <dmurphy@ti.com>
---
 drivers/net/can/m_can/tcan4x5x.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/net/can/m_can/tcan4x5x.c b/drivers/net/can/m_can/tcan4x5x.c
index b5d2ea0999c1..6a1f242d1876 100644
--- a/drivers/net/can/m_can/tcan4x5x.c
+++ b/drivers/net/can/m_can/tcan4x5x.c
@@ -102,6 +102,7 @@
 #define TCAN4X5X_MODE_NORMAL BIT(7)
 
 #define TCAN4X5X_DISABLE_WAKE_MSK	(BIT(31) | BIT(30))
+#define TCAN4X5X_DISABLE_INH_MSK	BIT(9)
 
 #define TCAN4X5X_SW_RESET BIT(2)
 
@@ -360,6 +361,15 @@ static int tcan4x5x_disable_wake(struct m_can_classdev *cdev)
 				  TCAN4X5X_DISABLE_WAKE_MSK, 0x00);
 }
 
+static int tcan4x5x_disable_state(struct m_can_classdev *cdev)
+{
+	struct tcan4x5x_priv *tcan4x5x = cdev->device_data;
+
+	return regmap_update_bits(tcan4x5x->regmap, TCAN4X5X_CONFIG,
+				  TCAN4X5X_DISABLE_INH_MSK, 0x01);
+
+}
+
 static int tcan4x5x_parse_config(struct m_can_classdev *cdev)
 {
 	struct tcan4x5x_priv *tcan4x5x = cdev->device_data;
@@ -383,8 +393,10 @@ static int tcan4x5x_parse_config(struct m_can_classdev *cdev)
 	tcan4x5x->device_state_gpio = devm_gpiod_get_optional(cdev->dev,
 							      "device-state",
 							      GPIOD_IN);
-	if (IS_ERR(tcan4x5x->device_state_gpio))
+	if (IS_ERR(tcan4x5x->device_state_gpio)) {
 		tcan4x5x->device_state_gpio = NULL;
+		tcan4x5x_disable_state(cdev);
+	}
 
 	return 0;
 }
-- 
2.23.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH linux-can/testing] can: tcan4x5x: Disable the INH pin device-state GPIO is unavailable
  2019-12-12 16:15 [PATCH linux-can/testing] can: tcan4x5x: Disable the INH pin device-state GPIO is unavailable Dan Murphy
@ 2019-12-29 15:32 ` Marc Kleine-Budde
  2019-12-29 16:05   ` Marc Kleine-Budde
  0 siblings, 1 reply; 5+ messages in thread
From: Marc Kleine-Budde @ 2019-12-29 15:32 UTC (permalink / raw)
  To: Dan Murphy, linux-kernel, linux-can, wg, sriram.dash


[-- Attachment #1.1: Type: text/plain, Size: 2306 bytes --]

On 12/12/19 5:15 PM, Dan Murphy wrote:
> If the device state GPIO is not connected to the host then disable the
> INH output from the TCAN device per section 8.3.5 of the data sheet.
> 
> Signed-off-by: Dan Murphy <dmurphy@ti.com>
> ---

Applied to linux-can. With some changes...

>  drivers/net/can/m_can/tcan4x5x.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/can/m_can/tcan4x5x.c b/drivers/net/can/m_can/tcan4x5x.c
> index b5d2ea0999c1..6a1f242d1876 100644
> --- a/drivers/net/can/m_can/tcan4x5x.c
> +++ b/drivers/net/can/m_can/tcan4x5x.c
> @@ -102,6 +102,7 @@
>  #define TCAN4X5X_MODE_NORMAL BIT(7)
>  
>  #define TCAN4X5X_DISABLE_WAKE_MSK	(BIT(31) | BIT(30))
> +#define TCAN4X5X_DISABLE_INH_MSK	BIT(9)
>  
>  #define TCAN4X5X_SW_RESET BIT(2)
>  
> @@ -360,6 +361,15 @@ static int tcan4x5x_disable_wake(struct m_can_classdev *cdev)
>  				  TCAN4X5X_DISABLE_WAKE_MSK, 0x00);
>  }
>  
> +static int tcan4x5x_disable_state(struct m_can_classdev *cdev)
> +{
> +	struct tcan4x5x_priv *tcan4x5x = cdev->device_data;
> +
> +	return regmap_update_bits(tcan4x5x->regmap, TCAN4X5X_CONFIG,
> +				  TCAN4X5X_DISABLE_INH_MSK, 0x01);
> +

Removed the stray line while applying.

> +}
> +
>  static int tcan4x5x_parse_config(struct m_can_classdev *cdev)
>  {
>  	struct tcan4x5x_priv *tcan4x5x = cdev->device_data;
> @@ -383,8 +393,10 @@ static int tcan4x5x_parse_config(struct m_can_classdev *cdev)
>  	tcan4x5x->device_state_gpio = devm_gpiod_get_optional(cdev->dev,
>  							      "device-state",
>  							      GPIOD_IN);
> -	if (IS_ERR(tcan4x5x->device_state_gpio))
> +	if (IS_ERR(tcan4x5x->device_state_gpio)) {
>  		tcan4x5x->device_state_gpio = NULL;
> +		tcan4x5x_disable_state(cdev);
> +	}
For some reason, this hunk doesn't apply, due to the additional:

>> 	tcan4x5x->power = devm_regulator_get_optional(cdev->dev,
>> 						      "vsup");

I've applied the patch manually.

>  
>  	return 0;
>  }
> 

Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH linux-can/testing] can: tcan4x5x: Disable the INH pin device-state GPIO is unavailable
  2019-12-29 15:32 ` Marc Kleine-Budde
@ 2019-12-29 16:05   ` Marc Kleine-Budde
  2020-01-08 20:47     ` Dan Murphy
  0 siblings, 1 reply; 5+ messages in thread
From: Marc Kleine-Budde @ 2019-12-29 16:05 UTC (permalink / raw)
  To: Dan Murphy, linux-kernel, linux-can, wg, sriram.dash


[-- Attachment #1.1: Type: text/plain, Size: 1254 bytes --]

On 12/29/19 4:32 PM, Marc Kleine-Budde wrote:
> On 12/12/19 5:15 PM, Dan Murphy wrote:
>>  static int tcan4x5x_parse_config(struct m_can_classdev *cdev)
>>  {
>>  	struct tcan4x5x_priv *tcan4x5x = cdev->device_data;
>> @@ -383,8 +393,10 @@ static int tcan4x5x_parse_config(struct m_can_classdev *cdev)
>>  	tcan4x5x->device_state_gpio = devm_gpiod_get_optional(cdev->dev,
>>  							      "device-state",
>>  							      GPIOD_IN);
>> -	if (IS_ERR(tcan4x5x->device_state_gpio))
>> +	if (IS_ERR(tcan4x5x->device_state_gpio)) {
>>  		tcan4x5x->device_state_gpio = NULL;
>> +		tcan4x5x_disable_state(cdev);
>> +	}
> For some reason, this hunk doesn't apply, due to the additional:
> 
>>> 	tcan4x5x->power = devm_regulator_get_optional(cdev->dev,
>>> 						      "vsup");

...which was my fault. :) Please have a look at

https://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can.git/log/?h=testing

...if I've collected every m_can related patch.

Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH linux-can/testing] can: tcan4x5x: Disable the INH pin device-state GPIO is unavailable
  2019-12-29 16:05   ` Marc Kleine-Budde
@ 2020-01-08 20:47     ` Dan Murphy
  2020-01-09  9:13       ` Marc Kleine-Budde
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Murphy @ 2020-01-08 20:47 UTC (permalink / raw)
  To: Marc Kleine-Budde, linux-kernel, linux-can, wg, sriram.dash

Marc

On 12/29/19 10:05 AM, Marc Kleine-Budde wrote:
> On 12/29/19 4:32 PM, Marc Kleine-Budde wrote:
>> On 12/12/19 5:15 PM, Dan Murphy wrote:
>>>   static int tcan4x5x_parse_config(struct m_can_classdev *cdev)
>>>   {
>>>   	struct tcan4x5x_priv *tcan4x5x = cdev->device_data;
>>> @@ -383,8 +393,10 @@ static int tcan4x5x_parse_config(struct m_can_classdev *cdev)
>>>   	tcan4x5x->device_state_gpio = devm_gpiod_get_optional(cdev->dev,
>>>   							      "device-state",
>>>   							      GPIOD_IN);
>>> -	if (IS_ERR(tcan4x5x->device_state_gpio))
>>> +	if (IS_ERR(tcan4x5x->device_state_gpio)) {
>>>   		tcan4x5x->device_state_gpio = NULL;
>>> +		tcan4x5x_disable_state(cdev);
>>> +	}
>> For some reason, this hunk doesn't apply, due to the additional:
>>
>>>> 	tcan4x5x->power = devm_regulator_get_optional(cdev->dev,
>>>> 						      "vsup");
> ...which was my fault. :) Please have a look at
>
> https://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can.git/log/?h=testing
>
> ...if I've collected every m_can related patch.

Is this still relevant or have you pulled this in?

It looks good to me.

Dan



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH linux-can/testing] can: tcan4x5x: Disable the INH pin device-state GPIO is unavailable
  2020-01-08 20:47     ` Dan Murphy
@ 2020-01-09  9:13       ` Marc Kleine-Budde
  0 siblings, 0 replies; 5+ messages in thread
From: Marc Kleine-Budde @ 2020-01-09  9:13 UTC (permalink / raw)
  To: Dan Murphy, linux-kernel, linux-can, wg, sriram.dash


[-- Attachment #1.1: Type: text/plain, Size: 710 bytes --]

On 1/8/20 9:47 PM, Dan Murphy wrote:
>> https://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can.git/log/?h=testing
>>
>> ...if I've collected every m_can related patch.
> 
> Is this still relevant or have you pulled this in?

Yes, it's still relevant, because it's upstream in the mean time. If
there are any problems left, we should fix them.

> It looks good to me.

If you find time, please test.

regards,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-01-09  9:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-12 16:15 [PATCH linux-can/testing] can: tcan4x5x: Disable the INH pin device-state GPIO is unavailable Dan Murphy
2019-12-29 15:32 ` Marc Kleine-Budde
2019-12-29 16:05   ` Marc Kleine-Budde
2020-01-08 20:47     ` Dan Murphy
2020-01-09  9:13       ` Marc Kleine-Budde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®