Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp893776lqp; Thu, 23 May 2024 03:21:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXi4AUWWbgsvmYd4WpxTQZDpb8X3/NA8Y6eFfRLUb0kv+hJzmpDBnLA6+SwIaBnzPsUBYL58oRKfP6AVJqWNAk70i7AzGgwZSLvOM3A5w== X-Google-Smtp-Source: AGHT+IH+MH2ld/a/hpEbF7EdCmjJApdTXtDenXXVj5jHhVW+jcWn1eYYxzt+JF4kj2dAvns8NL93 X-Received: by 2002:a17:906:553:b0:a5c:dd61:9c4a with SMTP id a640c23a62f3a-a62280d52ebmr270022466b.19.1716459677181; Thu, 23 May 2024 03:21:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716459677; cv=pass; d=google.com; s=arc-20160816; b=BdB6dfVIFGjYECYVZpPOxSoYPqNL/6Cerfuukw1RuAdUDpuVz+gW6lBWI34V5s9mSN 9Ym0hzLrmowPqUnCZXRPR1EnrVfeadGo7kp9oupN5OEW8AECKbCwwucKBsYHvGPVfD30 MkYsEUBZYNGUmV/qZmpmlkTzEjuQ3XWDKXuBYwfZrOtNEqz6p75x6nblB6dYf+jjIC93 cBUP0eiXE/DTiSsbPDkT/bRSSm20agqliBh+lmjDX9StRSte6gQt758vu7jRv0IBmKUs LQ1eLkTegN6sSyKnsCrizAI/msjj2H6cE1QKBKhwrZpX4RefICY5W0vjfaCynIYSyNC6 NcMA== 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=j4Su6yld4ecA3Kpk93JupQc4RFWdngTluOPaH0ARQRc=; fh=yJG0a4sP0Py0VcRO0FoZ7y1L5tvgkoSbJk2nY3Z9ahc=; b=wDgkMCxhh2/BDP6OKWQ8vLH0gGbJ3x7KvrpDmn4z7++RgKurlvUfVptP9lfyeo79nN x4tm4V9xeMDIR3+XJ7A4LToD3TffnL0ZnM18T8+W8dOqe0kgMnNLjCY9vbENht7mk+P8 HsLkL3cbIk88vvmKZJLaprE8VhgmdY136FtwhKyklQScLAEyHuoMiFC/XQKfcKrkd2j0 G4ia0yf7KehLgT80J5ky92h/WjNZUGjvvYU4pwi20gioQ6bEMPCmi9gV9RMc1reKRJ2z 781gbcT/ek3CrMd8sOIVt+PsSIwfYfRYR4wgylLltzpNgz037r7VvB01cLzmse4igL7j I5NA==; 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-187325-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187325-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a17ba2e59si1618271866b.513.2024.05.23.03.21.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 03:21:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-187325-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; 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-187325-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187325-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 am.mirrors.kernel.org (Postfix) with ESMTPS id B8F9D1F23668 for ; Thu, 23 May 2024 10:21:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 13614149C74; Thu, 23 May 2024 10:20:16 +0000 (UTC) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) (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 296E01448DF; Thu, 23 May 2024 10:20:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=92.121.34.13 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716459615; cv=none; b=G/67QD8WasRZhK6F7xRbKkLlFJLII6Bn9gnBjb97F2UTWSrs9ts3G8aVWLMYUj6MNB2mLfICUgwlUY724rEHKRIBoahY8zb4+/K93v3NA/aKuwvKCWDVB9rN7uxYhOIWXD3QGVjmVPMeydeYEPI+xd3MrPBTqTaawMGT4oVF7LM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716459615; c=relaxed/simple; bh=BtdA1bi1vTKacSIQQRa3l8lJs/HiE9G2jj2f6iSfkCE=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References; b=cYtL/epCS+DxH6CnNGLtBrcaFTQB0xDFVWgVps/UJR/18StgbWbn1v1zMNOIRKddpsvHoxIesj66IiLXpjbK7XLZmydrOq49LGlqQvwe52dNyZw+vJK4l+lZZHY30GqPXjN5R6iobxHJ/ezjzunPwPNosgBQWMxB6S8tgrJUsqg= 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.13 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 inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id D9B101A141A; Thu, 23 May 2024 12:20:05 +0200 (CEST) Received: from aprdc01srsp001v.ap-rdc01.nxp.com (aprdc01srsp001v.ap-rdc01.nxp.com [165.114.16.16]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 514981A1269; Thu, 23 May 2024 12:20:05 +0200 (CEST) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by aprdc01srsp001v.ap-rdc01.nxp.com (Postfix) with ESMTP id 0515E180222C; Thu, 23 May 2024 18:20:02 +0800 (+08) From: Shengjiu Wang To: 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, p.zabel@pengutronix.de, shengjiu.wang@gmail.com Subject: [PATCH v5 2/5] clk: imx: clk-audiomix: Add reset controller Date: Thu, 23 May 2024 17:59:47 +0800 Message-Id: <1716458390-20120-3-git-send-email-shengjiu.wang@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1716458390-20120-1-git-send-email-shengjiu.wang@nxp.com> References: <1716458390-20120-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 --- drivers/clk/imx/Kconfig | 1 + drivers/clk/imx/clk-imx8mp-audiomix.c | 60 +++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/drivers/clk/imx/Kconfig b/drivers/clk/imx/Kconfig index 6da0fba68225..9edfb030bea9 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 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..2ee68f518850 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,60 @@ 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 __free(kfree) * adev = NULL; + int ret; + + 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 +393,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