Received: by 2002:ab2:6f44:0:b0:1fd:c486:4f03 with SMTP id l4csp111113lqq; Wed, 12 Jun 2024 19:09:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVWX/I7qAzjgTeA1raiQh0CAKmMQ6Muwq+xVQZd2h2lmQtbnSLgfY0UWo77IwPEM7gv4b+X47Amprr05ZK+NKQXmkf1H4Mu6h3vJttKlA== X-Google-Smtp-Source: AGHT+IFTCTd6C4hHMmNKFi8yvbRsSGR2+dyGLIs5F6hy5MdDkOJ14+iyy0PWmTYswgHeFqQcSyoD X-Received: by 2002:a05:6870:2045:b0:24f:c31a:5c29 with SMTP id 586e51a60fabf-25514ea1fe1mr3839139fac.43.1718244547680; Wed, 12 Jun 2024 19:09:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718244547; cv=pass; d=google.com; s=arc-20160816; b=TegQm6K4lLManCfJnRh5KhsJOKRZP7vfjBmyFj3aMsr+1lmzgGhtTGcJWm+Ym9rY+U lStF403OjBfIyLnlOJZCAQOqZoAKHvQKZo2wMqSpvvk6aaOvSvrKczdn7XL/jICZoeqx e6U1oNDcDUWug2YiJxI4k/8284zQrENTwWTSe41ZhTxS6LqwOkN76LQR3u5ZEz498wMh mi/3vC/dh+LP2GMcNWtjT/9VYxF/dVqc8Xzp5FALX9uQusAioHBoNFgh6WlukMjcna+d zeHuc5PMK4uisGq1t4WYTTFpGYXnESNL3sxi/DL9IJbma8Hy++LpX0dI5jaxQ2yKaXiM nAcQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:to:from; bh=eRvl7gU0c8l83UF1o/ocJeK5aoW5IXQCOhiPx2lQpM8=; fh=hlaO54Y51C9KJIZLtE98iv/ncrPmJ9RabI5lLtWETi8=; b=oUrfieMT9gmnnj2dknuw3NaS0hKYS7JFS6SHMdTkWoxiD3hadT5Ic8J2y1o+aia1VW JHktu54nOmgGm6ogh/twIqFWnoObtW1G/NwWwBL4ts5uVKc3AvHfXTxm8tc1eJ6/ja4l zUtVAFpew6CQpxHDraxltnippMgGQKoMHHv3516VIY+1UYthFv0SGzmvU4+UVnfXPCil 4XxlC43LVEjJ4qkO24qvyLYaVv3aZtJ5XHOQocnBkSa6p0bcLm4oYrXYugT8qSFP4D6v xP0WI9Xe9lSfm8mfhq1NN7HhX7wdggOi1tfF1uGehliMQadQTafLZO1HcTuR1qYLvowB SORw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel+bounces-212482-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212482-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d2e1a72fcca58-705ccb3e315si397470b3a.185.2024.06.12.19.09.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 19:09:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-212482-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel+bounces-212482-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212482-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 70BF3B219DC for ; Thu, 13 Jun 2024 02:08:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4797A12C466; Thu, 13 Jun 2024 02:08:10 +0000 (UTC) Received: from inva021.nxp.com (inva021.nxp.com [92.121.34.21]) (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 01A0582D6D; Thu, 13 Jun 2024 02:08:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=92.121.34.21 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718244489; cv=none; b=nM3L4RGNKQVSdquo1aDFdADVPQ+aAzS9S/IkT7CAm1G2R97yz0gZ2xPzV0jVrjyOXCUteXAbEFsCDGbqaLaYToCoi5xvCrTPCzXIlQqM/vJgL/iq/kGrcuCK9KHXw2N03uLkt6obi3ezJ7hEF6dMFvGocA/dW05UGIWf+W4J/TI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718244489; c=relaxed/simple; bh=YPgb+EPpvBCyCUn2T8yebqm7ABelOMAksMUoCilfuQE=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References; b=Iv/kpLTIduc34D43XmBiOX7/udHesCS2B7z/qlTmZ1uX8+Tbj6RM8+8ezxchb8JnmNByavdpVzx6X7xEeBGocCA+rMfjog/gMg7y4klSQ2bW0Z962Vnq1ntpVfPKqA9E7VCxSG2tGg6jfYlY6NNkO5bfp2Nq12sF26+/WyHcRX4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; arc=none smtp.client-ip=92.121.34.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 67BB22002A5; Thu, 13 Jun 2024 04:08:05 +0200 (CEST) Received: from aprdc01srsp001v.ap-rdc01.nxp.com (aprdc01srsp001v.ap-rdc01.nxp.com [165.114.16.16]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id BDA42201460; Thu, 13 Jun 2024 04:08:04 +0200 (CEST) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by aprdc01srsp001v.ap-rdc01.nxp.com (Postfix) with ESMTP id 65607181D0F9; Thu, 13 Jun 2024 10:08:02 +0800 (+08) From: Shengjiu Wang To: p.zabel@pengutronix.de, abelvesa@kernel.org, peng.fan@nxp.com, mturquette@baylibre.com, sboyd@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, marex@denx.de, linux-clk@vger.kernel.org, imx@lists.linux.dev, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, shengjiu.wang@gmail.com Subject: [PATCH v7 3/5] reset: imx8mp-audiomix: Add AudioMix Block Control reset driver Date: Thu, 13 Jun 2024 09:51:20 +0800 Message-Id: <1718243482-18552-4-git-send-email-shengjiu.wang@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1718243482-18552-1-git-send-email-shengjiu.wang@nxp.com> References: <1718243482-18552-1-git-send-email-shengjiu.wang@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Add support for the resets on i.MX8MP Audio Block Control module, which includes the EARC PHY software reset and EARC controller software reset. The reset controller is created using the auxiliary device framework and set up in the clock driver. Signed-off-by: Shengjiu Wang --- drivers/reset/Kconfig | 8 ++ drivers/reset/Makefile | 1 + drivers/reset/reset-imx8mp-audiomix.c | 103 ++++++++++++++++++++++++++ 3 files changed, 112 insertions(+) create mode 100644 drivers/reset/reset-imx8mp-audiomix.c diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig index 7112f5932609..b3c0e528d08c 100644 --- a/drivers/reset/Kconfig +++ b/drivers/reset/Kconfig @@ -91,6 +91,14 @@ config RESET_IMX7 help This enables the reset controller driver for i.MX7 SoCs. +config RESET_IMX8MP_AUDIOMIX + tristate "i.MX8MP AudioMix Reset Driver" + depends on CLK_IMX8MP + select AUXILIARY_BUS + default CLK_IMX8MP + help + This enables the reset controller driver for i.MX8MP AudioMix + 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 fd8b49fa46fc..a6796e83900b 100644 --- a/drivers/reset/Makefile +++ b/drivers/reset/Makefile @@ -14,6 +14,7 @@ obj-$(CONFIG_RESET_BRCMSTB_RESCAL) += reset-brcmstb-rescal.o 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_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-imx8mp-audiomix.c b/drivers/reset/reset-imx8mp-audiomix.c new file mode 100644 index 000000000000..f3f9f5420c14 --- /dev/null +++ b/drivers/reset/reset-imx8mp-audiomix.c @@ -0,0 +1,103 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright 2024 NXP + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define EARC 0x200 +#define EARC_RESET_MASK 0x3 + +struct imx8mp_audiomix_reset_priv { + struct reset_controller_dev rcdev; + void __iomem *base; +}; + +static int imx8mp_audiomix_reset_assert(struct reset_controller_dev *rcdev, + unsigned long id) +{ + struct imx8mp_audiomix_reset_priv *priv = container_of(rcdev, + struct imx8mp_audiomix_reset_priv, rcdev); + void __iomem *reg_addr = priv->base; + unsigned int mask, reg; + + if (id >= fls(EARC_RESET_MASK)) + return -EINVAL; + + mask = BIT(id); + reg = readl(reg_addr + EARC); + writel(reg & ~mask, reg_addr + EARC); + + return 0; +} + +static int imx8mp_audiomix_reset_deassert(struct reset_controller_dev *rcdev, + unsigned long id) +{ + struct imx8mp_audiomix_reset_priv *priv = container_of(rcdev, + struct imx8mp_audiomix_reset_priv, rcdev); + void __iomem *reg_addr = priv->base; + unsigned int mask, reg; + + if (id >= fls(EARC_RESET_MASK)) + return -EINVAL; + + mask = BIT(id); + reg = readl(reg_addr + EARC); + writel(reg | mask, reg_addr + EARC); + + return 0; +} + +static const struct reset_control_ops imx8mp_audiomix_reset_ops = { + .assert = imx8mp_audiomix_reset_assert, + .deassert = imx8mp_audiomix_reset_deassert, +}; + +static int imx8mp_audiomix_reset_probe(struct auxiliary_device *adev, + const struct auxiliary_device_id *id) +{ + struct imx8mp_audiomix_reset_priv *priv; + struct device *dev = &adev->dev; + + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + priv->rcdev.owner = THIS_MODULE; + priv->rcdev.nr_resets = fls(EARC_RESET_MASK); + priv->rcdev.ops = &imx8mp_audiomix_reset_ops; + priv->rcdev.of_node = dev->parent->of_node; + priv->rcdev.dev = dev; + priv->rcdev.of_reset_n_cells = 1; + priv->base = of_iomap(dev->parent->of_node, 0); + + return devm_reset_controller_register(dev, &priv->rcdev); +} + +static const struct auxiliary_device_id imx8mp_audiomix_reset_ids[] = { + { + .name = "clk_imx8mp_audiomix.reset", + }, + { } +}; +MODULE_DEVICE_TABLE(auxiliary, imx8mp_audiomix_reset_ids); + +static struct auxiliary_driver imx8mp_audiomix_reset_driver = { + .probe = imx8mp_audiomix_reset_probe, + .id_table = imx8mp_audiomix_reset_ids, +}; + +module_auxiliary_driver(imx8mp_audiomix_reset_driver); + +MODULE_AUTHOR("Shengjiu Wang "); +MODULE_DESCRIPTION("Freescale i.MX8MP Audio Block Controller reset driver"); +MODULE_LICENSE("GPL"); -- 2.34.1