Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1163158

Re: [PATCH non-pretimeout 5/7] ACPI: add GTDT table parse driver into ACPI driver

Path csiph.com!aioe.org!bofh.it!news.nic.it!robomod
From Hanjun Guo <hanjun.guo@linaro.org>
Newsgroups linux.kernel
Subject Re: [PATCH non-pretimeout 5/7] ACPI: add GTDT table parse driver into ACPI driver
Date Thu, 11 Jun 2015 13:20:02 +0200
Message-ID <pA8GC-40B-23@gated-at.bofh.it> (permalink)
References <pqlF8-659-23@gated-at.bofh.it> <pzSit-503-9@gated-at.bofh.it> <pzSsa-5bn-11@gated-at.bofh.it>
X-Original-To rjw@rjwysocki.net
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=EQ2l06GVmh5SqD14G7pX3DMN4Z7tg8prq+BY1DqPZ9Q=; b=j4LHKFyVJVFTBPhLR0kadn8S2/IFHzTOo5qq/krIu4X5yQ/9v8v51VAwMpgOXIImb2 EWM/3J7IXTxo6UDMGMebzx+c03/pYtfJKJXPrXVAbFSGKvnrUMhtgaiiRJGo3ps2vxuM obbwavRgqJb6gWoV23XzwXhdmrBamlN28JsToXZw1JwD6k5iNlbE/5s2XaqOX4aNYC6C uLDpyjB+c1qAKcnku3pDCJjeYPJSOmOMLr9NOtS8r/AnQuA0C6T7ywo440lo76Z8i3+Z SuGT0D8eqBVFUNBqggkYQEVQtkFXO0IKp3va/hjiljo4r9/GLCPHWtefgxJl2UqvUIyy 2g/A==
X-Gm-Message-State ALoCoQl2DvCr5xqAVi+bOl/7wcBJ101uAgsSYsPJfAseW+dSmaZ0vpV3m0qDr3sdPl18rb0nWURA
X-Received by 10.70.131.33 with SMTP id oj1mr13965766pdb.3.1434021306744; Thu, 11 Jun 2015 04:15:06 -0700 (PDT)
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0
MIME-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 8bit
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 204
Organization linux.* mail to news gateway
X-Original-Cc fu.wei@linaro.org, Suravee.Suthikulpanit@amd.com, linaro-acpi@lists.linaro.org, linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, tekkamanninja@gmail.com, graeme.gregory@linaro.org, al.stone@linaro.org, timur@codeaurora.org, ashwin.chaugule@linaro.org, arnd@arndb.de, linux@roeck-us.net, vgandhi@codeaurora.org, wim@iguana.be, jcm@redhat.com, leo.duran@amd.com, corbet@lwn.net, mark.rutland@arm.com, catalin.marinas@arm.com, will.deacon@arm.com
X-Original-Date Thu, 11 Jun 2015 19:14:50 +0800
X-Original-Message-ID <55796DAA.5000903@linaro.org>
X-Original-References <=fu.wei@linaro.org> <1433958452-23721-1-git-send-email-fu.wei@linaro.org> <1433958452-23721-6-git-send-email-fu.wei@linaro.org>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref aioe.org linux.kernel:1163158

Show key headers only | View raw


Hi Rafael,

Any comments on patch 5,6,7/7 of this patch set?

Thanks
Hanjun


On 06/11/2015 01:47 AM, fu.wei@linaro.org wrote:
> From: Fu Wei <fu.wei@linaro.org>
>
> This driver adds support for parsing SBSA Generic Watchdog
> Structure in GTDT, and creating a platform device with that
> information. This allows the operating system to obtain device
> data from the resource of platform device.
>
> The platform device named "sbsa-gwdt" can be used by the
> ARM SBSA Generic Watchdog driver.
>
> Signed-off-by: Fu Wei <fu.wei@linaro.org>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> ---
>   drivers/acpi/Kconfig  |   9 ++++
>   drivers/acpi/Makefile |   1 +
>   drivers/acpi/gtdt.c   | 137 ++++++++++++++++++++++++++++++++++++++++++++++++++
>   3 files changed, 147 insertions(+)
>   create mode 100644 drivers/acpi/gtdt.c
>
> diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
> index 1bbaa3d..e125698 100644
> --- a/drivers/acpi/Kconfig
> +++ b/drivers/acpi/Kconfig
> @@ -433,4 +433,13 @@ config XPOWER_PMIC_OPREGION
>
>   endif
>
> +config ACPI_GTDT
> +	bool "ACPI GTDT Support"
> +	depends on ARM64
> +	help
> +	  GTDT (Generic Timer Description Table) provides information
> +	  for per-processor timers and Platform (memory-mapped) timers
> +	  for ARM platforms. Select this option to provide information
> +	  needed for the timers init.
> +
>   endif	# ACPI
> diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
> index 431e587..2c5a194 100644
> --- a/drivers/acpi/Makefile
> +++ b/drivers/acpi/Makefile
> @@ -96,3 +96,4 @@ obj-$(CONFIG_ACPI_EXTLOG)	+= acpi_extlog.o
>   obj-$(CONFIG_PMIC_OPREGION)	+= pmic/intel_pmic.o
>   obj-$(CONFIG_CRC_PMIC_OPREGION) += pmic/intel_pmic_crc.o
>   obj-$(CONFIG_XPOWER_PMIC_OPREGION) += pmic/intel_pmic_xpower.o
> +obj-$(CONFIG_ACPI_GTDT)		+= gtdt.o
> diff --git a/drivers/acpi/gtdt.c b/drivers/acpi/gtdt.c
> new file mode 100644
> index 0000000..a92abf2
> --- /dev/null
> +++ b/drivers/acpi/gtdt.c
> @@ -0,0 +1,137 @@
> +/*
> + * ARM Specific GTDT table Support
> + *
> + * Copyright (C) 2015, Linaro Ltd.
> + * Author: Fu Wei <fu.wei@linaro.org>
> + *         Hanjun Guo <hanjun.guo@linaro.org>
> + *
> + * 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.
> + */
> +
> +#include <linux/acpi.h>
> +#include <linux/device.h>
> +#include <linux/init.h>
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +
> +static int __init map_generic_timer_interrupt(u32 interrupt, u32 flags)
> +{
> +	int trigger, polarity;
> +
> +	if (!interrupt)
> +		return 0;
> +
> +	trigger = (flags & ACPI_GTDT_INTERRUPT_MODE) ? ACPI_EDGE_SENSITIVE
> +			: ACPI_LEVEL_SENSITIVE;
> +
> +	polarity = (flags & ACPI_GTDT_INTERRUPT_POLARITY) ? ACPI_ACTIVE_LOW
> +			: ACPI_ACTIVE_HIGH;
> +
> +	return acpi_register_gsi(NULL, interrupt, trigger, polarity);
> +}
> +
> +/*
> + * Initialize a SBSA generic Watchdog platform device info from GTDT
> + * According to SBSA specification the size of refresh and control
> + * frames of SBSA Generic Watchdog is SZ_4K(Offset 0x000 – 0xFFF).
> + */
> +static int __init gtdt_import_sbsa_gwdt(struct acpi_gtdt_watchdog *wd,
> +					int index)
> +{
> +	struct platform_device *pdev;
> +	int irq = map_generic_timer_interrupt(wd->timer_interrupt,
> +					      wd->timer_flags);
> +	struct resource res[] = {
> +		DEFINE_RES_IRQ_NAMED(irq, "ws0"),
> +		DEFINE_RES_MEM_NAMED(wd->refresh_frame_address, SZ_4K,
> +				     "refresh"),
> +		DEFINE_RES_MEM_NAMED(wd->control_frame_address, SZ_4K,
> +				     "control"),
> +	};
> +
> +	pr_debug("GTDT: a Watchdog GT(0x%llx/0x%llx gsi:%u flags:0x%x)\n",
> +		 wd->refresh_frame_address, wd->control_frame_address,
> +		 wd->timer_interrupt, wd->timer_flags);
> +
> +	if (!(wd->refresh_frame_address &&
> +	      wd->control_frame_address &&
> +	      wd->timer_interrupt)) {
> +		pr_err("GTDT: failed geting the device info.\n");
> +		return -EINVAL;
> +	}
> +
> +	if (irq < 0) {
> +		pr_err("GTDT: failed to register GSI of the Watchdog GT.\n");
> +		return -EINVAL;
> +	}
> +
> +	/*
> +	 * Add a platform device named "sbsa-gwdt" to match the platform driver.
> +	 * "sbsa-gwdt": SBSA(Server Base System Architecture) Generic Watchdog
> +	 * The platform driver (like drivers/watchdog/sbsa_gwdt.c)can get device
> +	 * info below by matching this name.
> +	 */
> +	pdev = platform_device_register_simple("sbsa-gwdt", index, res,
> +					       ARRAY_SIZE(res));
> +	if (IS_ERR(pdev)) {
> +		acpi_unregister_gsi(wd->timer_interrupt);
> +		return PTR_ERR(pdev);
> +	}
> +
> +	return 0;
> +}
> +
> +static int __init gtdt_platform_timer_parse(struct acpi_table_header *table)
> +{
> +	struct acpi_gtdt_header *header;
> +	struct acpi_table_gtdt *gtdt;
> +	void *gtdt_subtable;
> +	int i, gwdt_index;
> +	int ret = 0;
> +
> +	if (table->revision < 2) {
> +		pr_warn("GTDT: Revision:%d doesn't support Platform Timers.\n",
> +			table->revision);
> +		return 0;
> +	}
> +
> +	gtdt = container_of(table, struct acpi_table_gtdt, header);
> +	if (!gtdt->platform_timer_count) {
> +		pr_info("GTDT: No Platform Timer structures.\n");
> +		return 0;
> +	}
> +
> +	gtdt_subtable = (void *)gtdt + gtdt->platform_timer_offset;
> +
> +	for (i = 0, gwdt_index = 0; i < gtdt->platform_timer_count; i++) {
> +		if (gtdt_subtable > (void *)table + table->length) {
> +			pr_err("GTDT: subtable pointer overflows, bad table\n");
> +			return -EINVAL;
> +		}
> +		header = (struct acpi_gtdt_header *)gtdt_subtable;
> +		if (header->type == ACPI_GTDT_TYPE_WATCHDOG) {
> +			ret = gtdt_import_sbsa_gwdt(gtdt_subtable, gwdt_index);
> +			if (ret)
> +				pr_err("GTDT: failed to import subtable %d\n",
> +				       i);
> +			else
> +				gwdt_index++;
> +		}
> +		gtdt_subtable += header->length;
> +	}
> +
> +	return ret;
> +}
> +
> +static int __init gtdt_platform_timer_init(void)
> +{
> +	if (acpi_disabled)
> +		return 0;
> +
> +	return acpi_table_parse(ACPI_SIG_GTDT, gtdt_platform_timer_parse);
> +}
> +
> +device_initcall(gtdt_platform_timer_init);
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

Re: [PATCH non-pretimeout 5/7] ACPI: add GTDT table parse driver  into ACPI driver Hanjun Guo <hanjun.guo@linaro.org> - 2015-06-11 13:20 +0200

csiph-web