Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp832171lqp; Thu, 23 May 2024 00:55:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUXS6vlyWPLKlrlnNSJ9/3ZF9MnvlC9fO7L9Jm3SocEEd3CCjqRynQOFY3ylv///s8IEWR1J+g/mw2HX1B0Pm8R2l99wUSQwn7u44N2ug== X-Google-Smtp-Source: AGHT+IG92ETocZlZJ8PdgQC0uDgfAys3kyjXb5VUZ7ST6tgeeSECj7IYHO4GXCYa0qaV1sRrovSY X-Received: by 2002:a05:6512:44b:b0:51e:646d:fe3b with SMTP id 2adb3069b0e04-526c1213db4mr3290812e87.60.1716450959625; Thu, 23 May 2024 00:55:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716450959; cv=pass; d=google.com; s=arc-20160816; b=AdepZ4ivZXr3Lmxv+157CYNIA+8OExqj4yAuMeBopsLAS0zMKePwtIuxpMwRiENUdn qHZheMeWXbEM/KwOLWhra113AmfN+ZaPAzWT5lprcr0ZFXJBHCkJtfHRWFeLwMBDIAli A8GOh80G8CKW+UC9/Ry9dt0bpn793klX9Qsul3xZaCC+M8OTl5cf/Prghj41heVAHbXI lFi8F/rVkzBimkGmXgkoKL0QR/1g7xOwjtC6ETyC/8HMQW55c/wAvRoGyY1y8Iy6ZYP4 nNivs81fKTz+jX7TOxKxwDn2JSj6970akn5MIS8LB2UiYfIDZlZtVXI5CE4oBziljRjR Q7FQ== 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=P4T6sy6AEq30+xE+MXFJmyPKxLYvjiOTPFV8oNWYyfY=; fh=dYXQYcPyVGuZmyfeVURXek8uQgs398x4PkkItmXXqjE=; b=EHYXaKqpd4hfQQO/8JsbqcbBzqXEoHlEjYR70tkObpajKxmgxH/wmdEpxMp8WILnkQ a2cICRfolXzGmWo0COKNHbGkfQSSzhCxC1t3TaziaBIvkYOpfjx7222ZIinfRys16wg7 fIHIhQgz5jA5eHXDtt5fkUxQpLOifH92FfLs0UlHm/lVGvRJHGYi5UzwFIGDlQB06IWn Xxqo69HehrZAbxOS6EjbyTNB7NHOxEfsT7AaB40Q1XgNx1mZ1tp5kDRhEkSM4hlmVfkn mNkyrCmLQRiRdctFHJDLQxts5L+koiigTKj4xHvVIlF+6FUH9ozuwT5V/LxURE6ElPPT z3yg==; 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=APU8nV6P; 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-187118-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187118-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-a5a17c2c14bsi1652994266b.953.2024.05.23.00.55.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 00:55:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-187118-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=APU8nV6P; 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-187118-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187118-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 326F51F21CE1 for ; Thu, 23 May 2024 07:55:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B88EF13D53B; Thu, 23 May 2024 07:54:33 +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="APU8nV6P" Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 E95AA13D260 for ; Thu, 23 May 2024 07:54:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716450872; cv=none; b=Vdm9j5FtTujX9qUQJCqaqXPNj5qz1RmSQZF1zLqEjtVGIBuWFm8ArsfxpzjdkxQmPEOqUvnwf8Y0muwj1yWN5ubuSxq+ESv437YmVo70XQIW5Lc4wHiA8kF2DiH3atpLxQ2Le+SSjrad1kAa7pQ8buOZXklpYLqLGEBJrIhYXk4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716450872; c=relaxed/simple; bh=psaW3D5sy9xXOmkzELpixxLbVsz3tVfuUMx9AZiaJks=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BoreFFSF1easSoc+Nwkl3uueogCsulnXr3PkEPipraTjX9SwcXxuJWVHvvSJFz1w4FAtEmsyooXCW3E8vTh+TC/RYy38VQ1G5TdRuJbzKO0JpDl3h+2loXtoIw6yywdIRxRT1n9yEBl0RSOasrXN9D8atbzFm5+g3repzBmKEh0= 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=APU8nV6P; arc=none smtp.client-ip=209.85.128.49 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-wm1-f49.google.com with SMTP id 5b1f17b1804b1-420298ff5b1so68287535e9.1 for ; Thu, 23 May 2024 00:54:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1716450868; x=1717055668; 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=P4T6sy6AEq30+xE+MXFJmyPKxLYvjiOTPFV8oNWYyfY=; b=APU8nV6PUH3bX5GA0rppxHpHVJP88901zi2kPOwVbk8S/fLlm0LEfDTd2/UoFpsnN8 uUGVrfwZbyaU/PRR2GD8mV6ABnpPy7crQr9hwnJsar+cZFbijE900/ekMESI4RXIcBt+ 20L/J7dW3MwWyaLZwKGX6/8F0ypFjDgxlCad35TtCbt/iYr4+s5Zfkcm4KPY/Mhrnk0p Kqq/u7+ukUxcnSeyYjJjyI+cbWmSh/BUYR0lHER9KU9DOSlTK/6hOq7iUwvVb0fjJy4u LnqnDR2VsZ8NxZSlO0p4yxwAGK3KyAJSWDNSgZL4JKjjK7UeyD7vCQJAIagAwjeJnUc1 KSfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716450868; x=1717055668; 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=P4T6sy6AEq30+xE+MXFJmyPKxLYvjiOTPFV8oNWYyfY=; b=HFlzYDiI8PHQOhbC+kR6GErdcdTqBAEbSoZm6M+QICpIU+Gb1g3uk/a+QH1XXkot0I GF6fYXnQ5sD2JsfwOOKb6grgP9dAYJ/3e8ForynA/7inyyKPL4A/cTlavuvY5fM+y9wg RyhzwdkPzJ6rxBrPARfQIuBEAmOP8M42E1WoGFwx5NuGoY3Rb5oXF/XUzAIRPMlJrabu 4V7s1URL5guxZrOQ/LzkGnI+m66O94P7ojAU6JmU0GhvsCXlAONE4j9EPNbJuGAwlx9N U35tbqionsFFGPPaugPbrnHlMy381WWp12kz/OchLje7qI9PGJ6XShIinWGnQ1Z0krri ettg== X-Forwarded-Encrypted: i=1; AJvYcCVNljskrFx0xF3TOyU1G2yx2kdfac2AG/UCp8yZl0l6C4gvSBhzAmtH7/p7vD9bGPe78P4JOPpLGg/f3a89EyrE3NCWOrBqWozrzgro X-Gm-Message-State: AOJu0YwzNYQOcGoTMS3I+LTjDR41M5CaoyaY/o76BLb6b5xrK2uqqqY/ 3xyqm9FfcThEPEHM1tSkrOYhtwMeLcx4rDSgevOBD89UJxOtjj3A+AUczZ1gh76wjzYPVhM3zYQ l X-Received: by 2002:adf:e6cb:0:b0:354:f2b0:ebda with SMTP id ffacd0b85a97d-354f2b0ec82mr3067448f8f.10.1716450868279; Thu, 23 May 2024 00:54:28 -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.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 00:54:27 -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 4/7] can: m_can: Support pinctrl wakeup state Date: Thu, 23 May 2024 09:53:44 +0200 Message-ID: <20240523075347.1282395-5-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 am62 requires a wakeup flag being set in pinctrl when mcan pins acts as a wakeup source. Add support to select the wakeup state if WOL is enabled. Signed-off-by: Markus Schneider-Pargmann --- drivers/net/can/m_can/m_can.c | 20 +++++++++++++++++++- drivers/net/can/m_can/m_can.h | 4 ++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 80964e403a5e..c5585dc68f2f 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -2140,11 +2140,21 @@ static void m_can_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) static int m_can_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) { struct m_can_classdev *cdev = netdev_priv(dev); + struct pinctrl_state *new_pinctrl_state = NULL; + bool wol_enable = !!wol->wolopts & WAKE_PHY; if ((wol->wolopts & WAKE_PHY) != wol->wolopts) return -EINVAL; - device_set_wakeup_enable(cdev->dev, !!wol->wolopts & WAKE_PHY); + if (wol_enable) + new_pinctrl_state = cdev->pinctrl_state_wakeup; + else + new_pinctrl_state = cdev->pinctrl_state_default; + + if (!IS_ERR_OR_NULL(new_pinctrl_state)) + pinctrl_select_state(cdev->pinctrl, new_pinctrl_state); + + device_set_wakeup_enable(cdev->dev, wol_enable); return 0; } @@ -2309,6 +2319,14 @@ struct m_can_classdev *m_can_class_allocate_dev(struct device *dev, SET_NETDEV_DEV(net_dev, dev); m_can_of_parse_mram(class_dev, mram_config_vals); + + class_dev->pinctrl = devm_pinctrl_get(dev); + if (!IS_ERR_OR_NULL(class_dev->pinctrl)) { + class_dev->pinctrl_state_default = + pinctrl_lookup_state(class_dev->pinctrl, "default"); + class_dev->pinctrl_state_wakeup = + pinctrl_lookup_state(class_dev->pinctrl, "wakeup"); + } out: return class_dev; } diff --git a/drivers/net/can/m_can/m_can.h b/drivers/net/can/m_can/m_can.h index 3a9edc292593..bdfbba67b336 100644 --- a/drivers/net/can/m_can/m_can.h +++ b/drivers/net/can/m_can/m_can.h @@ -126,6 +126,10 @@ struct m_can_classdev { struct mram_cfg mcfg[MRAM_CFG_NUM]; struct hrtimer hrtimer; + + struct pinctrl *pinctrl; + struct pinctrl_state *pinctrl_state_default; + struct pinctrl_state *pinctrl_state_wakeup; }; struct m_can_classdev *m_can_class_allocate_dev(struct device *dev, int sizeof_priv); -- 2.43.0