ALT Linux kernel packages development
 help / color / mirror / Atom feed
From: antohami@basealt.ru
To: devel-kernel@lists.altlinux.org
Subject: [d-kernel] [PATCH 07/12] mfd: bcm2835-pm: Add support for BCM2711
Date: Tue, 22 Mar 2022 22:36:10 +0700
Message-ID: <70ed3da3bb60ccb427712ce0379a78ebb0118f40.1647954377.git.antohami@altlinux.org> (raw)
In-Reply-To: <cover.1647954375.git.antohami@altlinux.org>

From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

In BCM2711 the new RPiVid ASB took over V3D. The old ASB is still present
with the ISP and H264 bits, and V3D is in the same place in the new ASB
as the old one.

As per the devicetree bindings, BCM2711 will provide both the old and
new ASB resources, so get both of them and pass them into
'bcm2835-power,' which will take care of selecting which one to use
accordingly.

Since the RPiVid ASB's resources were being provided prior to formalizing
the bindings[1], also support the old firmwares that didn't use
'reg-names.'

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

[1] See: 7dbe8c62ceeb ("ARM: dts: Add minimal Raspberry Pi 4 support")
---
 drivers/mfd/bcm2835-pm.c       | 25 +++++++++++++++++++++++--
 include/linux/mfd/bcm2835-pm.h |  1 +
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/bcm2835-pm.c b/drivers/mfd/bcm2835-pm.c
index 36fede92775c..a06e9cf19b64 100644
--- a/drivers/mfd/bcm2835-pm.c
+++ b/drivers/mfd/bcm2835-pm.c
@@ -6,6 +6,7 @@
  * the WDT and power drivers.
  */
 
+#include <linux/bits.h>
 #include <linux/delay.h>
 #include <linux/io.h>
 #include <linux/mfd/bcm2835-pm.h>
@@ -17,6 +18,9 @@
 #include <linux/types.h>
 #include <linux/watchdog.h>
 
+#define BCM2835		BIT(1)
+#define BCM2711		BIT(2)
+
 static const struct mfd_cell bcm2835_pm_devs[] = {
 	{ .name = "bcm2835-wdt" },
 };
@@ -28,6 +32,8 @@ static const struct mfd_cell bcm2835_power_devs[] = {
 static int bcm2835_pm_get_pdata(struct platform_device *pdev,
 				struct bcm2835_pm *pm)
 {
+	bool is_bcm2711 = (uintptr_t)device_get_match_data(pm->dev) & BCM2711;
+
 	/* If no 'reg-names' property is found we can assume we're using old
 	 * firmware.
 	 */
@@ -41,6 +47,10 @@ static int bcm2835_pm_get_pdata(struct platform_device *pdev,
 		pm->asb = devm_platform_ioremap_resource(pdev, 1);
 		if (IS_ERR(pm->asb))
 			pm->asb = NULL;
+
+		pm->rpivid_asb = devm_platform_ioremap_resource(pdev, 2);
+		if (IS_ERR(pm->rpivid_asb))
+			pm->rpivid_asb = NULL;
 	} else {
 		pm->base = devm_platform_ioremap_resource_byname(pdev, "pm");
 		if (IS_ERR(pm->base))
@@ -49,6 +59,16 @@ static int bcm2835_pm_get_pdata(struct platform_device *pdev,
 		pm->asb = devm_platform_ioremap_resource_byname(pdev, "asb");
 		if (IS_ERR(pm->base))
 			pm->asb = NULL;
+
+		pm->rpivid_asb = devm_platform_ioremap_resource_byname(pdev,
+								      "rpivid_asb");
+		if (IS_ERR(pm->base))
+			pm->rpivid_asb = NULL;
+
+		if (pm->rpivid_asb && !is_bcm2711) {
+			dev_err(pm->dev, "RPiVid ASB support only present in BCM2711\n");
+			return -EINVAL;
+		}
 	}
 
 	return 0;
@@ -89,8 +109,9 @@ static int bcm2835_pm_probe(struct platform_device *pdev)
 }
 
 static const struct of_device_id bcm2835_pm_of_match[] = {
-	{ .compatible = "brcm,bcm2835-pm-wdt", },
-	{ .compatible = "brcm,bcm2835-pm", },
+	{ .compatible = "brcm,bcm2835-pm-wdt", .data = (void *)BCM2835},
+	{ .compatible = "brcm,bcm2835-pm", .data = (void *)BCM2835},
+	{ .compatible = "brcm,bcm2711-pm", .data = (void *)BCM2711},
 	{},
 };
 MODULE_DEVICE_TABLE(of, bcm2835_pm_of_match);
diff --git a/include/linux/mfd/bcm2835-pm.h b/include/linux/mfd/bcm2835-pm.h
index ed37dc40e82a..f70a810c55f7 100644
--- a/include/linux/mfd/bcm2835-pm.h
+++ b/include/linux/mfd/bcm2835-pm.h
@@ -9,6 +9,7 @@ struct bcm2835_pm {
 	struct device *dev;
 	void __iomem *base;
 	void __iomem *asb;
+	void __iomem *rpivid_asb;
 };
 
 #endif /* BCM2835_MFD_PM_H */
-- 
2.33.0



  parent reply	other threads:[~2022-03-22 15:36 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-22 15:36 [d-kernel] [PATCH 00/12] *** Enable v3d on Raspberry Pi 4 for kernel 5.10 std-def *** antohami
2022-03-22 15:36 ` [d-kernel] [PATCH 01/12] dt-bindings: soc: bcm: bcm2835-pm: Convert bindings to DT schema antohami
2022-03-22 15:36 ` [d-kernel] [PATCH 02/12] dt-bindings: soc: bcm: bcm2835-pm: Introduce reg-names antohami
2022-03-22 15:36 ` [d-kernel] [PATCH 03/12] dt-bindings: soc: bcm: bcm2835-pm: Add support for bcm2711 antohami
2022-03-22 15:36 ` [d-kernel] [PATCH 04/12] ARM: dts: bcm2835/bcm2711: Introduce reg-names in watchdog node antohami
2022-03-22 15:36 ` [d-kernel] [PATCH 05/12] ARM: dts: bcm2711: Use proper compatible in PM/Watchdog node antohami
2022-03-22 15:36 ` [d-kernel] [PATCH 06/12] mfd: bcm2835-pm: Use 'reg-names' to get resources antohami
2022-03-22 15:36 ` antohami [this message]
2022-03-22 15:36 ` [d-kernel] [PATCH 08/12] soc: bcm: bcm2835-power: Add support for BCM2711's RPiVid ASB antohami
2022-03-22 15:36 ` [d-kernel] [PATCH 09/12] soc: bcm: bcm2835-power: Bypass power_on/off() calls antohami
2022-03-22 15:36 ` [d-kernel] [PATCH 10/12] drm/v3d: Get rid of pm code antohami
2022-03-22 15:36 ` [d-kernel] [PATCH 11/12] drm/v3d: Add support for bcm2711 antohami
2022-03-22 15:36 ` [d-kernel] [PATCH 12/12] ARM: dts: bcm2711: Enable V3D antohami
2022-03-22 16:24 ` [d-kernel] [PATCH 00/12] *** Enable v3d on Raspberry Pi 4 for kernel 5.10 std-def *** Vitaly Chikunov
2022-03-22 16:39   ` Антон Мидюков
2022-03-22 17:14     ` Vitaly Chikunov
2022-03-22 17:17       ` Антон Мидюков
2022-03-22 17:25         ` Vitaly Chikunov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=70ed3da3bb60ccb427712ce0379a78ebb0118f40.1647954377.git.antohami@altlinux.org \
    --to=antohami@basealt.ru \
    --cc=devel-kernel@lists.altlinux.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

ALT Linux kernel packages development

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/devel-kernel/0 devel-kernel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 devel-kernel devel-kernel/ http://lore.altlinux.org/devel-kernel \
		devel-kernel@altlinux.org devel-kernel@altlinux.ru devel-kernel@altlinux.com
	public-inbox-index devel-kernel

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.devel-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git