linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: s.hauer@pengutronix.de (Sascha Hauer)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 31/40] ARM i.MX31: implement clocks using common clock framework
Date: Tue, 10 Apr 2012 15:45:44 +0200	[thread overview]
Message-ID: <1334065553-7565-32-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1334065553-7565-1-git-send-email-s.hauer@pengutronix.de>

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/mach-imx/Kconfig     |    1 +
 arch/arm/mach-imx/Makefile    |    2 +-
 arch/arm/mach-imx/clk-imx31.c |  168 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 170 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/mach-imx/clk-imx31.c

diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index efed8f9..692de7b 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -68,6 +68,7 @@ config SOC_IMX31
 	select CPU_V6
 	select IMX_HAVE_PLATFORM_MXC_RNGA
 	select MXC_AVIC
+	select COMMON_CLK
 	select SMP_ON_UP if SMP
 
 config SOC_IMX35
diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index c4ab418..fdad8f4 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -6,7 +6,7 @@ obj-$(CONFIG_SOC_IMX25) += clk-imx25.o mm-imx25.o ehci-imx25.o cpu-imx25.o
 obj-$(CONFIG_SOC_IMX27) += cpu-imx27.o pm-imx27.o
 obj-$(CONFIG_SOC_IMX27) += clk-imx27.o mm-imx27.o ehci-imx27.o
 
-obj-$(CONFIG_SOC_IMX31) += mm-imx3.o cpu-imx31.o clock-imx31.o iomux-imx31.o ehci-imx31.o pm-imx3.o
+obj-$(CONFIG_SOC_IMX31) += mm-imx3.o cpu-imx31.o clk-imx31.o iomux-imx31.o ehci-imx31.o pm-imx3.o
 obj-$(CONFIG_SOC_IMX35) += mm-imx3.o cpu-imx35.o clock-imx35.o ehci-imx35.o pm-imx3.o
 
 obj-$(CONFIG_SOC_IMX5) += cpu-imx5.o mm-imx5.o clock-mx51-mx53.o ehci-imx5.o pm-imx5.o cpu_op-mx51.o
diff --git a/arch/arm/mach-imx/clk-imx31.c b/arch/arm/mach-imx/clk-imx31.c
new file mode 100644
index 0000000..de3addb
--- /dev/null
+++ b/arch/arm/mach-imx/clk-imx31.c
@@ -0,0 +1,168 @@
+/*
+ * Copyright (C) 2012 Sascha Hauer <kernel@pengutronix.de>
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation.
+ */
+
+#include <linux/module.h>
+#include <linux/clk.h>
+#include <linux/clkdev.h>
+#include <linux/io.h>
+
+#include <mach/hardware.h>
+#include <mach/mx31.h>
+#include <mach/common.h>
+
+#include "clk.h"
+#include "crmregs-imx3.h"
+
+static char *mcu_main_sel[] = { "spll", "mpll", };
+static char *per_sel[] = { "per_div", "ipg", };
+static char *csi_sel[] = { "upll", "spll", };
+
+#define clkdev(d, n, c) \
+	{ \
+		.dev_id = d, \
+		.con_id = n, \
+		.clkname = c, \
+	},
+
+static struct clk_lookup lookups[] = {
+	clkdev("imx-gpt.0", "per", "gpt_gate")
+	clkdev("imx-gpt.0", "ipg", "ipg")
+	clkdev("imx31-cspi.0", NULL, "cspi1_gate")
+	clkdev("imx31-cspi.1", NULL, "cspi2_gate")
+	clkdev("imx31-cspi.2", NULL, "cspi3_gate")
+	clkdev(NULL, "pwm", "pwm_gate")
+	clkdev("imx2-wdt.0", NULL, "wdog_gate")
+	clkdev(NULL, "rtc", "rtc_gate")
+	clkdev(NULL, "epit", "epit1_gate")
+	clkdev(NULL, "epit", "epit2_gate")
+	clkdev("mxc_nand.0", NULL, "nfc")
+	clkdev("ipu-core", NULL, "ipu_gate")
+	clkdev("mx3_sdc_fb", NULL, "ipu_gate")
+	clkdev(NULL, "kpp", "kpp_gate")
+	clkdev("mxc-ehci.0", "per", "usb_div_post")
+	clkdev("mxc-ehci.0", "ahb", "usb_gate")
+	clkdev("mxc-ehci.0", "ipg", "ipg")
+	clkdev("mxc-ehci.1", "per", "usb_div_post")
+	clkdev("mxc-ehci.1", "ahb", "usb_gate")
+	clkdev("mxc-ehci.1", "ipg", "ipg")
+	clkdev("mxc-ehci.2", "per", "usb_div_post")
+	clkdev("mxc-ehci.2", "ahb", "usb_gate")
+	clkdev("mxc-ehci.2", "ipg", "ipg")
+	clkdev("fsl-usb2-udc", "per", "usb_div_post")
+	clkdev("fsl-usb2-udc", "ahb", "usb_gate")
+	clkdev("fsl-usb2-udc", "ipg", "ipg")
+	clkdev("mx3-camera.0", NULL, "csi_gate")
+	/* i.mx31 has the i.mx21 type uart */
+	clkdev("imx21-uart.0", "per", "uart1_gate")
+	clkdev("imx21-uart.0", "ipg", "ipg")
+	clkdev("imx21-uart.1", "per", "uart2_gate")
+	clkdev("imx21-uart.1", "ipg", "ipg")
+	clkdev("imx21-uart.2", "per", "uart3_gate")
+	clkdev("imx21-uart.2", "ipg", "ipg")
+	clkdev("imx21-uart.3", "per", "uart4_gate")
+	clkdev("imx21-uart.3", "ipg", "ipg")
+	clkdev("imx21-uart.4", "per", "uart5_gate")
+	clkdev("imx21-uart.4", "ipg", "ipg")
+	clkdev("imx-i2c.0", NULL, "i2c1_gate")
+	clkdev("imx-i2c.1", NULL, "i2c2_gate")
+	clkdev("imx-i2c.2", NULL, "i2c3_gate")
+	clkdev("mxc_w1.0", NULL, "owire_gate")
+	clkdev("mxc-mmc.0", NULL, "sdhc1_gate")
+	clkdev("mxc-mmc.1", NULL, "sdhc2_gate")
+	clkdev("imx-ssi.0", NULL, "ssi1_gate")
+	clkdev("imx-ssi.1", NULL, "ssi2_gate")
+	clkdev(NULL, "firi", "firi_gate")
+	clkdev("pata_imx", NULL, "pata_gate")
+	clkdev(NULL, "rtic", "rtic_gate")
+	clkdev(NULL, "rng", "rng_gate")
+	clkdev("imx31-sdma", NULL, "sdma_gate")
+	clkdev(NULL, "iim", "iim_gate")
+};
+
+int __init mx31_clocks_init(unsigned long fref)
+{
+	struct clk *emi, *upll, *csisel, *iim;
+	void __iomem *base = MX31_IO_ADDRESS(MX31_CCM_BASE_ADDR);
+
+	imx_clk_fixed("ckih", fref);
+	imx_clk_fixed("ckil", 32768);
+	imx_clk_pllv1("mpll", "ckih", base + MXC_CCM_MPCTL);
+	imx_clk_pllv1("spll", "ckih", base + MXC_CCM_SRPCTL);
+	upll = imx_clk_pllv1("upll", "ckih", base + MXC_CCM_UPCTL);
+	imx_clk_mux("mcu_main", base + MXC_CCM_PMCR0, 31, 1, mcu_main_sel, ARRAY_SIZE(mcu_main_sel));
+	imx_clk_divider("hsp", "mcu_main", base + MXC_CCM_PDR0, 11, 3);
+	imx_clk_divider("ahb", "mcu_main", base + MXC_CCM_PDR0, 3, 3);
+	imx_clk_divider("nfc", "ahb", base + MXC_CCM_PDR0, 8, 3);
+	imx_clk_divider("ipg", "ahb", base + MXC_CCM_PDR0, 6, 2);
+	imx_clk_divider("per_div", "upll", base + MXC_CCM_PDR0, 16, 5);
+	imx_clk_mux("per", base + MXC_CCM_CCMR, 24, 1, per_sel, ARRAY_SIZE(per_sel));
+	csisel = imx_clk_mux("csi_sel", base + MXC_CCM_CCMR, 25, 1, csi_sel, ARRAY_SIZE(csi_sel));
+	imx_clk_divider("csi_div", "csi_sel", base + MXC_CCM_PDR0, 23, 9);
+	imx_clk_divider("usb_div_pre", "upll", base + MXC_CCM_PDR1, 30, 2);
+	imx_clk_divider("usb_div_post", "usb_div_pre", base + MXC_CCM_PDR1, 27, 3);
+	imx_clk_gate2("sdhc1_gate", "per", base + MXC_CCM_CGR0, 0);
+	imx_clk_gate2("sdhc2_gate", "per", base + MXC_CCM_CGR0, 2);
+	imx_clk_gate2("gpt_gate", "per", base + MXC_CCM_CGR0, 4);
+	imx_clk_gate2("epit1_gate", "per", base + MXC_CCM_CGR0, 6);
+	imx_clk_gate2("epit2_gate", "per", base + MXC_CCM_CGR0, 8);
+	iim = imx_clk_gate2("iim_gate", "ipg", base + MXC_CCM_CGR0, 10);
+	imx_clk_gate2("ata_gate", "ipg", base + MXC_CCM_CGR0, 12);
+	imx_clk_gate2("sdma_gate", "ahb", base + MXC_CCM_CGR0, 14);
+	imx_clk_gate2("cspi3_gate", "ipg", base + MXC_CCM_CGR0, 16);
+	imx_clk_gate2("rng_gate", "ipg", base + MXC_CCM_CGR0, 18);
+	imx_clk_gate2("uart1_gate", "per", base + MXC_CCM_CGR0, 20);
+	imx_clk_gate2("uart2_gate", "per", base + MXC_CCM_CGR0, 22);
+	imx_clk_gate2("ssi1_gate", "spll", base + MXC_CCM_CGR0, 24);
+	imx_clk_gate2("i2c1_gate", "per", base + MXC_CCM_CGR0, 26);
+	imx_clk_gate2("i2c2_gate", "per", base + MXC_CCM_CGR0, 28);
+	imx_clk_gate2("i2c3_gate", "per", base + MXC_CCM_CGR0, 30);
+	imx_clk_gate2("hantro_gate", "per", base + MXC_CCM_CGR1, 0);
+	imx_clk_gate2("mstick1_gate", "per", base + MXC_CCM_CGR1, 2);
+	imx_clk_gate2("mstick2_gate", "per", base + MXC_CCM_CGR1, 4);
+	imx_clk_gate2("csi_gate", "csi_div", base + MXC_CCM_CGR1, 6);
+	imx_clk_gate2("rtc_gate", "ipg", base + MXC_CCM_CGR1, 8);
+	imx_clk_gate2("wdog_gate", "ipg", base + MXC_CCM_CGR1, 10);
+	imx_clk_gate2("pwm_gate", "per", base + MXC_CCM_CGR1, 12);
+	imx_clk_gate2("sim_gate", "per", base + MXC_CCM_CGR1, 14);
+	imx_clk_gate2("ect_gate", "per", base + MXC_CCM_CGR1, 16);
+	imx_clk_gate2("usb_gate", "ahb", base + MXC_CCM_CGR1, 18);
+	imx_clk_gate2("kpp_gate", "ipg", base + MXC_CCM_CGR1, 20);
+	imx_clk_gate2("ipu_gate", "hsp", base + MXC_CCM_CGR1, 22);
+	imx_clk_gate2("uart3_gate", "per", base + MXC_CCM_CGR1, 24);
+	imx_clk_gate2("uart4_gate", "per", base + MXC_CCM_CGR1, 26);
+	imx_clk_gate2("uart5_gate", "per", base + MXC_CCM_CGR1, 28);
+	imx_clk_gate2("owire_gate", "per", base + MXC_CCM_CGR1, 30);
+	imx_clk_gate2("ssi2_gate", "spll", base + MXC_CCM_CGR2, 0);
+	imx_clk_gate2("cspi1_gate", "ipg", base + MXC_CCM_CGR2, 2);
+	imx_clk_gate2("cspi2_gate", "ipg", base + MXC_CCM_CGR2, 4);
+	imx_clk_gate2("gacc_gate", "per", base + MXC_CCM_CGR2, 6);
+	emi = imx_clk_gate2("emi_gate", "ahb", base + MXC_CCM_CGR2, 8);
+	imx_clk_gate2("rtic_gate", "ahb", base + MXC_CCM_CGR2, 10);
+
+	clkdev_add_table(lookups, ARRAY_SIZE(lookups));
+
+	clk_set_parent(csisel, upll);
+	clk_prepare_enable(emi);
+	clk_prepare_enable(iim);
+	mx31_revision();
+	clk_disable_unprepare(iim);
+
+	mxc_timer_init(NULL, MX31_IO_ADDRESS(MX31_GPT1_BASE_ADDR),
+			MX31_INT_GPT);
+
+	return 0;
+}
-- 
1.7.9.5

  parent reply	other threads:[~2012-04-10 13:45 UTC|newest]

Thread overview: 101+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-10 13:45 Convert i.MX architecture to generic clock framework Sascha Hauer
2012-04-10 13:45 ` [PATCH 01/40] clkdev: add clkname to struct clk_lookup Sascha Hauer
2012-04-10 14:30   ` Russell King - ARM Linux
2012-04-10 16:11     ` Sascha Hauer
2012-04-11  1:11       ` Richard Zhao
2012-04-11  8:24         ` Mark Brown
2012-04-11  8:45           ` Richard Zhao
2012-04-11  9:15             ` Mark Brown
2012-04-11  9:21               ` Russell King - ARM Linux
2012-04-11  9:32                 ` Mark Brown
2012-04-11  9:41                   ` Russell King - ARM Linux
2012-04-11 10:31                     ` Mark Brown
2012-04-11 11:43                       ` Russell King - ARM Linux
2012-04-12 16:33                         ` Mark Brown
2012-04-11  9:20             ` Russell King - ARM Linux
2012-04-11  9:42               ` Sascha Hauer
2012-04-11  9:47                 ` Russell King - ARM Linux
2012-04-13  3:33                   ` Viresh Kumar
2012-04-13  4:17                     ` Shawn Guo
2012-04-13  5:06                       ` Viresh Kumar
2012-04-13  5:22                         ` Shawn Guo
2012-04-13  8:59                           ` Mark Brown
2012-04-13  9:10                             ` Viresh Kumar
2012-04-13  9:17                               ` Richard Zhao
2012-04-13  9:26                                 ` Russell King - ARM Linux
2012-04-13  9:27                                   ` Viresh Kumar
2012-04-13  9:36                                     ` Russell King - ARM Linux
2012-04-13 10:02                                       ` Viresh Kumar
2012-04-13 10:08                                         ` Mark Brown
2012-04-13 10:20                                         ` Russell King - ARM Linux
2012-04-13 10:43                                           ` Viresh Kumar
2012-04-13 23:19                                           ` Turquette, Mike
2012-04-24  2:17               ` Richard Zhao
2012-04-10 13:45 ` [PATCH 02/40] clk: add a fixed factor clock Sascha Hauer
2012-04-17 10:15   ` Viresh Kumar
2012-04-19  3:48   ` Viresh Kumar
2012-04-19  6:16     ` Domenico Andreoli
2012-04-19  6:19       ` Viresh Kumar
2012-04-19  6:45     ` Sascha Hauer
2012-04-10 13:45 ` [PATCH 03/40] clk: declare clk_ops of basic clks in clk-provider.h Sascha Hauer
2012-04-10 13:45 ` [PATCH 04/40] dmaengine i.MX SDMA: do not depend on grouped clocks Sascha Hauer
2012-04-10 13:45 ` [PATCH 05/40] spi i.MX: " Sascha Hauer
2012-04-10 13:45 ` [PATCH 06/40] video imxfb: " Sascha Hauer
2012-04-10 13:45 ` [PATCH 07/40] net fec: " Sascha Hauer
2012-04-10 13:45 ` [PATCH 08/40] mmc mxcmmc: " Sascha Hauer
2012-04-10 13:45 ` [PATCH 09/40] mmc sdhc i.MX: " Sascha Hauer
2012-04-20  2:06   ` Richard Zhao
2012-04-20  2:42     ` Richard Zhao
2012-04-10 13:45 ` [PATCH 10/40] serial " Sascha Hauer
2012-04-10 13:45 ` [PATCH 11/40] mtd mxc_nand: prepare/unprepare clock Sascha Hauer
2012-04-10 13:45 ` [PATCH 12/40] USB ehci mxc: " Sascha Hauer
2012-04-10 13:45 ` [PATCH 13/40] w1 i.MX: " Sascha Hauer
2012-04-10 13:45 ` [PATCH 14/40] watchdog imx2: prepare clk before enabling it Sascha Hauer
2012-04-10 13:45 ` [PATCH 15/40] media mx3 camera: " Sascha Hauer
2012-04-10 13:45 ` [PATCH 16/40] dmaengine i.MX ipu: clk_prepare/unprepare clock Sascha Hauer
2012-04-10 13:45 ` [PATCH 17/40] ARM i.MX5: prepare gpc_dvfs_clk Sascha Hauer
2012-04-10 13:45 ` [PATCH 18/40] ARM i.MX: prepare for common clock framework Sascha Hauer
2012-04-10 13:45 ` [PATCH 19/40] ARM i.MX timer: request correct clock Sascha Hauer
2012-04-10 13:45 ` [PATCH 20/40] ARM i.MX: Add common clock support for pllv1 Sascha Hauer
2012-04-10 13:45 ` [PATCH 21/40] ARM i.MX: Add common clock support for pllv2 Sascha Hauer
2012-04-10 13:45 ` [PATCH 22/40] ARM: imx: add common clock support for pllv3 Sascha Hauer
2012-04-10 13:45 ` [PATCH 23/40] ARM i.MX: Add common clock support for 2bit gate Sascha Hauer
2012-04-19  7:00   ` Shawn Guo
2012-04-19  7:15     ` Richard Zhao
2012-04-19  7:26     ` Lei Wen
2012-04-19  7:52       ` Domenico Andreoli
2012-04-10 13:45 ` [PATCH 24/40] ARM: imx: add common clock support for pfd Sascha Hauer
2012-04-10 13:45 ` [PATCH 25/40] ARM: imx: add common clock support for clk busy Sascha Hauer
2012-04-10 18:59   ` Stephen Boyd
2012-04-11  6:53     ` Sascha Hauer
2012-04-11 22:21       ` Stephen Boyd
2012-04-12  3:30         ` Shawn Guo
2012-04-12  1:50   ` Richard Zhao
2012-04-12  2:44     ` Shawn Guo
2012-04-13  2:09   ` [PATCH] ARM: imx: remove clk_hw from clk_busy Shawn Guo
2012-04-13 14:34     ` Sascha Hauer
2012-04-10 13:45 ` [PATCH 26/40] ARM i.MX3: Make ccm base address a variable Sascha Hauer
2012-04-10 13:45 ` [PATCH 27/40] ARM i.MX25: implement clocks using common clock framework Sascha Hauer
2012-04-10 20:10   ` Roberto Nibali
2012-04-10 20:45     ` Fabio Estevam
2012-04-11  7:01       ` Roberto Nibali
2012-04-10 13:45 ` [PATCH 28/40] ARM i.MX1: " Sascha Hauer
2012-04-16 21:07   ` Sascha Hauer
2012-04-10 13:45 ` [PATCH 29/40] ARM i.MX21: " Sascha Hauer
2012-04-10 13:45 ` [PATCH 30/40] ARM i.MX27: " Sascha Hauer
2012-04-10 13:45 ` Sascha Hauer [this message]
2012-04-10 13:45 ` [PATCH 32/40] ARM i.MX5: " Sascha Hauer
2012-04-23  6:39   ` Richard Zhao
2012-04-23  6:54     ` Sascha Hauer
2012-04-23  7:28       ` Richard Zhao
2012-04-10 13:45 ` [PATCH 33/40] ARM i.MX35: " Sascha Hauer
2012-04-10 13:45 ` [PATCH 34/40] ARM: imx6: " Sascha Hauer
2012-04-18 11:33   ` Sascha Hauer
2012-04-19 13:56     ` Shawn Guo
2012-04-19 14:06       ` Sascha Hauer
2012-04-10 13:45 ` [PATCH 35/40] ARM i.MX: remove now unused old clock support Sascha Hauer
2012-04-10 13:45 ` [PATCH 36/40] ARM i.MX pllv1: move mxc_decode_pll to its only user Sascha Hauer
2012-04-10 13:45 ` [PATCH 37/40] ARM i.MX: remove unused legacy clock support Sascha Hauer
2012-04-10 13:45 ` [PATCH 38/40] USB gadget i.MX: fix clock handling Sascha Hauer
2012-04-10 13:45 ` [PATCH 39/40] USB ehci i.MX: Fix " Sascha Hauer
2012-04-10 13:45 ` [PATCH 40/40] ARM i.MX: Remove now unused struct clk argument from mxc_timer_init 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=1334065553-7565-32-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=linux-arm-kernel@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;
as well as URLs for NNTP newsgroup(s).