mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: ukl@pengutronix.de, "Daniel Brát" <danek.brat@gmail.com>,
	ore@pengutronix.de, "Ahmad Fatoum" <a.fatoum@pengutronix.de>
Subject: [PATCH 07/15] clk: rpi: add Raspberry Pi 4 support
Date: Thu,  5 May 2022 10:01:44 +0200	[thread overview]
Message-ID: <20220505080152.1068424-8-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20220505080152.1068424-1-a.fatoum@pengutronix.de>

Our Raspberry Pi block driver is a hack, but it works well enough for
older Rpis and just needs one more clock to support the SD-Card on the
Raspberry Pi 4, so add that. In return, we remove bcm2835-cs, which we
won't use on Raspberry Pi 4, because we'll leverage the ARM architected
timer instead.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/arm/mach-bcm283x/include/mach/mbox.h |  1 +
 drivers/clk/clk-rpi.c                     | 42 +++++++++++++++++------
 2 files changed, 32 insertions(+), 11 deletions(-)

diff --git a/arch/arm/mach-bcm283x/include/mach/mbox.h b/arch/arm/mach-bcm283x/include/mach/mbox.h
index a9f06512bc23..46f9dfc9ea65 100644
--- a/arch/arm/mach-bcm283x/include/mach/mbox.h
+++ b/arch/arm/mach-bcm283x/include/mach/mbox.h
@@ -273,6 +273,7 @@ struct bcm2835_mbox_tag_set_power_state {
 #define BCM2835_MBOX_CLOCK_ID_SDRAM	8
 #define BCM2835_MBOX_CLOCK_ID_PIXEL	9
 #define BCM2835_MBOX_CLOCK_ID_PWM	10
+#define BCM2835_MBOX_CLOCK_ID_EMMC2	12
 
 struct bcm2835_mbox_tag_get_clock_rate {
 	struct bcm2835_mbox_tag_hdr tag_hdr;
diff --git a/drivers/clk/clk-rpi.c b/drivers/clk/clk-rpi.c
index 59ae8e59bac5..71badc04c0f0 100644
--- a/drivers/clk/clk-rpi.c
+++ b/drivers/clk/clk-rpi.c
@@ -40,10 +40,29 @@ static struct clk *rpi_register_firmware_clock(u32 clock_id, const char *name)
 	return clk_fixed(name, msg->get_clock_rate.body.resp.rate_hz);
 }
 
-static int bcm2835_cprman_probe(struct device_d *dev)
+static int bcm2835_cprman_init(struct device_d *dev)
 {
 	struct clk *clk_cs;
 
+	clk_cs = clk_fixed("bcm2835-cs", 1 * 1000 * 1000);
+	clk_register_clkdev(clk_cs, NULL, "bcm2835-cs");
+
+	return 0;
+}
+
+static int rpi_cprman_probe(struct device_d *dev)
+{
+	int (*init)(struct device_d *dev);
+
+	init = device_get_match_data(dev);
+	if (init) {
+		int ret;
+
+		ret = init(dev);
+		if (ret)
+			return ret;
+	}
+
 	clks[BCM2835_CLOCK_EMMC] =
 		rpi_register_firmware_clock(BCM2835_MBOX_CLOCK_ID_EMMC,
 					 "bcm2835_mci0");
@@ -56,12 +75,15 @@ static int bcm2835_cprman_probe(struct device_d *dev)
 	if (IS_ERR(clks[BCM2835_CLOCK_VPU]))
 		return PTR_ERR(clks[BCM2835_CLOCK_VPU]);
 
+	clks[BCM2711_CLOCK_EMMC2] =
+		rpi_register_firmware_clock(BCM2835_MBOX_CLOCK_ID_EMMC2,
+					 "bcm2711_emmc2");
+	if (IS_ERR(clks[BCM2711_CLOCK_EMMC2]))
+		return PTR_ERR(clks[BCM2711_CLOCK_EMMC2]);
+
 	clks[BCM2835_CLOCK_UART] = clk_fixed("uart0-pl0110", 48 * 1000 * 1000);
 	clk_register_clkdev(clks[BCM2835_CLOCK_UART], NULL, "uart0-pl0110");
 
-	clk_cs = clk_fixed("bcm2835-cs", 1 * 1000 * 1000);
-	clk_register_clkdev(clk_cs, NULL, "bcm2835-cs");
-
 	clk_data.clks = clks;
 	clk_data.clk_num = BCM2711_CLOCK_END;
 	of_clk_add_provider(dev->device_node, of_clk_src_onecell_get, &clk_data);
@@ -70,16 +92,14 @@ static int bcm2835_cprman_probe(struct device_d *dev)
 }
 
 static __maybe_unused struct of_device_id bcm2835_cprman_dt_ids[] = {
-	{
-		.compatible = "brcm,bcm2835-cprman",
-	}, {
-		/* sentinel */
-	}
+	{ .compatible = "brcm,bcm2835-cprman", .data = bcm2835_cprman_init },
+	{ .compatible = "brcm,bcm2711-cprman" },
+	{ /* sentinel */ }
 };
 
 static struct driver_d bcm2835_cprman_driver = {
-	.probe	= bcm2835_cprman_probe,
-	.name	= "bcm2835-cprman",
+	.probe	= rpi_cprman_probe,
+	.name	= "raspberrypi-cprman",
 	.of_compatible = DRV_OF_COMPAT(bcm2835_cprman_dt_ids),
 };
 core_platform_driver(bcm2835_cprman_driver);
-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


  parent reply	other threads:[~2022-05-05  8:04 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-05  8:01 [PATCH 00/15] ARM: rpi: add basic " Ahmad Fatoum
2022-05-05  8:01 ` [PATCH 01/15] PBL: fdt: fix /memory parsing when #address-cells != #size-cells Ahmad Fatoum
2022-05-05  8:01 ` [PATCH 02/15] of: address: fix printing of OF node name in error message Ahmad Fatoum
2022-05-05  8:01 ` [PATCH 03/15] serial: ns16550: rpi: remove ungating now done by proper clk driver Ahmad Fatoum
2022-05-05  8:01 ` [PATCH 04/15] ARM: cpu: prevent recursive dependencies via CPU_SUPPORTS_64BIT_KERNEL Ahmad Fatoum
2022-05-05  8:01 ` [PATCH 05/15] ARM: rpi: add Raspberry Pi 3 64-bit build support Ahmad Fatoum
2022-05-05  8:01 ` [PATCH 06/15] ARM: rpi: rpi3: disallow MMU_EARLY && 64BIT Ahmad Fatoum
2022-05-05  8:01 ` Ahmad Fatoum [this message]
2022-05-05  8:01 ` [PATCH 08/15] mci: bcm2835: add bcm2711-emmc2 (Rpi4) support Ahmad Fatoum
2022-05-05  8:01 ` [PATCH 09/15] serial: ns16550: rpi: skip baudrate changes for bcm2711 Ahmad Fatoum
2022-05-05  8:01 ` [PATCH 10/15] clocksource: bcm2835: bump below architeced timer for AArch64 Ahmad Fatoum
2022-05-05  8:01 ` [PATCH 11/15] ARM: rpi: add Raspberry Pi 4 support Ahmad Fatoum
2022-05-05  8:01 ` [PATCH 12/15] ARM: rpi: add debug_ll support for Raspberry Pi 4 Ahmad Fatoum
2022-05-05  8:01 ` [PATCH 13/15] ARM: rpi: add heuristic for skipping detection of SDIO card Ahmad Fatoum
2022-05-05  8:01 ` [PATCH 14/15] doc: bcm283x: add initial docs for Raspberry Pi 4 support Ahmad Fatoum
2022-05-05  8:01 ` [PATCH 15/15] doc: bcm283x: reference newer firmware Ahmad Fatoum
2022-05-06 12:47 ` [PATCH 00/15] ARM: rpi: add basic Raspberry Pi 4 support Ahmad Fatoum

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=20220505080152.1068424-8-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=danek.brat@gmail.com \
    --cc=ore@pengutronix.de \
    --cc=ukl@pengutronix.de \
    --subject='Re: [PATCH 07/15] clk: rpi: add Raspberry Pi 4 support' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox