Skip to content

Commit 40c0cdc

Browse files
Leo-YanSuzuki K Poulose
authored andcommitted
coresight: etm4x: Support atclk
The atclk is an optional clock for the CoreSight ETMv4, but the driver misses to initialize it. This change enables atclk in probe of the ETMv4 driver, and dynamically control the clock during suspend and resume. No need to check the driver data and clock pointer in the runtime suspend and resume, so remove checks. And add error handling in the resume function. Add a minor fix to the comment format when adding the atclk field. Fixes: 2e1cdfe ("coresight-etm4x: Adding CoreSight ETM4x driver") Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com> Reviewed-by: Yeoreum Yun <yeoreum.yun@arm.com> Tested-by: James Clark <james.clark@linaro.org> Signed-off-by: Leo Yan <leo.yan@arm.com> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> Link: https://lore.kernel.org/r/20250731-arm_cs_fix_clock_v4-v6-3-1dfe10bb3f6f@arm.com
1 parent 5483624 commit 40c0cdc

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

drivers/hwtracing/coresight/coresight-etm4x-core.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2221,6 +2221,10 @@ static int etm4_probe(struct device *dev)
22212221
if (WARN_ON(!drvdata))
22222222
return -ENOMEM;
22232223

2224+
drvdata->atclk = devm_clk_get_optional_enabled(dev, "atclk");
2225+
if (IS_ERR(drvdata->atclk))
2226+
return PTR_ERR(drvdata->atclk);
2227+
22242228
if (pm_save_enable == PARAM_PM_SAVE_FIRMWARE)
22252229
pm_save_enable = coresight_loses_context_with_cpu(dev) ?
22262230
PARAM_PM_SAVE_SELF_HOSTED : PARAM_PM_SAVE_NEVER;
@@ -2469,20 +2473,26 @@ static int etm4_runtime_suspend(struct device *dev)
24692473
{
24702474
struct etmv4_drvdata *drvdata = dev_get_drvdata(dev);
24712475

2472-
if (drvdata->pclk && !IS_ERR(drvdata->pclk))
2473-
clk_disable_unprepare(drvdata->pclk);
2476+
clk_disable_unprepare(drvdata->atclk);
2477+
clk_disable_unprepare(drvdata->pclk);
24742478

24752479
return 0;
24762480
}
24772481

24782482
static int etm4_runtime_resume(struct device *dev)
24792483
{
24802484
struct etmv4_drvdata *drvdata = dev_get_drvdata(dev);
2485+
int ret;
2486+
2487+
ret = clk_prepare_enable(drvdata->pclk);
2488+
if (ret)
2489+
return ret;
24812490

2482-
if (drvdata->pclk && !IS_ERR(drvdata->pclk))
2483-
clk_prepare_enable(drvdata->pclk);
2491+
ret = clk_prepare_enable(drvdata->atclk);
2492+
if (ret)
2493+
clk_disable_unprepare(drvdata->pclk);
24842494

2485-
return 0;
2495+
return ret;
24862496
}
24872497
#endif
24882498

drivers/hwtracing/coresight/coresight-etm4x.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,8 @@ struct etmv4_save_state {
920920

921921
/**
922922
* struct etm4_drvdata - specifics associated to an ETM component
923-
* @pclk APB clock if present, otherwise NULL
923+
* @pclk: APB clock if present, otherwise NULL
924+
* @atclk: Optional clock for the core parts of the ETMv4.
924925
* @base: Memory mapped base address for this component.
925926
* @csdev: Component vitals needed by the framework.
926927
* @spinlock: Only one at a time pls.
@@ -989,6 +990,7 @@ struct etmv4_save_state {
989990
*/
990991
struct etmv4_drvdata {
991992
struct clk *pclk;
993+
struct clk *atclk;
992994
void __iomem *base;
993995
struct coresight_device *csdev;
994996
raw_spinlock_t spinlock;

0 commit comments

Comments
 (0)