Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp832004lqp; Thu, 23 May 2024 00:55:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUkOpuNIXH6a0llZsISSBsnB2J/ITeRcfNFsriwo0WdgTybgnkHmIFVAKo+PgLB24z4Q3oGQq58erkDjFXCaadkZya4YjhhFfY4j4Adow== X-Google-Smtp-Source: AGHT+IHzTFRDSl9S1UmyT2uNXGkg3DhGxJYjBF1+qV8vkwHUckpmO00TKiGtFH+KrCnDAUV5iKNa X-Received: by 2002:a5d:5352:0:b0:354:fb27:ba42 with SMTP id ffacd0b85a97d-354fb27bb89mr765006f8f.11.1716450926388; Thu, 23 May 2024 00:55:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716450926; cv=pass; d=google.com; s=arc-20160816; b=0QiBgbaJ7bMPlqtLohqW8Mi3byvJVoVoFKW+RtZmJSS7Cz1rlzbOnadKP8A8t7GQxz 1vCOLMp3iqXLrS2wMVtxzPwStcZ0f0LKkfH5J3cy+PxYBKhji0TohsKAKMahyOafjqSY ERuBU6N7BKL3+O1kxN0pZafhupZS4jm7Q0OSDoTKArehMWa/OjqvYL8frISBGvn9UfDN VtWSE2Omok49bTXiT8u20Lj0Gt+W3s3Pg5URdQI60ahzvaAEZ1B7Bu58OE/Fyu65l2sP H7B5UDtAhN3SC42LrMEzszDo8Z4A6ilANfZlqHDJoe/Ji+NUgaPVgZ8o2qRlgmFm13VM f6gg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=hrFQSVhPJTExMHxUs9x2644C6X3jCTcC0vL8A1PKT6s=; fh=rI8vOxNpm/qj3gCDXV9j2Rephc7WUyavXis4h+2YNII=; b=Oa1HX9FccbDTEXiQnEYDSp6yd9rjdjPk6oWs79okoyFjJ2N4uGgARC/sDSahMYEreA 1sPwMyqFRCvdhxXI0GpPhNNM7BwDDlv+fHW7sD4C/MXFWtsSnnbrLHlar6ccD3Ra1AZq wUMPhSQPobN68gyxCgUprwmt/obcclO30L0CEAvwUJ5XKm/ASUNIitT53l9fZUqwwV66 MD6gueQY9RkeILx5x5JZiI1IfbYWmvY2dDFDBPKGWZyI+n+gkDJpOSVsZOUfEAFEvA1o M8BEHBZuLBTYbDP6WLUjaD41+jDfEnxz+neg3DDLSFk9fmsEGyqxcWDI/dkPms2GKL2N RMPw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b="kg8Zfb/G"; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-187117-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187117-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a88eb851dsi1057209566b.534.2024.05.23.00.55.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 00:55:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-187117-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b="kg8Zfb/G"; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-187117-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187117-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id EFA131F21CE1 for ; Thu, 23 May 2024 07:55:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5FE8813D290; Thu, 23 May 2024 07:54:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="kg8Zfb/G" Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A218913CFAF for ; Thu, 23 May 2024 07:54:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716450870; cv=none; b=WLlHBmL6rzRzo2vtK45D/qxNKufs6i2Y+GWiuQBWLdqiRgMkGPo/vRDCjaVmbTpQ2jEowcsbOCDnJctfrOcabR3pxPm2SllvGxozsqjLCVRP5NJsSo84o2tddVokYUo9dz1CwwNBA6YkdcXi0bSB0m21zKa6ngMQh2NfvIl3Pnk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716450870; c=relaxed/simple; bh=BPcdpNgRauvstbwBV7cyTFTtfwTX1AJQa1VOyBH+Orc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rGs16sQxuVEEdBFzwm6y9a8TkhLeav0SGuc6npKaetIH3Ljj5N7czFWc/1XSQ7Jb/adQEcbxmNjWbAxtSpKE2DcnpCWEnQImD4rYbecW46TO7ix233OfmdICNRX187kdH9mJs8rn0A+SVUS34Xv1lN33CWv3DsDW9D5NOTcDRjw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=kg8Zfb/G; arc=none smtp.client-ip=209.85.221.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-34d9c9f2cf0so1965667f8f.3 for ; Thu, 23 May 2024 00:54:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1716450867; x=1717055667; darn=vger.kernel.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=hrFQSVhPJTExMHxUs9x2644C6X3jCTcC0vL8A1PKT6s=; b=kg8Zfb/GLOwSbemxCeWvdCe/ZqX+cEzQssOdpaqq4Yk/MH6BVrNZfbSPPDkyXwjsZe ARYgUbAxaqrilEzuM/moTqhvlRmYatcfb86ercfb4QY1gm/NJuwX3n4lFpYnU3IyTVA8 mvBj28/TrQJ7umaAL6Z0gESqUN6OLAg7jCm5LI2BEcaIn0dL5bB8GpcCFGSaCxO5xQ5b xdu0R5lcCZz4VnwHbs9uEF/h+fRFtPcy43M+zwDIbqPPFASS1gy4BDTo6XN6hgyEPmR3 cjaYSV074df5g+IQQnLzVzQXPGWWSK316Xd4y+Azam3bjW0mmCuFui4b8ZqTUo0+rvCm 12yQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716450867; x=1717055667; 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=hrFQSVhPJTExMHxUs9x2644C6X3jCTcC0vL8A1PKT6s=; b=FJNU4d62aCYHdFC11Rp7eUrLUbUOtMYUxgLULFAbeBQVkz0byxoKbfKRN53cTHb+AV GiBL0SVZRzXDNVZ39DtQeBzhjhy7Vc8PWDNfQtybvPJ9MaMtOywhc7EbjvOnH2TlX8zf q0JuzPfe0t8naoDCdSEsGGKPltwIhvlICMWNWVndYU5w/iPzKXtRMG3X5Ai5QnvJZl0C cbQO5LcGX3exWBN4SqQ7ZHWZGcWgWIa4BOx8jkHwKTup2dZbMJB+BJ1eupR3c0VuqHLr JzTKPA746K8jaHJ7/hLj0BvFqZwGYUyp+fT9dAtxHiYewcdEgjuXAYBeMFGnBEum2v2T F4/g== X-Forwarded-Encrypted: i=1; AJvYcCWe2CkoH10gq2P8jOTROdP/7zpZoN+92UyPvgS+tu54YzcJFBVSjvf6fW6v1EU5n8i4d8u1LI5jKNm5gAVwzMqDFX0M68ovABG2RaTp X-Gm-Message-State: AOJu0YxiJl21LdA/24XZ70lkIJA1rbsBtGXCCN++4g+YJEcQxcKcDqD7 T3ZWj9014hyTpf95ghkpP79yiHXGZjk/sUVr6L/lQER1MmmeVsuRILMbl9ioMBg= X-Received: by 2002:a05:6000:1fa5:b0:355:15a:f0b5 with SMTP id ffacd0b85a97d-355015af206mr229576f8f.32.1716450866839; Thu, 23 May 2024 00:54:26 -0700 (PDT) Received: from blmsp.fritz.box ([2001:4091:a246:821e:6f3b:6b50:4762:8343]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3502baad074sm36501833f8f.70.2024.05.23.00.54.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 00:54:26 -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 Cc: Vibhore Vardhan , Kevin Hilman , Dhruva Gole , =?UTF-8?q?Martin=20Hundeb=C3=B8ll?= , Simon Horman , linux-can@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Markus Schneider-Pargmann Subject: [PATCH 3/7] can: m_can: Map WoL to device_set_wakeup_enable Date: Thu, 23 May 2024 09:53:43 +0200 Message-ID: <20240523075347.1282395-4-msp@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240523075347.1282395-1-msp@baylibre.com> References: <20240523075347.1282395-1-msp@baylibre.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- drivers/net/can/m_can/m_can.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 14b231c4d7ec..80964e403a5e 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -2129,6 +2129,26 @@ 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); + + if ((wol->wolopts & WAKE_PHY) != wol->wolopts) + return -EINVAL; + + device_set_wakeup_enable(cdev->dev, !!wol->wolopts & WAKE_PHY); + + return 0; +} + static const struct ethtool_ops m_can_ethtool_ops = { .supported_coalesce_params = ETHTOOL_COALESCE_RX_USECS_IRQ | ETHTOOL_COALESCE_RX_MAX_FRAMES_IRQ | @@ -2142,6 +2162,8 @@ static const struct ethtool_ops m_can_ethtool_ops = { static const struct ethtool_ops m_can_ethtool_ops_polling = { .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 net_device *dev) @@ -2266,6 +2288,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 */ -- 2.43.0