From nobody Wed Nov 27 14:41:38 2024 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C01A11A08D7; Thu, 10 Oct 2024 06:16:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728540990; cv=none; b=eVGNl6hs35203ilC7TXnSASMHIUeLI6nMZ6RQ7w1HHD+/a3IhgZlWyq+YxXUpQdOzbh/XYI/L8h7ez9QtAAhJBL/0ItBsoeXQ7LntQgKASzwA/79R1NJ/pp+Fb1egFOMj58TJ5lGhLWJP6fHvw/C8TlJJSHBSl1gYhrbGq/fLGo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728540990; c=relaxed/simple; bh=4jRMbsTtya8sck9o3TXTSwqD4/vs49q7NhKxiAlTRvk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BXXcWE/pCCoEfXFV0kuUvPO38N5p5ajrGprGAFcjQkIfX8lOllRBE7vNZt4ttXb52G0SmDEd7H0iyZrOpEIDnqDIDtrHTg7tjwQ4jQwiUPYxKMtNSzlh8EmF1K7u7EVn/t6WR18mQOwElX2ajYvASp/pgfIPNGfZz+wwcycx/ic= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=Fk9w5ESl; arc=none smtp.client-ip=217.70.183.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="Fk9w5ESl" Received: by mail.gandi.net (Postfix) with ESMTPA id 54A77E0009; Thu, 10 Oct 2024 06:16:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1728540986; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0CfXTIB149DBJ5rPusvsT7b3a7k7OVBjpLaLXBVFRjQ=; b=Fk9w5ESlv8XUeM0tN84YgA0TJj4Pgzw/ZpprLMS1CafNBAV5qzD1GNSf88qRF0pXbLFa1o Fgsmgk7c0qx8gbaVq7rKlGMyKqeVQNp8U61gbULq6V9XU9ick8r6eZ/3rE9NAGcb+cqSE0 cnszPLaLafo6TeNsAQEgbPFz2pJxhVLeX5Fqu6BqX2v23LkP/JoMbr7DUIXYW4q2MVH0Dq 7dD2dryysA715SBxTYr0Kczl7woBn1WYU7My0wmlXgV6SYLsEv67Xj/9zMQKgioryHMV5V q+hBFHXot9oKRq9+csWgnTw0nsaSrPb0xHYF9bS26G/i7Lh11qI7d7SsVn6vrQ== From: Herve Codina To: Geert Uytterhoeven , Andy Shevchenko , Simon Horman , Lee Jones , Arnd Bergmann , Derek Kiernan , Dragan Cvetic , Greg Kroah-Hartman , Herve Codina , Bjorn Helgaas , Philipp Zabel , Lars Povlsen , Steen Hegelund , Daniel Machon , UNGLinuxDriver@microchip.com, Rob Herring , Krzysztof Kozlowski , Conor Dooley , Saravana Kannan Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Horatiu Vultur , Andrew Lunn , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Allan Nielsen , Steen Hegelund , Luca Ceresoli , Thomas Petazzoni Subject: [PATCH v8 3/6] reset: mchp: sparx5: Map cpu-syscon locally in case of LAN966x Date: Thu, 10 Oct 2024 08:16:11 +0200 Message-ID: <20241010061615.787073-4-herve.codina@bootlin.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241010061615.787073-1-herve.codina@bootlin.com> References: <20241010061615.787073-1-herve.codina@bootlin.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 X-GND-Sasl: herve.codina@bootlin.com Content-Type: text/plain; charset="utf-8" In the LAN966x PCI device use case, the syscon API cannot be used as it does not support device removal [1]. A syscon device is a core "system" device and not a device available in some addon boards and so, it is not supposed to be removed. The syscon API follows this assumption but this assumption is no longer valid in the LAN966x use case. In order to avoid the use of the syscon API and so, support for removal, use a local mapping of the syscon device. Link: https://lore.kernel.org/all/20240923100741.11277439@bootlin.com/ [1] Signed-off-by: Herve Codina --- drivers/reset/reset-microchip-sparx5.c | 35 +++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/drivers/reset/reset-microchip-sparx5.c b/drivers/reset/reset-m= icrochip-sparx5.c index 636e85c388b0..48a62d5da78d 100644 --- a/drivers/reset/reset-microchip-sparx5.c +++ b/drivers/reset/reset-microchip-sparx5.c @@ -62,6 +62,28 @@ static const struct reset_control_ops sparx5_reset_ops = =3D { .reset =3D sparx5_reset_noop, }; =20 +static const struct regmap_config mchp_lan966x_syscon_regmap_config =3D { + .reg_bits =3D 32, + .val_bits =3D 32, + .reg_stride =3D 4, +}; + +static struct regmap *mchp_lan966x_syscon_to_regmap(struct device *dev, + struct device_node *syscon_np) +{ + struct regmap_config regmap_config =3D mchp_lan966x_syscon_regmap_config; + resource_size_t size; + void __iomem *base; + + base =3D devm_of_iomap(dev, syscon_np, 0, &size); + if (IS_ERR(base)) + return ERR_CAST(base); + + regmap_config.max_register =3D size - 4; + + return devm_regmap_init_mmio(dev, base, ®map_config); +} + static int mchp_sparx5_map_syscon(struct platform_device *pdev, char *name, struct regmap **target) { @@ -72,7 +94,18 @@ static int mchp_sparx5_map_syscon(struct platform_device= *pdev, char *name, syscon_np =3D of_parse_phandle(pdev->dev.of_node, name, 0); if (!syscon_np) return -ENODEV; - regmap =3D syscon_node_to_regmap(syscon_np); + + /* + * The syscon API doesn't support syscon device removal. + * When used in LAN966x PCI device, the cpu-syscon device needs to be + * removed when the PCI device is removed. + * In case of LAN966x, map the syscon device locally to support the + * device removal. + */ + if (of_device_is_compatible(pdev->dev.of_node, "microchip,lan966x-switch-= reset")) + regmap =3D mchp_lan966x_syscon_to_regmap(&pdev->dev, syscon_np); + else + regmap =3D syscon_node_to_regmap(syscon_np); of_node_put(syscon_np); if (IS_ERR(regmap)) { err =3D PTR_ERR(regmap); --=20 2.46.2