From patchwork Mon Dec 9 16:32:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Kleine-Budde X-Patchwork-Id: 181064 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp4580414ile; Mon, 9 Dec 2019 08:33:28 -0800 (PST) X-Google-Smtp-Source: APXvYqyRyxTMbumAqCcUKNkA7g+1BtGrKmzAd0katEacwSS86AI0rFXjxX/1bfnBwAa8GDLrf9gu X-Received: by 2002:aca:c645:: with SMTP id w66mr24209690oif.43.1575909208235; Mon, 09 Dec 2019 08:33:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575909208; cv=none; d=google.com; s=arc-20160816; b=zoxogxr0d/7zORHMzebCTkZT3fj1taY9sMP0dskv08Wu/RjWUfbpbUL+9LBOOuM4pV mghprgw83wiXp0tKhH1BmHXNWoiWAZlDzHmwtIs2a1lSA9w66HT12PF5kh11UrlGDmXp gBoSFVAVLJ3llxnVMaFoa498pbNJmoz5+Kfy8P2Uzw1jvK9iUxdyPE3caWtBn+biDiEi xVNlKf7NoaXEyrCpbY6SJzxb/IOadPSaFSF06Kryz6VNIJWgB5R4O1Kg3AGRmCIK0oW1 m4vhNTm9pg1w0cQd5mCw/ASA/5o+kft9DEp1J6v/IvTSx9dmoMoFjtMjbd1ULxYwTO3d peKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=WIzUa1cez/FaWXscvjqExXu9ZKHKjfsWk1u1X/fG2ho=; b=C31MZkKEq30IKK0ogxPbXQSyGuCbnxyAAu3IHIIcawjPZYdGFs4BypKOqEAUwuc83L +Mv2lHUU+0iurN99PackvZMNJblXaj9cC9sYi+TMrh0EohyEwDlGnikdlvHAidI9qcMF BjTHoeFxYHZ8Ev5Z/Wp82VwM+vHNL2v+fOc1xPN2uuZ1/Wr0wzPgb2lL1H6toqZdJxoA qrjl7MBOA418t/Q95qHsh7G6zK2Ml5mVyLzXRALbj3v0ZxakkAms3Wo1cFDHycFFYoU7 GF8/9bw97HyPzWglp8/KEMOUUUECec1DKlw9vdSMEy7PrVw0Csd84b9MbYyryo2Ybe16 AOFQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l62si160842oif.20.2019.12.09.08.33.28; Mon, 09 Dec 2019 08:33:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726999AbfLIQdU (ORCPT + 9 others); Mon, 9 Dec 2019 11:33:20 -0500 Received: from metis.ext.pengutronix.de ([85.220.165.71]:56519 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726911AbfLIQdH (ORCPT ); Mon, 9 Dec 2019 11:33:07 -0500 Received: from heimdall.vpn.pengutronix.de ([2001:67c:670:205:1d::14] helo=blackshift.org) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1ieLy5-0001up-Al; Mon, 09 Dec 2019 17:33:05 +0100 From: Marc Kleine-Budde To: netdev@vger.kernel.org Cc: davem@davemloft.net, linux-can@vger.kernel.org, kernel@pengutronix.de, Dan Murphy , Sean Nyekjaer , Marc Kleine-Budde Subject: [PATCH 12/13] can: tcan45x: Make wake-up GPIO an optional GPIO Date: Mon, 9 Dec 2019 17:32:55 +0100 Message-Id: <20191209163256.12000-13-mkl@pengutronix.de> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191209163256.12000-1-mkl@pengutronix.de> References: <20191209163256.12000-1-mkl@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:205:1d::14 X-SA-Exim-Mail-From: mkl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: netdev@vger.kernel.org Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Dan Murphy 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 Cc: Sean Nyekjaer Reviewed-by: Sean Nyekjaer Signed-off-by: Marc Kleine-Budde --- drivers/net/can/m_can/tcan4x5x.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) -- 2.24.0 diff --git a/drivers/net/can/m_can/tcan4x5x.c b/drivers/net/can/m_can/tcan4x5x.c index d5d4bfa9c8fd..4e1789ea2bc3 100644 --- a/drivers/net/can/m_can/tcan4x5x.c +++ b/drivers/net/can/m_can/tcan4x5x.c @@ -101,6 +101,8 @@ #define TCAN4X5X_MODE_STANDBY BIT(6) #define TCAN4X5X_MODE_NORMAL BIT(7) +#define TCAN4X5X_DISABLE_WAKE_MSK (BIT(31) | BIT(30)) + #define TCAN4X5X_SW_RESET BIT(2) #define TCAN4X5X_MCAN_CONFIGURED BIT(5) @@ -338,6 +340,14 @@ static int tcan4x5x_init(struct m_can_classdev *cdev) return ret; } +static int tcan4x5x_disable_wake(struct m_can_classdev *cdev) +{ + struct tcan4x5x_priv *tcan4x5x = cdev->device_data; + + return regmap_update_bits(tcan4x5x->regmap, TCAN4X5X_CONFIG, + TCAN4X5X_DISABLE_WAKE_MSK, 0x00); +} + static int tcan4x5x_parse_config(struct m_can_classdev *cdev) { struct tcan4x5x_priv *tcan4x5x = cdev->device_data; @@ -345,8 +355,10 @@ static int tcan4x5x_parse_config(struct m_can_classdev *cdev) tcan4x5x->device_wake_gpio = devm_gpiod_get(cdev->dev, "device-wake", GPIOD_OUT_HIGH); if (IS_ERR(tcan4x5x->device_wake_gpio)) { - dev_err(cdev->dev, "device-wake gpio not defined\n"); - return -EINVAL; + if (PTR_ERR(tcan4x5x->power) == -EPROBE_DEFER) + return -EPROBE_DEFER; + + tcan4x5x_disable_wake(cdev); } tcan4x5x->reset_gpio = devm_gpiod_get_optional(cdev->dev, "reset", @@ -430,10 +442,6 @@ static int tcan4x5x_can_probe(struct spi_device *spi) spi_set_drvdata(spi, priv); - ret = tcan4x5x_parse_config(mcan_class); - if (ret) - goto out_clk; - /* Configure the SPI bus */ spi->bits_per_word = 32; ret = spi_setup(spi); @@ -443,6 +451,10 @@ static int tcan4x5x_can_probe(struct spi_device *spi) priv->regmap = devm_regmap_init(&spi->dev, &tcan4x5x_bus, &spi->dev, &tcan4x5x_regmap); + ret = tcan4x5x_parse_config(mcan_class); + if (ret) + goto out_clk; + tcan4x5x_power_enable(priv->power, 1); ret = m_can_class_register(mcan_class);