Add QCOM camera clock controller driver
cover Add QCOM camera clock controller driver
This patch series adds a driver and device tree documentation binding for the camera clock controller on some Qualcomm Technologies, Inc, SoCs such as SDM845. This would allow camera drivers to probe and control their clocks.
Amit Nischal (2):
dt-bindings: clock: Introduce QCOM Camera clock bindings
clk: qcom: Add camera clock controller driver for SDM845
.../devicetree/bindings/clock/qcom,camcc.txt | 18 + drivers/clk/qcom/Kconfig | 8 + drivers/clk/qcom/Makefile | 1 + drivers/clk/qcom/camcc-sdm845.c | 1736 ++++++++++++++++++++ include/dt-bindings/clock/qcom,camcc-sdm845.h | 116 ++ 5 files changed, 1879 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/qcom,camcc.txt create mode 100644 drivers/clk/qcom/camcc-sdm845.c create mode 100644 include/dt-bindings/clock/qcom,camcc-sdm845.h
--
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
PATCH 1/2 dt-bindings: clock: Introduce QCOM Camera clock bindings
Add device tree bindings for camera clock controller for Qualcomm Technology Inc's SDM845 SoCs.
--- .../devicetree/bindings/clock/qcom,camcc.txt | 18 ++++ include/dt-bindings/clock/qcom,camcc-sdm845.h | 116 +++++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/qcom,camcc.txt create mode 100644 include/dt-bindings/clock/qcom,camcc-sdm845.h
Documentation/devicetree/bindings/clock/qcom,camcc.txt new file +18 -0
@@ -0,0 +1,18 @@ +Qualcomm Camera Clock & Reset Controller Binding +------------------------------------------------ + +Required properties : +- compatible : shall contain "qcom,sdm845-camcc". +- reg : shall contain base register location and length. +- #clock-cells : from common clock binding, shall contain 1. +- #reset-cells : from common reset binding, shall contain 1. +- #power-domain-cells : from generic power domain binding, shall contain 1. + +Example: + camcc: clock-controller@ad00000 { + compatible = "qcom,sdm845-camcc"; + reg = <0xad00000 0x10000>; + #clock-cells = <1>; + #reset-cells = <1>; + #power-domain-cells = <1>; + };
include/dt-bindings/clock/qcom,camcc-sdm845.h new file +116 -0
116 lines not on this page · raw message
--
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Re: [PATCH 1/2] dt-bindings: clock: Introduce QCOM Camera clock bindings
Quoting Amit Nischal (2018-07-23 04:26:32)
Quoted 5 lines
Add device tree bindings for camera clock controller for Qualcomm Technology Inc's SDM845 SoCs.
Signed-off-by Amit Nischal <[email protected]>---
Applied to clk-next
PATCH 2/2 clk: qcom: Add camera clock controller driver for SDM845
In reply to Amit NischalAdd support for the camera clock controller found on SDM845 based devices. This would allow camera drivers to probe and control their clocks.
--- drivers/clk/qcom/Kconfig | 8 + drivers/clk/qcom/Makefile | 1 + drivers/clk/qcom/camcc-sdm845.c | 1736 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 1745 insertions(+) create mode 100644 drivers/clk/qcom/camcc-sdm845.c
drivers/clk/qcom/Kconfig +8 -0
@@ -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
drivers/clk/qcom/Makefile +1 -0
@@ -40,6 +40,7 @@ obj-$(CONFIG_QCOM_CLK_APCS_MSM8916) += apcs-msm8916.o 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_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
drivers/clk/qcom/camcc-sdm845.c new file +1736 -0
1,736 lines not on this page · raw message
--
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Stephen Boyd
maintainerRe: [PATCH 2/2] clk: qcom: Add camera clock controller driver for SDM845
Quoting Amit Nischal (2018-07-23 04:26:33)
drivers/clk/qcom/camcc-sdm845.c line 6
Quoted 12 lines
drivers/clk/qcom/camcc-sdm845.c new file +6
-0@@ -0,0 +1,1736 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2018, The Linux Foundation. All rights reserved. +*/ + +#include <linux/clk.h>
Is this include used?
Quoted 171 lines
drivers/clk/qcom/camcc-sdm845.c new file +171
-0+#include <linux/clk-provider.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/regmap.h> + +#include <dt-bindings/clock/qcom,camcc-sdm845.h> + +#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 = &clk_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 = &clk_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 = &clk_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" }, + .num_parents =1 , + .ops = &clk_alpha_pll_postdiv_fabia_ops, + }, +}; + +static struct clk_alpha_pll cam_cc_pll2 = { + .offset =0x2000 , + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA ], + .clkr = { + .hw.init = &(struct clk_init_data ){ + .name ="cam_cc_pll2" , + .parent_names = (const char *[]){"bi_tcxo" }, + .num_parents =1 , + .ops = &clk_alpha_pll_fabia_ops, + }, + }, +}; + +static struct clk_alpha_pll_postdiv cam_cc_pll2_out_even = { + .offset =0x2000 , + .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_pll2_out_even" , + .parent_names = (const char *[]){"cam_cc_pll2" }, + .num_parents =1 , + .ops = &clk_alpha_pll_postdiv_fabia_ops, + }, +}; + +static struct clk_alpha_pll cam_cc_pll3 = { + .offset =0x3000 , + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA ], + .clkr = { + .hw.init = &(struct clk_init_data ){ + .name ="cam_cc_pll3" , + .parent_names = (const char *[]){"bi_tcxo" }, + .num_parents =1 , + .ops = &clk_alpha_pll_fabia_ops, + }, + }, +}; + +static struct clk_alpha_pll_postdiv cam_cc_pll3_out_even = { + .offset =0x3000 , + .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_pll3_out_even" , + .parent_names = (const char *[]){"cam_cc_pll3" }, + .num_parents =1 , + .ops = &clk_alpha_pll_postdiv_fabia_ops, + }, +}; + +static const struct freq_tbl ftbl_cam_cc_bps_clk_src[] = { +F (19200000 ,P_BI_TCXO ,1 ,0 ,0 ), +F (100000000 ,P_CAM_CC_PLL0_OUT_EVEN ,6 ,0 ,0 ), +F (200000000 ,P_CAM_CC_PLL0_OUT_EVEN ,3 ,0 ,0 ), +F (404000000 ,P_CAM_CC_PLL1_OUT_EVEN ,2 ,0 ,0 ), +F (480000000 ,P_CAM_CC_PLL2_OUT_EVEN ,1 ,0 ,0 ), +F (600000000 ,P_CAM_CC_PLL0_OUT_EVEN ,1 ,0 ,0 ), + { } +}; + +static struct clk_rcg2 cam_cc_bps_clk_src = { + .cmd_rcgr =0x600c ,
drivers/clk/qcom/camcc-sdm845.c line 187
Quoted 10 lines
drivers/clk/qcom/camcc-sdm845.c new file +10
-0+ .mnd_width = 0, + .hid_width = 5, + .parent_map = cam_cc_parent_map_0, + .freq_tbl = ftbl_cam_cc_bps_clk_src, + .clkr.hw.init = &(struct clk_init_data ){ + .name ="cam_cc_bps_clk_src" , + .parent_names = cam_cc_parent_names_0, + .num_parents =6 , + .flags =CLK_SET_RATE_PARENT , + .ops = &clk_rcg2_shared_ops,
Why are shared ops used in this driver?
Quoted 11 lines
drivers/clk/qcom/camcc-sdm845.c new file +11
-0+ }, +}; + +static const struct freq_tbl ftbl_cam_cc_cci_clk_src[] = { +F (19200000 ,P_BI_TCXO ,1 ,0 ,0 ), +F (37500000 ,P_CAM_CC_PLL0_OUT_EVEN ,16 ,0 ,0 ), +F (50000000 ,P_CAM_CC_PLL0_OUT_EVEN ,12 ,0 ,0 ), +F (100000000 ,P_CAM_CC_PLL0_OUT_EVEN ,6 ,0 ,0 ), + { } +}; +
[...]
Quoted 64 lines
drivers/clk/qcom/camcc-sdm845.c new file +64
-0+ .clkr.hw.init = &(struct clk_init_data){ + .name ="cam_cc_mclk0_clk_src" , + .parent_names = cam_cc_parent_names_0, + .num_parents =6 , + .flags =CLK_SET_RATE_PARENT , + .ops = &clk_rcg2_ops, + }, +}; + +static struct clk_rcg2 cam_cc_mclk1_clk_src = { + .cmd_rcgr =0x4024 , + .mnd_width =8 , + .hid_width =5 , + .parent_map = cam_cc_parent_map_0, + .freq_tbl = ftbl_cam_cc_mclk0_clk_src, + .clkr.hw.init = &(struct clk_init_data ){ + .name ="cam_cc_mclk1_clk_src" , + .parent_names = cam_cc_parent_names_0, + .num_parents =6 , + .flags =CLK_SET_RATE_PARENT , + .ops = &clk_rcg2_ops, + }, +}; + +static struct clk_rcg2 cam_cc_mclk2_clk_src = { + .cmd_rcgr =0x4044 , + .mnd_width =8 , + .hid_width =5 , + .parent_map = cam_cc_parent_map_0, + .freq_tbl = ftbl_cam_cc_mclk0_clk_src, + .clkr.hw.init = &(struct clk_init_data ){ + .name ="cam_cc_mclk2_clk_src" , + .parent_names = cam_cc_parent_names_0, + .num_parents =6 , + .flags =CLK_SET_RATE_PARENT , + .ops = &clk_rcg2_ops, + }, +}; + +static struct clk_rcg2 cam_cc_mclk3_clk_src = { + .cmd_rcgr =0x4064 , + .mnd_width =8 , + .hid_width =5 , + .parent_map = cam_cc_parent_map_0, + .freq_tbl = ftbl_cam_cc_mclk0_clk_src, + .clkr.hw.init = &(struct clk_init_data ){ + .name ="cam_cc_mclk3_clk_src" , + .parent_names = cam_cc_parent_names_0, + .num_parents =6 , + .flags =CLK_SET_RATE_PARENT , + .ops = &clk_rcg2_ops, + }, +}; + +static const struct freq_tbl ftbl_cam_cc_slow_ahb_clk_src[] = { +F (19200000 ,P_BI_TCXO ,1 ,0 ,0 ), +F (60000000 ,P_CAM_CC_PLL0_OUT_EVEN ,10 ,0 ,0 ), +F (66666667 ,P_CAM_CC_PLL0_OUT_EVEN ,9 ,0 ,0 ), +F (73846154 ,P_CAM_CC_PLL2_OUT_EVEN ,6.5 ,0 ,0 ), +F (80000000 ,P_CAM_CC_PLL2_OUT_EVEN ,6 ,0 ,0 ), + { } +}; + +static struct clk_rcg2 cam_cc_slow_ahb_clk_src = {
drivers/clk/qcom/camcc-sdm845.c line 642
Quoted 10 lines
drivers/clk/qcom/camcc-sdm845.c new file +10
-0+ .cmd_rcgr = 0x6054, + .mnd_width = 0, + .hid_width = 5, + .parent_map = cam_cc_parent_map_0, + .freq_tbl = ftbl_cam_cc_slow_ahb_clk_src, + .clkr.hw.init = &(struct clk_init_data ){ + .name ="cam_cc_slow_ahb_clk_src" , + .parent_names = cam_cc_parent_names_0, + .num_parents =6 , + .flags =CLK_SET_RATE_PARENT ,
Is CLK_SET_RATE_PARENT intentionally set on these RCGs so that they can reconfigure the PLL frequency? Wouldn't that be a fixed rate PLL frequency?
Quoted 4 lines
drivers/clk/qcom/camcc-sdm845.c new file +4
-0+ .ops = &clk_rcg2_ops, + }, +}; +
[...]
drivers/clk/qcom/camcc-sdm845.c line 1698
Quoted 12 lines
drivers/clk/qcom/camcc-sdm845.c new file +12
-0+ +static int cam_cc_sdm845_probe (struct platform_device *pdev) +{ +struct regmap *regmap; +struct alpha_pll_config cam_cc_pll_config = { }; + + regmap =qcom_cc_map (pdev, &cam_cc_sdm845_desc); +if (IS_ERR (regmap)) +return PTR_ERR (regmap); + + cam_cc_pll_config.l =0x1f , + cam_cc_pll_config.alpha = 0x4000,
Replace these commas with semicolons.
drivers/clk/qcom/camcc-sdm845.c line 1703
Quoted 5 lines
drivers/clk/qcom/camcc-sdm845.c new file +5
-0+clk_fabia_pll_configure (&cam_cc_pll0, regmap, &cam_cc_pll_config); + + cam_cc_pll_config.l =0x2a , + cam_cc_pll_config.alpha =0x1556 , +clk_fabia_pll_configure (&cam_cc_pll1, regmap, &cam_cc_pll_config);
All over this function.
Can you also add comments in the commit text and code describing why oddities like CLK_SET_RATE_PARENT on RCGs and shared rcg ops is used?
Re: [PATCH 2/2] clk: qcom: Add camera clock controller driver for SDM845
Quoted 15 lines · Stephen Boyd
Quoting Amit Nischal (2018-07-23 04:26:33)
drivers/clk/qcom/camcc-sdm845.c line 6
Quoted 12 lines
drivers/clk/qcom/camcc-sdm845.c new file +6
-0@@ -0,0 +1,1736 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2018, The Linux Foundation. All rights reserved. +*/ + +#include <linux/clk.h> Is this include used?
This is not required. I will remove this in next patch series.
Quoted 176 lines
Quoted 176 lines
drivers/clk/qcom/camcc-sdm845.c new file +175
-0+#include <linux/clk-provider.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/regmap.h> + +#include <dt-bindings/clock/qcom,camcc-sdm845.h> + +#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 = &clk_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 = &clk_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 = &clk_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" }, + .num_parents =1 , + .ops = &clk_alpha_pll_postdiv_fabia_ops, + }, +}; + +static struct clk_alpha_pll cam_cc_pll2 = { + .offset =0x2000 , + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA ], + .clkr = { + .hw.init = &(struct clk_init_data ){ + .name ="cam_cc_pll2" , + .parent_names = (const char *[]){"bi_tcxo" }, + .num_parents =1 , + .ops = &clk_alpha_pll_fabia_ops, + }, + }, +}; + +static struct clk_alpha_pll_postdiv cam_cc_pll2_out_even = { + .offset =0x2000 , + .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_pll2_out_even" , + .parent_names = (const char *[]){"cam_cc_pll2" }, + .num_parents =1 , + .ops = &clk_alpha_pll_postdiv_fabia_ops, + }, +}; + +static struct clk_alpha_pll cam_cc_pll3 = { + .offset =0x3000 , + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA ], + .clkr = { + .hw.init = &(struct clk_init_data ){ + .name ="cam_cc_pll3" , + .parent_names = (const char *[]){"bi_tcxo" }, + .num_parents =1 , + .ops = &clk_alpha_pll_fabia_ops, + }, + }, +}; + +static struct clk_alpha_pll_postdiv cam_cc_pll3_out_even = { + .offset =0x3000 , + .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_pll3_out_even" , + .parent_names = (const char *[]){"cam_cc_pll3" }, + .num_parents =1 , + .ops = &clk_alpha_pll_postdiv_fabia_ops, + }, +}; + +static const struct freq_tbl ftbl_cam_cc_bps_clk_src[] = { +F (19200000 ,P_BI_TCXO ,1 ,0 ,0 ), +F (100000000 ,P_CAM_CC_PLL0_OUT_EVEN ,6 ,0 ,0 ), +F (200000000 ,P_CAM_CC_PLL0_OUT_EVEN ,3 ,0 ,0 ), +F (404000000 ,P_CAM_CC_PLL1_OUT_EVEN ,2 ,0 ,0 ), +F (480000000 ,P_CAM_CC_PLL2_OUT_EVEN ,1 ,0 ,0 ), +F (600000000 ,P_CAM_CC_PLL0_OUT_EVEN ,1 ,0 ,0 ), + { } +}; + +static struct clk_rcg2 cam_cc_bps_clk_src = { + .cmd_rcgr =0x600c , + .mnd_width =0 , + .hid_width =5 , + .parent_map = cam_cc_parent_map_0, + .freq_tbl = ftbl_cam_cc_bps_clk_src,
Quoted 9 lines
drivers/clk/qcom/camcc-sdm845.c line 187
Quoted 6 lines
drivers/clk/qcom/camcc-sdm845.c new file +6
-0+ .clkr.hw.init = &(struct clk_init_data){ + .name ="cam_cc_bps_clk_src" , + .parent_names = cam_cc_parent_names_0, + .num_parents =6 , + .flags =CLK_SET_RATE_PARENT , + .ops = &clk_rcg2_shared_ops,Why are shared ops used in this driver?
As per HW design, most of the CAMCC RCGs needs to move to XO during clock disable so because of this we have used the shared ops.
Quoted 82 lines
Quoted 11 lines
drivers/clk/qcom/camcc-sdm845.c new file +11
-0+ }, +}; + +static const struct freq_tbl ftbl_cam_cc_cci_clk_src[] = { +F (19200000 ,P_BI_TCXO ,1 ,0 ,0 ), +F (37500000 ,P_CAM_CC_PLL0_OUT_EVEN ,16 ,0 ,0 ), +F (50000000 ,P_CAM_CC_PLL0_OUT_EVEN ,12 ,0 ,0 ), +F (100000000 ,P_CAM_CC_PLL0_OUT_EVEN ,6 ,0 ,0 ), + { } +}; +[...]
Quoted 70 lines
drivers/clk/qcom/camcc-sdm845.c new file +70
-0+ .clkr.hw.init = &(struct clk_init_data){ + .name ="cam_cc_mclk0_clk_src" , + .parent_names = cam_cc_parent_names_0, + .num_parents =6 , + .flags =CLK_SET_RATE_PARENT , + .ops = &clk_rcg2_ops, + }, +}; + +static struct clk_rcg2 cam_cc_mclk1_clk_src = { + .cmd_rcgr =0x4024 , + .mnd_width =8 , + .hid_width =5 , + .parent_map = cam_cc_parent_map_0, + .freq_tbl = ftbl_cam_cc_mclk0_clk_src, + .clkr.hw.init = &(struct clk_init_data ){ + .name ="cam_cc_mclk1_clk_src" , + .parent_names = cam_cc_parent_names_0, + .num_parents =6 , + .flags =CLK_SET_RATE_PARENT , + .ops = &clk_rcg2_ops, + }, +}; + +static struct clk_rcg2 cam_cc_mclk2_clk_src = { + .cmd_rcgr =0x4044 , + .mnd_width =8 , + .hid_width =5 , + .parent_map = cam_cc_parent_map_0, + .freq_tbl = ftbl_cam_cc_mclk0_clk_src, + .clkr.hw.init = &(struct clk_init_data ){ + .name ="cam_cc_mclk2_clk_src" , + .parent_names = cam_cc_parent_names_0, + .num_parents =6 , + .flags =CLK_SET_RATE_PARENT , + .ops = &clk_rcg2_ops, + }, +}; + +static struct clk_rcg2 cam_cc_mclk3_clk_src = { + .cmd_rcgr =0x4064 , + .mnd_width =8 , + .hid_width =5 , + .parent_map = cam_cc_parent_map_0, + .freq_tbl = ftbl_cam_cc_mclk0_clk_src, + .clkr.hw.init = &(struct clk_init_data ){ + .name ="cam_cc_mclk3_clk_src" , + .parent_names = cam_cc_parent_names_0, + .num_parents =6 , + .flags =CLK_SET_RATE_PARENT , + .ops = &clk_rcg2_ops, + }, +}; + +static const struct freq_tbl ftbl_cam_cc_slow_ahb_clk_src[] = { +F (19200000 ,P_BI_TCXO ,1 ,0 ,0 ), +F (60000000 ,P_CAM_CC_PLL0_OUT_EVEN ,10 ,0 ,0 ), +F (66666667 ,P_CAM_CC_PLL0_OUT_EVEN ,9 ,0 ,0 ), +F (73846154 ,P_CAM_CC_PLL2_OUT_EVEN ,6.5 ,0 ,0 ), +F (80000000 ,P_CAM_CC_PLL2_OUT_EVEN ,6 ,0 ,0 ), + { } +}; + +static struct clk_rcg2 cam_cc_slow_ahb_clk_src = { + .cmd_rcgr =0x6054 , + .mnd_width =0 , + .hid_width =5 , + .parent_map = cam_cc_parent_map_0, + .freq_tbl = ftbl_cam_cc_slow_ahb_clk_src, + .clkr.hw.init = &(struct clk_init_data ){
Quoted 9 lines
drivers/clk/qcom/camcc-sdm845.c line 642
Quoted 4 lines
drivers/clk/qcom/camcc-sdm845.c new file +4
-0+ .name = "cam_cc_slow_ahb_clk_src", + .parent_names = cam_cc_parent_names_0, + .num_parents = 6, + .flags = CLK_SET_RATE_PARENT,Is
CLK_SET_RATE_PARENTintentionally set on these RCGs so that they can reconfigure the PLL frequency? Wouldn't that be a fixed rate PLL frequency?
PLL2_OUT_EVEN requires to be reconfigure to 480MHz so clock sources which are using PLL2 in their frequency table requires 'CLK_SET_RATE_PARENT' flag to be set.
Quoted 5 lines
Quoted 4 lines
drivers/clk/qcom/camcc-sdm845.c new file +4
-0+ .ops = &clk_rcg2_ops, + }, +}; +[...]
Quoted 15 lines
drivers/clk/qcom/camcc-sdm845.c line 1698
Quoted 12 lines
drivers/clk/qcom/camcc-sdm845.c new file +12
-0+ +static int cam_cc_sdm845_probe (struct platform_device *pdev) +{ +struct regmap *regmap; +struct alpha_pll_config cam_cc_pll_config = { }; + + regmap =qcom_cc_map (pdev, &cam_cc_sdm845_desc); +if (IS_ERR (regmap)) +return PTR_ERR (regmap); + + cam_cc_pll_config.l =0x1f , + cam_cc_pll_config.alpha = 0x4000,Replace these commas with semicolons.
Ok sure. I will do as suggested in the next patch series.
Quoted 8 lines
Quoted 7 lines
+ clk_fabia_pll_configure(&cam_cc_pll0, regmap,
&cam_cc_pll_config);drivers/clk/qcom/camcc-sdm845.c new file +4
-0+ + cam_cc_pll_config.l =0x2a , + cam_cc_pll_config.alpha =0x1556 , + clk_fabia_pll_configure(&cam_cc_pll1, regmap,
&cam_cc_pll_config);
Quoted 4 lines
All over this function.
Can you also add comments in the commit text and code describing why oddities like
CLK_SET_RATE_PARENTon RCGs and shared rcg ops is used?
ok sure will add the same in the next patch series.
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-clk" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Stephen Boyd
maintainerRe: [PATCH 2/2] clk: qcom: Add camera clock controller driver for SDM845
Quoting Amit Nischal (2018-07-30 00:20:52)
Quoted 24 lines · Stephen Boyd
Quoted 13 lines
Quoting Amit Nischal (2018-07-23 04:26:33)
Quoted 12 lines
drivers/clk/qcom/camcc-sdm845.c new file +6
-0+static struct clk_rcg2 cam_cc_bps_clk_src = { + .cmd_rcgr =0x600c , + .mnd_width =0 , + .hid_width =5 , + .parent_map = cam_cc_parent_map_0, + .freq_tbl = ftbl_cam_cc_bps_clk_src,Quoted 9 lines
drivers/clk/qcom/camcc-sdm845.c line 187
Quoted 6 lines
drivers/clk/qcom/camcc-sdm845.c new file +6
-0+ .clkr.hw.init = &(struct clk_init_data){ + .name ="cam_cc_bps_clk_src" , + .parent_names = cam_cc_parent_names_0, + .num_parents =6 , + .flags =CLK_SET_RATE_PARENT , + .ops = &clk_rcg2_shared_ops,Why are shared ops used in this driver?
Quoted 3 lines
As per HW design, most of the CAMCC RCGs needs to move to XO during clock disable so because of this we have used the shared ops.
Please add a comment to this effect in this driver and also mention this in the commit text. I guess the camera firmware is also doing clk control and so it wants the clk to be on at some basic rate in case that's happening?
Quoted 18 lines
Quoted 8 lines
Quoted 8 lines
drivers/clk/qcom/camcc-sdm845.c new file +8
-0+ +static struct clk_rcg2 cam_cc_slow_ahb_clk_src = { + .cmd_rcgr =0x6054 , + .mnd_width =0 , + .hid_width =5 , + .parent_map = cam_cc_parent_map_0, + .freq_tbl = ftbl_cam_cc_slow_ahb_clk_src, + .clkr.hw.init = &(struct clk_init_data ){Quoted 9 lines
drivers/clk/qcom/camcc-sdm845.c line 642
Quoted 4 lines
drivers/clk/qcom/camcc-sdm845.c new file +4
-0+ .name = "cam_cc_slow_ahb_clk_src", + .parent_names = cam_cc_parent_names_0, + .num_parents = 6, + .flags = CLK_SET_RATE_PARENT,Is
CLK_SET_RATE_PARENTintentionally set on these RCGs so that they can reconfigure the PLL frequency? Wouldn't that be a fixed rate PLL frequency?
Quoted 4 lines
PLL2_OUT_EVENrequires to be reconfigure to 480MHz so clock sources which
are using PLL2 in their frequency table requires 'CLK_SET_RATE_PARENT' flag to be set.
Ok.