Re: [PATCH v2 1/3] clk: samsung: exynos3250: Register DMC clk provider

2014-09-22 Thread Tomasz Figa
On 02.09.2014 15:21, Krzysztof Kozlowski wrote:
> Add clock provider for clocks in DMC domain including EPLL and BPLL. The
> DMC clocks are necessary for Exynos3 devfreq driver.
> 
> The DMC clock domain uses different address space (0x105C) than
> standard clock domain (0x1003 - 0x1005). The difference is huge
> enough to add new DT node for the clock provider, rather than extending
> existing address space.
> 
> Signed-off-by: Krzysztof Kozlowski 
> 
> ---
> 
> Changes since v1:
> =
> 1. Fix overwritteing main clock provider reg_base with DMC clock domain
>reg_basr. This leads to OOPS in suspend.

Applied the whole series for next.

Best regards,
Tomasz
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 1/3] clk: samsung: exynos3250: Register DMC clk provider

2014-09-22 Thread Tomasz Figa
On 02.09.2014 15:21, Krzysztof Kozlowski wrote:
 Add clock provider for clocks in DMC domain including EPLL and BPLL. The
 DMC clocks are necessary for Exynos3 devfreq driver.
 
 The DMC clock domain uses different address space (0x105C) than
 standard clock domain (0x1003 - 0x1005). The difference is huge
 enough to add new DT node for the clock provider, rather than extending
 existing address space.
 
 Signed-off-by: Krzysztof Kozlowski k.kozlow...@samsung.com
 
 ---
 
 Changes since v1:
 =
 1. Fix overwritteing main clock provider reg_base with DMC clock domain
reg_basr. This leads to OOPS in suspend.

Applied the whole series for next.

Best regards,
Tomasz
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2 1/3] clk: samsung: exynos3250: Register DMC clk provider

2014-09-02 Thread Krzysztof Kozlowski
Add clock provider for clocks in DMC domain including EPLL and BPLL. The
DMC clocks are necessary for Exynos3 devfreq driver.

The DMC clock domain uses different address space (0x105C) than
standard clock domain (0x1003 - 0x1005). The difference is huge
enough to add new DT node for the clock provider, rather than extending
existing address space.

Signed-off-by: Krzysztof Kozlowski 

---

Changes since v1:
=
1. Fix overwritteing main clock provider reg_base with DMC clock domain
   reg_basr. This leads to OOPS in suspend.
---
 drivers/clk/samsung/clk-exynos3250.c   | 195 +
 include/dt-bindings/clock/exynos3250.h |  27 +
 2 files changed, 222 insertions(+)

diff --git a/drivers/clk/samsung/clk-exynos3250.c 
b/drivers/clk/samsung/clk-exynos3250.c
index dc85f8e7a2d7..6840dc71c72b 100644
--- a/drivers/clk/samsung/clk-exynos3250.c
+++ b/drivers/clk/samsung/clk-exynos3250.c
@@ -110,7 +110,14 @@ enum exynos3250_plls {
nr_plls
 };
 
+/* list of PLLs in DMC block to be registered */
+enum exynos3250_dmc_plls {
+   bpll, epll,
+   nr_dmc_plls
+};
+
 static void __iomem *reg_base;
+static void __iomem *dmc_reg_base;
 
 /*
  * Support for CMU save/restore across system suspends
@@ -724,6 +731,25 @@ static struct samsung_pll_rate_table 
exynos3250_pll_rates[] = {
{ /* sentinel */ }
 };
 
+/* EPLL */
+static struct samsung_pll_rate_table exynos3250_epll_rates[] = {
+   PLL_36XX_RATE(8, 200, 3, 1, 0),
+   PLL_36XX_RATE(28800,  96, 2, 2, 0),
+   PLL_36XX_RATE(19200, 128, 2, 3, 0),
+   PLL_36XX_RATE(14400,  96, 2, 3, 0),
+   PLL_36XX_RATE( 9600, 128, 2, 4, 0),
+   PLL_36XX_RATE( 8400, 112, 2, 4, 0),
+   PLL_36XX_RATE( 8004, 106, 2, 4, 43691),
+   PLL_36XX_RATE( 73728000,  98, 2, 4, 19923),
+   PLL_36XX_RATE( 67737598, 270, 3, 5, 62285),
+   PLL_36XX_RATE( 65535999, 174, 2, 5, 49982),
+   PLL_36XX_RATE( 5000, 200, 3, 5, 0),
+   PLL_36XX_RATE( 49152002, 131, 2, 5,  4719),
+   PLL_36XX_RATE( 4800, 128, 2, 5, 0),
+   PLL_36XX_RATE( 45158401, 180, 3, 5, 41524),
+   { /* sentinel */ }
+};
+
 /* VPLL */
 static struct samsung_pll_rate_table exynos3250_vpll_rates[] = {
PLL_36XX_RATE(6, 100, 2, 1, 0),
@@ -821,3 +847,172 @@ static void __init exynos3250_cmu_init(struct device_node 
*np)
samsung_clk_of_add_provider(np, ctx);
 }
 CLK_OF_DECLARE(exynos3250_cmu, "samsung,exynos3250-cmu", exynos3250_cmu_init);
+
+/*
+ * CMU DMC
+ */
+
+#define BPLL_LOCK  0x0118
+#define BPLL_CON0  0x0218
+#define BPLL_CON1  0x021c
+#define BPLL_CON2  0x0220
+#define SRC_DMC0x0300
+#define DIV_DMC1   0x0504
+#define GATE_BUS_DMC0  0x0700
+#define GATE_BUS_DMC1  0x0704
+#define GATE_BUS_DMC2  0x0708
+#define GATE_BUS_DMC3  0x070c
+#define GATE_SCLK_DMC  0x0800
+#define GATE_IP_DMC0   0x0900
+#define GATE_IP_DMC1   0x0904
+#define EPLL_LOCK  0x1110
+#define EPLL_CON0  0x1114
+#define EPLL_CON1  0x1118
+#define EPLL_CON2  0x111c
+#define SRC_EPLL   0x1120
+
+/*
+ * Support for CMU save/restore across system suspends
+ */
+#ifdef CONFIG_PM_SLEEP
+static struct samsung_clk_reg_dump *exynos3250_dmc_clk_regs;
+
+static unsigned long exynos3250_cmu_dmc_clk_regs[] __initdata = {
+   BPLL_LOCK,
+   BPLL_CON0,
+   BPLL_CON1,
+   BPLL_CON2,
+   SRC_DMC,
+   DIV_DMC1,
+   GATE_BUS_DMC0,
+   GATE_BUS_DMC1,
+   GATE_BUS_DMC2,
+   GATE_BUS_DMC3,
+   GATE_SCLK_DMC,
+   GATE_IP_DMC0,
+   GATE_IP_DMC1,
+   EPLL_LOCK,
+   EPLL_CON0,
+   EPLL_CON1,
+   EPLL_CON2,
+   SRC_EPLL,
+};
+
+static int exynos3250_dmc_clk_suspend(void)
+{
+   samsung_clk_save(dmc_reg_base, exynos3250_dmc_clk_regs,
+   ARRAY_SIZE(exynos3250_cmu_dmc_clk_regs));
+   return 0;
+}
+
+static void exynos3250_dmc_clk_resume(void)
+{
+   samsung_clk_restore(dmc_reg_base, exynos3250_dmc_clk_regs,
+   ARRAY_SIZE(exynos3250_cmu_dmc_clk_regs));
+}
+
+static struct syscore_ops exynos3250_dmc_clk_syscore_ops = {
+   .suspend = exynos3250_dmc_clk_suspend,
+   .resume = exynos3250_dmc_clk_resume,
+};
+
+static void exynos3250_dmc_clk_sleep_init(void)
+{
+   exynos3250_dmc_clk_regs =
+   samsung_clk_alloc_reg_dump(exynos3250_cmu_dmc_clk_regs,
+  ARRAY_SIZE(exynos3250_cmu_dmc_clk_regs));
+   if (!exynos3250_dmc_clk_regs) {
+   pr_warn("%s: Failed to allocate sleep save data\n", __func__);
+   goto err;
+   }
+
+   register_syscore_ops(_dmc_clk_syscore_ops);
+   return;
+err:
+   kfree(exynos3250_dmc_clk_regs);
+}
+#else
+static inline void 

[PATCH v2 1/3] clk: samsung: exynos3250: Register DMC clk provider

2014-09-02 Thread Krzysztof Kozlowski
Add clock provider for clocks in DMC domain including EPLL and BPLL. The
DMC clocks are necessary for Exynos3 devfreq driver.

The DMC clock domain uses different address space (0x105C) than
standard clock domain (0x1003 - 0x1005). The difference is huge
enough to add new DT node for the clock provider, rather than extending
existing address space.

Signed-off-by: Krzysztof Kozlowski k.kozlow...@samsung.com

---

Changes since v1:
=
1. Fix overwritteing main clock provider reg_base with DMC clock domain
   reg_basr. This leads to OOPS in suspend.
---
 drivers/clk/samsung/clk-exynos3250.c   | 195 +
 include/dt-bindings/clock/exynos3250.h |  27 +
 2 files changed, 222 insertions(+)

diff --git a/drivers/clk/samsung/clk-exynos3250.c 
b/drivers/clk/samsung/clk-exynos3250.c
index dc85f8e7a2d7..6840dc71c72b 100644
--- a/drivers/clk/samsung/clk-exynos3250.c
+++ b/drivers/clk/samsung/clk-exynos3250.c
@@ -110,7 +110,14 @@ enum exynos3250_plls {
nr_plls
 };
 
+/* list of PLLs in DMC block to be registered */
+enum exynos3250_dmc_plls {
+   bpll, epll,
+   nr_dmc_plls
+};
+
 static void __iomem *reg_base;
+static void __iomem *dmc_reg_base;
 
 /*
  * Support for CMU save/restore across system suspends
@@ -724,6 +731,25 @@ static struct samsung_pll_rate_table 
exynos3250_pll_rates[] = {
{ /* sentinel */ }
 };
 
+/* EPLL */
+static struct samsung_pll_rate_table exynos3250_epll_rates[] = {
+   PLL_36XX_RATE(8, 200, 3, 1, 0),
+   PLL_36XX_RATE(28800,  96, 2, 2, 0),
+   PLL_36XX_RATE(19200, 128, 2, 3, 0),
+   PLL_36XX_RATE(14400,  96, 2, 3, 0),
+   PLL_36XX_RATE( 9600, 128, 2, 4, 0),
+   PLL_36XX_RATE( 8400, 112, 2, 4, 0),
+   PLL_36XX_RATE( 8004, 106, 2, 4, 43691),
+   PLL_36XX_RATE( 73728000,  98, 2, 4, 19923),
+   PLL_36XX_RATE( 67737598, 270, 3, 5, 62285),
+   PLL_36XX_RATE( 65535999, 174, 2, 5, 49982),
+   PLL_36XX_RATE( 5000, 200, 3, 5, 0),
+   PLL_36XX_RATE( 49152002, 131, 2, 5,  4719),
+   PLL_36XX_RATE( 4800, 128, 2, 5, 0),
+   PLL_36XX_RATE( 45158401, 180, 3, 5, 41524),
+   { /* sentinel */ }
+};
+
 /* VPLL */
 static struct samsung_pll_rate_table exynos3250_vpll_rates[] = {
PLL_36XX_RATE(6, 100, 2, 1, 0),
@@ -821,3 +847,172 @@ static void __init exynos3250_cmu_init(struct device_node 
*np)
samsung_clk_of_add_provider(np, ctx);
 }
 CLK_OF_DECLARE(exynos3250_cmu, samsung,exynos3250-cmu, exynos3250_cmu_init);
+
+/*
+ * CMU DMC
+ */
+
+#define BPLL_LOCK  0x0118
+#define BPLL_CON0  0x0218
+#define BPLL_CON1  0x021c
+#define BPLL_CON2  0x0220
+#define SRC_DMC0x0300
+#define DIV_DMC1   0x0504
+#define GATE_BUS_DMC0  0x0700
+#define GATE_BUS_DMC1  0x0704
+#define GATE_BUS_DMC2  0x0708
+#define GATE_BUS_DMC3  0x070c
+#define GATE_SCLK_DMC  0x0800
+#define GATE_IP_DMC0   0x0900
+#define GATE_IP_DMC1   0x0904
+#define EPLL_LOCK  0x1110
+#define EPLL_CON0  0x1114
+#define EPLL_CON1  0x1118
+#define EPLL_CON2  0x111c
+#define SRC_EPLL   0x1120
+
+/*
+ * Support for CMU save/restore across system suspends
+ */
+#ifdef CONFIG_PM_SLEEP
+static struct samsung_clk_reg_dump *exynos3250_dmc_clk_regs;
+
+static unsigned long exynos3250_cmu_dmc_clk_regs[] __initdata = {
+   BPLL_LOCK,
+   BPLL_CON0,
+   BPLL_CON1,
+   BPLL_CON2,
+   SRC_DMC,
+   DIV_DMC1,
+   GATE_BUS_DMC0,
+   GATE_BUS_DMC1,
+   GATE_BUS_DMC2,
+   GATE_BUS_DMC3,
+   GATE_SCLK_DMC,
+   GATE_IP_DMC0,
+   GATE_IP_DMC1,
+   EPLL_LOCK,
+   EPLL_CON0,
+   EPLL_CON1,
+   EPLL_CON2,
+   SRC_EPLL,
+};
+
+static int exynos3250_dmc_clk_suspend(void)
+{
+   samsung_clk_save(dmc_reg_base, exynos3250_dmc_clk_regs,
+   ARRAY_SIZE(exynos3250_cmu_dmc_clk_regs));
+   return 0;
+}
+
+static void exynos3250_dmc_clk_resume(void)
+{
+   samsung_clk_restore(dmc_reg_base, exynos3250_dmc_clk_regs,
+   ARRAY_SIZE(exynos3250_cmu_dmc_clk_regs));
+}
+
+static struct syscore_ops exynos3250_dmc_clk_syscore_ops = {
+   .suspend = exynos3250_dmc_clk_suspend,
+   .resume = exynos3250_dmc_clk_resume,
+};
+
+static void exynos3250_dmc_clk_sleep_init(void)
+{
+   exynos3250_dmc_clk_regs =
+   samsung_clk_alloc_reg_dump(exynos3250_cmu_dmc_clk_regs,
+  ARRAY_SIZE(exynos3250_cmu_dmc_clk_regs));
+   if (!exynos3250_dmc_clk_regs) {
+   pr_warn(%s: Failed to allocate sleep save data\n, __func__);
+   goto err;
+   }
+
+   register_syscore_ops(exynos3250_dmc_clk_syscore_ops);
+   return;
+err:
+   kfree(exynos3250_dmc_clk_regs);
+}