From patchwork Tue Oct 15 19:15:57 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: 13837015 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 C8CE8D1F9C5 for ; Tue, 15 Oct 2024 19:27:23 +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:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=mWNsNiv/VcA8vMctiIZy19xLDs/iPmWut03+H1meriQ=; b=Czp4tAaA70FLXiafQX/97yR+iu fEznKzHzyxKko1FiswlG5FfT+MLyBZGXFaoIwpYTCB20Ua7iMSIcPJSzvsBVc9kmzRlC9e5QmteN+ mmmQIZKVvb3vH1IP/yj0CZjV669unuumkwLUTWWeH2VtS7gJeLrQVeuDooVJunPUjuZwQJJC1bbqb y6Mo7JztUmg8/kHAIq/J/N0OXJjy5Z9tYDdZ0q5OKHwbf1O4NxEQh4Q3Iv5Hw8utqJosl9HyD3P10 YqFTrj6033T7XF7Jr+D6IpKmn+LRJrRLk0H8KfC6RtVAKMIktgdzq8ADDljFRhNzxoXWWK656pFZo FdTJ/YgQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t0nCM-00000009OH5-1hzG; Tue, 15 Oct 2024 19:27:14 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t0n2s-00000009MWE-1049 for linux-arm-kernel@bombadil.infradead.org; Tue, 15 Oct 2024 19:17:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Sender:Reply-To:Content-ID:Content-Description; bh=mWNsNiv/VcA8vMctiIZy19xLDs/iPmWut03+H1meriQ=; b=Kh5QNDXfQswFKb17Fu3r0qH/2z Vc3/IhXL5Q9yscUMhseksHFDJvC+mJrghnLkZR8OnGiuDfpTZB/6c9mAL3/eIslfz6hYsDgrjVLr0 xQQRh1ZssJG9T3938pjFJXoJhMVqOrj/ab+v085SlcGXOYTvJkuoQRpFvp+zE98UJKz6ryNVv66EA OXXd+T6GJxQo0Tj9b/2o+IjRPoLuuO4AyDi1RcGUGOni4nF6xFupaXAamq/D7TuEy6qfmW5l9aTSs R3ihPaL2ylcKJmDpbHX5CHCT0h14X0jKR74sXxCS3iKbPmOXnDg3h8OHg5QDyQHTKKAIRS5ARP8wo VCueaTtg==; Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]) by desiato.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t0n2h-00000006dfh-2IuD for linux-arm-kernel@lists.infradead.org; Tue, 15 Oct 2024 19:17:19 +0000 Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-5c903f5bd0eso8704791a12.3 for ; Tue, 15 Oct 2024 12:17:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1729019833; x=1729624633; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=mWNsNiv/VcA8vMctiIZy19xLDs/iPmWut03+H1meriQ=; b=wfCwu0+08KiIn15k20UyhT1wU/906Jym/sg8Kl8sQIPoc4TSsfISYKay+wolVw+kI5 YLdXxBXFnslqFN3vkbGKo9QgdisQsYff+q6nVuB07f0FhHYiLBRp/JK64gQi6PNJrf+E ZelgU0vVyAtgXmH7ug8K4JIvvpek9gdPcp7NIkmR62B112uUgUkyeyCt6l8U8Ex2eoh9 plMKxif9w9qDXKGD+3vbKC2+QpdJtCLbNAYv3lKjxU4znFxIeL+WLod69Mf9K5xJulPg Z+RuEvKEYqsrjApHbxQfQDIX9VDIXyFkSpUQGy1bK8PrdO/pfQgNrJi0COIWTKDjg9Ll 8Tww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729019833; x=1729624633; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mWNsNiv/VcA8vMctiIZy19xLDs/iPmWut03+H1meriQ=; b=Ixwp0Tv2r5uXiJnfSLK8BlyBOxLX4173Oe8XD+zzo9VG+B2OBxXCfZgVeSBdTTZ/k6 iAoQu7gmOCmeoRglzTXdxynKbCQEoJZLratu0cmG2kRGYHtzq4NOOcjPx7DhvNfaLLfj QioCz8KFKc/+CauFHr7cDYILJFD7jhNYc2M+T0nAM8lMrLEgdtZPu179Pw3YPJmVEnFn XgvW+QDeh3+SsbvTxozryCteSU3LzkbNg1ouRwvvgluoBZc/wssRQhhxnZVpZMzpcG46 sD/7xo6NRE6U6KU/SVR8L0dIyfgEjQc7R+QLuh5HJ8NjQc4SFvdhNDXnRVXkXQ6bfpX3 2F+Q== X-Forwarded-Encrypted: i=1; AJvYcCVEV3X9uKj/p/vIOpiqRmR0BXPWfQZLDRzfp/pO8MvxpqHNzHmgFUXoy7gC/6cVfMJQHrPVvzidZ7hK8T1fz7EU@lists.infradead.org X-Gm-Message-State: AOJu0YxHuTBCsFQz9tPUYASABLcwVKtUf5AI/UWffGP2zmb6C7Lr02HV FJ0etKrjT5QFhD1HirsLwvtOS46JC7B0TbxpVzo1TtZ1iuMp+Z80G7iX07jNDts= X-Google-Smtp-Source: AGHT+IG6Wi1Y05CbHfGWTKc2Zvkf+SR2UYH5CumYtIzfZCX8f8wWHAG3iJhGVNaioMcvfL42erh2WA== X-Received: by 2002:a17:907:94d0:b0:a9a:e2b:170e with SMTP id a640c23a62f3a-a9a0e2b1ab5mr793919066b.10.1729019832936; Tue, 15 Oct 2024 12:17:12 -0700 (PDT) Received: from localhost ([2001:4090:a244:83ae:2517:2666:43c9:d0d3]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a29843374sm101011666b.157.2024.10.15.12.17.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 12:17:12 -0700 (PDT) From: Markus Schneider-Pargmann Date: Tue, 15 Oct 2024 21:15:57 +0200 Subject: [PATCH v4 3/9] can: m_can: Map WoL to device_set_wakeup_enable MIME-Version: 1.0 Message-Id: <20241015-topic-mcan-wakeup-source-v6-12-v4-3-fdac1d1e7aa6@baylibre.com> References: <20241015-topic-mcan-wakeup-source-v6-12-v4-0-fdac1d1e7aa6@baylibre.com> In-Reply-To: <20241015-topic-mcan-wakeup-source-v6-12-v4-0-fdac1d1e7aa6@baylibre.com> 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 Cc: linux-can@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Matthias Schiffer , Vishal Mahaveer , Kevin Hilman , Dhruva Gole , Simon Horman , Vincent MAILHOL , Markus Schneider-Pargmann X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2797; i=msp@baylibre.com; h=from:subject:message-id; bh=u3MS8m9UeG/FKMz+2aOKCV8URfG29eAzix8kKH+yzxk=; b=owGbwMvMwCGm0rPl0RXRdfaMp9WSGNL59k90PPz83/zbxmZT0q8prg/tYjDLUb7E+uH+Ke9ZS Uq3Dhjc7ChlYRDjYJAVU2S5+2Hhuzq56wsi1j1yhJnDygQyhIGLUwAmIv+N4X980sdAKe+fenOi BPbcXe81x0oilP1I45oVa5WXOBxoP9/IyNDGrD/7x7TU6bdipAy7HDhEikS1Q0/v9ew/mdkS1qO nyQYA X-Developer-Key: i=msp@baylibre.com; a=openpgp; fpr=BADD88DB889FDC3E8A3D5FE612FA6A01E0A45B41 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241015_201718_083478_F01C00F9 X-CRM114-Status: GOOD ( 18.01 ) 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: Vincent Mailhol --- 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 a978b960f1f1e1e8273216ff330ab789d0fd6d51..d427645a5b3baf7d0a648e3b008d7d7de7f23374 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -2185,6 +2185,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 | @@ -2194,10 +2224,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) @@ -2324,6 +2358,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 */