From nobody Mon Feb 9 16:45:13 2026 Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) (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 EA1A21C1F15 for ; Thu, 19 Dec 2024 19:59:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734638350; cv=none; b=jH+sEOjPlwYlLR5BQyGjinmEDZI5IY+iKTkRczX9pzXcsR6VH2xa4qysU7xtXO5MywD8Oio0wC+i5HUxv5iQUYqjUJ8Jys4HnBeZlYjjlW/JN6lUOkpuY+gKKExjE+86rYstKAl3DFI1ZuBKd/WJCM+ELWHk0o4OKAc0H6G+w4w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734638350; c=relaxed/simple; bh=JFdVPVem4046BqyFJNrVT8yrmK5qAD0B08AcK/8jouc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sAYl0VIJ96j7lhZSpUjnbpqtdBFrGy5buZ0jI0v5my0tL7G7x7cX48zAhuJqkS9zPalSjgByxDi8I8+gN3QKTaqL19O49LIFdmiKZ9tKQXpKgChANSuU83dcTO1OFCMapweWEK4CDwxIdHcW4ykWFdBet4SLPwhGa1BLm5jr990= 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=0wkKGBYS; arc=none smtp.client-ip=209.85.208.52 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 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="0wkKGBYS" Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-5d3ea065b79so1579487a12.3 for ; Thu, 19 Dec 2024 11:59:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1734638345; x=1735243145; darn=vger.kernel.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=2hLOILUzDo5sXZb8TaMc1HjYSIW50UI2D0EZn3eUUCc=; b=0wkKGBYSOT+GOIyMCexAHrBesg9G+IyTAtBXbt0UUVtGefnsORJr+f2CZmNf9Rt5Rf OvrzsAKwGJq4lV5i+tEEXc/i61jsF701lnGL4L+znJSK6HWo1CqJz1brp0ewViDe4J0O T+YypQ+6hyFCkPfXNAUehGcIIrq71yEYM/CIlVNHSMwmqJmVAjx95YcKLP1I0jyUumuo amhihI9ZXTR66S7qgIERmhIy7zz99as17PPGhtqhWiTDMRH+qBz4eSvPoe4mIlds844Q 7TB/J0g1BlCA5BruOCUSBTelm4EXFe45MXY/Einy/bYQ9rs/0OJIsUy+6UhFv3Dx81Tk Pw+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734638345; x=1735243145; 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=2hLOILUzDo5sXZb8TaMc1HjYSIW50UI2D0EZn3eUUCc=; b=WSZIhzhssREsx83EKQmbxmXARwMEJBQGIk/N2CIYtnI0VCA6y8F4XijXrmCgsNlLxa 3UKkK1P1O58ia8fuN0hDQjqtldqYZ9JUwXo3yKESR9OR9h0K/4Krllz+zpNjon4r8PBi RuczBaG8L6n2heqot+7z72npUxGK2eQJGcJ6meX2LllvTzn+Y1E81nTqYlq2SfHe6/iM LznZsoG13v5/LG+woN6FEaXc5QsiIMn3p8HS2NXOy1qjBF9pQbybtsiA0byFtxgIrUbO j0JgiJzCzPbIL36HaEJmMFTnRv/+E/6EZ9uEJaChuR99vQnlH16WX8zQSZyB44s/xRok aidQ== X-Forwarded-Encrypted: i=1; AJvYcCX0wSNNkYTfKx4g54xAbQ92pygmou+XXhr7Hg2bMAORy8sLyPtq13qAQW73fpOSeKcyX5/M26TRFm+dzzo=@vger.kernel.org X-Gm-Message-State: AOJu0YyEWOxRPjCcyasaxsAgEIlKHx2OuXFQimgybSeckoozG4XucGFM N4XjX6vHdlngB1ReEln+J1Hzilfl9mbbdAOlTTG0ZLOuLCBR89Ap74YGk+4ck/jo0K1llQMznLr A X-Gm-Gg: ASbGncuvOHn+Bpm5WSkO5SW7KPy0ev4CYcVM0b/VBPgO9nKQn9OxJ6FDOmR+y8wmHMu Xour3sxHy9vd5hj3VjbfXgfFRBqwFls2JYaUvha56UrVq9dlhyaG0tiixQJ5FyDA/4V81oYx+s0 UZnRAM4hImJdR7GfZClZpAe7kVDieYElBlzKDJGB3ZoxyU5ZxMzxiyej96k8Rpz6ceexVMqN0DV GiNP2S9wGwfg/GDLgr/Ug6ESprDZRsgmMUYYtAl0J327hG6YQ== X-Google-Smtp-Source: AGHT+IF0fmv4Wr8LY08jRHZsI4hjJsYafL7GiFI9dClEL14qKh8/PvfWAazPI1H0PfTeK1OuVNPC+Q== X-Received: by 2002:a05:6402:401a:b0:5d0:e560:487f with SMTP id 4fb4d7f45d1cf-5d81dd9cda0mr166803a12.11.1734638345098; Thu, 19 Dec 2024 11:59:05 -0800 (PST) Received: from localhost ([2001:4090:a244:82f5:6854:cb:184:5d19]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5d80701c822sm944816a12.77.2024.12.19.11.59.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 11:59:04 -0800 (PST) From: Markus Schneider-Pargmann Date: Thu, 19 Dec 2024 20:57:53 +0100 Subject: [PATCH v6 2/7] can: m_can: Map WoL to device_set_wakeup_enable Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241219-topic-mcan-wakeup-source-v6-12-v6-2-1356c7f7cfda@baylibre.com> References: <20241219-topic-mcan-wakeup-source-v6-12-v6-0-1356c7f7cfda@baylibre.com> In-Reply-To: <20241219-topic-mcan-wakeup-source-v6-12-v6-0-1356c7f7cfda@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=2839; i=msp@baylibre.com; h=from:subject:message-id; bh=JFdVPVem4046BqyFJNrVT8yrmK5qAD0B08AcK/8jouc=; b=owGbwMvMwCGm0rPl0RXRdfaMp9WSGNJTql42hv/19nSYusP1CavLp22BNzZ/n7ouRXbt/D8C6 h7r+A5c6ChlYRDjYJAVU2S5+2Hhuzq56wsi1j1yhJnDygQyhIGLUwAmov+J4b9TXO2Cm37sN//f a8hrCUk+uTZxt8CZi5NOl7adu+ObLfaMkeFTQNfl8oeFMqtrDm/I4c1fUBR8zveqgEjR8R0uXD8 MLzMBAA== X-Developer-Key: i=msp@baylibre.com; a=openpgp; fpr=BADD88DB889FDC3E8A3D5FE612FA6A01E0A45B41 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. Reviewed-by: Vincent Mailhol Signed-off-by: Markus Schneider-Pargmann --- 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 16e9e7d7527d9762d73a7ec47940c73c0976e05d..0dcdcde3449c7647e4bc9a92f91= 8160a336f94c0 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -2186,6 +2186,36 @@ static int m_can_set_coalesce(struct net_device *dev, return 0; } =20 +static void m_can_get_wol(struct net_device *dev, struct ethtool_wolinfo *= wol) +{ + struct m_can_classdev *cdev =3D netdev_priv(dev); + + wol->supported =3D device_can_wakeup(cdev->dev) ? WAKE_PHY : 0; + wol->wolopts =3D device_may_wakeup(cdev->dev) ? WAKE_PHY : 0; +} + +static int m_can_set_wol(struct net_device *dev, struct ethtool_wolinfo *w= ol) +{ + struct m_can_classdev *cdev =3D netdev_priv(dev); + bool wol_enable =3D !!(wol->wolopts & WAKE_PHY); + int ret; + + if (wol->wolopts & ~WAKE_PHY) + return -EINVAL; + + if (wol_enable =3D=3D device_may_wakeup(cdev->dev)) + return 0; + + ret =3D 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 =3D { .supported_coalesce_params =3D ETHTOOL_COALESCE_RX_USECS_IRQ | ETHTOOL_COALESCE_RX_MAX_FRAMES_IRQ | @@ -2195,10 +2225,14 @@ static const struct ethtool_ops m_can_ethtool_ops_c= oalescing =3D { .get_ts_info =3D ethtool_op_get_ts_info, .get_coalesce =3D m_can_get_coalesce, .set_coalesce =3D m_can_set_coalesce, + .get_wol =3D m_can_get_wol, + .set_wol =3D m_can_set_wol, }; =20 static const struct ethtool_ops m_can_ethtool_ops =3D { .get_ts_info =3D ethtool_op_get_ts_info, + .get_wol =3D m_can_get_wol, + .set_wol =3D m_can_set_wol, }; =20 static int register_m_can_dev(struct m_can_classdev *cdev) @@ -2325,6 +2359,9 @@ struct m_can_classdev *m_can_class_allocate_dev(struc= t device *dev, goto out; } =20 + 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 */ --=20 2.45.2