mirror of
https://github.com/torvalds/linux.git
synced 2026-05-31 18:43:33 +02:00
drivers/perf: hisi: Simplify the probe process of each L3C PMU version
Version 1 and 2 of L3C PMU also use different HID. Make use of struct acpi_device_id::driver_data for version specific information rather than judge the version register. This will help to simplify the probe process and also a bit easier for extension. Acked-by: Jonathan Cameron <jonathan.cameron@huawei.com> Signed-off-by: Yicong Yang <yangyicong@hisilicon.com> Signed-off-by: Yushan Wang <wangyushan12@huawei.com> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com> Signed-off-by: Will Deacon <will@kernel.org>
This commit is contained in:
parent
4550244b53
commit
0960e535be
|
|
@ -345,13 +345,6 @@ static void hisi_l3c_pmu_clear_int_status(struct hisi_pmu *l3c_pmu, int idx)
|
|||
writel(1 << idx, l3c_pmu->base + L3C_INT_CLEAR);
|
||||
}
|
||||
|
||||
static const struct acpi_device_id hisi_l3c_pmu_acpi_match[] = {
|
||||
{ "HISI0213", },
|
||||
{ "HISI0214", },
|
||||
{}
|
||||
};
|
||||
MODULE_DEVICE_TABLE(acpi, hisi_l3c_pmu_acpi_match);
|
||||
|
||||
static int hisi_l3c_pmu_init_data(struct platform_device *pdev,
|
||||
struct hisi_pmu *l3c_pmu)
|
||||
{
|
||||
|
|
@ -371,6 +364,10 @@ static int hisi_l3c_pmu_init_data(struct platform_device *pdev,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
l3c_pmu->dev_info = device_get_match_data(&pdev->dev);
|
||||
if (!l3c_pmu->dev_info)
|
||||
return -ENODEV;
|
||||
|
||||
l3c_pmu->base = devm_platform_ioremap_resource(pdev, 0);
|
||||
if (IS_ERR(l3c_pmu->base)) {
|
||||
dev_err(&pdev->dev, "ioremap failed for l3c_pmu resource\n");
|
||||
|
|
@ -457,6 +454,18 @@ static const struct attribute_group *hisi_l3c_pmu_v2_attr_groups[] = {
|
|||
NULL
|
||||
};
|
||||
|
||||
static const struct hisi_pmu_dev_info hisi_l3c_pmu_v1 = {
|
||||
.attr_groups = hisi_l3c_pmu_v1_attr_groups,
|
||||
.counter_bits = 48,
|
||||
.check_event = L3C_V1_NR_EVENTS,
|
||||
};
|
||||
|
||||
static const struct hisi_pmu_dev_info hisi_l3c_pmu_v2 = {
|
||||
.attr_groups = hisi_l3c_pmu_v2_attr_groups,
|
||||
.counter_bits = 64,
|
||||
.check_event = L3C_V2_NR_EVENTS,
|
||||
};
|
||||
|
||||
static const struct hisi_uncore_ops hisi_uncore_l3c_ops = {
|
||||
.write_evtype = hisi_l3c_pmu_write_evtype,
|
||||
.get_event_idx = hisi_uncore_pmu_get_event_idx,
|
||||
|
|
@ -487,16 +496,9 @@ static int hisi_l3c_pmu_dev_probe(struct platform_device *pdev,
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (l3c_pmu->identifier >= HISI_PMU_V2) {
|
||||
l3c_pmu->counter_bits = 64;
|
||||
l3c_pmu->check_event = L3C_V2_NR_EVENTS;
|
||||
l3c_pmu->pmu_events.attr_groups = hisi_l3c_pmu_v2_attr_groups;
|
||||
} else {
|
||||
l3c_pmu->counter_bits = 48;
|
||||
l3c_pmu->check_event = L3C_V1_NR_EVENTS;
|
||||
l3c_pmu->pmu_events.attr_groups = hisi_l3c_pmu_v1_attr_groups;
|
||||
}
|
||||
|
||||
l3c_pmu->pmu_events.attr_groups = l3c_pmu->dev_info->attr_groups;
|
||||
l3c_pmu->counter_bits = l3c_pmu->dev_info->counter_bits;
|
||||
l3c_pmu->check_event = l3c_pmu->dev_info->check_event;
|
||||
l3c_pmu->num_counters = L3C_NR_COUNTERS;
|
||||
l3c_pmu->ops = &hisi_uncore_l3c_ops;
|
||||
l3c_pmu->dev = &pdev->dev;
|
||||
|
|
@ -554,6 +556,13 @@ static void hisi_l3c_pmu_remove(struct platform_device *pdev)
|
|||
&l3c_pmu->node);
|
||||
}
|
||||
|
||||
static const struct acpi_device_id hisi_l3c_pmu_acpi_match[] = {
|
||||
{ "HISI0213", (kernel_ulong_t)&hisi_l3c_pmu_v1 },
|
||||
{ "HISI0214", (kernel_ulong_t)&hisi_l3c_pmu_v2 },
|
||||
{}
|
||||
};
|
||||
MODULE_DEVICE_TABLE(acpi, hisi_l3c_pmu_acpi_match);
|
||||
|
||||
static struct platform_driver hisi_l3c_pmu_driver = {
|
||||
.driver = {
|
||||
.name = "hisi_l3c_pmu",
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user