From patchwork Wed Feb 24 17:10:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksey Makarov X-Patchwork-Id: 8410031 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 471BA9F372 for ; Wed, 24 Feb 2016 17:15:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3334F202E9 for ; Wed, 24 Feb 2016 17:15:02 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2A83C202AE for ; Wed, 24 Feb 2016 17:15:01 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aYd02-0008Jt-3b; Wed, 24 Feb 2016 17:13:18 +0000 Received: from mail-lf0-x232.google.com ([2a00:1450:4010:c07::232]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aYcyC-00077y-1p for linux-arm-kernel@lists.infradead.org; Wed, 24 Feb 2016 17:11:32 +0000 Received: by mail-lf0-x232.google.com with SMTP id j78so16193659lfb.1 for ; Wed, 24 Feb 2016 09:11:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2pC4sfjHsILzYBZ/PF8+f4jVNESw1a0HEO3ZKFZvlmU=; b=IAn3ncFaeSuL1CHNCrSXk+QzVCnN32J2LH2/BNUQ640T3BpcETCXeOQJHcuwEmKpXJ f+CXQyvb2Jvxb/UXHZY6hZwM9bQm17I+EMcyJVQArtjXd166AzMlMzetFWlJZGgq0S+r fbBe73sZIW4IYsxawWmEXMFBaqHFvBev6i2LQ= 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=2pC4sfjHsILzYBZ/PF8+f4jVNESw1a0HEO3ZKFZvlmU=; b=ey5bVphXJN4RewxwxAoM+o/HTJHVZOzumgFfAPG7/okiSnfFBT9oXGH7wbf7yUaMCv w3MLZJyWh9gaFEiZ7WTg7Dkk7BbdeIpgkK8mPYx2grYEJm77hM2byLr/t2m5lVUJF/EK Y/qNd8o715NjnsFcrKs+500mYHQWZt7/Xzv5B/6sq21KLW40ZzVm3DKz2P31I4AzvbyS A1Z9o2JPwGy6zPExfKcRyK2pc0nQ5HovGdULkGB1HnPBRYaF7tnFKuv4Pf+T9Fs+25J4 kwz1PkyU35F41E2n7P7Jw5SOwlHqe/vOZL3LbJrPlHvRzIfcABlqP9xu/GlexYeweUr8 8QWA== X-Gm-Message-State: AG10YORkzYdYYT4+IdEQNHSgl0ppVcMHiJ20UJm7uiFak/LX5ei6R0wCbMJLYAdvE0hwhKgI X-Received: by 10.25.158.136 with SMTP id h130mr15424147lfe.108.1456333862146; Wed, 24 Feb 2016 09:11:02 -0800 (PST) Received: from turnip.localdomain (nivc-213.auriga.ru. [80.240.102.213]) by smtp.gmail.com with ESMTPSA id ne8sm509556lbc.21.2016.02.24.09.11.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 24 Feb 2016 09:11:01 -0800 (PST) From: Aleksey Makarov To: linux-acpi@vger.kernel.org Subject: [PATCH v2 5/8] ACPI: parse DBG2 table Date: Wed, 24 Feb 2016 20:10:14 +0300 Message-Id: <1456333819-13482-6-git-send-email-aleksey.makarov@linaro.org> X-Mailer: git-send-email 2.7.1 In-Reply-To: <1456333819-13482-1-git-send-email-aleksey.makarov@linaro.org> References: <1456333819-13482-1-git-send-email-aleksey.makarov@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160224_091124_808327_55CE2A32 X-CRM114-Status: GOOD ( 22.26 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, Russell King , Arnd Bergmann , Graeme Gregory , Greg Kroah-Hartman , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, Leif Lindholm , Aleksey Makarov , Christopher Covington , linux-serial@vger.kernel.org, Al Stone , linux-arm-kernel@lists.infradead.org, Len Brown MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 'ARM Server Base Boot Requiremets' [1] mentions DBG2 (Microsoft Debug Port Table 2) [2] as a mandatory ACPI table that specifies debug ports. - Implement macros ACPI_DBG2_DECLARE(name, type, subtype, setup_fn, data_ptr) that defines a handler for the port of given type and subtype. - For each declared port that is also described in the ACPI DBG2 table call the provided callback. [1] http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.den0044a/index.html [2] http://go.microsoft.com/fwlink/p/?LinkId=234837 Signed-off-by: Aleksey Makarov --- drivers/acpi/Kconfig | 3 ++ drivers/acpi/Makefile | 1 + drivers/acpi/dbg2.c | 85 +++++++++++++++++++++++++++++++++++++++ include/asm-generic/vmlinux.lds.h | 1 + include/linux/acpi_dbg2.h | 48 ++++++++++++++++++++++ 5 files changed, 138 insertions(+) create mode 100644 drivers/acpi/dbg2.c create mode 100644 include/linux/acpi_dbg2.h diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 65fb483..660666e 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -57,6 +57,9 @@ config ACPI_SYSTEM_POWER_STATES_SUPPORT config ACPI_CCA_REQUIRED bool +config ACPI_DBG2_TABLE + bool + config ACPI_DEBUGGER bool "AML debugger interface" select ACPI_DEBUG diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index 7395928..3b5f1ea 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile @@ -83,6 +83,7 @@ obj-$(CONFIG_ACPI_CUSTOM_METHOD)+= custom_method.o obj-$(CONFIG_ACPI_BGRT) += bgrt.o obj-$(CONFIG_ACPI_CPPC_LIB) += cppc_acpi.o obj-$(CONFIG_ACPI_DEBUGGER_USER) += acpi_dbg.o +obj-$(CONFIG_ACPI_DBG2_TABLE) += dbg2.o # processor has its own "processor." module_param namespace processor-y := processor_driver.o diff --git a/drivers/acpi/dbg2.c b/drivers/acpi/dbg2.c new file mode 100644 index 0000000..8a79117 --- /dev/null +++ b/drivers/acpi/dbg2.c @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2012, Intel Corporation + * Copyright (c) 2015, 2016 Linaro 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. + * + */ + +#define pr_fmt(fmt) "ACPI: DBG2: " fmt + +#include +#include +#include + +static const char * __init type2string(u16 type) +{ + switch (type) { + case ACPI_DBG2_SERIAL_PORT: + return "SERIAL"; + case ACPI_DBG2_1394_PORT: + return "1394"; + case ACPI_DBG2_USB_PORT: + return "USB"; + case ACPI_DBG2_NET_PORT: + return "NET"; + default: + return "?"; + } +} + +static const char * __init subtype2string(u16 subtype) +{ + switch (subtype) { + case ACPI_DBG2_16550_COMPATIBLE: + return "16550_COMPATIBLE"; + case ACPI_DBG2_16550_SUBSET: + return "16550_SUBSET"; + case ACPI_DBG2_ARM_PL011: + return "ARM_PL011"; + case ACPI_DBG2_ARM_SBSA_32BIT: + return "ARM_SBSA_32BIT"; + case ACPI_DBG2_ARM_SBSA_GENERIC: + return "ARM_SBSA_GENERIC"; + case ACPI_DBG2_ARM_DCC: + return "ARM_DCC"; + case ACPI_DBG2_BCM2835: + return "BCM2835"; + default: + return "?"; + } +} + +int __init acpi_dbg2_setup(struct acpi_table_header *table, const void *data) +{ + struct acpi_table_dbg2 *dbg2 = (struct acpi_table_dbg2 *)table; + struct acpi_dbg2_data *dbg2_data = (struct acpi_dbg2_data *)data; + struct acpi_dbg2_device *dbg2_device, *dbg2_end; + int i; + + dbg2_device = ACPI_ADD_PTR(struct acpi_dbg2_device, dbg2, + dbg2->info_offset); + dbg2_end = ACPI_ADD_PTR(struct acpi_dbg2_device, dbg2, table->length); + + for (i = 0; i < dbg2->info_count; i++) { + if (dbg2_device + 1 > dbg2_end) { + pr_err("device pointer overflows, bad table\n"); + return 0; + } + + if (dbg2_device->port_type == dbg2_data->port_type && + dbg2_device->port_subtype == dbg2_data->port_subtype) { + pr_info("debug port type: %s subtype: %s\n", + type2string(dbg2_device->port_type), + subtype2string(dbg2_device->port_subtype)); + dbg2_data->setup(dbg2_device, dbg2_data->data); + } + + dbg2_device = ACPI_ADD_PTR(struct acpi_dbg2_device, dbg2_device, + dbg2_device->length); + } + + return 0; +} diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index e9a81a6..ab6a727 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -525,6 +525,7 @@ IRQCHIP_OF_MATCH_TABLE() \ ACPI_PROBE_TABLE(irqchip) \ ACPI_PROBE_TABLE(clksrc) \ + ACPI_PROBE_TABLE(dbg2) \ EARLYCON_TABLE() #define INIT_TEXT \ diff --git a/include/linux/acpi_dbg2.h b/include/linux/acpi_dbg2.h new file mode 100644 index 0000000..125ae7e --- /dev/null +++ b/include/linux/acpi_dbg2.h @@ -0,0 +1,48 @@ +#ifndef _ACPI_DBG2_H_ +#define _ACPI_DBG2_H_ + +#ifdef CONFIG_ACPI_DBG2_TABLE + +#include + +struct acpi_dbg2_device; +struct acpi_table_header; + +struct acpi_dbg2_data { + u16 port_type; + u16 port_subtype; + int (*setup)(struct acpi_dbg2_device *, void *); + void *data; +}; + +int acpi_dbg2_setup(struct acpi_table_header *header, const void *data); + +/** + * ACPI_DBG2_DECLARE() - Define handler for ACPI DBG2 port + * @name: Identifier to compose name of table data + * @type: Type of the port + * @subtype: Subtype of the port + * @setup_fn: Function to be called to setup the port + * (of type int (*)(struct acpi_dbg2_device *, void *);) + * @data_ptr: Sideband data provided back to the driver + */ +#define ACPI_DBG2_DECLARE(name, type, subtype, setup_fn, data_ptr) \ + static const struct acpi_dbg2_data \ + __acpi_dbg2_data_##name __used = { \ + .port_type = type, \ + .port_subtype = subtype, \ + .setup = setup_fn, \ + .data = data_ptr, \ + }; \ + ACPI_DECLARE_PROBE_ENTRY(dbg2, name, ACPI_SIG_DBG2, \ + acpi_dbg2_setup, &__acpi_dbg2_data_##name) + +#else + +#define ACPI_DBG2_DECLARE(name, type, subtype, setup_fn, data_ptr) \ + static const void *__acpi_dbg_data_##name[] \ + __used __initdata = { (void *)setup_fn, (void *)data_ptr } + +#endif + +#endif