mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Andre Heider <a.heider@gmail.com>
To: barebox@lists.infradead.org
Subject: [PATCH 08/10] ARM: rpi: register a clkdev for the eMMC clock
Date: Sat, 19 Oct 2013 14:20:53 +0200	[thread overview]
Message-ID: <1382185254-29183-7-git-send-email-a.heider@gmail.com> (raw)
In-Reply-To: <1382185130-28995-1-git-send-email-a.heider@gmail.com>

Use the mailbox driver to query the clock frequency and create
a clkdev for the bcm2835_mci driver.

Signed-off-by: Andre Heider <a.heider@gmail.com>
---
 arch/arm/boards/raspberry-pi/rpi.c | 40 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/arch/arm/boards/raspberry-pi/rpi.c b/arch/arm/boards/raspberry-pi/rpi.c
index 971a603..d3c6b11 100644
--- a/arch/arm/boards/raspberry-pi/rpi.c
+++ b/arch/arm/boards/raspberry-pi/rpi.c
@@ -17,11 +17,44 @@
 #include <init.h>
 #include <fs.h>
 #include <linux/stat.h>
+#include <linux/clk.h>
+#include <linux/clkdev.h>
 #include <envfs.h>
 #include <asm/armlinux.h>
 #include <generated/mach-types.h>
 
 #include <mach/core.h>
+#include <mach/mbox.h>
+
+struct msg_get_clock_rate {
+	struct bcm2835_mbox_hdr hdr;
+	struct bcm2835_mbox_tag_get_clock_rate get_clock_rate;
+	u32 end_tag;
+};
+
+static int rpi_register_clkdev(u32 clock_id, const char *name)
+{
+	BCM2835_MBOX_STACK_ALIGN(struct msg_get_clock_rate, msg);
+	struct clk *clk;
+	int ret;
+
+	BCM2835_MBOX_INIT_HDR(msg);
+	BCM2835_MBOX_INIT_TAG(&msg->get_clock_rate, GET_CLOCK_RATE);
+	msg->get_clock_rate.body.req.clock_id = clock_id;
+
+	ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr);
+	if (ret)
+		return ret;
+
+	clk = clk_fixed(name, msg->get_clock_rate.body.resp.rate_hz);
+	if (IS_ERR(clk))
+		return PTR_ERR(clk);
+
+	if (!clk_register_clkdev(clk, NULL, name))
+		return -ENODEV;
+
+	return 0;
+}
 
 static int rpi_mem_init(void)
 {
@@ -40,6 +73,13 @@ static int rpi_console_init(void)
 }
 console_initcall(rpi_console_init);
 
+static int rpi_clock_init(void)
+{
+	rpi_register_clkdev(BCM2835_MBOX_CLOCK_ID_EMMC, "bcm2835_mci0");
+	return 0;
+}
+postconsole_initcall(rpi_clock_init);
+
 static int rpi_env_init(void)
 {
 	struct stat s;
-- 
1.8.3.2


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

  parent reply	other threads:[~2013-10-19 12:21 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-19 12:18 [PATCH 00/10] RPi mailbox support Andre Heider
2013-10-19 12:18 ` [PATCH 01/10] ARM: cache: restore cache functions from the PBL Andre Heider
2013-10-19 12:20 ` [PATCH 02/10] ARM: cache: do not crash when the MMU isn't yet setup Andre Heider
2013-10-19 12:20 ` [PATCH 03/10] common: add a macro to align an array on the stack Andre Heider
2013-10-19 12:20 ` [PATCH 04/10] ARM: bcm2835: cleanup clock registering Andre Heider
2013-10-19 12:20 ` [PATCH 05/10] ARM: bcm2835: register the clocksource driver earlier Andre Heider
2013-10-19 12:20 ` [PATCH 06/10] ARM: bcm2835: register the clocksource device earlier Andre Heider
2013-10-19 12:20 ` [PATCH 07/10] ARM: bcm2835: add a mailbox driver for VideoCore Andre Heider
2013-10-19 12:20 ` Andre Heider [this message]
2013-10-19 12:20 ` [PATCH 09/10] mci: bcm2835: use the registered device clkdev Andre Heider
2013-10-19 12:21 ` [PATCH 10/10] ARM: rpi: use the proper ARM memory size Andre Heider
2013-10-21  8:46 ` [PATCH 00/10] RPi mailbox support Sascha Hauer
2013-10-21 15:32   ` Andre Heider
2013-10-22 13:34 ` Sascha Hauer
2013-10-22 16:57   ` Andre Heider
2013-10-22 21:37     ` Sascha Hauer

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=1382185254-29183-7-git-send-email-a.heider@gmail.com \
    --to=a.heider@gmail.com \
    --cc=barebox@lists.infradead.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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox