[PATCH 09/12] clk: mmp: add pxa910 DT support for clock driver

2014-08-25 Thread Chao Xie
From: Chao Xie 

It adds the DT support for pxa910 clock subsystem.

Signed-off-by: Chao Xie 
---
 .../bindings/clock/marvell-pxa910-clock.txt|  20 ++
 drivers/clk/mmp/Makefile   |   2 +-
 drivers/clk/mmp/clk-of-pxa910.c| 260 +
 include/dt-bindings/clock/marvell-pxa910.h |  54 +
 4 files changed, 335 insertions(+), 1 deletion(-)
 create mode 100644 
Documentation/devicetree/bindings/clock/marvell-pxa910-clock.txt
 create mode 100644 drivers/clk/mmp/clk-of-pxa910.c
 create mode 100644 include/dt-bindings/clock/marvell-pxa910.h

diff --git a/Documentation/devicetree/bindings/clock/marvell-pxa910-clock.txt 
b/Documentation/devicetree/bindings/clock/marvell-pxa910-clock.txt
new file mode 100644
index 000..643b57b0
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/marvell-pxa910-clock.txt
@@ -0,0 +1,20 @@
+* Marvell PXA910 Clock Controller
+
+The PXA910 clock subsystem generates and supplies clock to various
+controllers within the PXA910 SoC.
+
+Required Properties:
+
+- compatible: should be one of the following.
+  - "marvell,pxa910-clock" - controller compatible with PXA910 SoC.
+
+- reg: physical base address of the clock subsystem and length of memory mapped
+  region. There are 4 places in SOC has clock control logic:
+  "mpmu", "apmu", "apbc", "apbcp". So four reg spaces need to be defined.
+
+- #clock-cells: should be 1.
+
+Each clock is assigned an identifier and client nodes use this identifier
+to specify the clock which they consume.
+
+All these identifier could be found in .
diff --git a/drivers/clk/mmp/Makefile b/drivers/clk/mmp/Makefile
index 37c14fa..b803fac 100644
--- a/drivers/clk/mmp/Makefile
+++ b/drivers/clk/mmp/Makefile
@@ -4,7 +4,7 @@
 
 obj-y += clk-apbc.o clk-apmu.o clk-frac.o clk-mix.o clk-gate.o clk.o
 
-obj-$(CONFIG_MACH_MMP_DT) += clk-of-pxa168.o
+obj-$(CONFIG_MACH_MMP_DT) += clk-of-pxa168.o clk-of-pxa910.o
 
 obj-$(CONFIG_CPU_PXA168) += clk-pxa168.o
 obj-$(CONFIG_CPU_PXA910) += clk-pxa910.o
diff --git a/drivers/clk/mmp/clk-of-pxa910.c b/drivers/clk/mmp/clk-of-pxa910.c
new file mode 100644
index 000..f746376
--- /dev/null
+++ b/drivers/clk/mmp/clk-of-pxa910.c
@@ -0,0 +1,260 @@
+/*
+ * pxa910 clock framework source file
+ *
+ * Copyright (C) 2012 Marvell
+ * Chao Xie 
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "clk.h"
+
+#define APBC_RTC   0x28
+#define APBC_TWSI0 0x2c
+#define APBC_KPC   0x18
+#define APBC_UART0 0x0
+#define APBC_UART1 0x4
+#define APBC_GPIO  0x8
+#define APBC_PWM0  0xc
+#define APBC_PWM1  0x10
+#define APBC_PWM2  0x14
+#define APBC_PWM3  0x18
+#define APBC_SSP0  0x1c
+#define APBC_SSP1  0x20
+#define APBC_SSP2  0x4c
+#define APBCP_TWSI10x28
+#define APBCP_UART20x1c
+#define APMU_SDH0  0x54
+#define APMU_SDH1  0x58
+#define APMU_USB   0x5c
+#define APMU_DISP0 0x4c
+#define APMU_CCIC0 0x50
+#define APMU_DFC   0x60
+#define MPMU_UART_PLL  0x14
+
+struct pxa910_clk_unit {
+   struct mmp_clk_unit unit;
+   void __iomem *mpmu_base;
+   void __iomem *apmu_base;
+   void __iomem *apbc_base;
+   void __iomem *apbcp_base;
+};
+
+static struct mmp_param_fixed_rate_clk fixed_rate_clks[] = {
+   {PXA910_CLK_CLK32, "clk32", NULL, CLK_IS_ROOT, 32768},
+   {PXA910_CLK_VCTCXO, "vctcxo", NULL, CLK_IS_ROOT, 2600},
+   {PXA910_CLK_PLL1, "pll1", NULL, CLK_IS_ROOT, 62400},
+};
+
+static struct mmp_param_fixed_factor_clk fixed_factor_clks[] = {
+   {PXA910_CLK_PLL1_2, "pll1_2", "pll1", 1, 2, 0},
+   {PXA910_CLK_PLL1_4, "pll1_4", "pll1_2", 1, 2, 0},
+   {PXA910_CLK_PLL1_8, "pll1_8", "pll1_4", 1, 2, 0},
+   {PXA910_CLK_PLL1_16, "pll1_16", "pll1_8", 1, 2, 0},
+   {PXA910_CLK_PLL1_6, "pll1_6", "pll1_2", 1, 3, 0},
+   {PXA910_CLK_PLL1_12, "pll1_12", "pll1_6", 1, 2, 0},
+   {PXA910_CLK_PLL1_24, "pll1_24", "pll1_12", 1, 2, 0},
+   {PXA910_CLK_PLL1_48, "pll1_48", "pll1_24", 1, 2, 0},
+   {PXA910_CLK_PLL1_96, "pll1_96", "pll1_48", 1, 2, 0},
+   {PXA910_CLK_PLL1_13, "pll1_13", "pll1", 1, 13, 0},
+   {PXA910_CLK_PLL1_13_1_5, "pll1_13_1_5", "pll1_13", 2, 3, 0},
+   {PXA910_CLK_PLL1_2_1_5, "pll1_2_1_5", "pll1_2", 2, 3, 0},
+   {PXA910_CLK_PLL1_3_16, "pll1_3_16", "pll1", 3, 16, 0},
+};
+
+static struct mmp_clk_factor_masks uart_factor_masks = {
+   .factor = 2,
+   .num_mask = 0x1fff,
+   .den_mask = 0x1fff,
+   .num_shift = 16,
+   .den_shift = 0,
+};
+
+static struct mmp_clk_factor_tbl uart_factor_tbl[] = {
+   {.num = 8125, .den = 1536}, /*14.745MHZ */
+};
+
+static void pxa910_pll_init(struct pxa910_clk_unit *pxa_unit)
+{
+   struct 

[PATCH 09/12] clk: mmp: add pxa910 DT support for clock driver

2014-08-25 Thread Chao Xie
From: Chao Xie chao@marvell.com

It adds the DT support for pxa910 clock subsystem.

Signed-off-by: Chao Xie chao@marvell.com
---
 .../bindings/clock/marvell-pxa910-clock.txt|  20 ++
 drivers/clk/mmp/Makefile   |   2 +-
 drivers/clk/mmp/clk-of-pxa910.c| 260 +
 include/dt-bindings/clock/marvell-pxa910.h |  54 +
 4 files changed, 335 insertions(+), 1 deletion(-)
 create mode 100644 
Documentation/devicetree/bindings/clock/marvell-pxa910-clock.txt
 create mode 100644 drivers/clk/mmp/clk-of-pxa910.c
 create mode 100644 include/dt-bindings/clock/marvell-pxa910.h

diff --git a/Documentation/devicetree/bindings/clock/marvell-pxa910-clock.txt 
b/Documentation/devicetree/bindings/clock/marvell-pxa910-clock.txt
new file mode 100644
index 000..643b57b0
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/marvell-pxa910-clock.txt
@@ -0,0 +1,20 @@
+* Marvell PXA910 Clock Controller
+
+The PXA910 clock subsystem generates and supplies clock to various
+controllers within the PXA910 SoC.
+
+Required Properties:
+
+- compatible: should be one of the following.
+  - marvell,pxa910-clock - controller compatible with PXA910 SoC.
+
+- reg: physical base address of the clock subsystem and length of memory mapped
+  region. There are 4 places in SOC has clock control logic:
+  mpmu, apmu, apbc, apbcp. So four reg spaces need to be defined.
+
+- #clock-cells: should be 1.
+
+Each clock is assigned an identifier and client nodes use this identifier
+to specify the clock which they consume.
+
+All these identifier could be found in dt-bindings/clock/marvell-pxa910.h.
diff --git a/drivers/clk/mmp/Makefile b/drivers/clk/mmp/Makefile
index 37c14fa..b803fac 100644
--- a/drivers/clk/mmp/Makefile
+++ b/drivers/clk/mmp/Makefile
@@ -4,7 +4,7 @@
 
 obj-y += clk-apbc.o clk-apmu.o clk-frac.o clk-mix.o clk-gate.o clk.o
 
-obj-$(CONFIG_MACH_MMP_DT) += clk-of-pxa168.o
+obj-$(CONFIG_MACH_MMP_DT) += clk-of-pxa168.o clk-of-pxa910.o
 
 obj-$(CONFIG_CPU_PXA168) += clk-pxa168.o
 obj-$(CONFIG_CPU_PXA910) += clk-pxa910.o
diff --git a/drivers/clk/mmp/clk-of-pxa910.c b/drivers/clk/mmp/clk-of-pxa910.c
new file mode 100644
index 000..f746376
--- /dev/null
+++ b/drivers/clk/mmp/clk-of-pxa910.c
@@ -0,0 +1,260 @@
+/*
+ * pxa910 clock framework source file
+ *
+ * Copyright (C) 2012 Marvell
+ * Chao Xie xiechao.m...@gmail.com
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed as is without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include linux/module.h
+#include linux/kernel.h
+#include linux/spinlock.h
+#include linux/io.h
+#include linux/delay.h
+#include linux/err.h
+#include linux/of_address.h
+
+#include dt-bindings/clock/marvell-pxa910.h
+
+#include clk.h
+
+#define APBC_RTC   0x28
+#define APBC_TWSI0 0x2c
+#define APBC_KPC   0x18
+#define APBC_UART0 0x0
+#define APBC_UART1 0x4
+#define APBC_GPIO  0x8
+#define APBC_PWM0  0xc
+#define APBC_PWM1  0x10
+#define APBC_PWM2  0x14
+#define APBC_PWM3  0x18
+#define APBC_SSP0  0x1c
+#define APBC_SSP1  0x20
+#define APBC_SSP2  0x4c
+#define APBCP_TWSI10x28
+#define APBCP_UART20x1c
+#define APMU_SDH0  0x54
+#define APMU_SDH1  0x58
+#define APMU_USB   0x5c
+#define APMU_DISP0 0x4c
+#define APMU_CCIC0 0x50
+#define APMU_DFC   0x60
+#define MPMU_UART_PLL  0x14
+
+struct pxa910_clk_unit {
+   struct mmp_clk_unit unit;
+   void __iomem *mpmu_base;
+   void __iomem *apmu_base;
+   void __iomem *apbc_base;
+   void __iomem *apbcp_base;
+};
+
+static struct mmp_param_fixed_rate_clk fixed_rate_clks[] = {
+   {PXA910_CLK_CLK32, clk32, NULL, CLK_IS_ROOT, 32768},
+   {PXA910_CLK_VCTCXO, vctcxo, NULL, CLK_IS_ROOT, 2600},
+   {PXA910_CLK_PLL1, pll1, NULL, CLK_IS_ROOT, 62400},
+};
+
+static struct mmp_param_fixed_factor_clk fixed_factor_clks[] = {
+   {PXA910_CLK_PLL1_2, pll1_2, pll1, 1, 2, 0},
+   {PXA910_CLK_PLL1_4, pll1_4, pll1_2, 1, 2, 0},
+   {PXA910_CLK_PLL1_8, pll1_8, pll1_4, 1, 2, 0},
+   {PXA910_CLK_PLL1_16, pll1_16, pll1_8, 1, 2, 0},
+   {PXA910_CLK_PLL1_6, pll1_6, pll1_2, 1, 3, 0},
+   {PXA910_CLK_PLL1_12, pll1_12, pll1_6, 1, 2, 0},
+   {PXA910_CLK_PLL1_24, pll1_24, pll1_12, 1, 2, 0},
+   {PXA910_CLK_PLL1_48, pll1_48, pll1_24, 1, 2, 0},
+   {PXA910_CLK_PLL1_96, pll1_96, pll1_48, 1, 2, 0},
+   {PXA910_CLK_PLL1_13, pll1_13, pll1, 1, 13, 0},
+   {PXA910_CLK_PLL1_13_1_5, pll1_13_1_5, pll1_13, 2, 3, 0},
+   {PXA910_CLK_PLL1_2_1_5, pll1_2_1_5, pll1_2, 2, 3, 0},
+   {PXA910_CLK_PLL1_3_16, pll1_3_16, pll1, 3, 16, 0},
+};
+
+static struct mmp_clk_factor_masks uart_factor_masks = {
+   .factor = 2,
+   .num_mask = 0x1fff,
+   .den_mask = 0x1fff,
+   .num_shift = 16,
+   .den_shift = 0,
+};
+
+static struct mmp_clk_factor_tbl