From patchwork Sun Sep 15 11:43:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurentiu Mihalcea X-Patchwork-Id: 13804778 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 31FA9C35FE4 for ; Sun, 15 Sep 2024 11:47:33 +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=AjYXEh+UbA9qfzH/UnBxzC6T1hiNz97xyypMsutGg+M=; b=Pq2Az3IIjFPDsebUIj2DC1kybw B6eZVlLtsMMyuRm7lDUqE1b32f1CPob5zadEzF6c5zTHiMhMvTo8t2fR2Pb+9v+5hRe2Cb381tbm+ LHKtYxLY+EOcPigc9skE3nA4F0n8DKmIrCz8GmHklbZDktJTuMBp6e1m8HPIQXSqZAmHqx0qb2zsk QMVV92ptXx9Y/5kAPAJsdZxsZNBjlX1Jz8/XXxFn6JkbVQOPYP2DsCPgolwsLJQaqMHl0g1BqRX5o FpqDMIk01nWI2Xjv7ZuMiB4VKRqV/aZ1kGdGNNTVMZhX/fzH9MLbqQHbxZVoTv7s+AgquEgUjyEvc O2kHU45w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1spnip-000000022bL-0h7a; Sun, 15 Sep 2024 11:47:19 +0000 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1spngb-000000022IA-03vD for linux-arm-kernel@lists.infradead.org; Sun, 15 Sep 2024 11:45:04 +0000 Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-5c42bd0386cso1637161a12.2 for ; Sun, 15 Sep 2024 04:45:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726400699; x=1727005499; 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=AjYXEh+UbA9qfzH/UnBxzC6T1hiNz97xyypMsutGg+M=; b=Y+305sE6sUYoLkqOMKTiLFAmFmCXx4qjchid2N1UhiplBs/Y337tch/MwAE+fk5HmS RIp/kuXOwFazKVjxmLj/3uef0bua/2pJGadBVMnkJELYgUi4uGXpCORqtRoJ8LZw4uVR bSHkbhtu1tJw6uNNgjJghpv5BhGmxx+JuGKvyQYiDRaLyB+knufT3WPfyVAbOIwbKUNa geFpBtW6OeHORhMRdwaUFvY47s4RMjfGnTbeXYJOIgA91agtHH/7OpqxQyCRpP02TS1d w9pU6vFlVYX93ECJvJLhPclrJWGypgN5S/aMl7/howU/o71oaf3I+1A2uGploLY4oqJL Rrsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726400699; x=1727005499; 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=AjYXEh+UbA9qfzH/UnBxzC6T1hiNz97xyypMsutGg+M=; b=kB+8ZMolkWISYEHXJ6C79STVjyXLlwqmOyKWzgFgRN3n21gzfflfr4wWiDvXmUgE71 VlbTTm1pZhdPibKG2WgSv7hpgNF9dYzFb3C5giyGOgRiDKtnGCREZeFmS+VyNCsGnMJA n6cFXyVoN6x0861dEA0bs3xoEjj1MEzcsIiInrtChIPQeKbsXc8CZ8JPE1FODknbUE2h 4ozVz4J443aM1Yrlvsv5kqVWrub4N9N3qGz8c/4tGwIre63+xw7nSm/qF8wI1wOc0Xq9 dLnckdPEQkSrz6F7y2sA5H3vQYBe2vGcNDRK3Z2pUvZHN3fxEk6+ha6qbL7vSoxqUzuj Tg7w== X-Forwarded-Encrypted: i=1; AJvYcCUBjtpBxYXB1aOxFBu7WYDQo4T4ywM4pwfsHs/xxJFfJowx1x7r8zCQWGVMyTgwPttt+xTgvcMPoZaU/mmR5+4U@lists.infradead.org X-Gm-Message-State: AOJu0Yyr39Rf8rXG9Ebj3JvQEFlpcryNfDJLb+KwGyUX3x8w+hmINOIT HuAqsOt8lHXL540ivtjLdcvReZO2tWo9f90HgjYfFMO9jWu5ZydufM50IHCs X-Google-Smtp-Source: AGHT+IHXk4ugJxOP+KLW8R2DhUn7YJ4NYahM5A6lar/YmFVgn0iuSPe4lDkcPU3xD/66jrRtBCfWkQ== X-Received: by 2002:a17:907:6096:b0:a8b:6ee7:ba26 with SMTP id a640c23a62f3a-a90294a88d5mr1357286266b.1.1726400699151; Sun, 15 Sep 2024 04:44:59 -0700 (PDT) Received: from playground.localdomain ([86.127.146.72]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a906109676esm188778266b.33.2024.09.15.04.44.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Sep 2024 04:44:58 -0700 (PDT) From: Laurentiu Mihalcea X-Google-Original-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 v4 2/3] reset: add driver for imx8ulp SIM reset controller Date: Sun, 15 Sep 2024 07:43:10 -0400 Message-Id: <20240915114311.75496-3-laurentiu.mihalcea@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240915114311.75496-1-laurentiu.mihalcea@nxp.com> References: <20240915114311.75496-1-laurentiu.mihalcea@nxp.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240915_044501_083868_69B0F80C X-CRM114-Status: GOOD ( 22.07 ) 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 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 Reviewed-by: Daniel Baluta --- 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 5484a65f66b9..492081354d03 100644 --- a/drivers/reset/Kconfig +++ b/drivers/reset/Kconfig @@ -113,6 +113,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 4411a2a124d7..38354e701811 100644 --- a/drivers/reset/Makefile +++ b/drivers/reset/Makefile @@ -16,6 +16,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");