From patchwork Tue May 12 04:24:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 48325 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D590921550 for ; Tue, 12 May 2015 04:25:57 +0000 (UTC) Received: by lbbqq2 with SMTP id qq2sf43301365lbb.0 for ; Mon, 11 May 2015 21:25:56 -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:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=6RcNxx8N2eKYCDtH2l+icYcmJrK0uChn4Gib6TWWUdo=; b=Lj6Tnb0n/9nAiW+aAuCr0PHX5no1DxIhREMv694WjzwqyJvIiAUbluFZMrQqpqq6tY DXJXz90aW7Hew/JW3aGP2DXX9sXG8Wy0TWy8fUHlhfWRU9s+2ENLn87iu7icieRW0BQ5 ofU56EQF8vUKUnNg0MtX5mxUZqOYZO1MyfkI6kejAUS6r8Q44Dv1wtFGzkBIzf5fLFF9 u9pS9daJAZqiMKghyqxxuTZG+WHR7kjLE9DmV9MJkj3aM0nhGsQ+/0ebpHVE1/PdMJay KvmjFLxWx8uvWs4DVQAZpPMbdE0fS3fUCM+XtNK7Kl9j00zIkGivpky/Hg9YEiEWKkY9 DT8g== X-Gm-Message-State: ALoCoQnpJ6vpQ3BFApa2ksKtampWkw08st+xiuWMRkn9IwRyG9zWthiypnd0fkCw3XqLNdNo4dgw X-Received: by 10.112.26.5 with SMTP id h5mr9443168lbg.4.1431404756733; Mon, 11 May 2015 21:25:56 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.163.65 with SMTP id yg1ls656947lab.26.gmail; Mon, 11 May 2015 21:25:56 -0700 (PDT) X-Received: by 10.112.172.35 with SMTP id az3mr10044346lbc.99.1431404756384; Mon, 11 May 2015 21:25:56 -0700 (PDT) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id pk3si9555935lbb.75.2015.05.11.21.25.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 May 2015 21:25:56 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by layy10 with SMTP id y10so107851802lay.0 for ; Mon, 11 May 2015 21:25:56 -0700 (PDT) X-Received: by 10.152.37.228 with SMTP id b4mr2255022lak.117.1431404756100; Mon, 11 May 2015 21:25:56 -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.112.108.230 with SMTP id hn6csp1855470lbb; Mon, 11 May 2015 21:25:55 -0700 (PDT) X-Received: by 10.55.54.136 with SMTP id d130mr27967133qka.22.1431404753451; Mon, 11 May 2015 21:25:53 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id l92si15024152qgf.83.2015.05.11.21.25.52 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 11 May 2015 21:25:53 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:40775 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ys1lQ-0006j0-Dc for patch@linaro.org; Tue, 12 May 2015 00:25:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54235) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ys1kT-0005h6-Vg for qemu-devel@nongnu.org; Tue, 12 May 2015 00:24:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ys1kN-0006vO-IP for qemu-devel@nongnu.org; Tue, 12 May 2015 00:24:53 -0400 Received: from mail-pd0-f177.google.com ([209.85.192.177]:35678) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ys1kN-0006vC-C6 for qemu-devel@nongnu.org; Tue, 12 May 2015 00:24:47 -0400 Received: by pdbqd1 with SMTP id qd1so166858823pdb.2 for ; Mon, 11 May 2015 21:24:46 -0700 (PDT) X-Received: by 10.66.140.101 with SMTP id rf5mr24991681pab.50.1431404686748; Mon, 11 May 2015 21:24:46 -0700 (PDT) Received: from localhost ([180.150.141.243]) by mx.google.com with ESMTPSA id lc14sm14669343pab.33.2015.05.11.21.24.44 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 11 May 2015 21:24:45 -0700 (PDT) From: shannon.zhao@linaro.org To: qemu-devel@nongnu.org, peter.maydell@linaro.org, imammedo@redhat.com, mst@redhat.com, pbonzini@redhat.com, wei@redhat.com, arnd@arndb.de, christoffer.dall@linaro.org Date: Tue, 12 May 2015 12:24:13 +0800 Message-Id: <1431404656-7180-5-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1431404656-7180-1-git-send-email-shannon.zhao@linaro.org> References: <1431404656-7180-1-git-send-email-shannon.zhao@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.192.177 Cc: hangaohuai@huawei.com, peter.huangpeng@huawei.com, zhaoshenglong@huawei.com Subject: [Qemu-devel] [PATCH 4/7] hw/acpi/aml-build: Add aml_gpio_int() term X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: shannon.zhao@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.215.53 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 From: Shannon Zhao Signed-off-by: Shannon Zhao Signed-off-by: Shannon Zhao --- hw/acpi/aml-build.c | 60 +++++++++++++++++++++++++++++++++++++++++++++ include/hw/acpi/aml-build.h | 16 ++++++++++++ 2 files changed, 76 insertions(+) diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index 643e885..40d7fa0 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -525,6 +525,66 @@ Aml *aml_call4(const char *method, Aml *arg1, Aml *arg2, Aml *arg3, Aml *arg4) } /* + * ACPI 5.0: 19.5.53 + * GpioInt(GPIO Interrupt Connection Resource Descriptor Macro) + */ +Aml *aml_gpio_int(AmlLevelAndEdge level_and_edge, + AmlActiveHighAndLow high_and_low, + AmlExclusiveAndShared exclusive_and_shared, + AmlWakeCap wake_capable, AmlPinConfig pin_cfg, + int32_t pin_num, const char *name) +{ + Aml *var = aml_alloc(); + uint8_t flags = level_and_edge | (high_and_low << 1) + | (exclusive_and_shared << 3) | (wake_capable << 4); + + build_append_byte(var->buf, 0x8C); /* GpioInt Resource Descriptor */ + /* Length */ + build_append_byte(var->buf, 0x1B); /* bits[7:0] */ + build_append_byte(var->buf, 0); /* bits[15:8] */ + build_append_byte(var->buf, 1); /* Revision ID */ + /* GPIO Connection Type 0x00 = Interrupt Connection */ + build_append_byte(var->buf, 0); + /* General Flags */ + build_append_byte(var->buf, 1); /* bits[7:0] */ + build_append_byte(var->buf, 0); /* bits[15:8] */ + /* Interrupt and IO Flags */ + build_append_byte(var->buf, flags); /* bits[7:0] */ + build_append_byte(var->buf, 0); /* bits[15:8] */ + /* Pin Configuration 0 = Default 1 = Pull-up 2 = Pull-down 3 = No Pull */ + build_append_byte(var->buf, pin_cfg); + /* Output Drive Strength */ + build_append_byte(var->buf, 0); /* bits[7:0] */ + build_append_byte(var->buf, 0); /* bits[15:8] */ + /* Debounce timeout */ + build_append_byte(var->buf, 0); /* bits[7:0] */ + build_append_byte(var->buf, 0); /* bits[15:8] */ + + /* Pin Table Offset */ + build_append_byte(var->buf, 0x17); /* bits[7:0] */ + build_append_byte(var->buf, 0); /* bits[15:8] */ + /* Resource Source Index */ + build_append_byte(var->buf, 0); + /* Resource Source Name */ + build_append_byte(var->buf, 0x19); /* bits[7:0] */ + build_append_byte(var->buf, 0); /* bits[15:8] */ + /* Vendor Data Offse */ + build_append_byte(var->buf, 0x1E); /* bits[7:0] */ + build_append_byte(var->buf, 0); /* bits[15:8] */ + /* Vendor Data Length */ + build_append_byte(var->buf, 0); /* bits[7:0] */ + build_append_byte(var->buf, 0); /* bits[15:8] */ + /* Pin Numbe */ + build_append_byte(var->buf, pin_num & 0xff); /* bits[7:0] */ + build_append_byte(var->buf, (pin_num >> 8) & 0xff); /* bits[15:8] */ + /* Resource Source */ + build_append_namestring(var->buf, "%s", name); + build_append_byte(var->buf, '\0'); + + return var; +} + +/* * ACPI 1.0: 6.4.3.4 Memory32Fixed (Memory Resource Descriptor Macro) */ Aml *aml_memory32_fixed(uint32_t addr, uint32_t size, diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index 39b44e4..b95a8e8 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -150,6 +150,17 @@ typedef enum { aml_wake_capable = 1, } AmlWakeCap; +/* + * ACPI 5.0: Table 6-189 GPIO Connection Descriptor Definition + * _PPI field definition + */ +typedef enum { + aml_default_config = 0, + aml_pull_up = 1, + aml_pull_down = 2, + aml_no_pull = 3, +} AmlPinConfig; + typedef struct AcpiBuildTables { GArray *table_data; @@ -208,6 +219,11 @@ Aml *aml_call1(const char *method, Aml *arg1); Aml *aml_call2(const char *method, Aml *arg1, Aml *arg2); Aml *aml_call3(const char *method, Aml *arg1, Aml *arg2, Aml *arg3); Aml *aml_call4(const char *method, Aml *arg1, Aml *arg2, Aml *arg3, Aml *arg4); +Aml *aml_gpio_int(AmlLevelAndEdge level_and_edge, + AmlActiveHighAndLow high_and_low, + AmlExclusiveAndShared exclusive_and_shared, + AmlWakeCap wake_capable, AmlPinConfig pin_cfg, + int32_t pin_num, const char *name); Aml *aml_memory32_fixed(uint32_t addr, uint32_t size, AmlReadAndWrite read_and_write); Aml *aml_interrupt(AmlConsumerAndProducer con_and_pro,