From: fu.wei@linaro.org To: rjw@rjwysocki.net, lenb@kernel.org, daniel.lezcano@linaro.org, tglx@linutronix.de, marc.zyngier@arm.com, lorenzo.pieralisi@arm.com, sudeep.holla@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, linux@roeck-us.net, linux-watchdog@vger.kernel.org, Fu Wei <fu.wei@linaro.org> Subject: [PATCH v10 6/8] acpi/arm64: Add memory-mapped timer support in GTDT driver Date: Tue, 26 Jul 2016 20:19:23 +0800 [thread overview] Message-ID: <1469535565-20924-7-git-send-email-fu.wei@linaro.org> (raw) In-Reply-To: <1469535565-20924-1-git-send-email-fu.wei@linaro.org> From: Fu Wei <fu.wei@linaro.org> On platforms booting with ACPI, architected memory-mapped timers' configuration data is provided by firmware through the ACPI GTDT static table. The clocksource architected timer kernel driver requires a firmware interface to collect timer configuration and configure its driver. this infrastructure is present for device tree systems, but it is missing on systems booting with ACPI. Implement the kernel infrastructure required to parse the static ACPI GTDT table so that the architected timer clocksource driver can make use of it on systems booting with ACPI, therefore enabling the corresponding timers configuration. Signed-off-by: Fu Wei <fu.wei@linaro.org> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org> --- drivers/acpi/arm64/acpi_gtdt.c | 70 ++++++++++++++++++++++++++++++++++++ include/clocksource/arm_arch_timer.h | 15 ++++++++ include/linux/acpi.h | 1 + 3 files changed, 86 insertions(+) diff --git a/drivers/acpi/arm64/acpi_gtdt.c b/drivers/acpi/arm64/acpi_gtdt.c index cdb2fb1..0159175 100644 --- a/drivers/acpi/arm64/acpi_gtdt.c +++ b/drivers/acpi/arm64/acpi_gtdt.c @@ -150,3 +150,73 @@ int __init acpi_gtdt_init(struct acpi_table_header *table) return gtdt->platform_timer_count; } + +static int __init gtdt_parse_gt_block(struct acpi_gtdt_timer_block *block, + struct gt_block_data *data) +{ + struct acpi_gtdt_timer_entry *frame; + int i; + + if (!block || !data) + return -EINVAL; + + if (!block->block_address || !block->timer_count) + return -EINVAL; + + data->cntctlbase_phy = (phys_addr_t)block->block_address; + data->timer_count = block->timer_count; + + frame = (void *)block + block->timer_offset; + if (frame + block->timer_count != (void *)block + block->header.length) + return -EINVAL; + + /* + * Get the GT timer Frame data for every GT Block Timer + */ + for (i = 0; i < block->timer_count; i++, frame++) { + if (!frame->base_address || !frame->timer_interrupt) + return -EINVAL; + + data->timer[i].irq = map_gt_gsi(frame->timer_interrupt, + frame->timer_flags); + if (data->timer[i].irq <= 0) + return -EINVAL; + + if (frame->virtual_timer_interrupt) { + data->timer[i].virtual_irq = + map_gt_gsi(frame->virtual_timer_interrupt, + frame->virtual_timer_flags); + if (data->timer[i].virtual_irq <= 0) + return -EINVAL; + } + + data->timer[i].frame_nr = frame->frame_number; + data->timer[i].cntbase_phy = frame->base_address; + } + + return 0; +} + +/* + * Get the GT block info for memory-mapped timer from GTDT table. + */ +int __init gtdt_arch_timer_mem_init(struct gt_block_data *data) +{ + void *platform_timer; + int index = 0; + int ret; + + for_each_platform_timer(platform_timer) { + if (!is_timer_block(platform_timer)) + continue; + ret = gtdt_parse_gt_block(platform_timer, data + index); + if (ret) + return ret; + index++; + } + + if (index) + pr_info("found %d memory-mapped timer block(s).\n", index); + + return index; +} diff --git a/include/clocksource/arm_arch_timer.h b/include/clocksource/arm_arch_timer.h index 16dcd10..94a5d14 100644 --- a/include/clocksource/arm_arch_timer.h +++ b/include/clocksource/arm_arch_timer.h @@ -56,6 +56,8 @@ enum spi_nr { #define ARCH_TIMER_MEM_PHYS_ACCESS 2 #define ARCH_TIMER_MEM_VIRT_ACCESS 3 +#define ARCH_TIMER_MEM_MAX_FRAME 8 + #define ARCH_TIMER_USR_PCT_ACCESS_EN (1 << 0) /* physical counter */ #define ARCH_TIMER_USR_VCT_ACCESS_EN (1 << 1) /* virtual counter */ #define ARCH_TIMER_VIRT_EVT_EN (1 << 2) @@ -71,6 +73,19 @@ struct arch_timer_kvm_info { int virtual_irq; }; +struct gt_timer_data { + int frame_nr; + phys_addr_t cntbase_phy; + int irq; + int virtual_irq; +}; + +struct gt_block_data { + phys_addr_t cntctlbase_phy; + int timer_count; + struct gt_timer_data timer[ARCH_TIMER_MEM_MAX_FRAME]; +}; + #ifdef CONFIG_ARM_ARCH_TIMER extern u32 arch_timer_get_rate(void); diff --git a/include/linux/acpi.h b/include/linux/acpi.h index fb8b689..24b1750 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -536,6 +536,7 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *); int acpi_gtdt_init(struct acpi_table_header *table); int acpi_gtdt_map_ppi(int type); bool acpi_gtdt_c3stop(void); +int gtdt_arch_timer_mem_init(struct gt_block_data *data); #endif #else /* !CONFIG_ACPI */ -- 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 v10 6/8] acpi/arm64: Add memory-mapped timer support in GTDT driver Date: Tue, 26 Jul 2016 20:19:23 +0800 [thread overview] Message-ID: <1469535565-20924-7-git-send-email-fu.wei@linaro.org> (raw) In-Reply-To: <1469535565-20924-1-git-send-email-fu.wei@linaro.org> From: Fu Wei <fu.wei@linaro.org> On platforms booting with ACPI, architected memory-mapped timers' configuration data is provided by firmware through the ACPI GTDT static table. The clocksource architected timer kernel driver requires a firmware interface to collect timer configuration and configure its driver. this infrastructure is present for device tree systems, but it is missing on systems booting with ACPI. Implement the kernel infrastructure required to parse the static ACPI GTDT table so that the architected timer clocksource driver can make use of it on systems booting with ACPI, therefore enabling the corresponding timers configuration. Signed-off-by: Fu Wei <fu.wei@linaro.org> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org> --- drivers/acpi/arm64/acpi_gtdt.c | 70 ++++++++++++++++++++++++++++++++++++ include/clocksource/arm_arch_timer.h | 15 ++++++++ include/linux/acpi.h | 1 + 3 files changed, 86 insertions(+) diff --git a/drivers/acpi/arm64/acpi_gtdt.c b/drivers/acpi/arm64/acpi_gtdt.c index cdb2fb1..0159175 100644 --- a/drivers/acpi/arm64/acpi_gtdt.c +++ b/drivers/acpi/arm64/acpi_gtdt.c @@ -150,3 +150,73 @@ int __init acpi_gtdt_init(struct acpi_table_header *table) return gtdt->platform_timer_count; } + +static int __init gtdt_parse_gt_block(struct acpi_gtdt_timer_block *block, + struct gt_block_data *data) +{ + struct acpi_gtdt_timer_entry *frame; + int i; + + if (!block || !data) + return -EINVAL; + + if (!block->block_address || !block->timer_count) + return -EINVAL; + + data->cntctlbase_phy = (phys_addr_t)block->block_address; + data->timer_count = block->timer_count; + + frame = (void *)block + block->timer_offset; + if (frame + block->timer_count != (void *)block + block->header.length) + return -EINVAL; + + /* + * Get the GT timer Frame data for every GT Block Timer + */ + for (i = 0; i < block->timer_count; i++, frame++) { + if (!frame->base_address || !frame->timer_interrupt) + return -EINVAL; + + data->timer[i].irq = map_gt_gsi(frame->timer_interrupt, + frame->timer_flags); + if (data->timer[i].irq <= 0) + return -EINVAL; + + if (frame->virtual_timer_interrupt) { + data->timer[i].virtual_irq = + map_gt_gsi(frame->virtual_timer_interrupt, + frame->virtual_timer_flags); + if (data->timer[i].virtual_irq <= 0) + return -EINVAL; + } + + data->timer[i].frame_nr = frame->frame_number; + data->timer[i].cntbase_phy = frame->base_address; + } + + return 0; +} + +/* + * Get the GT block info for memory-mapped timer from GTDT table. + */ +int __init gtdt_arch_timer_mem_init(struct gt_block_data *data) +{ + void *platform_timer; + int index = 0; + int ret; + + for_each_platform_timer(platform_timer) { + if (!is_timer_block(platform_timer)) + continue; + ret = gtdt_parse_gt_block(platform_timer, data + index); + if (ret) + return ret; + index++; + } + + if (index) + pr_info("found %d memory-mapped timer block(s).\n", index); + + return index; +} diff --git a/include/clocksource/arm_arch_timer.h b/include/clocksource/arm_arch_timer.h index 16dcd10..94a5d14 100644 --- a/include/clocksource/arm_arch_timer.h +++ b/include/clocksource/arm_arch_timer.h @@ -56,6 +56,8 @@ enum spi_nr { #define ARCH_TIMER_MEM_PHYS_ACCESS 2 #define ARCH_TIMER_MEM_VIRT_ACCESS 3 +#define ARCH_TIMER_MEM_MAX_FRAME 8 + #define ARCH_TIMER_USR_PCT_ACCESS_EN (1 << 0) /* physical counter */ #define ARCH_TIMER_USR_VCT_ACCESS_EN (1 << 1) /* virtual counter */ #define ARCH_TIMER_VIRT_EVT_EN (1 << 2) @@ -71,6 +73,19 @@ struct arch_timer_kvm_info { int virtual_irq; }; +struct gt_timer_data { + int frame_nr; + phys_addr_t cntbase_phy; + int irq; + int virtual_irq; +}; + +struct gt_block_data { + phys_addr_t cntctlbase_phy; + int timer_count; + struct gt_timer_data timer[ARCH_TIMER_MEM_MAX_FRAME]; +}; + #ifdef CONFIG_ARM_ARCH_TIMER extern u32 arch_timer_get_rate(void); diff --git a/include/linux/acpi.h b/include/linux/acpi.h index fb8b689..24b1750 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -536,6 +536,7 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *); int acpi_gtdt_init(struct acpi_table_header *table); int acpi_gtdt_map_ppi(int type); bool acpi_gtdt_c3stop(void); +int gtdt_arch_timer_mem_init(struct gt_block_data *data); #endif #else /* !CONFIG_ACPI */ -- 2.5.5
next prev parent reply other threads:[~2016-07-26 12:19 UTC|newest] Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top 2016-07-26 12:19 [PATCH v10 0/8] acpi, clocksource: add GTDT driver and GTDT support in arm_arch_timer fu.wei-QSEj5FYQhm4dnm+yROfE0A 2016-07-26 12:19 ` fu.wei at linaro.org 2016-07-26 12:19 ` fu.wei [not found] ` <1469535565-20924-1-git-send-email-fu.wei-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 2016-07-26 12:19 ` [PATCH v10 1/8] clocksource/drivers/arm_arch_timer: Move enums and defines to header file fu.wei-QSEj5FYQhm4dnm+yROfE0A 2016-07-26 12:19 ` fu.wei at linaro.org 2016-07-26 12:19 ` fu.wei 2016-07-26 12:19 ` [PATCH v10 2/8] clocksource/drivers/arm_arch_timer: Add a new enum for spi type fu.wei 2016-07-26 12:19 ` fu.wei at linaro.org 2016-07-26 12:19 ` [PATCH v10 3/8] clocksource/drivers/arm_arch_timer: Improve printk relevant code fu.wei 2016-07-26 12:19 ` fu.wei at linaro.org 2016-07-26 12:19 ` [PATCH v10 4/8] acpi/arm64: Add GTDT table parse driver fu.wei 2016-07-26 12:19 ` fu.wei at linaro.org 2016-07-26 12:19 ` [PATCH v10 5/8] clocksource/drivers/arm_arch_timer: Simplify ACPI support code fu.wei 2016-07-26 12:19 ` fu.wei at linaro.org 2016-07-26 12:19 ` fu.wei [this message] 2016-07-26 12:19 ` [PATCH v10 6/8] acpi/arm64: Add memory-mapped timer support in GTDT driver fu.wei at linaro.org 2016-07-26 12:19 ` [PATCH v10 7/8] clocksource/drivers/arm_arch_timer: Add GTDT support for memory-mapped timer fu.wei 2016-07-26 12:19 ` fu.wei at linaro.org 2016-07-26 12:19 ` fu.wei 2016-07-26 12:19 ` fu.wei 2016-07-26 12:19 ` [PATCH v10 8/8] acpi/arm64: Add SBSA Generic Watchdog support in GTDT driver fu.wei 2016-07-26 12:19 ` fu.wei at linaro.org 2016-07-26 12:19 ` fu.wei 2016-07-26 12:19 ` fu.wei 2016-08-11 9:37 ` [PATCH v10 0/8] acpi, clocksource: add GTDT driver and GTDT support in arm_arch_timer Tomasz Nowicki 2016-08-11 9:37 ` Tomasz Nowicki [not found] ` <0befd611-91a7-88e9-1686-82929c1745e8-nYOzD4b6Jr9Wk0Htik3J/w@public.gmane.org> 2016-08-11 10:15 ` Hanjun Guo 2016-08-11 10:15 ` Hanjun Guo 2016-08-11 10:15 ` Hanjun Guo 2016-08-11 10:22 ` Fu Wei 2016-08-11 10:22 ` Fu Wei 2016-08-11 10:22 ` Fu Wei 2016-08-11 10:58 ` Lorenzo Pieralisi 2016-08-11 10:58 ` Lorenzo Pieralisi 2016-08-11 10:58 ` Lorenzo Pieralisi 2016-08-17 19:01 ` Timur Tabi 2016-08-17 19:01 ` Timur Tabi 2016-08-17 19:01 ` Timur Tabi 2016-08-18 7:48 ` Fu Wei 2016-08-18 7:48 ` Fu Wei 2016-08-18 7:48 ` Fu Wei
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=1469535565-20924-7-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=linux-watchdog@vger.kernel.org \ --cc=linux@roeck-us.net \ --cc=lorenzo.pieralisi@arm.com \ --cc=marc.zyngier@arm.com \ --cc=rjw@rjwysocki.net \ --cc=rruigrok@codeaurora.org \ --cc=sudeep.holla@arm.com \ --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: linkBe 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.