From patchwork Tue Nov 17 09:40:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 56735 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1826535lbb; Tue, 17 Nov 2015 01:46:53 -0800 (PST) X-Received: by 10.141.23.20 with SMTP id z20mr42520094qhd.52.1447753613279; Tue, 17 Nov 2015 01:46:53 -0800 (PST) Return-Path: Received: from lists.xen.org (lists.xenproject.org. [50.57.142.19]) by mx.google.com with ESMTPS id d125si29211004qka.34.2015.11.17.01.46.53 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 17 Nov 2015 01:46:53 -0800 (PST) Received-SPF: neutral (google.com: 50.57.142.19 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=50.57.142.19; Authentication-Results: mx.google.com; spf=neutral (google.com: 50.57.142.19 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org; dkim=neutral (body hash did not verify) header.i=@linaro_org.20150623.gappssmtp.com Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Zycpe-0005FW-Br; Tue, 17 Nov 2015 09:45:46 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Zycpc-0005Dq-NR for xen-devel@lists.xen.org; Tue, 17 Nov 2015 09:45:44 +0000 Received: from [85.158.139.211] by server-12.bemta-5.messagelabs.com id A4/CC-12831-847FA465; Tue, 17 Nov 2015 09:45:44 +0000 X-Env-Sender: shannon.zhao@linaro.org X-Msg-Ref: server-6.tower-206.messagelabs.com!1447753543!4235762!1 X-Originating-IP: [74.125.82.45] X-SpamReason: No, hits=0.0 required=7.0 tests=UPPERCASE_25_50 X-StarScan-Received: X-StarScan-Version: 7.19.2; banners=-,-,- X-VirusChecked: Checked Received: (qmail 58818 invoked from network); 17 Nov 2015 09:45:43 -0000 Received: from mail-wm0-f45.google.com (HELO mail-wm0-f45.google.com) (74.125.82.45) by server-6.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Nov 2015 09:45:43 -0000 Received: by wmec201 with SMTP id c201so17253422wme.1 for ; Tue, 17 Nov 2015 01:45:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IvWzJrLjuPlmU1eaYr43oAN6dl4rlQR5EoMMdLKM/Io=; b=LRSVXrmMArqPXsK/76dTvdvWhdlv303ukETWQGB8vyDf/opwFWAYElvZG94DIOZkI4 EOusIqsA0ESOmmGCzVTvbwAyV58wuzHrzU+74dL9/fm3ONo2gyadJakeHEQiR6YW3tgE rU8cB9FCFXHKtDfhpCtflRnMgECivA5ep6tdYwRaoKhrtN+E5NHcDM61NyJ9Ge3yVDMW dcYO3OhAQSVzmOv31OnDS9n8+xsfnpbhFm9HPDst57oLivNcaRZH+qijndxezttOkGyQ xNgjK3dh9FsU1CT1rezfxYOB9r286/PqgKv6UKryCgh16erUKBNXRFwwFzAI3mgKX7hm EMpA== 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=IvWzJrLjuPlmU1eaYr43oAN6dl4rlQR5EoMMdLKM/Io=; b=O0+KtO0LO856sk1xwwPy79Co1sdCUMl1jEqOecl42WIOYbR8gJhZZnrPTr5HNncKm6 coWlJLl+zzit0Td07o8tzBa8ERjIEfvN4Vash2AYbVt8ufwdKhcATD3g+FNHg0SW16eQ HAhmW9FHOMDohX7X1q8h7rVUaqEVXDuLNutbSU7l8KZI3LrJnZ6tFgc1IEhExPg6scuN 9wiQTS504XD2RaFMZz54k3tLIXVs+sTDwqJcvaPDC2oLvP79KPSsypc4RoFtrj+kEylT Qi8+aDX+sdtq/lFgynaWEjZ5F/94hlK8vOlS51fas6fZ1vZFzyyoW2QLzfAmKCUEE9hs r4iw== X-Gm-Message-State: ALoCoQnH8PeLlRGgOe4ADsdOmKH6I6VENBbzYtuZtZ/MIrywAS+Vl/tyyX/35T39EBfl/2p22nsV X-Received: by 10.194.186.196 with SMTP id fm4mr50461468wjc.152.1447753543356; Tue, 17 Nov 2015 01:45:43 -0800 (PST) Received: from localhost ([78.129.251.54]) by smtp.gmail.com with ESMTPSA id bh5sm38979171wjb.42.2015.11.17.01.45.41 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 17 Nov 2015 01:45:42 -0800 (PST) From: shannon.zhao@linaro.org To: ian.campbell@citrix.com, stefano.stabellini@citrix.com, keir@xen.org, jbeulich@suse.com, andrew.cooper3@citrix.com, julien.grall@citrix.com, xen-devel@lists.xen.org Date: Tue, 17 Nov 2015 17:40:30 +0800 Message-Id: <1447753261-7552-32-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1447753261-7552-1-git-send-email-shannon.zhao@linaro.org> References: <1447753261-7552-1-git-send-email-shannon.zhao@linaro.org> Cc: mark.rutland@arm.com, hangaohuai@huawei.com, ard.biesheuvel@linaro.org, shannon.zhao@linaro.org, christoffer.dall@linaro.org, peter.huangpeng@huawei.com, david.vrabel@citrix.com, zhaoshenglong@huawei.com, linux-arm-kernel@lists.infradead.org, roger.pau@citrix.com Subject: [Xen-devel] [PATCH v3 31/62] arm/acpi: Add a helper function to get interrupt type X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org From: Shannon Zhao Add a helper funtion to get the type of interrupts in ACPI table. Signed-off-by: Shannon Zhao --- xen/arch/arm/acpi/lib.c | 27 +++++++++++++++++++++++++++ xen/include/asm-arm/acpi.h | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) -- 2.1.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c index d8b7635..47f4c6a 100644 --- a/xen/arch/arm/acpi/lib.c +++ b/xen/arch/arm/acpi/lib.c @@ -43,3 +43,30 @@ bool_t __init acpi_psci_hvc_present(void) { return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_USE_HVC; } + +unsigned int acpi_get_irq_type(u32 flags) +{ + int trigger, polarity; + + trigger = (flags & ACPI_GTDT_INTERRUPT_MODE) ? ACPI_EDGE_SENSITIVE + : ACPI_LEVEL_SENSITIVE; + + polarity = (flags & ACPI_GTDT_INTERRUPT_POLARITY) ? ACPI_ACTIVE_LOW + : ACPI_ACTIVE_HIGH; + + switch (polarity) { + case ACPI_ACTIVE_LOW: + return trigger == ACPI_EDGE_SENSITIVE ? + ACPI_IRQ_TYPE_EDGE_FALLING : + ACPI_IRQ_TYPE_LEVEL_LOW; + case ACPI_ACTIVE_HIGH: + return trigger == ACPI_EDGE_SENSITIVE ? + ACPI_IRQ_TYPE_EDGE_RISING : + ACPI_IRQ_TYPE_LEVEL_HIGH; + case ACPI_ACTIVE_BOTH: + if (trigger == ACPI_EDGE_SENSITIVE) + return ACPI_IRQ_TYPE_EDGE_BOTH; + default: + return ACPI_IRQ_TYPE_NONE; + } +} diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h index 714e596..214fc4e 100644 --- a/xen/include/asm-arm/acpi.h +++ b/xen/include/asm-arm/acpi.h @@ -34,10 +34,12 @@ extern bool_t acpi_disabled; bool_t __init acpi_psci_present(void); bool_t __init acpi_psci_hvc_present(void); void __init acpi_smp_init_cpus(void); +unsigned int acpi_get_irq_type(u32 flags); #else static inline bool_t acpi_psci_present(void) { return false; } static inline bool_t acpi_psci_hvc_present(void) {return false; } static inline void acpi_smp_init_cpus(void) { } +static inline unsigned int acpi_get_irq_type(u32 flags) { return 0; } #endif /* CONFIG_ACPI */ /* Basic configuration for ACPI */ @@ -48,4 +50,41 @@ static inline void disable_acpi(void) #define ACPI_GTDT_INTR_MASK ( ACPI_GTDT_INTERRUPT_MODE | ACPI_GTDT_INTERRUPT_POLARITY ) +/* Triggering */ + +#define ACPI_LEVEL_SENSITIVE (u8) 0x00 +#define ACPI_EDGE_SENSITIVE (u8) 0x01 + +/* Polarity */ + +#define ACPI_ACTIVE_HIGH (u8) 0x00 +#define ACPI_ACTIVE_LOW (u8) 0x01 +#define ACPI_ACTIVE_BOTH (u8) 0x02 + +/** + * IRQ line type. + * + * ACPI_IRQ_TYPE_NONE - default, unspecified type + * ACPI_IRQ_TYPE_EDGE_RISING - rising edge triggered + * ACPI_IRQ_TYPE_EDGE_FALLING - falling edge triggered + * ACPI_IRQ_TYPE_EDGE_BOTH - rising and falling edge triggered + * ACPI_IRQ_TYPE_LEVEL_HIGH - high level triggered + * ACPI_IRQ_TYPE_LEVEL_LOW - low level triggered + * ACPI_IRQ_TYPE_LEVEL_MASK - Mask to filter out the level bits + * ACPI_IRQ_TYPE_SENSE_MASK - Mask for all the above bits + * ACPI_IRQ_TYPE_INVALID - Use to initialize the type + */ +#define ACPI_IRQ_TYPE_NONE 0x00000000 +#define ACPI_IRQ_TYPE_EDGE_RISING 0x00000001 +#define ACPI_IRQ_TYPE_EDGE_FALLING 0x00000002 +#define ACPI_IRQ_TYPE_EDGE_BOTH \ + (ACPI_IRQ_TYPE_EDGE_FALLING | ACPI_IRQ_TYPE_EDGE_RISING) +#define ACPI_IRQ_TYPE_LEVEL_HIGH 0x00000004 +#define ACPI_IRQ_TYPE_LEVEL_LOW 0x00000008 +#define ACPI_IRQ_TYPE_LEVEL_MASK \ + (ACPI_IRQ_TYPE_LEVEL_LOW | ACPI_IRQ_TYPE_LEVEL_HIGH) +#define ACPI_IRQ_TYPE_SENSE_MASK 0x0000000f + +#define ACPI_IRQ_TYPE_INVALID 0x00000010 + #endif /*_ASM_ARM_ACPI_H*/