From patchwork Thu Mar 3 10:53:53 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 605821 X-Patchwork-Delegate: tony@atomide.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p23AtC1Q003124 for ; Thu, 3 Mar 2011 10:55:13 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757042Ab1CCKy4 (ORCPT ); Thu, 3 Mar 2011 05:54:56 -0500 Received: from mail-iw0-f174.google.com ([209.85.214.174]:35184 "EHLO mail-iw0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751832Ab1CCKyy (ORCPT ); Thu, 3 Mar 2011 05:54:54 -0500 Received: by iwn34 with SMTP id 34so822839iwn.19 for ; Thu, 03 Mar 2011 02:54:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=6rI0bXpCtyPWyMsbsCzUJo8MRi1nqC/AAlizDuNNxhI=; b=EPi+llwrWfasNKzYLiTNmVenewQIS7lIMFi5cguTeWAeYVfnKqClwKf1znbU4ErLk6 a6cpX5n2Zw/eixNkI1qwJrJ/WxesV9naSrNLgPip3zxmjrBWM40iwDtJnCBLntA9HX6j 7GpyzFMypm6q8OiWwTEfrGX+aiMHnOOlQbfxk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=Zqk5ONeN0jpTBPtTTJWz9rnPiZ2PA3zSsJGwZZQMmxakRrfXXF98TIweRALuazxpy1 UACHEetQmAd2W6nNnniBpwIc8GtJLqnrIk5SWisjeeqRLsThC28L3HkWhvQMoXiRmIw2 c10D6pJd/tYAy8Aee5PFvmCah/gwqFiaNglUY= Received: by 10.42.171.74 with SMTP id i10mr1387551icz.157.1299149693665; Thu, 03 Mar 2011 02:54:53 -0800 (PST) Received: from localhost ([119.145.41.251]) by mx.google.com with ESMTPS id gy41sm849895ibb.17.2011.03.03.02.54.44 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 03 Mar 2011 02:54:52 -0800 (PST) From: tom.leiming@gmail.com To: linux@arm.linux.org.uk Cc: linux-arm-kernel@lists.infradead.org, will.deacon@arm.com, Ming Lei , Santosh Shilimkar , Woodruff Richard , Tony Lindgren , linux-omap@vger.kernel.org Subject: [patch v3 3/3] arm: omap4: support pmu Date: Thu, 3 Mar 2011 18:53:53 +0800 Message-Id: <1299149633-699-4-git-send-email-tom.leiming@gmail.com> X-Mailer: git-send-email 1.7.3 In-Reply-To: <1299149633-699-1-git-send-email-tom.leiming@gmail.com> References: <1299149633-699-1-git-send-email-tom.leiming@gmail.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 03 Mar 2011 10:55:13 +0000 (UTC) diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c index d216976..d97bb5a 100644 --- a/arch/arm/mach-omap2/devices.c +++ b/arch/arm/mach-omap2/devices.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -322,20 +323,95 @@ static struct resource omap3_pmu_resource = { .flags = IORESOURCE_IRQ, }; +static struct resource omap4_pmu_resource[] = { + { + .start = OMAP44XX_IRQ_CTI0, + .end = OMAP44XX_IRQ_CTI0, + .flags = IORESOURCE_IRQ, + }, + { + .start = OMAP44XX_IRQ_CTI1, + .end = OMAP44XX_IRQ_CTI1, + .flags = IORESOURCE_IRQ, + } +}; + static struct platform_device omap_pmu_device = { .name = "arm-pmu", .id = ARM_PMU_DEVICE_CPU, .num_resources = 1, }; +static struct arm_pmu_platdata omap4_pmu_data; +static struct cti omap4_cti[2]; + +static void omap4_enable_cti(int irq) +{ + if (irq == OMAP44XX_IRQ_CTI0) + cti_enable(&omap4_cti[0]); + else if (irq == OMAP44XX_IRQ_CTI1) + cti_enable(&omap4_cti[1]); +} + +static void omap4_disable_cti(int irq) +{ + if (irq == OMAP44XX_IRQ_CTI0) + cti_disable(&omap4_cti[0]); + else if (irq == OMAP44XX_IRQ_CTI1) + cti_disable(&omap4_cti[1]); +} + +static irqreturn_t omap4_pmu_handler(int irq, void *dev, irq_handler_t handler) +{ + if (irq == OMAP44XX_IRQ_CTI0) + cti_irq_ack(&omap4_cti[0]); + else if (irq == OMAP44XX_IRQ_CTI1) + cti_irq_ack(&omap4_cti[1]); + + return handler(irq, dev); +} + +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; +} + static void omap_init_pmu(void) { - if (cpu_is_omap24xx()) + if (cpu_is_omap24xx()) { omap_pmu_device.resource = &omap2_pmu_resource; - else if (cpu_is_omap34xx()) + } else if (cpu_is_omap34xx()) { omap_pmu_device.resource = &omap3_pmu_resource; - else + } else if (cpu_is_omap44xx()) { + omap_pmu_device.resource = omap4_pmu_resource; + omap_pmu_device.num_resources = 2; + omap_pmu_device.dev.platform_data = &omap4_pmu_data; + omap4_configure_pmu_irq(); + } else { return; + } platform_device_register(&omap_pmu_device); } diff --git a/arch/arm/plat-omap/include/plat/omap44xx.h b/arch/arm/plat-omap/include/plat/omap44xx.h index ea2b8a6..b127a16 100644 --- a/arch/arm/plat-omap/include/plat/omap44xx.h +++ b/arch/arm/plat-omap/include/plat/omap44xx.h @@ -57,5 +57,7 @@ #define OMAP44XX_HSUSB_OHCI_BASE (L4_44XX_BASE + 0x64800) #define OMAP44XX_HSUSB_EHCI_BASE (L4_44XX_BASE + 0x64C00) +#define OMAP44XX_CTI0_BASE 0x54148000 +#define OMAP44XX_CTI1_BASE 0x54149000 #endif /* __ASM_ARCH_OMAP44XX_H */