From patchwork Thu Oct 10 06:36:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herve Codina X-Patchwork-Id: 13829568 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) (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 BA5181B533F; Thu, 10 Oct 2024 06:36:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.197 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728542185; cv=none; b=PJDyoVhgHXlE8vnW3iDrJcJa4/1y2jYwThJ+bUTeqo3gG3Zecpuz2IO4qpugVf4SjtL5E2nA+Fipt55OnKGeBIOonxMXPbdRQIUK/QUEAJhYYB78joIY1xE6JBvI4B4YHmoZl0A2QtoGLMtFbctvnbzP86vzJePIICWIzJYjvQo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728542185; c=relaxed/simple; bh=+SVdKl1IWa/HJRCY4IavIoOe2teX0PV4vUDkok6B1lo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KpRQ3XYlZzHGveLJMvEkEvqwQ5uikL9uJFuhs9hc0e8lr2K7t02t06OinMzsO5dX78F3NnKVkV/lEZGKVY4JRT5O3E4yWfhf+WZaWA3tSMXp93jW4cCgey+Hgy+vZ7tE1N6UtcVCnnThgPAls8COqFNcNHqb0xWdETCVjWObmvI= 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=OHoRfRhX; arc=none smtp.client-ip=217.70.183.197 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="OHoRfRhX" Received: by mail.gandi.net (Postfix) with ESMTPA id 8025C1C0002; Thu, 10 Oct 2024 06:36:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1728542181; 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=dfuIYqw7th60ZTkt8Ycp++b+l5ZZV6kmbe9D3MS4HFQ=; b=OHoRfRhXY4aHRMqd/QxPPu0rhMN7W6kyD/O2jRTHAXimoGP3d0WjQCwS8PsWY9hvWUcVID w/I0Kb2BJG9sWyE8Dld10TGvLRqAa0xBtAqiLx+2nc8nwHRDRiJSGy+EPvG6iXoCKT3hIJ 2hSgN4+KHlzAIVq0nSv/yg60+Qgd+gboyOrpxUWp8u5yHIq/nrjNMqtmI0EBPqSiWcKW6q iKFLDO6HngyGcZpWoz5KoluLRa59TXGSdPBbanMCQdVwKphfr0PAjFi2lBjME1BvJjTY6N v9cDrGQ5liIp3ENPqbeiC30Pctv1s4eqgeoShOyaQePiV142EIVK0wXaBc86KQ== 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 v9 3/6] reset: mchp: sparx5: Map cpu-syscon locally in case of LAN966x Date: Thu, 10 Oct 2024 08:36:03 +0200 Message-ID: <20241010063611.788527-4-herve.codina@bootlin.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241010063611.788527-1-herve.codina@bootlin.com> References: <20241010063611.788527-1-herve.codina@bootlin.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: herve.codina@bootlin.com 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);