From patchwork Thu May 16 15:08:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 13666301 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (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 290E414B97C for ; Thu, 16 May 2024 15:08:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715872132; cv=none; b=jOJBdM+uzzYbw4zq+hIlqeQ9BtBgviX44dDB8QlF48sT7FeeVnRX8qwK0qAX7UH1vHr6o9Ae6ZiwS25RoWQweOawOtL+TXdb9yn5hiLxPyBUWS4XBBc4lTIwtxzucbfnq8mtDDvlJDI1SkvWH16XVNHraZjjBQ095RXwAZ8r9nU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715872132; c=relaxed/simple; bh=cxaqUoQ9aguHyFdmx85j2AoRbVwkuszVVEgKQCGMEX8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cmdWBYvMTgl3lYeGPRPle6riVBp8rREKpqw5sC5l4Ko21VVNA4YCJpBmFVmsVF7Qsf71tAkGrY/VNt6kv+K+c4cB+JYG+PFWVmG7OqpFKawrde/6Z39LxuKmxC2pnF/tgLIq7UzgBfVZtK1hcXBIixUsbeUg8kAKUnFqBVf/anE= 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=qiT2ujII; arc=none smtp.client-ip=209.85.128.44 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="qiT2ujII" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4202dd90dcfso2629015e9.0 for ; Thu, 16 May 2024 08:08:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1715872128; x=1716476928; 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=+f/3bReYMesF4TJq9BOi7hv3PG6ArjPAwHRzmWrlWAw=; b=qiT2ujIIVGhrnuqOh3+FX8h23MZkpHqzNIhTFqsgLttZUVWi9NhtGcq7sh/HCpXPqS HnSdeWHSUiunY81T+sjuCYgvD9h44XvslU2HzSRxEA3PckF+6W+k7WauDx8JhvUnKN6L 3td+XdAWwgn2DkqL3cEBi8NbXX6ZVAKYSf1gdJaPWiRcCYIxc2n+XhjFXMgo+Wq23yvc jSGCrTrRgzmW+1impZgD9sP3WLKwHe4tgrA0w/hNNUceQcTfc8/BkdOGUaQNHYeP9ZUY 2MmiAwZXqVDOI0wzi9DGJqllfEJF8AhX5x9TPxfO9G2hG4LlKpoGQk8swM9zzSiGv/IY eYTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715872128; x=1716476928; 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=+f/3bReYMesF4TJq9BOi7hv3PG6ArjPAwHRzmWrlWAw=; b=V4gvYk1yAOzoIYL+rsmh4sj8gGGuoLHrbVwzwrUsIsYueV1Yf0IzkaMZzSzf4cpJgg zkDbsQ52yscYnohRHLVF1IbWlbmDN7zSacf8xHUyLsD8ZBJFDM/UF3PGRc2D+9bQTOMX 2FEDFDPuzy8Rlibl9sXgD7v6nCAiIlqoMtnZC/ZuB2CxbrnHISC8IOMQNFvxSiC5a8Pt 1IpCZoAGIwOMdXb8q7h3H1xJCbNDElIydTqFRicOWAEqq5ixSO46sEIuBBvM3CkDhDm9 l5/pfcW8+FzBErAxYhS0TXNbJXPQdDW4x+7sySnS96huHvDYktQ2hHjIYDLwJ3OabanJ BClg== X-Forwarded-Encrypted: i=1; AJvYcCWgIRMh6FIHInnYl7C/0YVpYrWimKy5lroWh8kdHUzkzO3Mh5W6G3ED8chFOeK5+johLpaWjBVF9IfrDDCQMHiwZWFon8cXpbuJ X-Gm-Message-State: AOJu0Yz+0q2l1gf+cmOqggMB2izKVYqCsDwAr6TXBErb6MRHkfX2aQOU aXlrYhNtWKg9sOup2jyeqGiolgjg4X0a6gNltvzqLM4p8X9f4os7bCLV+0zyGlw= X-Google-Smtp-Source: AGHT+IEYZF+5ejklYa8gOutFOpqH9vmFIkmi4oDHndgWrV0jEKKooJucmjXLHzEaKGqSFHUhay2i4Q== X-Received: by 2002:a05:600c:5008:b0:41f:e7ac:cc72 with SMTP id 5b1f17b1804b1-41fead643a0mr145586765e9.40.1715872128318; Thu, 16 May 2024 08:08:48 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:1fce:7e5a:e201:edd5]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-41f87c25459sm309351725e9.18.2024.05.16.08.08.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 08:08:48 -0700 (PDT) From: Jerome Brunet To: Philipp Zabel , Stephen Boyd , Neil Armstrong Cc: Jerome Brunet , Jan Dakinevich , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org Subject: [RFC PATCH 1/9] reset: amlogic: convert driver to regmap Date: Thu, 16 May 2024 17:08:31 +0200 Message-ID: <20240516150842.705844-2-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240516150842.705844-1-jbrunet@baylibre.com> References: <20240516150842.705844-1-jbrunet@baylibre.com> Precedence: bulk X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Bot: notify To allow using the same driver for the main reset controller and the auxiliary ones embedded in the clock controllers, convert the the Amlogic reset driver to regmap. Signed-off-by: Jerome Brunet --- drivers/reset/reset-meson.c | 80 ++++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 36 deletions(-) diff --git a/drivers/reset/reset-meson.c b/drivers/reset/reset-meson.c index f78be97898bc..8f3d6e9df235 100644 --- a/drivers/reset/reset-meson.c +++ b/drivers/reset/reset-meson.c @@ -11,36 +11,44 @@ #include #include #include +#include #include #include #include -#define BITS_PER_REG 32 - struct meson_reset_param { int reg_count; int level_offset; }; struct meson_reset { - void __iomem *reg_base; const struct meson_reset_param *param; struct reset_controller_dev rcdev; - spinlock_t lock; + struct regmap *map; }; +static void meson_reset_offset_and_bit(struct meson_reset *data, + unsigned long id, + unsigned int *offset, + unsigned int *bit) +{ + unsigned int stride = regmap_get_reg_stride(data->map); + + *offset = (id / (stride * BITS_PER_BYTE)) * stride; + *bit = id % (stride * BITS_PER_BYTE); +} + static int meson_reset_reset(struct reset_controller_dev *rcdev, - unsigned long id) + unsigned long id) { struct meson_reset *data = container_of(rcdev, struct meson_reset, rcdev); - unsigned int bank = id / BITS_PER_REG; - unsigned int offset = id % BITS_PER_REG; - void __iomem *reg_addr = data->reg_base + (bank << 2); + unsigned int offset, bit; - writel(BIT(offset), reg_addr); + meson_reset_offset_and_bit(data, id, &offset, &bit); - return 0; + return regmap_update_bits(data->map, offset, + BIT(bit), BIT(bit)); } static int meson_reset_level(struct reset_controller_dev *rcdev, @@ -48,25 +56,13 @@ static int meson_reset_level(struct reset_controller_dev *rcdev, { struct meson_reset *data = container_of(rcdev, struct meson_reset, rcdev); - unsigned int bank = id / BITS_PER_REG; - unsigned int offset = id % BITS_PER_REG; - void __iomem *reg_addr; - unsigned long flags; - u32 reg; + unsigned int offset, bit; - reg_addr = data->reg_base + data->param->level_offset + (bank << 2); + meson_reset_offset_and_bit(data, id, &offset, &bit); + offset += data->param->level_offset; - spin_lock_irqsave(&data->lock, flags); - - reg = readl(reg_addr); - if (assert) - writel(reg & ~BIT(offset), reg_addr); - else - writel(reg | BIT(offset), reg_addr); - - spin_unlock_irqrestore(&data->lock, flags); - - return 0; + return regmap_update_bits(data->map, offset, + BIT(bit), assert ? 0 : BIT(bit)); } static int meson_reset_assert(struct reset_controller_dev *rcdev, @@ -113,30 +109,42 @@ static const struct of_device_id meson_reset_dt_ids[] = { }; MODULE_DEVICE_TABLE(of, meson_reset_dt_ids); +static const struct regmap_config regmap_config = { + .reg_bits = 32, + .val_bits = 32, + .reg_stride = 4, +}; + static int meson_reset_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct meson_reset *data; + void __iomem *base; - data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); if (!data) return -ENOMEM; - data->reg_base = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(data->reg_base)) - return PTR_ERR(data->reg_base); + base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(base)) + return PTR_ERR(base); - data->param = of_device_get_match_data(&pdev->dev); + data->param = of_device_get_match_data(dev); if (!data->param) return -ENODEV; - spin_lock_init(&data->lock); + data->map = devm_regmap_init_mmio(dev, base, ®map_config); + if (IS_ERR(data->map)) + return dev_err_probe(dev, PTR_ERR(data->map), + "can't init regmap mmio region\n"); data->rcdev.owner = THIS_MODULE; - data->rcdev.nr_resets = data->param->reg_count * BITS_PER_REG; + data->rcdev.nr_resets = data->param->reg_count * BITS_PER_BYTE + * regmap_config.reg_stride; data->rcdev.ops = &meson_reset_ops; - data->rcdev.of_node = pdev->dev.of_node; + data->rcdev.of_node = dev->of_node; - return devm_reset_controller_register(&pdev->dev, &data->rcdev); + return devm_reset_controller_register(dev, &data->rcdev); } static struct platform_driver meson_reset_driver = { From patchwork Thu May 16 15:08:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 13666302 Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) (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 F116014B97E for ; Thu, 16 May 2024 15:08:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715872132; cv=none; b=HiAYLWOGOu3vkIg1ilVPvUFmjsfkjM6O7xxJ16F5tbsiZD3TmxJbM+uuZlT8IpFzVg+cAtinoRTlEtHXvBHU9+HHUy6pIO13vF2LsBqVItXne8PhdYiGA+ABORdJHCn1TEB8xXJdmwSqAhlsP8nK4lOsAoUzzdGJhr8qEQqkdgw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715872132; c=relaxed/simple; bh=XhLKaJpFjJZQj7yn2g+fkx1VUJf2EFpLz+SlbAbTNhQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nYiNWivm8+94B+DbBU8XM1p4+Be84C7/1ohhm0OXIKpt9SIdXcq3yfrCw+4/tjoECVfbvhysuaf4uQ9j2Qht01YZq5Fq5J17NJSQih/O9j9IH7II/tujuHdlYvLiH4IXT17F0KLuCFQ7xDnLQNJ/mNvlFRWQeWUXwz6ZO8lkVWg= 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=iLjE3YM6; arc=none smtp.client-ip=209.85.208.171 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="iLjE3YM6" Received: by mail-lj1-f171.google.com with SMTP id 38308e7fff4ca-2e34e85ebf4so7685021fa.2 for ; Thu, 16 May 2024 08:08:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1715872129; x=1716476929; 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=QEvOpWPnO+AdwLbOiUNmMA/qUdgyKNblxOI/csLZzos=; b=iLjE3YM6SqyFFYnVIJaEEKR/FT5pz6Lpbqi+8nFRWPD0qfNHvlKcJkW+Cs5EC2AfTL 9LMWRTnc3QiWO9Cdqg05iFfli8BcmK9Szz6gTWksH5yosbWWSfCC8PIb28JJHBZh/3Uj Yh1OPE22by7518eAMO91u2Qn9gP73M9NuKHMPz4RCJQNNOsGAgfuKaSX2pI9W6sdcOEM R2Qm17PBTrd0GM1FXPoSthomDvesVOeahhH+JL7Ol4ayJqK9IwaTIewgMN9wiDx7Ob0F eTS6hk59JBYh0R1D6LU7U0g6YNTTJlQg1lNQEBrpz4/mQ6dYdTLjU+imEOFJ0vuClA/O tyQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715872129; x=1716476929; 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=QEvOpWPnO+AdwLbOiUNmMA/qUdgyKNblxOI/csLZzos=; b=fgmc9L+im7bJp6Z/4jFzO5CRToZGvuauKDZSiTgsPjcdnvtG6sG+5lkrohHhPQOYNQ yYdXcDCVgu7IMTGNK0dkyM8IGIiPdCIKuGQzEmbzBYevGYLuNoReAJwrHZbqpZhUOvXB jowjMTPcu5ukfDEiehogiDOwfqYoUIyduIISxVWvcm7bs1SwSFpfHsoFG+TaUQpaMhgD 4H4Zpax7M1JepPx5sheJ5u8lIFpOqEm0F7N6YQWdzE4+Z6ZuQ3JVZcIPfgGoZywLO63e ltnwG7+vDJHKMLpdc6Dzs0F8SzZ3bd++JXjQhUlZFmZn8/2KGJTNGW0tfvsfXbph6BqN yizA== X-Forwarded-Encrypted: i=1; AJvYcCVDRYZzII5t3n3lOFoDeeqBT9qSkUCv0TyAUa31Kf3O5QGyhzvYxREgOItTO6RVDYzKC8jQsDvBG+nFOfmQflTwjPYFLvZzV7Bb X-Gm-Message-State: AOJu0Yw82K5Lec2qrYbQJRxAtTCuivEvvltZJmW3NlXhH6HO9jraEui8 fbwoZukTDvyOncF6zUoyJmzJm6ZbXYjVUA5WEbLSNVEGD3EqOL5yxqDudAZCdSo= X-Google-Smtp-Source: AGHT+IGYAck85LsbcTOvXFQY8nZM3fKLyOR5JchkAjsB3ueKLHe+uoUsgS+o6TUKMWmJKolx9ml/0A== X-Received: by 2002:a2e:a412:0:b0:2e4:e15d:40b0 with SMTP id 38308e7fff4ca-2e52028aefemr120909581fa.32.1715872129220; Thu, 16 May 2024 08:08:49 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:1fce:7e5a:e201:edd5]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-41f87c25459sm309351725e9.18.2024.05.16.08.08.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 08:08:48 -0700 (PDT) From: Jerome Brunet To: Philipp Zabel , Stephen Boyd , Neil Armstrong Cc: Jerome Brunet , Jan Dakinevich , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org Subject: [RFC PATCH 2/9] reset: amlogic: add driver parameters Date: Thu, 16 May 2024 17:08:32 +0200 Message-ID: <20240516150842.705844-3-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240516150842.705844-1-jbrunet@baylibre.com> References: <20240516150842.705844-1-jbrunet@baylibre.com> Precedence: bulk X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Bot: notify To allow using the same driver for the main reset controller and the auxiliary ones embedded in the clock controllers, allow to customise the reset offset, same as the level offset. Also add an option to make the level reset active low or high. Signed-off-by: Jerome Brunet --- drivers/reset/reset-meson.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/reset/reset-meson.c b/drivers/reset/reset-meson.c index 8f3d6e9df235..59126c9f194a 100644 --- a/drivers/reset/reset-meson.c +++ b/drivers/reset/reset-meson.c @@ -18,7 +18,9 @@ struct meson_reset_param { int reg_count; + int reset_offset; int level_offset; + bool level_low_reset; }; struct meson_reset { @@ -46,6 +48,7 @@ static int meson_reset_reset(struct reset_controller_dev *rcdev, unsigned int offset, bit; meson_reset_offset_and_bit(data, id, &offset, &bit); + offset += data->param->reset_offset; return regmap_update_bits(data->map, offset, BIT(bit), BIT(bit)); @@ -60,9 +63,10 @@ static int meson_reset_level(struct reset_controller_dev *rcdev, meson_reset_offset_and_bit(data, id, &offset, &bit); offset += data->param->level_offset; + assert ^= data->param->level_low_reset; return regmap_update_bits(data->map, offset, - BIT(bit), assert ? 0 : BIT(bit)); + BIT(bit), assert ? BIT(bit) : 0); } static int meson_reset_assert(struct reset_controller_dev *rcdev, @@ -85,17 +89,23 @@ static const struct reset_control_ops meson_reset_ops = { static const struct meson_reset_param meson8b_param = { .reg_count = 8, + .reset_offset = 0x0, .level_offset = 0x7c, + .level_low_reset = true, }; static const struct meson_reset_param meson_a1_param = { .reg_count = 3, + .reset_offset = 0x0, .level_offset = 0x40, + .level_low_reset = true, }; static const struct meson_reset_param meson_s4_param = { .reg_count = 6, + .reset_offset = 0x0, .level_offset = 0x40, + .level_low_reset = true, }; static const struct of_device_id meson_reset_dt_ids[] = { From patchwork Thu May 16 15:08:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 13666304 Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) (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 C913214C599 for ; Thu, 16 May 2024 15:08:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715872134; cv=none; b=Krxx65jlr9NgJ2LPmkBKo/Fn2kePLIdy9JIzt/juTi8UzdrRzcf7H7uz53DvkjIrWT+74Oz7EHiHwWutCIAnP+pmJMlbbyRKsnPu8MwURXYPletSFMYCL62GV6CgK8jlFm874Fvo+swg/HgPPnM05Vl5O82R9kSuFgCfrnyDno4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715872134; c=relaxed/simple; bh=GPIkBbQj4IQYkRBMApjzbDefFG1cRgF3e6hKKqXUa84=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pVyMrSCmYq++mU1dBwdN+8QrekE4Vyze7wmsm2tIj9KIR76ecF33/KmqYH7/BNJpg8hNRjdLkxZEQLEOeM1ouY5+Xy+uRTrD2t+8pYB/Nnm76fDU8JYbl4DSs7RPmhpDQWmkwmxPWCLYXGMIMAUa017o88yOz2zHh7blWAtFwg8= 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=p0S5dnGS; arc=none smtp.client-ip=209.85.208.169 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="p0S5dnGS" Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-2e3e18c24c1so10088691fa.1 for ; Thu, 16 May 2024 08:08:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1715872130; x=1716476930; 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=Zlq2XgSsulaEdUEoiNJy3+0ETTvrLEFhmOVX/TPKWFg=; b=p0S5dnGSdMKtvt45zX7xJfOn2ceBCsFzGZqPG3stB6jWb7rrlM+4+rxT7DlKbC6+sF Ze2uXr2DDZ8TzsgSxICYc0pwUU6CVokQnzW1APxdBYqRIzLG69wsDyud92ge1BRoi4VU HsXXOMd80A8csNv3JU4mNIHyqx2ep6uCAvbcqLzja1N6iOYkx/dhbKsSePcxXFmXQWW2 UyS10NhCMqXFtfjfxTlCzg+nCHV2Ly/SW/W6pL2KpiN8NDP/+XNAKzkPgwxT1Ua7KdXE f2TdCKVTGuPxMnOHsr+KjiMVysnLnPkC+TFeig89Cprqivn0JwMSdgxGjPrBTABQjQO5 A6zA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715872130; x=1716476930; 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=Zlq2XgSsulaEdUEoiNJy3+0ETTvrLEFhmOVX/TPKWFg=; b=YeIr0Vs79O8umfggYnT1LBZc29g/WdacWUmIGp4RTNsBAg5ZK7PJpjjSGqV/WBM5LL CVW3ZmbjY9d2kPT2V6uhRHxLTMLbbFA4mN5aho0LerrV75CdeK7+JmT7sh8PXcLmpcI5 70qVXHFvmLIqg8f7WsEXdE7KwtEwX3GwsxyvM6xzXeqqltZRzoWQXJZi2zfpvNzhhWkP R0IETbW6bg6ZV82igOKZtqu1JttLcQfbxh/mhMCQ1cpbCg8CSRbI74+NDydw7zNAY5/y 7OR2FRrLUyNnIXk6nMGZaGgxxw2sH/CoPh3EPIvjn05JkRp7UVSWFJ38UkypRUNcuveF 0h+g== X-Forwarded-Encrypted: i=1; AJvYcCVB9icSSprq0zlanyWCTip42ssRpQHX1++W5u1In7z1SuJ6g8CA37xYteKinOHljI6rCP3ETT9GDvgnyiW+iydZnnp/i/tVfQMJ X-Gm-Message-State: AOJu0YxeExvHbN1QhQ7RIahOFbsG5jIVwe0YU2J9ggXa5SLAZ5VWUFOI stXvncikXvU26R1QulbCZYoySSmX//H738DPOejpJJzegdPO6Xxc/TEKJRT4Www= X-Google-Smtp-Source: AGHT+IHr28udNSRatyT+2G5LNG1+hGVEMFrX9RhYuqKy2yHAm390/4kDGgRKQKwjLoGX9pVtnsJ34g== X-Received: by 2002:a2e:5112:0:b0:2e6:d2bc:1d18 with SMTP id 38308e7fff4ca-2e6d2bc24e5mr52015521fa.22.1715872129966; Thu, 16 May 2024 08:08:49 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:1fce:7e5a:e201:edd5]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-41f87c25459sm309351725e9.18.2024.05.16.08.08.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 08:08:49 -0700 (PDT) From: Jerome Brunet To: Philipp Zabel , Stephen Boyd , Neil Armstrong Cc: Jerome Brunet , Jan Dakinevich , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org Subject: [RFC PATCH 3/9] reset: amlogic: split the device and platform probe Date: Thu, 16 May 2024 17:08:33 +0200 Message-ID: <20240516150842.705844-4-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240516150842.705844-1-jbrunet@baylibre.com> References: <20240516150842.705844-1-jbrunet@baylibre.com> Precedence: bulk X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Bot: notify To prepare the addition of the auxiliary device support, split the device probe from the probe of the platform device. The device probe will be common to both the platform and auxiliary driver. Signed-off-by: Jerome Brunet --- drivers/reset/reset-meson.c | 55 +++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/drivers/reset/reset-meson.c b/drivers/reset/reset-meson.c index 59126c9f194a..fec55321b52b 100644 --- a/drivers/reset/reset-meson.c +++ b/drivers/reset/reset-meson.c @@ -87,6 +87,27 @@ static const struct reset_control_ops meson_reset_ops = { .deassert = meson_reset_deassert, }; +static int meson_reset_probe(struct device *dev, struct regmap *map, + const struct meson_reset_param *param) +{ + unsigned int stride = regmap_get_reg_stride(map); + struct meson_reset *data; + + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + data->param = param; + data->map = map; + data->rcdev.owner = dev->driver->owner; + data->rcdev.nr_resets = param->reg_count * BITS_PER_BYTE + * stride; + data->rcdev.ops = &meson_reset_ops; + data->rcdev.of_node = dev->of_node; + + return devm_reset_controller_register(dev, &data->rcdev); +} + static const struct meson_reset_param meson8b_param = { .reg_count = 8, .reset_offset = 0x0, @@ -125,46 +146,38 @@ static const struct regmap_config regmap_config = { .reg_stride = 4, }; -static int meson_reset_probe(struct platform_device *pdev) +static int meson_reset_pltf_probe(struct platform_device *pdev) { + + const struct meson_reset_param *param; struct device *dev = &pdev->dev; - struct meson_reset *data; + struct regmap *map; void __iomem *base; - data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); - if (!data) - return -ENOMEM; - base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(base)) return PTR_ERR(base); - data->param = of_device_get_match_data(dev); - if (!data->param) + param = of_device_get_match_data(dev); + if (!param) return -ENODEV; - data->map = devm_regmap_init_mmio(dev, base, ®map_config); - if (IS_ERR(data->map)) - return dev_err_probe(dev, PTR_ERR(data->map), + map = devm_regmap_init_mmio(dev, base, ®map_config); + if (IS_ERR(map)) + return dev_err_probe(dev, PTR_ERR(map), "can't init regmap mmio region\n"); - data->rcdev.owner = THIS_MODULE; - data->rcdev.nr_resets = data->param->reg_count * BITS_PER_BYTE - * regmap_config.reg_stride; - data->rcdev.ops = &meson_reset_ops; - data->rcdev.of_node = dev->of_node; - - return devm_reset_controller_register(dev, &data->rcdev); + return meson_reset_probe(dev, map, param); } -static struct platform_driver meson_reset_driver = { - .probe = meson_reset_probe, +static struct platform_driver meson_reset_pltf_driver = { + .probe = meson_reset_pltf_probe, .driver = { .name = "meson_reset", .of_match_table = meson_reset_dt_ids, }, }; -module_platform_driver(meson_reset_driver); +module_platform_driver(meson_reset_pltf_driver); MODULE_DESCRIPTION("Amlogic Meson Reset Controller driver"); MODULE_AUTHOR("Neil Armstrong "); From patchwork Thu May 16 15:08:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 13666306 Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) (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 0624A14D6E6 for ; Thu, 16 May 2024 15:08:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715872136; cv=none; b=TpNl4GAYwW9GABb7BFSvcNkiMNd8IS8OdoP9nYs3stNqJDeVs3HbGVHF5r9RokHgxg5mYbs6RIdyqv1g528yin6SpdhksE/UylgJHeLOwxQyKg8TgquzOg9TMjR9UOejAkRAlQylOOziiiZoHtlNZ459EAVWvguxeS4LJVg8+AU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715872136; c=relaxed/simple; bh=G+dvNYQOBLr+WoKmLXh98J7Aryp0MXfhIBc7+yfe0sM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Xwo/b4aZc6aKAec1+JhL3vTwHSnFeHn4RrFDs8ptYQbC+QsffXBYtsT0A5JqSmjpXwLUlyKSOGzi8mpfq6PHLR2vp4sKIQu12Xe84hmQlRE8JM0V8+GgDztSewQMTCmUwnrfkAr39WuckBi2BPDFI0zhqNFttgO6QARm/++XrDE= 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=bO9DB/Tt; arc=none smtp.client-ip=209.85.208.169 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="bO9DB/Tt" Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-2e52181c228so8151401fa.0 for ; Thu, 16 May 2024 08:08:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1715872132; x=1716476932; 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=ypBfZt6woLl48yZMYWLwJnxD1n063j94AW3SXRtrghk=; b=bO9DB/TtArv+1pvyVORnixHhr8CWdanaBXZDbx7w5vfArNShcbpFZzeslsUPEiVHel Kxwxph9dVzm+GumrpWlU7IJrBV/TIHCq++s0K5JOZSD2ZrExHAYux3LYAkOE8mZsipju fxUEDBZizHwbyNBKY9k+uyZrHDGUJB0YU2mR9EXWd4xlKHPR0a+3ScnzVBMLymcIRRsz +zUbW4asZY67COG/eossn22HAnYSSdtOLBwomFy9colskEg8vJYDo/eGKJIE85ZirJfK 2LBbOIYMIgB3ZUIZxciXWoBRimPILYrMHkCAJwmA/yXPy1jbMOpf1I4Pv1mMLvBFBlBR WJSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715872132; x=1716476932; 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=ypBfZt6woLl48yZMYWLwJnxD1n063j94AW3SXRtrghk=; b=cLTVehsnNS3JVxmITL40MS/GHcqZ1u0yfmc8/hblZzfrK1zz2tkL/DU0EMK4SkCDU3 JRrzu54jUsSM4g6PPZAJvxtcC2PtN6Uzzoe0g/haeK2klVS7BK01ul/7K8UeO4ien0VW NXp1wRe2qs7xLaI+GkwJ6IBZkbxD8eaFVqDMAX09IO+gng77Y1x2gcMjugDvBIpRl9w2 bJpwTGrjz9ssLMx7AjyGTavldIcZTGiZtXpTGkIKxkvLRvf0c65krq32ZSDaIEIkkg27 C14HvxDbaohlNsnUL7Y1wlbgrhSuqL1RaTzCTmiY2kz1nZsMkrBE37OeoP6omYafwI8W Y7Ug== X-Forwarded-Encrypted: i=1; AJvYcCWN6FbaN+4+OeaZDTWpH08ydUPVtqPofWtRzXhGVayNadi5NYSTwPw19y0+naSEKY4gbjFAk/MgpNmCvG9rq1Oq5rMx/wOXyd2N X-Gm-Message-State: AOJu0YzWiWoT7/YcZSmt8HQfOQs6zkH/O4ZGy/XZ+yghIRwVamhejdp9 yQs8jmM8ISCfjTarfw24PkjhvulAm/aZlhpI31xThSvbZV/TGlMnMh2PZgF0Luc= X-Google-Smtp-Source: AGHT+IE8U/D0l2CYHxsSjMxEnW9Nswfn86/rBWx05jmcgu+/3vQwWvbBIKiUixNYwUsYF7gN5EXKtA== X-Received: by 2002:a2e:81c3:0:b0:2df:907e:6de3 with SMTP id 38308e7fff4ca-2e52038a44bmr116578741fa.35.1715872130810; Thu, 16 May 2024 08:08:50 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:1fce:7e5a:e201:edd5]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-41f87c25459sm309351725e9.18.2024.05.16.08.08.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 08:08:50 -0700 (PDT) From: Jerome Brunet To: Philipp Zabel , Stephen Boyd , Neil Armstrong Cc: Jerome Brunet , Jan Dakinevich , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org Subject: [RFC PATCH 4/9] reset: amlogic: use reset number instead of register count Date: Thu, 16 May 2024 17:08:34 +0200 Message-ID: <20240516150842.705844-5-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240516150842.705844-1-jbrunet@baylibre.com> References: <20240516150842.705844-1-jbrunet@baylibre.com> Precedence: bulk X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Bot: notify The reset driver from audio clock controller may register less reset than a register can hold. To avoid making any change while switching to auxiliary support, use the number of reset instead of the register count to define the bounds of the reset controller. Signed-off-by: Jerome Brunet --- drivers/reset/reset-meson.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/reset/reset-meson.c b/drivers/reset/reset-meson.c index fec55321b52b..3e0447366ba6 100644 --- a/drivers/reset/reset-meson.c +++ b/drivers/reset/reset-meson.c @@ -17,7 +17,7 @@ #include struct meson_reset_param { - int reg_count; + unsigned int reset_num; int reset_offset; int level_offset; bool level_low_reset; @@ -90,7 +90,6 @@ static const struct reset_control_ops meson_reset_ops = { static int meson_reset_probe(struct device *dev, struct regmap *map, const struct meson_reset_param *param) { - unsigned int stride = regmap_get_reg_stride(map); struct meson_reset *data; data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); @@ -100,8 +99,7 @@ static int meson_reset_probe(struct device *dev, struct regmap *map, data->param = param; data->map = map; data->rcdev.owner = dev->driver->owner; - data->rcdev.nr_resets = param->reg_count * BITS_PER_BYTE - * stride; + data->rcdev.nr_resets = param->reset_num; data->rcdev.ops = &meson_reset_ops; data->rcdev.of_node = dev->of_node; @@ -109,21 +107,21 @@ static int meson_reset_probe(struct device *dev, struct regmap *map, } static const struct meson_reset_param meson8b_param = { - .reg_count = 8, + .reset_num = 256, .reset_offset = 0x0, .level_offset = 0x7c, .level_low_reset = true, }; static const struct meson_reset_param meson_a1_param = { - .reg_count = 3, + .reset_num = 96, .reset_offset = 0x0, .level_offset = 0x40, .level_low_reset = true, }; static const struct meson_reset_param meson_s4_param = { - .reg_count = 6, + .reset_num = 192, .reset_offset = 0x0, .level_offset = 0x40, .level_low_reset = true, From patchwork Thu May 16 15:08:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 13666305 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 028AD14D6E0 for ; Thu, 16 May 2024 15:08:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715872135; cv=none; b=AFxoYHVYAwiCfhX3xP/LfQOe/Wvot8e8+Zud0QMEu1XP3LuvZ25WInzJE30cafQxalJSa/Rad0NzWAbgdCsp63h47WAmUPJ1Q090RoIAddCPFFZW1upsyoESRWLWjBEAmXDCIk/Pgspj8GPAdD+FLmLiTPVYlXQkK4htHw7QFwg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715872135; c=relaxed/simple; bh=iaknELToT+8y0KfW1nvtsEVAwfzQue3+xA6phI3OqV0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=E8kNWh9NgKgT6haWGjtp10sYa0Qid3oXzh2nlsQKlU2hIJT1bpCa65dUswqEoUImVLMyxXM4CbslSOdt/wh3o1toBZhEaILZdFygC8b+MMACCrNvjTb3VO7CO+kx15J1OZSo+HPeSCGzPhZDCvsnzHFFCgoaa9lnhPbDZKWNfsg= 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=uiqrYctu; arc=none smtp.client-ip=209.85.128.46 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="uiqrYctu" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-420298ff5b1so9464015e9.1 for ; Thu, 16 May 2024 08:08:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1715872132; x=1716476932; 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=MKLxWZMdcIpvnKpiYpSqkgcStnHEt9yT8sCcERiOd18=; b=uiqrYctuTsCr0cP46z67CvPT3Av3VYvAodWSJPVzI4bSDfJbHMWx41e6sCxSWmAW2V gNvh5WxQUcTUE2R5zFhfMQrP28R8lXZTbvIVwQwdB3akI/909gBnZIxtg/8uZUoTnGTa K2oTOgjvKJfwzmSUSYVbDl3LdRPyDiHQsJqlqn23b82PT8fkvvWmYGJAMzynWlFlpq+R 4cxD/QHcP6qNR+Fl1encudwEu/qdvPgrpfjqMl3BUAYpYsIA7VSyhV3mFsy4/gfEYdmk gw2I4hVxMGfyP/kg2KwKUCV6HKtZr9ggM3W0QFnj8fuebAbwnpjoV8STvxdRxhDoJOAK AE8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715872132; x=1716476932; 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=MKLxWZMdcIpvnKpiYpSqkgcStnHEt9yT8sCcERiOd18=; b=sUr1stYhCtBq33/si7mN3Wwoxa2biD3HqpiVtivKdHftQnvVZP0TH9MPW3BcvYzFUR FGsdaX2MJQK+SSzQYNghV+JLpYB9X21BiCeB15Co7JkFT5wWbwPaSX+m/nGq44Szo2aw q3g+Nw/EkiVCD4TxWh1eZrTLKr6ISmAzpzQEAoXcb1hBxAK+jNI7opZFGbqaDy7NNZ8w Nxv3e2pUsQ01ZQz8VwNXVgq+Z6uGj3N1Q6EJMwuwbmkHcUwG8BKyJkbTPRwpwUdA0Js3 De+A27Kr7prniXi7bJD6JApaOIXDxwQr4fOEptb1ui7pbYAIs3cdBqHMe3MO9Od8Vsp2 x3gg== X-Forwarded-Encrypted: i=1; AJvYcCUQb2JsjEfVTg1gaPL1mT2FHulgaDUA56TCWS4hHhAZFdZzbAmbBqd3G2H/os8y9e522b3Z1Q5L8yX2ZIXsea2xwtk1juxRQ/+3 X-Gm-Message-State: AOJu0YzGatAEfwQxY/9XzqwVZD6V+wDXPNK4RZmHg8TAz2gZwRgv+T4b uCepRNkW68Gllj6YslqMgVDYQHchM/7AtQge4t7CNxhDqQT30RMV4MliSf2pRq4= X-Google-Smtp-Source: AGHT+IG/ykFXrbe/CvlsHN4du9qU8bGGEbwc+8VNXOgZYoQoZ5vQI4mqtGU2dnI3Uc7WqDGAtugK6A== X-Received: by 2002:a05:600c:3594:b0:41f:e10f:88b1 with SMTP id 5b1f17b1804b1-41feac55eccmr187308155e9.27.1715872132571; Thu, 16 May 2024 08:08:52 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:1fce:7e5a:e201:edd5]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-41f87c25459sm309351725e9.18.2024.05.16.08.08.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 08:08:52 -0700 (PDT) From: Jerome Brunet To: Philipp Zabel , Stephen Boyd , Neil Armstrong Cc: Jerome Brunet , Jan Dakinevich , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org Subject: [RFC PATCH 5/9] reset: amlogic: add reset status support Date: Thu, 16 May 2024 17:08:35 +0200 Message-ID: <20240516150842.705844-6-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240516150842.705844-1-jbrunet@baylibre.com> References: <20240516150842.705844-1-jbrunet@baylibre.com> Precedence: bulk X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Bot: notify Add the callback to check the status of the level reset, as done in the reset driver of the audio clock controller. Signed-off-by: Jerome Brunet --- drivers/reset/reset-meson.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/reset/reset-meson.c b/drivers/reset/reset-meson.c index 3e0447366ba6..65ba9190cb53 100644 --- a/drivers/reset/reset-meson.c +++ b/drivers/reset/reset-meson.c @@ -69,6 +69,23 @@ static int meson_reset_level(struct reset_controller_dev *rcdev, BIT(bit), assert ? BIT(bit) : 0); } +static int meson_reset_status(struct reset_controller_dev *rcdev, + unsigned long id) +{ + struct meson_reset *data = + container_of(rcdev, struct meson_reset, rcdev); + unsigned int val, offset, bit; + + meson_reset_offset_and_bit(data, id, &offset, &bit); + offset += data->param->level_offset; + + regmap_read(data->map, offset, &val); + val = !!(BIT(bit) & val); + + + return val ^ data->param->level_low_reset; +} + static int meson_reset_assert(struct reset_controller_dev *rcdev, unsigned long id) { @@ -85,6 +102,7 @@ static const struct reset_control_ops meson_reset_ops = { .reset = meson_reset_reset, .assert = meson_reset_assert, .deassert = meson_reset_deassert, + .status = meson_reset_status, }; static int meson_reset_probe(struct device *dev, struct regmap *map, From patchwork Thu May 16 15:08:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 13666307 Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) (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 E896C14C599 for ; Thu, 16 May 2024 15:08:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715872136; cv=none; b=al6m51B3a2VNZyXiuTf7JZxj6YD9ZDAFhkB1Ejbjt7UbBTCj6Ja0Ey5zjihbgVXyUyZ6VBAYUD2zFpQpsDXfSwETwFElbV/wgchOjBpio0pSyWd+IHoV9KKC6J4xlg/lyE/Zhcp1Iy+gXGxwguWjYf7YbIo9aHcxQjB5mb7ajK4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715872136; c=relaxed/simple; bh=tGtxQtR7HQ0uRAG9sLpag+dAG8Y70atmcVnT7vJqVsw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rICNFOfS4y0e+DOX8EZGe7bAbDS2ymFL9NXcIOqs0Ad7eGwRv383hCdePHmnBIwLldFHTZV8DzRzc/Nqlp3doIL7wOqABCfHMgjp3mrLKGBo280wXY3NriykUt3yJIY8gn40Q6nYcIF6z39rmX3K3/112zJesfCbRXtNDOsVC2g= 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=hbJwNewz; arc=none smtp.client-ip=209.85.208.174 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="hbJwNewz" Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2e6ffe57c23so8425231fa.3 for ; Thu, 16 May 2024 08:08:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1715872133; x=1716476933; 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=zRHJOwdVIwklQU4oj6tmH8SkcGKM9hDuvtKA2hq20zY=; b=hbJwNewzud1Oefpi9c5VwSDD8IUG8RsAFst1DYriSvb0AkKWLyEnRXKXQYP8h7Tp87 EdEQ17XITvLG6F5tkmd5zge1YRcT7ihBxmh6rtPdqNeg4TJQluEqRLWVUFeqH3UJPP9j II7hVjn5dq9H/kXFFf6RPOSvMujTbzJFVtNrbnfuqBJ4cpPdnKXVk0uWuFYvULANVmdo fdEHwtNJoILubrIkdfflLp/oboCzsI7YafTfaVUB2wkMclUTpBKBlLthNV0iNKIZFcVa 2LkGWVry1io8Kjmv4HnHedZkZmcmFa98o6uqFom96+fW8tiNMKrls5tBzAiiOcEKIAvY Bumg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715872133; x=1716476933; 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=zRHJOwdVIwklQU4oj6tmH8SkcGKM9hDuvtKA2hq20zY=; b=qHtfs1vqAd0kA6D2LZs/Tkguw5ZbYIsXDOuVlBLqH/j9MziM+h8bbeTPcxfE0vXaZb H9Ofxx+Mn6C1wQHAcNgaxCkb32xWMr2TzB2wBBs+qExsszeqmGeAte5vzWS1x/cCjow7 EWd8HxM2ghOA3zLExKR6yTZ/HusfGj5E7ufQAq/WJ6b1dIN+55fgQRx20WrsXpm9nt8t VPmvyIvm5+G24PR+UVapUqse4dL8bdEBNbXkNlFYlkGya2PllJChJMGwpzD3qvcOOrpC I8SVFKQKTzjPFASpPYlKIVOw+JZRzRmWmsqQZ7FIJAHHlOsVVWHek/pOR+xUkm1SeRIT RknA== X-Forwarded-Encrypted: i=1; AJvYcCVmV7FCvXxNJiNc54w2lS0E2MKL+6Ma4Ckfow2Buuhvkc3L2kHndh96achDmpirIj49HsQ3eBX/bJvnDNDUv4gjrYBNrHF+jaI3 X-Gm-Message-State: AOJu0YzUqIc87pdAfSXt54qUDlVWEhLMJLfErAD7x7Cf2aJOssHuxG8c rQs/dGlWn7HcstXM6/aPfse8dcOFQaNX/C/Rpq0KADf170ehfS7ETcI2dhgTte8= X-Google-Smtp-Source: AGHT+IHu52Tyfwl/3CPcNq8casphAsBV/Ti3JZcRRlwYTeXDmESt1XeztpWut4mxoqayT/xcvdJZXw== X-Received: by 2002:a2e:97c3:0:b0:2e1:f253:152a with SMTP id 38308e7fff4ca-2e5204aef69mr132927271fa.51.1715872133305; Thu, 16 May 2024 08:08:53 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:1fce:7e5a:e201:edd5]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-41f87c25459sm309351725e9.18.2024.05.16.08.08.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 08:08:52 -0700 (PDT) From: Jerome Brunet To: Philipp Zabel , Stephen Boyd , Neil Armstrong Cc: Jerome Brunet , Jan Dakinevich , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org Subject: [RFC PATCH 6/9] reset: amlogic: add toggle reset support Date: Thu, 16 May 2024 17:08:36 +0200 Message-ID: <20240516150842.705844-7-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240516150842.705844-1-jbrunet@baylibre.com> References: <20240516150842.705844-1-jbrunet@baylibre.com> Precedence: bulk X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Bot: notify Add the emulation for the reset callback using level reset if reset is not directly supported. This is done to keep the functionality of reset driver of audio clock controller. This is expected to work by the related reset consumers. Signed-off-by: Jerome Brunet --- drivers/reset/reset-meson.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/drivers/reset/reset-meson.c b/drivers/reset/reset-meson.c index 65ba9190cb53..e34a10b15593 100644 --- a/drivers/reset/reset-meson.c +++ b/drivers/reset/reset-meson.c @@ -17,6 +17,7 @@ #include struct meson_reset_param { + const struct reset_control_ops *reset_ops; unsigned int reset_num; int reset_offset; int level_offset; @@ -98,6 +99,18 @@ static int meson_reset_deassert(struct reset_controller_dev *rcdev, return meson_reset_level(rcdev, id, false); } +static int meson_reset_level_toggle(struct reset_controller_dev *rcdev, + unsigned long id) +{ + int ret; + + ret = meson_reset_assert(rcdev, id); + if (ret) + return ret; + + return meson_reset_deassert(rcdev, id); +} + static const struct reset_control_ops meson_reset_ops = { .reset = meson_reset_reset, .assert = meson_reset_assert, @@ -105,6 +118,13 @@ static const struct reset_control_ops meson_reset_ops = { .status = meson_reset_status, }; +static const struct reset_control_ops meson_reset_toggle_ops = { + .reset = meson_reset_level_toggle, + .assert = meson_reset_assert, + .deassert = meson_reset_deassert, + .status = meson_reset_status, +}; + static int meson_reset_probe(struct device *dev, struct regmap *map, const struct meson_reset_param *param) { @@ -118,13 +138,14 @@ static int meson_reset_probe(struct device *dev, struct regmap *map, data->map = map; data->rcdev.owner = dev->driver->owner; data->rcdev.nr_resets = param->reset_num; - data->rcdev.ops = &meson_reset_ops; + data->rcdev.ops = param->reset_ops; data->rcdev.of_node = dev->of_node; return devm_reset_controller_register(dev, &data->rcdev); } static const struct meson_reset_param meson8b_param = { + .reset_ops = &meson_reset_ops, .reset_num = 256, .reset_offset = 0x0, .level_offset = 0x7c, @@ -132,6 +153,7 @@ static const struct meson_reset_param meson8b_param = { }; static const struct meson_reset_param meson_a1_param = { + .reset_ops = &meson_reset_ops, .reset_num = 96, .reset_offset = 0x0, .level_offset = 0x40, @@ -139,6 +161,7 @@ static const struct meson_reset_param meson_a1_param = { }; static const struct meson_reset_param meson_s4_param = { + .reset_ops = &meson_reset_ops, .reset_num = 192, .reset_offset = 0x0, .level_offset = 0x40, From patchwork Thu May 16 15:08:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 13666308 Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) (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 0278014E2DB for ; Thu, 16 May 2024 15:08:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715872138; cv=none; b=dUDRucYhzqkBVFhvIVO5qWpZt+l0L5I33q8eQ5KLfKLfHbsQ4OjZSSgA3AiVDVyFBpHndBdhhpcvZg3Mu8tlJwJdKU2OQJjAyfUNUWHjPstQ98YLoU11cx/erf2w2mJn3OG/YnCmw+TvR1mmAFh2WKTiTzmql2PRK5idXxToFTQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715872138; c=relaxed/simple; bh=YuEmKCYtjRzD28siL5Mef5H9DNeixjGQ8vzsFA0+0cI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oYdwmq2+iYyhq0OIFgGO0HEVVvyJp0SnsM51x+57uYwgG8Fx4+M/Z/S8y3M/HeiMIG8+5o0KxQOIYF5r6Vo56GF9DIJ3BvKGZ06oPnzUJm5f+AS6Ije81HEj4XBG7pd8su6tUgQqf1mnoBr4UW2VYQ4LBIXM3kn28J6N6ZQUe7s= 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=wLgvbNR3; arc=none smtp.client-ip=209.85.208.179 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="wLgvbNR3" Received: by mail-lj1-f179.google.com with SMTP id 38308e7fff4ca-2e6f2534e41so8181061fa.0 for ; Thu, 16 May 2024 08:08:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1715872134; x=1716476934; 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=GDg+S33WfMWdi2lheaCvuNpDqmP/KU8F5TNkAy677Bw=; b=wLgvbNR3RKOhgFwV1r8erBg3jc0H/XlXJ6EODMTbFjGwOhoMK16+JXb3DeFhxwY926 9dW3sQJCw0DcWyMQCBGPuGFFXTxlRkKVWAAjQRxF8zvxR91LfoHHFYbQTa/C7I3i88Us 0g58nwZ+qbe6t+/PhfAVB4qRs7iyNjnsFBQ3h/H0alHPBfBcQtk+6SYfR3pXqoZBAZNg gqeeCTXe2G77J8A6vIUg08t7LGlRMvt8rn0EwXFl2vpzM97uC6JRjpbXaQaTgTWlxXtI 3BYug6VhDAWUyusOdc0rgzzIAJplr+bd/cQ+VZiRaFpaaRUmGcG6wCy9aGie7Y/5SzdP ltIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715872134; x=1716476934; 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=GDg+S33WfMWdi2lheaCvuNpDqmP/KU8F5TNkAy677Bw=; b=rIWiaseol6n+sGR4xiCR7J9/ovrEXdMUx2BLSiLMh/u+7s6inWhshA17bX7TlvyHBb lTIDzVsJ5jyQ+ANP4JUE+61sXvPXnq6r41KxMV201NF2tH7j80Mn9GodZgh5eep18ZFP AxNvXVBs+zQNMCluKMQ2COuuL7OQ7Qp77zdGe3lmt5+cll4AHLBfGf0UnbbAb4vWbH3Y 55Mvi32M6V43x2Mxc+Mb3utUdk9LlWPZODBtroYi2Uwhl7vttdrTmNAhGVBUbl4KKamL PlUgP1Kkvt+AIWlQheFP9PDBJ+xcbJn/uN6YOBoX57FUiclXyngHqL5ggyJexPapt2dK w/lQ== X-Forwarded-Encrypted: i=1; AJvYcCWEYjZ1yS5RE8AhaBLGKWRNOGvdu4seYK3qeI11IGiXH7aUkeWMuW1n80BseqLHua/dLDtxjn1gv3GVE+h3tmWlpXqh24fEpPum X-Gm-Message-State: AOJu0YxUDf6DBZsG9AEoOqEGOyMHrs+bbZVUV26twC0zcULJTHZHhTvJ /hU33uOwQWQN3K/ufj51pQvDZkKP6o3pvPeImPzkA+ftJ4jiYs/8Pg3SW9xH/CE= X-Google-Smtp-Source: AGHT+IF1dSFKKcicuWhPp02H8rzX/qoi5Hi1Gh7DCEthhD2sCLusrICLNxjBEsCmmaWZJsCyOMO6+g== X-Received: by 2002:a2e:8688:0:b0:2e6:f1f6:7ddb with SMTP id 38308e7fff4ca-2e6f1f6809dmr39824751fa.3.1715872134123; Thu, 16 May 2024 08:08:54 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:1fce:7e5a:e201:edd5]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-41f87c25459sm309351725e9.18.2024.05.16.08.08.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 08:08:53 -0700 (PDT) From: Jerome Brunet To: Philipp Zabel , Stephen Boyd , Neil Armstrong Cc: Jerome Brunet , Jan Dakinevich , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org Subject: [RFC PATCH 7/9] reset: amlogic: add auxiliary reset driver support Date: Thu, 16 May 2024 17:08:37 +0200 Message-ID: <20240516150842.705844-8-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240516150842.705844-1-jbrunet@baylibre.com> References: <20240516150842.705844-1-jbrunet@baylibre.com> Precedence: bulk X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Bot: notify Add support for the reset controller present in the audio clock controller of the g12 and sm1 SoC families, using the auxiliary bus. This is expected to replace the driver currently present directly within the related clock driver. Signed-off-by: Jerome Brunet --- drivers/reset/Kconfig | 1 + drivers/reset/reset-meson.c | 46 ++++++++++++++++++- include/soc/amlogic/meson8b-auxiliary-reset.h | 17 +++++++ 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 include/soc/amlogic/meson8b-auxiliary-reset.h diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig index 85b27c42cf65..4ceb4dc48fbc 100644 --- a/drivers/reset/Kconfig +++ b/drivers/reset/Kconfig @@ -134,6 +134,7 @@ config RESET_MCHP_SPARX5 config RESET_MESON tristate "Meson Reset Driver" depends on ARCH_MESON || COMPILE_TEST + depends on AUXILIARY_BUS default ARCH_MESON help This enables the reset driver for Amlogic Meson SoCs. diff --git a/drivers/reset/reset-meson.c b/drivers/reset/reset-meson.c index e34a10b15593..b5ddb85296ec 100644 --- a/drivers/reset/reset-meson.c +++ b/drivers/reset/reset-meson.c @@ -5,6 +5,7 @@ * Copyright (c) 2016 BayLibre, SAS. * Author: Neil Armstrong */ +#include #include #include #include @@ -16,6 +17,8 @@ #include #include +#include + struct meson_reset_param { const struct reset_control_ops *reset_ops; unsigned int reset_num; @@ -218,6 +221,47 @@ static struct platform_driver meson_reset_pltf_driver = { }; module_platform_driver(meson_reset_pltf_driver); -MODULE_DESCRIPTION("Amlogic Meson Reset Controller driver"); +static const struct meson_reset_param meson_g12a_audio_param = { + .reset_ops = &meson_reset_toggle_ops, + .reset_num = 26, + .level_offset = 0x24, +}; + +static const struct meson_reset_param meson_sm1_audio_param = { + .reset_ops = &meson_reset_toggle_ops, + .reset_num = 39, + .level_offset = 0x28, +}; + +static const struct auxiliary_device_id meson_reset_aux_ids[] = { + { + .name = "axg-audio-clkc.rst-g12a", + .driver_data = (kernel_ulong_t)&meson_g12a_audio_param, + }, { + .name = "axg-audio-clkc.rst-sm1", + .driver_data = (kernel_ulong_t)&meson_sm1_audio_param, + }, +}; +MODULE_DEVICE_TABLE(auxiliary, meson_reset_aux_ids); + +static int meson_reset_aux_probe(struct auxiliary_device *adev, + const struct auxiliary_device_id *id) +{ + const struct meson_reset_param *param = + (const struct meson_reset_param *)(id->driver_data); + struct meson8b_reset_adev *raux = + to_meson8b_reset_adev(adev); + + return meson_reset_probe(&adev->dev, raux->map, param); +} + +static struct auxiliary_driver meson_reset_aux_driver = { + .probe = meson_reset_aux_probe, + .id_table = meson_reset_aux_ids, +}; +module_auxiliary_driver(meson_reset_aux_driver); + +MODULE_DESCRIPTION("Amlogic Meson Reset driver"); MODULE_AUTHOR("Neil Armstrong "); +MODULE_AUTHOR("Jerome Brunet "); MODULE_LICENSE("Dual BSD/GPL"); diff --git a/include/soc/amlogic/meson8b-auxiliary-reset.h b/include/soc/amlogic/meson8b-auxiliary-reset.h new file mode 100644 index 000000000000..0a465deb4440 --- /dev/null +++ b/include/soc/amlogic/meson8b-auxiliary-reset.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __SOC_AMLOGIC_MESON8B_AUX_RESET_H +#define __SOC_AMLOGIC_MESON8B_AUX_RESET_H + +#include +#include +#include + +struct meson8b_reset_adev { + struct auxiliary_device adev; + struct regmap *map; +}; + +#define to_meson8b_reset_adev(_adev) \ + container_of((_adev), struct meson8b_reset_adev, adev) + +#endif /* __SOC_AMLOGIC_MESON8B_AUX_RESET_H */ From patchwork Thu May 16 15:08:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 13666309 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (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 6E57C14E2EC for ; Thu, 16 May 2024 15:08:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715872138; cv=none; b=lEtdO4qe8ii6rFTosSUqzfiHdVzZ2CvDnXK/eATDXt764pKJFrQfhGE4Y1qn6Zisy+nADT54eQHDT/1ZM9pYd1bnsc5/YIk20GMR41JiMJL3tDnJ7mhYz/hnKIzuk3kHnaJmJ97ctfwfenmuCpeheZ9sZSy9ntroekI+3qkhmoI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715872138; c=relaxed/simple; bh=p/YPY8cjy1AkeLBPe0wJNMGliuqwW5LH2qnn291HdqY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TerGZmfC9JdXSU4boMitGHH0gypcqmhhX/O2hb9/QMxjPUvqHTm9yluhs9fgvj+vy4qpYmYZBhdrfBJIhpN3rKjaL+axV66D9A/vZWI0B4W0W5yO0UgyhV9SqL7zNDyTYls8fAOJmW4CEJytowGO/Qk6rt3dQwsHxv8EGk+10eA= 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=FOD90Ys8; arc=none smtp.client-ip=209.85.128.43 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="FOD90Ys8" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-420180b5898so30138685e9.2 for ; Thu, 16 May 2024 08:08:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1715872135; x=1716476935; 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=puB+gD3ay9Sx041zZz0+FhSyarhWutAqTKpIgu3JFCo=; b=FOD90Ys8thMEkMdPY3oNFgRuhC+Xr43s+32UV1ygh2lCl2NaKDdsrfongK/mEZ8FLS N2TuWnETfs2nCNOd8UnGnRO02HhGLwZzLfhSvZPdqZOoWlNaU1a8ULrxIsE/svKVGiJ/ vDL5ReN4LznmB0QaeDxE2IyO4nCJ5LCc5dJbpSL7MLqNToKqa9cELH9f6dJOU7s82KEP 0WvJuRTPG9n+n5GaMQSAh2QzPwilXYHN8Q/hubFAiVOJAMlLJIwIsnNWpILadx0gRwwZ KZaS6vF8C4LB6bLOWnHNlnkdolahbInlyZeOOgG/z6Eq07/6uHLh4n9U+l4FMT9ZV809 d/KA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715872135; x=1716476935; 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=puB+gD3ay9Sx041zZz0+FhSyarhWutAqTKpIgu3JFCo=; b=Y0KdARZtr0by/Ip7SUrEPY5Q4RriSL4hjBuASUqIiDceN6kInijRJXUe+mZIkHq7nH xjfFSMHGRZ02eC0Xe5PREbKAloTnoAQb28CjN9D8QMHghCKKJjolXlSdsFSHqicgEv7p uc/8sREpQRg2rZ3vlg13OXJzBbdXB/dV2kPdoR1LgH2qXeTDUceLWzSSs9Xu0ofU9EqR lQDAYNk48E18XU7u6DK3ILK2h68FGAdWwIq+IrWEI3hxlIrKuTkSLx+jD/u4bLba+6EJ Ts23cJuRUmrvJQntnQQWq0RwbomTmf5zMWM47nwGyoHm2LUq+5jobUGmodRHFsFPhaQ4 c8zQ== X-Forwarded-Encrypted: i=1; AJvYcCU2UiwNBcRxBKtdi3Hmfe9rU3b6Et8tEdCFweyzaaqZdKO98TmvPb0n2tRlD9bDl3FdhFDb+pX8+ekgptAkSCFpf0kVhqMP9MKM X-Gm-Message-State: AOJu0Ywaq3sQMTvq8MNkVQmVFtcaqFtWNGkXmVXwqfaeQiJQR05dMziP oGB3M0oj/VAHX7xBdk0Zv/2HC/eAYfPZUuAOlAPIUrC5Wa7+DzvWuVhd3w07DZ4= X-Google-Smtp-Source: AGHT+IERIDiWGU6HrqYN8ZiuBsFdA4JZIIGZnn0g1+UjHbl3RAe6+oeD2WgCdEHGNIBGCjI44i0UXQ== X-Received: by 2002:a05:600c:1383:b0:41c:2992:a3bd with SMTP id 5b1f17b1804b1-41feac5a45fmr141942315e9.27.1715872134895; Thu, 16 May 2024 08:08:54 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:1fce:7e5a:e201:edd5]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-41f87c25459sm309351725e9.18.2024.05.16.08.08.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 08:08:54 -0700 (PDT) From: Jerome Brunet To: Philipp Zabel , Stephen Boyd , Neil Armstrong Cc: Jerome Brunet , Jan Dakinevich , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org Subject: [RFC PATCH 8/9] clk: meson: add auxiliary reset helper driver Date: Thu, 16 May 2024 17:08:38 +0200 Message-ID: <20240516150842.705844-9-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240516150842.705844-1-jbrunet@baylibre.com> References: <20240516150842.705844-1-jbrunet@baylibre.com> Precedence: bulk X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Bot: notify Add an helper module to register auxiliary reset drivers from Amlogic clock controller. Signed-off-by: Jerome Brunet --- drivers/clk/meson/Kconfig | 5 ++ drivers/clk/meson/Makefile | 1 + drivers/clk/meson/meson-clk-rst-aux.c | 84 +++++++++++++++++++++++++++ drivers/clk/meson/meson-clk-rst-aux.h | 14 +++++ 4 files changed, 104 insertions(+) create mode 100644 drivers/clk/meson/meson-clk-rst-aux.c create mode 100644 drivers/clk/meson/meson-clk-rst-aux.h diff --git a/drivers/clk/meson/Kconfig b/drivers/clk/meson/Kconfig index 59a40a49f8e1..6905aa2f080c 100644 --- a/drivers/clk/meson/Kconfig +++ b/drivers/clk/meson/Kconfig @@ -37,6 +37,11 @@ config COMMON_CLK_MESON_VCLK config COMMON_CLK_MESON_CLKC_UTILS tristate +config COMMON_CLK_MESON_CLK_RST_AUX + depends on REGMAP && AUXILIARY_BUS + imply RESET_MESON + tristate + config COMMON_CLK_MESON_AO_CLKC tristate select COMMON_CLK_MESON_REGMAP diff --git a/drivers/clk/meson/Makefile b/drivers/clk/meson/Makefile index 9ba43fe7a07a..2926a04b6c33 100644 --- a/drivers/clk/meson/Makefile +++ b/drivers/clk/meson/Makefile @@ -2,6 +2,7 @@ # Amlogic clock drivers obj-$(CONFIG_COMMON_CLK_MESON_CLKC_UTILS) += meson-clkc-utils.o +obj-$(CONFIG_COMMON_CLK_MESON_CLK_RST_AUX) += meson-clk-rst-aux.o obj-$(CONFIG_COMMON_CLK_MESON_AO_CLKC) += meson-aoclk.o obj-$(CONFIG_COMMON_CLK_MESON_CPU_DYNDIV) += clk-cpu-dyndiv.o obj-$(CONFIG_COMMON_CLK_MESON_DUALDIV) += clk-dualdiv.o diff --git a/drivers/clk/meson/meson-clk-rst-aux.c b/drivers/clk/meson/meson-clk-rst-aux.c new file mode 100644 index 000000000000..a7cf3c39828c --- /dev/null +++ b/drivers/clk/meson/meson-clk-rst-aux.c @@ -0,0 +1,84 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Copyright (c) 2024 BayLibre, SAS. +// Author: Jerome Brunet + +#include +#include +#include +#include + +#include + +#include "meson-clk-rst-aux.h" + +static DEFINE_IDA(meson_clk_rst_aux_ida); + +static void meson_clk_rst_aux_release(struct device *dev) +{ + struct auxiliary_device *adev = to_auxiliary_dev(dev); + struct meson8b_reset_adev *raux = + to_meson8b_reset_adev(adev); + + ida_free(&meson_clk_rst_aux_ida, adev->id); + kfree(raux); +} + +static void meson_clk_rst_aux_unregister_adev(void *_adev) +{ + struct auxiliary_device *adev = _adev; + + auxiliary_device_delete(adev); + auxiliary_device_uninit(adev); +} + +int devm_meson_clk_rst_aux_register(struct device *dev, + struct regmap *map, + const char *adev_name) +{ + struct meson8b_reset_adev *raux; + struct auxiliary_device *adev; + int ret; + + raux = kzalloc(sizeof(*raux), GFP_KERNEL); + if (!raux) + return -ENOMEM; + + ret = ida_alloc(&meson_clk_rst_aux_ida, GFP_KERNEL); + if (ret < 0) + goto raux_free; + + raux->map = map; + + adev = &raux->adev; + adev->id = ret; + adev->name = adev_name; + adev->dev.parent = dev; + adev->dev.release = meson_clk_rst_aux_release; + device_set_of_node_from_dev(&adev->dev, dev); + + ret = auxiliary_device_init(adev); + if (ret) + goto ida_free; + + ret = __auxiliary_device_add(adev, dev->driver->name); + if (ret) { + auxiliary_device_uninit(adev); + return ret; + } + + return devm_add_action_or_reset(dev, meson_clk_rst_aux_unregister_adev, + adev); + +ida_free: + ida_free(&meson_clk_rst_aux_ida, adev->id); +raux_free: + kfree(raux); + return ret; + +} +EXPORT_SYMBOL_GPL(devm_meson_clk_rst_aux_register); + +MODULE_DESCRIPTION("Amlogic auxiliary reset helper for clock"); +MODULE_AUTHOR("Jerome Brunet "); +MODULE_LICENSE("GPL"); diff --git a/drivers/clk/meson/meson-clk-rst-aux.h b/drivers/clk/meson/meson-clk-rst-aux.h new file mode 100644 index 000000000000..386a55a36cd9 --- /dev/null +++ b/drivers/clk/meson/meson-clk-rst-aux.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2024 BayLibre, SAS. + * Author: Jerome Brunet + */ + +#ifndef __MESON_CLK_RST_AUX_H +#define __MESON_CLK_RST_AUX_H + +int devm_meson_clk_rst_aux_register(struct device *dev, + struct regmap *map, + const char *adev_name); + +#endif /* __MESON_CLK_RST_AUX_H */ From patchwork Thu May 16 15:08:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 13666310 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (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 4646214EC4C for ; Thu, 16 May 2024 15:08:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715872140; cv=none; b=VGPNjJhHHchaS0UGAHeXq1guJvPJ1d8P4JHEv1dSUiMgaVjST/CNHUuS/EQB/gOoa7+TI/xkIk9Sg9be3N1yGU8rcEF3w3eSZqTO/56WzuGtkVNHfiu2M+0AdgBtSFZ9ZvLEvfiHurC6yEeQPPplCA9DLrzIZtP56zKewd8XKWA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715872140; c=relaxed/simple; bh=2Va0ITxM0suedkhfLIJ7a6V95PomOw82XQ9JMnUFjws=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FHuJXe5DXWm3oA/Qr3I/9RAjUNsGoo6c8SGzcyZ5T6pkI4b/CSh6oH4Wb6FgGWSelFpYNRvdv2brlw/tdXVrsFLPCDNHMcK8SqZ412Dh30TvXVyKi4qDFArY6ZKBnF7TrQ5DExwhtutKG5JJTrahEAsEOggJD4FKSbple6LLT5g= 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=PhQN27Oh; arc=none smtp.client-ip=209.85.128.50 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="PhQN27Oh" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-42011507a54so33474365e9.0 for ; Thu, 16 May 2024 08:08:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1715872135; x=1716476935; 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=mL5f80GGi83nhgomz2kgPXZIzOXSZK09LD8gHLnVu8c=; b=PhQN27OhGCBho6daqYyVBWZcGjM1J1+bP11BeXMc86+IgsqsDpHEMWwVmtjEBtcNZ7 Hh9KW+nXAHCBmK9zLZzZR3kUys4pXUgOeNGqH6nFjz/69mgiux/Xw8QHC3iBOQRmDi7w 3csljkYK8A85Bd8xhR9MOnpcodxMM+BCJeXSEi8sSQ6RjJs48P+Cf3wOsrqwiuqjj2rM 2sVcI2wsB/k29G/ax/csPG5pjYGza7kU2X0ehX5NPHRgkCWh8e8JkOSJn+OyW/rJPEIl 3d3dWbIs3m+fkLqmh+IKhRqlGrypnSOAKTPWOVpBDOO7Tv7BoTfHK/ynh2G5n4p61LMQ HdqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715872135; x=1716476935; 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=mL5f80GGi83nhgomz2kgPXZIzOXSZK09LD8gHLnVu8c=; b=JeWsVGdli6jwR/MAycWuw5HUb2GF9z5FRWhXxiJWGyOhGUn49D1VBaFTuMYG9AYdaH 35LFxTAUDxZDjT8uv1NZDbX0ZHwUEGv1MiJ2nskuKDLU0gdE8qKSozzbBVVCRN+RNq/g p80RfAU/8iuei7mwAmqMc/nHvs5zxWNp0iovXI2I9Jg64faV/+gVqf28RaVC9HIJrSOC 4AOB/R8yDzR0QkIrMzTY5JD9d6L9QsJ2JN87VqSVnMnbm15zv2bOFuctXwQVDiznXlcF OuJp8wEm8OgrP436l3qsxlpN+Rh3n97+ng99VMW4kwafsf060axY2dKJ+4k1F2CVxW8J GPWQ== X-Forwarded-Encrypted: i=1; AJvYcCVJoOjKBRCpy4exQechvbUeElK+2twBmg0cFdnUUEZr6ZwybmXXw1eUNlmAhGUDWc2Au73WkEdJQcQgI9zaCW4UXOd/Y/hDvLyL X-Gm-Message-State: AOJu0YwEuJaubpI8f9/4t+eiR0VJTa3r9XmhS6R+KE5Qs9PKEYy1Qcu3 9Pw4PNKD0DG5wivS50Z9DAk3BHPIGC+7aC6NQROPj1viMQHcM3GlCEwZHKq72hE= X-Google-Smtp-Source: AGHT+IF30UqBoIXs9icx2iDgiQ7TuYEvX0q0rV/70GCuE7s1xRKQ4Arx1HOxMSeUsJUlVOSEqHZT6Q== X-Received: by 2002:a05:600c:358f:b0:420:29dd:84d4 with SMTP id 5b1f17b1804b1-42029dd885amr21620795e9.13.1715872135697; Thu, 16 May 2024 08:08:55 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:1fce:7e5a:e201:edd5]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-41f87c25459sm309351725e9.18.2024.05.16.08.08.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 08:08:55 -0700 (PDT) From: Jerome Brunet To: Philipp Zabel , Stephen Boyd , Neil Armstrong Cc: Jerome Brunet , Jan Dakinevich , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org Subject: [RFC PATCH 9/9] clk: amlogic: axg-audio: use the auxiliary reset driver Date: Thu, 16 May 2024 17:08:39 +0200 Message-ID: <20240516150842.705844-10-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240516150842.705844-1-jbrunet@baylibre.com> References: <20240516150842.705844-1-jbrunet@baylibre.com> Precedence: bulk X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Bot: notify Remove the implementation of the reset driver in axg audio clock driver and migrate to the one provided by reset framework on auxiliary bus Signed-off-by: Jerome Brunet --- drivers/clk/meson/Kconfig | 1 + drivers/clk/meson/axg-audio.c | 108 +++------------------------------- 2 files changed, 9 insertions(+), 100 deletions(-) diff --git a/drivers/clk/meson/Kconfig b/drivers/clk/meson/Kconfig index 6905aa2f080c..b89e769a6362 100644 --- a/drivers/clk/meson/Kconfig +++ b/drivers/clk/meson/Kconfig @@ -110,6 +110,7 @@ config COMMON_CLK_AXG_AUDIO select COMMON_CLK_MESON_PHASE select COMMON_CLK_MESON_SCLK_DIV select COMMON_CLK_MESON_CLKC_UTILS + select COMMON_CLK_MESON_CLK_RST_AUX select REGMAP_MMIO help Support for the audio clock controller on AmLogic A113D devices, diff --git a/drivers/clk/meson/axg-audio.c b/drivers/clk/meson/axg-audio.c index 93e6a6d321be..dc9191a9ab0f 100644 --- a/drivers/clk/meson/axg-audio.c +++ b/drivers/clk/meson/axg-audio.c @@ -15,6 +15,7 @@ #include #include +#include "meson-clk-rst-aux.h" #include "meson-clkc-utils.h" #include "axg-audio.h" #include "clk-regmap.h" @@ -1678,84 +1679,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 const struct regmap_config axg_audio_regmap_cfg = { .reg_bits = 32, .val_bits = 32, @@ -1766,15 +1689,13 @@ 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; }; 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; @@ -1832,22 +1753,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_clk_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 = { @@ -1866,8 +1776,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", }; static const struct audioclk_data sm1_audioclk_data = { @@ -1877,8 +1786,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", }; static const struct of_device_id clkc_match_table[] = {