Lines Matching defs:xgene_pmu
94 struct xgene_pmu *parent;
104 void (*mask_int)(struct xgene_pmu *pmu);
105 void (*unmask_int)(struct xgene_pmu *pmu);
120 struct xgene_pmu {
710 static inline void xgene_pmu_mask_int(struct xgene_pmu *xgene_pmu)
712 writel(PCPPMU_INTENMASK, xgene_pmu->pcppmu_csr + PCPPMU_INTMASK_REG);
715 static inline void xgene_pmu_v3_mask_int(struct xgene_pmu *xgene_pmu)
717 writel(PCPPMU_V3_INTENMASK, xgene_pmu->pcppmu_csr + PCPPMU_INTMASK_REG);
720 static inline void xgene_pmu_unmask_int(struct xgene_pmu *xgene_pmu)
722 writel(PCPPMU_INTCLRMASK, xgene_pmu->pcppmu_csr + PCPPMU_INTMASK_REG);
725 static inline void xgene_pmu_v3_unmask_int(struct xgene_pmu *xgene_pmu)
728 xgene_pmu->pcppmu_csr + PCPPMU_INTMASK_REG);
869 struct xgene_pmu *xgene_pmu = pmu_dev->parent;
876 xgene_pmu->ops->start_counters(pmu_dev);
882 struct xgene_pmu *xgene_pmu = pmu_dev->parent;
884 xgene_pmu->ops->stop_counters(pmu_dev);
947 struct xgene_pmu *xgene_pmu = pmu_dev->parent;
949 xgene_pmu->ops->write_evttype(pmu_dev, GET_CNTR(event),
951 xgene_pmu->ops->write_agentmsk(pmu_dev, ~((u32)GET_AGENTID(event)));
953 xgene_pmu->ops->write_agent1msk(pmu_dev,
956 xgene_pmu->ops->enable_counter(pmu_dev, GET_CNTR(event));
957 xgene_pmu->ops->enable_counter_int(pmu_dev, GET_CNTR(event));
963 struct xgene_pmu *xgene_pmu = pmu_dev->parent;
965 xgene_pmu->ops->disable_counter(pmu_dev, GET_CNTR(event));
966 xgene_pmu->ops->disable_counter_int(pmu_dev, GET_CNTR(event));
972 struct xgene_pmu *xgene_pmu = pmu_dev->parent;
984 xgene_pmu->ops->write_counter(pmu_dev, hw->idx, val);
990 struct xgene_pmu *xgene_pmu = pmu_dev->parent;
996 new_raw_count = xgene_pmu->ops->read_counter(pmu_dev, GET_CNTR(event));
1015 struct xgene_pmu *xgene_pmu = pmu_dev->parent;
1029 xgene_pmu->ops->write_counter(pmu_dev, GET_CNTR(event),
1092 struct xgene_pmu *xgene_pmu;
1099 xgene_pmu = pmu_dev->parent;
1100 if (xgene_pmu->version == PCP_PMU_V1)
1121 xgene_pmu->ops->stop_counters(pmu_dev);
1122 xgene_pmu->ops->reset_counters(pmu_dev);
1128 xgene_pmu_dev_add(struct xgene_pmu *xgene_pmu, struct xgene_pmu_dev_ctx *ctx)
1130 struct device *dev = xgene_pmu->dev;
1136 pmu->parent = xgene_pmu;
1142 if (!(xgene_pmu->l3c_active_mask & pmu->inf->enable_mask))
1144 if (xgene_pmu->version == PCP_PMU_V3)
1150 if (xgene_pmu->version == PCP_PMU_V3)
1156 if (xgene_pmu->version == PCP_PMU_V3)
1160 if (!(xgene_pmu->mcb_active_mask & pmu->inf->enable_mask))
1162 if (xgene_pmu->version == PCP_PMU_V3)
1168 if (!(xgene_pmu->mc_active_mask & pmu->inf->enable_mask))
1170 if (xgene_pmu->version == PCP_PMU_V3)
1191 struct xgene_pmu *xgene_pmu = pmu_dev->parent;
1196 xgene_pmu->ops->stop_counters(pmu_dev);
1198 if (xgene_pmu->version == PCP_PMU_V3)
1207 if (xgene_pmu->version == PCP_PMU_V1)
1209 else if (xgene_pmu->version == PCP_PMU_V2)
1226 xgene_pmu->ops->start_counters(pmu_dev);
1233 struct xgene_pmu *xgene_pmu = dev_id;
1236 raw_spin_lock(&xgene_pmu->lock);
1239 val = readl(xgene_pmu->pcppmu_csr + PCPPMU_INTSTATUS_REG);
1240 if (xgene_pmu->version == PCP_PMU_V3) {
1252 list_for_each_entry(ctx, &xgene_pmu->mcpmus, next) {
1257 list_for_each_entry(ctx, &xgene_pmu->mcbpmus, next) {
1262 list_for_each_entry(ctx, &xgene_pmu->l3cpmus, next) {
1267 list_for_each_entry(ctx, &xgene_pmu->iobpmus, next) {
1272 raw_spin_unlock(&xgene_pmu->lock);
1277 static int acpi_pmu_probe_active_mcb_mcu_l3c(struct xgene_pmu *xgene_pmu,
1301 xgene_pmu->l3c_active_mask = 0x1;
1306 xgene_pmu->mcb_active_mask = 0x3;
1309 xgene_pmu->mc_active_mask =
1313 xgene_pmu->mcb_active_mask = 0x1;
1316 xgene_pmu->mc_active_mask =
1323 static int acpi_pmu_v3_probe_active_mcb_mcu_l3c(struct xgene_pmu *xgene_pmu,
1342 xgene_pmu->mcb_active_mask = 0x3;
1344 xgene_pmu->l3c_active_mask = 0xFF;
1347 xgene_pmu->mc_active_mask = 0xFF;
1349 xgene_pmu->mc_active_mask = 0x33;
1351 xgene_pmu->mc_active_mask = 0x11;
1354 xgene_pmu->mcb_active_mask = 0x1;
1356 xgene_pmu->l3c_active_mask = 0x0F;
1359 xgene_pmu->mc_active_mask = 0x0F;
1361 xgene_pmu->mc_active_mask = 0x03;
1363 xgene_pmu->mc_active_mask = 0x01;
1369 static int fdt_pmu_probe_active_mcb_mcu_l3c(struct xgene_pmu *xgene_pmu,
1394 xgene_pmu->l3c_active_mask = 0x1;
1400 xgene_pmu->mcb_active_mask = 0x3;
1404 xgene_pmu->mc_active_mask =
1408 xgene_pmu->mcb_active_mask = 0x1;
1412 xgene_pmu->mc_active_mask =
1419 static int xgene_pmu_probe_active_mcb_mcu_l3c(struct xgene_pmu *xgene_pmu,
1423 if (xgene_pmu->version == PCP_PMU_V3)
1424 return acpi_pmu_v3_probe_active_mcb_mcu_l3c(xgene_pmu,
1427 return acpi_pmu_probe_active_mcb_mcu_l3c(xgene_pmu,
1430 return fdt_pmu_probe_active_mcb_mcu_l3c(xgene_pmu, pdev);
1453 xgene_pmu_dev_ctx *acpi_get_pmu_hw_inf(struct xgene_pmu *xgene_pmu,
1456 struct device *dev = xgene_pmu->dev;
1554 struct xgene_pmu *xgene_pmu = data;
1564 ctx = acpi_get_pmu_hw_inf(xgene_pmu, adev, (u32)acpi_id->driver_data);
1568 if (xgene_pmu_dev_add(xgene_pmu, ctx)) {
1570 devm_kfree(xgene_pmu->dev, ctx);
1576 list_add(&ctx->next, &xgene_pmu->l3cpmus);
1579 list_add(&ctx->next, &xgene_pmu->iobpmus);
1582 list_add(&ctx->next, &xgene_pmu->iobpmus);
1585 list_add(&ctx->next, &xgene_pmu->mcbpmus);
1588 list_add(&ctx->next, &xgene_pmu->mcpmus);
1594 static int acpi_pmu_probe_pmu_dev(struct xgene_pmu *xgene_pmu,
1597 struct device *dev = xgene_pmu->dev;
1606 acpi_pmu_dev_add, NULL, xgene_pmu, NULL);
1615 static int acpi_pmu_probe_pmu_dev(struct xgene_pmu *xgene_pmu,
1623 xgene_pmu_dev_ctx *fdt_get_pmu_hw_inf(struct xgene_pmu *xgene_pmu,
1626 struct device *dev = xgene_pmu->dev;
1666 static int fdt_pmu_probe_pmu_dev(struct xgene_pmu *xgene_pmu,
1677 ctx = fdt_get_pmu_hw_inf(xgene_pmu, np, PMU_TYPE_L3C);
1679 ctx = fdt_get_pmu_hw_inf(xgene_pmu, np, PMU_TYPE_IOB);
1681 ctx = fdt_get_pmu_hw_inf(xgene_pmu, np, PMU_TYPE_MCB);
1683 ctx = fdt_get_pmu_hw_inf(xgene_pmu, np, PMU_TYPE_MC);
1690 if (xgene_pmu_dev_add(xgene_pmu, ctx)) {
1692 devm_kfree(xgene_pmu->dev, ctx);
1698 list_add(&ctx->next, &xgene_pmu->l3cpmus);
1701 list_add(&ctx->next, &xgene_pmu->iobpmus);
1704 list_add(&ctx->next, &xgene_pmu->iobpmus);
1707 list_add(&ctx->next, &xgene_pmu->mcbpmus);
1710 list_add(&ctx->next, &xgene_pmu->mcpmus);
1718 static int xgene_pmu_probe_pmu_dev(struct xgene_pmu *xgene_pmu,
1722 return acpi_pmu_probe_pmu_dev(xgene_pmu, pdev);
1723 return fdt_pmu_probe_pmu_dev(xgene_pmu, pdev);
1786 struct xgene_pmu *xgene_pmu = hlist_entry_safe(node, struct xgene_pmu,
1789 if (cpumask_empty(&xgene_pmu->cpu))
1790 cpumask_set_cpu(cpu, &xgene_pmu->cpu);
1793 WARN_ON(irq_set_affinity(xgene_pmu->irq, &xgene_pmu->cpu));
1800 struct xgene_pmu *xgene_pmu = hlist_entry_safe(node, struct xgene_pmu,
1805 if (!cpumask_test_and_clear_cpu(cpu, &xgene_pmu->cpu))
1811 list_for_each_entry(ctx, &xgene_pmu->mcpmus, next) {
1814 list_for_each_entry(ctx, &xgene_pmu->mcbpmus, next) {
1817 list_for_each_entry(ctx, &xgene_pmu->l3cpmus, next) {
1820 list_for_each_entry(ctx, &xgene_pmu->iobpmus, next) {
1824 cpumask_set_cpu(target, &xgene_pmu->cpu);
1826 WARN_ON(irq_set_affinity(xgene_pmu->irq, &xgene_pmu->cpu));
1835 struct xgene_pmu *xgene_pmu;
1847 xgene_pmu = devm_kzalloc(&pdev->dev, sizeof(*xgene_pmu), GFP_KERNEL);
1848 if (!xgene_pmu)
1850 xgene_pmu->dev = &pdev->dev;
1851 platform_set_drvdata(pdev, xgene_pmu);
1873 xgene_pmu->ops = &xgene_pmu_v3_ops;
1875 xgene_pmu->ops = &xgene_pmu_ops;
1877 INIT_LIST_HEAD(&xgene_pmu->l3cpmus);
1878 INIT_LIST_HEAD(&xgene_pmu->iobpmus);
1879 INIT_LIST_HEAD(&xgene_pmu->mcbpmus);
1880 INIT_LIST_HEAD(&xgene_pmu->mcpmus);
1882 xgene_pmu->version = version;
1883 dev_info(&pdev->dev, "X-Gene PMU version %d\n", xgene_pmu->version);
1885 xgene_pmu->pcppmu_csr = devm_platform_ioremap_resource(pdev, 0);
1886 if (IS_ERR(xgene_pmu->pcppmu_csr)) {
1888 return PTR_ERR(xgene_pmu->pcppmu_csr);
1897 dev_name(&pdev->dev), xgene_pmu);
1903 xgene_pmu->irq = irq;
1905 raw_spin_lock_init(&xgene_pmu->lock);
1908 rc = xgene_pmu_probe_active_mcb_mcu_l3c(xgene_pmu, pdev);
1911 xgene_pmu->mcb_active_mask = 0x1;
1912 xgene_pmu->mc_active_mask = 0x1;
1917 &xgene_pmu->node);
1924 rc = xgene_pmu_probe_pmu_dev(xgene_pmu, pdev);
1931 xgene_pmu->ops->unmask_int(xgene_pmu);
1937 &xgene_pmu->node);
1942 xgene_pmu_dev_cleanup(struct xgene_pmu *xgene_pmu, struct list_head *pmus)
1953 struct xgene_pmu *xgene_pmu = dev_get_drvdata(&pdev->dev);
1955 xgene_pmu_dev_cleanup(xgene_pmu, &xgene_pmu->l3cpmus);
1956 xgene_pmu_dev_cleanup(xgene_pmu, &xgene_pmu->iobpmus);
1957 xgene_pmu_dev_cleanup(xgene_pmu, &xgene_pmu->mcbpmus);
1958 xgene_pmu_dev_cleanup(xgene_pmu, &xgene_pmu->mcpmus);
1960 &xgene_pmu->node);