From patchwork Mon Jul 15 16:45:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurentiu Mihalcea X-Patchwork-Id: 13733660 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 F138BC3DA59 for ; Mon, 15 Jul 2024 16:47:43 +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=Jh6JZ+1LYv7M2Ni3seuv4GEQ7MYtjKnioH0Jix8Ipz0=; b=cpBnOEZSCy45i2VixNGbS1W9n2 pSVPlVcfFjWL/gONh5GNrhju4ndH7ni8xvsqvqibtQehEK7bWkjBB4jlD8XvnEzFsRLd7LY9Bnwhe /E4s0dziew2smsPnWz/8KYFzEBRO9ApYOLNZAVNriBhqjPDfqTmq2ZwOB58ddIvTMejo71SxScESa 9TdLCt6VlCuItkOfRJ5Z7GLIZWSP7jiQ0mf3luaUKJRSYLThD5EWTlC615ozysY4ZaOkzMpwwtw22 6Uc6HFwmqov2naK9+XR0l3A0KOqQ+dZWPXE9qowxBnvVtP4c01edwlEbtMAhdv9QLgTXiMHxXWKWG HlsW41Ow==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTOrN-00000007mW5-2Hwo; Mon, 15 Jul 2024 16:47:33 +0000 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTOqb-00000007mDf-1vin for linux-arm-kernel@lists.infradead.org; Mon, 15 Jul 2024 16:46:47 +0000 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-4266182a9d7so28687135e9.0 for ; Mon, 15 Jul 2024 09:46:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721062003; x=1721666803; darn=lists.infradead.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=Jh6JZ+1LYv7M2Ni3seuv4GEQ7MYtjKnioH0Jix8Ipz0=; b=ZD17uspgt7L+qfNuYfslR+BW9UNx4yDp3X9wAqe5o9EWfnk1i8JJiVflInFuY8xQkU oOIjOa4ZdP0UDMgo6oY0V6RfvVARHdAPk+9hwDoIajGAm6zTwzGe7k9N9kdGmtGHTnR+ tW9U9eYLPTcCn49GIOS94e+50OPKyoC9Sru9RsUC/clZt1+w30o4JT58jaFE8zD8NExw FmMhF6ppKYKk4/VB9wDDITvY41CatpJ23Pt/ZkIkbvAuYtFS6PLYEDQfKsSaxvj02hvX VA2DvR7a/fJsb2NtFEGsEtoTz0dpiKmx9s1qvXbc625yERWudMuRSsrEqZYJRtC2mm/E P3+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721062003; x=1721666803; 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=Jh6JZ+1LYv7M2Ni3seuv4GEQ7MYtjKnioH0Jix8Ipz0=; b=fwCSonrSugPq4zAK9fz6SEVL85J/0KpPcPg0hjiahtfENE/KIEpttGO3mTBYE8SBEM +eVTFzcwEzHyUMsoF8gIuInnwXtWQCVbqFPjHa3XRi1VNtaXJegzPPS90qF0wkp+Tng8 aJHuD6wx+S6xb35vOYUss76DWLvRUHTuN43ksDgvu72XyvTF8h7zMm17ZCvckAR1am21 54LDpqgmmL9zlkuFuwxp4WaQKkOf9yyGeaya23XpyVpQlhUSxBdV2AuyfqAs9Xkye6tY CNJ6gZ3T6jk6nsBCaoK5A7adk3dLEhJaH0EBD1GgRbt/an/lVzNSPpAVH9fF4jJA4rQr OzAA== X-Forwarded-Encrypted: i=1; AJvYcCXk5nt1OLFcBt2ytFFFp3sish7wQG5p/0Br+JIo/eRkjY2WujjE1XqEs42eIvpVUM+0klboiKuDlLGaBwg4AxSENH2yXjvOWp436WYXLsno2/+gxpM= X-Gm-Message-State: AOJu0YwgcVlYZILQ2vhUyZ0Zq08KKWPcqPSqzeAyGBqmgSDfrUPFhtob XqMFd1SvivCNK6JSWm0ShgNJ8zoTLmrZvzh+CDywpNH+EXpwE2ja X-Google-Smtp-Source: AGHT+IEr6cCHa9wTd0C+ds1nssosgD28+7x4wtLWpAatjKXHXE7WHF1w1QpLnGh9WYZlFn6Fb/QL9g== X-Received: by 2002:a05:600c:1911:b0:426:5dd0:a1fc with SMTP id 5b1f17b1804b1-427b88d00f5mr1337135e9.34.1721062003548; Mon, 15 Jul 2024 09:46:43 -0700 (PDT) Received: from playground.localdomain ([188.25.209.252]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427a5e7749esm94316975e9.2.2024.07.15.09.46.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jul 2024 09:46:43 -0700 (PDT) From: Laurentiu Mihalcea To: Rob Herring , Krzysztof Kozlowski , Shawn Guo , Philipp Zabel , Liu Ying , Sascha Hauer , Conor Dooley Cc: devicetree@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/3] reset: add driver for imx8ulp SIM reset controller Date: Mon, 15 Jul 2024 12:45:13 -0400 Message-Id: <20240715164514.8718-3-laurentiumihalcea111@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240715164514.8718-1-laurentiumihalcea111@gmail.com> References: <20240715164514.8718-1-laurentiumihalcea111@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240715_094645_638624_AED75E9E X-CRM114-Status: GOOD ( 21.92 ) 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 From: Laurentiu Mihalcea Certain components can be reset via the SIM module. Add reset controller driver for the SIM module to allow drivers for said components to control the reset signal(s). Signed-off-by: Liu Ying Signed-off-by: Laurentiu Mihalcea --- drivers/reset/Kconfig | 7 ++ drivers/reset/Makefile | 1 + drivers/reset/reset-imx8ulp-sim.c | 106 ++++++++++++++++++++++++++++++ 3 files changed, 114 insertions(+) create mode 100644 drivers/reset/reset-imx8ulp-sim.c diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig index 67bce340a87e..8e9cbf2859d6 100644 --- a/drivers/reset/Kconfig +++ b/drivers/reset/Kconfig @@ -100,6 +100,13 @@ config RESET_IMX8MP_AUDIOMIX help This enables the reset controller driver for i.MX8MP AudioMix +config RESET_IMX8ULP_SIM + tristate "i.MX8ULP SIM Reset Driver" + depends on ARCH_MXC + help + This enables the SIM (System Integration Module) reset driver + for i.MX8ULP SoC. + config RESET_INTEL_GW bool "Intel Reset Controller Driver" depends on X86 || COMPILE_TEST diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile index 27b0bbdfcc04..685e08982283 100644 --- a/drivers/reset/Makefile +++ b/drivers/reset/Makefile @@ -15,6 +15,7 @@ obj-$(CONFIG_RESET_GPIO) += reset-gpio.o obj-$(CONFIG_RESET_HSDK) += reset-hsdk.o obj-$(CONFIG_RESET_IMX7) += reset-imx7.o obj-$(CONFIG_RESET_IMX8MP_AUDIOMIX) += reset-imx8mp-audiomix.o +obj-$(CONFIG_RESET_IMX8ULP_SIM) += reset-imx8ulp-sim.o obj-$(CONFIG_RESET_INTEL_GW) += reset-intel-gw.o obj-$(CONFIG_RESET_K210) += reset-k210.o obj-$(CONFIG_RESET_LANTIQ) += reset-lantiq.o diff --git a/drivers/reset/reset-imx8ulp-sim.c b/drivers/reset/reset-imx8ulp-sim.c new file mode 100644 index 000000000000..04ff11d41e10 --- /dev/null +++ b/drivers/reset/reset-imx8ulp-sim.c @@ -0,0 +1,106 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/* + * Copyright 2024 NXP + */ + +#include +#include +#include +#include +#include +#include +#include + +#define IMX8ULP_SIM_RESET_MIPI_DSI_RST_DPI_N 0 +#define IMX8ULP_SIM_RESET_MIPI_DSI_RST_ESC_N 1 +#define IMX8ULP_SIM_RESET_MIPI_DSI_RST_BYTE_N 2 + +#define IMX8ULP_SIM_RESET_NUM 3 + +#define AVD_SIM_SYSCTRL0 0x8 + +struct imx8ulp_sim_reset { + struct reset_controller_dev rcdev; + struct regmap *regmap; +}; + +static const u32 imx8ulp_sim_reset_bits[IMX8ULP_SIM_RESET_NUM] = { + [IMX8ULP_SIM_RESET_MIPI_DSI_RST_DPI_N] = BIT(3), + [IMX8ULP_SIM_RESET_MIPI_DSI_RST_ESC_N] = BIT(4), + [IMX8ULP_SIM_RESET_MIPI_DSI_RST_BYTE_N] = BIT(5), +}; + +static inline struct imx8ulp_sim_reset * +to_imx8ulp_sim_reset(struct reset_controller_dev *rcdev) +{ + return container_of(rcdev, struct imx8ulp_sim_reset, rcdev); +} + +static int imx8ulp_sim_reset_assert(struct reset_controller_dev *rcdev, + unsigned long id) +{ + struct imx8ulp_sim_reset *simr = to_imx8ulp_sim_reset(rcdev); + const u32 bit = imx8ulp_sim_reset_bits[id]; + + return regmap_update_bits(simr->regmap, AVD_SIM_SYSCTRL0, bit, 0); +} + +static int imx8ulp_sim_reset_deassert(struct reset_controller_dev *rcdev, + unsigned long id) +{ + struct imx8ulp_sim_reset *simr = to_imx8ulp_sim_reset(rcdev); + const u32 bit = imx8ulp_sim_reset_bits[id]; + + return regmap_update_bits(simr->regmap, AVD_SIM_SYSCTRL0, bit, bit); +} + +static const struct reset_control_ops imx8ulp_sim_reset_ops = { + .assert = imx8ulp_sim_reset_assert, + .deassert = imx8ulp_sim_reset_deassert, +}; + +static const struct of_device_id imx8ulp_sim_reset_dt_ids[] = { + { .compatible = "nxp,imx8ulp-avd-sim-reset", }, + { /* sentinel */ }, +}; + +static int imx8ulp_sim_reset_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct imx8ulp_sim_reset *simr; + int ret; + + simr = devm_kzalloc(dev, sizeof(*simr), GFP_KERNEL); + if (!simr) + return -ENOMEM; + + simr->regmap = syscon_node_to_regmap(dev->of_node); + if (IS_ERR(simr->regmap)) + return dev_err_probe(&pdev->dev, PTR_ERR(simr->regmap), + "failed to get regmap\n"); + + simr->rcdev.owner = THIS_MODULE; + simr->rcdev.nr_resets = IMX8ULP_SIM_RESET_NUM; + simr->rcdev.ops = &imx8ulp_sim_reset_ops; + simr->rcdev.of_node = dev->of_node; + + ret = devm_of_platform_populate(dev); + if (ret) + return ret; + + return devm_reset_controller_register(dev, &simr->rcdev); +} + +static struct platform_driver imx8ulp_sim_reset_driver = { + .probe = imx8ulp_sim_reset_probe, + .driver = { + .name = KBUILD_MODNAME, + .of_match_table = imx8ulp_sim_reset_dt_ids, + }, +}; +module_platform_driver(imx8ulp_sim_reset_driver); + +MODULE_AUTHOR("Liu Ying "); +MODULE_DESCRIPTION("NXP i.MX8ULP System Integration Module Reset driver"); +MODULE_LICENSE("GPL");