static void omap4_configure_pmu_irq(void) { void __iomem *base0; void __iomem *base1; base0 = ioremap(OMAP44XX_CTI0_BASE, SZ_4K); base1 = ioremap(OMAP44XX_CTI1_BASE, SZ_4K); if (!base0 && !base1) { pr_err("ioremap for OMAP4 CTI failed\n"); return; } /*configure CTI0 for pmu irq routing*/ cti_init(&omap4_cti[0], base0, OMAP44XX_IRQ_CTI0, 6); cti_unlock(&omap4_cti[0]); cti_map_trigger(&omap4_cti[0], 1, 6, 2); /*configure CTI1 for pmu irq routing*/ cti_init(&omap4_cti[1], base1, OMAP44XX_IRQ_CTI1, 6); cti_unlock(&omap4_cti[1]); cti_map_trigger(&omap4_cti[1], 1, 6, 2); omap4_pmu_data.handle_irq = omap4_pmu_handler; omap4_pmu_data.enable_irq = omap4_enable_cti; omap4_pmu_data.disable_irq = omap4_disable_cti; }
int socfpga_init_cti(struct platform_device *pdev) { struct device_node *np, *np2; struct socfpga_cti_device *socfpga_cti_device; struct socfpga_cti *socfpga_cti, *socfpga_cti_error; void __iomem *cti_addr; int ncores; int i; socfpga_cti_device = devm_kzalloc(&pdev->dev, sizeof(*socfpga_cti_device), GFP_KERNEL); if (!socfpga_cti_device) return -ENOMEM; ncores = num_online_cpus(); socfpga_cti_device->socfpga_ncores = ncores; socfpga_cti_device->dev = &pdev->dev; np = pdev->dev.of_node; socfpga_cti = kzalloc(sizeof(socfpga_cti) * ncores, GFP_KERNEL); if (!socfpga_cti) return -ENOMEM; socfpga_cti_error = socfpga_cti; for (i = 0; i < socfpga_cti_device->socfpga_ncores; i++) { np2 = of_find_compatible_node(np, NULL, "arm,coresight-cti"); cti_addr = of_iomap(np2, 0); if (!cti_addr) { dev_err(&pdev->dev, "PMU: ioremap for CTI failed\n"); kfree(socfpga_cti_error); return -ENOMEM; } socfpga_cti->cti_addr = cti_addr; socfpga_cti->irq = platform_get_irq(pdev, i); /*configure CTI0 for pmu irq routing*/ cti_init(&socfpga_cti->socfpga_cti_data, socfpga_cti->cti_addr, socfpga_cti->irq, CTI_MPU_IRQ_TRIG_OUT); cti_unlock(&socfpga_cti->socfpga_cti_data); cti_map_trigger(&socfpga_cti->socfpga_cti_data, CTI_MPU_IRQ_TRIG_IN, CTI_MPU_IRQ_TRIG_OUT, PMU_CHANNEL_0); socfpga_cti_device->socfpga_cti[i] = socfpga_cti; socfpga_cti += sizeof(socfpga_cti); } platform_set_drvdata(pdev, socfpga_cti_device); dev_info(&pdev->dev, "PMU:CTI successfully enabled for %d cores\n", socfpga_cti_device->socfpga_ncores); return 0; }
int socfpga_init_cti(struct platform_device *pdev) { struct device_node *np, *np2; void __iomem *cti0_addr; void __iomem *cti1_addr; u32 irq0, irq1; np = pdev->dev.of_node; np2 = of_find_compatible_node(np, NULL, "arm,coresight-cti"); if (!np2) { dev_err(&pdev->dev, "PMU: Unable to find coresight-cti\n"); return -1; } cti0_addr = of_iomap(np2, 0); if (!cti0_addr) { dev_err(&pdev->dev, "PMU: ioremap for CTI failed\n"); return -1; } irq0 = platform_get_irq(pdev, 0); if (irq0 < 0) goto free_irq0; np2 = of_find_compatible_node(np2, NULL, "arm,coresight-cti"); if (!np2) { dev_err(&pdev->dev, "PMU: Unable to find coresight-cti\n"); goto err_iounmap; } cti1_addr = of_iomap(np2, 0); if (!cti1_addr) goto err_iounmap; irq1 = platform_get_irq(pdev, 1); if (irq1 < 0) goto free_irq1; /*configure CTI0 for pmu irq routing*/ cti_init(&socfpga_cti_data[0], cti0_addr, irq0, CTI_MPU_IRQ_TRIG_OUT); cti_unlock(&socfpga_cti_data[0]); cti_map_trigger(&socfpga_cti_data[0], CTI_MPU_IRQ_TRIG_IN, CTI_MPU_IRQ_TRIG_OUT, PMU_CHANNEL_0); /*configure CTI1 for pmu irq routing*/ cti_init(&socfpga_cti_data[1], cti1_addr, irq1, CTI_MPU_IRQ_TRIG_OUT); cti_unlock(&socfpga_cti_data[1]); cti_map_trigger(&socfpga_cti_data[1], CTI_MPU_IRQ_TRIG_IN, CTI_MPU_IRQ_TRIG_OUT, PMU_CHANNEL_1); dev_info(&pdev->dev, "PMU:CTI successfully enabled\n"); return 0; free_irq1: iounmap(cti1_addr); err_iounmap: free_irq(irq0, pdev); free_irq0: iounmap(cti0_addr); return -1; }