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: 21990 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f197.google.com (mail-pd0-f197.google.com [209.85.192.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3B8C4202AE for ; Tue, 3 Dec 2013 16:41:25 +0000 (UTC) Received: by mail-pd0-f197.google.com with SMTP id v10sf37053733pde.4 for ; Tue, 03 Dec 2013 08:41:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=Cs7HprRroQPCJleMUDlsUBVu2I8i2fLNF9+SADvTFYM=; b=gSGNRfCtbKcEMGHDPToc9oYABnZE0xfcqDImT4BLTBUkL6Mclnl7/XBexB8JUIptC5 Iooi/ykRWPEDZT3marGIc/ZjlytMWrUeQa5ix/Q0OCPPev1EBwGekKqgFxMJNfkbEbP7 Mse+xG8dRcqQDyTtBzA6uyqykTEmlu/beqQyLwnUsQBffxCVc5eyqOMk46cwkELwZi4q NWQl2iZQyBRPzYo/aYPbKOoz/YfwcExdU0oeACA97/Y1fD1FwmaqGKYjZYqACPc93oca 5l6hRfV23S8pwDgB6oI5SQQ021HHIeOKVeQJILlnv3j7H20Q58L06uBpT/toRzZy4tI/ Q1TA== X-Gm-Message-State: ALoCoQkwJlykpiVVIOQDJAvdk7HffULuEnEbk1TAYdWgbsdB8YLUlguWNKEtEDYX1IutpWUJW7FZ X-Received: by 10.66.172.79 with SMTP id ba15mr24874585pac.26.1386088882168; Tue, 03 Dec 2013 08:41:22 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.121.131 with SMTP id lk3ls1198776qeb.59.gmail; Tue, 03 Dec 2013 08:41:21 -0800 (PST) X-Received: by 10.52.78.193 with SMTP id d1mr224784vdx.57.1386088881913; Tue, 03 Dec 2013 08:41:21 -0800 (PST) Received: from mail-ve0-f182.google.com (mail-ve0-f182.google.com [209.85.128.182]) by mx.google.com with ESMTPS id gs2si17043698vdc.70.2013.12.03.08.41.21 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 03 Dec 2013 08:41:21 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.182; Received: by mail-ve0-f182.google.com with SMTP id jy13so10379679veb.41 for ; Tue, 03 Dec 2013 08:41:21 -0800 (PST) X-Received: by 10.53.2.36 with SMTP id bl4mr4383705vdd.32.1386088881613; Tue, 03 Dec 2013 08:41:21 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp222690vcz; Tue, 3 Dec 2013 08:41:21 -0800 (PST) X-Received: by 10.66.190.10 with SMTP id gm10mr50813762pac.126.1386088880635; Tue, 03 Dec 2013 08:41:20 -0800 (PST) Received: from mail-pd0-f172.google.com (mail-pd0-f172.google.com [209.85.192.172]) by mx.google.com with ESMTPS id sj5si51905070pab.23.2013.12.03.08.41.20 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 03 Dec 2013 08:41:20 -0800 (PST) Received-SPF: neutral (google.com: 209.85.192.172 is neither permitted nor denied by best guess record for domain of hanjun.guo@linaro.org) client-ip=209.85.192.172; Received: by mail-pd0-f172.google.com with SMTP id g10so20483475pdj.3 for ; Tue, 03 Dec 2013 08:41:19 -0800 (PST) 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 Cc: linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Grant Likely , Matthew Garrett , Olof Johansson , Linus Walleij , Bjorn Helgaas , Rob Herring , Mark Rutland , Jon Masters , patches@linaro.org, linux-kernel@vger.kernel.org, linaro-kernel@lists.linaro.org, linaro-acpi@lists.linaro.org, Hanjun Guo 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-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: hanjun.guo@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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;