From nobody Sun Feb 8 04:07:38 2026 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (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 0993686126 for ; Thu, 18 Jul 2024 09:58:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721296689; cv=none; b=YltiGw5kSIIVSj6HJi7iwMf2HuCajZvvZBw7izxEQEcz5x/yRag+7f0IaY987gEhPY4V52lQsUJ9/8DWXC3TPdGcmL8upYIgKFwGpsOvFUWKiK6pNphwC7SVQ/ykjfl+Ln/0haLLyqfSHLo5QJt2XX1LtrkCOT4U26TiF2L5PL4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721296689; c=relaxed/simple; bh=cxaqUoQ9aguHyFdmx85j2AoRbVwkuszVVEgKQCGMEX8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=E4Qcl0S8eEaP/vGlikHPnc/zZnSpcMJ+RqQNPzQpzIb9+O41aDdc/gQ0F8ivHKlyoH6wEpQdNfcTB3qdQYRhU7mx3wGIHO5McQIUJAoe7QsmPMZHXFfj3GZpLjbRkV8ndH+fYuIEfLgYQcnpEmOzz8hfVNO4yuhjTpKGtjpgZc8= 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=JAp1nfl/; arc=none smtp.client-ip=209.85.221.45 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="JAp1nfl/" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-368380828d6so420422f8f.1 for ; Thu, 18 Jul 2024 02:58:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1721296684; x=1721901484; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+f/3bReYMesF4TJq9BOi7hv3PG6ArjPAwHRzmWrlWAw=; b=JAp1nfl/mUpnT3GSrT+5Dc8Y0mNb84sLVaWAmDyW8veLLmLKy9Qihv0oyqKOM6SvmU YfWCtHUvb+LC7H3tMN7Urxfl5DWHdl6PHwGZV5zwMUP6JR97UYJBDZ1xFn+84pw2BXcu AXGPpJzk/0dV3EgA3uxMnyzafslm8HNbkGo/xcz4MNPGM0U8//j+N4QlK1dqcTK1RGlB asz5R3eajummhQQfwLfgNB3CctDFEIwQ9IwRmzkkgqMNsZwGBFOsXXQWQcTmPqUTw84d kpLtbWXavKuuEMT2tYTODUA26ENtO3kz6B3J/6AQ4gc6REF63y0nQ7V1XR3YVC4I7OEd NU2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721296684; x=1721901484; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+f/3bReYMesF4TJq9BOi7hv3PG6ArjPAwHRzmWrlWAw=; b=mJVou3SHYbbY0uMRigxXbS3GKj9SUi1jCgQhUyNC5A7zZUa0+43sRbJsQ/yuVrnerO b1DCgkmEOtnRUo1UZUBo/LZesXCM4helh+XBZBEDZS1LPlLayOibogGSGP06aOULhHL8 K46wmYP0QY8lmxC/4lW+GUR/SH28bpYeZwieotyelKZvHUbbfWNHap5SiKcjxR7YQK+9 MSIyfwbdd0y5od3o92WXDya4tDRZeQ1u3VUQ+epXwBa/IdBUnOy0FzxZeKqryCL+JCB6 soC6mnNC9SA8DYzFbK6BuXa4CgifO3hnUVHxd1o8Z5iI21uPixOcx1hE7a6OkpI23yxp TpOQ== X-Forwarded-Encrypted: i=1; AJvYcCVBLt+YSGWrwFpVYpar1Ff5c/zvBdZekvRcHH0NqkeqeScH4HkgCaa4CeMSBSmnFsKUqOiy41F7edkD2jVJEb15k9qgFeKUQ6hfGSAw X-Gm-Message-State: AOJu0YwHFvWeYhlGCKtOt8zsxHlIBKw9GCROtNBNETcwjjrmXcdqJksg VCm1dIEfCEjcip5SGEZNfc45wseXEd1pcYUfsKlH9vqsgzKeDk/MkwWGcurfeAs= X-Google-Smtp-Source: AGHT+IF2wpylHtE0GsGjeKwrPISupVDdqlSWSz7Bc5nyMlVO3EB3+GjMC7UpkG8hkKpJnSbvcphnrQ== X-Received: by 2002:a5d:540d:0:b0:367:9803:bfe7 with SMTP id ffacd0b85a97d-3683171fe16mr2596315f8f.53.1721296684185; Thu, 18 Jul 2024 02:58:04 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:8d37:f44a:c212:e320]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-3680dab3be3sm13837155f8f.24.2024.07.18.02.58.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 02:58:03 -0700 (PDT) From: Jerome Brunet To: Philipp Zabel , Stephen Boyd , Neil Armstrong Cc: Jerome Brunet , Jan Dakinevich , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org Subject: [PATCH v2 1/9] reset: amlogic: convert driver to regmap Date: Thu, 18 Jul 2024 11:57:45 +0200 Message-ID: <20240718095755.3511992-2-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240718095755.3511992-1-jbrunet@baylibre.com> References: <20240718095755.3511992-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 --- drivers/reset/reset-meson.c | 80 ++++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 36 deletions(-) diff --git a/drivers/reset/reset-meson.c b/drivers/reset/reset-meson.c index f78be97898bc..8f3d6e9df235 100644 --- a/drivers/reset/reset-meson.c +++ b/drivers/reset/reset-meson.c @@ -11,36 +11,44 @@ #include #include #include +#include #include #include #include =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_update_bits(data->map, offset, + BIT(bit), BIT(bit)); } =20 static int meson_reset_level(struct reset_controller_dev *rcdev, @@ -48,25 +56,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 +109,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 04:07:38 2026 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.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 A7B1612AAC6 for ; Thu, 18 Jul 2024 09:58:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721296689; cv=none; b=Ysycm3tWCWG6KAWSQmjkR3qypR20Q+L8EECm3+UatYxlWXGIvWbiaU5n9XauEcCnWKBm80C5xcmI3YsgZfP/BEhDbiardGq7coI2c/C0C0rK66dvK7nkyNrnlRjr7YZMRuIFcTR0p3rCDk0r9Ur0R7/MU5nb6VQO9P2x1jqdOaI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721296689; c=relaxed/simple; bh=stfv6wCp8LQ8d3OZA86W362D/4yVzrX9ApYD5+7KnVg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FxHIVZafzDjLmS4f0IJ+E+yzSOVOyE1xyqTaIyNVdie/87JkEMFBKXXQxnpMmfQxeHsSPicsjVErt5X/HTuVwrB0/FAaemNGapD+6PIvYRYMtEOIpx3nWpRAnqwtFBGs87UtmyDH0vZl6DoeyV0dsCju6hs9Y/tCQS8VuvINfjw= 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=ElxYlEfT; arc=none smtp.client-ip=209.85.128.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="ElxYlEfT" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-427b1d4da32so896765e9.0 for ; Thu, 18 Jul 2024 02:58:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1721296685; x=1721901485; 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=LHnjFErAgDASCliWVSwJYSmFcBoJAvgxBHMIXQRsSBo=; b=ElxYlEfTeZq2CEULhjr8+kxylhjbHDBkXHo4BdUbKcrIdQ/ItoLIpzAEgLrg6ZHb4S aaCzTTo0AVAIgdFpSAWtQMzkkLF9HoNGBQVDZT63hC8Yc+OBkEhIkXp2fGxe2hVektOm MJXxE2Hx2eJsjAxkIxjnjTSDe3opnV5gG7oZ9oDE9yp2H9cXSv0UIgMiM3t/4BcaU7VI oHqmplvZX9exqnWV0AbACpqZEkjZ+oF88APYoUHigglMz3939AC/66ShmA4knR0pJyCw nuTkE7P/EnwEbX0l6h+ZWCX1vXhXjNHREKSOYpBrTU5Sf12+E/4fNM4OmDxKYXD3PemV o7mA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721296685; x=1721901485; 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=LHnjFErAgDASCliWVSwJYSmFcBoJAvgxBHMIXQRsSBo=; b=LDcg0yaYFU6p3ue0hVS0sxq0blLgCs8LxAbVHkaf2gW5XidRjMK1ATX8jwF8CeYUxp pa8H0HDY7JPWVUXeAPEvvNQiUmGy88Ea3+3NsUIIRE+LQClzauCedNO7OZe2qloCRIYS nRO+1+uJukIs8WLV63qvhnh0pSlfoAsfrB4iVr6JwHueEv9guKe+dvGesbgk+DdDZ5Pr OjElO6taUbg5llyCtWHFvnoVf4Frth2Mpfne4xy4ZWSn4wKNDZnREeK6kFAf6S1YbkFb xWhDD8zIH6O+AgEmNfUNU6YW1k1bTvjvmnXBUp7oVJMpqfSLXwkj6Ia8uUW2gchWfNrH d7AA== X-Forwarded-Encrypted: i=1; AJvYcCW8taAgED83iyXIOq0CiEkEyXfBGcXyWxjdCz98wXXR8Hs4SjGnxikp1jW1poWBfBMCAPpxeds6tvonqcZaNowCcAf1i4wuyttJieyo X-Gm-Message-State: AOJu0YzXSlUDgp+sk79U047toaQclEDsSVW8aS94nMhc1YNuHVGkr6mt PaTtu/lHmjx9l+HIz/cvbIfE5iorOqGR29ajQgggosiWD2KpKisxO4YgSppuOyM= X-Google-Smtp-Source: AGHT+IG8+Imv2pZJ1VDWhnhTTaOQKKCKWkuYOQ3logSxOWNN3Qv8MGDFasB5Wj/12nLcm5NH0GyuVw== X-Received: by 2002:adf:fe92:0:b0:367:940b:b662 with SMTP id ffacd0b85a97d-3684b3c82e8mr1763009f8f.31.1721296685057; Thu, 18 Jul 2024 02:58:05 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:8d37:f44a:c212:e320]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-3680dab3be3sm13837155f8f.24.2024.07.18.02.58.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 02:58:04 -0700 (PDT) From: Jerome Brunet To: Philipp Zabel , Stephen Boyd , Neil Armstrong Cc: Jerome Brunet , Jan Dakinevich , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org Subject: [PATCH v2 2/9] reset: amlogic: use generic data matching function Date: Thu, 18 Jul 2024 11:57:46 +0200 Message-ID: <20240718095755.3511992-3-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240718095755.3511992-1-jbrunet@baylibre.com> References: <20240718095755.3511992-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 --- 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 8f3d6e9df235..cd7dff5bff61 100644 --- a/drivers/reset/reset-meson.c +++ b/drivers/reset/reset-meson.c @@ -129,7 +129,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 04:07:38 2026 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (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 7083D12C46D for ; Thu, 18 Jul 2024 09:58:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721296689; cv=none; b=LdefleNTfLxRMYIiGxCT4ymbmkapr6vVlzS1X/kWLd06q81EUIrKDkXYJQcOMzM1ZTzsNFiF+g8FuHljFiRNCX3Ozr/uWK058lA9CEbhX7Swso/f43KsmZ+S5eOkZR9c3M/ajoB5bz13YuHigVaCFO6rhv2Vkwo8GPLvEUQEKMg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721296689; c=relaxed/simple; bh=vUvLQh/jO3ceweKyo5MuuklomweI2Q56BLv7uiWnR0A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N+7m/ejTADLh/wLzr8WoJKk6QIHmYprKXC21Q5JvkWhmIW3MY8kDNPEujn2bBwRWYkF3E6Hf2FJsx99th5bknHsXSzlKUjfdevOmamSR3Yzii8IJS67QuQBLwCwmpHeBWJkr0Lb1ZGUCWcY44Z2ZlcoIzAQwSm+LGIQmpSJlBiM= 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=Ro39/axO; arc=none smtp.client-ip=209.85.221.53 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="Ro39/axO" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-3683178b226so342396f8f.1 for ; Thu, 18 Jul 2024 02:58:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1721296686; x=1721901486; 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=ZOgT9D/DodptCqE2kKdT3PPWDoUGy8iZZzt0/7nqeFs=; b=Ro39/axODBz57J8mWllB92iCBbdH9EhNVDO6J1ycG4k0RgCPSN1NOKyhXxhKaQUii5 YwcSc02Yw7STxE+M5IZ66rI2RgHcKF0p7+/BjLvjpah+60e9ykBsJzIHlpRAqaTih7a+ 7ypc8txKViv52i3tI8hTE/kTT9UHsDRMaeuUq5VeiAUVRhRXc7MtKnCD2ZptVrc1titt Mmlc0Rw6ttRJnSySXtp6ZCMGxcNCYXFH0d8TRbA6bjhUSc46FkArOwGLeu44GLziRauw AyVZkbSZP+ZmPtGHwjFdRK4yzmU1FZGDgdRZtPqHZ5FreolfQrEiG9piliPdm42bHC97 s08A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721296686; x=1721901486; 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=ZOgT9D/DodptCqE2kKdT3PPWDoUGy8iZZzt0/7nqeFs=; b=W/KleF5bd565VmcXilNA0DOnq+UcMEqfxq6WH9T3ODLeTqS4+7UtndFqPxz63ZJJnu Ja5PophH3AJlJkTFZ5nfoDqtMO0Eywojx3e+p1JQ8YoC5YfOZo6d3NXCrI3/1CQPPlAM yqboy9ZoOZ4Jq8Oy3W3SirjsQPm+93FVFZNfGpzyVypwyGMfU0CQCoSjtncK1HnKU6qe 9mlKdJiesz2fznq7/LbwFaPpvlFMT5h4YRqMnManMQjCoG7y9xePZxpIfhmvvkAfD6B4 iol+WCvGQKBA7+MJBf1Y5BrdsnYk4GqNVjwTElz7kexxnc6g4bnu1Sf7qC5vpEQipkpC KHNQ== X-Forwarded-Encrypted: i=1; AJvYcCXnUv5eb+r4b+cpfO+2oXTO0YQhjH1VyHQS03KeG9NfCze86EHVB4DIJJ1WAkoDF0DI7f8YOgPYN257zqIo/4+p1JTO9Fy/FHOCDby1 X-Gm-Message-State: AOJu0Yy57x0Y7PWam8Zkb3JTskMP9OcpNmoOxMrp+9Nn1+1nLw0lyJ2X Rhj3EmhHzDOb6xJSDqHxDprNgL3KQKiTnLIPBIbKujcUVVFJfuPuy4Ng66GnOo0= X-Google-Smtp-Source: AGHT+IGDhk3n3fMrhl+KxiP4qxoRTY3Xql+du2qHjuCX3AxvdTe+ANakilfvecMzJUQGpqBPrQYCqA== X-Received: by 2002:a5d:4576:0:b0:368:657a:6347 with SMTP id ffacd0b85a97d-368657a647bmr411614f8f.34.1721296685836; Thu, 18 Jul 2024 02:58:05 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:8d37:f44a:c212:e320]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-3680dab3be3sm13837155f8f.24.2024.07.18.02.58.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 02:58:05 -0700 (PDT) From: Jerome Brunet To: Philipp Zabel , Stephen Boyd , Neil Armstrong Cc: Jerome Brunet , Jan Dakinevich , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org Subject: [PATCH v2 3/9] reset: amlogic: make parameters unsigned Date: Thu, 18 Jul 2024 11:57:47 +0200 Message-ID: <20240718095755.3511992-4-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240718095755.3511992-1-jbrunet@baylibre.com> References: <20240718095755.3511992-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 --- 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 cd7dff5bff61..a4705021b8f2 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 04:07:38 2026 Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C15C12C49E for ; Thu, 18 Jul 2024 09:58:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721296690; cv=none; b=Vc0v8GvNwYlItqOhrEUgo5gaT7jpjeWWoBorwy+bpw0Aca3Qim6njYHu5NQYOIhjSYa8TBds6Z3wGhC9+qnfJ2pT9CZmZc2VQqZybVo58hyZRQC5WEXPbFqpImqwahLtfuDB7vy15im9oVH+9J68mjMNOaQGN3xG1cvXDUi1Oxk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721296690; c=relaxed/simple; bh=9cZe1kPmCTyObujoid9EqIB/vM/2BaIZArY0kMmMOUk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gh/EJoJplmFBMAg3Ns5lfh3oMXzoofpAEoX/qt2brasCCOrJCk69u918rT9xAx52rNzL+vJvlTkZpPo8/ySr9QCpuO3xNZsr7L5oMK2wWy0MwKEbOsVOv0TjMCUMcAbCzSj6FrM0Ay0XUWuBD40PWfBFyM9G2vEOdQCUdGP6i4Q= 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=2eIZ8F7D; arc=none smtp.client-ip=209.85.167.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="2eIZ8F7D" Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-52e9f788e7bso180842e87.0 for ; Thu, 18 Jul 2024 02:58:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1721296687; x=1721901487; 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=AsHCgll+Hmm8fed0dFMQNF0ix1j3UG0Ow/yT3gZX+Ck=; b=2eIZ8F7DA5+sokV3TfhI7NXGPjnmd12plKpgIMVvyjG3Y3Xc1A/VHFS8SP/2Bu7J7u tksBjNNQ8pRRZwy9b5oiLSRzfIHn3IR5ZpFJ3Tp8eOkBDEecl0tIwg84QepG63Phphl2 ib2USm4boJijeB3KJU8F2J/6Pecn2TIre0O867ekJX9wxDQhwsX5OSHtiwLl9MVkntsS C877L2ZqzZLynPSiZt9F/aW3wzWOIxuyVVaErMBz0FODUoNpBXIR3Ys6nS2XHcdLT9RO /W13UWmgzV5npCVf7jWkj5gSbZi9hV4f7KBJAh++cVKNa4E0a8lQByVOPPvv+2HD5qs6 Xf7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721296687; x=1721901487; 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=AsHCgll+Hmm8fed0dFMQNF0ix1j3UG0Ow/yT3gZX+Ck=; b=CUXHyOOJn6yWyVWesEl6ImKn6P0zdnTL+X22ZqDYCJluD1hg6A2BYJforBf8/i3FtF w5294Sd5t/DykXuk1jo1Jjy1a5JTToj6KVmLtv9+GuHTEVYYOA2RfvzXVlnBedxJ/Rli m0VrvV4Sx3C/WJKVi3cBB4tKwvaBn0fd8HISuw9u0n/FPWZZxj2WgL1tvYeQH4KqgFJB yXp4jk3zocntmC4a1DPEuLgV0UNyeTdE+vSzLUiaJ9eXaNk/RUrihdl3k1q/ozHHf6Fw KI1Xz2ROIcJuGq+z6LeyKdPCuk5qu7mVpvc1cI8+LuRCnCF9ac4zOTNoPkLmwQC3E63A i70w== X-Forwarded-Encrypted: i=1; AJvYcCVrDYrE2CIKVN1PUaA0CjEWkkBVEKc5oDIA7HS5REv0dTR4QoqKULga340AaRQGgF97wKcCDx75C2Mh6xhA0SGG6wTniTNrBhL8k4lG X-Gm-Message-State: AOJu0YypTM212EQW5SjQG33wPYJ76CPJA6FAJiKpShOXYmd7E+1JwEoS SpTwP3wnA9pMUcO5d7G4HpFWaWewPwbbPumXzi2Oy0nEkyxPydJT9RNT3tyrWX4= X-Google-Smtp-Source: AGHT+IHCNw6mvVs0JqyoFHW8EQrkH7lFTfsUSnH12CIgfhfeQ/Vay1c4tow8aO7Uajm253zXYZe4DA== X-Received: by 2002:a05:6512:2385:b0:52d:b1e4:b337 with SMTP id 2adb3069b0e04-52ee53b284dmr3180536e87.21.1721296686619; Thu, 18 Jul 2024 02:58:06 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:8d37:f44a:c212:e320]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-3680dab3be3sm13837155f8f.24.2024.07.18.02.58.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 02:58:06 -0700 (PDT) From: Jerome Brunet To: Philipp Zabel , Stephen Boyd , Neil Armstrong Cc: Jerome Brunet , Jan Dakinevich , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org Subject: [PATCH v2 4/9] reset: amlogic: add driver parameters Date: Thu, 18 Jul 2024 11:57:48 +0200 Message-ID: <20240718095755.3511992-5-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240718095755.3511992-1-jbrunet@baylibre.com> References: <20240718095755.3511992-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 a4705021b8f2..09b23f320f57 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_update_bits(data->map, offset, BIT(bit), BIT(bit)); @@ -60,9 +63,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, @@ -85,17 +89,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 04:07:38 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 F1F2F12C7FB for ; Thu, 18 Jul 2024 09:58:08 +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=1721296690; cv=none; b=nCn/jqFxDTNSs4XV92eK4gFZaKsANV+O9IaQ+uvybxPbkyqiqAjjXVbsvdWyh6npBkgX5AqitO7P2uQVUOT2XHA2DG9Yo+Z5bwG2jf2nfb9qGn2sh7tCHY0TGGPdzhw7gsIGqz+ckJxBspcOu+4pW2cganY/FNm04EQMfPkYDps= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721296690; c=relaxed/simple; bh=5V9s/8uzgo6Nj/XypJWT48nWu3rbfdd76bKMSCUv6fs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AS3ecZ+t09dmxtQ8O1qf5DEqRAvdvJlVB3uwwWW3YmZfZkIE+i975Xp+lUDEIVGsIzIeH2mMfNIUhOC5OQhjL8Qq35bE28Zm+P4zdfGiBa3O+PM7ceqg+LW2GIOaj2l8kt6ap/458UZN4kboyuXrQozXmXfuFBQv2cT6BMjExVw= 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=AWpNlOPf; 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="AWpNlOPf" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-36799fb93baso436874f8f.0 for ; Thu, 18 Jul 2024 02:58:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1721296687; x=1721901487; 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=anoJ0A/eyMlcq4ZsnQ8nc5h5FKEq9eY7wJHK/pAFmYw=; b=AWpNlOPfqCWv0ZzDdspuvs7tSG5SsQakSyLDj0qhLsG0idP2d8YuLydZ3VssmkMHPx ciEzF5H1LobvYH4CJmctSysFGWFpPxnlkEKcx9MTtl5IoxYwN0L9MTzV4AESJ66C2MMF uhnfWz+lLaIpQMHV1ca+SW/wqTVUVCbdSTnWQmwB1oKdJNkNdWC5/dD7L8TypKhZ4SXS BFFnaiAAvXfJ2nxPT+mw8Wi9FmihnWOpcw4q1woUN1pJ3nkIwkj7QrgsADzmYYMWL+kk VlQbjP0xa9tukHgYk5+D0mL6FxfsKlnyV9KLsm3ppzs8FhLvYKtNi207DxuyjMcnbtsW lvbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721296687; x=1721901487; 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=anoJ0A/eyMlcq4ZsnQ8nc5h5FKEq9eY7wJHK/pAFmYw=; b=CQqPq57fUx9Nv23vHxJRUIcCVFExO+TURGxztXA60j9LerSO5kgbqKppB+KCfAsWm8 7inRuynlrSU3vb8vL4zOihequlbL3RZ+C5ob4lt9Mm1w/NcVuO3YyyAawg70YdP0FDwj 8e/Qv7v4UOmhAblbB4UzkYxBC/n85VgpPT1D0cCKdnO7ErkMvlStCGhmMT8Efr9x1MCu jwdD5QgvaojzpVZmKzjQJtIVIBUrCA9sKapMLjGazZM8bG5i7Ncze8kJKQUzPzXgIhn2 2sAGzBMqSN+MilUjeNod12miA1HUJ38FEhE8mfo0nkhyKGJ80ajaAn2VlHLSFvfg5TUo 2mTg== X-Forwarded-Encrypted: i=1; AJvYcCVHkJkagD/jU7EIOZdCbC4i7/Tb6iC0BikdHalSk1RZSBcVpTVRwzcEDSlaBFMQ2jqHumnmV61Zo49ZGxsJTP/ATrmf2nRzzXhDekr9 X-Gm-Message-State: AOJu0Yxl6hipS/DB7H8kOTnOwpgUCFbDLb57YLFQbn5hr43R83OgvyJC r3ZFtMP6KKxUO9rJdHVwtGTvA4f0Xmb+XQ2QH56WTcH65Bn4/Z6SPaI27GZ3G3A= X-Google-Smtp-Source: AGHT+IGAJ2huYI+q7mn5ECdgrCiYMeaEBMdk8eW0Vl4o6RXhiCLf/tX+GMgpIK5T1/Tj+4ER838TOA== X-Received: by 2002:a05:6000:44:b0:367:9d2c:9602 with SMTP id ffacd0b85a97d-368316f8052mr4039827f8f.49.1721296687407; Thu, 18 Jul 2024 02:58:07 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:8d37:f44a:c212:e320]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-3680dab3be3sm13837155f8f.24.2024.07.18.02.58.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 02:58:07 -0700 (PDT) From: Jerome Brunet To: Philipp Zabel , Stephen Boyd , Neil Armstrong Cc: Jerome Brunet , Jan Dakinevich , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org Subject: [PATCH v2 5/9] reset: amlogic: use reset number instead of register count Date: Thu, 18 Jul 2024 11:57:49 +0200 Message-ID: <20240718095755.3511992-6-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240718095755.3511992-1-jbrunet@baylibre.com> References: <20240718095755.3511992-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 --- 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 09b23f320f57..5a5e1c2358b6 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; @@ -88,21 +88,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, @@ -149,8 +149,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 04:07:38 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 BD05F12D1FD for ; Thu, 18 Jul 2024 09:58:09 +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=1721296691; cv=none; b=QeG7pI0cBXp9oC+0DMam3cdFRrjuR8F6g7Ljzg1ZAZOUdzE4Gd1yBG3clUuDLCWKaO2Kr2WbeOvu/6vA1or/iExTsTzsTCkJV9HxHGCs8L0GSjrViMuRC9pqyA9XkjH5rffGKZnBc5zwR4ntvgvvnA2omTOsbeOcW6IRL9U7sVw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721296691; c=relaxed/simple; bh=sNK4ErMz2o48l417rUcSJGHPTYne7cRpAUMeOaIUetU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I3iELTSvpyWOvZU3aCxkyxf38GxyA/90oCaaXvY51Evff/HKfoTHs6jMzLrR4d6Dc/bTORtkx6KlPjZle5KbZMouzIrHk2BcwsALcCksmceAqrKTt3mkNtZ4Y/gOmcOGOqBIDzltp+Iu7uVdPKye2Ad8+Q4DLeILq3xGUdZeyxY= 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=qel0Ge4u; 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="qel0Ge4u" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-4266f344091so1100765e9.0 for ; Thu, 18 Jul 2024 02:58:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1721296688; x=1721901488; 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=5xcwXqNbcAcoUEX6kCiLZbJmCheMKB1aLHCgp/Pjck8=; b=qel0Ge4uV51zuheVcwRYlER5AW7vuB5cvxDmSFO8wutnk/dW3bnWrxrB6vcoeY1cSk Og38SmBNL7pWVLJY8QuWkzGeOFxunCOYReNssBEQA0E1jr3YTOL9w4MzRxrYIdiH/JtC BohnwYmqqTZcuSHzQH0eiR0l0qaW7+Wf+TzpsraRGPRx8w/2fiRHebZRRXExTUip7/H5 /roEVJyFZpEv7WVGW08wKSieFWsMXRR+vPU4i76aceezUcSBBCdYAFcpDcHQrmVpMGCL uQtS1Jl4X0R28Oo75eTPlCAzgF7EbhXqOGyVGhhVCg4YFQylMcxaqWv/ePSR0W5NBiwd UNbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721296688; x=1721901488; 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=5xcwXqNbcAcoUEX6kCiLZbJmCheMKB1aLHCgp/Pjck8=; b=R9xb1Q3QxYUuJxihArBhNqpVjTkgOnINrOAoBJBLkM7bTPXhcWSozuFEe8yRU5bBvm TlwSTJUN2+tVg64P2Xtcctx6ae33YQ45AY5XOv4H/CLjbK9iGA4mQgnNGbHKS5hW0Vns T2QN84H/Wej6VwPXQ3+yh/GDahFDmJyhNSlv8SrY3DN/pOrvl9JfGovnabysGtj/ZAJR nCOJP9pdjBKDRePFUzKHoRXDgdblz2CrPWi8XeT2Ph0xZoCoV4hAPrejNTmmvtdjiY1x sWmyr7/jn+AtNN6LfYPRHCk82wOsRmUZidUDNNsrZoVl5pOHRA4LdWrokooYd8q2GZ0L WqRA== X-Forwarded-Encrypted: i=1; AJvYcCULP4BoRJ7U7YAzQZ/OptwngM2Ov09eJKpuXLai3RemipbxXEaZYeMBYWhOO8srx9aQnZHp2pc9t5Rz8SyEx0c/RepsP5z9RTiDJzo2 X-Gm-Message-State: AOJu0YwVKTD3teLnuVNgNNO5jOjXV/iIMDGmIl4WdGu6iEpre1cL9N2R C0CYYIMIGr/ZDVSjWlgNa9ShxfJSNz82muQROGyBs/pFALAm0ku7Y0jfKnwL8QM= X-Google-Smtp-Source: AGHT+IHUSAbObAZJT7KXYxyHY/CVrKUlSK4TOOFWbep8mWkhqc4o82VXvxTyvmakEMq8v31akCeXEQ== X-Received: by 2002:a05:600c:4443:b0:426:686f:cb4c with SMTP id 5b1f17b1804b1-427c2cf6b1emr29425735e9.32.1721296688224; Thu, 18 Jul 2024 02:58:08 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:8d37:f44a:c212:e320]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-3680dab3be3sm13837155f8f.24.2024.07.18.02.58.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 02:58:07 -0700 (PDT) From: Jerome Brunet To: Philipp Zabel , Stephen Boyd , Neil Armstrong Cc: Jerome Brunet , Jan Dakinevich , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org Subject: [PATCH v2 6/9] reset: amlogic: add reset status support Date: Thu, 18 Jul 2024 11:57:50 +0200 Message-ID: <20240718095755.3511992-7-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240718095755.3511992-1-jbrunet@baylibre.com> References: <20240718095755.3511992-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 --- 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 5a5e1c2358b6..b3ef1a1c7cf9 100644 --- a/drivers/reset/reset-meson.c +++ b/drivers/reset/reset-meson.c @@ -57,8 +57,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); @@ -69,6 +68,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) { @@ -85,6 +100,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 04:07:38 2026 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (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 78A0F12EBE7 for ; Thu, 18 Jul 2024 09:58:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721296692; cv=none; b=o3VDINtXMaofR6qlUgmSzWJEjrrnWsk4sMrc6VRAA2iMc9E0ve5hrLcN+0si6On5fT17fmXoMzxkkgrKRf2E0V9L6aYK8RG0qCwv03apNu09iZebGsOfdHH1AKrvQ737rMcq0tZ2TQ8VaL6xV87dO6CrT5e/oH98a9I5XdjD+b4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721296692; c=relaxed/simple; bh=X9P7ZeWymMLqFZGWrumCo8iBNn8RuORIPL0PHhhDpzI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C60rPJpJc/+CkP3H+eJDvP54RPLJBLlXYvcXjoDkHoV13ml2a4yZh2Lm+TMcz0zVO+M5UHgj0u5TWvedjgzn+YAhsE9rY+1MF+AO2Y62mqp9B70KIcixlbcOFi1miQo3X00ukJNl2XtH+0NT6+vt88wVqC3A82nF9MfRuzvgM8w= 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=RfTljWYv; arc=none smtp.client-ip=209.85.221.51 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="RfTljWYv" Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-3684bea9728so426583f8f.3 for ; Thu, 18 Jul 2024 02:58:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1721296689; x=1721901489; 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=/FraBsn5t4nMihNDzTPwopMxXwcMdzGEUC8JHsJV5Dk=; b=RfTljWYvQLwezfhk/m42037/Vys4IPtmlTiwmyNDbjd5CwAATkPlK1ZLZDPNbJBF4y eZoPOh+ud5i9qbpWw08J++J5ITcdw1Q2E56HlQFDtmwdg8COl0OeVXLXT0qydI4o2pSH rlOF24YBzc7qT9tGAZH2FtQolOQslpguolL3jfxdQw9xj8cxlcFl3VgyL8QjhvspZ0co Crkihe/0kUnCUggI2PSD3GZMqad2FSvPEemCT+dmbZhBE0mkXnHbo6ZFSz5H6BnZp/eT G2+ZFiFOEI9BySMr20BRbuuqGmxRvpTBOZR4zAzvRdh2EYB32dkTT8wGkkw6Z6PMYfot wadg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721296689; x=1721901489; 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=/FraBsn5t4nMihNDzTPwopMxXwcMdzGEUC8JHsJV5Dk=; b=fe+T3eYvXgbRVLxnuvXGRKB0X+r8QgFnnUtcLGcYKVqeZpUt8gcAzUjH0ja7S4Stob r0+vzutbDQ8kZFY4rYu7kpPewH/cfqk0N77Fw4vkjPOb7pLYcMv1UkcU4hnU+bIWZxrk dXKCOpQFh7Q/FXnnKQMHNBKMM7zcsEKLFnupZUpClv4SEadhZyZ5hIS8fsF6N8Ip8hye DZg+aVJJrVqbMeEEFp0/x4DtPL68LiBw+udcWBkKibg+ti88MXZWA8tbgDfXxAQrGV7t tFPNa2KJqYW1lQO+/xi3l4LgzxNZfVmlTLPnNJwq2nOGX067i5hi1PVyXQTCCHNsa8Bt fA9A== X-Forwarded-Encrypted: i=1; AJvYcCWxENOovp6JSl96HSN3sttjLCowW3HAT+Rj1CokNFd1lo9IQyfjF3brbLAP2MDJCRYTO30s/NrG7SuGZwh/KRXObstJNwPNwWoFMV0C X-Gm-Message-State: AOJu0YwPa0OV8OnZ8R9q8oU3bzK8PIEi7DcZeGuVAxB2MsN+htIE9hAi mrqVFNrmTbPcu34F+C42djKQk+0I8S/90Og6L9nSHPBlko8hBYgDX4hueviy148= X-Google-Smtp-Source: AGHT+IFfFHtbCLCHhNC4eT72EfA+0uRA7O4pqzK1FiqFakwv+5WvN9D5HdNF0I2/90lf698t3MbycA== X-Received: by 2002:a05:6000:2c8:b0:367:9639:66d3 with SMTP id ffacd0b85a97d-368315f3344mr3179887f8f.5.1721296688962; Thu, 18 Jul 2024 02:58:08 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:8d37:f44a:c212:e320]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-3680dab3be3sm13837155f8f.24.2024.07.18.02.58.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 02:58:08 -0700 (PDT) From: Jerome Brunet To: Philipp Zabel , Stephen Boyd , Neil Armstrong Cc: Jerome Brunet , Jan Dakinevich , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org Subject: [PATCH v2 7/9] reset: amlogic: move drivers to a dedicated directory Date: Thu, 18 Jul 2024 11:57:51 +0200 Message-ID: <20240718095755.3511992-8-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240718095755.3511992-1-jbrunet@baylibre.com> References: <20240718095755.3511992-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 --- 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 36cfdb81cd34..3015fb8bb6e5 100644 --- a/drivers/reset/Kconfig +++ b/drivers/reset/Kconfig @@ -139,20 +139,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 @@ -342,6 +328,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 04:07:38 2026 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E10012D76F for ; Thu, 18 Jul 2024 09:58:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721296693; cv=none; b=MBc0khQkB/HXe8ofuUsn7xIdcM/xQIGFhpM8zUkIsHydn5b7QNB+tU3VOlE3mR1ph0cMz1HBsL+NkVpbp7WnXggA+BnErhCA+dPMmZ4qsrCArPq4OhcgFP69adeCAL/p/89jl6ZpPPiLC+TZfUrJZFbUIvWGTgmsgBG3w9/6pH4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721296693; c=relaxed/simple; bh=YX9oOmzuen/R6INXwW5TFjcGneUcqK6jfmkokW+qGUo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UCvVcVW5LvFessli/EQX+gtQRKwUmLif65mn/Ic7umML1F4TL6w5bLZKd5he+UzVbbKqxIGmPZaPCrC9eTVgzIFbpj/ONUmdh1rQPTrUo7+imvR5tyVSFPgw+PTZ/f1Wvd/rrl1mQAHmdFQ++ID/v3ja88Xy6BdMcjG0n09JaR4= 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=Ez2FVjhx; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="Ez2FVjhx" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4267345e746so1111875e9.0 for ; Thu, 18 Jul 2024 02:58:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1721296690; x=1721901490; 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=CCH5u/ZQ46EyBFByLmOEPWmFGVlqJDI/+pS92Vu1GSk=; b=Ez2FVjhx9Ptz+5YbOpyS7Sr35XamlSVgEMQjgIL3Ml9rjqRMkMwrYsYrhtg8ajPB5z OE5i0tlzovVEmTMyKE8m+/O+9FbMalg9oTrkFisFRjerq0AIIbzeeprzrzmQ8XR6IV2X iGmK5Iak34uigRsaO/fyEU3kVztPMntDj1+qNHLLRExIZvlheNjAUsa6if42mMcCTE87 5j3rnnK+QPCaHlFSh4+bM6T6QOHvgp6wSEZMWelU0HwsbSwBR/tR3pAs3AufWYLkgxDG 6WZnmTuWfTBzIYnkelCJnggEFQUW9M+ZZX/5yz2PEI4g015OZ+B9AMQqXTwJtJuFPwci S30Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721296690; x=1721901490; 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=CCH5u/ZQ46EyBFByLmOEPWmFGVlqJDI/+pS92Vu1GSk=; b=HztX96jDJFqILfa7ZzzhmdXxePwUdY8Vqdwf9vaHQcvzqM2SPUfc6Jc1YBKYkW+D5O l3uxTk3Vv2LM/+jOZlRba7mzjPhzuI/Gu0kecFUmeXOYJsH3rGWdGWNiJcX/wBZBIL5V /nRnjtyKTl7/Ge5bzuj3nH8OISzycrI5rQHFLW+7eIF1lUKQWeX6Tm0ebll2b4BkH6xZ dAbSdbn+1z91+5Aj/hst8sk/xWheGJkyukH16wQcih9vJKJKNVYkDRFzLuIsdi6jNf/M RK8vxLCfrYPozVTvqk5o/pytVh3dNG7wurRuNoep3GNwKr4Iqg/VD3JXZLLBpKomEwwB rUYA== X-Forwarded-Encrypted: i=1; AJvYcCW46QXHs8lMhzPJMDJ+LPQBpzcBWVND12dSMIZGRnyel8XI/dPPgdu0Zik43rbL1xB1kXFzFyKQ/ZW4pf6UPI6kUB2jL8f7HzO9Ib/l X-Gm-Message-State: AOJu0YziCVg4DnGxWQx9RXpWm/auoYxDdm3YdOvYwpy+pPURrKc0bllM fLyl1Hj4LBVxPu1YWm36t6BynVzCpQMqPopPlOfvyRR57v0XpRsWGYq4Uk6VquE= X-Google-Smtp-Source: AGHT+IGiRMLYPD8/mj2DdlgRkFnwPYEWEbXjTmQ5vs7sFEFj2QKW2f7+XfNNarH8pxk2uC5pHnAF9g== X-Received: by 2002:a5d:5f49:0:b0:367:993e:8747 with SMTP id ffacd0b85a97d-36831654ae0mr3925223f8f.30.1721296689701; Thu, 18 Jul 2024 02:58:09 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:8d37:f44a:c212:e320]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-3680dab3be3sm13837155f8f.24.2024.07.18.02.58.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 02:58:09 -0700 (PDT) From: Jerome Brunet To: Philipp Zabel , Stephen Boyd , Neil Armstrong Cc: Jerome Brunet , Jan Dakinevich , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org Subject: [PATCH v2 8/9] reset: amlogic: split the device core and platform probe Date: Thu, 18 Jul 2024 11:57:52 +0200 Message-ID: <20240718095755.3511992-9-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240718095755.3511992-1-jbrunet@baylibre.com> References: <20240718095755.3511992-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 b3ef1a1c7cf9..5e23f3212e6d 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; @@ -103,84 +93,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 04:07:38 2026 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.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 291DD1386C6 for ; Thu, 18 Jul 2024 09:58:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721296694; cv=none; b=fR978oEPGphGVzO1HAvcovT+LF7jQNMC4+nQDV4hzcgTOnWMRA4BVeAyLhnvTaCqTGwhRO+UWNNn8cD07iFSTFLQ4UcKTMibzprJ6Y7oOX2wJ0rU7efRKCrxUaZumKiH/Agf8zGjLfEhTZtyL6bNl4uvUoYbsj59nsaCH7wMNpI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721296694; c=relaxed/simple; bh=pV/k5bM442yZLu6RMWeIRO7ZU+6Iiko65mfelR1E5Kw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=a8H9Wh8+bqYDwTuEUKNg/u1i5BP/YfTx9PjhMp0QXRQ/vVsInYWEOaa31xnT/q1zDpkpduQgmAyr0NLJO8yMEM6sxfSgFfooVcncZrhnmrrVRRvkvpiZVIlfEm9ZzGyGAA0ELYzCQqM8vxxfR/4G1r3xKGNSp/eTgf3QDr9LHmk= 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=CcnPbpnn; arc=none smtp.client-ip=209.85.221.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="CcnPbpnn" Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-367a3d1a378so549786f8f.1 for ; Thu, 18 Jul 2024 02:58:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1721296690; x=1721901490; 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=+5GSp6YqIBS1rgi+tuHGNtfwR5VxLXn9gTpAO7YiMT0=; b=CcnPbpnnBT/ojWPG+yAZiMuJqR7bqL+EJR68GLXysI6qKFWzVHvl8pTRwcqs8qQwXz /Kfu9n/O1SPCVO9z7y0au+Jbcdq0vT3fRMASS3nw4N1LVhAWRQGHftLghpE3nOwGTIh1 kPRhxvBx+hX/pCetmZO4kIlU9TFVOE8dDAznU9ywQa3h8KPXOx3SZRRxfjYl0kLOm2SV b86E4QC85UC1AlslsSQxJY+0BHzlBODvCPNQIWMK194Hp/T2EmxnE9UQ9LZY2UV5WQEb 42+NXeRZamcqXYzl2fpI9dq/PzSgDUQ3QLKpYjbbxl5vqEbuWjwrWVA1o7LWDTdqWtW4 7eGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721296690; x=1721901490; 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=+5GSp6YqIBS1rgi+tuHGNtfwR5VxLXn9gTpAO7YiMT0=; b=ELY2lV/Bitpv9yRyMZ9RMGTNyeqsxC8igmoc9qXIZgRfuVc5HPOzufnTu48B6Q5fPX o99TsGvWsnIBKDpXnyDFXDineljun5LvA5RxAFY4lp3k/mFS5zNwhtfT2yFwQuyKXqTr kvrGam1abVXhI7T/lD5rIXvnCClKsgfZ9Mk+62C+rUmi8RHpeS5mVBSnEPkvouRlac5j y+0rADU4XJ7WC8MihD+m7ZO+hMbggo9/yw5UCKB/li/zSnHreOKn/B293mL1JP91e91q J7UPcP4Gz7o3wH8TnhvMNnK9R211voloFEEQDMubCP2rBYU9o0Hv//w4PSV7UL8+tNaT cqJg== X-Forwarded-Encrypted: i=1; AJvYcCXrjl4kE/K+xxyoQrn+tQwbmET7w+BtJdTzGQozoDyXJKX3cpF1x0C0nAEtkfkBH5KdK/Ggnpd8WxjGrJG2oyKhGRkw+wnwfrfgxbBQ X-Gm-Message-State: AOJu0Yx0XuSUD9vHzL7JpR/TQWTMzQeqDFM0l1T45Xw7+oNNVfZIgo8T V6EqJIVxwfHizBhhTQmZc5Aa2iH0DjHTzmT3Qsda/s2mQ0XFPC1PECa448TfrqaQHQrEZGQL4Qt qt6M= X-Google-Smtp-Source: AGHT+IHryavmJbdMxKtCJMTQmuM29v1Rpmy/SyHLJtT9TIAcJ6OTqhBKHskro52iNUAQuqiAg8XPuQ== X-Received: by 2002:adf:ffc1:0:b0:367:dc45:55ab with SMTP id ffacd0b85a97d-36831607ee5mr3102356f8f.25.1721296690493; Thu, 18 Jul 2024 02:58:10 -0700 (PDT) Received: from toaster.lan ([2a01:e0a:3c5:5fb1:8d37:f44a:c212:e320]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-3680dab3be3sm13837155f8f.24.2024.07.18.02.58.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 02:58:10 -0700 (PDT) From: Jerome Brunet To: Philipp Zabel , Stephen Boyd , Neil Armstrong Cc: Jerome Brunet , Jan Dakinevich , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org Subject: [PATCH v2 9/9] reset: amlogic: add auxiliary reset driver support Date: Thu, 18 Jul 2024 11:57:53 +0200 Message-ID: <20240718095755.3511992-10-jbrunet@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240718095755.3511992-1-jbrunet@baylibre.com> References: <20240718095755.3511992-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 5e23f3212e6d..1e5883b27c30 100644 --- a/drivers/reset/amlogic/reset-meson-core.c +++ b/drivers/reset/amlogic/reset-meson-core.c @@ -86,12 +86,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) @@ -106,7 +127,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