[PATCH 08/10] ARM: rpi: register a clkdev for the eMMC clock
Andre Heider
a.heider at gmail.com
Sat Oct 19 08:20:53 EDT 2013
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 at 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
More information about the barebox
mailing list