From patchwork Thu Aug 8 10:27: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: 13757202 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 A78C7C52D71 for ; Thu, 8 Aug 2024 10:28:13 +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=jJdHaHpHg83ec0eqpWsje1gDZpJkowE6En3uSQLPi7M=; b=UEXv2qC9pNInzM YbaarbAtPLyYFu1zkPpVJThPciTzG4bTZCCKvhAKRYOgx9gcNJ5W2P6/6XgLhjGx9C4jr5JDDeQKl JTwenn3fDGBlghJiMICTBWbzUAwVkjiSmCc3B/j5VEPdjZdrY4jUHX/4JFPHaLleJsU5AAj6PsxlB 8kcAka0uhFLl/U+rYBHXW29aF0pbSheSFrI+7TFUWdG/cEi/2VdTWS9lFQNYs5fY2p40Au9nYMKzh aDsBEOb79/U+3DJgZUmBSuyw8/3amNbWqjXFAnGeuMcgCiJJV7VNZ0zk8KTlgZ5YNC1CQZ6XdUJSz aJmDZMLjw9n0AHanOz1g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sc0NK-00000007tKK-1AVN; Thu, 08 Aug 2024 10:28:06 +0000 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sc0NH-00000007tIs-30P8 for linux-amlogic@lists.infradead.org; Thu, 08 Aug 2024 10:28:05 +0000 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4281d812d3eso8030905e9.3 for ; Thu, 08 Aug 2024 03:28:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1723112882; x=1723717682; 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=Q3DHNRvZJ0qhVqYezcY5P08/4agts36gA+QW7VdWHFk=; b=xeVuSobk52ouAulgjFcG6LOK1rUnQ9r6VBYPUQzZQPOgztqdaLJMKH838dRgBQQURV PuPwJ1Tu2GsaVQNs0wrpf24fjTLsaAUVS17iMjzW0pG3gCkmw9Ofd8+uMHyTCBaNxDHv 0S0dHDIUjZdGEAU+x9PNaNQa3/ZB3SHAxgq4cDG/5MF7JtP5TqgrVfuCy2LLXIMUugwg VMoqqfl3Z7xJOwLQSeIbBHaS01QeKfLK5MgWCT2hA8gEENcRolm5uX2nLY2lpNHPW98Q 06QZG6XVQ4E3ubnYXOXt2FLj7xQKBNvOB06w2rjLT//x6YmTdLgi0S1UH0dX+x1T8VOy bnbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723112882; x=1723717682; 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=Q3DHNRvZJ0qhVqYezcY5P08/4agts36gA+QW7VdWHFk=; b=LNg1bGFiuFGJsr/osiljJ8vaeRa8+gQrkuJOev0dPO2+EQ5nRqt8QEzarxsBx1CXw9 XA64NTyHnFqUKUAHMidCrdBg5Mde4MCU6GayrkVo2B9Zv+U47ecdg6+QdcYHhzpcaqET 3YHTDmzSX5eDj7D/Dt+G9z5x3sid/mEDuQukdLAvWAW+irWU4uD3XqfCt7Dtxt6pzesY of5fKvFHpXpnymvLd2BPwqUNUnqpUP9PFoQ27dZFW9S3lGcXSkGtgSPo/jqjIrqn6Uvn mT9SiR20n4+5u2WGivwf/jEu9uMsH6fzwebMTMEJIeUcsaMjpzpPBBdS2NJ+3LI8o2Ar SIog== X-Forwarded-Encrypted: i=1; AJvYcCVP2fpDi+A7QLaMN2x0yPBrRga27P+ROcT1fodQ3aeI8KQ2T2gHTPrwMpHpDQo1FQjEaYrEd904Il5k5qhUrKOY+6Hh+8FRfzm2Hup2qL6X+ZI= X-Gm-Message-State: AOJu0YxfDN6RSBZvEjG6DLC/55SGdyNJyTrZ3cmV0uu9su+GpBywptVu jHauMm0lWan6Wq4QnU3n8vRGSNL9YrTpm0jl+omeRSL9c3TeTdVg3y5pinrpMCR3bAVWdEtFXqQ nCzU= X-Google-Smtp-Source: AGHT+IGrQMQ9Wgj8GAuLCg2l16C1IOiYtKXoO5s1FPVyD++kkP2maHUyZrFQlTnKv9XjfgZ94mwS6Q== X-Received: by 2002:adf:a356:0:b0:368:78d0:c240 with SMTP id ffacd0b85a97d-36d2751ce11mr1193495f8f.35.1723112882103; Thu, 08 Aug 2024 03:28:02 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:ae7:4e79:8821:15db]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-36d27208c98sm1454596f8f.75.2024.08.08.03.28.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 03:28:01 -0700 (PDT) From: Jerome Brunet To: Philipp Zabel , Stephen Boyd , Neil Armstrong Cc: Jerome Brunet , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org Subject: [PATCH v3 1/9] reset: amlogic: convert driver to regmap Date: Thu, 8 Aug 2024 12:27:31 +0200 Message-ID: <20240808102742.4095904-2-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240808102742.4095904-1-jbrunet@baylibre.com> References: <20240808102742.4095904-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-20240808_032803_779258_14FE2B5F X-CRM114-Status: GOOD ( 16.99 ) 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 Reviewed-by: Neil Armstrong --- drivers/reset/reset-meson.c | 79 ++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 36 deletions(-) diff --git a/drivers/reset/reset-meson.c b/drivers/reset/reset-meson.c index f78be97898bc..b47431a21b86 100644 --- a/drivers/reset/reset-meson.c +++ b/drivers/reset/reset-meson.c @@ -11,36 +11,43 @@ #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_write(data->map, offset, BIT(bit)); } static int meson_reset_level(struct reset_controller_dev *rcdev, @@ -48,25 +55,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 +108,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 Aug 8 10:27: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: 13757205 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 1353FC52D7D for ; Thu, 8 Aug 2024 10:28:16 +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=lHPFsAgQRRjNHHU8OkJZ+Yxw0MJtT9BANT6+tnZ1GFE=; b=1PArpEwKvDu9y3 WiZxOT4uFHR2zxL0o28ZBQXVqzVo8lAc5pPZoyVEktR3uC/ygw/XukB+j24opiyotr6cSOaUyEbgK apFSjU94ZdReZXx1WKi/ZpAn6aMnA8WdsycdVpAuibgd0BsV27T0FQqW7hWI2LpJqFQnnDQV7irln DWbdaQl2f4PA6PWFwAzla7PxtYZ3o6eYXDJUbFeihzKIXGARcxg1bf8ikL9EpfPP5GZsfzft27U47 Iqaz+nPaC1j2geJmYwgk9BEJwQQpe3fSYKTtOhUe6XTw9jVDq04JVHO/pJmqN5D4p/jqaoZxOqQ9i LPOcegxw4xsjLQ2psBAQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sc0NN-00000007tMt-0NGV; Thu, 08 Aug 2024 10:28:09 +0000 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sc0NI-00000007tJB-2lox for linux-amlogic@lists.infradead.org; Thu, 08 Aug 2024 10:28:06 +0000 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-42816ca782dso5756485e9.2 for ; Thu, 08 Aug 2024 03:28:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1723112883; x=1723717683; 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=eLs1XU+vYdzxst2Jx1X+lCyMt00FFZC6iTK2ta7VGO4=; b=ZDVpxjkcnDU5wcsAbKr8F2VYhu6b5uMmyy9SB0Nlplq5aMA+jULlDByOdVABSQaHYh YJSCyqGJ2O4u0YWcS7jXGA+uY+y/tw6MyyJA1iwBgaqNucYkAQsVkaAZ5qKwssT/d2Ax y89e9xca4vjc/xDKT3gu/cBYs30QhMZ3/xuQXG/xyVCDgtM8oL47URv/pFzLmgAZgu5q xyYhEgqu45epaEywcmQ8sXT985Kv4AkCv4Bj8dqih24oLLIFZVKQ0MNwJ1kyxSf+eZRo 3GbvYrmMdbDH6yehpFrayR7uLRG20e5c83BYyQI79MuNBckdpC7tSneFX0tJlK0+Lqwp UfHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723112883; x=1723717683; 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=eLs1XU+vYdzxst2Jx1X+lCyMt00FFZC6iTK2ta7VGO4=; b=nmrVqTk6JtCYCLhnksZqwt83c5oBolfm2ehFV5/UiLhh8Ju14IHzfgc5OcpVN1KLKv QnSPsFG4Tehza27z/WtNG7R+HnFEoM9UrS8ub2sBxPJOjuBX3Sec0pYmU34Ed2pPbtgT MGFiwBNoxQ7na+eHmi3Pp0G3XRCG230NkXVZMxCCcMUZgko5ogojEnpzVFR0q0bix2Pr Qfb21G/x613BmkS92dKI9k/nTg5XL16MLQMIZ2ax6XYTqRO4sWGwxCysyarF31PVjTzo geH2tjwWWc17KVZJKWB2cB9+cYMDar5TVTvEUMzV2NUBLM2n0XnLKU8/YmdBJgz8fXGs Z6Tw== X-Forwarded-Encrypted: i=1; AJvYcCU9bSnI+4AU6uHb0Npxbe0P8gYJlNvBz7hadeJeoarhkP3vB3ceiSJ32rrd7eAnGNE93yTnu4aEJtr9rRChzQuhpZmQPUSBzCujT7RjitlUwnc= X-Gm-Message-State: AOJu0YxLIwLQG8t+yIwjEsFcqBjcxx1ht7VPDhckltiK1SS00U+34bvx niOAHIe1o9txflxCHWiI1zVy44SdXqnWVO5NtBcLBhaAXAoG4tN3FV+gibE+aHY= X-Google-Smtp-Source: AGHT+IH4wfvzwM4fkXArLZT1sNL9MljhNrH8VOMDF+lOosNHTQhMGAQbXMHkxibOYzjGWqC9kpdcsQ== X-Received: by 2002:adf:e6c1:0:b0:368:72c6:99c3 with SMTP id ffacd0b85a97d-36d2754b2abmr858636f8f.14.1723112882782; Thu, 08 Aug 2024 03:28:02 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:ae7:4e79:8821:15db]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-36d27208c98sm1454596f8f.75.2024.08.08.03.28.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 03:28:02 -0700 (PDT) From: Jerome Brunet To: Philipp Zabel , Stephen Boyd , Neil Armstrong Cc: Jerome Brunet , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org Subject: [PATCH v3 2/9] reset: amlogic: use generic data matching function Date: Thu, 8 Aug 2024 12:27:32 +0200 Message-ID: <20240808102742.4095904-3-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240808102742.4095904-1-jbrunet@baylibre.com> References: <20240808102742.4095904-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-20240808_032804_717804_812F3B76 X-CRM114-Status: GOOD ( 11.86 ) 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 There is no need to use the DT specific function to get matching data, use the generic one instead Suggested-by: Stephen Boyd Signed-off-by: Jerome Brunet Reviewed-by: Neil Armstrong --- drivers/reset/reset-meson.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/reset/reset-meson.c b/drivers/reset/reset-meson.c index b47431a21b86..820905779acd 100644 --- a/drivers/reset/reset-meson.c +++ b/drivers/reset/reset-meson.c @@ -128,7 +128,7 @@ static int meson_reset_probe(struct platform_device *pdev) if (IS_ERR(base)) return PTR_ERR(base); - data->param = of_device_get_match_data(dev); + data->param = device_get_match_data(dev); if (!data->param) return -ENODEV; From patchwork Thu Aug 8 10:27: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: 13757206 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 E045FC3DA4A for ; Thu, 8 Aug 2024 10:28: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=eeBwz13rW9wJCraYHqvHbBTdKH0KCK3zOLXmCzC3dS4=; b=hjQSbkaWCWafpo BcMWFoqmaDkLgR9bRWINA8B1mV2vFr87a/sHMiWqLfVVWvbXuxkBfpmuk1SQmr2P8rWysIQtMF0sm pmEo6zr0xTryJxKTx6vfI3QMdaDzB9XxMjw3KbQ95CAov5S222+NXhxfBU9XrC581aUkgUAlPgnv9 v/xHvr2OkEZzG27Kg6umCPtcIN3BlS91mpdkSc2A8bo/OdqBG/tMG7CTzx9f27r3bpktMO1Dhtq5K nxrF8j3C3vKfeoUMQRdnTnqW0jUOb78/3jo1doVe47m+i97515XDZ0fAAn3bSpjvJIuiVt3wq4KSB L1b09dTu4lHCb5bGuYhA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sc0NN-00000007tNo-2zq1; Thu, 08 Aug 2024 10:28:09 +0000 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sc0NJ-00000007tJV-0mtv for linux-amlogic@lists.infradead.org; Thu, 08 Aug 2024 10:28:07 +0000 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-368526b1333so1098214f8f.1 for ; Thu, 08 Aug 2024 03:28:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1723112883; x=1723717683; 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=Mtmd6W76tUil0cCcam+JDZpBYdbmzTJHGckyhD7jrDk=; b=OpWy27lnzXixQeG5UNY5Z2nftr7+z5ku2UGDwWNKxNwyXv4wRYbCP0OQ5NWZod+AnT Df7oOfJRs2M7RMKOmeL3xhSN5L626jt7Uj6ZMjXnHz4p4H/4Q4Q4y5VogKkN3cmXoBcX 0CBWK2RmWAKDsau5BE0SF3UXh7P7ctwwwqcJr6XqJz4wUOV3MkdyqV3ZGawuaCD7PZ40 faAu6dC2OgCbd+eklNHWoCrJ1Y8Ewy4GjCfvarL8DCYx8gNxPjpj+vRnm365roc0NA38 WPzjEqjlisgwJ7Zpo7jYBMlCWtOlgrYmMB5v+EYyQvaLjUv3ey+rWZ8FLEkWg575zy/D uo/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723112883; x=1723717683; 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=Mtmd6W76tUil0cCcam+JDZpBYdbmzTJHGckyhD7jrDk=; b=jRHbHGwcfzAgME7L2AkHXV2UtcOfKh1bhdkYNJJPTsSHLe8BT87vlIkI7xqLaLdbnW TaRGaX4ducauhgK4dkRNFQZt48rWgXWHeapqzQzl2NgCfufhViiEoTTvCOBi1jCN++Hp bjzb/3vhjZ1y4MIro8+eRmcn4/x6BoVf3Obys4vaoyGvF5YHmaG2far7RiPkkJ9upOK2 ynivkk/kTF1M2MCJ6Z7PLuIzBF2vNjRI7L1sAyraZns7cHYK9eMOa0e3Du0FV2ZoWXjl v0Jah3k6vmKk4mLtvq8Fp+XJnwin81Nd+Fts9oeByTwSKC6BpyNDCSIO1pmCefLVSk5T vsSQ== X-Forwarded-Encrypted: i=1; AJvYcCWR4qIksktp1yOWiBzNFgVeUNwLdXIbIhGh2b8VtiWlVLFVyHAjSFZOoMGlVjpotz6oF/F7FVQwLdWn7QlIPx0tQot6HaJTvOZFiqK13ryDoz0= X-Gm-Message-State: AOJu0YwbKYFKn0Am+QtCCeewNLtUfB7oGwJaSF6+snlkdnQFNVaiW1pV 3VsaTiCZoihIoozoZYNnK2Y8BfUDZnDi1uXgu52iY+YF77dGt84C/kXU9d9xTTw= X-Google-Smtp-Source: AGHT+IESK3Vcf6HBrh5b8hOTqs7HQ9tidPcmbWNqOL/A2DCJJeJ7YWip04j5wF2X6KBmuFiiDUvuLw== X-Received: by 2002:adf:f012:0:b0:363:ac4d:c44f with SMTP id ffacd0b85a97d-36d2815e3dcmr1034564f8f.17.1723112883473; Thu, 08 Aug 2024 03:28:03 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:ae7:4e79:8821:15db]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-36d27208c98sm1454596f8f.75.2024.08.08.03.28.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 03:28:03 -0700 (PDT) From: Jerome Brunet To: Philipp Zabel , Stephen Boyd , Neil Armstrong Cc: Jerome Brunet , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org Subject: [PATCH v3 3/9] reset: amlogic: make parameters unsigned Date: Thu, 8 Aug 2024 12:27:33 +0200 Message-ID: <20240808102742.4095904-4-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240808102742.4095904-1-jbrunet@baylibre.com> References: <20240808102742.4095904-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-20240808_032805_294528_24D3A361 X-CRM114-Status: GOOD ( 10.36 ) 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 register count and offset cannot be negative. Use unsigned integer for this. Suggested-by: Stephen Boyd Signed-off-by: Jerome Brunet Reviewed-by: Neil Armstrong --- drivers/reset/reset-meson.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/reset/reset-meson.c b/drivers/reset/reset-meson.c index 820905779acd..460ad2f8360f 100644 --- a/drivers/reset/reset-meson.c +++ b/drivers/reset/reset-meson.c @@ -17,8 +17,8 @@ #include struct meson_reset_param { - int reg_count; - int level_offset; + unsigned int reg_count; + unsigned int level_offset; }; struct meson_reset { From patchwork Thu Aug 8 10:27: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: 13757204 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 5A462C52D7C for ; Thu, 8 Aug 2024 10:28: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=hZyGMW4eNeVzTJwPL72LaUli/F5tLE+hZ4umilTGH9w=; b=FYjE4UMlyGdb1y HJLoGSHuaEa6EgO1GuJXDzaYMWglZ8turzT5dWCj8pPVa83Iqkd2E28KwQ7mWUqTt2k0TTqScNDbx w/Q04oPXlAa1eiJqSD4I43qYUDSR20PzdNVwtfhMxR2JB4qqC8v/Qdm9vYT8mkgG9z06qzfNrWH3T qDLytTTak9WCJYCKy2rLaJNiTj9UEc5lvu/gqm6vVqMF+Ht1qEf5APxcN/Ae0HZwXNo1aG9yovx/+ KE3V2sz44jXfFnep/0mgpqBSHm0KFOaMFluoeLNyUeMF0h4X0JWKcNiVgbEG2brA/Ml3PWxFdBBiv EHUTyV3Df4c3xPlpx3dg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sc0NP-00000007tP4-0Pgb; Thu, 08 Aug 2024 10:28:11 +0000 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sc0NK-00000007tJn-1UyX for linux-amlogic@lists.infradead.org; Thu, 08 Aug 2024 10:28:08 +0000 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-42809d6e719so5742555e9.3 for ; Thu, 08 Aug 2024 03:28:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1723112884; x=1723717684; 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=pr0Cx+l93ievhcSqcQh58PvVUEHk0s6N+Y0wdAmtxHg=; b=tWMLLYg5QEFisbyz/Y+QQ7hKUI9p8UDKAe3diAZUcTA3D50f5uf3w8Y50T2MC+S59R dcTmoJIJg5ynG1uF+Q6nvnjKMSfGwNT8mexWRnwgAcL4y2W4VflLHvBeNgftjJ6KuA2H s8mCsDKpKR16BQvtLlQ/ZUAUanEb3gv+bPulTjY/MjMpJjsNNymnnuS4dWf64T6OB9mB 3nHTOPLhEgi2xclBf4me/eNLLb4jo2KrJlXpVpHCqULxxfbZEwQGYBqnCcfl1tNqBl8P WqPAUlU3N7ZBaGAAaeR3/carF/tXYYrOWUl+2+lVYAv7yGTdRe40NpXbN8jIO7Yxkp4C s0fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723112884; x=1723717684; 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=pr0Cx+l93ievhcSqcQh58PvVUEHk0s6N+Y0wdAmtxHg=; b=sV/ONFuVOL0NNTVcegFVL88Oay5h/KDSXe5robko2IIGUsPeKuetRP/R6NfCtXBg4v XoDYF5Z1sfdGBLcw20lZ/mB24A6jdf40kEJrEeD4lPoEPdM4nz0N6RVlm6t35a2wEKtT eMVZOnj3q8W7TpEzqEHev4/1/MF0pv4D7AwxQKpQ4cJjHyC0EAnKab8lH/FEqG5cijqv o6Nosm2oO9XWuDTkrCuMQXB2wn/WFXutcaGsZpTtnx3Z8yxgx/c976qZjRJyj0wzcOWZ ZBNIxKaQQs2ir1uz3X4EkDjINO7/kW1iXXavKZUBohV7vp2EKWTvTNDXGjxKVFYXhHHD +Wug== X-Forwarded-Encrypted: i=1; AJvYcCWvKkZMX269Myt1G2S6NM8R9jR1YlMop+fE17ZNnIXkT/WWqenr2kzYCoqU4a/h7FCJUZwz4WWSaDeQ0dgNDno8ucCwsRAKC5TJ9iN6Zo+lF+4= X-Gm-Message-State: AOJu0YwlZ0ruRCWKpI8TzasmY4dcMwY8qYqSL58t3Lgpc0C+rp2GjIXE OEfh7/3Pv5erlLpZSMnL4C0yD0cj5W23U0GTTm5O5OGaiaHd3rnHShkIwnhodFg= X-Google-Smtp-Source: AGHT+IH6euXTuyAeaO2rodq608/hHNhqkkeHwCHczxlGWUhhgunMEiXRlBHFZXboJ9LIxTbuP/bp9A== X-Received: by 2002:a5d:64c5:0:b0:36b:a3f1:6333 with SMTP id ffacd0b85a97d-36d27554ae8mr1047306f8f.24.1723112884204; Thu, 08 Aug 2024 03:28:04 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:ae7:4e79:8821:15db]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-36d27208c98sm1454596f8f.75.2024.08.08.03.28.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 03:28:03 -0700 (PDT) From: Jerome Brunet To: Philipp Zabel , Stephen Boyd , Neil Armstrong Cc: Jerome Brunet , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org Subject: [PATCH v3 4/9] reset: amlogic: add driver parameters Date: Thu, 8 Aug 2024 12:27:34 +0200 Message-ID: <20240808102742.4095904-5-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240808102742.4095904-1-jbrunet@baylibre.com> References: <20240808102742.4095904-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-20240808_032806_956000_BE32213D X-CRM114-Status: GOOD ( 13.56 ) 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 460ad2f8360f..8addd100e601 100644 --- a/drivers/reset/reset-meson.c +++ b/drivers/reset/reset-meson.c @@ -18,7 +18,9 @@ struct meson_reset_param { unsigned int reg_count; + unsigned int reset_offset; unsigned 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_write(data->map, offset, BIT(bit)); } @@ -59,9 +62,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, @@ -84,17 +88,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 Aug 8 10:27: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: 13757207 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 EA0EBC52D7E for ; Thu, 8 Aug 2024 10:28:16 +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=fZpifPePBPRjMzY2plM1XovwX0uD5v/2c/wyrJmMDP0=; b=0aSWlyEsObxaU1 zK+s6tivts+qw0zeqgR36kzWchEIEvQVjpjdpFnsO1RwogDV8d2ON8qVbnzH5aMSxqTjxI02SZXdc EErYf52oqebLpyjwnKt80LcZfI5iJU+1UMZYtaWrfnBIf4urMwapZ2naPn8sAZIckqsGcjwW105n5 cfnTWlzMU2SjaB0sAKOrapeopJTX6LIIEfhB7OwfDqspHUTLoUZby5yf+0VKjvYC/bZSoYsMBn9hG BfjcecwiIzjeqw+fzUe9KnD7MO5ddPwa7MTe5/9bV0FCE8q5hrmbejYBmCO4c+cFFARrixE82bT5i 67nQsJz1o02eTb6+rF5w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sc0NP-00000007tPu-369j; Thu, 08 Aug 2024 10:28:11 +0000 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sc0NL-00000007tKI-0LT2 for linux-amlogic@lists.infradead.org; Thu, 08 Aug 2024 10:28:08 +0000 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4266dc7591fso5833385e9.0 for ; Thu, 08 Aug 2024 03:28:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1723112885; x=1723717685; 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=cPYzDSfyZeo+xZ43EsOSaQrJlRNd4kYLYsIOWeBqO/s=; b=zBneeasxsCNgOsx+04oEAZUzwPUO784QqLuhYuKa5APxt0uOepFzhmeqhu4//ipxOb CU5N8agf76SjVzbRX2amkUTb8d15GMmoPtGNEuIlR+5j2zOibZzyAJOvAlZbVfvNT9Pc xzjb3OA7l5DB5j6tOXmWPb18bjNCm+tfppp/mV5EELjChCHnLLr6L8bbabJkFh3LRyTX U4Qwt94OakqD2Je5FfN4vEu51oG5uevb8Uy7TAccBRRgZ9Z+B/2Mc5zRMtAJvqdu5kS2 SDrEJnXPpo04lzwW6qIVAyxDpvv8GLJLbFFtWfhLtqbhJ0lc0acLzYCloqF9NK2AJV2t FD2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723112885; x=1723717685; 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=cPYzDSfyZeo+xZ43EsOSaQrJlRNd4kYLYsIOWeBqO/s=; b=PKEo83PV4pdGDIK79KLf3kSw17Hz9c+roV6nv6BZkW1J7UxdxzkBatFPUD1QkQH7DW SxSn9m/P6+vMe5ut9utHtEV+y8ETIF5QzyTdK53LU+IOposqY4SutJ4CCuESTEeHk0Xr e32C3gozMsLKfN3VlmbxyZ62+zWcO5d0cJD3KWZMdCU42aoORE+nEj5tIOj8Kn2IhLYE wdLFfOO2RTPiM/oyFRWO2tqt23VYvkVkFL8CS9sYtEPU85ET/uZCagiujCwv6kcFpmUf vQwORT4XMIK1UkCWtFfk4UB1C8sfeGcA84B36Mziu9YlUoK4casU+fTkmSDMoJYR9vmO XyaQ== X-Forwarded-Encrypted: i=1; AJvYcCVLzVBrsjwmQ+hmFXrsED5mClIcV5IW2rTXrR2+xnXpvkWLMKKCkua8LR5vWy1T4Hhp0bF7jUpxx+2hZIZReV6Xa1SFzbSGIF4YT4etuB3cDGI= X-Gm-Message-State: AOJu0YxjPsoY3ZNRBHwnSOtgjFthkKjwG9Xk/jU67+zNj4TrBHKm/wQU luHyBBsi3PAvSpqIQBimf84zEiz0DITgQinlBz8uV37ptBEJYu3kfdwSBkd1yWu48h8h5yADoXM 5Ho8= X-Google-Smtp-Source: AGHT+IEvuEQLxY5NIcMxDxzPylcOhqHiALm1zbKzM1rXD702BA4RHo40fITpoOTHXRDRu8mJI7TSYg== X-Received: by 2002:a5d:588d:0:b0:368:4e38:a349 with SMTP id ffacd0b85a97d-36d274e0773mr1313790f8f.22.1723112885055; Thu, 08 Aug 2024 03:28:05 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:ae7:4e79:8821:15db]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-36d27208c98sm1454596f8f.75.2024.08.08.03.28.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 03:28:04 -0700 (PDT) From: Jerome Brunet To: Philipp Zabel , Stephen Boyd , Neil Armstrong Cc: Jerome Brunet , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org Subject: [PATCH v3 5/9] reset: amlogic: use reset number instead of register count Date: Thu, 8 Aug 2024 12:27:35 +0200 Message-ID: <20240808102742.4095904-6-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240808102742.4095904-1-jbrunet@baylibre.com> References: <20240808102742.4095904-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-20240808_032807_211766_4703C847 X-CRM114-Status: GOOD ( 11.99 ) 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 Reviewed-by: Neil Armstrong --- drivers/reset/reset-meson.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/reset/reset-meson.c b/drivers/reset/reset-meson.c index 8addd100e601..5b6f934c0265 100644 --- a/drivers/reset/reset-meson.c +++ b/drivers/reset/reset-meson.c @@ -17,7 +17,7 @@ #include struct meson_reset_param { - unsigned int reg_count; + unsigned int reset_num; unsigned int reset_offset; unsigned int level_offset; bool level_low_reset; @@ -87,21 +87,21 @@ static const struct reset_control_ops meson_reset_ops = { }; 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, @@ -148,8 +148,7 @@ static int meson_reset_probe(struct platform_device *pdev) "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.nr_resets = data->param->reset_num; data->rcdev.ops = &meson_reset_ops; data->rcdev.of_node = dev->of_node; From patchwork Thu Aug 8 10:27: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: 13757208 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 5331DC52D71 for ; Thu, 8 Aug 2024 10:28: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=RLbY+AgPukcr0CRil1uJ+0tYGqZJDMtw7VgtusolWFA=; b=GWAXn8Ym7V6ZLh gD7kl1FjvNQ2FpfcIh0EMu9p6JGxao2BNKxOr2nfO/G5d8pKezhHqpIOjkMt61CLdbsm4KVIoFZeB pZ7qT8cJ6XkEW01BH3E0EKl/eN8a2ZlRUzII1XSiu3Zl0EAgKdPvwq1uMcg1YNbNyWyf7sGJpFJSY RdQijTbkUu1dPFBVEPd5maiHARR1Ggplu6Drf0EXrIC75fOrvl588sUES4F5Axayt4P1kKQ5fom9g oF7DzLfgJMZrG4IHWkRrIUyZvxMCuxLiw2i1Ovf8w794YEHdMVVZIuGDqc8hXCZn2Q6345SKGvjgP CsNvf633TXzqpEfapfug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sc0NQ-00000007tQr-1nHS; Thu, 08 Aug 2024 10:28:12 +0000 Received: from mail-lj1-x232.google.com ([2a00:1450:4864:20::232]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sc0NM-00000007tKR-0E6z for linux-amlogic@lists.infradead.org; Thu, 08 Aug 2024 10:28:09 +0000 Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2f189a2a841so7146771fa.3 for ; Thu, 08 Aug 2024 03:28:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1723112886; x=1723717686; 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=SOSS3fc3XJBt3dG7ljbXMabd9Wrb6fH1OeKQO8767lc=; b=VEcYaep6Zs8N3+XvEdxD+FyM3c3Ssg5XPIm5oH1oMuIqLRP73faVTchxr1zn5DTVOg 3I7Jnngpw84ZlWO3oZzH60mGcV6t0hNMxgYft8L6+k8RKZmXY/ozL+gvZctvdD4IDoCl N5ytcTIJmRcVUq19J2vjCiM4Y71laaQHPBR61Psxy4s5ATiHxm5AW42vFQXOCg0uvOks JR0tCvt16GYH+DGWR3u7mv1R3TV3I3QX3WC7wIohk2KN8ZK22EkLd1xr2RQx/BuvQHQ5 jSx8/3Ec6ej60I/jKf4sGkQT30y+K8iy4g7lga2FbWfFiHz9PQN1BgfH6vebGglAzuyz 7HnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723112886; x=1723717686; 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=SOSS3fc3XJBt3dG7ljbXMabd9Wrb6fH1OeKQO8767lc=; b=dvzX+J8PoMefZk3ixmDD5s8D2hlJPdSxMdoIAYNunzN9McjH+l7d6e4xtrLj4Ji1F3 vNnuaIFqn3PpyGTFFNO+mWCEu4eEwCIzt0qTH6GnfO7R9BkR07KT9/f6RKZPePQATje3 25BiMimDoovsn3lE7B4mdlfyRjN+Vf1AlrWUt44UPvn/fnOkYX3FTci9k/iDlDPnFBlu n9w0whCBZX1WOETO296gSKelaEx4Px2W1/bbWK+eASar5nQEh/HKx3eKEbjA3V9ZCyoa SdaCvQCrVYQC4txIw4wLGmfMNzxCJp5KQPsaEilOW8eDcpPJ51nZ7afV4P06euNftsEe ob9g== X-Forwarded-Encrypted: i=1; AJvYcCVLGnSZoyUpQ3YH7sSEIqRNvbAe4YzMkvXJtepgT+0BkN2SBfFEy+vk1wvQaGo8HJwLThVJ6qN9ml0Ns8aPx+KLHsH575Bv7tOi8ownp4EBgug= X-Gm-Message-State: AOJu0YyJ4rKRB8Y7416GR35U1Qgu3dchPpHk+Iuses6tKVO1WORhOGYu tWXFQSFcs2JNJRi0YOIU2ZLKQTtGecgO93g2wzthgnvjsNq/eux7SxHorewFZeQ= X-Google-Smtp-Source: AGHT+IFI4Eqtp43CGeBvgz1gjODE89pru0R69ELYaTYb+vmy6UxKtO66CovxVMStVbq01JgDsE81/A== X-Received: by 2002:a2e:a595:0:b0:2ef:2c0f:283e with SMTP id 38308e7fff4ca-2f19de326d0mr11034371fa.12.1723112885800; Thu, 08 Aug 2024 03:28:05 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:ae7:4e79:8821:15db]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-36d27208c98sm1454596f8f.75.2024.08.08.03.28.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 03:28:05 -0700 (PDT) From: Jerome Brunet To: Philipp Zabel , Stephen Boyd , Neil Armstrong Cc: Jerome Brunet , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org Subject: [PATCH v3 6/9] reset: amlogic: add reset status support Date: Thu, 8 Aug 2024 12:27:36 +0200 Message-ID: <20240808102742.4095904-7-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240808102742.4095904-1-jbrunet@baylibre.com> References: <20240808102742.4095904-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-20240808_032808_136678_77468ABC X-CRM114-Status: GOOD ( 14.40 ) 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 a callback to check the status of the level reset, as done in the reset driver of the audio clock controller. This is done keep the functionality when the audio reset controller get migrated to meson-reset. Signed-off-by: Jerome Brunet Reviewed-by: Neil Armstrong --- drivers/reset/reset-meson.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/reset/reset-meson.c b/drivers/reset/reset-meson.c index 5b6f934c0265..b16d9c32adb1 100644 --- a/drivers/reset/reset-meson.c +++ b/drivers/reset/reset-meson.c @@ -56,8 +56,7 @@ static int meson_reset_reset(struct reset_controller_dev *rcdev, static int meson_reset_level(struct reset_controller_dev *rcdev, unsigned long id, bool assert) { - struct meson_reset *data = - container_of(rcdev, struct meson_reset, rcdev); + struct meson_reset *data = container_of(rcdev, struct meson_reset, rcdev); unsigned int offset, bit; meson_reset_offset_and_bit(data, id, &offset, &bit); @@ -68,6 +67,22 @@ 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) { @@ -84,6 +99,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 const struct meson_reset_param meson8b_param = { From patchwork Thu Aug 8 10:27: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: 13757209 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 4ABEEC52D7F for ; Thu, 8 Aug 2024 10:28: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=ZVzccMT96ADqUlm7P8Gykanaf4YRrSblX5ywI2AhsjM=; b=ui1Af4pN4tmtEE Oza/NUGBZAwpY5UwWOjQgPf7yQj9okcjV5fhg4XruDisIygf2f//i/Gwo9WcO13c4M5kcdP2mYM/a 06RpM5de8BRRAsr/ZIyN7UcovQ8kdLzstDH0dqQ5pKTZJJaj495wS+64iKqU6SqEcZ41yBDtwHsDv 205frMTkZM+2wFZaJd5mcBim2leQm+OYW+//q6XhqCsAGGX6ZjmPxT83kkcEPGTAW77b+TRU2CrFL krwxOE8J4/GMzgW2cIgjpQLUlh0h7zGtz5uBWrTA+I6fRgR/jKbdpgHILrVDboWSVzXWO7aIEqXhI icClcqbkx7U8Mwz9BpVw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sc0NQ-00000007tRK-3tk3; Thu, 08 Aug 2024 10:28:12 +0000 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sc0NM-00000007tKz-1ZF4 for linux-amlogic@lists.infradead.org; Thu, 08 Aug 2024 10:28:10 +0000 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4280bbdad3dso5773545e9.0 for ; Thu, 08 Aug 2024 03:28:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1723112887; x=1723717687; 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=99vHG6KBBSHLQN8ohhXjHSjQ/wjLWpAkbUWnRIGsOKY=; b=pWa0cfcisQLuZKDO6GcUi4iUrJAoczsD8Og1WvzwqLLiuKYNQaeC6R3jvZ0rZ4AVoy TPD4m0PSyDtSgad16VahEMdkbDNODLdcGaS1ljAKA/dWz9XfUbtH3elK8i62DCPd3m6x XCZGE22g3NqV/fJZU5HP84L++iX+IphJyC6mB3foYE2cmPTQYyE4m8t7KGjR1jBLXh9X qXb+Hck2S4JNtnM7T6ynVPlO60m3OI1vPowXflpOPglBzLGCHBultQa702I/LGnVY4YO 9E7C1GRtRn0xkGnj5zMvVtC5vBmKlCrKQcE50fbytwhx57TebUlfPru/O6pg6zSN8ITN xDvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723112887; x=1723717687; 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=99vHG6KBBSHLQN8ohhXjHSjQ/wjLWpAkbUWnRIGsOKY=; b=mo43opjyCohyDjguB1K1TnW1tNOruASisYiTlxTZCy0wJGIwjMsvNJ1FaWL9UR5EUW OEf+Hmsnic4+5io1L0E/lACJtv0upb6iPPfCEWRVBfNuqGlWoP/Uk3/cavZGAvt4bXob oF15g71kxKHHGdukg8f4P1IFcIO3aimswsO1hUF1RwIlCOFd66mkttDs88XRQJMOoNo8 pn9H9nj9B6FC8iMQFsYJo1yq+c7xGKVmKDWmG88CqVBTbIvEJl6jffVTpK7xCZJfB4Se ykyBqyIC7BeFzg+qyKQfaTRulAhnz+Fc7LRT3fTEG33o2/bbpdVJrDD/ChvMxAH7Qt2+ gTMA== X-Forwarded-Encrypted: i=1; AJvYcCUE+oEpw4LtuGOVmnHcsLTwVZsYvV0N2/Re3Q0GJfIgTlmRx68pI4GhwYPyyrBevRQp0beDMfQZmTyhz9bevJy+YF2GTwPGXYegKu4336A/RAI= X-Gm-Message-State: AOJu0YwCGRRHHpBeTmTZauai0PhuoypszIujCPOaw3aYlVlZD1aBc3hi 7/hlS1+E/M2qo4nU7uUt+impnIdNT9d681nwo/vszBLgwJFflR1vaoqfJwmrZVo= X-Google-Smtp-Source: AGHT+IHozoY21BcuIdPpefQDlZte6viZbFzsG4azJdBTs++YWZDu6Dyunzbq/tZpmybC31GPCvae9g== X-Received: by 2002:a5d:5910:0:b0:368:6336:6051 with SMTP id ffacd0b85a97d-36d274dd07bmr1051331f8f.22.1723112886546; Thu, 08 Aug 2024 03:28:06 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:ae7:4e79:8821:15db]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-36d27208c98sm1454596f8f.75.2024.08.08.03.28.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 03:28:06 -0700 (PDT) From: Jerome Brunet To: Philipp Zabel , Stephen Boyd , Neil Armstrong Cc: Jerome Brunet , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org Subject: [PATCH v3 7/9] reset: amlogic: move drivers to a dedicated directory Date: Thu, 8 Aug 2024 12:27:37 +0200 Message-ID: <20240808102742.4095904-8-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240808102742.4095904-1-jbrunet@baylibre.com> References: <20240808102742.4095904-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-20240808_032808_462976_F50B246C X-CRM114-Status: GOOD ( 15.30 ) 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 meson reset driver will be split in two part, one implemeting the ops, the other providing the platform driver support. This will be done to facilitate the addition of the auxiliary bus support. To avoid making a mess in drivers/reset/ while doing so, move the amlogic reset drivers to a dedicated directory. Signed-off-by: Jerome Brunet Reviewed-by: Neil Armstrong --- drivers/reset/Kconfig | 15 +-------------- drivers/reset/Makefile | 3 +-- drivers/reset/amlogic/Kconfig | 13 +++++++++++++ drivers/reset/amlogic/Makefile | 2 ++ .../reset/{ => amlogic}/reset-meson-audio-arb.c | 0 drivers/reset/{ => amlogic}/reset-meson.c | 0 6 files changed, 17 insertions(+), 16 deletions(-) create mode 100644 drivers/reset/amlogic/Kconfig create mode 100644 drivers/reset/amlogic/Makefile rename drivers/reset/{ => amlogic}/reset-meson-audio-arb.c (100%) rename drivers/reset/{ => amlogic}/reset-meson.c (100%) diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig index 67bce340a87e..0c092ae1b411 100644 --- a/drivers/reset/Kconfig +++ b/drivers/reset/Kconfig @@ -140,20 +140,6 @@ config RESET_MCHP_SPARX5 help This driver supports switch core reset for the Microchip Sparx5 SoC. -config RESET_MESON - tristate "Meson Reset Driver" - depends on ARCH_MESON || COMPILE_TEST - default ARCH_MESON - help - This enables the reset driver for Amlogic Meson SoCs. - -config RESET_MESON_AUDIO_ARB - tristate "Meson Audio Memory Arbiter Reset Driver" - depends on ARCH_MESON || COMPILE_TEST - help - This enables the reset driver for Audio Memory Arbiter of - Amlogic's A113 based SoCs - config RESET_NPCM bool "NPCM BMC Reset Driver" if COMPILE_TEST default ARCH_NPCM @@ -343,6 +329,7 @@ config RESET_ZYNQMP help This enables the reset controller driver for Xilinx ZynqMP SoCs. +source "drivers/reset/amlogic/Kconfig" source "drivers/reset/starfive/Kconfig" source "drivers/reset/sti/Kconfig" source "drivers/reset/hisilicon/Kconfig" diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile index 27b0bbdfcc04..bf089176c9f4 100644 --- a/drivers/reset/Makefile +++ b/drivers/reset/Makefile @@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 obj-y += core.o +obj-y += amlogic/ obj-y += hisilicon/ obj-y += starfive/ obj-y += sti/ @@ -20,8 +21,6 @@ obj-$(CONFIG_RESET_K210) += reset-k210.o obj-$(CONFIG_RESET_LANTIQ) += reset-lantiq.o obj-$(CONFIG_RESET_LPC18XX) += reset-lpc18xx.o obj-$(CONFIG_RESET_MCHP_SPARX5) += reset-microchip-sparx5.o -obj-$(CONFIG_RESET_MESON) += reset-meson.o -obj-$(CONFIG_RESET_MESON_AUDIO_ARB) += reset-meson-audio-arb.o obj-$(CONFIG_RESET_NPCM) += reset-npcm.o obj-$(CONFIG_RESET_NUVOTON_MA35D1) += reset-ma35d1.o obj-$(CONFIG_RESET_PISTACHIO) += reset-pistachio.o diff --git a/drivers/reset/amlogic/Kconfig b/drivers/reset/amlogic/Kconfig new file mode 100644 index 000000000000..7ed9cf50f038 --- /dev/null +++ b/drivers/reset/amlogic/Kconfig @@ -0,0 +1,13 @@ +config RESET_MESON + tristate "Meson Reset Driver" + depends on ARCH_MESON || COMPILE_TEST + default ARCH_MESON + help + This enables the reset driver for Amlogic Meson SoCs. + +config RESET_MESON_AUDIO_ARB + tristate "Meson Audio Memory Arbiter Reset Driver" + depends on ARCH_MESON || COMPILE_TEST + help + This enables the reset driver for Audio Memory Arbiter of + Amlogic's A113 based SoCs diff --git a/drivers/reset/amlogic/Makefile b/drivers/reset/amlogic/Makefile new file mode 100644 index 000000000000..55509fc78513 --- /dev/null +++ b/drivers/reset/amlogic/Makefile @@ -0,0 +1,2 @@ +obj-$(CONFIG_RESET_MESON) += reset-meson.o +obj-$(CONFIG_RESET_MESON_AUDIO_ARB) += reset-meson-audio-arb.o diff --git a/drivers/reset/reset-meson-audio-arb.c b/drivers/reset/amlogic/reset-meson-audio-arb.c similarity index 100% rename from drivers/reset/reset-meson-audio-arb.c rename to drivers/reset/amlogic/reset-meson-audio-arb.c diff --git a/drivers/reset/reset-meson.c b/drivers/reset/amlogic/reset-meson.c similarity index 100% rename from drivers/reset/reset-meson.c rename to drivers/reset/amlogic/reset-meson.c From patchwork Thu Aug 8 10:27: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: 13757211 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 4548BC52D71 for ; Thu, 8 Aug 2024 10:28: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=+lmfCb/UGBavprf+Ze0009KzhP82UNyqxXka3k22TU8=; b=uv3ONRWSZ6MSjL 6K+ezPIBJzeNMY8ueMXKArqFZJkgwfl40yUvZJtRfS2ZoX5bxRWcZBJhP5Hx9OBOhTYCDT+wcixms +875glQt9BGPsAZtPDCifs2D6Mg7gu4/uNWyisD8qzfDN0yrTcTU6+qaVTJvkdDP+0j3KMJOj0heN qIaQ+7pTv2n1hv4HO0/POBvatpdaHUDB/J0thv0oChn3quR24Nm1fiasMyNe1pJOhACyRJGkJpBzU HK6Lp49KgjyhchnMU9Z2bbjPcoU4uJDEMLK1Ur6yB/sVSZtgFtLjaZWXfadzNvxniqC+eFd74hn9Z m7YXReAMvI2puNlQe+EA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sc0NT-00000007tTc-0l8G; Thu, 08 Aug 2024 10:28:15 +0000 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sc0NN-00000007tLo-0SEz for linux-amlogic@lists.infradead.org; Thu, 08 Aug 2024 10:28:11 +0000 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-367ab76d5e1so395729f8f.3 for ; Thu, 08 Aug 2024 03:28:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1723112887; x=1723717687; 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=0x1lfpdLeHdHaVZLxnPFzwGf3V/7oMT6QazhAgPTFUc=; b=MsHO3oNGTQcJk1AjItiyiZzkjgGZNO+VlGRp5M7tiNWq48x/IpMZO3KXpLjob6uS1b LhtFb6T0I1pLxc5i/5t+RenYdxBnMYRth4gSm3lID9QFVJsQ8A1/1UswVujfu8i4iyyK HF51yt6URRsPf3kTjBp17SdezgQMZhRA0QsFYpjttvr1u2/HkB/q5Sxl5HoQOm5lOmUT DngJG1nKA0iBQSzSGzH0gBh0VyTIkMQkBymI6U7hqtYl4Aco6suRmwreGHRnaW9NoE0p +dGnPjgBYDAPdXIAyiuNf5gDoIeaLFC5axLY//UOR6BdTxkgdT5SgsJCjQwrZ9Uev1eJ Mtxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723112887; x=1723717687; 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=0x1lfpdLeHdHaVZLxnPFzwGf3V/7oMT6QazhAgPTFUc=; b=iBQePZxM3wO89R7bHzUDWvOwJ9Yqr97UhlpzLBszffaIS8IsrLLOaqaTv4gqIRd/6z cp6Av2BqS3FwbhiMi69BPZg8+B7kmOI7CoP4ApohLSL8s/An9df52sanbByWYd+n6uss lrCb5krWivZMU1YsulMdNZgR18/anOdIdV18QUehSYVyMqgID4pMLzQqdKlSIQgVHFsi Dtg6TE3wGq6V2+xnPGGrXlc5JvgILjS7vhClXVjt1KZQDDxbZ6mqZHg7ME4IlmRFea0q Bua4tlyINO1rQP3zJOvLjDCToK5luacLMkQ0HbC3W0sF5d8Dc3jYiUnyKW+7JtVp1Fmh yiHA== X-Forwarded-Encrypted: i=1; AJvYcCX0dvXSobGNBWgX6iQtUmBb/T+ibE91FwFROExqE+VyvDxW2rOnzOlRLvZahfOBpjk7Bol3Rk+8OQxcTAP2jYnzd55/Pf1v5WvntylVBZUuCD0= X-Gm-Message-State: AOJu0YxpJppmNYDYMWB05TVCbVESDHsUZRR4CWUkVtnrG27N46wVLt5R X3k09SzfrogcVFJMWIKRlCqBtech4sMAEjkYcc9hzIzzBUcPEk2r1fYtWPAj/qU= X-Google-Smtp-Source: AGHT+IF44atPcsfUXvMJQaD7h568xLsRA9KqH/4UoYtbI1jiNngo54AyUWhS/kjqhCBIq1PF0BbzEg== X-Received: by 2002:adf:fe12:0:b0:362:8ec2:53d6 with SMTP id ffacd0b85a97d-36d2757dcd3mr1025346f8f.61.1723112887285; Thu, 08 Aug 2024 03:28:07 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:ae7:4e79:8821:15db]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-36d27208c98sm1454596f8f.75.2024.08.08.03.28.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 03:28:07 -0700 (PDT) From: Jerome Brunet To: Philipp Zabel , Stephen Boyd , Neil Armstrong Cc: Jerome Brunet , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org Subject: [PATCH v3 8/9] reset: amlogic: split the device core and platform probe Date: Thu, 8 Aug 2024 12:27:38 +0200 Message-ID: <20240808102742.4095904-9-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240808102742.4095904-1-jbrunet@baylibre.com> References: <20240808102742.4095904-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-20240808_032809_254199_4318EF51 X-CRM114-Status: GOOD ( 23.56 ) 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 out the device core function from the probe of the platform device. The device core function will be common to both the platform and auxiliary driver. Signed-off-by: Jerome Brunet --- drivers/reset/amlogic/Kconfig | 10 +- drivers/reset/amlogic/Makefile | 3 +- .../{reset-meson.c => reset-meson-core.c} | 101 +++--------------- drivers/reset/amlogic/reset-meson-pltf.c | 92 ++++++++++++++++ drivers/reset/amlogic/reset-meson.h | 24 +++++ 5 files changed, 143 insertions(+), 87 deletions(-) rename drivers/reset/amlogic/{reset-meson.c => reset-meson-core.c} (51%) create mode 100644 drivers/reset/amlogic/reset-meson-pltf.c create mode 100644 drivers/reset/amlogic/reset-meson.h diff --git a/drivers/reset/amlogic/Kconfig b/drivers/reset/amlogic/Kconfig index 7ed9cf50f038..04c7be0f3165 100644 --- a/drivers/reset/amlogic/Kconfig +++ b/drivers/reset/amlogic/Kconfig @@ -1,9 +1,15 @@ +config RESET_MESON_CORE + tristate + select REGMAP + config RESET_MESON - tristate "Meson Reset Driver" + tristate "Meson Reset Platform Driver" depends on ARCH_MESON || COMPILE_TEST default ARCH_MESON + select REGMAP_MMIO + select RESET_MESON_CORE help - This enables the reset driver for Amlogic Meson SoCs. + This enables the reset platform driver for Amlogic SoCs. config RESET_MESON_AUDIO_ARB tristate "Meson Audio Memory Arbiter Reset Driver" diff --git a/drivers/reset/amlogic/Makefile b/drivers/reset/amlogic/Makefile index 55509fc78513..0f8f9121b566 100644 --- a/drivers/reset/amlogic/Makefile +++ b/drivers/reset/amlogic/Makefile @@ -1,2 +1,3 @@ -obj-$(CONFIG_RESET_MESON) += reset-meson.o +obj-$(CONFIG_RESET_MESON) += reset-meson-pltf.o +obj-$(CONFIG_RESET_MESON_CORE) += reset-meson-core.o obj-$(CONFIG_RESET_MESON_AUDIO_ARB) += reset-meson-audio-arb.o diff --git a/drivers/reset/amlogic/reset-meson.c b/drivers/reset/amlogic/reset-meson-core.c similarity index 51% rename from drivers/reset/amlogic/reset-meson.c rename to drivers/reset/amlogic/reset-meson-core.c index b16d9c32adb1..ea4fc562f7e6 100644 --- a/drivers/reset/amlogic/reset-meson.c +++ b/drivers/reset/amlogic/reset-meson-core.c @@ -1,27 +1,17 @@ // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause /* - * Amlogic Meson Reset Controller driver + * Amlogic Meson Reset core functions * - * Copyright (c) 2016 BayLibre, SAS. - * Author: Neil Armstrong + * Copyright (c) 2024 BayLibre, SAS. + * Author: Jerome Brunet */ -#include -#include -#include -#include + +#include #include -#include #include #include -#include -#include - -struct meson_reset_param { - unsigned int reset_num; - unsigned int reset_offset; - unsigned int level_offset; - bool level_low_reset; -}; + +#include "reset-meson.h" struct meson_reset { const struct meson_reset_param *param; @@ -102,84 +92,27 @@ static const struct reset_control_ops meson_reset_ops = { .status = meson_reset_status, }; -static const struct meson_reset_param meson8b_param = { - .reset_num = 256, - .reset_offset = 0x0, - .level_offset = 0x7c, - .level_low_reset = true, -}; - -static const struct meson_reset_param meson_a1_param = { - .reset_num = 96, - .reset_offset = 0x0, - .level_offset = 0x40, - .level_low_reset = true, -}; - -static const struct meson_reset_param meson_s4_param = { - .reset_num = 192, - .reset_offset = 0x0, - .level_offset = 0x40, - .level_low_reset = true, -}; - -static const struct of_device_id meson_reset_dt_ids[] = { - { .compatible = "amlogic,meson8b-reset", .data = &meson8b_param}, - { .compatible = "amlogic,meson-gxbb-reset", .data = &meson8b_param}, - { .compatible = "amlogic,meson-axg-reset", .data = &meson8b_param}, - { .compatible = "amlogic,meson-a1-reset", .data = &meson_a1_param}, - { .compatible = "amlogic,meson-s4-reset", .data = &meson_s4_param}, - { .compatible = "amlogic,c3-reset", .data = &meson_s4_param}, - { /* sentinel */ }, -}; -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) +int meson_reset_probe(struct device *dev, struct regmap *map, + const struct meson_reset_param *param) { - struct device *dev = &pdev->dev; struct meson_reset *data; - 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 = device_get_match_data(dev); - if (!data->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), - "can't init regmap mmio region\n"); - - data->rcdev.owner = THIS_MODULE; - data->rcdev.nr_resets = data->param->reset_num; + data->param = param; + data->map = map; + data->rcdev.owner = dev->driver->owner; + data->rcdev.nr_resets = param->reset_num; data->rcdev.ops = &meson_reset_ops; data->rcdev.of_node = dev->of_node; return devm_reset_controller_register(dev, &data->rcdev); } +EXPORT_SYMBOL_NS_GPL(meson_reset_probe, MESON_RESET); -static struct platform_driver meson_reset_driver = { - .probe = meson_reset_probe, - .driver = { - .name = "meson_reset", - .of_match_table = meson_reset_dt_ids, - }, -}; -module_platform_driver(meson_reset_driver); - -MODULE_DESCRIPTION("Amlogic Meson Reset Controller driver"); +MODULE_DESCRIPTION("Amlogic Meson Reset Core function"); MODULE_AUTHOR("Neil Armstrong "); -MODULE_LICENSE("Dual BSD/GPL"); +MODULE_AUTHOR("Jerome Brunet "); +MODULE_IMPORT_NS(MESON_RESET); diff --git a/drivers/reset/amlogic/reset-meson-pltf.c b/drivers/reset/amlogic/reset-meson-pltf.c new file mode 100644 index 000000000000..97e933b4aa34 --- /dev/null +++ b/drivers/reset/amlogic/reset-meson-pltf.c @@ -0,0 +1,92 @@ +// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause +/* + * Amlogic Meson Reset platform driver + * + * Copyright (c) 2016 BayLibre, SAS. + * Author: Neil Armstrong + */ +#include +#include +#include +#include +#include +#include +#include + +#include "reset-meson.h" + +static const struct meson_reset_param meson8b_param = { + .reset_num = 256, + .reset_offset = 0x0, + .level_offset = 0x7c, + .level_low_reset = true, +}; + +static const struct meson_reset_param meson_a1_param = { + .reset_num = 96, + .reset_offset = 0x0, + .level_offset = 0x40, + .level_low_reset = true, +}; + +static const struct meson_reset_param meson_s4_param = { + .reset_num = 192, + .reset_offset = 0x0, + .level_offset = 0x40, + .level_low_reset = true, +}; + +static const struct of_device_id meson_reset_dt_ids[] = { + { .compatible = "amlogic,meson8b-reset", .data = &meson8b_param}, + { .compatible = "amlogic,meson-gxbb-reset", .data = &meson8b_param}, + { .compatible = "amlogic,meson-axg-reset", .data = &meson8b_param}, + { .compatible = "amlogic,meson-a1-reset", .data = &meson_a1_param}, + { .compatible = "amlogic,meson-s4-reset", .data = &meson_s4_param}, + { .compatible = "amlogic,c3-reset", .data = &meson_s4_param}, + { /* sentinel */ }, +}; +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_pltf_probe(struct platform_device *pdev) +{ + const struct meson_reset_param *param; + struct device *dev = &pdev->dev; + struct regmap *map; + void __iomem *base; + + base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(base)) + return PTR_ERR(base); + + param = device_get_match_data(dev); + if (!param) + return -ENODEV; + + 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"); + + return meson_reset_probe(dev, map, param); +} + +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_pltf_driver); + +MODULE_DESCRIPTION("Amlogic Meson Reset Platform Controller driver"); +MODULE_AUTHOR("Neil Armstrong "); +MODULE_AUTHOR("Jerome Brunet "); +MODULE_LICENSE("Dual BSD/GPL"); +MODULE_IMPORT_NS(MESON_RESET); diff --git a/drivers/reset/amlogic/reset-meson.h b/drivers/reset/amlogic/reset-meson.h new file mode 100644 index 000000000000..c2e8a5cf2e46 --- /dev/null +++ b/drivers/reset/amlogic/reset-meson.h @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* + * Copyright (c) 2024 BayLibre, SAS. + * Author: Jerome Brunet + */ + +#ifndef __MESON_RESET_CORE_H +#define __MESON_RESET_CORE_H + +#include +#include +#include + +struct meson_reset_param { + unsigned int reset_num; + unsigned int reset_offset; + unsigned int level_offset; + bool level_low_reset; +}; + +int meson_reset_probe(struct device *dev, struct regmap *map, + const struct meson_reset_param *param); + +#endif /* __MESON_RESET_CORE_H */ From patchwork Thu Aug 8 10:27: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: 13757210 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 1E122C52D73 for ; Thu, 8 Aug 2024 10:28: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=BTHorBtbyTpPxnGwpS+41DKXJFo4dxoswS0zhZXc4oA=; b=llyKC+fyIZhthX WLdMF/rLF22KjdsSSIV3qq/hP6fHQN7zwddEQWsttE4xmMmGObiuABFDao4x+4XGrqO575qx0GeJi W6VdFtgKp865/G3flVGgttMDku0vnyVbJHn7gLFQfuYxKFSipBWBzg2MYebBVztbVZ/ouRZRdU8aJ 2BqX5lxU6u5lkpyT/v+9cHs3DixVOOSlzVr2+VWGId0wSfB+Z400szREz9QWQVSnDqXAS/qXAtPcA GJHN1t6saqUf+Sy04j8hAU7hnAlzOlZe9Y8m9g/N//Sdb3SRatcPaivNJKInq7sRZ69XWJsIGr30+ JhG5yfT7Q8fFQKznkfvg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sc0NS-00000007tT6-2WMv; Thu, 08 Aug 2024 10:28:14 +0000 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sc0NN-00000007tMV-1umQ for linux-amlogic@lists.infradead.org; Thu, 08 Aug 2024 10:28:11 +0000 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-368663d7f80so352453f8f.3 for ; Thu, 08 Aug 2024 03:28:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1723112888; x=1723717688; 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=uHAo36qJMD+4wxk3g0lOFfwjuuv+/seGus04OZIl27g=; b=yYEoxrA8ilhs7NKa1kvjLNqhxN9ljM3c1/Og6HtwcFzka33e6HKilRn0z0hZx/EwPT 09ZeM2faZlM6aw0Q47M2/MbbxaHISSsDqh+0JGXs401B3gJTOUPcGk+nYuzmDn+HPfXr u2kSjZpfxpg12lyDi/kXGvCafLwhpEDpmHVtY1ZddmTTDISZFFoHGdKiH1FNbI46J3GF 9X38xS68AsTwTOWkoSd4NcLZNmor92KTmS2Too4Y6YTll0u1ha1u8kaZlMK4I11PALWS HWqDDMQOqpufZdo6x892auSuMTtAtL5M8DhffmUAM5L34w2bC3bv6edJLlOiT5Pzpp5k T+SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723112888; x=1723717688; 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=uHAo36qJMD+4wxk3g0lOFfwjuuv+/seGus04OZIl27g=; b=r/xTvPEK2JCevE5Ukq+lizOV6QYrSW52qT44CK7TGfQxQWrEuP4MZw7Pei/uatUFSl EsebWfiX5gBu6FdABs/aiAx26lWao10U7jS2+gLSWhd8OkddKCZxsuEr0muK1jq7AC4v xwhVeoCugK5nEuh2II5zx1QhPi7OFYLXK+pcMUMnjsLWwnFE1X+RRF40PWHpUsoosKzm 877UEscjQCHofY6Oj8/edutc5raAdC9fqQWT6S1yM69a36Qx+VIljoHxC71xa6a6NgbL O+9aGJAuePp4RPPzQO7CWFdfMYIbflFxcQ6W/MsZIIQD2Ga9dN6O8IJ8fM/G5APBRzr9 jOow== X-Forwarded-Encrypted: i=1; AJvYcCUR67zyyOcgmAcbN4lbhKz9+C3lx34toEl4NatTa28Of/II2L4jYE5YzVm69JVcuCYZS3RhsuDoBLgCu8m4FA+Ahp8NOyKXwD0ZxJ7nJcIBZ8c= X-Gm-Message-State: AOJu0YyoTXgoZcQ5c8PFtTS9bTrOd8qfecLqZweGlN12Cyzy86JplaiF wNDrOVbxpx8Zpd7Szfd0UCkUgMXZoVkiRTroT4Q9m1cuiwk2j8QKWydKeQ4O0fU= X-Google-Smtp-Source: AGHT+IFmqwaJ4o87yD8ryfkxnUfmJJm0YXqGEqbQfeRoZvj1W0kleGmTnVkbk+wyr5B0NIdesRL0ew== X-Received: by 2002:adf:e80f:0:b0:368:7943:146f with SMTP id ffacd0b85a97d-36d27565ec6mr910185f8f.26.1723112887996; Thu, 08 Aug 2024 03:28:07 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:ae7:4e79:8821:15db]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-36d27208c98sm1454596f8f.75.2024.08.08.03.28.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 03:28:07 -0700 (PDT) From: Jerome Brunet To: Philipp Zabel , Stephen Boyd , Neil Armstrong Cc: Jerome Brunet , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org Subject: [PATCH v3 9/9] reset: amlogic: add auxiliary reset driver support Date: Thu, 8 Aug 2024 12:27:39 +0200 Message-ID: <20240808102742.4095904-10-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240808102742.4095904-1-jbrunet@baylibre.com> References: <20240808102742.4095904-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-20240808_032809_566530_B8FF9D20 X-CRM114-Status: GOOD ( 24.89 ) 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/amlogic/Kconfig | 8 ++ drivers/reset/amlogic/Makefile | 1 + drivers/reset/amlogic/reset-meson-aux.c | 136 ++++++++++++++++++++ drivers/reset/amlogic/reset-meson-core.c | 25 +++- drivers/reset/amlogic/reset-meson-pltf.c | 3 + drivers/reset/amlogic/reset-meson.h | 4 + include/soc/amlogic/meson-auxiliary-reset.h | 23 ++++ 7 files changed, 198 insertions(+), 2 deletions(-) create mode 100644 drivers/reset/amlogic/reset-meson-aux.c create mode 100644 include/soc/amlogic/meson-auxiliary-reset.h diff --git a/drivers/reset/amlogic/Kconfig b/drivers/reset/amlogic/Kconfig index 04c7be0f3165..ee1c7620a2b1 100644 --- a/drivers/reset/amlogic/Kconfig +++ b/drivers/reset/amlogic/Kconfig @@ -11,6 +11,14 @@ config RESET_MESON help This enables the reset platform driver for Amlogic SoCs. +config RESET_MESON_AUX + tristate "Meson Reset Platform Driver" + depends on ARCH_MESON || COMPILE_TEST + select AUXILIARY_BUS + select RESET_MESON_CORE + help + This enables the reset auxiliary driver for Amlogic SoCs. + config RESET_MESON_AUDIO_ARB tristate "Meson Audio Memory Arbiter Reset Driver" depends on ARCH_MESON || COMPILE_TEST diff --git a/drivers/reset/amlogic/Makefile b/drivers/reset/amlogic/Makefile index 0f8f9121b566..5d53a4b11ed9 100644 --- a/drivers/reset/amlogic/Makefile +++ b/drivers/reset/amlogic/Makefile @@ -1,3 +1,4 @@ obj-$(CONFIG_RESET_MESON) += reset-meson-pltf.o +obj-$(CONFIG_RESET_MESON_AUX) += reset-meson-aux.o obj-$(CONFIG_RESET_MESON_CORE) += reset-meson-core.o obj-$(CONFIG_RESET_MESON_AUDIO_ARB) += reset-meson-audio-arb.o diff --git a/drivers/reset/amlogic/reset-meson-aux.c b/drivers/reset/amlogic/reset-meson-aux.c new file mode 100644 index 000000000000..caf26eb67c14 --- /dev/null +++ b/drivers/reset/amlogic/reset-meson-aux.c @@ -0,0 +1,136 @@ +// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause +/* + * Amlogic Meson Reset Auxiliary driver + * + * Copyright (c) 2024 BayLibre, SAS. + * Author: Jerome Brunet + */ + +#include +#include +#include +#include +#include +#include + +#include "reset-meson.h" +#include + +static DEFINE_IDA(meson_rst_aux_ida); + +struct meson_reset_adev { + struct auxiliary_device adev; + struct regmap *map; +}; + +#define to_meson_reset_adev(_adev) \ + container_of((_adev), struct meson_reset_adev, adev) + +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 meson_reset_adev *raux = + to_meson_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); + +static void meson_rst_aux_release(struct device *dev) +{ + struct auxiliary_device *adev = to_auxiliary_dev(dev); + struct meson_reset_adev *raux = + to_meson_reset_adev(adev); + + ida_free(&meson_rst_aux_ida, adev->id); + kfree(raux); +} + +static void meson_rst_aux_unregister_adev(void *_adev) +{ + struct auxiliary_device *adev = _adev; + + auxiliary_device_delete(adev); + auxiliary_device_uninit(adev); +} + +int devm_meson_rst_aux_register(struct device *dev, + struct regmap *map, + const char *adev_name) +{ + struct meson_reset_adev *raux; + struct auxiliary_device *adev; + int ret; + + raux = kzalloc(sizeof(*raux), GFP_KERNEL); + if (!raux) + return -ENOMEM; + + ret = ida_alloc(&meson_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_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_rst_aux_unregister_adev, + adev); + +ida_free: + ida_free(&meson_rst_aux_ida, adev->id); +raux_free: + kfree(raux); + return ret; +} +EXPORT_SYMBOL_GPL(devm_meson_rst_aux_register); + +MODULE_DESCRIPTION("Amlogic Meson Reset Auxiliary driver"); +MODULE_AUTHOR("Jerome Brunet "); +MODULE_LICENSE("Dual BSD/GPL"); +MODULE_IMPORT_NS(MESON_RESET); diff --git a/drivers/reset/amlogic/reset-meson-core.c b/drivers/reset/amlogic/reset-meson-core.c index ea4fc562f7e6..774902527d17 100644 --- a/drivers/reset/amlogic/reset-meson-core.c +++ b/drivers/reset/amlogic/reset-meson-core.c @@ -85,12 +85,33 @@ static int meson_reset_deassert(struct reset_controller_dev *rcdev, return meson_reset_level(rcdev, id, false); } -static const struct reset_control_ops meson_reset_ops = { +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); +} + +const struct reset_control_ops meson_reset_ops = { .reset = meson_reset_reset, .assert = meson_reset_assert, .deassert = meson_reset_deassert, .status = meson_reset_status, }; +EXPORT_SYMBOL_NS_GPL(meson_reset_ops, MESON_RESET); + +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, +}; +EXPORT_SYMBOL_NS_GPL(meson_reset_toggle_ops, MESON_RESET); int meson_reset_probe(struct device *dev, struct regmap *map, const struct meson_reset_param *param) @@ -105,7 +126,7 @@ 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 = data->param->reset_ops; data->rcdev.of_node = dev->of_node; return devm_reset_controller_register(dev, &data->rcdev); diff --git a/drivers/reset/amlogic/reset-meson-pltf.c b/drivers/reset/amlogic/reset-meson-pltf.c index 97e933b4aa34..2bc3ea42c6ec 100644 --- a/drivers/reset/amlogic/reset-meson-pltf.c +++ b/drivers/reset/amlogic/reset-meson-pltf.c @@ -16,6 +16,7 @@ #include "reset-meson.h" static const struct meson_reset_param meson8b_param = { + .reset_ops = &meson_reset_ops, .reset_num = 256, .reset_offset = 0x0, .level_offset = 0x7c, @@ -23,6 +24,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, @@ -30,6 +32,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, diff --git a/drivers/reset/amlogic/reset-meson.h b/drivers/reset/amlogic/reset-meson.h index c2e8a5cf2e46..5ab2ac9ab2e5 100644 --- a/drivers/reset/amlogic/reset-meson.h +++ b/drivers/reset/amlogic/reset-meson.h @@ -12,6 +12,7 @@ #include struct meson_reset_param { + const struct reset_control_ops *reset_ops; unsigned int reset_num; unsigned int reset_offset; unsigned int level_offset; @@ -21,4 +22,7 @@ struct meson_reset_param { int meson_reset_probe(struct device *dev, struct regmap *map, const struct meson_reset_param *param); +extern const struct reset_control_ops meson_reset_ops; +extern const struct reset_control_ops meson_reset_toggle_ops; + #endif /* __MESON_RESET_CORE_H */ diff --git a/include/soc/amlogic/meson-auxiliary-reset.h b/include/soc/amlogic/meson-auxiliary-reset.h new file mode 100644 index 000000000000..f70dd864ef6a --- /dev/null +++ b/include/soc/amlogic/meson-auxiliary-reset.h @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __SOC_AMLOGIC_MESON_AUX_RESET_H +#define __SOC_AMLOGIC_MESON_AUX_RESET_H + +#include + +struct device; +struct regmap; + +#if IS_ENABLED(CONFIG_RESET_MESON_AUX) +int devm_meson_rst_aux_register(struct device *dev, + struct regmap *map, + const char *adev_name); +#else +static inline int devm_meson_rst_aux_register(struct device *dev, + struct regmap *map, + const char *adev_name) +{ + return 0; +} +#endif + +#endif /* __SOC_AMLOGIC_MESON_AUX_RESET_H */