From nobody Sun Feb 8 17:42:53 2026 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (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 4A71B12C54D for ; Mon, 29 Jul 2024 07:42:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722238923; cv=none; b=QNtq5dyrVTPN7Unr40n0c/SyL5S/9YQXMAmaky5uHVJEYmg1wnJDGKcqmNo2R6YzXZ1inC+bKYJ5Dioo3tcVBQ/pfATizxHq5YKszAWJ+Njz5+rWhADC4oS4jOxExnK+OeiF9+rRByZ0sCA717AjRnwlc2J3Rk/cgiNP4ujK1a4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722238923; c=relaxed/simple; bh=t7F2lKoixWfzCSNEpIYekj5rawyt2QRxC3AGjmCilLM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EgLkSmtquEtJmCKNzp69gr+8gaO+Cvcowr6Zez4SRmpuBCIKfPcBlpHZ9sAXpocySuiIIdGTNDPh6qqk1+bDnjeVdrZV68gIATIdUaanipUaq3b5a8YDt4JKtbqYnYDoR/81nDe5eGFmIeZKIiXdAJGg+fxyzrbW/hiEHCPRGks= 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=fgy3eIpv; arc=none smtp.client-ip=209.85.221.48 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="fgy3eIpv" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-3684e8220f9so776048f8f.1 for ; Mon, 29 Jul 2024 00:42:01 -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=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=ZCJyOdovnkFMEmbndXoqHv/AoixQbNLaTwmx6tiqcEI=; b=fgy3eIpv4wNCMkq5iKTCCDuJryptZxSFJTCW7Esks7pESN6kl+8HkbJG09E1qDbp1F qCXDkIeAPumM70YrzMKKBpCDw8BfIj80TUUucZneSCRHRwr5TZH5aBwAuDERp8iqwoHm hj3JY/HRAtJQak7K0HSzjzNS5r8yyK6Hh27cnHVso8TbjyiZVuKqUPUc0I1QLP2niH8u +ZTw/RPtxdkfCa1Osr10GVm4JTCH61QjiRjP0FOT9PKHVHv7RCpRhYb71F3XQZWLNino /Y2bNfpQpyr6rqWveXi/rTPcvwaA0+tzCoLUqEFibSsGwOXWfs9113X0Ad2HWCpAjoN2 ciwA== 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=YFS+hAc5YJ4kcKrJQhLlBJvMHPQbZplYAfISQvKKNKjeHB2mGBtkG1o0Q1EZhVG8EE bNIJh/ht4zexav7mkWyiKCGOjtDiHD9gkFcaukPjp6y3JFjcT2/wOS2IOboCQGnzR9aM NkFXVccD6TaPiB5sUvqm+kOkyZAVn2hlNYNGU0g8nuC1gaAVDZMRks0wJyqnkWzfyd1H p7Nps3L/DO4nEDvafdpDUozEOvDRo/kVxCB7ucnwTPgeZWbK7cuPGFsUMbHmmm8sBHEW BAYISS352hj5nJ2x1JgKi//ZFmXIZHX6EfuMUUEUL8iBCeUzJSvTdofCtq1sIR7cqiP8 H0ZA== X-Forwarded-Encrypted: i=1; AJvYcCXlfO744PGJeaHPrydxfxc9V05kFj1c9MwqpccUDAfeUmTR9V1itD9INNkpkw1okdnT7/3+Fo/kxVBEtJTI2qmqYkGc9d4Tcc8pSifC X-Gm-Message-State: AOJu0YxdGYBgV4TbTPYm109k36QIUxtYYH4UV3YqQmjCto2kvXOjUB6J 7b9O9ZHJm2mszEpDteqMoNBAmxRtNmZS6notcfUo3wcOZMiDh3CoHwA/9Sn3pLI= 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=20Hundeb=C3=B8ll?= , 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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; } =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) !=3D wol->wolopts) + 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 | @@ -2191,10 +2221,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) @@ -2321,6 +2355,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