soc: qcom: soc_sleep_stats: Update driver to support legacy targets
Update driver to support legacy drivers which do not have separate offset address to read stats. The legacy targets provided with start and end address. Change-Id: I241c1b28d23491001d193737ac1bca90a87e9169 Signed-off-by: Raghavendra Kakarla <rkakarla@codeaurora.org> Signed-off-by: Tushar Nimkar <tnimkar@codeaurora.org>
This commit is contained in:
parent
08db65b8bf
commit
f57ccea829
@ -1,7 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011-2020, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2011-2021, The Linux Foundation. All rights reserved.
|
||||
*/
|
||||
|
||||
#define pr_fmt(fmt) "%s: " fmt, __func__
|
||||
@ -159,6 +159,11 @@ static int soc_sleep_stats_create_sysfs(struct platform_device *pdev,
|
||||
return sysfs_create_file(drv->kobj, &drv->ka.attr);
|
||||
}
|
||||
|
||||
static const struct stats_config legacy_rpm_data = {
|
||||
.num_records = 2,
|
||||
.appended_stats_avail = true,
|
||||
};
|
||||
|
||||
static const struct stats_config rpm_data = {
|
||||
.offset_addr = 0x14,
|
||||
.num_records = 2,
|
||||
@ -174,6 +179,7 @@ static const struct stats_config rpmh_data = {
|
||||
static const struct of_device_id soc_sleep_stats_table[] = {
|
||||
{ .compatible = "qcom,rpm-sleep-stats", .data = &rpm_data},
|
||||
{ .compatible = "qcom,rpmh-sleep-stats", .data = &rpmh_data},
|
||||
{ .compatible = "qcom,legacy-rpm-sleep-stats", .data = &legacy_rpm_data},
|
||||
{ },
|
||||
};
|
||||
|
||||
@ -182,6 +188,7 @@ static int soc_sleep_stats_probe(struct platform_device *pdev)
|
||||
struct soc_sleep_stats_data *drv;
|
||||
struct resource *res;
|
||||
void __iomem *offset_addr;
|
||||
uint32_t offset = 0;
|
||||
int ret;
|
||||
|
||||
drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL);
|
||||
@ -196,14 +203,18 @@ static int soc_sleep_stats_probe(struct platform_device *pdev)
|
||||
if (!res)
|
||||
return PTR_ERR(res);
|
||||
|
||||
offset_addr = ioremap_nocache(res->start + drv->config->offset_addr,
|
||||
sizeof(u32));
|
||||
if (IS_ERR(offset_addr))
|
||||
return PTR_ERR(offset_addr);
|
||||
if (drv->config->offset_addr) {
|
||||
offset_addr = devm_ioremap_nocache(&pdev->dev, res->start +
|
||||
drv->config->offset_addr,
|
||||
sizeof(u32));
|
||||
if (!offset_addr)
|
||||
return -ENOMEM;
|
||||
|
||||
drv->stats_base = res->start | readl_relaxed(offset_addr);
|
||||
offset = readl_relaxed(offset_addr);
|
||||
}
|
||||
|
||||
drv->stats_base = res->start | offset;
|
||||
drv->stats_size = resource_size(res);
|
||||
iounmap(offset_addr);
|
||||
|
||||
ret = soc_sleep_stats_create_sysfs(pdev, drv);
|
||||
if (ret) {
|
||||
|
Loading…
Reference in New Issue
Block a user