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 {
713 static inline void xgene_pmu_mask_int(struct xgene_pmu *xgene_pmu)
715 writel(PCPPMU_INTENMASK, xgene_pmu->pcppmu_csr + PCPPMU_INTMASK_REG);
718 static inline void xgene_pmu_v3_mask_int(struct xgene_pmu *xgene_pmu)
720 writel(PCPPMU_V3_INTENMASK, xgene_pmu->pcppmu_csr + PCPPMU_INTMASK_REG);
723 static inline void xgene_pmu_unmask_int(struct xgene_pmu *xgene_pmu)
725 writel(PCPPMU_INTCLRMASK, xgene_pmu->pcppmu_csr + PCPPMU_INTMASK_REG);
728 static inline void xgene_pmu_v3_unmask_int(struct xgene_pmu *xgene_pmu)
731 xgene_pmu->pcppmu_csr + PCPPMU_INTMASK_REG);
872 struct xgene_pmu *xgene_pmu = pmu_dev->parent;
879 xgene_pmu->ops->start_counters(pmu_dev);
885 struct xgene_pmu *xgene_pmu = pmu_dev->parent;
887 xgene_pmu->ops->stop_counters(pmu_dev);
950 struct xgene_pmu *xgene_pmu = pmu_dev->parent;
952 xgene_pmu->ops->write_evttype(pmu_dev, GET_CNTR(event),
954 xgene_pmu->ops->write_agentmsk(pmu_dev, ~((u32)GET_AGENTID(event)));
956 xgene_pmu->ops->write_agent1msk(pmu_dev,
959 xgene_pmu->ops->enable_counter(pmu_dev, GET_CNTR(event));
960 xgene_pmu->ops->enable_counter_int(pmu_dev, GET_CNTR(event));
966 struct xgene_pmu *xgene_pmu = pmu_dev->parent;
968 xgene_pmu->ops->disable_counter(pmu_dev, GET_CNTR(event));
969 xgene_pmu->ops->disable_counter_int(pmu_dev, GET_CNTR(event));
975 struct xgene_pmu *xgene_pmu = pmu_dev->parent;
987 xgene_pmu->ops->write_counter(pmu_dev, hw->idx, val);
993 struct xgene_pmu *xgene_pmu = pmu_dev->parent;
999 new_raw_count = xgene_pmu->ops->read_counter(pmu_dev, GET_CNTR(event));
1018 struct xgene_pmu *xgene_pmu = pmu_dev->parent;
1032 xgene_pmu->ops->write_counter(pmu_dev, GET_CNTR(event),
1095 struct xgene_pmu *xgene_pmu;
1102 xgene_pmu = pmu_dev->parent;
1103 if (xgene_pmu->version == PCP_PMU_V1)
1124 xgene_pmu->ops->stop_counters(pmu_dev);
1125 xgene_pmu->ops->reset_counters(pmu_dev);
1131 xgene_pmu_dev_add(struct xgene_pmu *xgene_pmu, struct xgene_pmu_dev_ctx *ctx)
1133 struct device *dev = xgene_pmu->dev;
1139 pmu->parent = xgene_pmu;
1145 if (!(xgene_pmu->l3c_active_mask & pmu->inf->enable_mask))
1147 if (xgene_pmu->version == PCP_PMU_V3)
1153 if (xgene_pmu->version == PCP_PMU_V3)
1159 if (xgene_pmu->version == PCP_PMU_V3)
1163 if (!(xgene_pmu->mcb_active_mask & pmu->inf->enable_mask))
1165 if (xgene_pmu->version == PCP_PMU_V3)
1171 if (!(xgene_pmu->mc_active_mask & pmu->inf->enable_mask))
1173 if (xgene_pmu->version == PCP_PMU_V3)
1194 struct xgene_pmu *xgene_pmu = pmu_dev->parent;
1199 xgene_pmu->ops->stop_counters(pmu_dev);
1201 if (xgene_pmu->version == PCP_PMU_V3)
1210 if (xgene_pmu->version == PCP_PMU_V1)
1212 else if (xgene_pmu->version == PCP_PMU_V2)
1229 xgene_pmu->ops->start_counters(pmu_dev);
1236 struct xgene_pmu *xgene_pmu = dev_id;
1240 raw_spin_lock_irqsave(&xgene_pmu->lock, flags);
1243 val = readl(xgene_pmu->pcppmu_csr + PCPPMU_INTSTATUS_REG);
1244 if (xgene_pmu->version == PCP_PMU_V3) {
1256 list_for_each_entry(ctx, &xgene_pmu->mcpmus, next) {
1261 list_for_each_entry(ctx, &xgene_pmu->mcbpmus, next) {
1266 list_for_each_entry(ctx, &xgene_pmu->l3cpmus, next) {
1271 list_for_each_entry(ctx, &xgene_pmu->iobpmus, next) {
1276 raw_spin_unlock_irqrestore(&xgene_pmu->lock, flags);
1281 static int acpi_pmu_probe_active_mcb_mcu_l3c(struct xgene_pmu *xgene_pmu,
1305 xgene_pmu->l3c_active_mask = 0x1;
1310 xgene_pmu->mcb_active_mask = 0x3;
1313 xgene_pmu->mc_active_mask =
1317 xgene_pmu->mcb_active_mask = 0x1;
1320 xgene_pmu->mc_active_mask =
1327 static int acpi_pmu_v3_probe_active_mcb_mcu_l3c(struct xgene_pmu *xgene_pmu,
1346 xgene_pmu->mcb_active_mask = 0x3;
1348 xgene_pmu->l3c_active_mask = 0xFF;
1351 xgene_pmu->mc_active_mask = 0xFF;
1353 xgene_pmu->mc_active_mask = 0x33;
1355 xgene_pmu->mc_active_mask = 0x11;
1358 xgene_pmu->mcb_active_mask = 0x1;
1360 xgene_pmu->l3c_active_mask = 0x0F;
1363 xgene_pmu->mc_active_mask = 0x0F;
1365 xgene_pmu->mc_active_mask = 0x03;
1367 xgene_pmu->mc_active_mask = 0x01;
1373 static int fdt_pmu_probe_active_mcb_mcu_l3c(struct xgene_pmu *xgene_pmu,
1398 xgene_pmu->l3c_active_mask = 0x1;
1404 xgene_pmu->mcb_active_mask = 0x3;
1408 xgene_pmu->mc_active_mask =
1412 xgene_pmu->mcb_active_mask = 0x1;
1416 xgene_pmu->mc_active_mask =
1423 static int xgene_pmu_probe_active_mcb_mcu_l3c(struct xgene_pmu *xgene_pmu,
1427 if (xgene_pmu->version == PCP_PMU_V3)
1428 return acpi_pmu_v3_probe_active_mcb_mcu_l3c(xgene_pmu,
1431 return acpi_pmu_probe_active_mcb_mcu_l3c(xgene_pmu,
1434 return fdt_pmu_probe_active_mcb_mcu_l3c(xgene_pmu, pdev);
1457 xgene_pmu_dev_ctx *acpi_get_pmu_hw_inf(struct xgene_pmu *xgene_pmu,
1460 struct device *dev = xgene_pmu->dev;
1557 struct xgene_pmu *xgene_pmu = data;
1570 ctx = acpi_get_pmu_hw_inf(xgene_pmu, adev, (u32)acpi_id->driver_data);
1574 if (xgene_pmu_dev_add(xgene_pmu, ctx)) {
1576 devm_kfree(xgene_pmu->dev, ctx);
1582 list_add(&ctx->next, &xgene_pmu->l3cpmus);
1585 list_add(&ctx->next, &xgene_pmu->iobpmus);
1588 list_add(&ctx->next, &xgene_pmu->iobpmus);
1591 list_add(&ctx->next, &xgene_pmu->mcbpmus);
1594 list_add(&ctx->next, &xgene_pmu->mcpmus);
1600 static int acpi_pmu_probe_pmu_dev(struct xgene_pmu *xgene_pmu,
1603 struct device *dev = xgene_pmu->dev;
1612 acpi_pmu_dev_add, NULL, xgene_pmu, NULL);
1621 static int acpi_pmu_probe_pmu_dev(struct xgene_pmu *xgene_pmu,
1629 xgene_pmu_dev_ctx *fdt_get_pmu_hw_inf(struct xgene_pmu *xgene_pmu,
1632 struct device *dev = xgene_pmu->dev;
1672 static int fdt_pmu_probe_pmu_dev(struct xgene_pmu *xgene_pmu,
1683 ctx = fdt_get_pmu_hw_inf(xgene_pmu, np, PMU_TYPE_L3C);
1685 ctx = fdt_get_pmu_hw_inf(xgene_pmu, np, PMU_TYPE_IOB);
1687 ctx = fdt_get_pmu_hw_inf(xgene_pmu, np, PMU_TYPE_MCB);
1689 ctx = fdt_get_pmu_hw_inf(xgene_pmu, np, PMU_TYPE_MC);
1696 if (xgene_pmu_dev_add(xgene_pmu, ctx)) {
1698 devm_kfree(xgene_pmu->dev, ctx);
1704 list_add(&ctx->next, &xgene_pmu->l3cpmus);
1707 list_add(&ctx->next, &xgene_pmu->iobpmus);
1710 list_add(&ctx->next, &xgene_pmu->iobpmus);
1713 list_add(&ctx->next, &xgene_pmu->mcbpmus);
1716 list_add(&ctx->next, &xgene_pmu->mcpmus);
1724 static int xgene_pmu_probe_pmu_dev(struct xgene_pmu *xgene_pmu,
1728 return acpi_pmu_probe_pmu_dev(xgene_pmu, pdev);
1729 return fdt_pmu_probe_pmu_dev(xgene_pmu, pdev);
1792 struct xgene_pmu *xgene_pmu = hlist_entry_safe(node, struct xgene_pmu,
1795 if (cpumask_empty(&xgene_pmu->cpu))
1796 cpumask_set_cpu(cpu, &xgene_pmu->cpu);
1799 WARN_ON(irq_set_affinity(xgene_pmu->irq, &xgene_pmu->cpu));
1806 struct xgene_pmu *xgene_pmu = hlist_entry_safe(node, struct xgene_pmu,
1811 if (!cpumask_test_and_clear_cpu(cpu, &xgene_pmu->cpu))
1817 list_for_each_entry(ctx, &xgene_pmu->mcpmus, next) {
1820 list_for_each_entry(ctx, &xgene_pmu->mcbpmus, next) {
1823 list_for_each_entry(ctx, &xgene_pmu->l3cpmus, next) {
1826 list_for_each_entry(ctx, &xgene_pmu->iobpmus, next) {
1830 cpumask_set_cpu(target, &xgene_pmu->cpu);
1832 WARN_ON(irq_set_affinity(xgene_pmu->irq, &xgene_pmu->cpu));
1841 struct xgene_pmu *xgene_pmu;
1854 xgene_pmu = devm_kzalloc(&pdev->dev, sizeof(*xgene_pmu), GFP_KERNEL);
1855 if (!xgene_pmu)
1857 xgene_pmu->dev = &pdev->dev;
1858 platform_set_drvdata(pdev, xgene_pmu);
1880 xgene_pmu->ops = &xgene_pmu_v3_ops;
1882 xgene_pmu->ops = &xgene_pmu_ops;
1884 INIT_LIST_HEAD(&xgene_pmu->l3cpmus);
1885 INIT_LIST_HEAD(&xgene_pmu->iobpmus);
1886 INIT_LIST_HEAD(&xgene_pmu->mcbpmus);
1887 INIT_LIST_HEAD(&xgene_pmu->mcpmus);
1889 xgene_pmu->version = version;
1890 dev_info(&pdev->dev, "X-Gene PMU version %d\n", xgene_pmu->version);
1893 xgene_pmu->pcppmu_csr = devm_ioremap_resource(&pdev->dev, res);
1894 if (IS_ERR(xgene_pmu->pcppmu_csr)) {
1896 return PTR_ERR(xgene_pmu->pcppmu_csr);
1905 dev_name(&pdev->dev), xgene_pmu);
1911 xgene_pmu->irq = irq;
1913 raw_spin_lock_init(&xgene_pmu->lock);
1916 rc = xgene_pmu_probe_active_mcb_mcu_l3c(xgene_pmu, pdev);
1919 xgene_pmu->mcb_active_mask = 0x1;
1920 xgene_pmu->mc_active_mask = 0x1;
1925 &xgene_pmu->node);
1932 rc = xgene_pmu_probe_pmu_dev(xgene_pmu, pdev);
1939 xgene_pmu->ops->unmask_int(xgene_pmu);
1945 &xgene_pmu->node);
1950 xgene_pmu_dev_cleanup(struct xgene_pmu *xgene_pmu, struct list_head *pmus)
1961 struct xgene_pmu *xgene_pmu = dev_get_drvdata(&pdev->dev);
1963 xgene_pmu_dev_cleanup(xgene_pmu, &xgene_pmu->l3cpmus);
1964 xgene_pmu_dev_cleanup(xgene_pmu, &xgene_pmu->iobpmus);
1965 xgene_pmu_dev_cleanup(xgene_pmu, &xgene_pmu->mcbpmus);
1966 xgene_pmu_dev_cleanup(xgene_pmu, &xgene_pmu->mcpmus);
1968 &xgene_pmu->node);