All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Stein <alexander.stein@systec-electronic.com>
To: Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@codeaurora.org>
Cc: Alexander Stein <alexander.stein@systec-electronic.com>,
	linux-clk@vger.kernel.org
Subject: [PATCH 1/3] clk: ls1021a: new platform clock driver
Date: Wed, 22 Feb 2017 16:03:47 +0100	[thread overview]
Message-ID: <20170222150349.16790-2-alexander.stein@systec-electronic.com> (raw)
In-Reply-To: <20170222150349.16790-1-alexander.stein@systec-electronic.com>

This driver currently only implements the QSPI divider register
SCFG_QSPI_CFG.

Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
---
 drivers/clk/Makefile      |  1 +
 drivers/clk/clk-ls1021a.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 59 insertions(+)
 create mode 100644 drivers/clk/clk-ls1021a.c

diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 925081e..611f53f 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -26,6 +26,7 @@ obj-$(CONFIG_ARCH_CLPS711X)		+= clk-clps711x.o
 obj-$(CONFIG_COMMON_CLK_CS2000_CP)	+= clk-cs2000-cp.o
 obj-$(CONFIG_ARCH_EFM32)		+= clk-efm32gg.o
 obj-$(CONFIG_ARCH_HIGHBANK)		+= clk-highbank.o
+obj-$(CONFIG_SOC_LS1021A)		+= clk-ls1021a.o
 obj-$(CONFIG_COMMON_CLK_MAX77686)	+= clk-max77686.o
 obj-$(CONFIG_ARCH_MB86S7X)		+= clk-mb86s7x.o
 obj-$(CONFIG_ARCH_MOXART)		+= clk-moxart.o
diff --git a/drivers/clk/clk-ls1021a.c b/drivers/clk/clk-ls1021a.c
new file mode 100644
index 0000000..2f64806
--- /dev/null
+++ b/drivers/clk/clk-ls1021a.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2017 SYS TEC electronic GmbH
+ * Alexander Stein <alexander.stein@systec-electronic.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License version 2 as published by the
+ * Free Software Foundation.
+ */
+#include <linux/io.h>
+#include <linux/clk.h>
+#include <linux/clk-provider.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+
+static const struct clk_div_table qspi_cfg_div_table[] = {
+	{ 0x0, 256 }, { 0x1, 64 }, { 0x2, 32 }, { 0x3, 24 },
+	{ 0x4,  20 }, { 0x5, 15 }, { 0x6, 12 }, { 0x7,  8 },
+	{ 0 },
+};
+
+static void __init scfg_qspi_cfg_ls1021a_init(struct device_node *np)
+{
+	const char *parent_name;
+	const char *name;
+	void __iomem *base;
+	struct clk *parent_clk;
+	struct clk *clk;
+	struct resource res;
+
+	base = of_iomap(np, 0);
+	if (!base) {
+		pr_warn("Failed to map address range for node %s\n", np->name);
+		return;
+	}
+
+	parent_clk = of_clk_get(np, 0);
+	if (IS_ERR(parent_clk)) {
+		pr_warn("Failed to get clock for node %s\n", np->name);
+		return;
+	}
+
+	/* Register the input clock under the desired name. */
+	parent_name = __clk_get_name(parent_clk);
+
+	if (of_property_read_string(np, "clock-output-names", &name))
+		name = np->name;
+
+	/* Works only as those 4 bits (Bits 28-31 big endian) do not cross byte boundary */
+	clk = clk_register_divider_table(NULL, name, parent_name,
+				   0, base,
+				   4, 4, 0, qspi_cfg_div_table, NULL);
+	if (IS_ERR(clk)) {
+		pr_warn("Failed to register divider table clock (%ld)\n", PTR_ERR(clk));
+		return;
+	}
+	of_clk_add_provider(np, of_clk_src_simple_get, clk);
+}
+CLK_OF_DECLARE(scfg_qspi_cfg_ls1021a, "fsl,scfg-qspi-cfg-ls1021a", scfg_qspi_cfg_ls1021a_init);
-- 
2.10.2

  reply	other threads:[~2017-02-22 15:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-22 15:03 [PATCH 0/3] LS1021A: QSPI clock divider suport Alexander Stein
2017-02-22 15:03 ` Alexander Stein [this message]
2017-04-07 19:33   ` [PATCH 1/3] clk: ls1021a: new platform clock driver Stephen Boyd
2017-04-12 15:01     ` Alexander Stein
2017-04-19 16:39       ` Stephen Boyd
2017-02-22 15:03 ` [PATCH 2/3] ARM: dts: ls1021a: Add node for scfg-qspi-cfg Alexander Stein
2017-02-22 15:03 ` [PATCH 3/3] ARM: dts: ls1021a: Add QSPI node Alexander Stein

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=20170222150349.16790-2-alexander.stein@systec-electronic.com \
    --to=alexander.stein@systec-electronic.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=sboyd@codeaurora.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.