Skip to content

Commit 2de4973

Browse files
Dan Murphymarckleinebudde
authored andcommitted
can: tcan45x: Make wake-up GPIO an optional GPIO
The device has the ability to disable the wake-up pin option. The wake-up pin can be either force to GND or Vsup and does not have to be tied to a GPIO. In order for the device to not use the wake-up feature write the register to disable the WAKE_CONFIG option. Signed-off-by: Dan Murphy <[email protected]> Cc: Sean Nyekjaer <[email protected]> Reviewed-by: Sean Nyekjaer <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent 1202d23 commit 2de4973

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

drivers/net/can/m_can/tcan4x5x.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@
101101
#define TCAN4X5X_MODE_STANDBY BIT(6)
102102
#define TCAN4X5X_MODE_NORMAL BIT(7)
103103

104+
#define TCAN4X5X_DISABLE_WAKE_MSK (BIT(31) | BIT(30))
105+
104106
#define TCAN4X5X_SW_RESET BIT(2)
105107

106108
#define TCAN4X5X_MCAN_CONFIGURED BIT(5)
@@ -338,15 +340,25 @@ static int tcan4x5x_init(struct m_can_classdev *cdev)
338340
return ret;
339341
}
340342

343+
static int tcan4x5x_disable_wake(struct m_can_classdev *cdev)
344+
{
345+
struct tcan4x5x_priv *tcan4x5x = cdev->device_data;
346+
347+
return regmap_update_bits(tcan4x5x->regmap, TCAN4X5X_CONFIG,
348+
TCAN4X5X_DISABLE_WAKE_MSK, 0x00);
349+
}
350+
341351
static int tcan4x5x_parse_config(struct m_can_classdev *cdev)
342352
{
343353
struct tcan4x5x_priv *tcan4x5x = cdev->device_data;
344354

345355
tcan4x5x->device_wake_gpio = devm_gpiod_get(cdev->dev, "device-wake",
346356
GPIOD_OUT_HIGH);
347357
if (IS_ERR(tcan4x5x->device_wake_gpio)) {
348-
dev_err(cdev->dev, "device-wake gpio not defined\n");
349-
return -EINVAL;
358+
if (PTR_ERR(tcan4x5x->power) == -EPROBE_DEFER)
359+
return -EPROBE_DEFER;
360+
361+
tcan4x5x_disable_wake(cdev);
350362
}
351363

352364
tcan4x5x->reset_gpio = devm_gpiod_get_optional(cdev->dev, "reset",
@@ -430,10 +442,6 @@ static int tcan4x5x_can_probe(struct spi_device *spi)
430442

431443
spi_set_drvdata(spi, priv);
432444

433-
ret = tcan4x5x_parse_config(mcan_class);
434-
if (ret)
435-
goto out_clk;
436-
437445
/* Configure the SPI bus */
438446
spi->bits_per_word = 32;
439447
ret = spi_setup(spi);
@@ -443,6 +451,10 @@ static int tcan4x5x_can_probe(struct spi_device *spi)
443451
priv->regmap = devm_regmap_init(&spi->dev, &tcan4x5x_bus,
444452
&spi->dev, &tcan4x5x_regmap);
445453

454+
ret = tcan4x5x_parse_config(mcan_class);
455+
if (ret)
456+
goto out_clk;
457+
446458
tcan4x5x_power_enable(priv->power, 1);
447459

448460
ret = m_can_class_register(mcan_class);

0 commit comments

Comments
 (0)