From patchwork Thu Jul 24 13:00:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 34202 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f71.google.com (mail-pa0-f71.google.com [209.85.220.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C940820C7F for ; Thu, 24 Jul 2014 13:00:59 +0000 (UTC) Received: by mail-pa0-f71.google.com with SMTP id et14sf18520553pad.6 for ; Thu, 24 Jul 2014 06:00:59 -0700 (PDT) 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:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=F0XQePMb0xvviadOvGBgaG0Ai6WuGWMyOQbVCJ2q7PA=; b=Cx+I04/PFELlZYCpGH99Nsa8wv0egVsKC++Lme2FAeAsTS5a9dt9oI4Z9Qgg60g8hC DSf2iLPjLfwFkGhtIvkWBFIHixc9KkZPu9S99vGKiWos7jdraKEaAsh9NBKjLgvMtL7y lWhfelU/BQ5Ys0EPPdMZ0TLVZaPOvzCuboXlIHzqsALpiYRPeYzqFeYcBJp0hmshUiUx MD4v5nNXo51gTWCDE2IbNeZLVscNH8fe9ENClIDmUSx88ydoJ66qt7IISeG2sYqBhjMA cZpigmiGAo/PBEG5VsucWm0tHpGP9lBmLfLKgSDqheHVt7AN7Ri73ER8S6LH1V+57Xrk NyQw== X-Gm-Message-State: ALoCoQmoqvkzcJKFgF3UAEGCN8/DFnX/FFRVDEaXTuZPqehUDdOlVcHnJQR3x6Hb0JyTjwrGXftJ X-Received: by 10.66.66.163 with SMTP id g3mr4315301pat.3.1406206859131; Thu, 24 Jul 2014 06:00:59 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.100.214 with SMTP id s80ls794347qge.99.gmail; Thu, 24 Jul 2014 06:00:58 -0700 (PDT) X-Received: by 10.220.44.20 with SMTP id y20mr12017520vce.60.1406206858887; Thu, 24 Jul 2014 06:00:58 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id 16si4815107vdd.92.2014.07.24.06.00.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 24 Jul 2014 06:00:58 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id hu12so4719088vcb.6 for ; Thu, 24 Jul 2014 06:00:58 -0700 (PDT) X-Received: by 10.52.244.81 with SMTP id xe17mr10167653vdc.24.1406206858783; Thu, 24 Jul 2014 06:00:58 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp362753vcb; Thu, 24 Jul 2014 06:00:58 -0700 (PDT) X-Received: by 10.66.251.98 with SMTP id zj2mr9916018pac.115.1406206857627; Thu, 24 Jul 2014 06:00:57 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id hm5si5909436pac.222.2014.07.24.06.00.57 for ; Thu, 24 Jul 2014 06:00:57 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758988AbaGXNAz (ORCPT + 13 others); Thu, 24 Jul 2014 09:00:55 -0400 Received: from mail-pd0-f182.google.com ([209.85.192.182]:58054 "EHLO mail-pd0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758971AbaGXNAx (ORCPT ); Thu, 24 Jul 2014 09:00:53 -0400 Received: by mail-pd0-f182.google.com with SMTP id fp1so3660457pdb.27 for ; Thu, 24 Jul 2014 06:00:52 -0700 (PDT) X-Received: by 10.66.192.73 with SMTP id he9mr10269902pac.88.1406206852473; Thu, 24 Jul 2014 06:00:52 -0700 (PDT) Received: from localhost ([183.247.163.231]) by mx.google.com with ESMTPSA id w7sm5558770pbs.74.2014.07.24.06.00.45 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 24 Jul 2014 06:00:51 -0700 (PDT) From: Hanjun Guo To: Catalin Marinas , "Rafael J. Wysocki" , Mark Rutland Cc: Graeme Gregory , Arnd Bergmann , Grant Likely , Sudeep Holla , Will Deacon , Jason Cooper , Marc Zyngier , Bjorn Helgaas , Daniel Lezcano , Mark Brown , Robert Richter , Lv Zheng , Robert Moore , Lorenzo Pieralisi , Liviu Dudau , Randy Dunlap , Charles.Garcia-Tobin@arm.com, linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linaro-acpi-private@linaro.org, Al Stone , Tomasz Nowicki , Hanjun Guo Subject: [PATCH 01/19] ARM64 / ACPI: Get RSDP and ACPI boot-time tables Date: Thu, 24 Jul 2014 21:00:07 +0800 Message-Id: <1406206825-15590-2-git-send-email-hanjun.guo@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1406206825-15590-1-git-send-email-hanjun.guo@linaro.org> References: <1406206825-15590-1-git-send-email-hanjun.guo@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: hanjun.guo@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Al Stone As we want to get ACPI tables to parse and then use the information for system initialization, we should get the RSDP (Root System Description Pointer) first, it then locates Extended Root Description Table (XSDT) which contains all the 64-bit physical address that pointer to other boot-time tables. Introduce acpi.c and its related head file in this patch to provide fundamental needs of extern variables and functions for ACPI core, and then get boot-time tables as needed. - asm/cpu.h need for ACPI core and will be updated in the future to add definitions for arch_(un)register_cpu which are required for ACPI based physical CPU hotplug; - asm/acenv.h for arch specific ACPICA environments and implementation; - asm/acpi.h for arch specific variables and functions needed by ACPI driver core; - acpi.c for ARM64 related ACPI implementation for ACPI driver core; acpi_boot_table_init() is introduced to get RSDP and boot-time tables, it will be called in setup_arch() before paging_init(), so we should use eary_memremap() mechanism here to get the RSDP and all the table pointers. Signed-off-by: Al Stone Signed-off-by: Graeme Gregory Signed-off-by: Tomasz Nowicki Signed-off-by: Hanjun Guo --- arch/arm64/include/asm/acenv.h | 18 ++++++++++ arch/arm64/include/asm/acpi.h | 41 ++++++++++++++++++++++ arch/arm64/include/asm/cpu.h | 11 ++++++ arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/acpi.c | 76 ++++++++++++++++++++++++++++++++++++++++ arch/arm64/kernel/setup.c | 4 +++ 6 files changed, 151 insertions(+) create mode 100644 arch/arm64/include/asm/acenv.h create mode 100644 arch/arm64/include/asm/acpi.h create mode 100644 arch/arm64/include/asm/cpu.h create mode 100644 arch/arm64/kernel/acpi.c diff --git a/arch/arm64/include/asm/acenv.h b/arch/arm64/include/asm/acenv.h new file mode 100644 index 0000000..3899ee6 --- /dev/null +++ b/arch/arm64/include/asm/acenv.h @@ -0,0 +1,18 @@ +/* + * ARM64 specific ACPICA environments and implementation + * + * Copyright (C) 2014, Linaro Ltd. + * Author: Hanjun Guo + * Author: Graeme Gregory + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef _ASM_ACENV_H +#define _ASM_ACENV_H + +#define ACPI_FLUSH_CPU_CACHE() WARN_ONCE(1, "Not currently supported on ARM64") + +#endif /* _ASM_ACENV_H */ diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h new file mode 100644 index 0000000..e8581ea --- /dev/null +++ b/arch/arm64/include/asm/acpi.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2013-2014, Linaro Ltd. + * Author: Al Stone + * Author: Graeme Gregory + * Author: Hanjun Guo + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + */ + +#ifndef _ASM_ACPI_H +#define _ASM_ACPI_H + +/* Basic configuration for ACPI */ +#ifdef CONFIG_ACPI +extern int acpi_disabled; +extern int acpi_noirq; +extern int acpi_pci_disabled; +extern int acpi_strict; + +static inline void disable_acpi(void) +{ + acpi_disabled = 1; + acpi_pci_disabled = 1; + acpi_noirq = 1; +} + +/* + * MADT must provide at least one GICC structure + * for GIC initialization, so CPU will be + * always available in MADT on ARM64 + */ +static inline bool acpi_has_cpu_in_madt(void) +{ + return 1; +} + +#endif /* CONFIG_ACPI */ + +#endif /*_ASM_ACPI_H*/ diff --git a/arch/arm64/include/asm/cpu.h b/arch/arm64/include/asm/cpu.h new file mode 100644 index 0000000..cee7d3f --- /dev/null +++ b/arch/arm64/include/asm/cpu.h @@ -0,0 +1,11 @@ +/* + * Copyright (C) 2013-2014 ARM Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +#ifndef __ASM_CPU_H +#define __ASM_CPU_H + +#endif diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index cdaedad..b568c26 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -29,6 +29,7 @@ arm64-obj-$(CONFIG_ARM64_CPU_SUSPEND) += sleep.o suspend.o arm64-obj-$(CONFIG_JUMP_LABEL) += jump_label.o arm64-obj-$(CONFIG_KGDB) += kgdb.o arm64-obj-$(CONFIG_EFI) += efi.o efi-stub.o efi-entry.o +arm64-obj-$(CONFIG_ACPI) += acpi.o obj-y += $(arm64-obj-y) vdso/ obj-m += $(arm64-obj-m) diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c new file mode 100644 index 0000000..c62fce6 --- /dev/null +++ b/arch/arm64/kernel/acpi.c @@ -0,0 +1,76 @@ +/* + * ARM64 Specific Low-Level ACPI Boot Support + * + * Copyright (C) 2013-2014, Linaro Ltd. + * Author: Al Stone + * Author: Graeme Gregory + * Author: Hanjun Guo + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * We never plan to use RSDT on arm/arm64 as its deprecated in spec but this + * variable is still required by the ACPI core + */ +u32 acpi_rsdt_forced; + +int acpi_noirq; /* skip ACPI IRQ initialization */ +int acpi_strict; +int acpi_disabled; +EXPORT_SYMBOL(acpi_disabled); + +int acpi_pci_disabled; /* skip ACPI PCI scan and IRQ initialization */ +EXPORT_SYMBOL(acpi_pci_disabled); + +/* + * __acpi_map_table() will be called before page_init(), so early_ioremap() + * or early_memremap() should be called here to for ACPI table mapping. + */ +char *__init __acpi_map_table(unsigned long phys, unsigned long size) +{ + if (!phys || !size) + return NULL; + + return early_memremap(phys, size); +} + +void __init __acpi_unmap_table(char *map, unsigned long size) +{ + if (!map || !size) + return; + + early_iounmap(map, size); +} + +/* + * acpi_boot_table_init() called from setup_arch(), always. + * 1. find RSDP and get its address, and then find XSDT + * 2. extract all tables and checksums them all + * + * We can parse ACPI boot-time tables such as FADT, MADT after + * this function is called. + */ +void __init acpi_boot_table_init(void) +{ + /* If acpi_disabled, bail out */ + if (acpi_disabled) + return; + + /* Initialize the ACPI boot-time table parser. */ + if (acpi_table_init()) { + disable_acpi(); + return; + } +} diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index 46d1125..9dedb0b 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -385,6 +386,9 @@ void __init setup_arch(char **cmdline_p) efi_init(); arm64_memblock_init(); + /* Parse the ACPI tables for possible boot-time configuration */ + acpi_boot_table_init(); + paging_init(); request_standard_resources();