From: <dinguyen@altera.com>
To: dinh.linux@gmail.com
Cc: Dinh Nguyen <dinguyen@altera.com>, Pavel Machek <pavel@denx.de>,
Arnd Bergmann <arnd@arndb.de>,
Mike Turquette <mturquette@linaro.org>,
Olof Johansson <olof@lixom.net>,
Rob Herring <rob.herring@calxeda.com>,
Pawel Moll <pawel.moll@arm.com>,
Mark Rutland <mark.rutland@arm.com>,
Stephen Warren <swarren@wwwdotorg.org>,
Ian Campbell <ian.campbell@citrix.com>,
Chris Ball <cjb@laptop.org>,
Jaehoon Chung <jh80.chung@samsung.com>,
Seungwon Jeon <tgih.jun@samsung.com>,
devicetree@vger.kernel.org, linux-mmc@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/4] clk: socfpga: Add a clock driver for SOCFPGA's system manager
Date: Wed, 16 Oct 2013 19:32:38 -0500 [thread overview]
Message-ID: <1381969961-12679-2-git-send-email-dinguyen@altera.com> (raw)
In-Reply-To: <1381969961-12679-1-git-send-email-dinguyen@altera.com>
From: Dinh Nguyen <dinguyen@altera.com>
The system manager is an IP block on the SOCFPGA platform. The system manager
contains registers that control other IPs on the platform. One of them is
the SD/MMC IP. The system manager contains a register that controls the
clock phase of the SD/MMC CIU.
This patch adds a clock driver that the SD/MMC driver can use by calling
the common clock API in order to set the appropriate register in the
system manager.
Signed-off-by: Dinh Nguyen <dinguyen@altera.com>
Cc: Pavel Machek <pavel@denx.de>
CC: Arnd Bergmann <arnd@arndb.de>
Cc: Mike Turquette <mturquette@linaro.org>
CC: Olof Johansson <olof@lixom.net>
Cc: Rob Herring <rob.herring@calxeda.com>
Cc: Pawel Moll <pawel.moll@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Stephen Warren <swarren@wwwdotorg.org>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Chris Ball <cjb@laptop.org>
Cc: Jaehoon Chung <jh80.chung@samsung.com>
Cc: Seungwon Jeon <tgih.jun@samsung.com>
Cc: devicetree@vger.kernel.org
Cc: linux-mmc@vger.kernel.org
CC: linux-arm-kernel@lists.infradead.org
---
drivers/clk/socfpga/Makefile | 2 +-
drivers/clk/socfpga/clk-sysmgr.c | 91 ++++++++++++++++++++++++++++++++++++++
2 files changed, 92 insertions(+), 1 deletion(-)
create mode 100644 drivers/clk/socfpga/clk-sysmgr.c
diff --git a/drivers/clk/socfpga/Makefile b/drivers/clk/socfpga/Makefile
index 0303c0b..cfceabc 100644
--- a/drivers/clk/socfpga/Makefile
+++ b/drivers/clk/socfpga/Makefile
@@ -1 +1 @@
-obj-y += clk.o
+obj-y += clk.o clk-sysmgr.o
diff --git a/drivers/clk/socfpga/clk-sysmgr.c b/drivers/clk/socfpga/clk-sysmgr.c
new file mode 100644
index 0000000..0e13290
--- /dev/null
+++ b/drivers/clk/socfpga/clk-sysmgr.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2013 Altera Corporation <www.altera.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <linux/slab.h>
+#include <linux/clk-provider.h>
+#include <linux/of.h>
+#include <linux/of_platform.h>
+
+extern void __iomem *sys_manager_base_addr;
+
+/* SDMMC Group for System Manager defines */
+#define SYSMGR_SDMMC_CTRL_SET(smplsel, drvsel) \
+ ((((smplsel) & 0x7) << 3) | (((drvsel) & 0x7) << 0))
+
+struct socfpga_sysmgr {
+ struct clk_hw hw;
+ void __iomem *reg;
+};
+#define to_sysmgr_clk(p) container_of(p, struct socfpga_sysmgr, hw)
+
+static int sysmgr_set_dwmmc_drvsel_smpsel(struct clk_hw *hwclk)
+{
+ struct device_node *np;
+ struct socfpga_sysmgr *socfpga_sysmgr = to_sysmgr_clk(hwclk);
+ u32 timing[2];
+ u32 hs_timing;
+
+ np = of_find_compatible_node(NULL, NULL, "altr,socfpga-dw-mshc");
+ of_property_read_u32_array(np, "samsung,dw-mshc-sdr-timing", timing, 2);
+ hs_timing = SYSMGR_SDMMC_CTRL_SET(timing[1], timing[0]);
+ writel(hs_timing, socfpga_sysmgr->reg);
+ return 0;
+}
+
+static const struct clk_ops clk_sysmgr_sdmmc_ops = {
+ .enable = sysmgr_set_dwmmc_drvsel_smpsel,
+};
+
+static void __init socfpga_sysmgr_init(struct device_node *node, const struct clk_ops *ops)
+{
+ u32 reg;
+ struct clk *clk;
+ struct socfpga_sysmgr *socfpga_sysmgr;
+ const char *clk_name = node->name;
+ struct clk_init_data init;
+ int rc;
+
+ rc = of_property_read_u32(node, "reg", ®);
+ if (WARN_ON(rc))
+ return;
+
+ socfpga_sysmgr = kzalloc(sizeof(*socfpga_sysmgr), GFP_KERNEL);
+ if (WARN_ON(!socfpga_sysmgr))
+ return;
+
+ socfpga_sysmgr->reg = sys_manager_base_addr + reg;
+
+ init.name = clk_name;
+ init.ops = ops;
+ init.flags = 0;
+ init.num_parents = 0;
+
+ socfpga_sysmgr->hw.init = &init;
+ clk = clk_register(NULL, &socfpga_sysmgr->hw);
+ if (WARN_ON(IS_ERR(clk))) {
+ kfree(socfpga_sysmgr);
+ return;
+ }
+ rc = of_clk_add_provider(node, of_clk_src_simple_get, clk);
+ if (WARN_ON(rc))
+ return;
+}
+
+static void __init sysmgr_init(struct device_node *node)
+{
+ socfpga_sysmgr_init(node, &clk_sysmgr_sdmmc_ops);
+}
+CLK_OF_DECLARE(sysmgr, "altr,sysmgr-sdmmc-sdr", sysmgr_init);
--
1.7.9.5
next prev parent reply other threads:[~2013-10-17 0:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-17 0:32 [PATCH 0/4] socfpga: Enable SD/MMC support dinguyen
2013-10-17 0:32 ` dinguyen [this message]
2013-10-17 0:32 ` [PATCH 2/4] arm: dts: Add a system manager compatible property dinguyen
2013-10-17 0:32 ` [PATCH 3/4] mmc: dw_mmc-socfpga: Clean up SOCFPGA platform specific functionality dinguyen
2013-10-17 0:32 ` [PATCH 4/4] arm: dts: Add support for SD/MMC on SOCFPGA dinguyen
2013-10-17 7:47 ` [PATCH 0/4] socfpga: Enable SD/MMC support Steffen Trumtrar
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=1381969961-12679-2-git-send-email-dinguyen@altera.com \
--to=dinguyen@altera.com \
--cc=arnd@arndb.de \
--cc=cjb@laptop.org \
--cc=devicetree@vger.kernel.org \
--cc=dinh.linux@gmail.com \
--cc=ian.campbell@citrix.com \
--cc=jh80.chung@samsung.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-mmc@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mturquette@linaro.org \
--cc=olof@lixom.net \
--cc=pavel@denx.de \
--cc=pawel.moll@arm.com \
--cc=rob.herring@calxeda.com \
--cc=swarren@wwwdotorg.org \
--cc=tgih.jun@samsung.com \
/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).