mirror of https://github.com/torvalds/linux.git
clk: imx95-blk-ctl: Save platform data in imx95_blk_ctl structure
Add a platform data (pdata) member to struct imx95_blk_ctl to store the result of of_device_get_match_data() during probe to avoid redundant calls in suspend and resume functions. Signed-off-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com> Reviewed-by: Frank Li <Frank.Li@nxp.com> Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com> Reviewed-by: Abel Vesa <abel.vesa@linaro.org> Link: https://lore.kernel.org/r/20250804131450.3918846-2-laurentiu.palcu@oss.nxp.com Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
This commit is contained in:
parent
8f5ae30d69
commit
aa1735d72b
|
|
@ -36,6 +36,7 @@ struct imx95_blk_ctl {
|
||||||
void __iomem *base;
|
void __iomem *base;
|
||||||
/* clock gate register */
|
/* clock gate register */
|
||||||
u32 clk_reg_restore;
|
u32 clk_reg_restore;
|
||||||
|
const struct imx95_blk_ctl_dev_data *pdata;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct imx95_blk_ctl_clk_dev_data {
|
struct imx95_blk_ctl_clk_dev_data {
|
||||||
|
|
@ -349,7 +350,6 @@ static const struct imx95_blk_ctl_dev_data imx94_dispmix_csr_dev_data = {
|
||||||
static int imx95_bc_probe(struct platform_device *pdev)
|
static int imx95_bc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
const struct imx95_blk_ctl_dev_data *bc_data;
|
|
||||||
struct imx95_blk_ctl *bc;
|
struct imx95_blk_ctl *bc;
|
||||||
struct clk_hw_onecell_data *clk_hw_data;
|
struct clk_hw_onecell_data *clk_hw_data;
|
||||||
struct clk_hw **hws;
|
struct clk_hw **hws;
|
||||||
|
|
@ -379,25 +379,25 @@ static int imx95_bc_probe(struct platform_device *pdev)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bc_data = of_device_get_match_data(dev);
|
bc->pdata = of_device_get_match_data(dev);
|
||||||
if (!bc_data)
|
if (!bc->pdata)
|
||||||
return devm_of_platform_populate(dev);
|
return devm_of_platform_populate(dev);
|
||||||
|
|
||||||
clk_hw_data = devm_kzalloc(dev, struct_size(clk_hw_data, hws, bc_data->num_clks),
|
clk_hw_data = devm_kzalloc(dev, struct_size(clk_hw_data, hws, bc->pdata->num_clks),
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
if (!clk_hw_data)
|
if (!clk_hw_data)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
if (bc_data->rpm_enabled) {
|
if (bc->pdata->rpm_enabled) {
|
||||||
devm_pm_runtime_enable(&pdev->dev);
|
devm_pm_runtime_enable(&pdev->dev);
|
||||||
pm_runtime_resume_and_get(&pdev->dev);
|
pm_runtime_resume_and_get(&pdev->dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
clk_hw_data->num = bc_data->num_clks;
|
clk_hw_data->num = bc->pdata->num_clks;
|
||||||
hws = clk_hw_data->hws;
|
hws = clk_hw_data->hws;
|
||||||
|
|
||||||
for (i = 0; i < bc_data->num_clks; i++) {
|
for (i = 0; i < bc->pdata->num_clks; i++) {
|
||||||
const struct imx95_blk_ctl_clk_dev_data *data = &bc_data->clk_dev_data[i];
|
const struct imx95_blk_ctl_clk_dev_data *data = &bc->pdata->clk_dev_data[i];
|
||||||
void __iomem *reg = base + data->reg;
|
void __iomem *reg = base + data->reg;
|
||||||
|
|
||||||
if (data->type == CLK_MUX) {
|
if (data->type == CLK_MUX) {
|
||||||
|
|
@ -439,7 +439,7 @@ static int imx95_bc_probe(struct platform_device *pdev)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
for (i = 0; i < bc_data->num_clks; i++) {
|
for (i = 0; i < bc->pdata->num_clks; i++) {
|
||||||
if (IS_ERR_OR_NULL(hws[i]))
|
if (IS_ERR_OR_NULL(hws[i]))
|
||||||
continue;
|
continue;
|
||||||
clk_hw_unregister(hws[i]);
|
clk_hw_unregister(hws[i]);
|
||||||
|
|
@ -469,14 +469,9 @@ static int imx95_bc_runtime_resume(struct device *dev)
|
||||||
static int imx95_bc_suspend(struct device *dev)
|
static int imx95_bc_suspend(struct device *dev)
|
||||||
{
|
{
|
||||||
struct imx95_blk_ctl *bc = dev_get_drvdata(dev);
|
struct imx95_blk_ctl *bc = dev_get_drvdata(dev);
|
||||||
const struct imx95_blk_ctl_dev_data *bc_data;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
bc_data = of_device_get_match_data(dev);
|
if (bc->pdata->rpm_enabled) {
|
||||||
if (!bc_data)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (bc_data->rpm_enabled) {
|
|
||||||
ret = pm_runtime_get_sync(bc->dev);
|
ret = pm_runtime_get_sync(bc->dev);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
pm_runtime_put_noidle(bc->dev);
|
pm_runtime_put_noidle(bc->dev);
|
||||||
|
|
@ -484,7 +479,7 @@ static int imx95_bc_suspend(struct device *dev)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bc->clk_reg_restore = readl(bc->base + bc_data->clk_reg_offset);
|
bc->clk_reg_restore = readl(bc->base + bc->pdata->clk_reg_offset);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -492,15 +487,10 @@ static int imx95_bc_suspend(struct device *dev)
|
||||||
static int imx95_bc_resume(struct device *dev)
|
static int imx95_bc_resume(struct device *dev)
|
||||||
{
|
{
|
||||||
struct imx95_blk_ctl *bc = dev_get_drvdata(dev);
|
struct imx95_blk_ctl *bc = dev_get_drvdata(dev);
|
||||||
const struct imx95_blk_ctl_dev_data *bc_data;
|
|
||||||
|
|
||||||
bc_data = of_device_get_match_data(dev);
|
writel(bc->clk_reg_restore, bc->base + bc->pdata->clk_reg_offset);
|
||||||
if (!bc_data)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
writel(bc->clk_reg_restore, bc->base + bc_data->clk_reg_offset);
|
if (bc->pdata->rpm_enabled)
|
||||||
|
|
||||||
if (bc_data->rpm_enabled)
|
|
||||||
pm_runtime_put(bc->dev);
|
pm_runtime_put(bc->dev);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue