linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: ben-linux@fluff.org (Ben Dooks)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 04/15] ARM: SAMSUNG: Move S3C6400 PLL code to <plat/pll.h> for re-use
Date: Wed, 12 May 2010 03:35:55 +0100	[thread overview]
Message-ID: <1273631766-15693-4-git-send-email-ben-linux@fluff.org> (raw)
In-Reply-To: <1273631766-15693-1-git-send-email-ben-linux@fluff.org>

The S3C6400 EPLL code matches the S3C2416 and compatible SoCs, so move
it from mach-s3c64xx into <plat/pll.h> for easy reuse.

Signed-off-by: Ben Dooks <ben-linux@fluff.org>
---
 arch/arm/mach-s3c64xx/include/mach/pll.h      |   35 +---------------
 arch/arm/plat-samsung/include/plat/pll6553x.h |   51 +++++++++++++++++++++++++
 2 files changed, 54 insertions(+), 32 deletions(-)
 create mode 100644 arch/arm/plat-samsung/include/plat/pll6553x.h

diff --git a/arch/arm/mach-s3c64xx/include/mach/pll.h b/arch/arm/mach-s3c64xx/include/mach/pll.h
index 90bbd72..5ef0bb6 100644
--- a/arch/arm/mach-s3c64xx/include/mach/pll.h
+++ b/arch/arm/mach-s3c64xx/include/mach/pll.h
@@ -20,6 +20,7 @@
 #define S3C6400_PLL_SDIV_SHIFT	(0)
 
 #include <asm/div64.h>
+#include <plat/pll6553x.h>
 
 static inline unsigned long s3c6400_get_pll(unsigned long baseclk,
 					    u32 pllcon)
@@ -37,38 +38,8 @@ static inline unsigned long s3c6400_get_pll(unsigned long baseclk,
 	return (unsigned long)fvco;
 }
 
-#define S3C6400_EPLL_MDIV_MASK	((1 << (23-16)) - 1)
-#define S3C6400_EPLL_PDIV_MASK	((1 << (13-8)) - 1)
-#define S3C6400_EPLL_SDIV_MASK	((1 << (2-0)) - 1)
-#define S3C6400_EPLL_MDIV_SHIFT	(16)
-#define S3C6400_EPLL_PDIV_SHIFT	(8)
-#define S3C6400_EPLL_SDIV_SHIFT	(0)
-#define S3C6400_EPLL_KDIV_MASK  (0xffff)
-
 static inline unsigned long s3c6400_get_epll(unsigned long baseclk)
 {
-	unsigned long result;
-	u32 epll0 = __raw_readl(S3C_EPLL_CON0);
-	u32 epll1 = __raw_readl(S3C_EPLL_CON1);
-	u32 mdiv, pdiv, sdiv, kdiv;
-	u64 tmp;
-
-	mdiv = (epll0 >> S3C6400_EPLL_MDIV_SHIFT) & S3C6400_EPLL_MDIV_MASK;
-	pdiv = (epll0 >> S3C6400_EPLL_PDIV_SHIFT) & S3C6400_EPLL_PDIV_MASK;
-	sdiv = (epll0 >> S3C6400_EPLL_SDIV_SHIFT) & S3C6400_EPLL_SDIV_MASK;
-	kdiv = epll1 & S3C6400_EPLL_KDIV_MASK;
-
-	/* We need to multiple baseclk by mdiv (the integer part) and kdiv
-	 * which is in 2^16ths, so shift mdiv up (does not overflow) and
-	 * add kdiv before multiplying. The use of tmp is to avoid any
-	 * overflows before shifting bac down into result when multipling
-	 * by the mdiv and kdiv pair.
-	 */
-
-	tmp = baseclk;
-	tmp *= (mdiv << 16) + kdiv;
-	do_div(tmp, (pdiv << sdiv));
-	result = tmp >> 16;
-
-	return result;
+	return s3c_get_pll6553x(baseclk, __raw_readl(S3C_EPLL_CON0),
+				__raw_readl(S3C_EPLL_CON1));
 }
diff --git a/arch/arm/plat-samsung/include/plat/pll6553x.h b/arch/arm/plat-samsung/include/plat/pll6553x.h
new file mode 100644
index 0000000..b8b7e1d
--- /dev/null
+++ b/arch/arm/plat-samsung/include/plat/pll6553x.h
@@ -0,0 +1,51 @@
+/* arch/arm/plat-samsung/include/plat/pll6553x.h
+ *	partially from arch/arm/mach-s3c64xx/include/mach/pll.h
+ *
+ * Copyright 2008 Openmoko, Inc.
+ * Copyright 2008 Simtec Electronics
+ *	Ben Dooks <ben@simtec.co.uk>
+ *	http://armlinux.simtec.co.uk/
+ *
+ * Samsung PLL6553x PLL code
+ *
+ * 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.
+*/
+
+/* S3C6400 and compatible (S3C2416, etc.) EPLL code */
+
+#define PLL6553X_MDIV_MASK	((1 << (23-16)) - 1)
+#define PLL6553X_PDIV_MASK	((1 << (13-8)) - 1)
+#define PLL6553X_SDIV_MASK	((1 << (2-0)) - 1)
+#define PLL6553X_MDIV_SHIFT	(16)
+#define PLL6553X_PDIV_SHIFT	(8)
+#define PLL6553X_SDIV_SHIFT	(0)
+#define PLL6553X_KDIV_MASK	(0xffff)
+
+static inline unsigned long s3c_get_pll6553x(unsigned long baseclk,
+					     u32 pll0, u32 pll1)
+{
+	unsigned long result;
+	u32 mdiv, pdiv, sdiv, kdiv;
+	u64 tmp;
+
+	mdiv = (pll0 >> PLL6553X_MDIV_SHIFT) & PLL6553X_MDIV_MASK;
+	pdiv = (pll0 >> PLL6553X_PDIV_SHIFT) & PLL6553X_PDIV_MASK;
+	sdiv = (pll0 >> PLL6553X_SDIV_SHIFT) & PLL6553X_SDIV_MASK;
+	kdiv = pll1 & PLL6553X_KDIV_MASK;
+
+	/* We need to multiple baseclk by mdiv (the integer part) and kdiv
+	 * which is in 2^16ths, so shift mdiv up (does not overflow) and
+	 * add kdiv before multiplying. The use of tmp is to avoid any
+	 * overflows before shifting bac down into result when multipling
+	 * by the mdiv and kdiv pair.
+	 */
+
+	tmp = baseclk;
+	tmp *= (mdiv << 16) + kdiv;
+	do_div(tmp, (pdiv << sdiv));
+	result = tmp >> 16;
+
+	return result;
+}
-- 
1.6.3.3

  parent reply	other threads:[~2010-05-12  2:35 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-12  2:35 [PATCH 01/15] ARM: S3C: Add S3C2416 detection to uncompress code Ben Dooks
2010-05-12  2:35 ` [PATCH 02/15] serial: Use s3c2440 driver for S3C2416 SoC Ben Dooks
2010-05-12  2:35 ` [PATCH 03/15] ARM: S3C2416: Add S3C2416-specific registers definitions Ben Dooks
2010-05-12  2:35 ` Ben Dooks [this message]
2010-05-12  2:35 ` [PATCH 05/15] ARM: SAMSUNG: Add s3c_disable_clocks() and tidy init+disable usage Ben Dooks
2010-05-12  2:35 ` [PATCH 06/15] ARM: S3C2416: Add arch support Ben Dooks
2010-05-12  2:35 ` [PATCH 07/15] ARM: S3C2416: Add initial support of SMDK2416 Ben Dooks
2010-05-12  2:35 ` [PATCH 08/15] ARM: S3C24XX: Identify S3C2416 if S3C2412/S3C2413 built in Ben Dooks
2010-05-12  2:36 ` [PATCH 09/15] ARM: S3C2443: Move parts of the clock code to common clock file Ben Dooks
2010-05-12  2:36 ` [PATCH 10/15] ARM: S3C2416: Add basic clock support Ben Dooks
2010-05-12  2:36 ` [PATCH 11/15] ARM: S3C2416: Add support for second HSMMC channel Ben Dooks
2010-06-17 19:05   ` Darius Augulis
2010-06-17 19:19     ` Yauhen Kharuzhy
2010-06-18 18:30       ` Darius Augulis
2010-05-12  2:36 ` [PATCH 12/15] ARM: S3C2416: Add support for OHCI on SMDK2416 Ben Dooks
2010-05-12  2:36 ` [PATCH 13/15] ARM: S3C2416: Use s3c2440 style i2c controller Ben Dooks
2010-05-12  2:36 ` [PATCH 14/15] ARM: S3C2413: Update GPIO pull-up support Ben Dooks
2010-05-12  2:36 ` [PATCH 15/15] ARM: SAMSUNG: Update S3C2416 entry with S3C2450 Ben Dooks
2010-05-12  2:38 ` [PATCH 01/15] ARM: S3C: Add S3C2416 detection to uncompress code Ben Dooks
2010-05-12  7:25   ` Yauhen Kharuzhy

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=1273631766-15693-4-git-send-email-ben-linux@fluff.org \
    --to=ben-linux@fluff.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).