From patchwork Mon Feb 29 12:42:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksey Makarov X-Patchwork-Id: 63206 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp1223886lbc; Mon, 29 Feb 2016 04:43:31 -0800 (PST) X-Received: by 10.98.9.219 with SMTP id 88mr22238723pfj.0.1456749805312; Mon, 29 Feb 2016 04:43:25 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h7si3212675pat.114.2016.02.29.04.43.25; Mon, 29 Feb 2016 04:43:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-serial-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-serial-owner@vger.kernel.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755179AbcB2MnR (ORCPT + 1 other); Mon, 29 Feb 2016 07:43:17 -0500 Received: from mail-lb0-f176.google.com ([209.85.217.176]:32920 "EHLO mail-lb0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754917AbcB2MnN (ORCPT ); Mon, 29 Feb 2016 07:43:13 -0500 Received: by mail-lb0-f176.google.com with SMTP id ed16so982052lbb.0 for ; Mon, 29 Feb 2016 04:43:12 -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=lSvJ0159NskUgFAMjjpvCr6VHxBESTA7MhLkb8O0aFc=; b=P5fbx+a1NtmIw5IhHs+u6O/ZYpoVXuvWj3qwhsyC40APvvvUztCZVk/gwt1N0ji95L SZA18LNYNQ0mPnWutqgB8Df+wMVeHCMvqhrboA5Cam57x4zv7+jDZnGsH45pTWfnc0r6 IUFIRn9KKZ2iFdHLvBA3upNcn18GsF6clte8U= 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=lSvJ0159NskUgFAMjjpvCr6VHxBESTA7MhLkb8O0aFc=; b=Lfd/vgPWj/sYB/Y2hLAvRQ8cXTb/22DANuq808w+sStqY5hTym7yexlvPXDfbsSGHy nq3lctdPaZzJY1Q7Olw+g4ICrYJmIq/ANEM1o4croWwuB6yHwtMIvyZKGNV0sOk9uX3l zGvl9U2o8oNADmKFXPxKW0P27UI92aMDnETgse8qg1EhaaRrOy++SpGBTS1XrOqhV7e2 uWvG/y3ZlPPm1V6LPtBJhTRRuxMt8eNkWnRfcvdVIiJ3i1xFdo3kmJ1lOADVZf6OoGsL lddI9fntWtsbTa95AF6RDTnllwb33OVc0oL/iO14VwD5O0orwAXUBOVc9woKaRXcI5WE 7EYA== X-Gm-Message-State: AD7BkJLHdc8b9o/Ya3iw9tHtp7e2O0j+OY0tVw78lt6yRKm2GLof9S9+IiPHO850z1512/qF X-Received: by 10.112.209.68 with SMTP id mk4mr5436496lbc.45.1456749791760; Mon, 29 Feb 2016 04:43:11 -0800 (PST) Received: from turnip.localdomain (nivc-213.auriga.ru. [80.240.102.213]) by smtp.gmail.com with ESMTPSA id ke9sm3929150lbc.28.2016.02.29.04.43.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 29 Feb 2016 04:43:11 -0800 (PST) From: Aleksey Makarov To: linux-acpi@vger.kernel.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Aleksey Makarov , Russell King , Greg Kroah-Hartman , "Rafael J . Wysocki" , Leif Lindholm , Graeme Gregory , Al Stone , Christopher Covington , Matthias Brugger , Len Brown , Arnd Bergmann , linux-arch@vger.kernel.org Subject: [PATCH v3 4/7] ACPI: parse DBG2 table Date: Mon, 29 Feb 2016 15:42:01 +0300 Message-Id: <1456749726-30261-5-git-send-email-aleksey.makarov@linaro.org> X-Mailer: git-send-email 2.7.1 In-Reply-To: <1456749726-30261-1-git-send-email-aleksey.makarov@linaro.org> References: <1456749726-30261-1-git-send-email-aleksey.makarov@linaro.org> Sender: linux-serial-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org 'ARM Server Base Boot Requirements' [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 | 88 +++++++++++++++++++++++++++++++++++++++ include/asm-generic/vmlinux.lds.h | 1 + include/linux/acpi_dbg2.h | 48 +++++++++++++++++++++ 5 files changed, 141 insertions(+) create mode 100644 drivers/acpi/dbg2.c create mode 100644 include/linux/acpi_dbg2.h -- 2.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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..0f0f6ca --- /dev/null +++ b/drivers/acpi/dbg2.c @@ -0,0 +1,88 @@ +/* + * 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) { + if (dbg2_device->port_type == ACPI_DBG2_SERIAL_PORT) + pr_info("debug port: SERIAL; subtype: %s\n", + subtype2string(dbg2_device->port_subtype)); + else + pr_info("debug port: %s\n", + type2string(dbg2_device->port_type)); + 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 8f5a12a..8cc49ba 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -526,6 +526,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