All of lore.kernel.org
 help / color / mirror / Atom feed
From: fu.wei@linaro.org
To: rjw@rjwysocki.net, lenb@kernel.org, daniel.lezcano@linaro.org,
	tglx@linutronix.de, marc.zyngier@arm.com, hanjun.guo@linaro.org
Cc: linux-arm-kernel@lists.infradead.org,
	linaro-acpi@lists.linaro.org, linux-kernel@vger.kernel.org,
	linux-acpi@vger.kernel.org, rruigrok@codeaurora.org,
	harba@codeaurora.org, cov@codeaurora.org, timur@codeaurora.org,
	graeme.gregory@linaro.org, al.stone@linaro.org, jcm@redhat.com,
	wei@redhat.com, arnd@arndb.de, wim@iguana.be,
	catalin.marinas@arm.com, will.deacon@arm.com,
	Suravee.Suthikulpanit@amd.com, leo.duran@amd.com,
	Fu Wei <fu.wei@linaro.org>
Subject: [PATCH v6 04/10] acpi: Add some basic struct and functions in GTDT driver
Date: Thu, 30 Jun 2016 02:15:47 +0800	[thread overview]
Message-ID: <1467224153-22873-5-git-send-email-fu.wei@linaro.org> (raw)
In-Reply-To: <1467224153-22873-1-git-send-email-fu.wei@linaro.org>

From: Fu Wei <fu.wei@linaro.org>

Signed-off-by: Fu Wei <fu.wei@linaro.org>
---
 drivers/acpi/acpi_gtdt.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 85 insertions(+)

diff --git a/drivers/acpi/acpi_gtdt.c b/drivers/acpi/acpi_gtdt.c
new file mode 100644
index 0000000..54d7644e
--- /dev/null
+++ b/drivers/acpi/acpi_gtdt.c
@@ -0,0 +1,85 @@
+/*
+ * ARM Specific GTDT table Support
+ *
+ * Copyright (C) 2015, Linaro Ltd.
+ * Author: Daniel Lezcano <daniel.lezcano@linaro.org>
+ *         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/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+
+#undef pr_fmt
+#define pr_fmt(fmt) "GTDT: " fmt
+
+typedef struct {
+	struct acpi_table_gtdt *gtdt;
+	void *platform_timer_start;
+	void *gtdt_end;
+} acpi_gtdt_desc_t;
+
+static acpi_gtdt_desc_t acpi_gtdt_desc __initdata;
+
+static inline void *gtdt_next(void *platform_timer, void *end, int type)
+{
+	struct acpi_gtdt_header *gh = platform_timer;
+
+	while ((void *)(gh += gh->length) < end)
+		if (gh->type == type)
+			return (void *)gh;
+	return NULL;
+}
+
+#define for_each_gtdt_type(_g, _t)				\
+	for (_g = acpi_gtdt_desc.platform_timer_start; _g;	\
+	     _g = gtdt_next(_g, acpi_gtdt_desc.gtdt_end, _t))
+
+#define for_each_gtdt_timer(_g)				\
+	for_each_gtdt_type(_g, ACPI_GTDT_TYPE_TIMER_BLOCK)
+
+#define for_each_gtdt_watchdog(_g)			\
+	for_each_gtdt_type(_g, ACPI_GTDT_TYPE_WATCHDOG)
+
+/*
+ * Get some basic info from GTDT table, and init the global variables above
+ * for all timers initialization of Generic Timer.
+ * This function does some validation on GTDT table.
+ */
+static int __init acpi_gtdt_desc_init(struct acpi_table_header *table)
+{
+	struct acpi_table_gtdt *gtdt = container_of(table,
+						    struct acpi_table_gtdt,
+						    header);
+
+	acpi_gtdt_desc.gtdt = gtdt;
+	acpi_gtdt_desc.gtdt_end = (void *)table + table->length;
+
+	if (table->revision < 2) {
+		pr_info("Revision:%d doesn't support Platform Timers.\n",
+			table->revision);
+		return 0;
+	}
+
+	if (!gtdt->platform_timer_count) {
+		pr_info("No Platform Timer.\n");
+		return 0;
+	}
+
+	acpi_gtdt_desc.platform_timer_start = (void *)gtdt +
+					      gtdt->platform_timer_offset;
+	if (acpi_gtdt_desc.platform_timer_start <
+	    (void *)table + sizeof(struct acpi_table_gtdt)) {
+		pr_err(FW_BUG "Platform Timer pointer error.\n");
+		acpi_gtdt_desc.platform_timer_start = NULL;
+		return -EINVAL;
+	}
+
+	return gtdt->platform_timer_count;
+}
-- 
2.5.5

WARNING: multiple messages have this Message-ID (diff)
From: fu.wei@linaro.org (fu.wei at linaro.org)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v6 04/10] acpi: Add some basic struct and functions in GTDT driver
Date: Thu, 30 Jun 2016 02:15:47 +0800	[thread overview]
Message-ID: <1467224153-22873-5-git-send-email-fu.wei@linaro.org> (raw)
In-Reply-To: <1467224153-22873-1-git-send-email-fu.wei@linaro.org>

From: Fu Wei <fu.wei@linaro.org>

Signed-off-by: Fu Wei <fu.wei@linaro.org>
---
 drivers/acpi/acpi_gtdt.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 85 insertions(+)

diff --git a/drivers/acpi/acpi_gtdt.c b/drivers/acpi/acpi_gtdt.c
new file mode 100644
index 0000000..54d7644e
--- /dev/null
+++ b/drivers/acpi/acpi_gtdt.c
@@ -0,0 +1,85 @@
+/*
+ * ARM Specific GTDT table Support
+ *
+ * Copyright (C) 2015, Linaro Ltd.
+ * Author: Daniel Lezcano <daniel.lezcano@linaro.org>
+ *         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/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+
+#undef pr_fmt
+#define pr_fmt(fmt) "GTDT: " fmt
+
+typedef struct {
+	struct acpi_table_gtdt *gtdt;
+	void *platform_timer_start;
+	void *gtdt_end;
+} acpi_gtdt_desc_t;
+
+static acpi_gtdt_desc_t acpi_gtdt_desc __initdata;
+
+static inline void *gtdt_next(void *platform_timer, void *end, int type)
+{
+	struct acpi_gtdt_header *gh = platform_timer;
+
+	while ((void *)(gh += gh->length) < end)
+		if (gh->type == type)
+			return (void *)gh;
+	return NULL;
+}
+
+#define for_each_gtdt_type(_g, _t)				\
+	for (_g = acpi_gtdt_desc.platform_timer_start; _g;	\
+	     _g = gtdt_next(_g, acpi_gtdt_desc.gtdt_end, _t))
+
+#define for_each_gtdt_timer(_g)				\
+	for_each_gtdt_type(_g, ACPI_GTDT_TYPE_TIMER_BLOCK)
+
+#define for_each_gtdt_watchdog(_g)			\
+	for_each_gtdt_type(_g, ACPI_GTDT_TYPE_WATCHDOG)
+
+/*
+ * Get some basic info from GTDT table, and init the global variables above
+ * for all timers initialization of Generic Timer.
+ * This function does some validation on GTDT table.
+ */
+static int __init acpi_gtdt_desc_init(struct acpi_table_header *table)
+{
+	struct acpi_table_gtdt *gtdt = container_of(table,
+						    struct acpi_table_gtdt,
+						    header);
+
+	acpi_gtdt_desc.gtdt = gtdt;
+	acpi_gtdt_desc.gtdt_end = (void *)table + table->length;
+
+	if (table->revision < 2) {
+		pr_info("Revision:%d doesn't support Platform Timers.\n",
+			table->revision);
+		return 0;
+	}
+
+	if (!gtdt->platform_timer_count) {
+		pr_info("No Platform Timer.\n");
+		return 0;
+	}
+
+	acpi_gtdt_desc.platform_timer_start = (void *)gtdt +
+					      gtdt->platform_timer_offset;
+	if (acpi_gtdt_desc.platform_timer_start <
+	    (void *)table + sizeof(struct acpi_table_gtdt)) {
+		pr_err(FW_BUG "Platform Timer pointer error.\n");
+		acpi_gtdt_desc.platform_timer_start = NULL;
+		return -EINVAL;
+	}
+
+	return gtdt->platform_timer_count;
+}
-- 
2.5.5

  parent reply	other threads:[~2016-06-29 18:15 UTC|newest]

Thread overview: 124+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-29 18:15 [PATCH v6 00/10] acpi, clocksource: add GTDT driver and GTDT support in arm_arch_timer fu.wei
2016-06-29 18:15 ` fu.wei at linaro.org
2016-06-29 18:15 ` fu.wei
2016-06-29 18:15 ` [PATCH v6 01/10] clocksource/drivers/arm_arch_timer: Move enums and defines to header file fu.wei
2016-06-29 18:15   ` fu.wei at linaro.org
2016-06-29 18:15   ` fu.wei
2016-06-29 18:15 ` [PATCH v6 02/10] clocksource/drivers/arm_arch_timer: Add a new enum for spi type fu.wei
2016-06-29 18:15   ` fu.wei at linaro.org
2016-06-29 18:15   ` fu.wei
2016-06-29 18:15 ` [PATCH v6 03/10] clocksource/drivers/arm_arch_timer: Improve printk relevant code fu.wei
2016-06-29 18:15   ` fu.wei at linaro.org
2016-06-30  2:54   ` Hanjun Guo
2016-06-30  2:54     ` Hanjun Guo
2016-07-07 16:12     ` Fu Wei
2016-07-07 16:12       ` Fu Wei
2016-06-29 18:15 ` fu.wei [this message]
2016-06-29 18:15   ` [PATCH v6 04/10] acpi: Add some basic struct and functions in GTDT driver fu.wei at linaro.org
2016-06-29 21:24   ` Rafael J. Wysocki
2016-06-29 21:24     ` Rafael J. Wysocki
2016-06-29 21:24     ` Rafael J. Wysocki
2016-06-30  1:17     ` Fu Wei
2016-06-30  1:17       ` Fu Wei
2016-06-30  1:17       ` Fu Wei
2016-06-30  1:26       ` Rafael J. Wysocki
2016-06-30  1:26         ` Rafael J. Wysocki
2016-06-30  1:26         ` Rafael J. Wysocki
2016-06-30  1:32         ` Fu Wei
2016-06-30  1:32           ` Fu Wei
2016-06-30  1:32           ` Fu Wei
2016-06-30  4:13         ` Timur Tabi
2016-06-30  4:13           ` Timur Tabi
2016-06-30  4:13           ` Timur Tabi
2016-06-29 18:15 ` [PATCH v6 05/10] acpi: Add arch_timer support in GTDT table parse driver fu.wei
2016-06-29 18:15   ` fu.wei at linaro.org
2016-06-29 18:15   ` fu.wei
2016-06-29 18:15 ` [PATCH v6 06/10] acpi: Add GTDT driver to kernel build system fu.wei
2016-06-29 18:15   ` fu.wei at linaro.org
2016-06-29 18:15   ` fu.wei
2016-06-29 18:15 ` [PATCH v6 07/10] clocksource/drivers/arm_arch_timer: Simplify ACPI support code fu.wei
2016-06-29 18:15   ` fu.wei at linaro.org
2016-06-29 18:15 ` [PATCH v6 08/10] acpi: Add memory-mapped timer support in GTDT driver fu.wei
2016-06-29 18:15   ` fu.wei at linaro.org
2016-06-29 18:15   ` fu.wei
2016-06-29 18:15 ` [PATCH v6 09/10] clocksource/drivers/arm_arch_timer: Add GTDT support for memory-mapped timer fu.wei
2016-06-29 18:15   ` fu.wei at linaro.org
2016-06-29 18:15   ` fu.wei
2016-06-29 18:15 ` [PATCH v6 10/10] acpi: Add SBSA Generic Watchdog support in GTDT driver fu.wei
2016-06-29 18:15   ` fu.wei at linaro.org
2016-06-29 18:15   ` fu.wei
2016-06-29 21:32 ` [PATCH v6 00/10] acpi, clocksource: add GTDT driver and GTDT support in arm_arch_timer Rafael J. Wysocki
2016-06-29 21:32   ` Rafael J. Wysocki
2016-06-29 21:32   ` Rafael J. Wysocki
2016-06-30  1:29   ` Fu Wei
2016-06-30  1:29     ` Fu Wei
2016-06-30  1:29     ` Fu Wei
2016-06-30  1:37     ` Rafael J. Wysocki
2016-06-30  1:37       ` Rafael J. Wysocki
2016-06-30  1:37       ` Rafael J. Wysocki
2016-06-30  2:10       ` Hanjun Guo
2016-06-30  2:10         ` Hanjun Guo
2016-06-30  2:10         ` Hanjun Guo
2016-06-30 13:27         ` Rafael J. Wysocki
2016-06-30 13:27           ` Rafael J. Wysocki
2016-06-30 13:27           ` Rafael J. Wysocki
2016-06-30 13:48           ` Hanjun Guo
2016-06-30 13:48             ` Hanjun Guo
2016-06-30 13:48             ` Hanjun Guo
2016-07-01 15:23             ` Will Deacon
2016-07-01 15:23               ` Will Deacon
2016-07-01 15:23               ` Will Deacon
2016-07-01 21:04               ` Rafael J. Wysocki
2016-07-01 21:04                 ` Rafael J. Wysocki
2016-07-01 21:04                 ` Rafael J. Wysocki
2016-07-04 12:53                 ` Rafael J. Wysocki
2016-07-04 12:53                   ` Rafael J. Wysocki
2016-07-04 12:53                   ` Rafael J. Wysocki
2016-07-05 14:18                   ` Graeme Gregory
2016-07-05 14:18                     ` Graeme Gregory
2016-07-05 14:18                     ` Graeme Gregory
2016-07-06  0:00                     ` Rafael J. Wysocki
2016-07-06  0:00                       ` Rafael J. Wysocki
2016-07-06  0:00                       ` Rafael J. Wysocki
2016-07-07 11:12                       ` Hanjun Guo
2016-07-07 11:12                         ` Hanjun Guo
2016-07-07 11:12                         ` Hanjun Guo
2016-07-07 12:03                         ` Rafael J. Wysocki
2016-07-07 12:03                           ` Rafael J. Wysocki
2016-07-07 12:03                           ` Rafael J. Wysocki
2016-07-07 13:40                           ` Lorenzo Pieralisi
2016-07-07 13:40                             ` Lorenzo Pieralisi
2016-07-07 13:40                             ` Lorenzo Pieralisi
2016-07-07 13:58                             ` Rafael J. Wysocki
2016-07-07 13:58                               ` Rafael J. Wysocki
2016-07-07 13:58                               ` Rafael J. Wysocki
2016-07-07 15:21                               ` Fu Wei
2016-07-07 15:21                                 ` Fu Wei
2016-07-07 15:21                                 ` Fu Wei
2016-07-08 13:22                               ` Lorenzo Pieralisi
2016-07-08 13:22                                 ` Lorenzo Pieralisi
2016-07-08 13:22                                 ` Lorenzo Pieralisi
2016-07-08 13:50                                 ` Sudeep Holla
2016-07-08 13:50                                   ` Sudeep Holla
2016-07-08 13:50                                   ` Sudeep Holla
2016-07-09  3:44                                 ` Hanjun Guo
2016-07-09  3:44                                   ` Hanjun Guo
2016-07-09  3:44                                   ` Hanjun Guo
2016-07-10  1:26                                   ` Rafael J. Wysocki
2016-07-10  1:26                                     ` Rafael J. Wysocki
2016-07-10  1:26                                     ` Rafael J. Wysocki
2016-07-09  3:00                               ` Hanjun Guo
2016-07-09  3:00                                 ` Hanjun Guo
2016-07-09  3:00                                 ` Hanjun Guo
2016-07-01 14:00           ` Daniel Lezcano
2016-07-01 14:00             ` Daniel Lezcano
2016-07-01 14:00             ` Daniel Lezcano
2016-07-01 21:01             ` Rafael J. Wysocki
2016-07-01 21:01               ` Rafael J. Wysocki
2016-07-01 21:01               ` Rafael J. Wysocki
2016-07-04 13:43               ` Daniel Lezcano
2016-07-04 13:43                 ` Daniel Lezcano
2016-07-04 13:43                 ` Daniel Lezcano
2016-07-04 14:19                 ` Rafael J. Wysocki
2016-07-04 14:19                   ` Rafael J. Wysocki
2016-07-04 14:19                   ` Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1467224153-22873-5-git-send-email-fu.wei@linaro.org \
    --to=fu.wei@linaro.org \
    --cc=Suravee.Suthikulpanit@amd.com \
    --cc=al.stone@linaro.org \
    --cc=arnd@arndb.de \
    --cc=catalin.marinas@arm.com \
    --cc=cov@codeaurora.org \
    --cc=daniel.lezcano@linaro.org \
    --cc=graeme.gregory@linaro.org \
    --cc=hanjun.guo@linaro.org \
    --cc=harba@codeaurora.org \
    --cc=jcm@redhat.com \
    --cc=lenb@kernel.org \
    --cc=leo.duran@amd.com \
    --cc=linaro-acpi@lists.linaro.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marc.zyngier@arm.com \
    --cc=rjw@rjwysocki.net \
    --cc=rruigrok@codeaurora.org \
    --cc=tglx@linutronix.de \
    --cc=timur@codeaurora.org \
    --cc=wei@redhat.com \
    --cc=will.deacon@arm.com \
    --cc=wim@iguana.be \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.