clk: qcom: cbf-msm8996: scale CBF clock according to the CPUfreq

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>
Acked-by: Bjorn Andersson <andersson@kernel.org>
Link: https://lore.kernel.org/r/20230512001334.2983048-4-dmitry.baryshkov@linaro.org
Signed-off-by: Georgi Djakov <djakov@kernel.org>
This commit is contained in:
Dmitry Baryshkov 2023-05-12 03:13:33 +03:00 committed by Georgi Djakov
parent 0ac2a08f42
commit 12dc71953e
2 changed files with 60 additions and 1 deletions

View File

@ -48,6 +48,7 @@ config QCOM_CLK_APCS_MSM8916
config QCOM_CLK_APCC_MSM8996 config QCOM_CLK_APCC_MSM8996
tristate "MSM8996 CPU Clock Controller" tristate "MSM8996 CPU Clock Controller"
select QCOM_KRYO_L2_ACCESSORS select QCOM_KRYO_L2_ACCESSORS
select INTERCONNECT_CLK if INTERCONNECT
depends on ARM64 depends on ARM64
help help
Support for the CPU clock controller on msm8996 devices. Support for the CPU clock controller on msm8996 devices.

View File

@ -5,11 +5,15 @@
#include <linux/bitfield.h> #include <linux/bitfield.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/clk-provider.h> #include <linux/clk-provider.h>
#include <linux/interconnect-clk.h>
#include <linux/interconnect-provider.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <dt-bindings/interconnect/qcom,msm8996-cbf.h>
#include "clk-alpha-pll.h" #include "clk-alpha-pll.h"
#include "clk-regmap.h" #include "clk-regmap.h"
@ -223,6 +227,49 @@ static const struct regmap_config cbf_msm8996_regmap_config = {
.val_format_endian = REGMAP_ENDIAN_LITTLE, .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) static int qcom_msm8996_cbf_probe(struct platform_device *pdev)
{ {
void __iomem *base; void __iomem *base;
@ -281,7 +328,16 @@ static int qcom_msm8996_cbf_probe(struct platform_device *pdev)
if (ret) if (ret)
return 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[] = { 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 = { static struct platform_driver qcom_msm8996_cbf_driver = {
.probe = qcom_msm8996_cbf_probe, .probe = qcom_msm8996_cbf_probe,
.remove = qcom_msm8996_cbf_remove,
.driver = { .driver = {
.name = "qcom-msm8996-cbf", .name = "qcom-msm8996-cbf",
.of_match_table = qcom_msm8996_cbf_match_table, .of_match_table = qcom_msm8996_cbf_match_table,
.sync_state = qcom_msm8996_cbf_icc_sync_state,
}, },
}; };