Message ID | 20230512001334.2983048-4-dmitry.baryshkov@linaro.org |
---|---|
State | Accepted |
Commit | 12dc71953e664f084918d3e1b63b211b0e6f8e98 |
Headers | show |
Series | clk: qcom: msm8996: add support for the CBF clock | expand |
On Fri, May 12, 2023 at 03:13:33AM +0300, Dmitry Baryshkov wrote: > Turn CBF into the interconnect provider. Scale CBF frequency (bandwidth) > according to CPU frequencies. > > Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org> > Tested-by: Yassine Oudjana <y.oudjana@protonmail.com> > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Georgi, Dmitry tells me that you picked up the interconnect patches, I don't see an immutable branch in your tree with them, but this patch has a build time dependency on them. Could you please pick this through your tree as well? Acked-by: Bjorn Andersson <andersson@kernel.org> Regards, Bjorn > --- > drivers/clk/qcom/Kconfig | 1 + > drivers/clk/qcom/clk-cbf-8996.c | 60 ++++++++++++++++++++++++++++++++- > 2 files changed, 60 insertions(+), 1 deletion(-) > > diff --git a/drivers/clk/qcom/Kconfig b/drivers/clk/qcom/Kconfig > index 12be3e2371b3..85869e7a9f16 100644 > --- a/drivers/clk/qcom/Kconfig > +++ b/drivers/clk/qcom/Kconfig > @@ -48,6 +48,7 @@ config QCOM_CLK_APCS_MSM8916 > config QCOM_CLK_APCC_MSM8996 > tristate "MSM8996 CPU Clock Controller" > select QCOM_KRYO_L2_ACCESSORS > + select INTERCONNECT_CLK if INTERCONNECT > depends on ARM64 > help > Support for the CPU clock controller on msm8996 devices. > diff --git a/drivers/clk/qcom/clk-cbf-8996.c b/drivers/clk/qcom/clk-cbf-8996.c > index cfd567636f4e..1e23b734abb3 100644 > --- a/drivers/clk/qcom/clk-cbf-8996.c > +++ b/drivers/clk/qcom/clk-cbf-8996.c > @@ -5,11 +5,15 @@ > #include <linux/bitfield.h> > #include <linux/clk.h> > #include <linux/clk-provider.h> > +#include <linux/interconnect-clk.h> > +#include <linux/interconnect-provider.h> > #include <linux/of.h> > #include <linux/module.h> > #include <linux/platform_device.h> > #include <linux/regmap.h> > > +#include <dt-bindings/interconnect/qcom,msm8996-cbf.h> > + > #include "clk-alpha-pll.h" > #include "clk-regmap.h" > > @@ -223,6 +227,49 @@ static const struct regmap_config cbf_msm8996_regmap_config = { > .val_format_endian = REGMAP_ENDIAN_LITTLE, > }; > > +#ifdef CONFIG_INTERCONNECT > + > +/* Random ID that doesn't clash with main qnoc and OSM */ > +#define CBF_MASTER_NODE 2000 > + > +static int qcom_msm8996_cbf_icc_register(struct platform_device *pdev, struct clk_hw *cbf_hw) > +{ > + struct device *dev = &pdev->dev; > + struct clk *clk = devm_clk_hw_get_clk(dev, cbf_hw, "cbf"); > + const struct icc_clk_data data[] = { > + { .clk = clk, .name = "cbf", }, > + }; > + struct icc_provider *provider; > + > + provider = icc_clk_register(dev, CBF_MASTER_NODE, ARRAY_SIZE(data), data); > + if (IS_ERR(provider)) > + return PTR_ERR(provider); > + > + platform_set_drvdata(pdev, provider); > + > + return 0; > +} > + > +static int qcom_msm8996_cbf_icc_remove(struct platform_device *pdev) > +{ > + struct icc_provider *provider = platform_get_drvdata(pdev); > + > + icc_clk_unregister(provider); > + > + return 0; > +} > +#define qcom_msm8996_cbf_icc_sync_state icc_sync_state > +#else > +static int qcom_msm8996_cbf_icc_register(struct platform_device *pdev, struct clk_hw *cbf_hw) > +{ > + dev_warn(&pdev->dev, "CONFIG_INTERCONNECT is disabled, CBF clock is fixed\n"); > + > + return 0; > +} > +#define qcom_msm8996_cbf_icc_remove(pdev) (0) > +#define qcom_msm8996_cbf_icc_sync_state NULL > +#endif > + > static int qcom_msm8996_cbf_probe(struct platform_device *pdev) > { > void __iomem *base; > @@ -281,7 +328,16 @@ static int qcom_msm8996_cbf_probe(struct platform_device *pdev) > if (ret) > return ret; > > - return devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, &cbf_mux.clkr.hw); > + ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, &cbf_mux.clkr.hw); > + if (ret) > + return ret; > + > + return qcom_msm8996_cbf_icc_register(pdev, &cbf_mux.clkr.hw); > +} > + > +static int qcom_msm8996_cbf_remove(struct platform_device *pdev) > +{ > + return qcom_msm8996_cbf_icc_remove(pdev); > } > > static const struct of_device_id qcom_msm8996_cbf_match_table[] = { > @@ -292,9 +348,11 @@ MODULE_DEVICE_TABLE(of, qcom_msm8996_cbf_match_table); > > static struct platform_driver qcom_msm8996_cbf_driver = { > .probe = qcom_msm8996_cbf_probe, > + .remove = qcom_msm8996_cbf_remove, > .driver = { > .name = "qcom-msm8996-cbf", > .of_match_table = qcom_msm8996_cbf_match_table, > + .sync_state = qcom_msm8996_cbf_icc_sync_state, > }, > }; > > -- > 2.39.2 >
On 10.06.23 3:18, Bjorn Andersson wrote: > On Fri, May 12, 2023 at 03:13:33AM +0300, Dmitry Baryshkov wrote: >> Turn CBF into the interconnect provider. Scale CBF frequency (bandwidth) >> according to CPU frequencies. >> >> Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org> >> Tested-by: Yassine Oudjana <y.oudjana@protonmail.com> >> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> > > Georgi, > > Dmitry tells me that you picked up the interconnect patches, I don't see > an immutable branch in your tree with them, but this patch has a build > time dependency on them. Could you please pick this through your tree as > well? It's done. Thanks a lot Bjorn! BR, Georgi > Acked-by: Bjorn Andersson <andersson@kernel.org> > > Regards, > Bjorn > >> --- >> drivers/clk/qcom/Kconfig | 1 + >> drivers/clk/qcom/clk-cbf-8996.c | 60 ++++++++++++++++++++++++++++++++- >> 2 files changed, 60 insertions(+), 1 deletion(-) >>
diff --git a/drivers/clk/qcom/Kconfig b/drivers/clk/qcom/Kconfig index 12be3e2371b3..85869e7a9f16 100644 --- a/drivers/clk/qcom/Kconfig +++ b/drivers/clk/qcom/Kconfig @@ -48,6 +48,7 @@ config QCOM_CLK_APCS_MSM8916 config QCOM_CLK_APCC_MSM8996 tristate "MSM8996 CPU Clock Controller" select QCOM_KRYO_L2_ACCESSORS + select INTERCONNECT_CLK if INTERCONNECT depends on ARM64 help Support for the CPU clock controller on msm8996 devices. diff --git a/drivers/clk/qcom/clk-cbf-8996.c b/drivers/clk/qcom/clk-cbf-8996.c index cfd567636f4e..1e23b734abb3 100644 --- a/drivers/clk/qcom/clk-cbf-8996.c +++ b/drivers/clk/qcom/clk-cbf-8996.c @@ -5,11 +5,15 @@ #include <linux/bitfield.h> #include <linux/clk.h> #include <linux/clk-provider.h> +#include <linux/interconnect-clk.h> +#include <linux/interconnect-provider.h> #include <linux/of.h> #include <linux/module.h> #include <linux/platform_device.h> #include <linux/regmap.h> +#include <dt-bindings/interconnect/qcom,msm8996-cbf.h> + #include "clk-alpha-pll.h" #include "clk-regmap.h" @@ -223,6 +227,49 @@ static const struct regmap_config cbf_msm8996_regmap_config = { .val_format_endian = REGMAP_ENDIAN_LITTLE, }; +#ifdef CONFIG_INTERCONNECT + +/* Random ID that doesn't clash with main qnoc and OSM */ +#define CBF_MASTER_NODE 2000 + +static int qcom_msm8996_cbf_icc_register(struct platform_device *pdev, struct clk_hw *cbf_hw) +{ + struct device *dev = &pdev->dev; + struct clk *clk = devm_clk_hw_get_clk(dev, cbf_hw, "cbf"); + const struct icc_clk_data data[] = { + { .clk = clk, .name = "cbf", }, + }; + struct icc_provider *provider; + + provider = icc_clk_register(dev, CBF_MASTER_NODE, ARRAY_SIZE(data), data); + if (IS_ERR(provider)) + return PTR_ERR(provider); + + platform_set_drvdata(pdev, provider); + + return 0; +} + +static int qcom_msm8996_cbf_icc_remove(struct platform_device *pdev) +{ + struct icc_provider *provider = platform_get_drvdata(pdev); + + icc_clk_unregister(provider); + + return 0; +} +#define qcom_msm8996_cbf_icc_sync_state icc_sync_state +#else +static int qcom_msm8996_cbf_icc_register(struct platform_device *pdev, struct clk_hw *cbf_hw) +{ + dev_warn(&pdev->dev, "CONFIG_INTERCONNECT is disabled, CBF clock is fixed\n"); + + return 0; +} +#define qcom_msm8996_cbf_icc_remove(pdev) (0) +#define qcom_msm8996_cbf_icc_sync_state NULL +#endif + static int qcom_msm8996_cbf_probe(struct platform_device *pdev) { void __iomem *base; @@ -281,7 +328,16 @@ static int qcom_msm8996_cbf_probe(struct platform_device *pdev) if (ret) return ret; - return devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, &cbf_mux.clkr.hw); + ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, &cbf_mux.clkr.hw); + if (ret) + return ret; + + return qcom_msm8996_cbf_icc_register(pdev, &cbf_mux.clkr.hw); +} + +static int qcom_msm8996_cbf_remove(struct platform_device *pdev) +{ + return qcom_msm8996_cbf_icc_remove(pdev); } static const struct of_device_id qcom_msm8996_cbf_match_table[] = { @@ -292,9 +348,11 @@ MODULE_DEVICE_TABLE(of, qcom_msm8996_cbf_match_table); static struct platform_driver qcom_msm8996_cbf_driver = { .probe = qcom_msm8996_cbf_probe, + .remove = qcom_msm8996_cbf_remove, .driver = { .name = "qcom-msm8996-cbf", .of_match_table = qcom_msm8996_cbf_match_table, + .sync_state = qcom_msm8996_cbf_icc_sync_state, }, };