Add display clock controller driver for SDM845
cover Add display clock controller driver for SDM845
Add support for the display clock controller found on SDM845 based devices. This would allow display drivers to probe and control their clocks.
Taniya Das (2):
dt-bindings: clock: Introduce QCOM Display clock bindings
clk: qcom: Add display clock controller driver for SDM845
.../devicetree/bindings/clock/qcom,dispcc.txt | 18 + drivers/clk/qcom/Kconfig | 10 + drivers/clk/qcom/Makefile | 1 + drivers/clk/qcom/dispcc-sdm845.c | 704 +++++++++++++++++++++ include/dt-bindings/clock/qcom,dispcc-sdm845.h | 42 ++ 5 files changed, 775 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/qcom,dispcc.txt create mode 100644 drivers/clk/qcom/dispcc-sdm845.c create mode 100644 include/dt-bindings/clock/qcom,dispcc-sdm845.h
--
Qualcomm INDIA, on behalf of Qualcomm Innovation Center, Inc.is a member of the Code Aurora Forum, hosted by the Linux Foundation.
PATCH 1/2 dt-bindings: clock: Introduce QCOM Display clock bindings
Add device tree bindings for display clock controller for Qualcomm Technology Inc's SoCs.
--- .../devicetree/bindings/clock/qcom,dispcc.txt | 19 +++++++++ include/dt-bindings/clock/qcom,dispcc-sdm845.h | 45 ++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/qcom,dispcc.txt create mode 100644 include/dt-bindings/clock/qcom,dispcc-sdm845.h
Documentation/devicetree/bindings/clock/qcom,dispcc.txt new file +19 -0
@@ -0,0 +1,19 @@ +Qualcomm Technologies, Inc. Display Clock Controller Binding +------------------------------------------------------------ + +Required properties : + +- compatible : shall contain "qcom,sdm845-dispcc" +- 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: + dispcc: clock-controller@af00000 { + compatible = "qcom,sdm845-dispcc"; + reg = <0xaf00000 0x100000>; + #clock-cells = <1>; + #reset-cells = <1>; + #power-domain-cells = <1>; + };
include/dt-bindings/clock/qcom,dispcc-sdm845.h new file +45 -0
45 lines not on this page · raw message
--
Qualcomm INDIA, on behalf of Qualcomm Innovation Center, Inc.is a member of the Code Aurora Forum, hosted by the Linux Foundation.
PATCH 2/2 clk: qcom: Add display clock controller driver for SDM845
In reply to Taniya DasAdd support for the display clock controller found on SDM845 based devices. This would allow display drivers to probe and control their clocks.
--- drivers/clk/qcom/Kconfig | 10 + drivers/clk/qcom/Makefile | 1 + drivers/clk/qcom/dispcc-sdm845.c | 679 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 690 insertions(+) create mode 100644 drivers/clk/qcom/dispcc-sdm845.c
drivers/clk/qcom/Kconfig +10 -0
@@ -227,6 +227,16 @@ config SDM_GCC_845 Say Y if you want to use peripheral devices such as UART, SPI, I2C, USB, UFS, SDDC, PCIe, etc. +config SDM_DISPCC_845 + tristate "SDM845 Display Clock Controller" + select SDM_GCC_845 + depends on COMMON_CLK_QCOM + help + Support for the display clock controller on Qualcomm Technologies, Inc + sdm845 devices. + Say Y if you want to support display devices and functionality such as + splash screen. + config SPMI_PMIC_CLKDIV tristate "SPMI PMIC clkdiv Support" depends on (COMMON_CLK_QCOM && SPMI) || COMPILE_TEST
drivers/clk/qcom/Makefile +1 -0
@@ -38,4 +38,5 @@ obj-$(CONFIG_QCOM_CLK_APCS_MSM8916) += apcs-msm8916.o obj-$(CONFIG_QCOM_CLK_RPM) += clk-rpm.o obj-$(CONFIG_QCOM_CLK_SMD_RPM) += clk-smd-rpm.o obj-$(CONFIG_SDM_GCC_845) += gcc-sdm845.o +obj-$(CONFIG_SDM_DISPCC_845) += dispcc-sdm845.o obj-$(CONFIG_SPMI_PMIC_CLKDIV) += clk-spmi-pmic-div.o
drivers/clk/qcom/dispcc-sdm845.c new file +679 -0
679 lines not on this page · raw message
--
Qualcomm INDIA, on behalf of Qualcomm Innovation Center, Inc.is a member of the Code Aurora Forum, hosted by the Linux Foundation.
Stephen Boyd
maintainerRe: [PATCH 2/2] clk: qcom: Add display clock controller driver for SDM845
Quoting Taniya Das (2018-06-04 00:56:25)
Quoted 15 lines
drivers/clk/qcom/dispcc-sdm845.c new file +9
-0@@ -0,0 +1,679 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2018, The Linux Foundation. All rights reserved. +*/ + +#include <linux/clk-provider.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/regmap.h>
drivers/clk/qcom/dispcc-sdm845.c line 19
Quoted 10 lines
drivers/clk/qcom/dispcc-sdm845.c new file +10
-0+#include <linux/reset-controller.h> + +#include <dt-bindings/clock/qcom,dispcc-sdm845.h> + +#include "clk-alpha-pll.h" +#include "clk-branch.h" +#include "clk-pll.h" +#include "clk-rcg.h" +#include "clk-regmap.h" +#include "clk-regmap-divider.h"
Used?
drivers/clk/qcom/dispcc-sdm845.c line 24
Quoted 5 lines
drivers/clk/qcom/dispcc-sdm845.c new file +5
-0+#include "common.h" +#include "gdsc.h" +#include "reset.h" + +#define F (f, s, h, m, n) { (f), (s), (2 * (h) - 1), (m), (n) }
We really need to move this into the header file.
$ git grep '#define F(' -- drivers/clk/qcom/ | wc -l
13Quoted 1 line
drivers/clk/qcom/dispcc-sdm845.c new file +1
-0+
[...]
drivers/clk/qcom/dispcc-sdm845.c line 95
Quoted 11 lines
drivers/clk/qcom/dispcc-sdm845.c new file +11
-0+static const char *const disp_cc_parent_names_4[] = { +"bi_tcxo" , +"dsi0_phy_pll_out_dsiclk" , +"dsi1_phy_pll_out_dsiclk" , +"core_bi_pll_test_se" , +}; + +static const struct alpha_pll_config disp_cc_pll0_config = { + .l =0x2c , + .alpha =0xcaaa , +};
Any reason this can't be put on the stack in the probe function?
Quoted 13 lines
drivers/clk/qcom/dispcc-sdm845.c new file +13
-0+ +static struct clk_alpha_pll disp_cc_pll0 = { + .offset =0x0 , + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA ], + .clkr = { + .hw.init = &(struct clk_init_data ){ + .name ="disp_cc_pll0" , + .parent_names = (const char *[]){"bi_tcxo" }, + .num_parents =1 , + .ops = &clk_alpha_pll_fabia_ops, + }, + }, +};
[...]
drivers/clk/qcom/dispcc-sdm845.c line 207
Quoted 11 lines
drivers/clk/qcom/dispcc-sdm845.c new file +11
-0+ +static struct clk_rcg2 disp_cc_mdss_pclk0_clk_src = { + .cmd_rcgr =0x2058 , + .mnd_width =8 , + .hid_width =5 , + .parent_map = disp_cc_parent_map_4, + .clkr.hw.init = &(struct clk_init_data ){ + .name ="disp_cc_mdss_pclk0_clk_src" , + .parent_names = disp_cc_parent_names_4, + .num_parents =4 , + .flags =CLK_SET_RATE_PARENT |CLK_GET_RATE_NOCACHE ,
Why is the nocache flag needed? Applies to all clks in this file.
Quoted 10 lines
drivers/clk/qcom/dispcc-sdm845.c new file +10
-0+ .ops = &clk_pixel_ops, + }, +}; + +static struct clk_rcg2 disp_cc_mdss_pclk1_clk_src = { + .cmd_rcgr =0x2070 , + .mnd_width =8 , + .hid_width =5 , + .parent_map = disp_cc_parent_map_4, + .clkr.hw.init = &(struct clk_init_data ){
[...]
drivers/clk/qcom/dispcc-sdm845.c line 623
Quoted 6 lines
drivers/clk/qcom/dispcc-sdm845.c new file +6
-0+ +static const struct regmap_config disp_cc_sdm845_regmap_config = { + .reg_bits =32 , + .reg_stride =4 , + .val_bits =32 , + .max_register =0x10000 ,
This seems arbitrarily large. List the actual end?
Quoted 20 lines
drivers/clk/qcom/dispcc-sdm845.c new file +20
-0+ .fast_io = true, +}; + +static const struct qcom_cc_desc disp_cc_sdm845_desc = { + .config = &disp_cc_sdm845_regmap_config, + .clks = disp_cc_sdm845_clocks, + .num_clks =ARRAY_SIZE (disp_cc_sdm845_clocks), + .resets = disp_cc_sdm845_resets, + .num_resets =ARRAY_SIZE (disp_cc_sdm845_resets), + .gdscs = disp_cc_sdm845_gdscs, + .num_gdscs =ARRAY_SIZE (disp_cc_sdm845_gdscs), +}; + +static const struct of_device_id disp_cc_sdm845_match_table[] = { + { .compatible ="qcom,sdm845-dispcc" }, + { } +}; +MODULE_DEVICE_TABLE (of, disp_cc_sdm845_match_table); + +static int disp_cc_sdm845_probe (struct platform_device *pdev)
drivers/clk/qcom/dispcc-sdm845.c line 653
Quoted 10 lines
drivers/clk/qcom/dispcc-sdm845.c new file +10
-0+{ +struct regmap *regmap; + + regmap =qcom_cc_map (pdev, &disp_cc_sdm845_desc); +if (IS_ERR (regmap)) +return PTR_ERR (regmap); + +clk_fabia_pll_configure (&disp_cc_pll0, regmap, &disp_cc_pll0_config); + +/* Enable clock gating for DSI and MDP clocks */
Hardware clock gating? What does this mean.
Quoted 4 lines
drivers/clk/qcom/dispcc-sdm845.c new file +4
-0+regmap_update_bits (regmap,0x8000 ,0x7f0 ,0x7f0 ); + +return qcom_cc_really_probe (pdev, &disp_cc_sdm845_desc, regmap); +}
Stephen Boyd
maintainerRe: [PATCH 1/2] dt-bindings: clock: Introduce QCOM Display clock bindings
In reply to Taniya DasQuoting Taniya Das (2018-06-04 00:56:24)
Quoted 2 lines
Add device tree bindings for display clock controller for Qualcomm Technology Inc's SoCs.
SDM845 SoCs?
Re: [PATCH 1/2] dt-bindings: clock: Introduce QCOM Display clock bindings
In reply to Taniya DasQuoted 10 lines · Taniya Das
Add device tree bindings for display clock controller for Qualcomm Technology Inc's SoCs.
Signed-off-by Taniya Das <[email protected]>--- .../devicetree/bindings/clock/qcom,dispcc.txt | 19 +++++++++ include/dt-bindings/clock/qcom,dispcc-sdm845.h | 45 ++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/qcom,dispcc.txt create mode 100644 include/dt-bindings/clock/qcom,dispcc-sdm845.h
Re: [PATCH 2/2] clk: qcom: Add display clock controller driver for SDM845
In reply to Stephen BoydHello Stephen,
Thanks for review.
Quoted 20 lines · Stephen Boyd
Quoting Taniya Das (2018-06-04 00:56:25)
Quoted 19 lines
drivers/clk/qcom/dispcc-sdm845.c new file +13
-0@@ -0,0 +1,679 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2018, The Linux Foundation. All rights reserved. +*/ + +#include <linux/clk-provider.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/regmap.h> +#include <linux/reset-controller.h> + +#include <dt-bindings/clock/qcom,dispcc-sdm845.h> +
Quoted 9 lines
drivers/clk/qcom/dispcc-sdm845.c line 19
Quoted 6 lines
drivers/clk/qcom/dispcc-sdm845.c new file +6
-0+#include "clk-alpha-pll.h" +#include "clk-branch.h" +#include "clk-pll.h" +#include "clk-rcg.h" +#include "clk-regmap.h" +#include "clk-regmap-divider.h" Used?
Unused ones I would clean up.
Quoted 11 lines
drivers/clk/qcom/dispcc-sdm845.c line 24
Quoted 5 lines
drivers/clk/qcom/dispcc-sdm845.c new file +5
-0+#include "common.h" +#include "gdsc.h" +#include "reset.h" + +#define F (f, s, h, m, n) { (f), (s), (2 * (h) - 1), (m), (n) }We really need to move this into the header file.
$ git grep '#define F(' -- drivers/clk/qcom/ | wc -l 13
Sure, will move this in a header and submit the patch.
Quoted 16 lines
Quoted 1 line
drivers/clk/qcom/dispcc-sdm845.c new file +1
-0+[...]
drivers/clk/qcom/dispcc-sdm845.c line 95
Quoted 11 lines
drivers/clk/qcom/dispcc-sdm845.c new file +11
-0+static const char *const disp_cc_parent_names_4[] = { +"bi_tcxo" , +"dsi0_phy_pll_out_dsiclk" , +"dsi1_phy_pll_out_dsiclk" , +"core_bi_pll_test_se" , +}; + +static const struct alpha_pll_config disp_cc_pll0_config = { + .l =0x2c , + .alpha =0xcaaa , +};Any reason this can't be put on the stack in the probe function?
I would move it.
Quoted 14 lines
Quoted 13 lines
drivers/clk/qcom/dispcc-sdm845.c new file +13
-0+ +static struct clk_alpha_pll disp_cc_pll0 = { + .offset =0x0 , + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA ], + .clkr = { + .hw.init = &(struct clk_init_data ){ + .name ="disp_cc_pll0" , + .parent_names = (const char *[]){"bi_tcxo" }, + .num_parents =1 , + .ops = &clk_alpha_pll_fabia_ops, + }, + }, +};[...]
Quoted 14 lines
drivers/clk/qcom/dispcc-sdm845.c line 207
Quoted 11 lines
drivers/clk/qcom/dispcc-sdm845.c new file +11
-0+ +static struct clk_rcg2 disp_cc_mdss_pclk0_clk_src = { + .cmd_rcgr =0x2058 , + .mnd_width =8 , + .hid_width =5 , + .parent_map = disp_cc_parent_map_4, + .clkr.hw.init = &(struct clk_init_data ){ + .name ="disp_cc_mdss_pclk0_clk_src" , + .parent_names = disp_cc_parent_names_4, + .num_parents =4 , + .flags =CLK_SET_RATE_PARENT |CLK_GET_RATE_NOCACHE ,Why is the nocache flag needed? Applies to all clks in this file.
This flag is required for all RCGs whose PLLs are controlled outside the clock controller. The display code would require the recalculated rate always.
Quoted 11 lines
Quoted 10 lines
drivers/clk/qcom/dispcc-sdm845.c new file +10
-0+ .ops = &clk_pixel_ops, + }, +}; + +static struct clk_rcg2 disp_cc_mdss_pclk1_clk_src = { + .cmd_rcgr =0x2070 , + .mnd_width =8 , + .hid_width =5 , + .parent_map = disp_cc_parent_map_4, + .clkr.hw.init = &(struct clk_init_data ){[...]
Quoted 9 lines
drivers/clk/qcom/dispcc-sdm845.c line 623
Quoted 6 lines
drivers/clk/qcom/dispcc-sdm845.c new file +6
-0+ +static const struct regmap_config disp_cc_sdm845_regmap_config = { + .reg_bits =32 , + .reg_stride =4 , + .val_bits =32 , + .max_register =0x10000 ,This seems arbitrarily large. List the actual end?
The actual end is larger than this :( , I have listed the range till the register offset are used here.
Quoted 24 lines
Quoted 24 lines
drivers/clk/qcom/dispcc-sdm845.c new file +24
-0+ .fast_io = true, +}; + +static const struct qcom_cc_desc disp_cc_sdm845_desc = { + .config = &disp_cc_sdm845_regmap_config, + .clks = disp_cc_sdm845_clocks, + .num_clks =ARRAY_SIZE (disp_cc_sdm845_clocks), + .resets = disp_cc_sdm845_resets, + .num_resets =ARRAY_SIZE (disp_cc_sdm845_resets), + .gdscs = disp_cc_sdm845_gdscs, + .num_gdscs =ARRAY_SIZE (disp_cc_sdm845_gdscs), +}; + +static const struct of_device_id disp_cc_sdm845_match_table[] = { + { .compatible ="qcom,sdm845-dispcc" }, + { } +}; +MODULE_DEVICE_TABLE (of, disp_cc_sdm845_match_table); + +static int disp_cc_sdm845_probe (struct platform_device *pdev) +{ +struct regmap *regmap; + + regmap =qcom_cc_map (pdev, &disp_cc_sdm845_desc);
Quoted 9 lines
drivers/clk/qcom/dispcc-sdm845.c line 653
Quoted 6 lines
drivers/clk/qcom/dispcc-sdm845.c new file +6
-0+if (IS_ERR (regmap)) +return PTR_ERR (regmap); + +clk_fabia_pll_configure (&disp_cc_pll0, regmap, &disp_cc_pll0_config); + +/* Enable clock gating for DSI and MDP clocks */ Hardware clock gating? What does this mean.
These are used for deciding whether to enable HW based Clock gating or not. Setting these bit will enable HW based Clock gating.
Quoted 4 lines
Quoted 4 lines
drivers/clk/qcom/dispcc-sdm845.c new file +4
-0+regmap_update_bits (regmap,0x8000 ,0x7f0 ,0x7f0 ); + +return qcom_cc_really_probe (pdev, &disp_cc_sdm845_desc, regmap); +}
Signature · 4 lines
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 display clock controller driver for SDM845
Quoting Taniya Das (2018-06-13 02:18:59)
Quoted 20 lines
Hello Stephen,
Thanks for review.
Quoted 15 lines · Stephen Boyd
Quoting Taniya Das (2018-06-04 00:56:25)
drivers/clk/qcom/dispcc-sdm845.c line 24
Quoted 11 lines
drivers/clk/qcom/dispcc-sdm845.c new file +5
-0+#include "common.h" +#include "gdsc.h" +#include "reset.h" + +#define F (f, s, h, m, n) { (f), (s), (2 * (h) - 1), (m), (n) }We really need to move this into the header file.
Quoted 4 lines
Quoted 3 lines
$ git grep '#define F(' -- drivers/clk/qcom/ | wc -l 13Sure, will move this in a header and submit the patch.
Thanks!
Quoted 29 lines
Quoted 14 lines
Quoted 13 lines
drivers/clk/qcom/dispcc-sdm845.c new file +13
-0+ +static struct clk_alpha_pll disp_cc_pll0 = { + .offset =0x0 , + .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA ], + .clkr = { + .hw.init = &(struct clk_init_data ){ + .name ="disp_cc_pll0" , + .parent_names = (const char *[]){"bi_tcxo" }, + .num_parents =1 , + .ops = &clk_alpha_pll_fabia_ops, + }, + }, +};[...]
Quoted 14 lines
drivers/clk/qcom/dispcc-sdm845.c line 207
Quoted 11 lines
drivers/clk/qcom/dispcc-sdm845.c new file +11
-0+ +static struct clk_rcg2 disp_cc_mdss_pclk0_clk_src = { + .cmd_rcgr =0x2058 , + .mnd_width =8 , + .hid_width =5 , + .parent_map = disp_cc_parent_map_4, + .clkr.hw.init = &(struct clk_init_data ){ + .name ="disp_cc_mdss_pclk0_clk_src" , + .parent_names = disp_cc_parent_names_4, + .num_parents =4 , + .flags =CLK_SET_RATE_PARENT |CLK_GET_RATE_NOCACHE ,Why is the nocache flag needed? Applies to all clks in this file.
Quoted 3 lines
This flag is required for all RCGs whose PLLs are controlled outside the clock controller. The display code would require the recalculated rate always.
That doesn't really answer the question. It seems to describe some sort of problem with the PLL being controlled outside the clk controller/clk framework. Please add more details and comments into the code here.
Quoted 21 lines
Quoted 12 lines
Quoted 11 lines
drivers/clk/qcom/dispcc-sdm845.c new file +10
-0+ .ops = &clk_pixel_ops, + }, +}; + +static struct clk_rcg2 disp_cc_mdss_pclk1_clk_src = { + .cmd_rcgr =0x2070 , + .mnd_width =8 , + .hid_width =5 , + .parent_map = disp_cc_parent_map_4, + .clkr.hw.init = &(struct clk_init_data ){[...]
Quoted 9 lines
drivers/clk/qcom/dispcc-sdm845.c line 623
Quoted 6 lines
drivers/clk/qcom/dispcc-sdm845.c new file +6
-0+ +static const struct regmap_config disp_cc_sdm845_regmap_config = { + .reg_bits =32 , + .reg_stride =4 , + .val_bits =32 , + .max_register =0x10000 ,This seems arbitrarily large. List the actual end?
Quoted 2 lines
The actual end is larger than this :( , I have listed the range till the register offset are used here.
Ok.
Quoted 34 lines
Quoted 25 lines
Quoted 25 lines
drivers/clk/qcom/dispcc-sdm845.c new file +24
-0+ .fast_io = true, +}; + +static const struct qcom_cc_desc disp_cc_sdm845_desc = { + .config = &disp_cc_sdm845_regmap_config, + .clks = disp_cc_sdm845_clocks, + .num_clks =ARRAY_SIZE (disp_cc_sdm845_clocks), + .resets = disp_cc_sdm845_resets, + .num_resets =ARRAY_SIZE (disp_cc_sdm845_resets), + .gdscs = disp_cc_sdm845_gdscs, + .num_gdscs =ARRAY_SIZE (disp_cc_sdm845_gdscs), +}; + +static const struct of_device_id disp_cc_sdm845_match_table[] = { + { .compatible ="qcom,sdm845-dispcc" }, + { } +}; +MODULE_DEVICE_TABLE (of, disp_cc_sdm845_match_table); + +static int disp_cc_sdm845_probe (struct platform_device *pdev) +{ +struct regmap *regmap; + + regmap =qcom_cc_map (pdev, &disp_cc_sdm845_desc);Quoted 9 lines
drivers/clk/qcom/dispcc-sdm845.c line 653
Quoted 6 lines
drivers/clk/qcom/dispcc-sdm845.c new file +6
-0+if (IS_ERR (regmap)) +return PTR_ERR (regmap); + +clk_fabia_pll_configure (&disp_cc_pll0, regmap, &disp_cc_pll0_config); + +/* Enable clock gating for DSI and MDP clocks */ Hardware clock gating? What does this mean.
Quoted 2 lines
These are used for deciding whether to enable HW based Clock gating or not. Setting these bit will enable HW based Clock gating.
Please state it's hardware clock gating then in the comment.
Quoted 6 lines
Quoted 5 lines
Quoted 5 lines
drivers/clk/qcom/dispcc-sdm845.c new file +4
-0+regmap_update_bits (regmap,0x8000 ,0x7f0 ,0x7f0 ); + +return qcom_cc_really_probe (pdev, &disp_cc_sdm845_desc, regmap); +}