From patchwork Tue Oct 8 07:48:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 13825886 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 CDE8FCED276 for ; Tue, 8 Oct 2024 07:53:08 +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:Cc:To:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=L0GhXAeo0piAQdGhAtPqSFGupduVbCpRmFqdHRYbqxQ=; b=yHeB1o+2kv3rEoYEAdzreW9RAe PTuOIPawxluatMM9nqQG9APtzL4vS+4nORMwKn+MTjEzfFH2UtWXypk1vpmSAgEM6w44KfuKVbm5p DRcB5XGDC7eXmjdJ0+wmchZliQH96MZAm4bw/lsyO+baKorQqBAcByKfZQc85G/hd8jV4D0PBUhFN bUFg2Vi+MHryyzxRp9ECc2LkLCTgo1QNp5wXMfLWvBAfOMIpObLdVFJNI+/iL/KUGAnhEAfLKi3+0 jZUT6oURCoKHjRNW45nHl1CHrxswLcBxSvSWWxM6SGGaWSNeYRguJFukfZ68yFi5uzJwO9KWmGTtS xKYgZxpw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sy51b-00000004sqQ-1hPG; Tue, 08 Oct 2024 07:52:55 +0000 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sy4xa-00000004rsd-3A7Y for linux-arm-kernel@lists.infradead.org; Tue, 08 Oct 2024 07:48:49 +0000 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-430558cddbeso887625e9.1 for ; Tue, 08 Oct 2024 00:48:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1728373725; x=1728978525; darn=lists.infradead.org; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=L0GhXAeo0piAQdGhAtPqSFGupduVbCpRmFqdHRYbqxQ=; b=hIj8YK4JRv/uG4GT1mXMeNDTuuZyOfPoF3EWCwRO5+m1NuwdrMm1Bo5J8iuXuBlNCE wkGTdvLdk+5Jqa/uawVIUGloEuXrIFnKZzOGTXyrp/qqPOdodXBGTy7gUgo3Ki+yXw12 59GvNL43on/4Yvhgpc9eBHKhot3qTIyEMT0ONu83i3yz4hg1A09jc6ywwhcIUYyjHPOw 0Beli7dPAWByqh25AMZfebJibGL8TBtnZA+6GasaVdTzkyXo+Wdzmf+pfPqO1ncNau33 NxaNOPqsSIzIypbr9EZueQOG9GsvwCJnozZ+DjqhdFC2e17U4PSBdOwZlZfcu8QU5E8E VXHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728373725; x=1728978525; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=L0GhXAeo0piAQdGhAtPqSFGupduVbCpRmFqdHRYbqxQ=; b=jA3xG5kySbH9UzDiAA1Q/3WVb7J1ZbFovbOaOCUJv3Gl2zOW8/HUXlMo7PfSq8MPPI Ao68zLAJDy01MFH8aVz0O/GP5uHfEoPAzLnTGS1w/1Mm11x4O8K7WHHcym0ZqQC52tBT Obx0FOVHdH3D2bYqgeY5XkVZgUXHU90OHXNF8CXn4WPpueBDcOFQInBpUaBXL1J9RPST HZ5XNhRYNm/tBszcay4nlMTlJhFIzk7GVfq9CD49JXn0bdcrf4OPMRiacJ+iQcoSvMBg ir/yk5cFVF0PH79HXb+tCtwucxDzCtzZvTGU1axvOwrey0frsr8vpNqpOzwPnvoTjkmM pVPQ== X-Forwarded-Encrypted: i=1; AJvYcCWZQOuElGRtqVPazboDnG7Gcwq8VY0WZ5drORXI4uxkWQKLTOvGMaaxcAH0bNrxH31SULBGF5FNL5wSKYwcl5Sc@lists.infradead.org X-Gm-Message-State: AOJu0YyNB0Z8iwF411//sO/uuZSCLKjU6WATQzbmSV2ggaNVYYVYGsUR s5Bkv957NFJryUUezxR+h3R2on2EQkqaSXxVDv5qIgZdXKoHRAhI5OhyCWIkq6vpFr7VQ5J//sS /flU= X-Google-Smtp-Source: AGHT+IHi0+ORDCyV5vkJi+PlJDdFKmgXiMW5ND6falmeeIdVKg0rgjsymhSWmT3meLpqvDkc2TtieA== X-Received: by 2002:a05:600c:4f02:b0:42c:b68f:38fb with SMTP id 5b1f17b1804b1-42f94bd941cmr13112065e9.7.1728373725142; Tue, 08 Oct 2024 00:48:45 -0700 (PDT) Received: from toaster.baylibre.com ([2a01:e0a:3c5:5fb1:41f2:4244:ce34:c273]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-4304efc0460sm11833055e9.1.2024.10.08.00.48.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 00:48:44 -0700 (PDT) From: Jerome Brunet Date: Tue, 08 Oct 2024 09:48:29 +0200 Subject: [PATCH v2] clk: amlogic: axg-audio: use the auxiliary reset driver MIME-Version: 1.0 Message-Id: <20241008-meson-clk-rst-aux-v2-1-682ab9151f4f@baylibre.com> X-B4-Tracking: v=1; b=H4sIAMzjBGcC/z3MTQ6CMBBA4auQrh0y5c+WlfcwLloYpAqtmYLBE O5u48Llt3hvF5HYURRttgumt4su+ITilIluNP5O4PpkUWBRSUQFM8XgoZuewHEBs25gpVQKNdV l34jUvZgGt/2e11vywGGGZWQy/xOepUZdaYl5qVVT1QgSHpZXT8vFms/kLFPehVkcxxdALdrwo wAAAA== To: Neil Armstrong , Michael Turquette , Stephen Boyd , Kevin Hilman , Martin Blumenstingl , Philipp Zabel Cc: linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Jerome Brunet X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=5861; i=jbrunet@baylibre.com; h=from:subject:message-id; bh=3sTokONfWb8mUVLZczdE/QoXyeWn/xlJxOAF+f4qk80=; b=owEBbQKS/ZANAwAKAeb8Dxw38tqFAcsmYgBnBOPbvk7E+qYQvsmYSjDEPjdmtXMmeOO+V7FmU s61xBYzSNSJAjMEAAEKAB0WIQT04VmuGPP1bV8btxvm/A8cN/LahQUCZwTj2wAKCRDm/A8cN/La hVQED/9wJX4zBrZTc5UHIO0D6Z/J2p5y4QHaNRkFznexo9UQBszkDSqvfhk7CbBB7XPALmPt65H V9klvoiHvntmz+MuqgeetdQNwzbGaRLj7vj1umcn6ysHwgrlX9Z/EXpMG6U+At0XJh6nHpDevrZ BIu78CVR2yyy6XzHCfAWtYDaQbcPjNW5kyob6kvjUQLjCa71NAC3KX9SoDXbRwvzvEo2JGgqiQE /tKoc2T6hrBKMTCMrW+k5Eu57LdvefSGGjQaeJaIxd9dA/QXBr+Yg8dx0we+vZYRQmycY/ujpjS P4ybmmMF7qMGjI78eSZ1UuYT9WF+twM7QdgUsnlb5C5wjaoAstXCkirr6NBy5dV5hEj36+sYZeg W7iwSvtH47yPLe4bPHdyY7Kum7Hfpo5xQ8xA/5MICTP6w4RQYyZVYNpA6zvOIpp81748JIe3bFO lN6bMCgEJyPB0FcNs1UTjs5Q0e7lTZdfByE/pfx4ZeQIwqZFFOQNsTiqqQfiCczOO/6SGYipzFD A6SOd9PR1cpvMLJKcEVGsAk+EUybLKeXcydN6RooZiElyk3vkaWIvAyzPRPQchQ6sFObQM1iOOu qvybg0d4FDBksLTOnzpqvk5m4JDrCgPxay8YPmLBMRaj/Ruw2vMNDJ9slGDE8Lq1qwAQmmGyIRw vAv/PI8qC9eh5wA== X-Developer-Key: i=jbrunet@baylibre.com; a=openpgp; fpr=F29F26CF27BAE1A9719AE6BDC3C92AAF3E60AED9 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241008_004847_087527_D8EC99B2 X-CRM114-Status: GOOD ( 19.49 ) 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 Remove the implementation of the reset driver in axg audio clock driver and migrate to the one provided by the reset framework on the auxiliary bus Signed-off-by: Jerome Brunet Reviewed-by: Neil Armstrong --- Change in v2: * Rebase on the applied version of amlogic auxiliary reset driver * Link to v1: https://lore.kernel.org/r/20240719094910.3986450-1-jbrunet@baylibre.com --- drivers/clk/meson/Kconfig | 1 + drivers/clk/meson/axg-audio.c | 109 ++++-------------------------------------- 2 files changed, 10 insertions(+), 100 deletions(-) --- base-commit: 0e2d37252dd525b117bda4e4e0e6fac178ba569d change-id: 20241008-meson-clk-rst-aux-b118809e53d6 Best regards, diff --git a/drivers/clk/meson/Kconfig b/drivers/clk/meson/Kconfig index 78f648c9c97d..7cb21fc223b0 100644 --- a/drivers/clk/meson/Kconfig +++ b/drivers/clk/meson/Kconfig @@ -106,6 +106,7 @@ config COMMON_CLK_AXG_AUDIO select COMMON_CLK_MESON_SCLK_DIV select COMMON_CLK_MESON_CLKC_UTILS select REGMAP_MMIO + imply RESET_MESON_AUX help Support for the audio clock controller on AmLogic A113D devices, aka axg, Say Y if you want audio subsystem to work. diff --git a/drivers/clk/meson/axg-audio.c b/drivers/clk/meson/axg-audio.c index beda86349389..7714bde5ffc0 100644 --- a/drivers/clk/meson/axg-audio.c +++ b/drivers/clk/meson/axg-audio.c @@ -15,6 +15,8 @@ #include #include +#include + #include "meson-clkc-utils.h" #include "axg-audio.h" #include "clk-regmap.h" @@ -1678,84 +1680,6 @@ static struct clk_regmap *const sm1_clk_regmaps[] = { &sm1_earcrx_dmac_clk, }; -struct axg_audio_reset_data { - struct reset_controller_dev rstc; - struct regmap *map; - unsigned int offset; -}; - -static void axg_audio_reset_reg_and_bit(struct axg_audio_reset_data *rst, - unsigned long id, - unsigned int *reg, - unsigned int *bit) -{ - unsigned int stride = regmap_get_reg_stride(rst->map); - - *reg = (id / (stride * BITS_PER_BYTE)) * stride; - *reg += rst->offset; - *bit = id % (stride * BITS_PER_BYTE); -} - -static int axg_audio_reset_update(struct reset_controller_dev *rcdev, - unsigned long id, bool assert) -{ - struct axg_audio_reset_data *rst = - container_of(rcdev, struct axg_audio_reset_data, rstc); - unsigned int offset, bit; - - axg_audio_reset_reg_and_bit(rst, id, &offset, &bit); - - regmap_update_bits(rst->map, offset, BIT(bit), - assert ? BIT(bit) : 0); - - return 0; -} - -static int axg_audio_reset_status(struct reset_controller_dev *rcdev, - unsigned long id) -{ - struct axg_audio_reset_data *rst = - container_of(rcdev, struct axg_audio_reset_data, rstc); - unsigned int val, offset, bit; - - axg_audio_reset_reg_and_bit(rst, id, &offset, &bit); - - regmap_read(rst->map, offset, &val); - - return !!(val & BIT(bit)); -} - -static int axg_audio_reset_assert(struct reset_controller_dev *rcdev, - unsigned long id) -{ - return axg_audio_reset_update(rcdev, id, true); -} - -static int axg_audio_reset_deassert(struct reset_controller_dev *rcdev, - unsigned long id) -{ - return axg_audio_reset_update(rcdev, id, false); -} - -static int axg_audio_reset_toggle(struct reset_controller_dev *rcdev, - unsigned long id) -{ - int ret; - - ret = axg_audio_reset_assert(rcdev, id); - if (ret) - return ret; - - return axg_audio_reset_deassert(rcdev, id); -} - -static const struct reset_control_ops axg_audio_rstc_ops = { - .assert = axg_audio_reset_assert, - .deassert = axg_audio_reset_deassert, - .reset = axg_audio_reset_toggle, - .status = axg_audio_reset_status, -}; - static struct regmap_config axg_audio_regmap_cfg = { .reg_bits = 32, .val_bits = 32, @@ -1766,16 +1690,14 @@ struct audioclk_data { struct clk_regmap *const *regmap_clks; unsigned int regmap_clk_num; struct meson_clk_hw_data hw_clks; - unsigned int reset_offset; - unsigned int reset_num; unsigned int max_register; + const char *rst_drvname; }; static int axg_audio_clkc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; const struct audioclk_data *data; - struct axg_audio_reset_data *rst; struct regmap *map; void __iomem *regs; struct clk_hw *hw; @@ -1834,22 +1756,11 @@ static int axg_audio_clkc_probe(struct platform_device *pdev) if (ret) return ret; - /* Stop here if there is no reset */ - if (!data->reset_num) - return 0; - - rst = devm_kzalloc(dev, sizeof(*rst), GFP_KERNEL); - if (!rst) - return -ENOMEM; - - rst->map = map; - rst->offset = data->reset_offset; - rst->rstc.nr_resets = data->reset_num; - rst->rstc.ops = &axg_audio_rstc_ops; - rst->rstc.of_node = dev->of_node; - rst->rstc.owner = THIS_MODULE; + /* Register auxiliary reset driver when applicable */ + if (data->rst_drvname) + ret = devm_meson_rst_aux_register(dev, map, data->rst_drvname); - return devm_reset_controller_register(dev, &rst->rstc); + return ret; } static const struct audioclk_data axg_audioclk_data = { @@ -1869,9 +1780,8 @@ static const struct audioclk_data g12a_audioclk_data = { .hws = g12a_audio_hw_clks, .num = ARRAY_SIZE(g12a_audio_hw_clks), }, - .reset_offset = AUDIO_SW_RESET, - .reset_num = 26, .max_register = AUDIO_CLK_SPDIFOUT_B_CTRL, + .rst_drvname = "rst-g12a", }; static const struct audioclk_data sm1_audioclk_data = { @@ -1881,9 +1791,8 @@ static const struct audioclk_data sm1_audioclk_data = { .hws = sm1_audio_hw_clks, .num = ARRAY_SIZE(sm1_audio_hw_clks), }, - .reset_offset = AUDIO_SM1_SW_RESET0, - .reset_num = 39, .max_register = AUDIO_EARCRX_DMAC_CLK_CTRL, + .rst_drvname = "rst-sm1", }; static const struct of_device_id clkc_match_table[] = {