From patchwork Thu Oct 3 08:16:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herve Codina X-Patchwork-Id: 13820788 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4326CCF856E for ; Thu, 3 Oct 2024 08:28:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=+XO2rdVBW0+y55QhuTmw+UBmQKbaRpvUUCjnyl07ovk=; b=H2wYKSTkswKRotNqAhp849FhFf lEsCnGCOk+1anDG5mie4rT2FuedZ97s2ydlZpl8sPBTYYFBfWb8+D+n2IHt63A8kmMWOgHvAzp7kh fqvvBUntQEsfNCADKVLldGhG2st6NQX7OV/WBLY/FtqfCLSqreeLsnWNZKAN1kEZd+4iN1NS2/O8D HbXlcnSIWgWPWMYSSBgmJ6WNiLbu/O9Arpm0lAuFC/Fy7FqeVrSXh/zliApdSAfDG5wDfTvKNyY8Y znLSlpFCAMmEbBRbkI2E9Qgv0iho8X9JriX5gPKO4oNu0oevlM5HiGMRPloujGe+ZBbT/Vhn2RYer +kb7HB6w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1swHC5-00000008YuG-3ppq; Thu, 03 Oct 2024 08:28:17 +0000 Received: from relay4-d.mail.gandi.net ([217.70.183.196]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1swH2A-00000008XCR-3ygx for linux-arm-kernel@lists.infradead.org; Thu, 03 Oct 2024 08:18:04 +0000 Received: by mail.gandi.net (Postfix) with ESMTPA id D3804E000E; Thu, 3 Oct 2024 08:17:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1727943481; 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=+XO2rdVBW0+y55QhuTmw+UBmQKbaRpvUUCjnyl07ovk=; b=UGIQ19O4IofDIsfRgORITtRTvILDQWzB8YL9s5ZvpS/z8J0kxq7SGsNx+oE96dtPkQFtM7 lkq9qkfg5kA1Lhnu34x8JXIDo6ReV9WYQxZJoPuT7zOu0lWwq8mIgYi7x73Cb2ZPPfSqGz 98D8umH+ziF72gZGlTvrY2rNcLdYltcD2ygnr1HW+CD5mmhnA8MCCWKdJ+lsifGPEpk5pt lPVhH+iTeT85nWhMEt3iRkK/6s4268mspvzHKB8dl+MAzYAIlMjJws/eXXGRKVdWiWGkXt v0ZTUUReRW0BvT2LemoQzyzFbpqQdbobbK81wGVh5qQMXzqNq2eTW8ob78oX7g== 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 v7 3/6] reset: mchp: sparx5: Map cpu-syscon locally in case of LAN966x Date: Thu, 3 Oct 2024 10:16:40 +0200 Message-ID: <20241003081647.642468-4-herve.codina@bootlin.com> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20241003081647.642468-1-herve.codina@bootlin.com> References: <20241003081647.642468-1-herve.codina@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: herve.codina@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241003_011803_285180_23332849 X-CRM114-Status: GOOD ( 18.63 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Reviewed-by: Steen Hegelund Reviewed-by: Philipp Zabel --- 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-microchip-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 = { .reset = sparx5_reset_noop, }; +static const struct regmap_config mchp_lan966x_syscon_regmap_config = { + .reg_bits = 32, + .val_bits = 32, + .reg_stride = 4, +}; + +static struct regmap *mchp_lan966x_syscon_to_regmap(struct device *dev, + struct device_node *syscon_np) +{ + struct regmap_config regmap_config = mchp_lan966x_syscon_regmap_config; + resource_size_t size; + void __iomem *base; + + base = devm_of_iomap(dev, syscon_np, 0, &size); + if (IS_ERR(base)) + return ERR_CAST(base); + + regmap_config.max_register = 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 = of_parse_phandle(pdev->dev.of_node, name, 0); if (!syscon_np) return -ENODEV; - regmap = 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 = mchp_lan966x_syscon_to_regmap(&pdev->dev, syscon_np); + else + regmap = syscon_node_to_regmap(syscon_np); of_node_put(syscon_np); if (IS_ERR(regmap)) { err = PTR_ERR(regmap);