From patchwork Thu Oct 29 14:27:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 55784 Delivered-To: patch@linaro.org Received: by 10.202.175.130 with SMTP id y124csp456001oie; Thu, 29 Oct 2015 07:31:58 -0700 (PDT) X-Received: by 10.140.96.200 with SMTP id k66mr2595109qge.81.1446129118242; Thu, 29 Oct 2015 07:31:58 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id t70si1443754qkt.85.2015.10.29.07.31.58 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 29 Oct 2015 07:31:58 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dkim=fail header.i=@linaro_org.20150623.gappssmtp.com Received: from localhost ([::1]:44409 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZroFB-0003Rd-Qi for patch@linaro.org; Thu, 29 Oct 2015 10:31:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56301) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZroCT-0008MS-Dg for qemu-devel@nongnu.org; Thu, 29 Oct 2015 10:29:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZroCR-0000KJ-Cu for qemu-devel@nongnu.org; Thu, 29 Oct 2015 10:29:09 -0400 Received: from mail-pa0-x22a.google.com ([2607:f8b0:400e:c03::22a]:36336) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZroCR-0000K7-5M for qemu-devel@nongnu.org; Thu, 29 Oct 2015 10:29:07 -0400 Received: by pacfv9 with SMTP id fv9so44362162pac.3 for ; Thu, 29 Oct 2015 07:29:06 -0700 (PDT) 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=NPN78Q6FLoogoMTyAZJjOqcKooRUH8Sr0f62OvkeyIU=; b=re+30Y+C7LaE8X1zripI4Mu9uyQoBOGYK3DzfsdR/2JttLNlPV87oYPwd2LfbRyszb rZaOTxTwBWj75zkaBZvsc1keePoPreVnqu9UQ0okLWGZKOc6jtN8paqLGuYeW1NKUZSQ rZk0oc5xa+T0v+EpJWSsd1/cb2MG7Y2ENcTuxWa1g42+/mn/wT22Bsok1AeedPPxcdYe n+mdLy0Asdktt+bUl3cTQ9QRSRxCL0qGvt53zCGknFfKu9SqbFa6NiCRTwIIeeYspzKP cvPdadibv0R3usGN+TUkymR3jwU89nRupjVzjGFplKruTuFCQIHWSYcNsMjCxA3qZwHA N+Bg== 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=NPN78Q6FLoogoMTyAZJjOqcKooRUH8Sr0f62OvkeyIU=; b=Avvr77KcdRV0kcFJLBpQdA4hB60vSMnvO0rF2BKkzi6qhrkzXPEu6CfXV/du6/VB3Z kfzl432HxYxnFuBndvYIkOKEafDPko8X0v/rRhfHDa8xgjgiWR2DrGtLGCck6sAhm390 0vZYjvjGig/LRdPSyWXNUaz9/njGiqumuMUVicExYPYmIKsE2CqtFHqgvM0zHaL5V+8M HdGox8cn8CTqJJoTrI6XL0OGJzJDaYV8KyW+mLUhX7Z5QS2/cUwCsLhIKBgaXPm57I8H k718ozUFa8Slj7wXfKNfwJgBzQxhUn0v6XBh9wLCbycYV8MwQWlo7dyg10vU6b7m1I6F 8AEw== X-Gm-Message-State: ALoCoQm2nAIaVBf1+S+IYipvVIh8/olpFRh6miZeoJHWkFsk55JrX405N/9mEP2PZFf9fZ00Pzxd X-Received: by 10.66.172.144 with SMTP id bc16mr2099192pac.114.1446128946619; Thu, 29 Oct 2015 07:29:06 -0700 (PDT) Received: from localhost.localdomain ([180.150.157.4]) by smtp.gmail.com with ESMTPSA id a5sm1805986pbu.55.2015.10.29.07.29.00 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Oct 2015 07:29:05 -0700 (PDT) From: Shannon Zhao To: qemu-devel@nongnu.org, peter.maydell@linaro.org, mst@redhat.com, imammedo@redhat.com Date: Thu, 29 Oct 2015 22:27:31 +0800 Message-Id: <1446128855-26637-5-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1446128855-26637-1-git-send-email-shannon.zhao@linaro.org> References: <1446128855-26637-1-git-send-email-shannon.zhao@linaro.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c03::22a Cc: zhaoshenglong@huawei.com, peter.huangpeng@huawei.com, shannon.zhao@linaro.org Subject: [Qemu-devel] [PATCH v2 4/8] hw/acpi/aml-build: Add GPIO Connection Descriptor 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 Signed-off-by: Shannon Zhao Signed-off-by: Shannon Zhao --- hw/acpi/aml-build.c | 61 +++++++++++++++++++++++++++++++++++++++++++++ include/hw/acpi/aml-build.h | 20 +++++++++++++++ 2 files changed, 81 insertions(+) -- 2.1.0 diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index 0d4b324..250941f 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -565,6 +565,67 @@ Aml *aml_call4(const char *method, Aml *arg1, Aml *arg2, Aml *arg3, Aml *arg4) } /* + * ACPI 5.0: 6.4.3.8.1 GPIO Connection Descriptor + * Type 1, Large Item Name 0xC + */ + +static Aml *aml_gpio_connection(AmlGpioConnectionType type, + AmlConsumerAndProducer con_and_pro, + uint8_t flags, AmlPinConfig pin_cfg, + int16_t output_drive, int16_t debounce_timeout, + int32_t pin_num[], int32_t pin_count, + const char *name, const char *vendor_data) +{ + Aml *var = aml_alloc(); + uint16_t name_len = name ? (strlen(name) + 1) : 0; + uint16_t vendor_data_len = vendor_data ? (strlen(vendor_data) + 1) : 0; + uint16_t length = 0x16 + name_len + vendor_data_len; + uint16_t name_offset = 0x17 + pin_count * 2; + uint16_t vendor_data_offset = name_offset + name_len; + int i; + + build_append_byte(var->buf, 0x8C); /* GpioInt Resource Descriptor */ + build_append_int_noprefix(var->buf, length, 2); /* Length */ + build_append_byte(var->buf, 1); /* Revision ID */ + build_append_byte(var->buf, type); /* GPIO Connection Type */ + /* General Flags (2 bytes) */ + build_append_int_noprefix(var->buf, con_and_pro, 2); + /* Interrupt and IO Flags (2 bytes) */ + build_append_int_noprefix(var->buf, flags, 2); + /* Pin Configuration 0 = Default 1 = Pull-up 2 = Pull-down 3 = No Pull */ + build_append_byte(var->buf, pin_cfg); + /* Output Drive Strength (2 bytes) */ + build_append_int_noprefix(var->buf, output_drive, 2); + /* Debounce Timeout (2 bytes) */ + build_append_int_noprefix(var->buf, debounce_timeout, 2); + /* Pin Table Offset (2 bytes) */ + build_append_int_noprefix(var->buf, 0x17, 2); + build_append_byte(var->buf, 0); /* Resource Source Index */ + /* Resource Source Name Offset (2 bytes) */ + build_append_int_noprefix(var->buf, name_offset, 2); + /* Vendor Data Offset (2 bytes) */ + build_append_int_noprefix(var->buf, vendor_data_offset, 2); + /* Vendor Data Length (2 bytes) */ + build_append_int_noprefix(var->buf, vendor_data_len, 2); + /* Pin Number (2n bytes)*/ + for (i = 0; i < pin_count; i++) { + build_append_int_noprefix(var->buf, pin_num[i], 2); + } + /* Resource Source Name */ + if (name != NULL) { + build_append_namestring(var->buf, "%s", name); + build_append_byte(var->buf, '\0'); + } + /* Vendor-defined Data */ + if (vendor_data != NULL) { + build_append_namestring(var->buf, "%s", vendor_data); + build_append_byte(var->buf, '\0'); + } + + return var; +} + +/* * ACPI 1.0b: 6.4.3.4 32-Bit Fixed Location Memory Range Descriptor * (Type 1, Large Item Name 0x6) */ diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index 1b632dc..4e88882 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -148,6 +148,26 @@ typedef enum { AML_SHARED_AND_WAKE = 3, } AmlShared; +/* + * ACPI 5.0: Table 6-189 GPIO Connection Descriptor Definition + * GPIO Connection Type + */ +typedef enum { + AML_INTERRUPT_CONNECTION = 0, + AML_IO_CONNECTION = 1, +} AmlGpioConnectionType; + +/* + * 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;