Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp646896lqs; Fri, 14 Jun 2024 00:59:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWtn8p2cm8qo4L95Qg54c+vLVemqMy0s+UMhU8rvAhGtXUhqPObrCfSqRGyfLzbZcRUkg2f+yR7KTGDQURoTrH3wW9Zs1DkZFkMWhCZuA== X-Google-Smtp-Source: AGHT+IHiL67G2EtmODhkp481Yy1mDA+tL0RbPsMd3jn62U9CLL2NffXmXkusitd0z+/2gdL86haj X-Received: by 2002:a05:6a20:2449:b0:1b1:f785:550b with SMTP id adf61e73a8af0-1bae823dc89mr2398119637.38.1718351979298; Fri, 14 Jun 2024 00:59:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718351979; cv=pass; d=google.com; s=arc-20160816; b=yfzWnhoba8fXZBowd0vxNyx169aENp46+RMPaZQ3lR4rh59PcW+UylVmjO3Q6DZRcQ xIG/8HR3P4kPrDSOsoHYg3cqv1FfId7pXP9XgFG2OJvuYNjrL+8AqvCEY5nRy8EJ3WOL ZiJ6RsVmGH+Fo1wMqt0QJSbKd7STXhW+E57jRXJx9L6C1mrAsbTrMXvKaBg6esbH2431 Cqoegqx1oGPQ1gSmD1EwXWjSsnSrfcdS0Qhdqtzq5FJQMR0/Y95cYaIqQtZLFMNSrQGU EVGB3ASa1T5bGswbzFce5zu2HxrGJvI1Wig2yhdLd4YgaZZhd2oYJKlU3bA9zdqFxUGF Qo8g== 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=s//OGJgaJgoUNu800H/ay+cdw1aPZZdMCMr1lDGdNsY=; fh=hlaO54Y51C9KJIZLtE98iv/ncrPmJ9RabI5lLtWETi8=; b=HhYXXF3lG9KNVOCVR5Z+TwA2z2yV2fr+WIn7+lhjluLw1WzYU+HIfbPJrl5snxrRuf ZdbBjjeWnTAldybN59TnDEbdaEu+vW3FJgrPV7Bp0aw4dDJ41rcn9Hz6lqN/+D3rc1J1 er0tp/5Y7Pb5925Xy18mzxj0nqq/y3JAvAyI/Y1a9BbJeCD6H7UyEpm1qbt4GXwnhLxV yeImnVGa982VkxM5VhxjaaDput7P0gOVcCCKdNa13LBmb2EKpdRjO7lTHypA2jNeb2nC pzFKXLRr0QfTu+BOfallkFQvKcl5qS3lfnZZGoY+H9P1Kups272SGfL8UvqH5DOi2/41 X8Jg==; 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-214491-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214491-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6fee67b8493si3233831a12.798.2024.06.14.00.59.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 00:59:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-214491-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::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-214491-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214491-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 8D48428200A for ; Fri, 14 Jun 2024 07:59:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EF80518411C; Fri, 14 Jun 2024 07:59:18 +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 A9E771836C7; Fri, 14 Jun 2024 07:59:16 +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=1718351958; cv=none; b=p/TD4FSVxpfogrwxrq69uGGq2bvczxM9PDs61Q5d6ngpptxkH1Bnvp8BdHzb+gwY8rHUttNchS6ZcQxbTVYAxn+AnIal0EKoqtPtY4baYejGGh05ULz1J8uGm1SKjwErRQRIluyG9+XXJn6Nu8ctJ5LAmpFei551rtfZFLmG0As= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718351958; c=relaxed/simple; bh=9WuykSLDvgrkD83NKcuDTuqiituZEcT1+6M80EnAUsk=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References; b=MhW4IIKMz0b/qNSE6OOy8qakwyrhr+IvMJvt29I+Zq2GCryG6W7p5dM0mHLhCsl5Qft+1gPcjyDTGHHKqcoySB0VBhEElzOcurMeHDSK3gUYKan3+mFBkYQhsQ3NvVBTRNQd6U1FP91Bn7QakgPVhEcVegf/PUwt3VN2yO14dvY= 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 33A57201714; Fri, 14 Jun 2024 09:59:09 +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 AAD57201712; Fri, 14 Jun 2024 09:59:08 +0200 (CEST) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by aprdc01srsp001v.ap-rdc01.nxp.com (Postfix) with ESMTP id DA5B41820F76; Fri, 14 Jun 2024 15:59:06 +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 v8 2/5] clk: imx: clk-audiomix: Add reset controller Date: Fri, 14 Jun 2024 15:42:00 +0800 Message-Id: <1718350923-21392-3-git-send-email-shengjiu.wang@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1718350923-21392-1-git-send-email-shengjiu.wang@nxp.com> References: <1718350923-21392-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: Audiomix block control can be a reset controller for Enhanced Audio Return Channel (EARC), which is one of modules in this audiomix subsystem. The reset controller is supported by the auxiliary device framework. Signed-off-by: Shengjiu Wang Reviewed-by: Frank Li --- drivers/clk/imx/Kconfig | 1 + drivers/clk/imx/clk-imx8mp-audiomix.c | 63 +++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/drivers/clk/imx/Kconfig b/drivers/clk/imx/Kconfig index 6da0fba68225..6ff6d934848a 100644 --- a/drivers/clk/imx/Kconfig +++ b/drivers/clk/imx/Kconfig @@ -81,6 +81,7 @@ config CLK_IMX8MP tristate "IMX8MP CCM Clock Driver" depends on ARCH_MXC || COMPILE_TEST select MXC_CLK + select AUXILIARY_BUS if RESET_CONTROLLER help Build the driver for i.MX8MP CCM Clock Driver diff --git a/drivers/clk/imx/clk-imx8mp-audiomix.c b/drivers/clk/imx/clk-imx8mp-audiomix.c index b381d6f784c8..517b1f88661b 100644 --- a/drivers/clk/imx/clk-imx8mp-audiomix.c +++ b/drivers/clk/imx/clk-imx8mp-audiomix.c @@ -5,6 +5,7 @@ * Copyright (C) 2022 Marek Vasut */ +#include #include #include #include @@ -13,6 +14,7 @@ #include #include #include +#include #include @@ -217,6 +219,63 @@ struct clk_imx8mp_audiomix_priv { struct clk_hw_onecell_data clk_data; }; +#if IS_ENABLED(CONFIG_RESET_CONTROLLER) + +static void clk_imx8mp_audiomix_reset_unregister_adev(void *_adev) +{ + struct auxiliary_device *adev = _adev; + + auxiliary_device_delete(adev); + auxiliary_device_uninit(adev); +} + +static void clk_imx8mp_audiomix_reset_adev_release(struct device *dev) +{ + struct auxiliary_device *adev = to_auxiliary_dev(dev); + + kfree(adev); +} + +static int clk_imx8mp_audiomix_reset_controller_register(struct device *dev, + struct clk_imx8mp_audiomix_priv *priv) +{ + struct auxiliary_device *adev __free(kfree) = NULL; + int ret; + + if (!of_property_present(dev->of_node, "#reset-cells")) + return 0; + + adev = kzalloc(sizeof(*adev), GFP_KERNEL); + if (!adev) + return -ENOMEM; + + adev->name = "reset"; + adev->dev.parent = dev; + adev->dev.release = clk_imx8mp_audiomix_reset_adev_release; + + ret = auxiliary_device_init(adev); + if (ret) + return ret; + + ret = auxiliary_device_add(adev); + if (ret) { + auxiliary_device_uninit(adev); + return ret; + } + + return devm_add_action_or_reset(dev, clk_imx8mp_audiomix_reset_unregister_adev, + no_free_ptr(adev)); +} + +#else /* !CONFIG_RESET_CONTROLLER */ + +static int clk_imx8mp_audiomix_reset_controller_register(struct clk_imx8mp_audiomix_priv *priv) +{ + return 0; +} + +#endif /* !CONFIG_RESET_CONTROLLER */ + static void clk_imx8mp_audiomix_save_restore(struct device *dev, bool save) { struct clk_imx8mp_audiomix_priv *priv = dev_get_drvdata(dev); @@ -337,6 +396,10 @@ static int clk_imx8mp_audiomix_probe(struct platform_device *pdev) if (ret) goto err_clk_register; + ret = clk_imx8mp_audiomix_reset_controller_register(dev, priv); + if (ret) + goto err_clk_register; + pm_runtime_put_sync(dev); return 0; -- 2.34.1