From patchwork Tue Feb 11 17:28:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 13970404 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DB96F267B61 for ; Tue, 11 Feb 2025 17:28:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739294925; cv=none; b=OHLF8AA2fRoq0GWEAziXOfGqwHBO55ymhYr7n5MitW1pvvTp0614xu1clb8xVhmhQvvMfic4AYDojMAturCKHrGoXsE1tF+rr4A4+4cf7Q+axctmenMO5nOs0CYTsqMNQ5nml8kFZc9g69z3XQF/UYju1iSwbLWIvw0TZg1vm+I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739294925; c=relaxed/simple; bh=gtTXUBCRQBXsYqOe/++F6w9kWmBkT08mx5TkDgNzKIs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KkgWg+x/0bu43ymtOQdBgc4LsRcSbqosP+adAvG/39f1TPKlN+Hw8vM7oh8KIRKdR8mz41kc1JG49H1y9FLma/fgpuKensjm+oqhmgqIFoSJ6XeIEeTPZXVaR7a8unJ4G/BJUqmI5+dd0KHnm3E1bWVnOPsuZHPN3zB9P7JkxeU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=Bf5vE+q+; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="Bf5vE+q+" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-43948021a45so21175145e9.1 for ; Tue, 11 Feb 2025 09:28:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1739294921; x=1739899721; darn=vger.kernel.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=kX3ghmSADof/fdYKGzDtB/q8+rQu9IUcD4dmFIXduMs=; b=Bf5vE+q+TaB9apdWcW0z7yfuxvW2t8JRMueh6XaLnzbghBrKyPFI485w9QZiXbviZ/ gMrT3wj0tEUFTBw7rsDs/g5G+Rhfu2U3hpz2X0XtgGWwNtEAOeSCi/74YBaH16j0otxW CqbLVIJMDqmzGbYKFOS5tBQieA0OQfVn3BZRff3MdzO2rvvxL9ZXg3sUxE3DnGNn3IHq cygNpCA1IKKWFf4zzl87yRT6puon0vHdZDtnotxNYp8zqjYk+ZFH1l+auFQILOQV8g0K fwiT1dGSosjTKZ381zcU6/Xj3ARxJL7d86gqoAAFlIUvNo7Z1McIKDD8JRiRmm5AE2jQ JlWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739294921; x=1739899721; 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=kX3ghmSADof/fdYKGzDtB/q8+rQu9IUcD4dmFIXduMs=; b=BE8iIth8ZzEN++VyBYAt9jsce5Rg7ldKO+CqQfBkrxzUpPnDOtY6YgEkJanQEB26rJ m2wjXcs2w0LiZgQwr46yfK30DhTD+lDTGpc8ERxfyGOHu3avJvZTUR1jVmdG2su49tB2 GtvPVj45Cb+dXzYWaiN+lq3q337I8cetsFvVXFsbiKoHMhARb1l1WOf0LXu7UupxImDQ pCSklEx0pPAkttdvPmhSsu9/HtqsNWc9JeQ16IGPIGXs8yqCl+s1Isa/bWKWlNgXZe0b iMFAmQCsniwhc1JIf4fAChonihm6GZZSG7yB7EWOzccVdUwsFUjoJ4agytVa28UEXN2M r2dg== X-Forwarded-Encrypted: i=1; AJvYcCUtsN8tZ8xmGxMc8hEQaMOniyxYyONb5NRJEuaWkpSGO8JS/y2qdr5rs9SgoP49wj7sr8C+TnQC4Uw=@vger.kernel.org X-Gm-Message-State: AOJu0YxWn9Ate51JO/bE5y3unA7uy8RJvju4G/lwssGeugrBBGZtZIdg qrcM6IXy7w8ygX1TM1de75MyIWeWOxc3kzP+aXzBWpIXUWn9gXudO/R+qyj92Fk= X-Gm-Gg: ASbGncsYaF0bdq8dNHTA8Vi6xdcfH+9d43VQ2gZmbIDpraLE0ai4ngzNiwGUEcl5d3q gQGnGh+lJL6s7yNxuE66CC9bXMc6aI+WU+jwltNTIYRaUv4O4M8ZjRtPuoExdiR1/n3mSgkgPX+ JUPNJky078tOavzXtvhbOCCpX1U6AukhMd/SQ8oEmatjKWSR5UuZtRXbk4NgH0BaU2JCBrrS79k zE9Z8ljKb0ClSpPSkPPYy+9COkqHLAbcZyR4Ah70lTWZyN/lm5x0lRN1VW67bNsk6d9QbqWVjxv wZe9y5ajzE5YUHVEOg== X-Google-Smtp-Source: AGHT+IHNZKomgYXqcV4iueNtMWjdqrJCqK18R/l4YoIndkgvWwENIn/juV5TQLvLjyHtq/y8uwbzbg== X-Received: by 2002:a05:6000:154d:b0:38d:e481:c680 with SMTP id ffacd0b85a97d-38de481c6d6mr3134750f8f.18.1739294921265; Tue, 11 Feb 2025 09:28:41 -0800 (PST) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:fc0c:6c04:7ae0:c5c2]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-38dc6c80df2sm13691082f8f.18.2025.02.11.09.28.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Feb 2025 09:28:40 -0800 (PST) From: Jerome Brunet To: Greg Kroah-Hartman , Dave Ertman , Ira Weiny , "Rafael J. Wysocki" , Stephen Boyd , Arnd Bergmann , Danilo Krummrich , Conor Dooley , Daire McNamara , Philipp Zabel , Douglas Anderson , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Bryan O'Donoghue , Vladimir Kondratiev , Gregory CLEMENT , =?utf-8?q?Th=C3=A9o_Lebrun?= , Michael Turquette , Abel Vesa , Peng Fan , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Kevin Hilman , Martin Blumenstingl Cc: Jerome Brunet , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, dri-devel@lists.freedesktop.org, platform-driver-x86@vger.kernel.org, linux-mips@vger.kernel.org, linux-clk@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org Subject: [PATCH v3 7/7] clk: amlogic: axg-audio: use the auxiliary reset driver - take 2 Date: Tue, 11 Feb 2025 18:28:04 +0100 Message-ID: <20250211-aux-device-create-helper-v3-7-7edb50524909@baylibre.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250211-aux-device-create-helper-v3-0-7edb50524909@baylibre.com> References: <20250211-aux-device-create-helper-v3-0-7edb50524909@baylibre.com> Precedence: bulk X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=5921; i=jbrunet@baylibre.com; h=from:subject:message-id; bh=TI3PyQ4RBlsYvn/3ym2zOR51oxwz92ZVC/TIhelLgEk=; b=owEBbQKS/ZANAwAKAeb8Dxw38tqFAcsmYgBnq4g7rK2qbvDSMWo7y7IKYVc4VNag+NKBkBwBX 7AivAacwaKJAjMEAAEKAB0WIQT04VmuGPP1bV8btxvm/A8cN/LahQUCZ6uIOwAKCRDm/A8cN/La hbzVD/0aQSeKG38/WN0LzdAbQTHjP8c2dJCCutKqih2e3zHr0RKjaYamy5oVuPOh498VVAmF9cn JeAalYPQoR3MZ8oiPIpwNYFmdLz9SdTLYUF+PKdNWbORrKgBWRKu2ivLUtegcvaJUMhHO5Ix5bG CrQz74Dt9ScsD6/j3QRGph2BODHh8TbsywwrMIS5K/urLzgDSwanjOPXFfQzQfbJMYU09h3YUDs e3xEkGsqD9aIqFiYJHTVPTMJ/+vbqp334Lqc9hnPqgNJcOoDO193NJiXYa1yVU95vo/72i38MBq 3crANEecIqg7ti6Gz60LNk2WTZAFJ3gZqhxhQr/imfzRiZ7siLD3ZjmPJPZ1b4owNJscGsqQG2/ PswDJyFP788jPnd1LdniQrVQWuYG5yUzBu7jJyinlYAY+MgUcgelAC9bt7VKJNydWJLWbheq1O1 JVY2z1C35EIyV8hU1Gd4eAUofbzasGlOz8CjvwQrMAv+ip84NLLoqzvnvJGgRFm1igRtkHWw96X oHd1iR7mYoTUtOPuC+NQWLoZ7FhdSXsAbCawy/ai4kYIx0SwT/S8WQV+WfxcSxkir99fqoEjLso XAYvea00nIRJBgjfT5Kl03ruc1yRSK0CM6ZpO6eN7w1Kf14T+sfeD13r5XgO16wfSNJVWGktDas GH37TQ7hJz+6o9g== X-Developer-Key: i=jbrunet@baylibre.com; a=openpgp; fpr=F29F26CF27BAE1A9719AE6BDC3C92AAF3E60AED9 Remove the implementation of the reset driver in axg audio clock driver and migrate to the one provided by reset framework on the auxiliary bus. Signed-off-by: Jerome Brunet --- There has been a discussion about the use on imply here. After re-reading the documentation I've sticked with imply in this version: > This is useful e.g. with multiple drivers that want to indicate their > ability to hook into a secondary subsystem while allowing the user to > configure that subsystem out without also having to unset these drivers. IMO, this is a pretty accurate description of the use case in this change. The pitfall mentioned in the doc does not apply as there is not link error regardless of the config of RESET_MESON_AUX. I also think this is more readeable and maintainable than a bunch of 'default CONFIG_FOO if CONFIG_FOO' for CONFIG_RESET_MESON_AUX. This approach also would have several pitfall, such as picking the value of the first config set or the config of RESET_MESON_AUX staying to 'n' if CONFIG_FOO is turned on with menuconfig. drivers/clk/meson/Kconfig | 2 +- drivers/clk/meson/axg-audio.c | 114 +++++------------------------------------- 2 files changed, 14 insertions(+), 102 deletions(-) diff --git a/drivers/clk/meson/Kconfig b/drivers/clk/meson/Kconfig index be2e3a5f83363b07cdcec2601acf15780ff24892..7cb21fc223b063cb93812643f02f192343981ed8 100644 --- a/drivers/clk/meson/Kconfig +++ b/drivers/clk/meson/Kconfig @@ -106,7 +106,7 @@ config COMMON_CLK_AXG_AUDIO select COMMON_CLK_MESON_SCLK_DIV select COMMON_CLK_MESON_CLKC_UTILS select REGMAP_MMIO - select RESET_CONTROLLER + 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 9df627b142f89788966ede0262aaaf39e13f0b49..6d798705c5fd1e6190192294783c955fc9be1e21 100644 --- a/drivers/clk/meson/axg-audio.c +++ b/drivers/clk/meson/axg-audio.c @@ -4,6 +4,7 @@ * Author: Jerome Brunet */ +#include #include #include #include @@ -12,7 +13,6 @@ #include #include #include -#include #include #include "meson-clkc-utils.h" @@ -1678,84 +1678,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,8 +1688,7 @@ 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; + const char *rst_drvname; unsigned int max_register; }; @@ -1775,7 +1696,7 @@ 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 auxiliary_device *auxdev; struct regmap *map; void __iomem *regs; struct clk_hw *hw; @@ -1834,22 +1755,15 @@ 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) { + auxdev = __devm_auxiliary_device_create(dev, dev->driver->name, + data->rst_drvname, NULL, 0); + if (IS_ERR(auxdev)) + return PTR_ERR(auxdev); + } - return devm_reset_controller_register(dev, &rst->rstc); + return 0; } static const struct audioclk_data axg_audioclk_data = { @@ -1869,8 +1783,7 @@ 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, + .rst_drvname = "rst-g12a", .max_register = AUDIO_CLK_SPDIFOUT_B_CTRL, }; @@ -1881,8 +1794,7 @@ 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, + .rst_drvname = "rst-sm1", .max_register = AUDIO_EARCRX_DMAC_CLK_CTRL, };