Add Global Clock controller (GCC) driver for SC7180
Subsystems (6)
v4 cover Add Global Clock controller (GCC) driver for SC7180
[v4]
* convert current documentation to YAML schemas.
* Update license to use GPL-2.0-only.
* define nvmem-cells/nvmem-cell-names only for the required compatible.
* split the dt-bindings for SC7180 to a separate patch.
* remove registering the CRITICAL clocks to clock provider and leave them always ON from the GCC probe.
* Return NULL from qcom_cc_clk_hw_get where clk hw is not registered.
* gcc_sc7180_init moved from subsys to core init.
[v3]
* Remove old documentation and fix comments for binding.
* Cleanup few CRITICAL clocks and add comments for the CRITICAL clocks.
* Add reference clocks for UFS & USB.
[v2]
* Update the DFS macro for RCG to reflect the hw init similar to clock name.
* Update the Documentation binding of GCC to YAML schemas.
* Add comments for CRITICAL clocks, remove PLL forward declarations and unwanted comments/prints.
[v1]
* Add driver support for Global Clock controller for SC7180 and also update device tree bindings for the various clocks supported in the clock controller.
Taniya Das (5):
clk: qcom: rcg: update the DFS macro for RCG
clk: qcom: common: Return NULL from clk_hw OF provider
dt-bindings: clock: Add YAML schemas for the QCOM GCC clock bindings
dt-bindings: clock: Introduce QCOM GCC clock bindings
clk: qcom: Add Global Clock controller (GCC) driver for SC7180
.../devicetree/bindings/clock/qcom,gcc.txt | 94 - .../devicetree/bindings/clock/qcom,gcc.yaml | 188 ++ drivers/clk/qcom/Kconfig | 9 + drivers/clk/qcom/Makefile | 1 + drivers/clk/qcom/clk-rcg.h | 2 +- drivers/clk/qcom/common.c | 2 +- drivers/clk/qcom/gcc-sc7180.c | 2450 +++++++++++++++++ drivers/clk/qcom/gcc-sdm845.c | 96 +- include/dt-bindings/clock/qcom,gcc-sc7180.h | 155 ++ 9 files changed, 2853 insertions(+), 144 deletions(-) delete mode 100644 Documentation/devicetree/bindings/clock/qcom,gcc.txt create mode 100644 Documentation/devicetree/bindings/clock/qcom,gcc.yaml create mode 100644 drivers/clk/qcom/gcc-sc7180.c create mode 100644 include/dt-bindings/clock/qcom,gcc-sc7180.h
--
Qualcomm INDIA, on behalf of Qualcomm Innovation Center, Inc.is a member of the Code Aurora Forum, hosted by the Linux Foundation.
PATCH v4 1/5 clk: qcom: rcg: update the DFS macro for RCG
Update the init data name for each of the dynamic frequency switch controlled clock associated with the RCG clock name, so that it can be generated as per the hardware plan. Thus update the macro accordingly.
--- drivers/clk/qcom/clk-rcg.h | 2 +- drivers/clk/qcom/gcc-sdm845.c | 96 +++++++++++++++++------------------ 2 files changed, 49 insertions(+), 49 deletions(-)
drivers/clk/qcom/clk-rcg.h +1 -1
@@ -168,7 +168,7 @@ struct clk_rcg_dfs_data { };#define DEFINE_RCG_DFS (r) \ - { .rcg = &r##_src, .init = &r##_init } + { .rcg = &r, .init = &r##_init } extern int qcom_cc_register_rcg_dfs(struct regmap *regmap, const struct clk_rcg_dfs_data *rcgs,
drivers/clk/qcom/gcc-sdm845.c +48 -48
234 lines not on this page · raw message
Signature · 2 lines
Qualcomm INDIA, on behalf of Qualcomm Innovation Center, Inc.is a member of the Code Aurora Forum, hosted by the Linux Foundation.
Re: [PATCH v4 1/5] clk: qcom: rcg: update the DFS macro for RCG
Quoting Taniya Das (2019-10-14 03:23:04)
Quoted 6 lines
Update the init data name for each of the dynamic frequency switch controlled clock associated with the RCG clock name, so that it can be generated as per the hardware plan. Thus update the macro accordingly.
Signed-off-by Taniya Das <[email protected]>---
Applied to clk-next
PATCH v4 2/5 clk: qcom: common: Return NULL from clk_hw OF provider
In reply to Taniya DasReturn NULL in the cases where the clk_hw is not registered with the clock provider, but the clock consumer still requests for a clock id.
--- drivers/clk/qcom/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/qcom/common.c +1 -1
@@ -218,7 +218,7 @@ static struct clk_hw *qcom_cc_clk_hw_get(struct of_phandle_args *clkspec,return ERR_PTR (-EINVAL ); } -return cc->rclks[idx] ? &cc->rclks[idx]->hw :ERR_PTR (-ENOENT ); +return cc->rclks[idx] ? &cc->rclks[idx]->hw :NULL ; } int qcom_cc_really_probe(struct platform_device *pdev,
--
Qualcomm INDIA, on behalf of Qualcomm Innovation Center, Inc.is a member of the Code Aurora Forum, hosted by the Linux Foundation.
Re: [PATCH v4 2/5] clk: qcom: common: Return NULL from clk_hw OF provider
Quoting Taniya Das (2019-10-14 03:23:05)
Quoted 5 lines
Return NULL in the cases where the
clk_hwis not registered with the clock provider, but the clock consumer still requests for a clock id.Signed-off-by Taniya Das <[email protected]>---
Applied to clk-next
PATCH v4 3/5 dt-bindings: clock: Add YAML schemas for the QCOM GCC clock bindings
In reply to Taniya DasThe GCC clock provider have a bunch of generic properties that are needed in a device tree. Add a YAML schemas for those.
--- .../devicetree/bindings/clock/qcom,gcc.txt | 94 ---------- .../devicetree/bindings/clock/qcom,gcc.yaml | 174 ++++++++++++++++++ 2 files changed, 174 insertions(+), 94 deletions(-) delete mode 100644 Documentation/devicetree/bindings/clock/qcom,gcc.txt create mode 100644 Documentation/devicetree/bindings/clock/qcom,gcc.yaml
Documentation/devicetree/bindings/clock/qcom,gcc.txt deleted +0 -94
@@ -1,94 +0,0 @@ -Qualcomm Global Clock & Reset Controller Binding ------------------------------------------------- - -Required properties : -- compatible : shall contain only one of the following: - - "qcom,gcc-apq8064" - "qcom,gcc-apq8084" - "qcom,gcc-ipq8064" - "qcom,gcc-ipq4019" - "qcom,gcc-ipq8074" - "qcom,gcc-msm8660" - "qcom,gcc-msm8916" - "qcom,gcc-msm8960" - "qcom,gcc-msm8974" - "qcom,gcc-msm8974pro" - "qcom,gcc-msm8974pro-ac" - "qcom,gcc-msm8994" - "qcom,gcc-msm8996" - "qcom,gcc-msm8998" - "qcom,gcc-mdm9615" - "qcom,gcc-qcs404" - "qcom,gcc-sdm630" - "qcom,gcc-sdm660" - "qcom,gcc-sdm845" - "qcom,gcc-sm8150" - -- reg : shall contain base register location and length -- #clock-cells : shall contain 1 -- #reset-cells : shall contain 1 - -Optional properties : -- #power-domain-cells : shall contain 1 -- Qualcomm TSENS (thermal sensor device) on some devices can -be part of GCC and hence the TSENS properties can also be -part of the GCC/clock-controller node. -For more details on the TSENS properties please refer -Documentation/devicetree/bindings/thermal/qcom-tsens.txt -- protected-clocks : Protected clock specifier list as per common clock - binding. - -For SM8150 only: - - clocks: a list of phandles and clock-specifier pairs, - one for each entry in clock-names. - - clock-names: "bi_tcxo" (required) - "sleep_clk" (optional) - "aud_ref_clock" (optional) - -Example: - clock-controller@900000 { - compatible = "qcom,gcc-msm8960"; - reg = <0x900000 0x4000>; - #clock-cells = <1>; - #reset-cells = <1>; - #power-domain-cells = <1>; - }; - -Example of GCC with TSENS properties: - clock-controller@900000 { - compatible = "qcom,gcc-apq8064"; - reg = <0x00900000 0x4000>; - nvmem-cells = <&tsens_calib>, <&tsens_backup>; - nvmem-cell-names = "calib", "calib_backup"; - #clock-cells = <1>; - #reset-cells = <1>; - #thermal-sensor-cells = <1>; - }; - -Example of GCC with protected-clocks properties: - clock-controller@100000 { - compatible = "qcom,gcc-sdm845"; - reg = <0x100000 0x1f0000>; - #clock-cells = <1>; - #reset-cells = <1>; - #power-domain-cells = <1>; - protected-clocks = <GCC_QSPI_CORE_CLK>, - <GCC_QSPI_CORE_CLK_SRC>, - <GCC_QSPI_CNOC_PERIPH_AHB_CLK>, - <GCC_LPASS_Q6_AXI_CLK>, - <GCC_LPASS_SWAY_CLK>; - }; - -Example of GCC with clocks - gcc: clock-controller@100000 { - compatible = "qcom,gcc-sm8150"; - reg = <0x00100000 0x1f0000>; - #clock-cells = <1>; - #reset-cells = <1>; - #power-domain-cells = <1>; - clock-names = "bi_tcxo", - "sleep_clk"; - clocks = <&rpmcc RPM_SMD_XO_CLK_SRC>, - <&sleep_clk>; - };
Documentation/devicetree/bindings/clock/qcom,gcc.yaml new file +174 -0
174 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.
Re: [PATCH v4 3/5] dt-bindings: clock: Add YAML schemas for the QCOM GCC clock bindings
Quoted 11 lines · Taniya Das
The GCC clock provider have a bunch of generic properties that are needed in a device tree. Add a YAML schemas for those.
Signed-off-by Taniya Das <[email protected]>--- .../devicetree/bindings/clock/qcom,gcc.txt | 94 ---------- .../devicetree/bindings/clock/qcom,gcc.yaml | 174 ++++++++++++++++++ 2 files changed, 174 insertions(+), 94 deletions(-) delete mode 100644 Documentation/devicetree/bindings/clock/qcom,gcc.txt create mode 100644 Documentation/devicetree/bindings/clock/qcom,gcc.yaml
Re: [PATCH v4 3/5] dt-bindings: clock: Add YAML schemas for the QCOM GCC clock bindings
In reply to Taniya DasQuoting Taniya Das (2019-10-14 03:23:06)
Quoted 5 lines
The GCC clock provider have a bunch of generic properties that are needed in a device tree. Add a YAML schemas for those.
Signed-off-by Taniya Das <[email protected]>---
Applied to clk-next
PATCH v4 4/5 dt-bindings: clock: Introduce QCOM GCC clock bindings
In reply to Taniya DasAdd device tree bindings for Global clock subsystem clock controller for Qualcomm Technology Inc's SC7180 SoCs.
--- .../devicetree/bindings/clock/qcom,gcc.yaml | 14 ++ include/dt-bindings/clock/qcom,gcc-sc7180.h | 155 ++++++++++++++++++ 2 files changed, 169 insertions(+) create mode 100644 include/dt-bindings/clock/qcom,gcc-sc7180.h
Documentation/devicetree/bindings/clock/qcom,gcc.yaml +14 -0
@@ -37,6 +37,7 @@ properties: - qcom,gcc-sdm660 - qcom,gcc-sdm845 - qcom,gcc-sm8150 + - qcom,gcc-sc7180 clocks: minItems: 1
@@ -118,6 +119,7 @@ else: contains: enum: - qcom,gcc-sm8150 + - qcom,gcc-sc7180 then: required: - clocks
@@ -171,4 +173,16 @@ examples: #reset-cells = <1>; #power-domain-cells = <1>; }; + + # Example of GCC with clock nodes properties for SC7180: + - | + clock-controller@100000 { + compatible = "qcom,gcc-sc7180"; + reg = <0x100000 0x1f0000>; + clocks = <&rpmhcc 0>, <&rpmhcc 1>; + clock-names = "bi_tcxo", "bi_tcxo_ao"; + #clock-cells = <1>; + #reset-cells = <1>; + #power-domain-cells = <1>; + }; ...
include/dt-bindings/clock/qcom,gcc-sc7180.h new file +155 -0
155 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.
Re: [PATCH v4 4/5] dt-bindings: clock: Introduce QCOM GCC clock bindings
Quoted 10 lines · Taniya Das
Add device tree bindings for Global clock subsystem clock controller for Qualcomm Technology Inc's SC7180 SoCs.
Signed-off-by Taniya Das <[email protected]>--- .../devicetree/bindings/clock/qcom,gcc.yaml | 14 ++ include/dt-bindings/clock/qcom,gcc-sc7180.h | 155 ++++++++++++++++++ 2 files changed, 169 insertions(+) create mode 100644 include/dt-bindings/clock/qcom,gcc-sc7180.h
Re: [PATCH v4 4/5] dt-bindings: clock: Introduce QCOM GCC clock bindings
In reply to Taniya DasQuoting Taniya Das (2019-10-14 03:23:07)
Quoted 5 lines
Add device tree bindings for Global clock subsystem clock controller for Qualcomm Technology Inc's SC7180 SoCs.
Signed-off-by Taniya Das <[email protected]>---
Applied to clk-next
PATCH v4 5/5 clk: qcom: Add Global Clock controller (GCC) driver for SC7180
In reply to Taniya DasAdd support for the global clock controller found on SC7180 based devices. This should allow most non-multimedia device drivers to probe and control their clocks.
--- drivers/clk/qcom/Kconfig | 9 + drivers/clk/qcom/Makefile | 1 + drivers/clk/qcom/gcc-sc7180.c | 2450 +++++++++++++++++++++++++++++++++ 3 files changed, 2460 insertions(+) create mode 100644 drivers/clk/qcom/gcc-sc7180.c
drivers/clk/qcom/Kconfig +9 -0
@@ -227,6 +227,15 @@ config QCS_GCC_404 Say Y if you want to use multimedia devices or peripheral devices such as UART, SPI, I2C, USB, SD/eMMC, PCIe etc. +config SC_GCC_7180 + tristate "SC7180 Global Clock Controller" + select QCOM_GDSC + depends on COMMON_CLK_QCOM + help + Support for the global clock controller on SC7180 devices. + Say Y if you want to use peripheral devices such as UART, SPI, + I2C, USB, UFS, SDCC, etc. + config SDM_CAMCC_845 tristate "SDM845 Camera Clock Controller" select SDM_GCC_845
drivers/clk/qcom/Makefile +1 -0
@@ -43,6 +43,7 @@ obj-$(CONFIG_QCOM_CLK_RPMH) += clk-rpmh.o obj-$(CONFIG_QCOM_CLK_SMD_RPM) += clk-smd-rpm.o obj-$(CONFIG_QCS_GCC_404) += gcc-qcs404.o obj-$(CONFIG_QCS_TURING_404) += turingcc-qcs404.o +obj-$(CONFIG_SC_GCC_7180) += gcc-sc7180.o obj-$(CONFIG_SDM_CAMCC_845) += camcc-sdm845.o obj-$(CONFIG_SDM_DISPCC_845) += dispcc-sdm845.o obj-$(CONFIG_SDM_GCC_660) += gcc-sdm660.o
drivers/clk/qcom/gcc-sc7180.c new file +2450 -0
2,450 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.
Re: [PATCH v4 5/5] clk: qcom: Add Global Clock controller (GCC) driver for SC7180
Hi Taniya,
Quoted 60 lines · Taniya Das
Add support for the global clock controller found on SC7180 based devices. This should allow most non-multimedia device drivers to probe and control their clocks.
Signed-off-by Taniya Das <[email protected]>--- drivers/clk/qcom/Kconfig | 9 + drivers/clk/qcom/Makefile | 1 + drivers/clk/qcom/gcc-sc7180.c | 2450 +++++++++++++++++++++++++++++++++ 3 files changed, 2460 insertions(+) create mode 100644 drivers/clk/qcom/gcc-sc7180.cdrivers/clk/qcom/Kconfig +9
-0@@ -227,6 +227,15 @@ config QCS_GCC_404 Say Y if you want to use multimedia devices or peripheral devices such as UART, SPI, I2C, USB, SD/eMMC, PCIe etc. +config SC_GCC_7180 + tristate "SC7180 Global Clock Controller" + select QCOM_GDSC + depends on COMMON_CLK_QCOM + help + Support for the global clock controller on SC7180 devices. + Say Y if you want to use peripheral devices such as UART, SPI, + I2C, USB, UFS, SDCC, etc. + config SDM_CAMCC_845 tristate "SDM845 Camera Clock Controller" select SDM_GCC_845drivers/clk/qcom/Makefile +1
-0@@ -43,6 +43,7 @@ obj-$(CONFIG_QCOM_CLK_RPMH) += clk-rpmh.o obj-$(CONFIG_QCOM_CLK_SMD_RPM) += clk-smd-rpm.o obj-$(CONFIG_QCS_GCC_404) += gcc-qcs404.o obj-$(CONFIG_QCS_TURING_404) += turingcc-qcs404.o +obj-$(CONFIG_SC_GCC_7180) += gcc-sc7180.o obj-$(CONFIG_SDM_CAMCC_845) += camcc-sdm845.o obj-$(CONFIG_SDM_DISPCC_845) += dispcc-sdm845.o obj-$(CONFIG_SDM_GCC_660) += gcc-sdm660.odrivers/clk/qcom/gcc-sc7180.c new file +10
-0+static struct clk_hw *gcc_sc7180_hws[] = { + [GCC_GPLL0_MAIN_DIV_CDIV ] = &gcc_pll0_main_div_cdiv.hw, +}; + +static struct clk_regmap *gcc_sc7180_clocks[] = { + [GCC_AGGRE_UFS_PHY_AXI_CLK ] = &gcc_aggre_ufs_phy_axi_clk.clkr, + [GCC_AGGRE_USB3_PRIM_AXI_CLK ] = &gcc_aggre_usb3_prim_axi_clk.clkr, + [GCC_BOOT_ROM_AHB_CLK ] = &gcc_boot_rom_ahb_clk.clkr, + [GCC_CAMERA_AHB_CLK ] = &gcc_camera_ahb_clk.clkr, + [GCC_CAMERA_HF_AXI_CLK ] = &gcc_camera_hf_axi_clk.clkr,
drivers/clk/qcom/gcc-sc7180.c line 2229
Quoted 10 lines
drivers/clk/qcom/gcc-sc7180.c new file +10
-0+ [GCC_CAMERA_THROTTLE_HF_AXI_CLK] = &gcc_camera_throttle_hf_axi_clk.clkr, + [GCC_CAMERA_XO_CLK] = &gcc_camera_xo_clk.clkr, + [GCC_CE1_AHB_CLK] = &gcc_ce1_ahb_clk.clkr, + [GCC_CE1_AXI_CLK] = &gcc_ce1_axi_clk.clkr, + [GCC_CE1_CLK] = &gcc_ce1_clk.clkr, + [GCC_CFG_NOC_USB3_PRIM_AXI_CLK] = &gcc_cfg_noc_usb3_prim_axi_clk.clkr, + [GCC_CPUSS_AHB_CLK] = &gcc_cpuss_ahb_clk.clkr, + [GCC_CPUSS_AHB_CLK_SRC] = &gcc_cpuss_ahb_clk_src.clkr, + [GCC_CPUSS_RBCPR_CLK] = &gcc_cpuss_rbcpr_clk.clkr, + [GCC_DDRSS_GPU_AXI_CLK] = &gcc_ddrss_gpu_axi_clk.clkr,
v3 also had
+ [GCC_DISP_AHB_CLK] = &gcc_disp_ahb_clk.clkr,
Removing it makes the dpu_mdss driver unhappy:
[ 2.999855] dpu_mdss_enable+0x2c/0x58->msm_dss_enable_clk: 'iface' is not available
because:
mdss: mdss@ae00000 {
... => clocks = <&gcc GCC_DISP_AHB_CLK>,
<&gcc GCC_DISP_HF_AXI_CLK>,
<&dispcc DISP_CC_MDSS_MDP_CLK>;
clock-names = "iface", "gcc_bus", "core";
};More clocks were removed in v4:
- [GCC_CPUSS_GNOC_CLK] = &gcc_cpuss_gnoc_clk.clkr, - [GCC_GPU_CFG_AHB_CLK] = &gcc_gpu_cfg_ahb_clk.clkr, - [GCC_VIDEO_AHB_CLK] = &gcc_video_ahb_clk.clkr,
I guess this part of "remove registering the CRITICAL clocks to clock provider and leave them always ON from the GCC probe." (change log entry), but are you sure nobody is going to reference these clocks?
Quoted 6 lines
drivers/clk/qcom/gcc-sc7180.c new file +6
-0+static int gcc_sc7180_probe (struct platform_device *pdev) +{ +struct regmap *regmap; +int ret; + + regmap =qcom_cc_map (pdev, &gcc_sc7180_desc);
drivers/clk/qcom/gcc-sc7180.c line 2409
Quoted 10 lines
drivers/clk/qcom/gcc-sc7180.c new file +10
-0+if (IS_ERR (regmap)) +return PTR_ERR (regmap); + +/* +* Disable the GPLL0 active input to MM blocks, NPU +* and GPU via MISC registers. +*/ +regmap_update_bits (regmap,0x09ffc ,0x3 ,0x3 ); +regmap_update_bits (regmap,0x4d110 ,0x3 ,0x3 ); +regmap_update_bits (regmap,0x71028 ,0x3 ,0x3 );
In v3 this was:
regmap_update_bits(regmap, GCC_MMSS_MISC, 0x3, 0x3); regmap_update_bits(regmap, GCC_NPU_MISC, 0x3, 0x3); regmap_update_bits(regmap, GCC_GPU_MISC, 0x3, 0x3);
IMO register names seem preferable, why switch to literal addresses instead?
drivers/clk/qcom/gcc-sc7180.c line 2419
Quoted 10 lines
drivers/clk/qcom/gcc-sc7180.c new file +10
-0+ +/* +* Keep the clocks always-ON +* GCC_CPUSS_GNOC_CLK, GCC_VIDEO_AHB_CLK, GCC_DISP_AHB_CLK +* GCC_GPU_CFG_AHB_CLK +*/ +regmap_update_bits (regmap,0x48004 ,BIT (0 ),BIT (0 )); +regmap_update_bits (regmap,0x0b004 ,BIT (0 ),BIT (0 )); +regmap_update_bits (regmap,0x0b00c ,BIT (0 ),BIT (0 )); +regmap_update_bits (regmap,0x71004 ,BIT (0 ),BIT (0 ));
ditto, register names seem preferable.
Re: [PATCH v4 5/5] clk: qcom: Add Global Clock controller (GCC) driver for SC7180
Hi Matthias,
Thanks for your comments.
Quoted 20 lines · Matthias Kaehlcke
Hi Taniya,
Quoted 5 lines · Taniya Das
Add support for the global clock controller found on SC7180 based devices. This should allow most non-multimedia device drivers to probe and control their clocks.
Signed-off-by Taniya Das <[email protected]>v3 also had
(quoted diff) +1
-0+ [GCC_DISP_AHB_CLK] = &gcc_disp_ahb_clk.clkr,Removing it makes the
dpu_mdssdriver unhappy:[ 2.999855] dpu_mdss_enable+0x2c/0x58->msm_dss_enable_clk: 'iface' is not availablebecause:
Quoted 9 lines
mdss: mdss@ae00000 { ...=> clocks = <&gcc
GCC_DISP_AHB_CLK>,<&gcc GCC_DISP_HF_AXI_CLK>, <&dispcc DISP_CC_MDSS_MDP_CLK>; clock-names = "iface", "gcc_bus", "core"; };
The basic idea as you mentioned below was to move the CRITICAL clocks to probe. The clock provider to return NULL in case the clocks are not registered. This was discussed with Stephen on v3. Thus I submitted the below patch.
clk: qcom: common: Return NULL from clk_hw OF provider.
Yes it would throw these warnings, but no functional issue is observed from display. I have tested it on the cheza board. I guess we could fix the DRM driver to use the "devm_clk_get_optional()" instead?
Quoted 10 lines
More clocks were removed in v4:
(quoted diff) +0
-3- [GCC_CPUSS_GNOC_CLK] = &gcc_cpuss_gnoc_clk.clkr, - [GCC_GPU_CFG_AHB_CLK] = &gcc_gpu_cfg_ahb_clk.clkr, - [GCC_VIDEO_AHB_CLK] = &gcc_video_ahb_clk.clkr,I guess this part of "remove registering the CRITICAL clocks to clock provider and leave them always ON from the GCC probe." (change log entry), but are you sure nobody is going to reference these clocks?
Even if they are referenced clk provider would return NULL.
Quoted 19 lines
Quoted 6 lines
drivers/clk/qcom/gcc-sc7180.c new file +6
-0+static int gcc_sc7180_probe (struct platform_device *pdev) +{ +struct regmap *regmap; +int ret; + + regmap =qcom_cc_map (pdev, &gcc_sc7180_desc);drivers/clk/qcom/gcc-sc7180.c line 2409
Quoted 10 lines
drivers/clk/qcom/gcc-sc7180.c new file +10
-0+if (IS_ERR (regmap)) +return PTR_ERR (regmap); + +/* +* Disable the GPLL0 active input to MM blocks, NPU +* and GPU via MISC registers. +*/ +regmap_update_bits (regmap,0x09ffc ,0x3 ,0x3 ); +regmap_update_bits (regmap,0x4d110 ,0x3 ,0x3 ); +regmap_update_bits (regmap,0x71028 ,0x3 ,0x3 );In v3 this was:
Quoted 7 lines
regmap_update_bits(regmap, GCC_MMSS_MISC, 0x3, 0x3); regmap_update_bits(regmap, GCC_NPU_MISC, 0x3, 0x3); regmap_update_bits(regmap, GCC_GPU_MISC, 0x3, 0x3);IMO register names seem preferable, why switch to literal addresses instead?
:). These cleanups where done based on the comments I had received during SDM845 review. If Stephen is fine moving them to names, I could submit them in the next patch series.
Quoted 13 lines
drivers/clk/qcom/gcc-sc7180.c line 2419
Quoted 10 lines
drivers/clk/qcom/gcc-sc7180.c new file +10
-0+ +/* +* Keep the clocks always-ON +* GCC_CPUSS_GNOC_CLK, GCC_VIDEO_AHB_CLK, GCC_DISP_AHB_CLK +* GCC_GPU_CFG_AHB_CLK +*/ +regmap_update_bits (regmap,0x48004 ,BIT (0 ),BIT (0 )); +regmap_update_bits (regmap,0x0b004 ,BIT (0 ),BIT (0 )); +regmap_update_bits (regmap,0x0b00c ,BIT (0 ),BIT (0 )); +regmap_update_bits (regmap,0x71004 ,BIT (0 ),BIT (0 ));ditto, register names seem preferable.
Signature · 4 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation. --
Re: [PATCH v4 5/5] clk: qcom: Add Global Clock controller (GCC) driver for SC7180
Hi Taniya,
Quoted 28 lines · Taniya Das
Hi Matthias,
Thanks for your comments.
Quoted 23 lines · Matthias Kaehlcke
Hi Taniya,
Quoted 5 lines · Taniya Das
Add support for the global clock controller found on SC7180 based devices. This should allow most non-multimedia device drivers to probe and control their clocks.
Signed-off-by Taniya Das <[email protected]>v3 also had
(quoted diff) +1
-0+ [GCC_DISP_AHB_CLK] = &gcc_disp_ahb_clk.clkr,Removing it makes the
dpu_mdssdriver unhappy:[ 2.999855] dpu_mdss_enable+0x2c/0x58->msm_dss_enable_clk: 'iface' is not availablebecause:
mdss: mdss@ae00000 { ...
Quoted 12 lines
Quoted 6 lines
=> clocks = <&gcc
GCC_DISP_AHB_CLK>,<&gcc GCC_DISP_HF_AXI_CLK>, <&dispcc DISP_CC_MDSS_MDP_CLK>; clock-names = "iface", "gcc_bus", "core"; };The basic idea as you mentioned below was to move the CRITICAL clocks to probe. The clock provider to return NULL in case the clocks are not registered.
This was discussed with Stephen on v3. Thus I submitted the below patch.
clk: qcom: common: Return NULL fromclk_hwOF provider.
I see. My assumption was that the entire clock hierarchy should be registered, but Stephen almost certainly knows better :)
Quoted 2 lines
Yes it would throw these warnings, but no functional issue is observed from display. I have tested it on the cheza board.
The driver considers it an error (uses DEV_ERR to log the message) and doesn't handle other clocks when one is found missing. I'm not really famililar with the dpu_mdss driver, but I imagine this can have some side effects. Added some of the authors/contributors to cc.
Quoted 2 lines
I guess we could fix the DRM driver to use the "
devm_clk_get_optional()" instead?
It would also require a minor rework of the driver, which currently expects all specified clocks to be available.
Another option could be to not list the clock in the device tree, then the driver won't notice it as missing.
Quoted 36 lines
Quoted 10 lines
More clocks were removed in v4:
(quoted diff) +0
-3- [GCC_CPUSS_GNOC_CLK] = &gcc_cpuss_gnoc_clk.clkr, - [GCC_GPU_CFG_AHB_CLK] = &gcc_gpu_cfg_ahb_clk.clkr, - [GCC_VIDEO_AHB_CLK] = &gcc_video_ahb_clk.clkr,I guess this part of "remove registering the CRITICAL clocks to clock provider and leave them always ON from the GCC probe." (change log entry), but are you sure nobody is going to reference these clocks?
Even if they are referenced clk provider would return NULL.
Quoted 23 lines
Quoted 6 lines
drivers/clk/qcom/gcc-sc7180.c new file +6
-0+static int gcc_sc7180_probe (struct platform_device *pdev) +{ +struct regmap *regmap; +int ret; + + regmap =qcom_cc_map (pdev, &gcc_sc7180_desc);drivers/clk/qcom/gcc-sc7180.c line 2409
Quoted 10 lines
drivers/clk/qcom/gcc-sc7180.c new file +10
-0+if (IS_ERR (regmap)) +return PTR_ERR (regmap); + +/* +* Disable the GPLL0 active input to MM blocks, NPU +* and GPU via MISC registers. +*/ +regmap_update_bits (regmap,0x09ffc ,0x3 ,0x3 ); +regmap_update_bits (regmap,0x4d110 ,0x3 ,0x3 ); +regmap_update_bits (regmap,0x71028 ,0x3 ,0x3 );In v3 this was:
regmap_update_bits(regmap, GCC_MMSS_MISC, 0x3, 0x3); regmap_update_bits(regmap, GCC_NPU_MISC, 0x3, 0x3); regmap_update_bits(regmap, GCC_GPU_MISC, 0x3, 0x3);
Quoted 7 lines
Quoted 3 lines
IMO register names seem preferable, why switch to literal addresses instead?
:). These cleanups where done based on the comments I had received during SDM845 review. If Stephen is fine moving them to names, I could submit them in the next patch series.
Ok, thanks
Stephen Boyd
maintainerRe: [PATCH v4 5/5] clk: qcom: Add Global Clock controller (GCC) driver for SC7180
Quoting Matthias Kaehlcke (2019-10-31 10:41:49)
Quoted 47 lines
Hi Taniya,
Quoted 35 lines · Taniya Das
Hi Matthias,
Thanks for your comments.
Quoted 20 lines · Matthias Kaehlcke
Hi Taniya,
Quoted 5 lines · Taniya Das
Add support for the global clock controller found on SC7180 based devices. This should allow most non-multimedia device drivers to probe and control their clocks.
Signed-off-by Taniya Das <[email protected]>v3 also had
+ [
GCC_DISP_AHB_CLK] = &gcc_disp_ahb_clk.clkr,Removing it makes the
dpu_mdssdriver unhappy:[ 2.999855] dpu_mdss_enable+0x2c/0x58->msm_dss_enable_clk: 'iface' is not availablebecause:
Quoted 9 lines
mdss: mdss@ae00000 { ...=> clocks = <&gcc GCC_DISP_AHB_CLK>, <&gcc GCC_DISP_HF_AXI_CLK>, <&dispcc DISP_CC_MDSS_MDP_CLK>; clock-names = "iface", "gcc_bus", "core"; };Quoted 5 lines
The basic idea as you mentioned below was to move the CRITICAL clocks to probe. The clock provider to return NULL in case the clocks are not registered.
This was discussed with Stephen on v3. Thus I submitted the below patch.
clk: qcom: common: Return NULL fromclk_hwOF provider.I see. My assumption was that the entire clock hierarchy should be registered, but Stephen almost certainly knows better :)
Quoted 7 lines
Quoted 2 lines
Yes it would throw these warnings, but no functional issue is observed from display. I have tested it on the cheza board.
The driver considers it an error (uses
DEV_ERRto log the message) and doesn't handle other clocks when one is found missing. I'm not really famililar with thedpu_mdssdriver, but I imagine this can have some side effects. Added some of the authors/contributors to cc.
NULL is a valid clk pointer returned by clk_get(). What is the display driver doing that makes it consider NULL an error?
Re: [PATCH v4 5/5] clk: qcom: Add Global Clock controller (GCC) driver for SC7180
Quoted 52 lines · Stephen Boyd
Quoting Matthias Kaehlcke (2019-10-31 10:41:49)
Quoted 50 lines
Hi Taniya,
Quoted 35 lines · Taniya Das
Hi Matthias,
Thanks for your comments.
Quoted 20 lines · Matthias Kaehlcke
Hi Taniya,
Quoted 5 lines · Taniya Das
Add support for the global clock controller found on SC7180 based devices. This should allow most non-multimedia device drivers to probe and control their clocks.
Signed-off-by Taniya Das <[email protected]>v3 also had
+ [
GCC_DISP_AHB_CLK] = &gcc_disp_ahb_clk.clkr,Removing it makes the
dpu_mdssdriver unhappy:[ 2.999855] dpu_mdss_enable+0x2c/0x58->msm_dss_enable_clk: 'iface' is not availablebecause:
Quoted 9 lines
mdss: mdss@ae00000 { ...=> clocks = <&gcc GCC_DISP_AHB_CLK>, <&gcc GCC_DISP_HF_AXI_CLK>, <&dispcc DISP_CC_MDSS_MDP_CLK>; clock-names = "iface", "gcc_bus", "core"; };Quoted 5 lines
The basic idea as you mentioned below was to move the CRITICAL clocks to probe. The clock provider to return NULL in case the clocks are not registered.
This was discussed with Stephen on v3. Thus I submitted the below patch.
clk: qcom: common: Return NULL fromclk_hwOF provider.I see. My assumption was that the entire clock hierarchy should be registered, but Stephen almost certainly knows better :)
Quoted 2 lines
Yes it would throw these warnings, but no functional issue is observed from display. I have tested it on the cheza board.
Quoted 8 lines
Quoted 4 lines
The driver considers it an error (uses
DEV_ERRto log the message) and doesn't handle other clocks when one is found missing. I'm not really famililar with thedpu_mdssdriver, but I imagine this can have some side effects. Added some of the authors/contributors to cc.NULL is a valid clk pointer returned by
clk_get(). What is the display driver doing that makes it consider NULL an error?
do we not have an iface clk? I think the driver assumes we should have one, rather than it being an optional thing.. we could ofc change that
BR,
-R
Stephen Boyd
maintainerRe: [PATCH v4 5/5] clk: qcom: Add Global Clock controller (GCC) driver for SC7180
Quoting Rob Clark (2019-11-07 18:06:19)
Quoted 58 lines · Stephen Boyd
Quoted 57 lines
Quoting Matthias Kaehlcke (2019-10-31 10:41:49)
Quoted 54 lines
Hi Taniya,
Quoted 35 lines · Taniya Das
Hi Matthias,
Thanks for your comments.
Quoted 20 lines · Matthias Kaehlcke
Hi Taniya,
Quoted 5 lines · Taniya Das
Add support for the global clock controller found on SC7180 based devices. This should allow most non-multimedia device drivers to probe and control their clocks.
Signed-off-by Taniya Das <[email protected]>v3 also had
+ [
GCC_DISP_AHB_CLK] = &gcc_disp_ahb_clk.clkr,Removing it makes the
dpu_mdssdriver unhappy:[ 2.999855] dpu_mdss_enable+0x2c/0x58->msm_dss_enable_clk: 'iface' is not availablebecause:
Quoted 9 lines
mdss: mdss@ae00000 { ...=> clocks = <&gcc GCC_DISP_AHB_CLK>, <&gcc GCC_DISP_HF_AXI_CLK>, <&dispcc DISP_CC_MDSS_MDP_CLK>; clock-names = "iface", "gcc_bus", "core"; };Quoted 5 lines
The basic idea as you mentioned below was to move the CRITICAL clocks to probe. The clock provider to return NULL in case the clocks are not registered.
This was discussed with Stephen on v3. Thus I submitted the below patch.
clk: qcom: common: Return NULL fromclk_hwOF provider.I see. My assumption was that the entire clock hierarchy should be registered, but Stephen almost certainly knows better :)
Quoted 2 lines
Yes it would throw these warnings, but no functional issue is observed from display. I have tested it on the cheza board.
The driver considers it an error (uses
DEV_ERRto log the message) and doesn't handle other clocks when one is found missing. I'm not really famililar with thedpu_mdssdriver, but I imagine this can have some side effects. Added some of the authors/contributors to cc.
Quoted 7 lines
Quoted 3 lines
NULL is a valid clk pointer returned by
clk_get(). What is the display driver doing that makes it consider NULL an error?do we not have an iface clk? I think the driver assumes we should have one, rather than it being an optional thing.. we could ofc change that
I think some sort of AHB clk is always enabled so the plan is to just hand back NULL to the caller when they call clk_get() on it and nobody should be the wiser when calling clk APIs with a NULL iface clk. The common clk APIs typically just return 0 and move along. Of course, we'll also turn the clk on in the clk driver so that hardware can function properly, but we don't need to expose it as a clk object and all that stuff if we're literally just slamming a bit somewhere and never looking back.
But it sounds like we can't return NULL for this clk for some reason? I haven't tried to track it down yet but I think Matthias has found it causes some sort of problem in the display driver.
Re: [PATCH v4 5/5] clk: qcom: Add Global Clock controller (GCC) driver for SC7180
Quoted 77 lines · Stephen Boyd
Quoting Rob Clark (2019-11-07 18:06:19)
Quoted 58 lines · Stephen Boyd
Quoted 57 lines
Quoting Matthias Kaehlcke (2019-10-31 10:41:49)
Quoted 54 lines
Hi Taniya,
Quoted 35 lines · Taniya Das
Hi Matthias,
Thanks for your comments.
Quoted 20 lines · Matthias Kaehlcke
Hi Taniya,
Quoted 5 lines · Taniya Das
Add support for the global clock controller found on SC7180 based devices. This should allow most non-multimedia device drivers to probe and control their clocks.
Signed-off-by Taniya Das <[email protected]>v3 also had
+ [
GCC_DISP_AHB_CLK] = &gcc_disp_ahb_clk.clkr,Removing it makes the
dpu_mdssdriver unhappy:[ 2.999855] dpu_mdss_enable+0x2c/0x58->msm_dss_enable_clk: 'iface' is not availablebecause:
Quoted 9 lines
mdss: mdss@ae00000 { ...=> clocks = <&gcc GCC_DISP_AHB_CLK>, <&gcc GCC_DISP_HF_AXI_CLK>, <&dispcc DISP_CC_MDSS_MDP_CLK>; clock-names = "iface", "gcc_bus", "core"; };Quoted 5 lines
The basic idea as you mentioned below was to move the CRITICAL clocks to probe. The clock provider to return NULL in case the clocks are not registered.
This was discussed with Stephen on v3. Thus I submitted the below patch.
clk: qcom: common: Return NULL fromclk_hwOF provider.I see. My assumption was that the entire clock hierarchy should be registered, but Stephen almost certainly knows better :)
Quoted 2 lines
Yes it would throw these warnings, but no functional issue is observed from display. I have tested it on the cheza board.
The driver considers it an error (uses
DEV_ERRto log the message) and doesn't handle other clocks when one is found missing. I'm not really famililar with thedpu_mdssdriver, but I imagine this can have some side effects. Added some of the authors/contributors to cc.Quoted 7 lines
Quoted 3 lines
NULL is a valid clk pointer returned by
clk_get(). What is the display driver doing that makes it consider NULL an error?do we not have an iface clk? I think the driver assumes we should have one, rather than it being an optional thing.. we could ofc change that
I think some sort of AHB clk is always enabled so the plan is to just hand back NULL to the caller when they call
clk_get()on it and nobody should be the wiser when calling clk APIs with a NULL iface clk. The common clk APIs typically just return 0 and move along. Of course, we'll also turn the clk on in the clk driver so that hardware can function properly, but we don't need to expose it as a clk object and all that stuff if we're literally just slamming a bit somewhere and never looking back.
Quoted 4 lines
But it sounds like we can't return NULL for this clk for some reason? I haven't tried to track it down yet but I think Matthias has found it causes some sort of problem in the display driver.
ok, I guess we can change the dpu code to allow NULL.. but what would the return be, for example on a different SoC where we do have an iface clk, but the clk driver isn't enabled? Would that also return NULL? I guess it would be nice to differentiate between those cases..
BR,
-R
Stephen Boyd
maintainerRe: [PATCH v4 5/5] clk: qcom: Add Global Clock controller (GCC) driver for SC7180
Quoting Rob Clark (2019-11-08 08:54:23)
Quoted 28 lines · Stephen Boyd
Quoted 22 lines
Quoting Rob Clark (2019-11-07 18:06:19)
Quoted 10 lines · Stephen Boyd
Quoted 5 lines
NULL is a valid clk pointer returned by
clk_get(). What is the display driver doing that makes it consider NULL an error?do we not have an iface clk? I think the driver assumes we should have one, rather than it being an optional thing.. we could ofc change that
I think some sort of AHB clk is always enabled so the plan is to just hand back NULL to the caller when they call
clk_get()on it and nobody should be the wiser when calling clk APIs with a NULL iface clk. The common clk APIs typically just return 0 and move along. Of course, we'll also turn the clk on in the clk driver so that hardware can function properly, but we don't need to expose it as a clk object and all that stuff if we're literally just slamming a bit somewhere and never looking back.Quoted 4 lines
But it sounds like we can't return NULL for this clk for some reason? I haven't tried to track it down yet but I think Matthias has found it causes some sort of problem in the display driver.
Quoted 5 lines
ok, I guess we can change the dpu code to allow NULL.. but what would the return be, for example on a different SoC where we do have an iface clk, but the clk driver isn't enabled? Would that also return NULL? I guess it would be nice to differentiate between those cases..
So the scenario is DT describes the clk
dpu_node {
clocks = <&cc AHB_CLK>;
clock-names = "iface";}
but the &cc node has a driver that doesn't probe?
I believe in this scenario we return -EPROBE_DEFER because we assume we should wait for the clk driver to probe and provide the iface clk. See of_clk_get_hw_from_clkspec() and how it looks through a list of clk providers and tries to match the &cc phandle to some provider.
Once the driver probes, the match will happen and we'll be able to look up the clk in the provider with __of_clk_get_hw_from_provider(). If the clk provider decides that there isn't a clk object, it will return NULL and then eventually clk_hw_create_clk() will turn the NULL return value into a NULL pointer to return from clk_get().
Re: [PATCH v4 5/5] clk: qcom: Add Global Clock controller (GCC) driver for SC7180
Quoted 50 lines · Stephen Boyd
Quoting Rob Clark (2019-11-08 08:54:23)
Quoted 28 lines · Stephen Boyd
Quoted 22 lines
Quoting Rob Clark (2019-11-07 18:06:19)
Quoted 10 lines · Stephen Boyd
Quoted 5 lines
NULL is a valid clk pointer returned by
clk_get(). What is the display driver doing that makes it consider NULL an error?do we not have an iface clk? I think the driver assumes we should have one, rather than it being an optional thing.. we could ofc change that
I think some sort of AHB clk is always enabled so the plan is to just hand back NULL to the caller when they call
clk_get()on it and nobody should be the wiser when calling clk APIs with a NULL iface clk. The common clk APIs typically just return 0 and move along. Of course, we'll also turn the clk on in the clk driver so that hardware can function properly, but we don't need to expose it as a clk object and all that stuff if we're literally just slamming a bit somewhere and never looking back.Quoted 4 lines
But it sounds like we can't return NULL for this clk for some reason? I haven't tried to track it down yet but I think Matthias has found it causes some sort of problem in the display driver.
Quoted 5 lines
ok, I guess we can change the dpu code to allow NULL.. but what would the return be, for example on a different SoC where we do have an iface clk, but the clk driver isn't enabled? Would that also return NULL? I guess it would be nice to differentiate between those cases..
So the scenario is DT describes the clk
dpu_node { clocks = <&cc AHB_CLK>; clock-names = "iface";}
but the &cc node has a driver that doesn't probe?
I believe in this scenario we return -EPROBE_DEFER because we assume we should wait for the clk driver to probe and provide the iface clk. See
of_clk_get_hw_from_clkspec()and how it looks through a list of clk providers and tries to match the &cc phandle to some provider.
Quoted 6 lines
Once the driver probes, the match will happen and we'll be able to look up the clk in the provider with
__of_clk_get_hw_from_provider(). If the clk provider decides that there isn't a clk object, it will return NULL and then eventuallyclk_hw_create_clk()will turn the NULL return value into a NULL pointer to return fromclk_get().
ok, that was the scenario I was worried about (since unclk'd register access tends to be insta-reboot and hard to debug).. so I think it should be ok to make dpu just ignore NULL clks.
From a quick look, I think something like the attached (untested). (Sorry, I'd just paste it inline but gmail somehow eats all the whitespace when I do that :-/)
From 0a31adb5994d5df4c3393687b4c6084005502247 Mon Sep 17 00:00:00 2001
From: Rob Clark <[email protected]>
Date: Fri, 8 Nov 2019 11:38:46 -0800
Subject: [PATCH] drm/msm/dpu: ignore NULL clocks
This isn't an error. Also the clk APIs handle the NULL case, so we can just delete the check.
--- drivers/gpu/drm/msm/disp/dpu1/dpu_io_util.c | 26 ++++++--------------- 1 file changed, 7 insertions(+), 19 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_io_util.c +7 -19
@@ -93,19 +93,12 @@ int msm_dss_enable_clk(struct dss_clk *clk_arry, int num_clk, int enable)DEV_DBG ("%pS->%s: enable '%s'\n" ,__builtin_return_address (0 ), __func__, clk_arry[i].clk_name); -if (clk_arry[i].clk) { - rc =clk_prepare_enable (clk_arry[i].clk); -if (rc) -DEV_ERR ("%pS->%s: %s en fail. rc=%d\n" , -__builtin_return_address (0 ), - __func__, - clk_arry[i].clk_name, rc); - }else { -DEV_ERR ("%pS->%s: '%s' is not available\n" , -__builtin_return_address (0 ), __func__, - clk_arry[i].clk_name); - rc = -EPERM ; - } + rc =clk_prepare_enable (clk_arry[i].clk); +if (rc) +DEV_ERR ("%pS->%s: %s en fail. rc=%d\n" , +__builtin_return_address (0 ), + __func__, + clk_arry[i].clk_name, rc);if (rc && i) { msm_dss_enable_clk(&clk_arry[i - 1],
@@ -119,12 +112,7 @@ int msm_dss_enable_clk(struct dss_clk *clk_arry, int num_clk, int enable)__builtin_return_address (0 ), __func__, clk_arry[i].clk_name); -if (clk_arry[i].clk) -clk_disable_unprepare (clk_arry[i].clk); -else -DEV_ERR ("%pS->%s: '%s' is not available\n" , -__builtin_return_address (0 ), __func__, - clk_arry[i].clk_name); +clk_disable_unprepare (clk_arry[i].clk); } }
Signature · 1 line
2.24.0.432.g9d3f5f5b63-goog
Stephen Boyd
maintainerRe: [PATCH v4 5/5] clk: qcom: Add Global Clock controller (GCC) driver for SC7180
Quoting Rob Clark (2019-11-08 11:40:53)
Quoted 23 lines · Stephen Boyd
Quoted 15 lines
So the scenario is DT describes the clk
dpu_node { clocks = <&cc AHB_CLK>; clock-names = "iface";}
but the &cc node has a driver that doesn't probe?
I believe in this scenario we return -EPROBE_DEFER because we assume we should wait for the clk driver to probe and provide the iface clk. See
of_clk_get_hw_from_clkspec()and how it looks through a list of clk providers and tries to match the &cc phandle to some provider.Quoted 6 lines
Once the driver probes, the match will happen and we'll be able to look up the clk in the provider with
__of_clk_get_hw_from_provider(). If the clk provider decides that there isn't a clk object, it will return NULL and then eventuallyclk_hw_create_clk()will turn the NULL return value into a NULL pointer to return fromclk_get().
Quoted 7 lines
ok, that was the scenario I was worried about (since unclk'd register access tends to be insta-reboot and hard to debug).. so I think it should be ok to make dpu just ignore NULL clks.
From a quick look, I think something like the attached (untested). (Sorry, I'd just paste it inline but gmail somehow eats all the whitespace when I do that :-/)
Cool. Looks good to me.
Re: [PATCH v4 5/5] clk: qcom: Add Global Clock controller (GCC) driver for SC7180
In reply to Rob ClarkQuoted 58 lines · Rob Clark
Quoted 50 lines · Stephen Boyd
Quoting Rob Clark (2019-11-08 08:54:23)
Quoted 28 lines · Stephen Boyd
Quoted 22 lines
Quoting Rob Clark (2019-11-07 18:06:19)
Quoted 10 lines · Stephen Boyd
Quoted 5 lines
NULL is a valid clk pointer returned by
clk_get(). What is the display driver doing that makes it consider NULL an error?do we not have an iface clk? I think the driver assumes we should have one, rather than it being an optional thing.. we could ofc change that
I think some sort of AHB clk is always enabled so the plan is to just hand back NULL to the caller when they call
clk_get()on it and nobody should be the wiser when calling clk APIs with a NULL iface clk. The common clk APIs typically just return 0 and move along. Of course, we'll also turn the clk on in the clk driver so that hardware can function properly, but we don't need to expose it as a clk object and all that stuff if we're literally just slamming a bit somewhere and never looking back.Quoted 4 lines
But it sounds like we can't return NULL for this clk for some reason? I haven't tried to track it down yet but I think Matthias has found it causes some sort of problem in the display driver.
Quoted 5 lines
ok, I guess we can change the dpu code to allow NULL.. but what would the return be, for example on a different SoC where we do have an iface clk, but the clk driver isn't enabled? Would that also return NULL? I guess it would be nice to differentiate between those cases..
So the scenario is DT describes the clk
dpu_node { clocks = <&cc AHB_CLK>; clock-names = "iface";}
but the &cc node has a driver that doesn't probe?
I believe in this scenario we return -EPROBE_DEFER because we assume we should wait for the clk driver to probe and provide the iface clk. See
of_clk_get_hw_from_clkspec()and how it looks through a list of clk providers and tries to match the &cc phandle to some provider.Quoted 6 lines
Once the driver probes, the match will happen and we'll be able to look up the clk in the provider with
__of_clk_get_hw_from_provider(). If the clk provider decides that there isn't a clk object, it will return NULL and then eventuallyclk_hw_create_clk()will turn the NULL return value into a NULL pointer to return fromclk_get().
Quoted 5 lines
ok, that was the scenario I was worried about (since unclk'd register access tends to be insta-reboot and hard to debug).. so I think it should be ok to make dpu just ignore NULL clks.
From a quick look, I think something like the attached (untested).
The driver appears to be happy with it, at least at probe() time.
Re: [PATCH v4 5/5] clk: qcom: Add Global Clock controller (GCC) driver for SC7180
Quoted 60 lines · Matthias Kaehlcke
Quoted 58 lines · Rob Clark
Quoted 56 lines · Stephen Boyd
Quoting Rob Clark (2019-11-08 08:54:23)
Quoted 28 lines · Stephen Boyd
Quoted 22 lines
Quoting Rob Clark (2019-11-07 18:06:19)
Quoted 10 lines · Stephen Boyd
Quoted 5 lines
NULL is a valid clk pointer returned by
clk_get(). What is the display driver doing that makes it consider NULL an error?do we not have an iface clk? I think the driver assumes we should have one, rather than it being an optional thing.. we could ofc change that
I think some sort of AHB clk is always enabled so the plan is to just hand back NULL to the caller when they call
clk_get()on it and nobody should be the wiser when calling clk APIs with a NULL iface clk. The common clk APIs typically just return 0 and move along. Of course, we'll also turn the clk on in the clk driver so that hardware can function properly, but we don't need to expose it as a clk object and all that stuff if we're literally just slamming a bit somewhere and never looking back.Quoted 4 lines
But it sounds like we can't return NULL for this clk for some reason? I haven't tried to track it down yet but I think Matthias has found it causes some sort of problem in the display driver.
Quoted 5 lines
ok, I guess we can change the dpu code to allow NULL.. but what would the return be, for example on a different SoC where we do have an iface clk, but the clk driver isn't enabled? Would that also return NULL? I guess it would be nice to differentiate between those cases..
So the scenario is DT describes the clk
dpu_node { clocks = <&cc AHB_CLK>; clock-names = "iface";}
but the &cc node has a driver that doesn't probe?
I believe in this scenario we return -EPROBE_DEFER because we assume we should wait for the clk driver to probe and provide the iface clk. See
of_clk_get_hw_from_clkspec()and how it looks through a list of clk providers and tries to match the &cc phandle to some provider.Once the driver probes, the match will happen and we'll be able to look up the clk in the provider with
__of_clk_get_hw_from_provider(). If the clk provider decides that there isn't a clk object, it will return NULL and then eventuallyclk_hw_create_clk()will turn the NULL return value into a NULL pointer to return fromclk_get().
Quoted 7 lines
Quoted 5 lines
ok, that was the scenario I was worried about (since unclk'd register access tends to be insta-reboot and hard to debug).. so I think it should be ok to make dpu just ignore NULL clks.
From a quick look, I think something like the attached (untested).
The driver appears to be happy with it, at least at
probe()time.
Ok, I suppose I should re-send the dpu patch to the appropriate lists.. does that count as a Tested-by?
BR,
-R
Re: [PATCH v4 5/5] clk: qcom: Add Global Clock controller (GCC) driver for SC7180
Quoted 65 lines · Rob Clark
Quoted 64 lines · Matthias Kaehlcke
Quoted 62 lines · Rob Clark
Quoted 50 lines · Stephen Boyd
Quoting Rob Clark (2019-11-08 08:54:23)
Quoted 28 lines · Stephen Boyd
Quoted 22 lines
Quoting Rob Clark (2019-11-07 18:06:19)
Quoted 10 lines · Stephen Boyd
Quoted 5 lines
NULL is a valid clk pointer returned by
clk_get(). What is the display driver doing that makes it consider NULL an error?do we not have an iface clk? I think the driver assumes we should have one, rather than it being an optional thing.. we could ofc change that
I think some sort of AHB clk is always enabled so the plan is to just hand back NULL to the caller when they call
clk_get()on it and nobody should be the wiser when calling clk APIs with a NULL iface clk. The common clk APIs typically just return 0 and move along. Of course, we'll also turn the clk on in the clk driver so that hardware can function properly, but we don't need to expose it as a clk object and all that stuff if we're literally just slamming a bit somewhere and never looking back.Quoted 4 lines
But it sounds like we can't return NULL for this clk for some reason? I haven't tried to track it down yet but I think Matthias has found it causes some sort of problem in the display driver.
Quoted 5 lines
ok, I guess we can change the dpu code to allow NULL.. but what would the return be, for example on a different SoC where we do have an iface clk, but the clk driver isn't enabled? Would that also return NULL? I guess it would be nice to differentiate between those cases..
So the scenario is DT describes the clk
dpu_node { clocks = <&cc AHB_CLK>; clock-names = "iface";}
but the &cc node has a driver that doesn't probe?
I believe in this scenario we return -EPROBE_DEFER because we assume we should wait for the clk driver to probe and provide the iface clk. See
of_clk_get_hw_from_clkspec()and how it looks through a list of clk providers and tries to match the &cc phandle to some provider.Quoted 6 lines
Once the driver probes, the match will happen and we'll be able to look up the clk in the provider with
__of_clk_get_hw_from_provider(). If the clk provider decides that there isn't a clk object, it will return NULL and then eventuallyclk_hw_create_clk()will turn the NULL return value into a NULL pointer to return fromclk_get().ok, that was the scenario I was worried about (since unclk'd register access tends to be insta-reboot and hard to debug).. so I think it should be ok to make dpu just ignore NULL clks.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
From a quick look, I think something like the attached (untested).
The driver appears to be happy with it, at least at
probe()time.Ok, I suppose I should re-send the dpu patch to the appropriate lists.. does that count as a Tested-by?
Ack
Re: [PATCH v4 5/5] clk: qcom: Add Global Clock controller (GCC) driver for SC7180
In reply to Taniya DasQuoting Taniya Das (2019-10-14 03:23:08)
Quoted 6 lines
Add support for the global clock controller found on SC7180 based devices. This should allow most non-multimedia device drivers to probe and control their clocks.
Signed-off-by Taniya Das <[email protected]>---
Applied to clk-next
Re: [PATCH v4 5/5] clk: qcom: Add Global Clock controller (GCC) driver for SC7180
In reply to Taniya DasQuoted 49 lines · Taniya Das
Add support for the global clock controller found on SC7180 based devices. This should allow most non-multimedia device drivers to probe and control their clocks.
Signed-off-by Taniya Das <[email protected]>--- drivers/clk/qcom/Kconfig | 9 + drivers/clk/qcom/Makefile | 1 + drivers/clk/qcom/gcc-sc7180.c | 2450 +++++++++++++++++++++++++++++++++ 3 files changed, 2460 insertions(+) create mode 100644 drivers/clk/qcom/gcc-sc7180.cdrivers/clk/qcom/Kconfig +9
-0@@ -227,6 +227,15 @@ config QCS_GCC_404 Say Y if you want to use multimedia devices or peripheral devices such as UART, SPI, I2C, USB, SD/eMMC, PCIe etc. +config SC_GCC_7180 + tristate "SC7180 Global Clock Controller" + select QCOM_GDSC + depends on COMMON_CLK_QCOM + help + Support for the global clock controller on SC7180 devices. + Say Y if you want to use peripheral devices such as UART, SPI, + I2C, USB, UFS, SDCC, etc. + config SDM_CAMCC_845 tristate "SDM845 Camera Clock Controller" select SDM_GCC_845drivers/clk/qcom/Makefile +1
-0@@ -43,6 +43,7 @@ obj-$(CONFIG_QCOM_CLK_RPMH) += clk-rpmh.o obj-$(CONFIG_QCOM_CLK_SMD_RPM) += clk-smd-rpm.o obj-$(CONFIG_QCS_GCC_404) += gcc-qcs404.o obj-$(CONFIG_QCS_TURING_404) += turingcc-qcs404.o +obj-$(CONFIG_SC_GCC_7180) += gcc-sc7180.o obj-$(CONFIG_SDM_CAMCC_845) += camcc-sdm845.o obj-$(CONFIG_SDM_DISPCC_845) += dispcc-sdm845.o obj-$(CONFIG_SDM_GCC_660) += gcc-sdm660.odrivers/clk/qcom/gcc-sc7180.c new file +0
-0
drivers/clk/qcom/gcc-sc7180.c line 2441
Quoted 6 lines
drivers/clk/qcom/gcc-sc7180.c new file +5
-0+static int __init gcc_sc7180_init (void ) +{ +return platform_driver_register (&gcc_sc7180_driver); +} +core_initcall (gcc_sc7180_init);
This was a subsys_initcall in v3. In combination with the MSS clock driver for SC7180 (not posted yet) the change 'causes' an abort:
[ 4.892250] DBG: clk_is_enabled_regmap: mss_axi_nav_clk
[ 4.586124] Internal error: synchronous external abort: 96000010 [#1] PREEMPT SMP [ 4.593817] Modules linked in: [ 4.596976] CPU: 0 PID: 1 Comm: swapper/0 Tainted: G S W 5.4.0-rc6 #27 [ 4.604843] Hardware name: Qualcomm Technologies, Inc. SC7180 IDP (DT) [ 4.611550] pstate: 20c00089 (nzCv daIf +PAN +UAO) [ 4.616484] pc : regmap_mmio_read32le+0x20/0x40 [ 4.621140] lr : regmap_mmio_read+0x44/0x6c [ 4.625443] sp : ffffffc01005bb10 [ 4.628863] x29: ffffffc01005bb20 x28: 0000000000000000 [ 4.634331] x27: 0000000000000000 x26: 0000000000000000 [ 4.639787] x25: 0000000000000000 x24: ffffffd9a8ae1018 [ 4.645244] x23: ffffffd9a8e12148 x22: ffffff8177292800 [ 4.650712] x21: 00000000000000bc x20: ffffff8177342d80 [ 4.656168] x19: 00000000000000bc x18: 0000000059d6eecd [ 4.661635] x17: 00000000765f46d1 x16: 00000000bbaf844b [ 4.667103] x15: 0000000098366c8e x14: 4000000000000000 [ 4.672559] x13: ffffff8174b43b30 x12: 0000000000000000 [ 4.678015] x11: 0000000000000000 x10: 0000000000000000 [ 4.683482] x9 : 0000000000000001 x8 : ffffffc0100250bc [ 4.688949] x7 : 0000000000000008 x6 : 0000000000000000 [ 4.694416] x5 : 0000000000000000 x4 : 0000000000000000 [ 4.699873] x3 : 0000000000000000 x2 : ffffffc01005bc04 [ 4.705340] x1 : 00000000000000bc x0 : ffffff8177342d80 [ 4.710807] Call trace: [ 4.713330] regmap_mmio_read32le+0x20/0x40 [ 4.717634] regmap_mmio_read+0x44/0x6c [ 4.721591] _regmap_bus_reg_read+0x34/0x44 [ 4.725895] _regmap_read+0x88/0x16c [ 4.729580] regmap_read+0x54/0x78 [ 4.733088] clk_is_enabled_regmap+0x34/0x84 [ 4.737478] clk_core_is_enabled+0x68/0xac [ 4.741699] clk_disable_unused_subtree+0x90/0x23c [ 4.746621] clk_disable_unused+0x44/0x108 [ 4.750844] do_one_initcall+0x120/0x2bc [ 4.754886] do_initcall_level+0x14c/0x174 [ 4.759105] do_basic_setup+0x30/0x48 [ 4.762876] kernel_init_freeable+0xc4/0x144 [ 4.767266] kernel_init+0x14/0x100 [ 4.770855] ret_from_fork+0x10/0x18 [ 4.774546] Code: aa0003f4 d503201f f9400288 8b334108 (b9400100) [ 4.780813] ---[ end trace e75cb36fe5e38dd3 ]--- [ 4.791327] Kernel panic - not syncing: Fatal exception [ 4.796710] SMP: stopping secondary CPUs [ 4.801330] Kernel Offset: 0x1997c00000 from 0xffffffc010000000 [ 4.807414] PHYS_OFFSET: 0xfffffff180000000 [ 4.811718] CPU features: 0x0006,2a80aa18 [ 4.815841] Memory Limit: none [ 4.824753] ---[ end Kernel panic - not syncing: Fatal exception ]---
I understand that we don't care too much about the MSS clock driver at this point since it is out of tree, just wanted to mention it, maybe it helps saving a bit of time debugging later on.