Re: [PATCH v3] clk: qcom: Add camera clock controller driver for SDM845

2018-08-30 Thread Stephen Boyd
Quoting Amit Nischal (2018-08-08 03:47:19)
> Add support for the camera clock controller found on SDM845
> based devices. This would allow camera drivers to probe and
> control their clocks.
> 
> Signed-off-by: Amit Nischal 
> ---

Applied to clk-next



Re: [PATCH v3] clk: qcom: Add camera clock controller driver for SDM845

2018-08-30 Thread Stephen Boyd
Quoting Amit Nischal (2018-08-08 03:47:19)
> Add support for the camera clock controller found on SDM845
> based devices. This would allow camera drivers to probe and
> control their clocks.
> 
> Signed-off-by: Amit Nischal 
> ---

Applied to clk-next



[PATCH v3] clk: qcom: Add camera clock controller driver for SDM845

2018-08-08 Thread Amit Nischal
Add support for the camera clock controller found on SDM845
based devices. This would allow camera drivers to probe and
control their clocks.

Signed-off-by: Amit Nischal 
---
 drivers/clk/qcom/Kconfig|8 +
 drivers/clk/qcom/Makefile   |1 +
 drivers/clk/qcom/camcc-sdm845.c | 1745 +++
 3 files changed, 1754 insertions(+)
 create mode 100644 drivers/clk/qcom/camcc-sdm845.c

diff --git a/drivers/clk/qcom/Kconfig b/drivers/clk/qcom/Kconfig
index 1595464..f551432 100644
--- a/drivers/clk/qcom/Kconfig
+++ b/drivers/clk/qcom/Kconfig
@@ -235,6 +235,14 @@ config MSM_GCC_8998
  Say Y if you want to use peripheral devices such as UART, SPI,
  i2c, USB, UFS, SD/eMMC, PCIe, etc.

+config SDM_CAMCC_845
+   tristate "SDM845 Camera Clock Controller"
+   depends on COMMON_CLK_QCOM
+   select SDM_GCC_845
+   help
+ Support for the camera clock controller on SDM845 devices.
+ Say Y if you want to support camera devices and camera functionality.
+
 config SDM_GCC_845
tristate "SDM845 Global Clock Controller"
select QCOM_GDSC
diff --git a/drivers/clk/qcom/Makefile b/drivers/clk/qcom/Makefile
index 93c1089..ada8750 100644
--- a/drivers/clk/qcom/Makefile
+++ b/drivers/clk/qcom/Makefile
@@ -41,6 +41,7 @@ obj-$(CONFIG_QCOM_CLK_RPM) += clk-rpm.o
 obj-$(CONFIG_QCOM_CLK_RPMH) += clk-rpmh.o
 obj-$(CONFIG_QCOM_CLK_SMD_RPM) += clk-smd-rpm.o
 obj-$(CONFIG_SDM_DISPCC_845) += dispcc-sdm845.o
+obj-$(CONFIG_SDM_CAMCC_845) += camcc-sdm845.o
 obj-$(CONFIG_SDM_GCC_845) += gcc-sdm845.o
 obj-$(CONFIG_SDM_GPUCC_845) += gpucc-sdm845.o
 obj-$(CONFIG_SDM_VIDEOCC_845) += videocc-sdm845.o
diff --git a/drivers/clk/qcom/camcc-sdm845.c b/drivers/clk/qcom/camcc-sdm845.c
new file mode 100644
index 000..1b2cefe
--- /dev/null
+++ b/drivers/clk/qcom/camcc-sdm845.c
@@ -0,0 +1,1745 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "common.h"
+#include "clk-alpha-pll.h"
+#include "clk-branch.h"
+#include "clk-rcg.h"
+#include "clk-regmap.h"
+#include "gdsc.h"
+
+enum {
+   P_BI_TCXO,
+   P_CAM_CC_PLL0_OUT_EVEN,
+   P_CAM_CC_PLL1_OUT_EVEN,
+   P_CAM_CC_PLL2_OUT_EVEN,
+   P_CAM_CC_PLL3_OUT_EVEN,
+   P_CORE_BI_PLL_TEST_SE,
+};
+
+static const struct parent_map cam_cc_parent_map_0[] = {
+   { P_BI_TCXO, 0 },
+   { P_CAM_CC_PLL2_OUT_EVEN, 1 },
+   { P_CAM_CC_PLL1_OUT_EVEN, 2 },
+   { P_CAM_CC_PLL3_OUT_EVEN, 5 },
+   { P_CAM_CC_PLL0_OUT_EVEN, 6 },
+   { P_CORE_BI_PLL_TEST_SE, 7 },
+};
+
+static const char * const cam_cc_parent_names_0[] = {
+   "bi_tcxo",
+   "cam_cc_pll2_out_even",
+   "cam_cc_pll1_out_even",
+   "cam_cc_pll3_out_even",
+   "cam_cc_pll0_out_even",
+   "core_bi_pll_test_se",
+};
+
+static struct clk_alpha_pll cam_cc_pll0 = {
+   .offset = 0x0,
+   .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA],
+   .clkr = {
+   .hw.init = &(struct clk_init_data){
+   .name = "cam_cc_pll0",
+   .parent_names = (const char *[]){ "bi_tcxo" },
+   .num_parents = 1,
+   .ops = _alpha_pll_fabia_ops,
+   },
+   },
+};
+
+static const struct clk_div_table post_div_table_fabia_even[] = {
+   { 0x0, 1 },
+   { 0x1, 2 },
+   { }
+};
+
+static struct clk_alpha_pll_postdiv cam_cc_pll0_out_even = {
+   .offset = 0x0,
+   .post_div_shift = 8,
+   .post_div_table = post_div_table_fabia_even,
+   .num_post_div = ARRAY_SIZE(post_div_table_fabia_even),
+   .width = 4,
+   .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA],
+   .clkr.hw.init = &(struct clk_init_data){
+   .name = "cam_cc_pll0_out_even",
+   .parent_names = (const char *[]){ "cam_cc_pll0" },
+   .num_parents = 1,
+   .ops = _alpha_pll_postdiv_fabia_ops,
+   },
+};
+
+static struct clk_alpha_pll cam_cc_pll1 = {
+   .offset = 0x1000,
+   .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA],
+   .clkr = {
+   .hw.init = &(struct clk_init_data){
+   .name = "cam_cc_pll1",
+   .parent_names = (const char *[]){ "bi_tcxo" },
+   .num_parents = 1,
+   .ops = _alpha_pll_fabia_ops,
+   },
+   },
+};
+
+static struct clk_alpha_pll_postdiv cam_cc_pll1_out_even = {
+   .offset = 0x1000,
+   .post_div_shift = 8,
+   .post_div_table = post_div_table_fabia_even,
+   .num_post_div = ARRAY_SIZE(post_div_table_fabia_even),
+   .width = 4,
+   .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA],
+   .clkr.hw.init = &(struct clk_init_data){
+   .name = "cam_cc_pll1_out_even",
+   .parent_names = (const char *[]){ "cam_cc_pll1" },

[PATCH v3] clk: qcom: Add camera clock controller driver for SDM845

2018-08-08 Thread Amit Nischal
Add support for the camera clock controller found on SDM845
based devices. This would allow camera drivers to probe and
control their clocks.

Signed-off-by: Amit Nischal 
---
 drivers/clk/qcom/Kconfig|8 +
 drivers/clk/qcom/Makefile   |1 +
 drivers/clk/qcom/camcc-sdm845.c | 1745 +++
 3 files changed, 1754 insertions(+)
 create mode 100644 drivers/clk/qcom/camcc-sdm845.c

diff --git a/drivers/clk/qcom/Kconfig b/drivers/clk/qcom/Kconfig
index 1595464..f551432 100644
--- a/drivers/clk/qcom/Kconfig
+++ b/drivers/clk/qcom/Kconfig
@@ -235,6 +235,14 @@ config MSM_GCC_8998
  Say Y if you want to use peripheral devices such as UART, SPI,
  i2c, USB, UFS, SD/eMMC, PCIe, etc.

+config SDM_CAMCC_845
+   tristate "SDM845 Camera Clock Controller"
+   depends on COMMON_CLK_QCOM
+   select SDM_GCC_845
+   help
+ Support for the camera clock controller on SDM845 devices.
+ Say Y if you want to support camera devices and camera functionality.
+
 config SDM_GCC_845
tristate "SDM845 Global Clock Controller"
select QCOM_GDSC
diff --git a/drivers/clk/qcom/Makefile b/drivers/clk/qcom/Makefile
index 93c1089..ada8750 100644
--- a/drivers/clk/qcom/Makefile
+++ b/drivers/clk/qcom/Makefile
@@ -41,6 +41,7 @@ obj-$(CONFIG_QCOM_CLK_RPM) += clk-rpm.o
 obj-$(CONFIG_QCOM_CLK_RPMH) += clk-rpmh.o
 obj-$(CONFIG_QCOM_CLK_SMD_RPM) += clk-smd-rpm.o
 obj-$(CONFIG_SDM_DISPCC_845) += dispcc-sdm845.o
+obj-$(CONFIG_SDM_CAMCC_845) += camcc-sdm845.o
 obj-$(CONFIG_SDM_GCC_845) += gcc-sdm845.o
 obj-$(CONFIG_SDM_GPUCC_845) += gpucc-sdm845.o
 obj-$(CONFIG_SDM_VIDEOCC_845) += videocc-sdm845.o
diff --git a/drivers/clk/qcom/camcc-sdm845.c b/drivers/clk/qcom/camcc-sdm845.c
new file mode 100644
index 000..1b2cefe
--- /dev/null
+++ b/drivers/clk/qcom/camcc-sdm845.c
@@ -0,0 +1,1745 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "common.h"
+#include "clk-alpha-pll.h"
+#include "clk-branch.h"
+#include "clk-rcg.h"
+#include "clk-regmap.h"
+#include "gdsc.h"
+
+enum {
+   P_BI_TCXO,
+   P_CAM_CC_PLL0_OUT_EVEN,
+   P_CAM_CC_PLL1_OUT_EVEN,
+   P_CAM_CC_PLL2_OUT_EVEN,
+   P_CAM_CC_PLL3_OUT_EVEN,
+   P_CORE_BI_PLL_TEST_SE,
+};
+
+static const struct parent_map cam_cc_parent_map_0[] = {
+   { P_BI_TCXO, 0 },
+   { P_CAM_CC_PLL2_OUT_EVEN, 1 },
+   { P_CAM_CC_PLL1_OUT_EVEN, 2 },
+   { P_CAM_CC_PLL3_OUT_EVEN, 5 },
+   { P_CAM_CC_PLL0_OUT_EVEN, 6 },
+   { P_CORE_BI_PLL_TEST_SE, 7 },
+};
+
+static const char * const cam_cc_parent_names_0[] = {
+   "bi_tcxo",
+   "cam_cc_pll2_out_even",
+   "cam_cc_pll1_out_even",
+   "cam_cc_pll3_out_even",
+   "cam_cc_pll0_out_even",
+   "core_bi_pll_test_se",
+};
+
+static struct clk_alpha_pll cam_cc_pll0 = {
+   .offset = 0x0,
+   .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA],
+   .clkr = {
+   .hw.init = &(struct clk_init_data){
+   .name = "cam_cc_pll0",
+   .parent_names = (const char *[]){ "bi_tcxo" },
+   .num_parents = 1,
+   .ops = _alpha_pll_fabia_ops,
+   },
+   },
+};
+
+static const struct clk_div_table post_div_table_fabia_even[] = {
+   { 0x0, 1 },
+   { 0x1, 2 },
+   { }
+};
+
+static struct clk_alpha_pll_postdiv cam_cc_pll0_out_even = {
+   .offset = 0x0,
+   .post_div_shift = 8,
+   .post_div_table = post_div_table_fabia_even,
+   .num_post_div = ARRAY_SIZE(post_div_table_fabia_even),
+   .width = 4,
+   .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA],
+   .clkr.hw.init = &(struct clk_init_data){
+   .name = "cam_cc_pll0_out_even",
+   .parent_names = (const char *[]){ "cam_cc_pll0" },
+   .num_parents = 1,
+   .ops = _alpha_pll_postdiv_fabia_ops,
+   },
+};
+
+static struct clk_alpha_pll cam_cc_pll1 = {
+   .offset = 0x1000,
+   .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA],
+   .clkr = {
+   .hw.init = &(struct clk_init_data){
+   .name = "cam_cc_pll1",
+   .parent_names = (const char *[]){ "bi_tcxo" },
+   .num_parents = 1,
+   .ops = _alpha_pll_fabia_ops,
+   },
+   },
+};
+
+static struct clk_alpha_pll_postdiv cam_cc_pll1_out_even = {
+   .offset = 0x1000,
+   .post_div_shift = 8,
+   .post_div_table = post_div_table_fabia_even,
+   .num_post_div = ARRAY_SIZE(post_div_table_fabia_even),
+   .width = 4,
+   .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA],
+   .clkr.hw.init = &(struct clk_init_data){
+   .name = "cam_cc_pll1_out_even",
+   .parent_names = (const char *[]){ "cam_cc_pll1" },