From nobody Sun Feb 8 07:21:37 2026 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D940C189F59 for ; Thu, 8 Aug 2024 10:28:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723112886; cv=none; b=Cb8/w3Cfr1/XEz4WtjF0iuEIhqumOJeRu4tTrCamlKDhobx1MM9XXG8KQvtAep+ZGjYmJDyHnb/iwrCuEGpkH/nGwUM1FWDRWHUqW/oKJTjgKQ1yQEnUOXpoq2sjhwfcRqaXxx4DTAlk5yzCFHiIVWv+V1Q3rQr+77TwlewqVKQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723112886; c=relaxed/simple; bh=VxrGpDNMX8R5lgwAxG/KzKNsVWNXJHDG0Pc8zBTHDuA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mtkPnmzoCoMsZnDWNi19/cyOMJ4o3/bXIwEjFInnX+cWVLcDOK/I3nIQrHApfFPU8828NbSsjeKskPZ33USHsREQVMrYuZ3qztHI3gtcy9PBWRH3F/WTRvrf8uYdc3AhNsBUIffWP3EOTlTvnqusrwchQRbINXCQYvGGvyg2OO8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=R8OHwHbA; arc=none smtp.client-ip=209.85.221.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="R8OHwHbA" Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-367963ea053so631809f8f.2 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=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Q3DHNRvZJ0qhVqYezcY5P08/4agts36gA+QW7VdWHFk=; b=R8OHwHbAJBsRO+niJl6HGn7NDKmzCgGVz412HBem08wu6nwvEUZyQdotZGYj69I7qo oHjJcFGStH6+FZrIWDciPgmkEPPexxxUZLkd9JGRcIupkom31i6Ux/96QAN3bvmQyodY gHEwG4b412i6o4fsp1yslUUc6EEOSlw9SmviBGnPyEs6kKn8cwria0omJkxpWHeRKtf7 T6V4lNW0GnYCHrSufM079OPVWGw/wrO5YGlW1rLBfTnzLyX2gRNmFDZfGdiH7PCSae5e p+3wOW1yBfKb0mY42hW9y3rCdEYJlS3vaydG0mhiilqcdRSr1GtxB0b3UQg+mH+tltvs 7vsg== 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=IniWbhL0eez+XlkbE1E1UYadvkHGAoNF2cccNWNMbRyp9v7c8pIzVj8AhxqW1/8exR pItmI1FwZJGhzLLTYWAOQTgFZEnbKY0PqsdISAtMJUAcS3iBTO6bvFu7GUmk76YLbl+a tdVgMdr19BwRaFQd8tU9yf9sIOOFCn+8fQWDug8ggNikAeqBBOTXlo57ui1FiZxM6Om+ Pbe8qD+ViO88aoxPYy4cQA/5xSug2hy4B88bTCyq5SpYTkTgcIj/PS8baVWz8KX9uA4T G8ftwJvo2yA6EPEK7P/DA2Ut22NjVTCq0gye3zcLf7S2Pn5ghkcuWJv8nMBeCqWwS2PD HN0g== X-Forwarded-Encrypted: i=1; AJvYcCWQFNLbJ3bNyIswfX7t3t9qUxzypo0GxizdBlekBljwrcjnwldctXa3Gk4012sr2kq4XpOIsOwm4u3A84h1y3Ms2erM6/XzBsr9MOWF X-Gm-Message-State: AOJu0YxNoV5mSeV/79Pm5D7VJuXcy7jHMa844+ki05k3fhtv7YdVtGHq gA7gV96L2yh2wnSeH2Hh2SCCRntSTFEg/jSsCg58ac9DK9kwaI8JST/kxUOjoZM= 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Bot: notify Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =20 -#define BITS_PER_REG 32 - struct meson_reset_param { int reg_count; int level_offset; }; =20 struct meson_reset { - void __iomem *reg_base; const struct meson_reset_param *param; struct reset_controller_dev rcdev; - spinlock_t lock; + struct regmap *map; }; =20 +static void meson_reset_offset_and_bit(struct meson_reset *data, + unsigned long id, + unsigned int *offset, + unsigned int *bit) +{ + unsigned int stride =3D regmap_get_reg_stride(data->map); + + *offset =3D (id / (stride * BITS_PER_BYTE)) * stride; + *bit =3D 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 =3D container_of(rcdev, struct meson_reset, rcdev); - unsigned int bank =3D id / BITS_PER_REG; - unsigned int offset =3D id % BITS_PER_REG; - void __iomem *reg_addr =3D data->reg_base + (bank << 2); + unsigned int offset, bit; =20 - writel(BIT(offset), reg_addr); + meson_reset_offset_and_bit(data, id, &offset, &bit); =20 - return 0; + return regmap_write(data->map, offset, BIT(bit)); } =20 static int meson_reset_level(struct reset_controller_dev *rcdev, @@ -48,25 +55,13 @@ static int meson_reset_level(struct reset_controller_de= v *rcdev, { struct meson_reset *data =3D container_of(rcdev, struct meson_reset, rcdev); - unsigned int bank =3D id / BITS_PER_REG; - unsigned int offset =3D id % BITS_PER_REG; - void __iomem *reg_addr; - unsigned long flags; - u32 reg; + unsigned int offset, bit; =20 - reg_addr =3D data->reg_base + data->param->level_offset + (bank << 2); + meson_reset_offset_and_bit(data, id, &offset, &bit); + offset +=3D data->param->level_offset; =20 - spin_lock_irqsave(&data->lock, flags); - - reg =3D 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)); } =20 static int meson_reset_assert(struct reset_controller_dev *rcdev, @@ -113,30 +108,42 @@ static const struct of_device_id meson_reset_dt_ids[]= =3D { }; MODULE_DEVICE_TABLE(of, meson_reset_dt_ids); =20 +static const struct regmap_config regmap_config =3D { + .reg_bits =3D 32, + .val_bits =3D 32, + .reg_stride =3D 4, +}; + static int meson_reset_probe(struct platform_device *pdev) { + struct device *dev =3D &pdev->dev; struct meson_reset *data; + void __iomem *base; =20 - data =3D devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); + data =3D devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); if (!data) return -ENOMEM; =20 - data->reg_base =3D devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(data->reg_base)) - return PTR_ERR(data->reg_base); + base =3D devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(base)) + return PTR_ERR(base); =20 - data->param =3D of_device_get_match_data(&pdev->dev); + data->param =3D of_device_get_match_data(dev); if (!data->param) return -ENODEV; =20 - spin_lock_init(&data->lock); + data->map =3D 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"); =20 data->rcdev.owner =3D THIS_MODULE; - data->rcdev.nr_resets =3D data->param->reg_count * BITS_PER_REG; + data->rcdev.nr_resets =3D data->param->reg_count * BITS_PER_BYTE + * regmap_config.reg_stride; data->rcdev.ops =3D &meson_reset_ops; - data->rcdev.of_node =3D pdev->dev.of_node; + data->rcdev.of_node =3D dev->of_node; =20 - return devm_reset_controller_register(&pdev->dev, &data->rcdev); + return devm_reset_controller_register(dev, &data->rcdev); } =20 static struct platform_driver meson_reset_driver =3D { --=20 2.43.0 From nobody Sun Feb 8 07:21:37 2026 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A108618A6A8 for ; Thu, 8 Aug 2024 10:28:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723112886; cv=none; b=aa2bOFWG+4yz9dH3zkNMdYW57Cg0WF62fYiaCp061Z55t+V7qLqC1bfwkpPhzrjLK08MhrKheXbyw7tKcEmd8thnBf3QqTeKA2QikFJFnkpGEcOaJidhXkxtgC2MZPchYBbJ9V+8119V2DijBJheFS083h8Kf3XRrx0NvK/zd4k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723112886; c=relaxed/simple; bh=NerWYmC0Zj/71XZg9G0jYL5bD9JcYGXHp2BwBzjd9Xw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MCDctuK9pDv4iBsltbTL1dmui3wQhA6oTL6XUxrvTWngqUYeEvA3QdzoU6CjtoVj+OZ/FBe7o5LNTL8vxPvpCgSKSFO8KQRa+ErfTx2QWzNDCvY61pid5mZzV5ibk18h5eIq90x+3c8q13VbblH47zbgDQQS/wyPHwa0er4ZHIs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=JpqZwvxn; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="JpqZwvxn" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-428ec6c190eso5824935e9.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=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eLs1XU+vYdzxst2Jx1X+lCyMt00FFZC6iTK2ta7VGO4=; b=JpqZwvxntCdAb0zqi2i0MXVu0XNzZHFscfImLAM7wN2Uh1+PYECpJEOAqRbY+Rpz61 oarJFArD8nqOxQc/Cc6L6a0ctDoBE6hUrLuHUz3pYUZ1Bba3ffSR9aybOj53Yaph0kl8 2KPg45ktyiXU74ZwxbcCifLiEiKjN50nuZR38f3mJGRWNqNjU6zPSIaOk8WCTb7JqWeJ qnDjoWrdeCOSsVB0LFyGDz4Hu8NlARh3GcyWKmx1+9H2a34mUy2nbVzFaB0z2ncV75hr 62U8jtcCWuDUhAuWhynWRaepfOMCfdFyWErv9r0YTmpyv6wm1LwuSMxS9UNnepOi+/Vg iybA== 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=dQXoJyDs3u8q7Z+06YFfJpIauKtHo75ItA7mUboymoDVknPsy+d+XvekJMr1RMUmX0 jPij2xbT8SXP4hMw2BKGsryIkwnzm4gMqOgcoeQhTLVVYsPNWsDmL8dWPF32lMBUKWv/ 0t+bat6MOeaqiZa3mMJihL+dLdjrimkqvhywqxryUCq4iLBr9yy9TXrJRtmyqoJ3PfVB 2c0T3bv4LJ0yj/Fvaiai+Gd5NeFPxTa1TjtPNEsCWs1wTiRoXMNwqKTZjHL2YOdmrFEf xtEvBxgtUNIM3EquKutHPSolksyuprOxo0fP0Uwp0mJxcIr2G5Tuieq3tQai/14+xLPp IMZQ== X-Forwarded-Encrypted: i=1; AJvYcCU+7hK7iQXamiXIEsOEj4zObpfYoT5xLuKEveS1ix/GijCmYVBva2B4WGUDjI+IeCeqBzTl4vTXCrdlQrADVywwrzao6iDL1DHfqDV2 X-Gm-Message-State: AOJu0Ywwf5fz3obpJn+dA/9ablvGOd6bH4qnd6hwXbch4rvZsgYNeSpg dttutPWZZSOADJNUBnOTn3JgRkM050CdXlY18FrTW15mkaq7VCOvzeSyrBke0Qk= 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Bot: notify Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 *pd= ev) if (IS_ERR(base)) return PTR_ERR(base); =20 - data->param =3D of_device_get_match_data(dev); + data->param =3D device_get_match_data(dev); if (!data->param) return -ENODEV; =20 --=20 2.43.0 From nobody Sun Feb 8 07:21:37 2026 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4965818A6AE for ; Thu, 8 Aug 2024 10:28:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723112886; cv=none; b=Ebjkz9mwAEfa23b55oO+LbtraRvBxawBky6aXblky4+hOEZieF81gCJY8ba1JZ1Ele6/GWyCDrexDE31zORe4HOMuJ4cwhLQJxAcILsISiv2ZECs5Ihm8grfmu8didDEdWtZ7mglwrCMIVTgUma+lPY+YNQf9s1p86jpLTIJNts= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723112886; c=relaxed/simple; bh=ouBTIN2jRU0pfNdAImzVJxq5KmrTpV4HJkq32LGYJ0I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=l5uktciDtmToLt1IKvzi5yc5JoFgW8e5Ri8BSxJT47BS3ZKWWndojAgxivI59FuF7zjpUGRy/VqFeYfV9NG8RC+QWaEhpsZxJ+d+pep11TnjWN1de8uT/tQ49yT5BQ8CApULt9x2SCXb1Ukv8jvXi8V13bPa4l0dug/44YyY0Qw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=LY4wfLp5; arc=none smtp.client-ip=209.85.221.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="LY4wfLp5" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-3684e8220f9so441993f8f.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=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Mtmd6W76tUil0cCcam+JDZpBYdbmzTJHGckyhD7jrDk=; b=LY4wfLp5ovrTbQn14/rBelst+3F01Scu2aCp/S773Q3baFnkVu9A24yqSc32NfIKjr NoSYeIXZuN1JHadsh5gBF45wYBGlU1IolxI8vDDpHnBZdtvP3T16SgGyCekQYlGPZQa7 sV+Ff3mYlJBLo07GC8d32gu9/rg3sBl1wsQaV+OXEs3lrS7YeORZVb5V/ZkveiNJXCWR V6ZuBxmdeW0WNMxXoMyMmBJjiEk1rKbE5s8N2lymzzYNuZQw+f2ngHqtaHxUp5IrP9Jc m49n4RgECXg/kIyX2gFfPXRLyLCjdAUvvcY6dTb/guLVE/MkTAZVSBoN0hnKXsN9yJ33 7TwA== 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=rRGfN6lDST3N0peL3s8XtvmkPj/No2hkYpXTxGaUwnDqkUItysm/AvV5QglahiSdN0 MXHfDXTCooTu75w639mnSswK3yF3uDvWvvTfR2ESYshSIofrW9qCXvCGnffBADYLjch9 iBMnpVcgs+vJ6TzioZq0vJrX4Ap6SwFmmGrbumbdmFz6rLPvwfSk2w2hSnA1K/FGzjij Ty8/v2Pcim6jweMm4TGxzy/QNKhd9AAPQecgb0VX/273k7qNgxl9In8bGGCObonO+A7G etKCS/3im7hSvOWPcy3Ldm5KVTeoO3qe1S24mzGDFAs03hGpnutTyZwI17RXtbgKJXT7 b1EA== X-Forwarded-Encrypted: i=1; AJvYcCX+uLKeM0u2iAdT2xaSWiV+E/s0AKTRrhh/R77RSP4MwlFSqWcIeYNhMxwLUFS+YpKdy7bImMYh5ks9S0rUxwmcbgErqyZndsRup3Jo X-Gm-Message-State: AOJu0YyWJs4aEYNzttHH7ldKRhzMBCwrKS1MoUDl6NVV+T0zVNszq2PT BfQFIoOB0WNV8njpDQNP9mDd5oWI1AMlLCnP28hrGV9rYUpqNPwomxijxfAkggI= 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Bot: notify Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =20 struct meson_reset_param { - int reg_count; - int level_offset; + unsigned int reg_count; + unsigned int level_offset; }; =20 struct meson_reset { --=20 2.43.0 From nobody Sun Feb 8 07:21:37 2026 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C804F18A6B3 for ; Thu, 8 Aug 2024 10:28:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723112888; cv=none; b=uqe7n9L7bXniUjWBgnwjdHvAvIMJBpbjsUUlcVyyk1RIg3iem7BJr88ka8+YG3ptU7fXU4rNoQuB1eBZouvaQI9nzkel256kN0grn7oTnqHZ7aEw6pUk3Lx8P8GzQTPjRLg5+9QQ9UJ6q7HbSBhed4HODjk5c+I4ALdK5GTE3YA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723112888; c=relaxed/simple; bh=mX97e01MPkA2KLIL7hS96bYzDDAlkGTLJdClNcccIkg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YEyA6Mvc2RyW5B4EWUpcScIAUphHjyOlflzW18Gdd0/4i3NMmdrpaEI0WHyaBvb0QiiZ4Ye3pRVNVpsdp1yCnnpUCYHKzMIHTGC8L/hZJkGseCxtbnYTXT6ID0VcA/RT7b65IqLHtIoLgy243zuyIzpo6EUe5xKHx1qLvWkwpK0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=Ax7RODOk; arc=none smtp.client-ip=209.85.221.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="Ax7RODOk" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-368f92df172so393375f8f.2 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=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pr0Cx+l93ievhcSqcQh58PvVUEHk0s6N+Y0wdAmtxHg=; b=Ax7RODOkK2i3nuVWANl+CpYAiF+gF6VPqi2N+evFanfdJ5HyorfP2PCgOdId521bQC eK071sFqPcIukys0eTjWRmibgQ30I/X9lorXtI6pOcsZ8zc5ZTBpImR9W8NX5MY9LzKq 5KrfXoXP67JZOMMDMFHn7+KOhUFlZp1YRmRQQuPWC1/Cq+GyxRz4sb2rtFP2k8AaV2Fe aNk1uMVb0v9LkaLrzTXyfiQRXgcPDx4MjhcZ49DPhwkQ4OSld2x40k8GscnVoZHm/WPI ufSlUvB7xoEXaRY693CJuH5z0UXTLjtBQTVQJnjX0Y8PpVBoFbiVuqsr6muOE7zx8RUM Humg== 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=BKh2KP6rkVNrgTOsJJdEyml1g4FhqdcGB6dSlCGJKNUgl7oRyu8+/sRsl/yqWpwwu4 nB8szom2dhzfubqtxTqt49L9OAtlJqpKZseJ5qPn+Vm2tjGkSfC21NDC1kURTv6142Z0 Y98qp0lM9/l8L6nahsXMi6aHEyrVj3qpFnraR2AqK9SX2vzllln86t+5iB0b5pbfqBHG LfexutuS/fB0S/JrGtZ1AQMcTIl5V31+AcPVF6tzZPrS4d0SjpVHVHo4AU+QvlgE+uLy Ox1B6y/I5oDNfmvsdosjYK1VsPo4+y7zN69F0aRK+sYWyNq/g1+e+fosRfblJ+MQwhhw mF4w== X-Forwarded-Encrypted: i=1; AJvYcCXTJE6lzIfhndzWqAMpsl3HGYDLhCjDfiKFn/BZWrgij7EUWRULQazx5bVVfH1RYtbuKiNiVtIl36+Yx740jdKouJNajNIpHZpmnnpa X-Gm-Message-State: AOJu0Yy8dYekrzLUyvVmJACOu3KWhm5rDp9KJ5qJzZVelupa1imbMvjF UeP2JepnVetsLebWwuTJMW0y3FlFuW0CcXVpcSWSrGya9uNI9sh1xlD/w/rQjN0= 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Bot: notify Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 @@ =20 struct meson_reset_param { unsigned int reg_count; + unsigned int reset_offset; unsigned int level_offset; + bool level_low_reset; }; =20 struct meson_reset { @@ -46,6 +48,7 @@ static int meson_reset_reset(struct reset_controller_dev = *rcdev, unsigned int offset, bit; =20 meson_reset_offset_and_bit(data, id, &offset, &bit); + offset +=3D data->param->reset_offset; =20 return regmap_write(data->map, offset, BIT(bit)); } @@ -59,9 +62,10 @@ static int meson_reset_level(struct reset_controller_dev= *rcdev, =20 meson_reset_offset_and_bit(data, id, &offset, &bit); offset +=3D data->param->level_offset; + assert ^=3D data->param->level_low_reset; =20 return regmap_update_bits(data->map, offset, - BIT(bit), assert ? 0 : BIT(bit)); + BIT(bit), assert ? BIT(bit) : 0); } =20 static int meson_reset_assert(struct reset_controller_dev *rcdev, @@ -84,17 +88,23 @@ static const struct reset_control_ops meson_reset_ops = =3D { =20 static const struct meson_reset_param meson8b_param =3D { .reg_count =3D 8, + .reset_offset =3D 0x0, .level_offset =3D 0x7c, + .level_low_reset =3D true, }; =20 static const struct meson_reset_param meson_a1_param =3D { .reg_count =3D 3, + .reset_offset =3D 0x0, .level_offset =3D 0x40, + .level_low_reset =3D true, }; =20 static const struct meson_reset_param meson_s4_param =3D { .reg_count =3D 6, + .reset_offset =3D 0x0, .level_offset =3D 0x40, + .level_low_reset =3D true, }; =20 static const struct of_device_id meson_reset_dt_ids[] =3D { --=20 2.43.0 From nobody Sun Feb 8 07:21:37 2026 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C18E918A6D3 for ; Thu, 8 Aug 2024 10:28:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723112889; cv=none; b=G5p99+uuZS+jhDx7P825SuCNIlUImYzNZqFq3LOvzXHhd+RnCk0MANVGCTF4+4F+CMV/MQUiFhVO8BXBVj9xTAeMsN5Nl0WrwRdZsTmERqUDgJ+JkRpq4CnoZj1QBgPw72LYYfVnvI2LOJIUVCQP87GxI72NIjQsVFoAMIZJNeQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723112889; c=relaxed/simple; bh=QSWG+r3Q0UIT+KgY1i3jfYrp1y6wAWuw6wMU7KYNqvM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FcHVEk11ZVJRxGrz0JMoKyIOZe0qmS2pZzinTtwGJlap9KNxQXjvgHgLwG2VoW2ahOx+z1zKsMUT3Xa9iRioSv4AqUIvzBAgIVyH64tQZc4kfeS6tME+IFrUvY/wf/fFQAOOLP03s1XPD2tpR3Od509kTOEdJp7uJbtCPbkQwQQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=w9kpg5+z; arc=none smtp.client-ip=209.85.221.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="w9kpg5+z" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-3684bea9728so464235f8f.3 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=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cPYzDSfyZeo+xZ43EsOSaQrJlRNd4kYLYsIOWeBqO/s=; b=w9kpg5+zHyEZm6QLmPA+jRtvjlFWB73KKW30gbO8cyQxSE3vNR65uWu2jONonveNnD SyVg23rTODLDrPLq3oh+X6JipYObIREM0mGt6dHc9andA95FQgzcecRYJrC6qWonoJja BKlkMOBLNIbzoi05bdXhrTEQ1Lb7g6KeckW+nFfWqnXjUTEVuP/G+FzCcY21RceCImwV KHnP/DQZS1/Y9w2TInsXYhaE2qc2rwEjU7ejNgy+4c8Q0cKJRg8Ega2QW7RLpy+yONo2 6kvPwIaOijsptX4Xx+7DFtLR2i4WK09KWtWJwFjHl4oz4uizDz/mzSENuxJXeunRKrZX HIUg== 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=JQNqX8ReUkJkDId92H0Q0hx9G1uGJ1/ggcL1OlDpBGfo5wxzCl3xVK74eaka5enDm4 F8wseZZMp/uMGYQYg3itH3WSeODhVbrKUvY2NtMvMBmvHxjVO/85s+PeFA1KYsVYpz+T 9fL1KPK/BQ3O2OuCyiMWPEEgxfCReizFbw0QT1wD5shrv6IrQAPn2IVZkef9SLCqkzok VQ1P6axbZtzpOdpsZxF2XBXgbcrVx0sC2tkPdBonJ/Y3tEVBNj82Yv//QMBDCM7sKRH3 sXijVEVNkh6XcsmHQHM74JUDZmG07znjUbUO6MWxgtFI0MWJlmW294tiQdRYHuKqlsXu 5GtA== X-Forwarded-Encrypted: i=1; AJvYcCVY6wTrtv7O6cZdOWs0ODpAArBqhnirpB/5nHI8Ytn1skLgRT7M4GD1C/NTFSrlLPO98PpzARiF9+UIg4f1qYvb7TDnpHMkzWJbsofI X-Gm-Message-State: AOJu0YzRklCaIQcqQ5NzyfpeVL4mwDptVSHgC6HDWsJzE5GsbxRKp3X4 EI8a03hh3mO/PHXbdgznGOnxAhZPtkLNQIe3Ir+Y7QnCjw8XhMR9nN0HAB5qx6U= 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Bot: notify Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =20 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 = =3D { }; =20 static const struct meson_reset_param meson8b_param =3D { - .reg_count =3D 8, + .reset_num =3D 256, .reset_offset =3D 0x0, .level_offset =3D 0x7c, .level_low_reset =3D true, }; =20 static const struct meson_reset_param meson_a1_param =3D { - .reg_count =3D 3, + .reset_num =3D 96, .reset_offset =3D 0x0, .level_offset =3D 0x40, .level_low_reset =3D true, }; =20 static const struct meson_reset_param meson_s4_param =3D { - .reg_count =3D 6, + .reset_num =3D 192, .reset_offset =3D 0x0, .level_offset =3D 0x40, .level_low_reset =3D true, @@ -148,8 +148,7 @@ static int meson_reset_probe(struct platform_device *pd= ev) "can't init regmap mmio region\n"); =20 data->rcdev.owner =3D THIS_MODULE; - data->rcdev.nr_resets =3D data->param->reg_count * BITS_PER_BYTE - * regmap_config.reg_stride; + data->rcdev.nr_resets =3D data->param->reset_num; data->rcdev.ops =3D &meson_reset_ops; data->rcdev.of_node =3D dev->of_node; =20 --=20 2.43.0 From nobody Sun Feb 8 07:21:37 2026 Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1E30E18B463 for ; Thu, 8 Aug 2024 10:28:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723112890; cv=none; b=rQ6lXINe+cgWamPSOES0EdG0mCXGrRnooYOzyVyTr2jw+U7LhUBHgJjINejS7HHovnTrTbOeeKCxW+lER7x6+7yECWgUsCGTILXK7NFruZewuCDhUsd855kCUDl11XvZQsWNyNn+z4DqefSebH10if0iznDCOpO8i6o1Q6M7vdo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723112890; c=relaxed/simple; bh=YH6KsNQo0XkKJ12/gKzCt+ALliyW2i9jpAtnP7Z0NFo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ED7OaFABvYYpT5ijmdcxTqkfzLvZyrArfVBCfZnwsRWYoAqJLREhzLIA+ybKMwDfsvn6FaSfUjk9Kf2D2LhmgGKiihmMzO7s4QZfzu0qVjIlsp7pMEu2EgX2NclQn07IpbFhXyN93kKYZ7iy8yiitVZi44KkJMn6pW2HBRQjaLg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=cdWRkTMP; arc=none smtp.client-ip=209.85.208.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="cdWRkTMP" Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2eeb1ba0481so9719971fa.2 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=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SOSS3fc3XJBt3dG7ljbXMabd9Wrb6fH1OeKQO8767lc=; b=cdWRkTMPN3lvU1U7sQueCHZyGVIY1lBkjJlbNA+EIG2Tuf0JRP+0mX+DUYBsOe/kWe NxYEgUz3RBlLnXJ7f/ay7C0iYA+lJ72JK6TPPfAN84EcJyHW0DXS2PIuTesKPnOSkg7H 1FecbQbvfdWzDn1xu4w55X8yeyO1dwdZlQErWBzDnttc1zoin3H7mccsMvwr5wEC2jLF HHuh8y6mmJ/+15fNbfpxp31f8ThaPu7be0JgLL08pmzP2FpcfFHzfvSZQZAAALKg9LmG NYWZ0xkbU2QvUMPd/5R6azh2tYNU9Uzj7QvgdxNMawMrMBop1CUZzv358NMkKbOJXsmJ 4g0w== 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=g+VhVzkiACEArZK8MQ8lpRrw7Pa5R+H6s+DFDP5nmAZdJ9phjOJrUtjHCFP6iLR47E Y7h0iLWYIMn5oF1JnxxhP6jdR8TCPcJTjzNM5htTGqqBIKOYYBJY/ZOeSJAsLWMkpyDy FBfdXarjLBJ62G/0Esk2ggY6jiC+6z9qaZDqZAj831CRz8vj+y0BH4bRFEKxzmX6YxlC 0c9vNwZSdJaxNew4vd/3sVyleeiWSrpOczGAVId0eqaWBb2fRUHOZFciQD+0oStViweL Ty3C/nFfxxQt4UeQi+XkkWrFNB5RcbloqcnfzPyvZ84ur/fOri/KdJnK+K25JE9MDwl1 sRDQ== X-Forwarded-Encrypted: i=1; AJvYcCViPAmXSs9X9TVwnz8dCv0qQeXA6iJMMtpHEDu7X69u7NREq4GsOBrtGujUpQ9IkwZyO9bsX8ggqkywPgTtReBGSzFW4USGBZB2y92X X-Gm-Message-State: AOJu0YyZm6hQp0ig9C6aAtK1YvK8VccIcvOAkV4um3TysUK3srsmjneo mAJ7ILZt/ODujDfty8A5yo78Xr7BBrVQ1EBzKfGTMT0UfXkVVhnvUBGBDHE3R5Y= 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Bot: notify Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =3D - container_of(rcdev, struct meson_reset, rcdev); + struct meson_reset *data =3D container_of(rcdev, struct meson_reset, rcde= v); unsigned int offset, bit; =20 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); } =20 +static int meson_reset_status(struct reset_controller_dev *rcdev, + unsigned long id) +{ + struct meson_reset *data =3D + container_of(rcdev, struct meson_reset, rcdev); + unsigned int val, offset, bit; + + meson_reset_offset_and_bit(data, id, &offset, &bit); + offset +=3D data->param->level_offset; + + regmap_read(data->map, offset, &val); + val =3D !!(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 =3D= { .reset =3D meson_reset_reset, .assert =3D meson_reset_assert, .deassert =3D meson_reset_deassert, + .status =3D meson_reset_status, }; =20 static const struct meson_reset_param meson8b_param =3D { --=20 2.43.0 From nobody Sun Feb 8 07:21:37 2026 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 450AD18B46D for ; Thu, 8 Aug 2024 10:28:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723112890; cv=none; b=RA936PY97YNvRwppO8Tp4/EeWUOwnMjxXkzuHJnS+hwijOUwE2VKwkSCH0TYVqtAMdVO3+ATJIsw2adz6uAVv2rSVOxlyVWXG3ghdIBtIRpUsnbaQd1HazXbQzRPfnxOJbJ96uTFVeVdXltxaxLcgQRlr56a+8eLZkv/wsjvhFg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723112890; c=relaxed/simple; bh=FJV8WpUSAXHd9iSKbRipWBdZuj3nj2ZfvvNLA6M0Jig=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jqnsPEhq2dgZzsRm6Wfv5TEl9ucqNZZ4tMw5xXEXBrQTYZGS7BYtNQVIAW/DFppKVAG9D4R0T3TYN1RC5JRDd00GA+b10ZRwRPf/LFKLDMFH225JvKXEJxII5UoCvJ4bqh0PexeeV0G5WTlVTRefghp9KMJ79qiltZUuNIuyw7I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=FcfuIm9g; arc=none smtp.client-ip=209.85.221.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="FcfuIm9g" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-3683178b226so310589f8f.1 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=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=99vHG6KBBSHLQN8ohhXjHSjQ/wjLWpAkbUWnRIGsOKY=; b=FcfuIm9ga7WkW5B7GPRJ8riUbfCeVJpzaKl2HWDxw054M2+kOZ9CDnwBF9LaIfuJls FSy+N9t4dnqD8eMQpLfwm6dL6rr7LX0/F36IHCshX13ik4eNvNsmLzK+Tn4JftF+PAD0 k8Y/8it3qqHHFyqNVNRXeRH9bLi/JF7snRymXPWSSxaWZpw+9fCk9A64C+yWh2pwiiJG PAdp5bqjaOyoQM9vZEcVDFTb8jKSz3D0C1W1+AJvl1aqRbTB8Ma4itZp9y/6xayRUEzy Tz53ZB7LgkS+QCxKpSY4pGGhMEqrn71/nW0GNF3CjJTaCddGUcKenAKs73Xnp7kgB5wj vkHw== 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=wlhy9P69rZObXzwfN+kD99CSu/AwMm583sbM5aa0oxsagWFAdyRgDcXAUdENZzElUS +3cg8NESHeWwYND7mi/w3eg1Gq6kpsIu2gmOisUROqeU8ZD7SN0UPOYBA4lnkFUAi9Ww xlSKHKAhb19nBiWE0Ot5Ed9v+o0tFY5dmUU3esJJsj9eK+vYBj9hXwZUiuXPOM7Ig8UF oV3w2vE2zPDZV4vHXD9aqsEbk2zWBWKDzUMS8vPbcaMee0ZG0apmmhItoQRwfoqPPA3o 8ZzeQx7aSZA1Y3d05QXOjkLY2Bh6v1+tBnUJkdKnQZBChAzmb0PP+5G9AAYj3yZWfTGn 7hqw== X-Forwarded-Encrypted: i=1; AJvYcCWb0zh43R4vG3K6zbv/FedUO06GHf4lK3xeZwm7WpKqfhnL0DFQZYduavKWwsLhyY0mW2revkbzVcVXf/Wn211mVj4W1aS2k/LdVQgP X-Gm-Message-State: AOJu0YxQp17WDAnKaeJ9Cw6FRN6jlIjOdvgjpoH1hrhyFs6JFVNWqQqN cK9ldA+Oq8nKwvZmlJmWhrtRcBU+5Ptg3k2Pi+ks+UKylSW/citZbsvkDcRL8L0= 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Bot: notify Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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/{ =3D> amlogic}/reset-meson-audio-arb.c | 0 drivers/reset/{ =3D> 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/{ =3D> amlogic}/reset-meson-audio-arb.c (100%) rename drivers/reset/{ =3D> 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. =20 -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. =20 +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 +=3D core.o +obj-y +=3D amlogic/ obj-y +=3D hisilicon/ obj-y +=3D starfive/ obj-y +=3D sti/ @@ -20,8 +21,6 @@ obj-$(CONFIG_RESET_K210) +=3D reset-k210.o obj-$(CONFIG_RESET_LANTIQ) +=3D reset-lantiq.o obj-$(CONFIG_RESET_LPC18XX) +=3D reset-lpc18xx.o obj-$(CONFIG_RESET_MCHP_SPARX5) +=3D reset-microchip-sparx5.o -obj-$(CONFIG_RESET_MESON) +=3D reset-meson.o -obj-$(CONFIG_RESET_MESON_AUDIO_ARB) +=3D reset-meson-audio-arb.o obj-$(CONFIG_RESET_NPCM) +=3D reset-npcm.o obj-$(CONFIG_RESET_NUVOTON_MA35D1) +=3D reset-ma35d1.o obj-$(CONFIG_RESET_PISTACHIO) +=3D 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) +=3D reset-meson.o +obj-$(CONFIG_RESET_MESON_AUDIO_ARB) +=3D 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-meso= n.c similarity index 100% rename from drivers/reset/reset-meson.c rename to drivers/reset/amlogic/reset-meson.c --=20 2.43.0 From nobody Sun Feb 8 07:21:37 2026 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E9F3018B488 for ; Thu, 8 Aug 2024 10:28:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723112891; cv=none; b=IEtK0utAeRCUkN4/tkp6Oq/fXbvIGaM3/EAn65w1pQDNoK+yiAMtR+0bm2h5rmPcPb7aK0MYjZcPkPA6uqwkFpUU8XzYjKy7PGqzTeEbPizFWFWmGkZ2eNEmipTsFaLMKGAjlDzxPPXZau1cRY2GbHzVxStUoj6e2D8WCV7lfdQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723112891; c=relaxed/simple; bh=mFDjyf3WRN8A9pQQQLievbp8sSfjF42ekOPZY+9tCUE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U4F3vR0tMMk6WZQkvQQvffc2wBtB0wxqO3WEWqTYWWAksMpr0gOq+oaDhR9BHSmpX7MlsiAUXAflAwSPLQaxsWIp74OYXvjsv/D9bbh4JOPmv39PP/PH7li0Ke6Kih+bu7L51oaUDnt4DsZTErjNHWiJ/kJo3tGMuErYQdCzNjY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=2Sim2PFp; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="2Sim2PFp" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-428e1915e18so5186455e9.1 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=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0x1lfpdLeHdHaVZLxnPFzwGf3V/7oMT6QazhAgPTFUc=; b=2Sim2PFpS9Kc4JJRdksWS17AmrWtApmZBa0DscDBhcMsv9xU6ufvhOIPuMJBGZyZ0n xuwwi5MN0VrtMHogMqj2zZRcVBVcObd/dnwgH3XCc09mSN5scn2WcKOEc0fS+W3AZViA MuhneWPgO0fEx4VDiCpaSEzUmz0tD1hwcEyo5Nu4z1cgba060o4b1dlEzs5E6VnGAVNp kdF1OZMsJh6gzXvxWxdSDHtpSeSlDH1RnCVAcw3UDM/sdUbNYB1DWszfb1ojQMThFlF4 kdzYdI6E9tDaV7npAw/Eu5eJj2AoLDwfjKw0OEtMTD1vPmOFRlhRAz6g0f8Isu1xr95n JqLg== 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=JWH0E2zGISJoSj0j3QZKtIUKSUBQb+DDoE897kgwJ1TXkeeDBx4buLngvMbo4uQG+Z naZVH5uil1tkIfSoZXxh2EdjpjPXZVjqFi9N2heB/Qhg/MnuTro0AjjhfGgqiVmBa5Y9 SvnxK1IHxUr9MFv+9cZg4VEzaDpbkpdHs/WkWceTe3JvJ53bjMuqAST5Izr9XW/XaO1v fzh6LVpBObnS3pfgqJBMMj6dAcf5e6kWg6AQkVMsPiZW8wZw2hs4T4OtJFj9gg1ToMco Qm8MLsY2SBJ4u7XdUX0sxAXn3Ml5UxpT+7+Lzy9dunE6ct6/SlyiAWMGBWeD6H9fUMDB +3/Q== X-Forwarded-Encrypted: i=1; AJvYcCWYuPITZI3jTpjPFC3AnfBqA7tFaMHqJsrmXecMhQiDPalT49RNYDUnXF0oF4BCJFdeSqynH5tXbNvO5VsVDy2qoMgO0GlrEufDxTXk X-Gm-Message-State: AOJu0Ywdjds/9hWLSYJtZjYoD1TUHe6erXolbZ5noc+OBi7T/fan0dXx bE2zPNahLAAf2roa6eOZy3bnA9ZsLfDmKBrni8l2dpmqTE5PCdIQnRaR3b9mVrw= 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Bot: notify Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =3D> 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 =3D> 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. =20 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) +=3D reset-meson.o +obj-$(CONFIG_RESET_MESON) +=3D reset-meson-pltf.o +obj-$(CONFIG_RESET_MESON_CORE) +=3D reset-meson-core.o obj-$(CONFIG_RESET_MESON_AUDIO_ARB) +=3D reset-meson-audio-arb.o diff --git a/drivers/reset/amlogic/reset-meson.c b/drivers/reset/amlogic/re= set-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" =20 struct meson_reset { const struct meson_reset_param *param; @@ -102,84 +92,27 @@ static const struct reset_control_ops meson_reset_ops = =3D { .status =3D meson_reset_status, }; =20 -static const struct meson_reset_param meson8b_param =3D { - .reset_num =3D 256, - .reset_offset =3D 0x0, - .level_offset =3D 0x7c, - .level_low_reset =3D true, -}; - -static const struct meson_reset_param meson_a1_param =3D { - .reset_num =3D 96, - .reset_offset =3D 0x0, - .level_offset =3D 0x40, - .level_low_reset =3D true, -}; - -static const struct meson_reset_param meson_s4_param =3D { - .reset_num =3D 192, - .reset_offset =3D 0x0, - .level_offset =3D 0x40, - .level_low_reset =3D true, -}; - -static const struct of_device_id meson_reset_dt_ids[] =3D { - { .compatible =3D "amlogic,meson8b-reset", .data =3D &meson8b_param}, - { .compatible =3D "amlogic,meson-gxbb-reset", .data =3D &meson8b_param}, - { .compatible =3D "amlogic,meson-axg-reset", .data =3D &meson8b_param}, - { .compatible =3D "amlogic,meson-a1-reset", .data =3D &meson_a1_param}, - { .compatible =3D "amlogic,meson-s4-reset", .data =3D &meson_s4_param}, - { .compatible =3D "amlogic,c3-reset", .data =3D &meson_s4_param}, - { /* sentinel */ }, -}; -MODULE_DEVICE_TABLE(of, meson_reset_dt_ids); - -static const struct regmap_config regmap_config =3D { - .reg_bits =3D 32, - .val_bits =3D 32, - .reg_stride =3D 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 =3D &pdev->dev; struct meson_reset *data; - void __iomem *base; =20 data =3D devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); if (!data) return -ENOMEM; =20 - base =3D devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(base)) - return PTR_ERR(base); - - data->param =3D device_get_match_data(dev); - if (!data->param) - return -ENODEV; - - data->map =3D 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 =3D THIS_MODULE; - data->rcdev.nr_resets =3D data->param->reset_num; + data->param =3D param; + data->map =3D map; + data->rcdev.owner =3D dev->driver->owner; + data->rcdev.nr_resets =3D param->reset_num; data->rcdev.ops =3D &meson_reset_ops; data->rcdev.of_node =3D dev->of_node; =20 return devm_reset_controller_register(dev, &data->rcdev); } +EXPORT_SYMBOL_NS_GPL(meson_reset_probe, MESON_RESET); =20 -static struct platform_driver meson_reset_driver =3D { - .probe =3D meson_reset_probe, - .driver =3D { - .name =3D "meson_reset", - .of_match_table =3D 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/amlog= ic/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 =3D { + .reset_num =3D 256, + .reset_offset =3D 0x0, + .level_offset =3D 0x7c, + .level_low_reset =3D true, +}; + +static const struct meson_reset_param meson_a1_param =3D { + .reset_num =3D 96, + .reset_offset =3D 0x0, + .level_offset =3D 0x40, + .level_low_reset =3D true, +}; + +static const struct meson_reset_param meson_s4_param =3D { + .reset_num =3D 192, + .reset_offset =3D 0x0, + .level_offset =3D 0x40, + .level_low_reset =3D true, +}; + +static const struct of_device_id meson_reset_dt_ids[] =3D { + { .compatible =3D "amlogic,meson8b-reset", .data =3D &meson8b_param}, + { .compatible =3D "amlogic,meson-gxbb-reset", .data =3D &meson8b_param}, + { .compatible =3D "amlogic,meson-axg-reset", .data =3D &meson8b_param}, + { .compatible =3D "amlogic,meson-a1-reset", .data =3D &meson_a1_param}, + { .compatible =3D "amlogic,meson-s4-reset", .data =3D &meson_s4_param}, + { .compatible =3D "amlogic,c3-reset", .data =3D &meson_s4_param}, + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE(of, meson_reset_dt_ids); + +static const struct regmap_config regmap_config =3D { + .reg_bits =3D 32, + .val_bits =3D 32, + .reg_stride =3D 4, +}; + +static int meson_reset_pltf_probe(struct platform_device *pdev) +{ + const struct meson_reset_param *param; + struct device *dev =3D &pdev->dev; + struct regmap *map; + void __iomem *base; + + base =3D devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(base)) + return PTR_ERR(base); + + param =3D device_get_match_data(dev); + if (!param) + return -ENODEV; + + map =3D 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 =3D { + .probe =3D meson_reset_pltf_probe, + .driver =3D { + .name =3D "meson_reset", + .of_match_table =3D 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/re= set-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 */ --=20 2.43.0 From nobody Sun Feb 8 07:21:37 2026 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D19CA18C352 for ; Thu, 8 Aug 2024 10:28:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723112892; cv=none; b=hG6oB1+SWRaajds7EhiU+rSl4GgvKPE9bCt1dTSYiXrhBlKpF5kj7RliEM5AGFvBn+FM5f+7gtA+wlTY+xwaMmFj3fGuRns4EqYFySTB1Mr7ZLHPZWvE5HvFBlZ7JzUPA4ff9Ru+4jYojZdgsl2GXNmc05YMyHlFko1MK8vtPas= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723112892; c=relaxed/simple; bh=gRHaE5OE2DJ9BlHyPGeEP4d66Ka94js69R0NwtbyaDg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dAvcf+0MUt/e7cpI/iRxg6H2pbGeVyf5fcq/7UPiUP/Oq1nagkoZZ4CzaQcO0pR61c6pGNMbUurN28pLLlidoxaEmrMnMIpIsb5+Yi63p/CJGFFz5vYNs/mf23OPEIawWvg2ENlzV3gcAoAFpZMfiJ+LoM8elhfwflnidR10NLE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=IAQmB/jl; arc=none smtp.client-ip=209.85.221.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="IAQmB/jl" Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-36844375001so369594f8f.0 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=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uHAo36qJMD+4wxk3g0lOFfwjuuv+/seGus04OZIl27g=; b=IAQmB/jl+gSjMp0fkHgUe73FiiQCJSOHsKK+vkA+N7QC4dFVFdAMfTPMUq3elIJ5zY OrbDzY1xPj4ffvcm+aWo4PXj77GGDm6j68SBn2+fcT2KLBQKLyta5pgKir0QvgzDKGYQ yPlTP8ImalFSfIArT4H9AjEBaHC/WBfEWRDcSFLu7FslV+OFWCCCgldPdrm08BxKr23h cVYgKg2PxmBOQwMOAXDUlCZAI4BNCDkKBa7lH2BJhjxrErDNOzpjSTntXFnfQxQ8C975 F45LisbMH2BSG0NX0NNObycMRUDIAaCh/rJPJJS9Zz6/Ec5OnLQJZa3qFWGU0FEmVdbw jVHQ== 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=B7X4GFpglTOKFb4T4d2i26Q5zr7chnK7PPL0q3YzhZPI9+eLiVWhzOA9h4aKNkXKOe bHjB2lc5Iv9BkTuUq+273xR3xXfaAwgZujiNj/71RymLILGBu4TD+Hhxp+xZX4/aQX6q fvXz7dZL6Iva6Vx25l3TVxzwbshnuwNlILDPWbo+HBgRys1EN7wX95bH7I3ELOlo5aMF 77LPwRER81Tk/AAl+Bus1UBz+EHT3G82kUfGBl2oUCheFrC0gAtfOt+/FdR1K817cXx2 W/pt4/ws8xL3OJ9sULlEAALTUWMwicSZ0TwKOzVfZZMziV2Z6P/2lPvXiupF0ZeQhVux Oxog== X-Forwarded-Encrypted: i=1; AJvYcCWn11GQlpd6Y/7yt3+DPFN+Ky9fiRDufLNA/BqeILKXnmHL7yHweumFAfhgef/bToyx0izrBAeSWsinHHT7bcaA2CvpYAb5fvTj4Md1 X-Gm-Message-State: AOJu0YxYw3SDGsDPvdMphxocxciUDmq6/dK26MxGA9CBsz+lOA+Tw4D8 zleFwplLeoNCyD3QbXNVCcKSQgc3tlvVoEqEgt9azf1ZxfLQZ6NSX7UzWq+OUbo= 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Bot: notify Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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. =20 +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) +=3D reset-meson-pltf.o +obj-$(CONFIG_RESET_MESON_AUX) +=3D reset-meson-aux.o obj-$(CONFIG_RESET_MESON_CORE) +=3D reset-meson-core.o obj-$(CONFIG_RESET_MESON_AUDIO_ARB) +=3D reset-meson-audio-arb.o diff --git a/drivers/reset/amlogic/reset-meson-aux.c b/drivers/reset/amlogi= c/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 =3D { + .reset_ops =3D &meson_reset_toggle_ops, + .reset_num =3D 26, + .level_offset =3D 0x24, +}; + +static const struct meson_reset_param meson_sm1_audio_param =3D { + .reset_ops =3D &meson_reset_toggle_ops, + .reset_num =3D 39, + .level_offset =3D 0x28, +}; + +static const struct auxiliary_device_id meson_reset_aux_ids[] =3D { + { + .name =3D "axg-audio-clkc.rst-g12a", + .driver_data =3D (kernel_ulong_t)&meson_g12a_audio_param, + }, { + .name =3D "axg-audio-clkc.rst-sm1", + .driver_data =3D (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 =3D + (const struct meson_reset_param *)(id->driver_data); + struct meson_reset_adev *raux =3D + to_meson_reset_adev(adev); + + return meson_reset_probe(&adev->dev, raux->map, param); +} + +static struct auxiliary_driver meson_reset_aux_driver =3D { + .probe =3D meson_reset_aux_probe, + .id_table =3D meson_reset_aux_ids, +}; +module_auxiliary_driver(meson_reset_aux_driver); + +static void meson_rst_aux_release(struct device *dev) +{ + struct auxiliary_device *adev =3D to_auxiliary_dev(dev); + struct meson_reset_adev *raux =3D + 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 =3D _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 =3D kzalloc(sizeof(*raux), GFP_KERNEL); + if (!raux) + return -ENOMEM; + + ret =3D ida_alloc(&meson_rst_aux_ida, GFP_KERNEL); + if (ret < 0) + goto raux_free; + + raux->map =3D map; + + adev =3D &raux->adev; + adev->id =3D ret; + adev->name =3D adev_name; + adev->dev.parent =3D dev; + adev->dev.release =3D meson_rst_aux_release; + device_set_of_node_from_dev(&adev->dev, dev); + + ret =3D auxiliary_device_init(adev); + if (ret) + goto ida_free; + + ret =3D __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/amlog= ic/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); } =20 -static const struct reset_control_ops meson_reset_ops =3D { +static int meson_reset_level_toggle(struct reset_controller_dev *rcdev, + unsigned long id) +{ + int ret; + + ret =3D meson_reset_assert(rcdev, id); + if (ret) + return ret; + + return meson_reset_deassert(rcdev, id); +} + +const struct reset_control_ops meson_reset_ops =3D { .reset =3D meson_reset_reset, .assert =3D meson_reset_assert, .deassert =3D meson_reset_deassert, .status =3D meson_reset_status, }; +EXPORT_SYMBOL_NS_GPL(meson_reset_ops, MESON_RESET); + +const struct reset_control_ops meson_reset_toggle_ops =3D { + .reset =3D meson_reset_level_toggle, + .assert =3D meson_reset_assert, + .deassert =3D meson_reset_deassert, + .status =3D meson_reset_status, +}; +EXPORT_SYMBOL_NS_GPL(meson_reset_toggle_ops, MESON_RESET); =20 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 =3D map; data->rcdev.owner =3D dev->driver->owner; data->rcdev.nr_resets =3D param->reset_num; - data->rcdev.ops =3D &meson_reset_ops; + data->rcdev.ops =3D data->param->reset_ops; data->rcdev.of_node =3D dev->of_node; =20 return devm_reset_controller_register(dev, &data->rcdev); diff --git a/drivers/reset/amlogic/reset-meson-pltf.c b/drivers/reset/amlog= ic/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" =20 static const struct meson_reset_param meson8b_param =3D { + .reset_ops =3D &meson_reset_ops, .reset_num =3D 256, .reset_offset =3D 0x0, .level_offset =3D 0x7c, @@ -23,6 +24,7 @@ static const struct meson_reset_param meson8b_param =3D { }; =20 static const struct meson_reset_param meson_a1_param =3D { + .reset_ops =3D &meson_reset_ops, .reset_num =3D 96, .reset_offset =3D 0x0, .level_offset =3D 0x40, @@ -30,6 +32,7 @@ static const struct meson_reset_param meson_a1_param =3D { }; =20 static const struct meson_reset_param meson_s4_param =3D { + .reset_ops =3D &meson_reset_ops, .reset_num =3D 192, .reset_offset =3D 0x0, .level_offset =3D 0x40, diff --git a/drivers/reset/amlogic/reset-meson.h b/drivers/reset/amlogic/re= set-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 =20 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); =20 +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/amlo= gic/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 */ --=20 2.43.0