linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: haojian.zhuang@linaro.org (Haojian Zhuang)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v4 1/7] clk: mux: add CLK_MUX_HIWORD_MASK
Date: Sat,  8 Jun 2013 22:47:17 +0800	[thread overview]
Message-ID: <1370702843-27172-2-git-send-email-haojian.zhuang@linaro.org> (raw)
In-Reply-To: <1370702843-27172-1-git-send-email-haojian.zhuang@linaro.org>

In both Hisilicon & Rockchip Cortex-A9 based chips, they don't use the
paradigm of reading-changing-writing the register contents.
Instead they use a hiword mask to indicate the changed bits.

When b01 should be set as switching mux, it also needs to indicate
the change by setting hiword mask (b11 << 16).

The patch adds mux flag for this usage.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
---
 drivers/clk/clk-mux.c        | 17 +++++++++++++++--
 include/linux/clk-provider.h |  5 +++++
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/clk-mux.c b/drivers/clk/clk-mux.c
index 25b1734..614444c 100644
--- a/drivers/clk/clk-mux.c
+++ b/drivers/clk/clk-mux.c
@@ -86,8 +86,12 @@ static int clk_mux_set_parent(struct clk_hw *hw, u8 index)
 	if (mux->lock)
 		spin_lock_irqsave(mux->lock, flags);
 
-	val = readl(mux->reg);
-	val &= ~(mux->mask << mux->shift);
+	if (mux->flags & CLK_MUX_HIWORD_MASK) {
+		val = mux->mask << (mux->shift + 16);
+	} else {
+		val = readl(mux->reg);
+		val &= ~(mux->mask << mux->shift);
+	}
 	val |= index << mux->shift;
 	writel(val, mux->reg);
 
@@ -111,6 +115,15 @@ struct clk *clk_register_mux_table(struct device *dev, const char *name,
 	struct clk_mux *mux;
 	struct clk *clk;
 	struct clk_init_data init;
+	u8 width = 0;
+
+	if (clk_mux_flags & CLK_MUX_HIWORD_MASK) {
+		width = fls(mask) - ffs(mask) + 1;
+		if (width + shift > 16) {
+			pr_err("mux value exceeds LOWORD field\n");
+			return ERR_PTR(-EINVAL);
+		}
+	}
 
 	/* allocate the mux */
 	mux = kzalloc(sizeof(struct clk_mux), GFP_KERNEL);
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index 1186098..fecef88 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -299,6 +299,10 @@ struct clk *clk_register_divider_table(struct device *dev, const char *name,
  * Flags:
  * CLK_MUX_INDEX_ONE - register index starts at 1, not 0
  * CLK_MUX_INDEX_BIT - register index is a single bit (power of two)
+ * CLK_MUX_HIWORD_MASK - The mux settings are only in lower 16-bit of this
+ *   register, and mask of mux bits are in higher 16-bit of this register.
+ *   While setting the mux bits, higher 16-bit should also be updated to
+ *   indicate changing mux bits.
  */
 struct clk_mux {
 	struct clk_hw	hw;
@@ -312,6 +316,7 @@ struct clk_mux {
 
 #define CLK_MUX_INDEX_ONE		BIT(0)
 #define CLK_MUX_INDEX_BIT		BIT(1)
+#define CLK_MUX_HIWORD_MASK		BIT(2)
 
 extern const struct clk_ops clk_mux_ops;
 
-- 
1.8.1.2

  reply	other threads:[~2013-06-08 14:47 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-08 14:47 [PATCH v4 0/7] support Hisilicon SoC Haojian Zhuang
2013-06-08 14:47 ` Haojian Zhuang [this message]
2013-06-08 14:47 ` [PATCH v4 2/7] clk: divider: add CLK_DIVIDER_HIWORD_MASK flag Haojian Zhuang
2013-06-08 14:47 ` [PATCH v4 3/7] clk: gate: add CLK_GATE_HIWORD_MASK Haojian Zhuang
2013-06-08 14:47 ` [PATCH v4 4/7] clk: hi3xxx: add clock support Haojian Zhuang
2013-06-08 14:47 ` [PATCH v4 5/7] ARM: debug: support debug ll on hisilicon soc Haojian Zhuang
2013-06-08 14:47 ` [PATCH v4 6/7] ARM: hi3xxx: add board support with device tree Haojian Zhuang
2013-06-12 19:54   ` Olof Johansson
2013-06-17  1:06     ` Haojian Zhuang
2013-06-08 14:47 ` [PATCH v4 7/7] ARM: hi3xxx: enable hi4511 " Haojian Zhuang
2013-06-12 20:00   ` Olof Johansson
2013-06-17  1:21     ` Haojian Zhuang
2013-06-18  7:38   ` Linus Walleij
2013-06-12 20:01 ` [PATCH v4 0/7] support Hisilicon SoC Olof Johansson
2013-06-13 16:29   ` Heiko Stübner
2013-06-13 19:58     ` Olof Johansson
2013-06-16  4:08       ` Mike Turquette
2013-06-16  4:32         ` Olof Johansson

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=1370702843-27172-2-git-send-email-haojian.zhuang@linaro.org \
    --to=haojian.zhuang@linaro.org \
    --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).