From patchwork Wed May 11 19:46:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 67620 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp396718qge; Wed, 11 May 2016 12:49:55 -0700 (PDT) X-Received: by 10.55.119.66 with SMTP id s63mr5896799qkc.169.1462996194647; Wed, 11 May 2016 12:49:54 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id a65si2314631qkc.140.2016.05.11.12.49.54 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 11 May 2016 12:49:54 -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; dkim=fail header.i=@gmail.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 Received: from localhost ([::1]:53801 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0a8o-00072M-9T for patch@linaro.org; Wed, 11 May 2016 15:49:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60551) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0a5P-0000LB-3z for qemu-devel@nongnu.org; Wed, 11 May 2016 15:46:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b0a5H-00084n-SL for qemu-devel@nongnu.org; Wed, 11 May 2016 15:46:21 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:35472) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0a5H-00084W-Ii for qemu-devel@nongnu.org; Wed, 11 May 2016 15:46:15 -0400 Received: by mail-pf0-x241.google.com with SMTP id r187so5284140pfr.2 for ; Wed, 11 May 2016 12:46:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=14lit2AKlZ+fdgJPJNoMw5vKkVOLScHrKXxY8ThY5Cs=; b=gI6qALGyhW1bVeX/Uq65JjfnmtxpcPIM7JKymjiM8gdNmkWiuZvLj7gh4G7BHyAEcF F8IL9/4oVWRaLE6Aiobfwc+CGo1cFIGw1SLrK/mgWU2CoDu60Trg5kZ/JYTHUVMoUKCN r2EFq0eRk+txcaMMHSNawpnHP35GgCLso5iCg/81tSlb2SmCjAMPR9/Qx6nmyX9Z/lMl M/bUTK1a/fAPXK5bnN6bo5MOHOPYE5roDq5HEpgU36WZef776PD3KCIx5zbQJts//7tP tcWCm97Cm2+kaWICrCg6BdfAYn3hYFxArtVpDFg96vfDiHmGzc3vYRr5bNH7JBzgTR20 L39A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=14lit2AKlZ+fdgJPJNoMw5vKkVOLScHrKXxY8ThY5Cs=; b=XT4RKKKW4Qzt8hUknftsItTS40PwG9CbkV8CEUXhIV09l6KYGHKSk9hcbR99ty3snN YNGbU5RP6WUyr1D8rkh5ZyOnVybQNMuG/w0XlJfCOH+pzK37mxhhLxZ9jotL7omPzE+g +aUy5TwYha3A6Q/wn6QGC/BZoF18RwR8EAx1vh/21FwMX07R05J7UkGG3gSx3zF7Ja40 0ajLSpi2PljhnlOoVMXHQcFvvTwhkCmHgl5n5eRIeOrUW+3DYHIIDPoxgJv8uNBzTYQy P2qrH13CmA0q/Y1MB4BkyweAqiniRJbagU2ff4IaXb6+GMIDv1mND0jE/qwggWQEeBUJ /CQw== X-Gm-Message-State: AOPr4FU/5CN51NbyCjotP7tMKyTfaPEpcYqVfp8rNVnU/UzhXsI/MzVaa+tJ4tfNxGHL5Q== X-Received: by 10.98.70.144 with SMTP id o16mr7753984pfi.26.1462995974937; Wed, 11 May 2016 12:46:14 -0700 (PDT) Received: from serve.minyard.net ([108.19.215.157]) by smtp.gmail.com with ESMTPSA id o80sm14135859pfa.37.2016.05.11.12.46.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 May 2016 12:46:13 -0700 (PDT) Received: from t430.minyard.net (unknown [IPv6:2001:470:b8f6:1b:a430:dab6:589a:a3a1]) by serve.minyard.net (Postfix) with ESMTPA id CBA1F1D41; Wed, 11 May 2016 14:46:10 -0500 (CDT) Received: by t430.minyard.net (Postfix, from userid 1000) id A84CC30054F; Wed, 11 May 2016 14:46:08 -0500 (CDT) From: minyard@acm.org To: Igor Mammedov , "Michael S . Tsirkin" , Paolo Bonzini , qemu-devel@nongnu.org, minyard@acm.org Date: Wed, 11 May 2016 14:46:04 -0500 Message-Id: <1462995966-1184-6-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1462995966-1184-1-git-send-email-minyard@acm.org> References: <1462995966-1184-1-git-send-email-minyard@acm.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c00::241 Subject: [Qemu-devel] [PATCH 5/7] acpi: Add I2c serial bus CRS handling X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Corey Minyard Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Corey Minyard Signed-off-by: Corey Minyard --- hw/acpi/aml-build.c | 42 ++++++++++++++++++++++++++++++++++++++++++ include/hw/acpi/aml-build.h | 11 +++++++++++ 2 files changed, 53 insertions(+) -- 2.7.4 diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index ab89ca6..7a3874b 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -1563,3 +1563,45 @@ build_rsdt(GArray *table_data, GArray *linker, GArray *table_offsets, build_header(linker, table_data, (void *)rsdt, "RSDT", rsdt_len, 1, oem_id, oem_table_id); } + +static Aml *aml_serial_bus_device(AmlSerialBusType type, uint8_t flags, + uint16_t type_flags, + uint8_t revid, uint16_t data_length, + uint16_t resource_source_length) +{ + Aml *var = aml_alloc(); + uint16_t length = data_length + resource_source_length + 9; + + build_append_byte(var->buf, 0x8e); /* Serial Bus Connection Descriptor */ + build_append_byte(var->buf, length & 0xff); + build_append_byte(var->buf, length >> 8); + build_append_byte(var->buf, 1); /* Revision */ + build_append_byte(var->buf, 0); /* Resource source index */ + build_append_byte(var->buf, type); /* Serial bus type */ + build_append_byte(var->buf, flags); /* Serial bus type */ + build_append_byte(var->buf, type_flags & 0xff); + build_append_byte(var->buf, type_flags >> 8); + build_append_byte(var->buf, revid); + build_append_byte(var->buf, data_length & 0xff); + build_append_byte(var->buf, data_length >> 8); + + return var; +} + +Aml *aml_i2c_serial_bus_device(uint8_t flags, uint32_t con_speed, + uint16_t address, const char *resource_source) +{ + unsigned int resource_source_len = strlen(resource_source) + 1; + Aml *var = aml_serial_bus_device(aml_serial_bus_type_i2c, flags, 0, 1, + 6, resource_source_len); + + build_append_byte(var->buf, con_speed & 0xff); + build_append_byte(var->buf, (con_speed >> 8) & 0xff); + build_append_byte(var->buf, (con_speed >> 16) & 0xff); + build_append_byte(var->buf, (con_speed >> 24) & 0xff); + build_append_byte(var->buf, address & 0xff); + build_append_byte(var->buf, address >> 8); + g_array_append_vals(var->buf, resource_source, resource_source_len); + + return var; +} diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index 2c994b3..1eb3ebd 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -206,6 +206,15 @@ struct AcpiBuildTables { GArray *linker; } AcpiBuildTables; +typedef enum { + aml_serial_bus_type_i2c = 1, + aml_serial_bus_type_spi = 2, + aml_serial_bus_type_uart = 3 +} AmlSerialBusType; + +#define AML_SERIAL_BUS_FLAG_MASTER_DEVICE (1 << 0) +#define AML_SERIAL_BUS_FLAG_CONSUME_ONLY (1 << 1) + /** * init_aml_allocator: * @@ -327,6 +336,8 @@ Aml *aml_qword_memory(AmlDecode dec, AmlMinFixed min_fixed, Aml *aml_dma(AmlDmaType typ, AmlDmaBusMaster bm, AmlTransferSize sz, uint8_t channel); Aml *aml_sleep(uint64_t msec); +Aml *aml_i2c_serial_bus_device(uint8_t flags, uint32_t con_speed, + uint16_t address, const char *resource_source); /* Block AML object primitives */ Aml *aml_scope(const char *name_format, ...) GCC_FMT_ATTR(1, 2);