From patchwork Tue Dec 3 16:39:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 3277701 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 868AC9F380 for ; Tue, 3 Dec 2013 16:41:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 47822203A9 for ; Tue, 3 Dec 2013 16:41:58 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E362D2015E for ; Tue, 3 Dec 2013 16:41:56 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vnt2m-0007H7-AU; Tue, 03 Dec 2013 16:41:52 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vnt2j-0001IA-Oz; Tue, 03 Dec 2013 16:41:49 +0000 Received: from mail-pd0-f173.google.com ([209.85.192.173]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vnt2e-0001DD-0d for linux-arm-kernel@lists.infradead.org; Tue, 03 Dec 2013 16:41:47 +0000 Received: by mail-pd0-f173.google.com with SMTP id p10so20441542pdj.32 for ; Tue, 03 Dec 2013 08:41:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Cs7HprRroQPCJleMUDlsUBVu2I8i2fLNF9+SADvTFYM=; b=fsWfWRCy38TiBScnXyPjmUq9TXkUEjebD+u/H4q93fmV/C8u5ZChADssf1hHhxULpr iXHjSNMR3tv/Mv6A8ED6Z8LtAKtyoMmHUIMAPeF9l2FKIxdE20DXUnMS2AT4VmBEPBJB QpPnZaW5G3Hvg/+qdwzsk5aXVlSKB2OSUlAj8h/Yk/dydDiHdEVnI8+ptq6fPTCKust0 WwAla4r7bObXqF8uVwUrLRUUKKdkjBulkMx+cttAn3Lh03EqDdPTq2iYe3zwbM/oghXq 7/s4P6RmiFA7ZEjgw1brN/1p59M5c9NySiAC0AEZJf6BxMI5jYG9+LSEMGGBVhyziOk/ EqDw== X-Gm-Message-State: ALoCoQn6yuNEwKdXcx4v8UALPUKQxihNv7kxVWGYtQzxt8nHEcFvw/0VbRO0wE0utLyJ5dgCBBOH X-Received: by 10.68.52.231 with SMTP id w7mr39744959pbo.19.1386088879751; Tue, 03 Dec 2013 08:41:19 -0800 (PST) Received: from localhost ([61.148.199.138]) by mx.google.com with ESMTPSA id wp8sm131177347pbc.26.2013.12.03.08.41.14 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 03 Dec 2013 08:41:19 -0800 (PST) From: Hanjun Guo To: "Rafael J. Wysocki" , Catalin Marinas , Will Deacon , Russell King - ARM Linux , Daniel Lezcano Subject: [RFC part2 PATCH 9/9] ACPI / GIC: Initialize GIC using the information in MADT Date: Wed, 4 Dec 2013 00:39:13 +0800 Message-Id: <1386088753-2850-10-git-send-email-hanjun.guo@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1386088753-2850-1-git-send-email-hanjun.guo@linaro.org> References: <1386088753-2850-1-git-send-email-hanjun.guo@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131203_114144_311569_78359FBB X-CRM114-Status: GOOD ( 19.98 ) X-Spam-Score: -1.9 (-) Cc: Mark Rutland , Matthew Garrett , linaro-kernel@lists.linaro.org, patches@linaro.org, Linus Walleij , Olof Johansson , linux-kernel@vger.kernel.org, Rob Herring , linaro-acpi@lists.linaro.org, linux-acpi@vger.kernel.org, Jon Masters , Grant Likely , Bjorn Helgaas , linux-arm-kernel@lists.infradead.org, Hanjun Guo X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In MADT table, there are GIC cpu interface base address and GIC distributor base address, use them to convert GIC to ACPI. Signed-off-by: Hanjun Guo --- arch/arm64/kernel/irq.c | 5 ++++ drivers/acpi/plat/arm-core.c | 66 ++++++++++++++++++++++++++++++++++++------ include/linux/acpi.h | 6 ++++ 3 files changed, 68 insertions(+), 9 deletions(-) diff --git a/arch/arm64/kernel/irq.c b/arch/arm64/kernel/irq.c index 473e5db..a9e68bf 100644 --- a/arch/arm64/kernel/irq.c +++ b/arch/arm64/kernel/irq.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -78,6 +79,10 @@ void __init set_handle_irq(void (*handle_irq)(struct pt_regs *)) void __init init_IRQ(void) { irqchip_init(); + + if (!handle_arch_irq) + acpi_gic_init(); + if (!handle_arch_irq) panic("No interrupt controller found."); } diff --git a/drivers/acpi/plat/arm-core.c b/drivers/acpi/plat/arm-core.c index 17c99e1..509b847 100644 --- a/drivers/acpi/plat/arm-core.c +++ b/drivers/acpi/plat/arm-core.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -211,11 +212,21 @@ acpi_parse_gic(struct acpi_subtable_header *header, const unsigned long end) return 0; } +#ifdef CONFIG_ARM_GIC +/* + * Hard code here, we can not get memory size from MADT (but FDT does), + * this size is described in ARMv8 foudation model's User Guide + */ +#define GIC_DISTRIBUTOR_MEMORY_SIZE (SZ_8K) +#define GIC_CPU_INTERFACE_MEMORY_SIZE (SZ_4K) + static int __init acpi_parse_gic_distributor(struct acpi_subtable_header *header, const unsigned long end) { struct acpi_madt_generic_distributor *distributor = NULL; + void __iomem *dist_base = NULL; + void __iomem *cpu_base = NULL; distributor = (struct acpi_madt_generic_distributor *)header; @@ -224,8 +235,43 @@ acpi_parse_gic_distributor(struct acpi_subtable_header *header, acpi_table_print_madt_entry(header); + /* GIC is initialised after page_init(), no need for early_ioremap */ + dist_base = ioremap(distributor->base_address, + GIC_CPU_INTERFACE_MEMORY_SIZE); + if (!dist_base) { + pr_warn(PREFIX "unable to map gic dist registers\n"); + return -ENOMEM; + } + + /* + * acpi_lapic_addr is stored in acpi_parse_madt(), + * so we can use it here for GIC init + */ + if (acpi_lapic_addr) { + iounmap(dist_base); + pr_warn(PREFIX "Invalid GIC cpu interface base address\n"); + return -EINVAL; + } + + cpu_base = ioremap(acpi_lapic_addr, GIC_CPU_INTERFACE_MEMORY_SIZE); + if (!cpu_base) { + iounmap(dist_base); + pr_warn(PREFIX "unable to map gic cpu registers\n"); + return -ENOMEM; + } + + gic_init(distributor->gic_id, -1, dist_base, cpu_base); + return 0; } +#else +static int __init +acpi_parse_gic_distributor(struct acpi_subtable_header *header, + const unsigned long end) +{ + return -ENODEV; +} +#endif /* CONFIG_ARM_GIC */ /* * Parse GIC cpu interface related entries in MADT @@ -234,7 +280,7 @@ acpi_parse_gic_distributor(struct acpi_subtable_header *header, static int __init acpi_parse_madt_gic_entries(void) { int count; - + /* * do a partial walk of MADT to determine how many CPUs * we have including disabled CPUs @@ -468,19 +514,21 @@ static void __init acpi_process_madt(void) * Parse MADT GIC cpu interface entries */ error = acpi_parse_madt_gic_entries(); - if (!error) { - /* - * Parse MADT GIC distributor entries - */ - acpi_parse_madt_gic_distributor_entries(); - } + if (!error) + pr_info("Using ACPI for processor (GIC) configuration information\n"); } - pr_info("Using ACPI for processor (GIC) configuration information\n"); - return; } +int __init acpi_gic_init(void) +{ + /* + * Parse MADT GIC distributor entries + */ + return acpi_parse_madt_gic_distributor_entries(); +} + /* * acpi_boot_table_init() and acpi_boot_init() * called from setup_arch(), always. diff --git a/include/linux/acpi.h b/include/linux/acpi.h index edd5806..58a4bf4 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -112,6 +112,7 @@ char * __acpi_map_table (unsigned long phys_addr, unsigned long size); void __acpi_unmap_table(char *map, unsigned long size); int early_acpi_boot_init(void); int acpi_boot_init (void); +int acpi_gic_init(void); void acpi_boot_table_init (void); int acpi_mps_check (void); int acpi_numa_init (void); @@ -444,6 +445,11 @@ static inline int acpi_boot_init(void) return 0; } +static inline int acpi_gic_init(void) +{ + return -ENODEV; +} + static inline void acpi_boot_table_init(void) { return;