From patchwork Mon Jul 29 07:41:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Schneider-Pargmann X-Patchwork-Id: 13744506 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C33DAC3DA4A for ; Mon, 29 Jul 2024 07:43:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ZCJyOdovnkFMEmbndXoqHv/AoixQbNLaTwmx6tiqcEI=; b=1p35px3HmOo0SUkS8u9lv0FbV7 XsPRQLhYm2lY8Fk3Rl8/c1b2FeQ7XVZoktyD/8Eyf9EkjalAUXgk1kqAuTC+w0ls6qmFpAJ5dg+b6 1qCbhyI1UuHqjkso3VHo/k7mIjZQQT9swA9Jp0Vo/XJ4x3LSX5yDLh/hrBkkFWoR2DIW5wHr5qIuX Mr/12xnVQT/XSQI8Y+y6z4qJhIYPe8RkeXQtmLGtvAom3J0XLraq6UkzYnEGPuV8tdB0xMe8j8kho tVaNCcBoTg/c6r+96DVmIt+ojd4/JmWT8bpW9B7kDHI+BsKXM5UsOVl9DF9aNcapoz61O6omImSgA UGF0TJ6A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYL2K-0000000AOZb-1Yg6; Mon, 29 Jul 2024 07:43:16 +0000 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYL17-0000000AOCE-2kFG for linux-arm-kernel@lists.infradead.org; Mon, 29 Jul 2024 07:42:04 +0000 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-428035c0bb2so7869195e9.1 for ; Mon, 29 Jul 2024 00:42:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1722238920; x=1722843720; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZCJyOdovnkFMEmbndXoqHv/AoixQbNLaTwmx6tiqcEI=; b=nIcAwgynWOwUPx4IT8eCXnTF5k3MYXCv+babWxE0s5vaGb79i4zXbnkajz+k3n/Exs eGcIwKBqPae8F4yVZrRIKLk1UoAr+09vTBnC23aL8/1tMFIRMF3EVaqbDSB0P/w/PJcI KzFFfIsQB3E/xaFmB52zhG2kn5DkWe2GXaOY1PJ1HPiyTPUDEhSJKuLydGm7EXuHkcn+ Vb2zKIOu9p7+LcuSUS5xAPQn1i1f0puJBPvmkPcifNnZupDnkjzbUZA6viX/2fRRuI+d Z6CHBS8TXY/mTw0meGKLSanjvMfWAisFhUDKyVrZ974Ix9XMBjT8UTXo8zx0wvZcs8fp zI0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722238920; x=1722843720; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZCJyOdovnkFMEmbndXoqHv/AoixQbNLaTwmx6tiqcEI=; b=VQkB6tCMPz9/9gTLO9avjgXIzSJt7Y8jBGawJ6M7TKjmQM+zRxlAyip0l9LzxdLX7x lCFoBwuBG6l6LgewH0rKBUCMXzMqyJm9SQ9vtNLuRDVUd89tEGc3B9Blj5xQ32qwmAuA 9/784XQtumLt20BYHKDu4As/DuPViUf7ZgGAwVJUbh5Br2r3QWGwMQOibz1OhrIvOmZ3 UwbavPuTFMNuNF3doL5pQq+siQLm49BU57BMwKtO13ywiAEHd7szaQDPyfm/woi+GOH0 ebFcpYhs5xZNbJWleVreaZpf3vnfW3aE3XKt3WTp/KaRmptwCXmq+WTSbRq0SmSqymep tg+g== X-Forwarded-Encrypted: i=1; AJvYcCXK8VhWhlT1p9FlPe/Qp/0hCnY46zXVPrEv4ClkSLAikBShVURuVM559T3PTL+UNi0h3yd2qRuRQLm2q/83l6yKpkpSH7bURFoTNoVMCGnEfesRXfU= X-Gm-Message-State: AOJu0YzE5JQ5J8DahK7z1MjYn/99TPJeF4XDfFcH5ZzGccaMfa/mXp51 vBGvbDlq6DDn7L5Q7EfdbtlZ7uF6L7VioI4uj+fCgj+cu4wrrQuACRQ6pUb00Rw= X-Google-Smtp-Source: AGHT+IGA9WK2y4GsRw5Nh5f5SQhHnBIbXwPuYenvw4gciCMeqP8xAeSl3QvUhZ/h2LeIGM5P+g9f4Q== X-Received: by 2002:a5d:5227:0:b0:36b:5d86:d889 with SMTP id ffacd0b85a97d-36b5d86d95cmr3919065f8f.6.1722238919709; Mon, 29 Jul 2024 00:41:59 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4091:a245:8609:c1c4:a4f8:94c8:31f2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b36863aa7sm11460879f8f.109.2024.07.29.00.41.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 00:41:59 -0700 (PDT) From: Markus Schneider-Pargmann To: Chandrasekar Ramakrishnan , Marc Kleine-Budde , Vincent Mailhol , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Nishanth Menon , Vignesh Raghavendra , Tero Kristo , Markus Schneider-Pargmann , =?utf-8?q?Martin_Hundeb=C3=B8?= =?utf-8?q?ll?= , Christophe JAILLET , Michal Kubiak Cc: Vibhore Vardhan , Kevin Hilman , Dhruva Gole , Conor Dooley , linux-can@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 2/7] can: m_can: Map WoL to device_set_wakeup_enable Date: Mon, 29 Jul 2024 09:41:30 +0200 Message-ID: <20240729074135.3850634-3-msp@baylibre.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240729074135.3850634-1-msp@baylibre.com> References: <20240729074135.3850634-1-msp@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240729_004201_722300_0E88FEAC X-CRM114-Status: GOOD ( 16.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In some devices the pins of the m_can module can act as a wakeup source. This patch helps do that by connecting the PHY_WAKE WoL option to device_set_wakeup_enable. By marking this device as being wakeup enabled, this setting can be used by platform code to decide which sleep or poweroff mode to use. Also this prepares the driver for the next patch in which the pinctrl settings are changed depending on the desired wakeup source. Signed-off-by: Markus Schneider-Pargmann Reviewed-by: Andrew Lunn --- drivers/net/can/m_can/m_can.c | 37 +++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 81e05746d7d4..2e4ccf05e162 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -2182,6 +2182,36 @@ static int m_can_set_coalesce(struct net_device *dev, return 0; } +static void m_can_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) +{ + struct m_can_classdev *cdev = netdev_priv(dev); + + wol->supported = device_can_wakeup(cdev->dev) ? WAKE_PHY : 0; + wol->wolopts = device_may_wakeup(cdev->dev) ? WAKE_PHY : 0; +} + +static int m_can_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) +{ + struct m_can_classdev *cdev = netdev_priv(dev); + bool wol_enable = !!wol->wolopts & WAKE_PHY; + int ret; + + if ((wol->wolopts & WAKE_PHY) != wol->wolopts) + return -EINVAL; + + if (wol_enable == device_may_wakeup(cdev->dev)) + return 0; + + ret = device_set_wakeup_enable(cdev->dev, wol_enable); + if (ret) { + netdev_err(cdev->net, "Failed to set wakeup enable %pE\n", + ERR_PTR(ret)); + return ret; + } + + return 0; +} + static const struct ethtool_ops m_can_ethtool_ops_coalescing = { .supported_coalesce_params = ETHTOOL_COALESCE_RX_USECS_IRQ | ETHTOOL_COALESCE_RX_MAX_FRAMES_IRQ | @@ -2191,10 +2221,14 @@ static const struct ethtool_ops m_can_ethtool_ops_coalescing = { .get_ts_info = ethtool_op_get_ts_info, .get_coalesce = m_can_get_coalesce, .set_coalesce = m_can_set_coalesce, + .get_wol = m_can_get_wol, + .set_wol = m_can_set_wol, }; static const struct ethtool_ops m_can_ethtool_ops = { .get_ts_info = ethtool_op_get_ts_info, + .get_wol = m_can_get_wol, + .set_wol = m_can_set_wol, }; static int register_m_can_dev(struct m_can_classdev *cdev) @@ -2321,6 +2355,9 @@ struct m_can_classdev *m_can_class_allocate_dev(struct device *dev, goto out; } + if (dev->of_node && of_property_read_bool(dev->of_node, "wakeup-source")) + device_set_wakeup_capable(dev, true); + /* Get TX FIFO size * Defines the total amount of echo buffers for loopback */