[PATCH v3 05/12] clk: samsung: exynos5433: Add clocks for CMU_G2D domain

2015-01-20 Thread Chanwoo Choi
This patch adds ths mux/divider/gate clocks of CMU_G2D domain which includes
G2D/MDMA IPs. The CMU_G2D must need the clocks related to G2D by providing
CMU_TOP domain. So, this patch add several clocks for G2D from CMU_TOP domain.

Cc: Sylwester Nawrocki 
Cc: Tomasz Figa 
Signed-off-by: Chanwoo Choi 
Acked-by: Inki Dae 
Reviewed-by: Pankaj Dubey 
---
 .../devicetree/bindings/clock/exynos5433-clock.txt |   8 ++
 drivers/clk/samsung/clk-exynos5433.c   | 146 +
 include/dt-bindings/clock/exynos5433.h |  42 +-
 3 files changed, 195 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/clock/exynos5433-clock.txt 
b/Documentation/devicetree/bindings/clock/exynos5433-clock.txt
index 72cd0ba..27dd77b 100644
--- a/Documentation/devicetree/bindings/clock/exynos5433-clock.txt
+++ b/Documentation/devicetree/bindings/clock/exynos5433-clock.txt
@@ -19,6 +19,8 @@ Required Properties:
 which generates clocks for PMU/TMU/MCT/WDT/RTC/SECKEY/TZPC IPs.
   - "samsung,exynos5433-cmu-fsys"  - clock controller compatible for CMU_FSYS
 which generates clocks for USB/UFS/SDMMC/TSI/PDMA IPs.
+  - "samsung,exynos5433-cmu-g2d"   - clock controller compatible for CMU_G2D
+which generates clocks for G2D/MDMA IPs.
 
 - reg: physical base address of the controller and length of memory mapped
   region.
@@ -70,6 +72,12 @@ Example 1: Examples of clock controller nodes are listed 
below.
#clock-cells = <1>;
};
 
+   cmu_g2d: clock-controller@0x1246 {
+   compatible = "samsung,exynos5433-cmu-g2d";
+   reg = <0x1246 0x0b08>;
+   #clock-cells = <1>;
+   };
+
 Example 2: UART controller node that consumes the clock generated by the clock
   controller.
 
diff --git a/drivers/clk/samsung/clk-exynos5433.c 
b/drivers/clk/samsung/clk-exynos5433.c
index 88e8651..9754c3d 100644
--- a/drivers/clk/samsung/clk-exynos5433.c
+++ b/drivers/clk/samsung/clk-exynos5433.c
@@ -398,6 +398,20 @@ static struct samsung_mux_clock top_mux_clks[] __initdata 
= {
 };
 
 static struct samsung_div_clock top_div_clks[] __initdata = {
+   /* DIV_TOP1 */
+   DIV(CLK_DIV_ACLK_GSCL_111, "div_aclk_gscl_111", "mout_aclk_gscl_333",
+   DIV_TOP1, 28, 3),
+   DIV(CLK_DIV_ACLK_GSCL_333, "div_aclk_gscl_333", "mout_aclk_gscl_333",
+   DIV_TOP1, 24, 3),
+   DIV(CLK_DIV_ACLK_HEVC_400, "div_aclk_hevc_400", "mout_aclk_hevc_400",
+   DIV_TOP1, 20, 3),
+   DIV(CLK_DIV_ACLK_MFC_400, "div_aclk_mfc_400", "mout_aclk_mfc_400_c",
+   DIV_TOP1, 12, 3),
+   DIV(CLK_DIV_ACLK_G2D_266, "div_aclk_g2d_266", "mout_bus_pll_user",
+   DIV_TOP1, 8, 3),
+   DIV(CLK_DIV_ACLK_G2D_400, "div_aclk_g2d_400", "mout_aclk_g2d_400_b",
+   DIV_TOP1, 0, 3),
+
/* DIV_TOP2 */
DIV(CLK_DIV_ACLK_FSYS_200, "div_aclk_fsys_200", "mout_bus_pll_user",
DIV_TOP2, 0, 3),
@@ -490,6 +504,12 @@ static struct samsung_gate_clock top_gate_clks[] 
__initdata = {
GATE(CLK_ACLK_FSYS_200, "aclk_fsys_200", "div_aclk_fsys_200",
ENABLE_ACLK_TOP, 18,
CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, 0),
+   GATE(CLK_ACLK_G2D_266, "aclk_g2d_266", "div_aclk_g2d_266",
+   ENABLE_ACLK_TOP, 2,
+   CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, 0),
+   GATE(CLK_ACLK_G2D_400, "aclk_g2d_400", "div_aclk_g2d_400",
+   ENABLE_ACLK_TOP, 0,
+   CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, 0),
 
/* ENABLE_SCLK_TOP_FSYS */
GATE(CLK_SCLK_MMC2_FSYS, "sclk_mmc2_fsys", "div_sclk_mmc2_b",
@@ -1277,3 +1297,129 @@ static void __init exynos5433_cmu_fsys_init(struct 
device_node *np)
 
 CLK_OF_DECLARE(exynos5433_cmu_fsys, "samsung,exynos5433-cmu-fsys",
exynos5433_cmu_fsys_init);
+
+/*
+ * Register offset definitions for CMU_G2D
+ */
+#define MUX_SEL_G2D0   0x0200
+#define MUX_SEL_ENABLE_G2D00x0300
+#define MUX_SEL_STAT_G2D0  0x0400
+#define DIV_G2D0x0600
+#define DIV_STAT_G2D   0x0700
+#define DIV_ENABLE_ACLK_G2D0x0800
+#define DIV_ENABLE_ACLK_G2D_SECURE_SMMU_G2D0x0804
+#define DIV_ENABLE_PCLK_G2D0x0900
+#define DIV_ENABLE_PCLK_G2D_SECURE_SMMU_G2D0x0904
+#define DIV_ENABLE_IP_G2D0 0x0b00
+#define DIV_ENABLE_IP_G2D1 0x0b04
+#define DIV_ENABLE_IP_G2D_SECURE_SMMU_G2D  0x0b08
+
+static unsigned long g2d_clk_regs[] __initdata = {
+   MUX_SEL_G2D0,
+   MUX_SEL_ENABLE_G2D0,
+   MUX_SEL_STAT_G2D0,
+   DIV_G2D,
+   DIV_STAT_G2D,
+   DIV_ENABLE_ACLK_G2D,
+   DIV_ENABLE_ACLK_G2D_SECURE_SMMU_G2D,
+   DIV_ENABLE_PCLK_G2D,
+   

[PATCH v3 05/12] clk: samsung: exynos5433: Add clocks for CMU_G2D domain

2015-01-20 Thread Chanwoo Choi
This patch adds ths mux/divider/gate clocks of CMU_G2D domain which includes
G2D/MDMA IPs. The CMU_G2D must need the clocks related to G2D by providing
CMU_TOP domain. So, this patch add several clocks for G2D from CMU_TOP domain.

Cc: Sylwester Nawrocki s.nawro...@samsung.com
Cc: Tomasz Figa tomasz.f...@gmail.com
Signed-off-by: Chanwoo Choi cw00.c...@samsung.com
Acked-by: Inki Dae inki@samsung.com
Reviewed-by: Pankaj Dubey pankaj.du...@samsung.com
---
 .../devicetree/bindings/clock/exynos5433-clock.txt |   8 ++
 drivers/clk/samsung/clk-exynos5433.c   | 146 +
 include/dt-bindings/clock/exynos5433.h |  42 +-
 3 files changed, 195 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/clock/exynos5433-clock.txt 
b/Documentation/devicetree/bindings/clock/exynos5433-clock.txt
index 72cd0ba..27dd77b 100644
--- a/Documentation/devicetree/bindings/clock/exynos5433-clock.txt
+++ b/Documentation/devicetree/bindings/clock/exynos5433-clock.txt
@@ -19,6 +19,8 @@ Required Properties:
 which generates clocks for PMU/TMU/MCT/WDT/RTC/SECKEY/TZPC IPs.
   - samsung,exynos5433-cmu-fsys  - clock controller compatible for CMU_FSYS
 which generates clocks for USB/UFS/SDMMC/TSI/PDMA IPs.
+  - samsung,exynos5433-cmu-g2d   - clock controller compatible for CMU_G2D
+which generates clocks for G2D/MDMA IPs.
 
 - reg: physical base address of the controller and length of memory mapped
   region.
@@ -70,6 +72,12 @@ Example 1: Examples of clock controller nodes are listed 
below.
#clock-cells = 1;
};
 
+   cmu_g2d: clock-controller@0x1246 {
+   compatible = samsung,exynos5433-cmu-g2d;
+   reg = 0x1246 0x0b08;
+   #clock-cells = 1;
+   };
+
 Example 2: UART controller node that consumes the clock generated by the clock
   controller.
 
diff --git a/drivers/clk/samsung/clk-exynos5433.c 
b/drivers/clk/samsung/clk-exynos5433.c
index 88e8651..9754c3d 100644
--- a/drivers/clk/samsung/clk-exynos5433.c
+++ b/drivers/clk/samsung/clk-exynos5433.c
@@ -398,6 +398,20 @@ static struct samsung_mux_clock top_mux_clks[] __initdata 
= {
 };
 
 static struct samsung_div_clock top_div_clks[] __initdata = {
+   /* DIV_TOP1 */
+   DIV(CLK_DIV_ACLK_GSCL_111, div_aclk_gscl_111, mout_aclk_gscl_333,
+   DIV_TOP1, 28, 3),
+   DIV(CLK_DIV_ACLK_GSCL_333, div_aclk_gscl_333, mout_aclk_gscl_333,
+   DIV_TOP1, 24, 3),
+   DIV(CLK_DIV_ACLK_HEVC_400, div_aclk_hevc_400, mout_aclk_hevc_400,
+   DIV_TOP1, 20, 3),
+   DIV(CLK_DIV_ACLK_MFC_400, div_aclk_mfc_400, mout_aclk_mfc_400_c,
+   DIV_TOP1, 12, 3),
+   DIV(CLK_DIV_ACLK_G2D_266, div_aclk_g2d_266, mout_bus_pll_user,
+   DIV_TOP1, 8, 3),
+   DIV(CLK_DIV_ACLK_G2D_400, div_aclk_g2d_400, mout_aclk_g2d_400_b,
+   DIV_TOP1, 0, 3),
+
/* DIV_TOP2 */
DIV(CLK_DIV_ACLK_FSYS_200, div_aclk_fsys_200, mout_bus_pll_user,
DIV_TOP2, 0, 3),
@@ -490,6 +504,12 @@ static struct samsung_gate_clock top_gate_clks[] 
__initdata = {
GATE(CLK_ACLK_FSYS_200, aclk_fsys_200, div_aclk_fsys_200,
ENABLE_ACLK_TOP, 18,
CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, 0),
+   GATE(CLK_ACLK_G2D_266, aclk_g2d_266, div_aclk_g2d_266,
+   ENABLE_ACLK_TOP, 2,
+   CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, 0),
+   GATE(CLK_ACLK_G2D_400, aclk_g2d_400, div_aclk_g2d_400,
+   ENABLE_ACLK_TOP, 0,
+   CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED, 0),
 
/* ENABLE_SCLK_TOP_FSYS */
GATE(CLK_SCLK_MMC2_FSYS, sclk_mmc2_fsys, div_sclk_mmc2_b,
@@ -1277,3 +1297,129 @@ static void __init exynos5433_cmu_fsys_init(struct 
device_node *np)
 
 CLK_OF_DECLARE(exynos5433_cmu_fsys, samsung,exynos5433-cmu-fsys,
exynos5433_cmu_fsys_init);
+
+/*
+ * Register offset definitions for CMU_G2D
+ */
+#define MUX_SEL_G2D0   0x0200
+#define MUX_SEL_ENABLE_G2D00x0300
+#define MUX_SEL_STAT_G2D0  0x0400
+#define DIV_G2D0x0600
+#define DIV_STAT_G2D   0x0700
+#define DIV_ENABLE_ACLK_G2D0x0800
+#define DIV_ENABLE_ACLK_G2D_SECURE_SMMU_G2D0x0804
+#define DIV_ENABLE_PCLK_G2D0x0900
+#define DIV_ENABLE_PCLK_G2D_SECURE_SMMU_G2D0x0904
+#define DIV_ENABLE_IP_G2D0 0x0b00
+#define DIV_ENABLE_IP_G2D1 0x0b04
+#define DIV_ENABLE_IP_G2D_SECURE_SMMU_G2D  0x0b08
+
+static unsigned long g2d_clk_regs[] __initdata = {
+   MUX_SEL_G2D0,
+   MUX_SEL_ENABLE_G2D0,
+   MUX_SEL_STAT_G2D0,
+   DIV_G2D,
+   DIV_STAT_G2D,
+   DIV_ENABLE_ACLK_G2D,
+