devfreq test

parent e5d28b08
......@@ -1509,11 +1509,15 @@ gic: interrupt-controller@38800000 {
ddrc: memory-controller@3d400000 {
compatible = "fsl,imx8mq-ddrc", "fsl,imx8m-ddrc";
reg = <0x3d400000 0x400000>;
clock-names = "core", "pll", "alt", "apb";
clock-names = "core", "pll", "alt", "apb", "main_axi", "ahb", "osc_25m", "sys2_pll_333m";
clocks = <&clk IMX8MQ_CLK_DRAM_CORE>,
<&clk IMX8MQ_DRAM_PLL_OUT>,
<&clk IMX8MQ_CLK_DRAM_ALT>,
<&clk IMX8MQ_CLK_DRAM_APB>;
<&clk IMX8MQ_CLK_DRAM_APB>,
<&clk IMX8MQ_CLK_MAIN_AXI>,
<&clk IMX8MQ_CLK_AHB>,
<&clk IMX8MQ_CLK_25M>,
<&clk IMX8MQ_SYS2_PLL_333M>;
};
ddr-pmu@3d800000 {
......
......@@ -71,6 +71,10 @@ struct imx8m_ddrc {
struct clk *dram_pll;
struct clk *dram_alt;
struct clk *dram_apb;
struct clk *main_axi;
struct clk *ahb;
struct clk *sys2_pll_333m;
struct clk *osc_25m;
int freq_count;
struct imx8m_ddrc_freq freq_table[IMX8M_DDRC_MAX_FREQ_COUNT];
......@@ -268,6 +272,14 @@ static int imx8m_ddrc_target(struct device *dev, unsigned long *freq, u32 flags)
dev_dbg(dev, "ddrc freq set to %lu (was %lu)\n",
*freq, old_freq);
if (DIV_ROUND_CLOSEST(new_freq, 250000) == 100) {
clk_set_rate(priv->ahb, 22222222);
clk_set_parent(priv->main_axi, priv->osc_25m);
} else {
clk_set_rate(priv->ahb, 133333333);
clk_set_parent(priv->main_axi, priv->sys2_pll_333m);
}
return ret;
}
......@@ -418,6 +430,30 @@ static int imx8m_ddrc_probe(struct platform_device *pdev)
dev_err(dev, "failed to fetch apb clock: %d\n", ret);
return ret;
}
priv->main_axi = devm_clk_get(dev, "main_axi");
if (IS_ERR(priv->main_axi)) {
ret = PTR_ERR(priv->main_axi);
dev_err(dev, "failed to fetch main_axi clock: %d\n", ret);
return ret;
}
priv->ahb = devm_clk_get(dev, "ahb");
if (IS_ERR(priv->ahb)) {
ret = PTR_ERR(priv->ahb);
dev_err(dev, "failed to fetch ahb clock: %d\n", ret);
return ret;
}
priv->osc_25m = devm_clk_get(dev, "osc_25m");
if (IS_ERR(priv->osc_25m)) {
ret = PTR_ERR(priv->osc_25m);
dev_err(dev, "failed to fetch osc_25m clock: %d\n", ret);
return ret;
}
priv->sys2_pll_333m = devm_clk_get(dev, "sys2_pll_333m");
if (IS_ERR(priv->sys2_pll_333m)) {
ret = PTR_ERR(priv->sys2_pll_333m);
dev_err(dev, "failed to fetch sys2_pll_333m clock: %d\n", ret);
return ret;
}
ret = dev_pm_opp_of_add_table(dev);
if (ret < 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment