diff mbox

[v2,4/5] ARM: bcm476x: Add stub clock driver

Message ID 20121014223024.818915781@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Domenico Andreoli Oct. 14, 2012, 10:14 p.m. UTC
From: Domenico Andreoli <domenico.andreoli@linux.com>

Minimal clock support required for the boot, a more complete
implementation will follow (shortly).

v2:
* dropped the static clock initializers in favour of
  clk_register_fixed_rate()

v1:
* initial release

Signed-off-by: Domenico Andreoli <domenico.andreoli@linux.com>
Acked-by: Olof Johansson <olof@lixom.net>
---
 arch/arm/mach-bcm476x/bcm476x.c |    3 ++
 drivers/clk/Makefile            |    1 +
 drivers/clk/clk-bcm476x.c       |   55 ++++++++++++++++++++++++++++++++++++++++
 include/linux/clk/bcm476x.h     |   22 ++++++++++++++++
 4 files changed, 81 insertions(+)
 create mode 100644 drivers/clk/clk-bcm476x.c
 create mode 100644 include/linux/clk/bcm476x.h
diff mbox

Patch

Index: b/arch/arm/mach-bcm476x/bcm476x.c
===================================================================
--- a/arch/arm/mach-bcm476x/bcm476x.c
+++ b/arch/arm/mach-bcm476x/bcm476x.c
@@ -18,6 +18,7 @@ 
 #include <linux/of_irq.h>
 #include <linux/of_platform.h>
 #include <linux/bcm476x_timer.h>
+#include <linux/clk/bcm476x.h>
 
 #include <asm/hardware/vic.h>
 #include <asm/mach/arch.h>
@@ -43,6 +44,8 @@  static void __init bcm476x_init(void)
 {
 	int err;
 
+	bcm476x_init_clocks();
+
 	err = of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
 	if (err) {
 		pr_err("of_platform_populate failed: %d\n", err);
Index: b/drivers/clk/Makefile
===================================================================
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -5,6 +5,7 @@  obj-$(CONFIG_COMMON_CLK)	+= clk.o clk-fi
 				   clk-mux.o clk-divider.o clk-fixed-factor.o
 # SoCs specific
 obj-$(CONFIG_ARCH_BCM2835)	+= clk-bcm2835.o
+obj-$(CONFIG_ARCH_BCM476X)	+= clk-bcm476x.o
 obj-$(CONFIG_ARCH_NOMADIK)	+= clk-nomadik.o
 obj-$(CONFIG_ARCH_HIGHBANK)	+= clk-highbank.o
 obj-$(CONFIG_ARCH_MXS)		+= mxs/
Index: b/drivers/clk/clk-bcm476x.c
===================================================================
--- /dev/null
+++ b/drivers/clk/clk-bcm476x.c
@@ -0,0 +1,55 @@ 
+/*
+ * Broadcom BCM476x SoCs clocks
+ *
+ * Copyright (C) 2011-2012 Domenico Andreoli <domenico.andreoli@linux.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/clk-provider.h>
+#include <linux/clkdev.h>
+#include <linux/clk/bcm476x.h>
+
+/*
+ * These are fixed clocks. They're probably not all root clocks and it may
+ * be possible to turn them on and off but until this is mapped out better
+ * it's the only way they can be used.
+ */
+void __init bcm476x_init_clocks(void)
+{
+	struct clk *clk;
+
+	clk = clk_register_fixed_rate(NULL, "sys_pclk", NULL, CLK_IS_ROOT, 312000000);
+	if (IS_ERR(clk))
+		pr_err("sys_pclk not registered\n");
+
+	clk = clk_register_fixed_rate(NULL, "apb_pclk", NULL, CLK_IS_ROOT, 156000000);
+	if (IS_ERR(clk))
+		pr_err("apb_pclk not registered\n");
+
+	clk = clk_register_fixed_rate(NULL, "uart0_pclk", NULL, CLK_IS_ROOT, 78000000);
+	if (IS_ERR(clk))
+		pr_err("uart0_pclk not registered\n");
+	if (clk_register_clkdev(clk, NULL, "c0000.uart0"))
+		pr_err("uart0_pclk alias not registered\n");
+
+	clk = clk_register_fixed_rate(NULL, "uart1_pclk", NULL, CLK_IS_ROOT, 78000000);
+	if (IS_ERR(clk))
+		pr_err("uart1_pclk not registered\n");
+	if (clk_register_clkdev(clk, NULL, "c1000.uart1"))
+		pr_err("uart1_pclk alias not registered\n");
+
+	clk = clk_register_fixed_rate(NULL, "uart2_pclk", NULL, CLK_IS_ROOT, 78000000);
+	if (IS_ERR(clk))
+		pr_err("uart2_pclk not registered\n");
+	if (clk_register_clkdev(clk, NULL, "b2000.uart2"))
+		pr_err("uart2_pclk alias not registered\n");
+}
Index: b/include/linux/clk/bcm476x.h
===================================================================
--- /dev/null
+++ b/include/linux/clk/bcm476x.h
@@ -0,0 +1,22 @@ 
+/*
+ * Broadcom BCM476x SoCs clocks
+ *
+ * Copyright (C) 2011-2012 Domenico Andreoli <domenico.andreoli@linux.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef _LINUX_CLK_BCM476X_H
+#define _LINUX_CLK_BCM476X_H
+
+void __init bcm476x_init_clocks(void);
+
+#endif