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: 13666292 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 B984CC25B74 for ; Thu, 16 May 2024 15:09:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jVm0DLf8Oepoe2Q9iW8kXrqziAoLljiLA7dGshiTNsw=; b=JhaQPnEry5PCL4 qL/XD3Z/w8sCE7GpoopCbWybjDVYE89fKThmZn97vN9GCd8WC18hBm366r3Npct0b6qmTfjcujIBD P1RpZDYMos4BWKmmL48IiSpuIptDMh/N4lgxu4xcHbVACR/KZULGUCwsjndzyHtaNFgufyfZiTdhn j3hdwILTyeseWlRfYc8lbi2bKtSj2ExSUsgzRIKXh1DKSH/UDq1USIqyvy0NBsc+UhC7DM2WIWExz 0TVtUGARaJ1gLDR4i41fPOsPpHtZrfAxXLH/PsbUFBBJFCxhf8AhMN+IA2XNygPsutdmdAIwGCXQn RznCqMteIqDm0Z46Rrdw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7cj1-00000005FoV-0Lek; Thu, 16 May 2024 15:08:55 +0000 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7ciw-00000005FkB-200m for linux-amlogic@lists.infradead.org; Thu, 16 May 2024 15:08:53 +0000 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4202c1d19d5so5018375e9.2 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=lists.infradead.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=n8o2m8dQUTrveEZWez9Rvt9AmCrkqXaglxPkZS661TR0IJe8C8TuDbmsrhWlejVHC7 mRgqGg5/xAdkmlAIIUdU7q6Wvr3tL8IgoUU7BfdQ2s15Cmv5yov9C9yDYtIar3eZQP3o glqAOkl6OgDdeCTK5lw5kqlpNxnEN+xdVuumagy72DQbzFc9qBfNc+HXWDir7dH43p2q 6+8lJSa9bvjk53/ugdkF4SnZQPoP5OJm50jZBg+o6zkLy1Vrju62XACJ4tlEZ8mAc/sp nKlJE6gqb5wDhEgX2fTINB0jqiMRrcMrv5XPSF0DMRfVoWBbVtNVeLvZ/L8BEhCxFanF yj1A== 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=olWKkRYWxK6wPc8fblz97Zb25cPp+BHrEb/ysKg4ZQDxxonG0vs/tHL+2xPmpBxF27 sM1CaGnFdN6JW/1kZhzDXb6uFq8iFegDtmFSXBKcRtIQ4eY7V7oG5K+TohsFrWof41aP C7QnOEg60OKcTFZNeUXgsf9sOU+xad9F35O7a8UYxUqj4jq6RNui6nHZjFsbyK1+Xmm7 56jk6uW4LLm/w/x2xGWi4ozTr4dp/zMIcNMP6+Zszzd17+0CJ6PAGKlhE2PF+fQ2/IsM TRfaKbrCbkDbz/KHMcs4RpFFNX9esHe/eXCWPJoddSdpnOTuu+hNSkOs4l8O2EdnYmxe CV4A== X-Forwarded-Encrypted: i=1; AJvYcCVV7ZLZFMtB0ascdT33lvzhJuAFLnAPXGuYiAbpwDK15zpnmxxHmlLNVs6MXGsKqLEFRPS0lG9cMpB15QaSHWgsRQdp/Jmaw3EHob8M69WCpjs= X-Gm-Message-State: AOJu0YxEcjq2eV/EkIRsKFc3u3BhnwgpcqenSHX5x5YWMalLdp5sBvNy eoDu794UE4HYnaIoanCKz8NsK5JcodOBHuX/u3RZ9fIOV+8ukcomapDrPGtpvPA= 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> MIME-Version: 1.0 X-Patchwork-Bot: notify X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240516_080850_557534_4A3A00F3 X-CRM114-Status: GOOD ( 17.14 ) X-BeenThere: linux-amlogic@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-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org 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: 13666293 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 7F805C25B74 for ; Thu, 16 May 2024 15:09:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=7mW+Rk2K+u4cy7NdqaHLI7M4FR+qcmWJNJc3iACk20M=; b=HNAhC6XClwYWAz +sLGD9ovOIKIb+TElXuBH6I4T0ScIUb2tHwsnc+1a4WilFA/sSa1EO0DWhGR4rnJ1Ih1eX/cIWeZC ohGbPz2FVrRq9AbGTEFGJovGWXDqm6/cY59iS2tfaufYX4wRnYH+FggJSnegskygVT8qTHXouzHOg ZqnMKJNLifUNFdntd+fk5c4XQYAehtzsy1TfVFHpdbdKO97fl5mvHwukzUKeEsk1UIcGc2xI0w7CP whnk/iUdZSXsBx5UsxJUoRIljJK3Kb9/jkUEDFoso7WEdi2HGr8DVX2n4lh95c4Ehcq7TZLVCpKTI WJ93EvjlqGkBi2BzJ6Vw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7cj4-00000005Fpk-3sIk; Thu, 16 May 2024 15:08:59 +0000 Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7cix-00000005FkZ-0xI0 for linux-amlogic@lists.infradead.org; Thu, 16 May 2024 15:08:54 +0000 Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2df83058d48so11219301fa.1 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=lists.infradead.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=eaHCteu09lb78zw3+Lq3k0kMKn/OAWbP/iJNHNai3/44gqS3teH0HGBvi1kFw7Z5dn m/qqG1jhkQPSEC9kCN3C3XPBem/GWqgjqI0oGsZfvxSnN79rd83m85A9C4KgZBu/18tD /3cuQTO8HfOr5IMJJRBIVZ9eV2hipFjeTWP8NSe6XfTqos3XweCXzRYNx8guUZQe5XXZ IydjP3CGjri4UsUw6G9NYHdLtKhN6j37v8Qh7MtRrqdCdzsMl47i9QEJHurqsiyLPwS3 /0n8UEFZ6mDiZwe6n91GbgVkhAkElOIVn9HQc2BTURe3+/lS3BFG5qfHe0E5bR1LoRBr 29cA== 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=k0PaKXYoO4VOG+nHfwhlsDxcjFrkM1GgQRz/od85EHGl36FBy7OA4EdNzpliZ/hpY9 cOexT41HIh6i1XO3LHe0TqbyxkY+MUlY+4jdtMLQGeig0ToSXmE2BG607RqIqx4NLXTC SuhZ0G6684e11mtCbuFOkDFP3cidEkXQUMDEzDp3SrDuN+SAllc1Mjz8NMG9TxDws4/k ZKxgJDVc2d7KnRO8j0CwXv5hxm8ei0wOQa/s4UzGcs0xZWPVp1C0CGrqifO6owPRX2ar Fh/0SGRNDtYvv4QaaPDHqchlq95YUEwYhnf3RJ3H993uGltO+ds7eJRDAp0RocOvSiYA Agbw== X-Forwarded-Encrypted: i=1; AJvYcCVuc+JOp+F5zAQbFnHSgrt4e8xHnk2K+SbmEnbzcfDiGK0giDkHsgDYjXNDk5DtTjszzbcled2f/bxuLUbftw+Rnx1HldM9nMhaFcvFMtgvNeA= X-Gm-Message-State: AOJu0Yy5nIr5q+NTpeaDuueZaSUEDAMwkBpuqYTScK/rSbIk2rkXvYkn 31WJdJs6ZXznUmCBxLGS/TH6cu/Mm0jROn+pM8M66dK5/JeFIkj+Zb14h4/WwkA= 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> MIME-Version: 1.0 X-Patchwork-Bot: notify X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240516_080851_369071_EC7827D9 X-CRM114-Status: GOOD ( 13.16 ) X-BeenThere: linux-amlogic@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-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org 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: 13666294 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 36A53C25B77 for ; Thu, 16 May 2024 15:09:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=iofhkf40duATzvgTSspYabpYCydyo/98mEeXcsbsCiU=; b=GJhNqP16mf2Kqm aVBQrsHdfmOi5MbxrsRAj4TpLtfm23XTMqgsMvtKunI2O/FM3Ek58F36wNv3TE1JUHAu1vLaGMRYo N9H3+bY2xAu/ak+DR/ddN1RNU/PvDLrUrtE+s7y5CkVYnMNC/9QK5SsMP0Ct9sOL6cWjgK7MOHYRR DwUO7+oP4Jtb0g+DXdILRIeYWIgjhv1TObhKl1RlzAWLc+orRdQmynmxjc4q1/Be+Z9+APqDGbhMy OfzJrVA3uSDAlCJRokVZ/3AjRc5RTF0vm+V5+RdRt2NLRTNKo8R0BEEY1VONYH5qsZUKSnMPdqlz8 H3u63TIwSddbwdiMp8pQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7cjB-00000005FsI-0IZO; Thu, 16 May 2024 15:09:05 +0000 Received: from mail-lj1-x230.google.com ([2a00:1450:4864:20::230]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7ciy-00000005FlF-0JLA for linux-amlogic@lists.infradead.org; Thu, 16 May 2024 15:08:54 +0000 Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2e43c481b53so10198101fa.2 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=lists.infradead.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=VN4TZlJNCM9/pQVp48v+pLj76vLGIHocNXox1aSqFVd//sfeX8kzmFGN7tAJFm6Bq/ Syx1YgfM4yGtJYd2eFRpIfnSYC1pdllJQ5e8Ui0H/nyIocLkn9FQUXj/LkkNK8QSSAAT 5RctPTk8cRjh2dCGC1WKUnxbBJYjnxnr8nE9DOI9ISGKmV8u9GI4F6t//wa35mQSMMmu e7Iw45Q5ZBEjL16E3ue2eJNRseYOTk7zhhJFM2tTQLJhRXtiYVmpp7tQO7VwNnY0qDaE M447+H+QxpJA0FEoUsumWwJgCt37GF98Zc76KJmccDqY3XYa7QnDZhwrvZIoBH3OoY+H n8hw== 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=GV05nkOECeFx6OAd9a9CeFtHoWX8MG2Kir8gcCVN587Fs+E+C6mSlgc/YA6gclqFNo JvC7hZROCOobf4wTBUT4HUjicCPenlJ08QOxIxhYCE387omkYXQspyORUs3VHUQ9MG7y fkv6hVcJ9HirMnz3OnC3M3dz0eJq7yrnkb2WY7U5F6EE+XnSJUXVK0sDDiWIdcxHKR+n ol/pjoOcVVdm4HW+JrRo20dL7heEfhWbRQG5UcE9fQMP6Pa9fU35cFGQtuQKPavXZkvW Du1k4gSSTWyCtI2Xpd58jSeYMjXjKvA8KxNoNB6HGRK2o1Xoas3T5F/yNGyHJQGfb0up 3pAA== X-Forwarded-Encrypted: i=1; AJvYcCXZc5mPz3pQOYjJYhh1w1wCNVHDvVNCQhI6QiKWpJVTsF7EXHLUzrETqam8Nn4uJvxJUBpizmHbjASCiZ6UZjjWwPmohoE8NDkY6Cp5MlaXI+Y= X-Gm-Message-State: AOJu0YyaVVaOqf+JLecGWdA3z3903JEBlZF1VNf/+2E2H+00yHbwtgVv 6dIw28VVItVeJlUFKGx3yLKOEpU52S4JSKnAzcXYutl3CJXqQA1UW0x/q/hqadE= 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> MIME-Version: 1.0 X-Patchwork-Bot: notify X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240516_080852_442044_6E3F5A74 X-CRM114-Status: GOOD ( 14.76 ) X-BeenThere: linux-amlogic@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-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org 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: 13666295 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 76128C25B74 for ; Thu, 16 May 2024 15:09:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xVlIKmLDZIE+els66MaH7ImtNWryk+VMYYbe74arcKU=; b=CQvcBowmJQOD0b vc+LnsDpo6cngNzm6EM5DuDjIGm8yPtAnyN9Ej7Ah0TdhWPhcpy0kfvIZXGyP5m+IeqChE5ulfB/z T70q15nNniAkUxsOX5SwhW01ygDuwvxtrbc5K/Y8XaK/LihAEG3x57jWkryXr14NZI06MWlaZUFW5 /1uvxHwZ5MX6I1FLCaT13Mo5jFev5KcL8ykNDtOl5yIGrR+ZzlG+fUyuwp99I9kg5AYQ3ZzA18MKA 9X7hEyXIyW2huim4sRSYKg6xmKFmwVe7MP3gAMjYo0siLqhibMcRnKOB7XenQbiYwQQjCu2VG8Jn/ a6C1DtUO8qt31IkXSLKA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7cjE-00000005Fv8-2VuJ; Thu, 16 May 2024 15:09:08 +0000 Received: from mail-lj1-x234.google.com ([2a00:1450:4864:20::234]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7cj0-00000005Fmn-0zVO for linux-amlogic@lists.infradead.org; Thu, 16 May 2024 15:09:06 +0000 Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2e271acb015so12135651fa.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=lists.infradead.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=g1g07MYNF0iJbWMxILTJfB651W5DdorvwUJyuk20w6KJCXfA6KEFssVWgcNuqLDBMm XplUvpUJKGRK9CChzuJ3CbNqtElK1t9WHNa7U5khPf5irGAPNRDrQwt1rfaGEJD5hSXS 4Nv1AqvFK0KozN6qIy2fW+Vo/82M2RD3clDgITD4EKMF2hMliPRBEDNdKSXMVzSWF2X4 BHrG64UW9klwMd96PWvfLTvSMZwoGBOPgHvthxLGHpT6bqmF2vg1gs3QxvIiuqvgv95V vGQc2Sh4yW0e+ySpFHNnaAtigc2nCEYU2dVwutZv8Z9qm5cEeuI2cRTxT1/dxJsbsmy3 dYzg== 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=EwaGWlz8yUzqL9/MlLvLWT0WxmkcJ6ePPQ9hc7ZJk2I27KPefqLvKno2zd4cfItS3Q mZ+ykA+iy76dqrfVG39GipygnVlDpI+S4kDDOR8RMq3tpamp2f7Mf9DHuUe43j8xs/xc zSdcdGW4cQKpeTzFRExk82TgbGb9SQYqc3GmpQQCTtCaS/EPTgOV2aF16Y3qBVROw711 jXsyieiAoztbs/LmcLU8g66lipRMcJz1gxRAy1HpfBWFZj/xTqKUhopHw8Yck0/6w1bU 69k9suAfjBHBre/l5mJ5sRi4nkjZsAU3HkGcELQuDI6W+6kTQEuDrK00AAaWpQf5TYPQ Hb5g== X-Forwarded-Encrypted: i=1; AJvYcCXzDYv0jbvfR7gl2B4CG79AvgsP0AAwKdzm+/JaAG1Qj0NOaG5T894xY7DZo1tsU8sXfcRtbwNZI6TeflPHAbapQ+j4TdR+C3C//16Ynfdfzhw= X-Gm-Message-State: AOJu0YwbTJ/lbiehjG2EEHeko4MDv0q41bo2gbxgdmaBARDW3MuT3oCk 3rX6PlrMqdVoKsvEMng9xd0dyQ5aE/era/3l8YVl/lzCGweQIIkZ/LEs8VnFAO0= 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> MIME-Version: 1.0 X-Patchwork-Bot: notify X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240516_080854_323988_59FB3044 X-CRM114-Status: GOOD ( 12.14 ) X-BeenThere: linux-amlogic@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-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org 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: 13666297 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 B88A2C25B74 for ; Thu, 16 May 2024 15:09:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=eGGLzhQr5Z+GRqrh3Xc2CrUvqWfy6YjxY+0UGmt/bkE=; b=HZJ/IWzNDe1hwH M62Qxns6j4xh3kanL8hyFTt8LWOHHnSWkcuRhbeDswQcwMdoVmHHJRRqawo4R4lpV/kW2FG3jAXrf hybWK0Y/W4vFmToDSvJrK6j9H2cc1mx8hF3PIhirXZz0sMiYn/eJFfjkb85/i7p5bdvsztHxsPM1z 6EFbt6tie+M4ukdKnNFk981LAxS1EDY7ZjnC9oWUfl1tqDhVMUJw8ZXDPmZpgiHCG+BsuAyEfFi2b 0S9wsKd4z6if0MR1yXbveD0kYZDmhy0i8GTUsGGkl78Fto+cF30UDjvyqpZn1qzponM6wqG4WJxXZ KcaxRsg9AxZzFxLDNnlA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7cjH-00000005Fxr-3PHL; Thu, 16 May 2024 15:09:11 +0000 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7cj0-00000005Fn5-1bld for linux-amlogic@lists.infradead.org; Thu, 16 May 2024 15:09:06 +0000 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4202ca70270so6535305e9.3 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=lists.infradead.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=WyGQv5fQl3vtgVLm3LjjjEwEgEgtM0Oyhf7HSbdypOBQrF+UXliakKlzLv+4YZKu30 XFpNC+wDmFC7B/+jCEkXsru2nSQ7yw2/iV2CQVIZ+0c41ZqN+r2DmdqGF10SWc3Av1EV 40SPisvFOdMttCWAbGEWS6AvhcKtz4FALjrRHYiMp5LWe6tfWogN7MkeiHhUGkY2OZ2Y JPAG+sbxOD3UwBn0AEt9K7Vsi5h9hdNJbJXk7CMQtLetitsIYBepAhqxm8PDpI3uYP0t MPqJaPN604sPzbjiFzcS0ZKzrWsddnAirv1twKIbc73E0h3OffvYujgk4FQ6z5FS2pet lwYQ== 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=BoaFsoshXJm60T+Lv7+re7bNxv84z7cC1jPiJC2HjRk1WGh9fRQHV+7lZsnB/zkccl 8247dqSEXIbpQqGVex5NI+d7oOv9FfRMoSmnSBIG1HBxF8nQEG/ESyn62bC2fXBg01qr hBJ2T28dXPB16lLImXnz6Aq0s4x9mGQPhZfB8eFswZA5HpqDoDkL6MqzfqvHSwm1I053 OEYHuu0XnzxYDZT6rgZM7IbxHb3GOh7Bux+80vYXVxNy4NtgKsPic41CbMcMwfCruCa2 sujFB0fnCFvGNPktoeSOFhG9/3yk755LUqHO7XHRKS6//Un5uRXzt7EYOJrupMDm+GbN irWQ== X-Forwarded-Encrypted: i=1; AJvYcCVb/+on7ntfSDmae1SCj6t/KULUVBmd8pq/n3y9Go7ZhZgYFHUlOELuO1kM6pgYaZis7LgNIowIuXatuqPtWRXV27HeNoFOmngyyoa+wJedqYs= X-Gm-Message-State: AOJu0YzykR8ob5PooeBUY9eihR2U7JOVVV0iPc41QYNC0vjUpiHB+eIv 09Mc3EjLHvfhGdtVzX2/MWjOMmXobfuTDdWBtxlRS8pwJWKK0ug3131pQhmPizw= 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> MIME-Version: 1.0 X-Patchwork-Bot: notify X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240516_080854_497353_21D3200E X-CRM114-Status: GOOD ( 11.25 ) X-BeenThere: linux-amlogic@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-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org 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: 13666296 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 DCF3BC25B78 for ; Thu, 16 May 2024 15:09:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=obQZMNvYV5g+l23JY0xQUc2Q+5Q5QwoV03cvl2jeB8A=; b=d3rnR7bO1ARlmL NHasBRj8QWbiWWJjrrmd6jle2HmwOZkDT5mk6GtFxYGs7owky+dL4i7w+YyMuotf1c3dfqNDyaL18 51l9JjnsfMgFuxAtvnKdUBUnzf4inQy5Q5SUWojAnTppFhHGEsFfwzI+K3Tz8Q5o0oSc211v2n3NH +qPui/y+RNxQKUBNFAQkYGP4ytlZQ3akiDm/2n68hpf7CqYyX97CSAKZ0+OP8e8sk9huugApJM78t tLRS8rgF6yQYi3XeYuCSVSRByrVDLlYS4kxlvse4K0i4PNLJYoIV1TT2OIAN2qNiueCrXh3JDYR/5 uaX459jg7YpS2oAwFdGw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7cjG-00000005Fwu-3K0m; Thu, 16 May 2024 15:09:10 +0000 Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7cj1-00000005FnZ-2gUB for linux-amlogic@lists.infradead.org; Thu, 16 May 2024 15:09:06 +0000 Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-51f57713684so1343857e87.1 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=lists.infradead.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=JLJmkEmSSQf1h5RJdEPLLYGWgsZh3ZLO6jFP2TMj+L/o0A55nYLn6TcuZDpdMTzGvt unhX09isttYay3M9pCsq+GLHWvvyi78s2fUIwrOgoX0o20DTVmaBkPVbKpCEPDz8P8NG EtxzoyFqY2p9eO4KHSSNhlP2NwF9tgjiGdpIR1JeMn4GMkDaGgDJcaYMPp/3xkVDXjsX o/hhcgbJZ/+1p05+bHrdvVZwYfN/9mRxd0NneJp/sUdtza2qP73280bMFZsatFkFCrgo g5zqVfkRIiPUt96BrjFXL1qUDiKsDaqxFJM1BXH73g2VEufj4kkhhPg4NzEX0Wm4g1ab WkAA== 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=LQagbvfLdJny7CkHSJt96LL95NRiPAfb34ZrbgKK6UxzjELF5P33yWOiOzUTBPXGGL A9YOfk/IHKc0PMDaDAuRymUNaN4H34Uj3wpJqnfXZKw0v3XYRBXS0f/4lVNrTFpoUO1t 6CRwexM0Q1QJwY+F6i4X3SPDGa/u53gl3zyRnPQs4DrXMrZvc47FbbiZ2EJ7BPUND6L2 Gd5xeE1iRKYZt+hsH3ADtc0KobF0QuRnOUjD6iURpbJh3rJBBA5TDvd8C5s2uRW3/JzK mU/VMwGetTMNiUBrc5IQugGejIQXmfA6Y/gi9IE6sQ5Ed8IKP3qMhS5bhzQO06TGW7JW ybYg== X-Forwarded-Encrypted: i=1; AJvYcCXo7vlcip/GxD1eb6jekWtqf4b8gMREq49wF6CHAZS/NKPLYxB5kaQyfL1tDVB00eiKoKrLR2f2mTINzjweOu6sHkEV8u7PIbm/Je++X6NaBoY= X-Gm-Message-State: AOJu0YyaSuZ+S8Ihl5rjd32jeEiuR4YiA7eiHu6+vzR/JTW28DY3OCSB JmckSQ3yNQGr9bKS2Y5VSwXMfFqRD/sbV+miDuUYh/287Wx+9V9cD4QgxS2+IV8= 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> MIME-Version: 1.0 X-Patchwork-Bot: notify X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240516_080855_773738_4ADF8E5B X-CRM114-Status: GOOD ( 13.24 ) X-BeenThere: linux-amlogic@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-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org 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: 13666299 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 391ABC25B7B for ; Thu, 16 May 2024 15:09:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=97K1cgbXSEA9G2TnZ5fMPjYNqiyZHPRzeQ767KaHH7w=; b=C2n7wSRL8NSDNK C4XCbcmoYrYB4d93LCLQvGOXdqlNKIoHrdD6IvWXzxtnix1p+geyvSjfV87Is/iA+7Kpran25pGzr 4vD24O8oqskDNrmD1K8rJ1ZQ9CzW2wXt9IJyOiTY2VJfICDGhcHWfNeTBUNlbLt16RmUx80ujAgnZ wZ6jrpSwRLOshkm92GbleoaDDliZPwW2Bzb4bYOktq4q76+plehS2LCDr49TXfbIe09X6QVqVimOy xUKa9t9LH84xiP34Rf0nouZ3drTXP9isohXIKmKPdTxEG2tEJ0c4XWQv6qwNIH+yRV/pNeTJKcya9 xWlcED4Md1eCuwLZfZrg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7cjK-00000005G0b-41kf; Thu, 16 May 2024 15:09:14 +0000 Received: from mail-lj1-x231.google.com ([2a00:1450:4864:20::231]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7cj2-00000005FoS-1FUM for linux-amlogic@lists.infradead.org; Thu, 16 May 2024 15:09:07 +0000 Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2e6f2534e41so8181071fa.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=lists.infradead.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=sXiL0bFR3uSrqdZK8t3E3jSdaAbf+nYcJDuxqHhZeqIRcyEygcV+eJhVqEZyaIOIXf qEWOvjg2Do5taOY0StvjmdMVCCm48qT5VEqjZu42cnDHllM3P5514jnoH0pUbGPKUw92 HbgN48lb2l62xLrWv2Mqf6hc2uAI2f65Vd9qySlAIK0F/t5OM40rRv8umDsZKUnvaM70 jrWnEmbd6/gomZV47wtodU8CrjdPCDSpCv3gwvQSgGHXkz/FbEdzQFI2+Dwv5MX5/Y5Q iQ0nTi0/eKwcLka+oTjJ3/7tLGzPnyhrxD+yDHf3TM3QNMen4eDO41ekSD3Iu3YSeJPp zMAg== 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=p+eUUN55Q+xwZS1EocLm/gBLHgssbknNObtdUPsOJYyjwHUfONPY8ZkAEFFS2oDBX6 Sl/sSXgjSrcip4sioRCswftoT2YGiHiXTIJl8jSRuTdrwxlwQdDHLuJ/rvUpj6PFaaRp d4o7+5p0E5og0QKM3fuoIFGYQLcYxbkrd6ZY5Y+d/eJf4tS+8yrwcP7ZZQwz09ax/3Dp RemnU5+aD09Shs51bQqyWV4mBKQ8oWCu97RBGXbc7V5eA5ephDlvAmyb5B1v2QB47UQs y7/cGXMFz8VIxj5/plVpiVuy1yqW8FmJoajJN0F41qW23koBWHtQHBB0OIdWJ7MY9W2y DwBg== X-Forwarded-Encrypted: i=1; AJvYcCXoK3sNTnlzXVTrSOzz9/KxrUpWjTMNbMMVgRmNRE2QR8UczCDRoKPESJTSdH7AVlX9lgNCuNj+Vghs+2/dKG5Sd4sRWppP43nLWx/wjoN+HSc= X-Gm-Message-State: AOJu0Yx7Dpjm9XYdZbll+eOIXctin33iRKGsjkVYkwoEEGYl2RxXz5xt hqiTokCpbJ0MLdwx9S/tkEn1Hqzm0YYo4GpDhKY41KRukLv0FVLxbl01gekgGKE= 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> MIME-Version: 1.0 X-Patchwork-Bot: notify X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240516_080858_639470_4A437D7E X-CRM114-Status: GOOD ( 18.98 ) X-BeenThere: linux-amlogic@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-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org 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: 13666300 X-Patchwork-Delegate: neil.armstrong@linaro.org 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 1A6BDC25B77 for ; Thu, 16 May 2024 15:09:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=sm27MZZfcVKLsNliEp7j1oq4GVwiEAgscXDzAo0alQM=; b=36MyATxapd40Of Q1SdTHNFy57F0CXnBobQzmVqI6FPzvMMbt+34VGwSUH1RYYD9nEKyMBPkVA0AmlKLR+moVSKM/b+e fjI+Qe9MjcgTsPgXaAw/GCBLDvSEibgp7IEGjpALDz3/X+XSG6z1J2pVz8lR6FzeTeo4/RKSV3m89 4VvOeCdw39oRnbgBXdXfVcodfjN6IDawAJZPGmwSW9UJalQuh2Voosg+YY7RewnO8gI2nSO35Hbhn ZpJe8OXW89VciVdPsFuluTwehTxG5XTkWyyNWoqjrx8u7pAz1kVLBZLO4qmwR1mN06ACWNT2gp336 W0ICZ3F1XTPnaKkBCGdw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7cjM-00000005G2H-0k8i; Thu, 16 May 2024 15:09:16 +0000 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7cj2-00000005Foo-0mQW for linux-amlogic@lists.infradead.org; Thu, 16 May 2024 15:09:08 +0000 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-41fd5dc0480so51936695e9.1 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=lists.infradead.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=EkOXrOIZgaa+1ypcaBTA8T3CNGO+85upE+zKzZN27FKjRStmKEdHP4UxA7Do0Rc+R8 cnaAt/eMQgDzqCWpPnuM/X5n3zyo3jPq+mZ7EngcdQw8tBHfzDpShIe4aTJChJj+C6bX ieyxqjt4b8cQTgnXGQqzFaK+e7BlEwMxZxAsA8jNnLhcph7TRrA2XJelkFBB2aIdrgD1 hv/G3SmLVA42+3EtuXg5TQE3LfETm+MA9Ap03rVXYKG4azMDkC5gh9CxBO4daoHgtvtI 2zKQiyvUz0FH7tfirV6DokHwrvCi1pbf8rGpWqeNIxRiQeEb6sfliqLoMpSoV6oHmGYZ al7w== 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=B8U5JjkFgGdP6bKs8HnuDt1iu8WDe8hxCFFb0gjMJk7z3liBolrXISkQX9ecV96bTl xvVjSvWy5IoJeoDFbuuEnhVOC6+rM1C4z6+usxUmbNPbjuPnFfCeWWGk/m/N8tjP6bBS 7Wrpe39bDz+qNQxZ/BbPU9ZyMzN5zdfVpt3ElWiI141N8paRRnRQ+TxzRYGyML4Qolhh dRCYcnS0Vc22HmYuFVYPjow7l9TqmGDjTbXIdOQf8I58PDpI6hnOuHOibLmA4vQTvFVi +KR8KpiUcds/byVvmJr2M0Mk32ppXGKwqNrbd4dcD6hM0zMfKIthrhtNCELi4SYA9PU1 3iig== X-Forwarded-Encrypted: i=1; AJvYcCW7obR2HNbs3FfPOIFSmu0V/G7Myle6+nAme/LZPRS/RGT5Xm7gaO8OV0eSi9O0y2ypvTLR/C/2pswBqk6G4cdFdH1Bv7DadVR+zr4GsPfbE7o= X-Gm-Message-State: AOJu0Yw+6FbvIEFrE9I8/O+0buIl7fxGS3ZiIWIKQ2zVcruHt3tuzZCQ MxadBU8/NjoTEiNul5jBIj93lyQiigUChLbND2OMWtNWKbUH9JYcHlqpbbUYv62ZYQ9hdSYoene n 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> MIME-Version: 1.0 X-Patchwork-Bot: notify X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240516_080858_649041_80C92B24 X-CRM114-Status: GOOD ( 16.23 ) X-BeenThere: linux-amlogic@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-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org 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: 13666298 X-Patchwork-Delegate: neil.armstrong@linaro.org 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 32111C25B78 for ; Thu, 16 May 2024 15:09:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8Y87dbjna/ehEwJhCrXn5lA+j8lJhpv72t72XDRficA=; b=ZH0ovJ+rY+55UN SPoQSdModG3cDTcfnNIrYfrG8+ggiCBSIKBE68nPwqZYPppipalwbRoPb3TcZSpGGjfuJFeLWmabD mo5S446g6dENSjUT182DlPuEq8qPtGTV9jcFHloIJrI+go2FJd44inJx5q4hvnUzfca5ivrPWJqcs ztDU4g5Avvx6iVvZMCvr7lQiu+JyCzt9tdG0VjyBWgOuDqKVeQDR7jyqV/rpnw4aFg+nrpXDDPrYW +8IkPurH55Jtfej9AokK3iM2gGgy4TmVNiKSN4ZQBZfXD0WviE+gwwteJ64T5jclDWhp99TcwhB4G V3uuPIqzOG/tP7hM+MrA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7cjJ-00000005FzE-1Spn; Thu, 16 May 2024 15:09:13 +0000 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7cj3-00000005Fp7-29WD for linux-amlogic@lists.infradead.org; Thu, 16 May 2024 15:09:07 +0000 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-420104e5336so34120525e9.1 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=lists.infradead.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=gi0vppS+PpDcoLqPvSBQrp4mTLY2t+7wFVgQD4/IxUj8GlhY0Ii3C8ZqSWbWNQpUC2 AX03gCN8uAGT5jf8ue/eirrkVEcbvuJlqjXn+BXaZ0pA2h1Tb8l4M/UPFq7YF4zhQ1TR vOuKFwjUi+n7bDMvaGq+fwA9IqS1Q0VAGSKz+mOvR2YEp36HOcKs7/ZKd3kmacH8wj65 dq5Ldron3YyUeXG/VIPMVUJBy8BzmUHVZ3tmZvv6q7SEVD0oqBIvGBzP7Kz9xper/Vg9 N2qV+vnHt6VbG+At1NgLwtD0+iPe7zWfgA3Z+hswYShLrsXdE7eE1+QIgEskipMnFw33 8sWw== 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=TQfRbDaJxrBfW919qySEI5w6XhJI6414vxSgQHp7bsGMJRz7NH/oCpoDDocF9/os+k faLfTs4zqBl/TiDDsqDZz3HXRNoFSBcODRa4Ae2Z0gArOYOpqN0LxLn/pyoQkOnmptbf 56aND3CjHkiJaJl9x4y9Q26OO8HcfWv7fGGLQ2DvNUiU1cEGCyffJJRh1UpCt7dwkw1d l2nHs2J2v0TohcIAgfk2dKwySBACv413c/JIM5Kgz/ERClUCsj3jv9O+l77ykMirQnVT GCEKBqxDbRSA9M4cy7MDZJL8WT5wUrc9OdJXDTdm0SKMiCmg9V0P7yENsSgqUobeyj0F IpbQ== X-Forwarded-Encrypted: i=1; AJvYcCUmrAUaCV5gy8mWZhSkOS8BXw5fp4oDZ5mTIw2ZQHWBX8JVjEwKD2CdMzkNJuZ0sho5Xg1orQU0Q8j0OjijvLqLBcPrcApmPyr4daT6hHyUhnI= X-Gm-Message-State: AOJu0YyCcyFzmhbR8CMatJzCLICR/+h9x2WAXc2OlISqakd7nw8rw63D 0djxfKKkCp4Xc5nVMYY8OlSmQsWgRNV7bqpWO0xyluzwqY8rbXgb9my1D7En+EI= 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> MIME-Version: 1.0 X-Patchwork-Bot: notify X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240516_080858_725691_20711E60 X-CRM114-Status: GOOD ( 17.67 ) X-BeenThere: linux-amlogic@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-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=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 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[] = {