Lines Matching +full:timer +full:- +full:secure
1 // SPDX-License-Identifier: GPL-2.0-only
23 * struct acpi_gtdt_descriptor - Store the key info of GTDT for all functions
26 * @platform_timer: The pointer to the start of Platform Timer Structure
43 platform_timer += gh->length; in next_platform_timer()
58 return gh->type == ACPI_GTDT_TYPE_TIMER_BLOCK; in is_timer_block()
66 if (gh->type != ACPI_GTDT_TYPE_WATCHDOG) in is_non_secure_watchdog()
69 return !(wd->timer_flags & ACPI_GTDT_WATCHDOG_SECURE); in is_non_secure_watchdog()
86 * acpi_gtdt_map_ppi() - Map the PPIs of per-cpu arch_timer.
89 * Note: Secure state is not managed by the kernel on ARM64 systems.
90 * So we only handle the non-secure timer PPIs,
101 return map_gt_gsi(gtdt->non_secure_el1_interrupt, in acpi_gtdt_map_ppi()
102 gtdt->non_secure_el1_flags); in acpi_gtdt_map_ppi()
104 return map_gt_gsi(gtdt->virtual_timer_interrupt, in acpi_gtdt_map_ppi()
105 gtdt->virtual_timer_flags); in acpi_gtdt_map_ppi()
108 return map_gt_gsi(gtdt->non_secure_el2_interrupt, in acpi_gtdt_map_ppi()
109 gtdt->non_secure_el2_flags); in acpi_gtdt_map_ppi()
111 pr_err("Failed to map timer interrupt: invalid type.\n"); in acpi_gtdt_map_ppi()
118 * acpi_gtdt_c3stop() - Got c3stop info from GTDT according to the type of PPI.
121 * Return: true if the timer HW state is lost when a CPU enters an idle state,
130 return !(gtdt->non_secure_el1_flags & ACPI_GTDT_ALWAYS_ON); in acpi_gtdt_c3stop()
133 return !(gtdt->virtual_timer_flags & ACPI_GTDT_ALWAYS_ON); in acpi_gtdt_c3stop()
136 return !(gtdt->non_secure_el2_flags & ACPI_GTDT_ALWAYS_ON); in acpi_gtdt_c3stop()
146 * acpi_gtdt_init() - Get the info of GTDT table to prepare for further init.
153 * Return: 0 if success, -EINVAL if error.
163 acpi_gtdt_desc.gtdt_end = (void *)table + table->length; in acpi_gtdt_init()
168 if (table->revision < 2) { in acpi_gtdt_init()
170 table->revision); in acpi_gtdt_init()
174 if (!gtdt->platform_timer_count) { in acpi_gtdt_init()
175 pr_debug("No Platform Timer.\n"); in acpi_gtdt_init()
179 platform_timer = (void *)gtdt + gtdt->platform_timer_offset; in acpi_gtdt_init()
181 pr_err(FW_BUG "invalid timer data.\n"); in acpi_gtdt_init()
182 return -EINVAL; in acpi_gtdt_init()
186 *platform_timer_count = gtdt->platform_timer_count; in acpi_gtdt_init()
198 if (!block->timer_count) { in gtdt_parse_timer_block()
200 return -ENODEV; in gtdt_parse_timer_block()
203 if (block->timer_count > ARCH_TIMER_MEM_MAX_FRAMES) { in gtdt_parse_timer_block()
205 block->timer_count); in gtdt_parse_timer_block()
206 return -EINVAL; in gtdt_parse_timer_block()
209 timer_mem->cntctlbase = (phys_addr_t)block->block_address; in gtdt_parse_timer_block()
211 * The CNTCTLBase frame is 4KB (register offsets 0x000 - 0xFFC). in gtdt_parse_timer_block()
212 * See ARM DDI 0487A.k_iss10775, page I1-5129, Table I1-3 in gtdt_parse_timer_block()
215 timer_mem->size = SZ_4K; in gtdt_parse_timer_block()
217 gtdt_frame = (void *)block + block->timer_offset; in gtdt_parse_timer_block()
218 if (gtdt_frame + block->timer_count != (void *)block + block->header.length) in gtdt_parse_timer_block()
219 return -EINVAL; in gtdt_parse_timer_block()
222 * Get the GT timer Frame data for every GT Block Timer in gtdt_parse_timer_block()
224 for (i = 0; i < block->timer_count; i++, gtdt_frame++) { in gtdt_parse_timer_block()
225 if (gtdt_frame->common_flags & ACPI_GTDT_GT_IS_SECURE_TIMER) in gtdt_parse_timer_block()
227 if (gtdt_frame->frame_number >= ARCH_TIMER_MEM_MAX_FRAMES || in gtdt_parse_timer_block()
228 !gtdt_frame->base_address || !gtdt_frame->timer_interrupt) in gtdt_parse_timer_block()
231 frame = &timer_mem->frame[gtdt_frame->frame_number]; in gtdt_parse_timer_block()
234 if (frame->valid) in gtdt_parse_timer_block()
237 frame->phys_irq = map_gt_gsi(gtdt_frame->timer_interrupt, in gtdt_parse_timer_block()
238 gtdt_frame->timer_flags); in gtdt_parse_timer_block()
239 if (frame->phys_irq <= 0) { in gtdt_parse_timer_block()
240 pr_warn("failed to map physical timer irq in frame %d.\n", in gtdt_parse_timer_block()
241 gtdt_frame->frame_number); in gtdt_parse_timer_block()
245 if (gtdt_frame->virtual_timer_interrupt) { in gtdt_parse_timer_block()
246 frame->virt_irq = in gtdt_parse_timer_block()
247 map_gt_gsi(gtdt_frame->virtual_timer_interrupt, in gtdt_parse_timer_block()
248 gtdt_frame->virtual_timer_flags); in gtdt_parse_timer_block()
249 if (frame->virt_irq <= 0) { in gtdt_parse_timer_block()
250 pr_warn("failed to map virtual timer irq in frame %d.\n", in gtdt_parse_timer_block()
251 gtdt_frame->frame_number); in gtdt_parse_timer_block()
255 pr_debug("virtual timer in frame %d not implemented.\n", in gtdt_parse_timer_block()
256 gtdt_frame->frame_number); in gtdt_parse_timer_block()
259 frame->cntbase = gtdt_frame->base_address; in gtdt_parse_timer_block()
261 * The CNTBaseN frame is 4KB (register offsets 0x000 - 0xFFC). in gtdt_parse_timer_block()
262 * See ARM DDI 0487A.k_iss10775, page I1-5130, Table I1-4 in gtdt_parse_timer_block()
265 frame->size = SZ_4K; in gtdt_parse_timer_block()
266 frame->valid = true; in gtdt_parse_timer_block()
273 if (gtdt_frame->common_flags & ACPI_GTDT_GT_IS_SECURE_TIMER || in gtdt_parse_timer_block()
274 gtdt_frame->frame_number >= ARCH_TIMER_MEM_MAX_FRAMES) in gtdt_parse_timer_block()
277 frame = &timer_mem->frame[gtdt_frame->frame_number]; in gtdt_parse_timer_block()
279 if (frame->phys_irq > 0) in gtdt_parse_timer_block()
280 acpi_unregister_gsi(gtdt_frame->timer_interrupt); in gtdt_parse_timer_block()
281 frame->phys_irq = 0; in gtdt_parse_timer_block()
283 if (frame->virt_irq > 0) in gtdt_parse_timer_block()
284 acpi_unregister_gsi(gtdt_frame->virtual_timer_interrupt); in gtdt_parse_timer_block()
285 frame->virt_irq = 0; in gtdt_parse_timer_block()
286 } while (i-- >= 0 && gtdt_frame--); in gtdt_parse_timer_block()
288 return -EINVAL; in gtdt_parse_timer_block()
292 * acpi_arch_timer_mem_init() - Get the info of all GT blocks in GTDT table.
299 * Return: 0 if success, -EINVAL/-ENODEV if error.
319 pr_info("found %d memory-mapped timer block(s).\n", in acpi_arch_timer_mem_init()
339 DEFINE_RES_MEM(wd->control_frame_address, SZ_4K), in gtdt_import_sbsa_gwdt()
340 DEFINE_RES_MEM(wd->refresh_frame_address, SZ_4K), in gtdt_import_sbsa_gwdt()
346 wd->refresh_frame_address, wd->control_frame_address, in gtdt_import_sbsa_gwdt()
347 wd->timer_interrupt, wd->timer_flags); in gtdt_import_sbsa_gwdt()
349 if (!(wd->refresh_frame_address && wd->control_frame_address)) { in gtdt_import_sbsa_gwdt()
351 return -EINVAL; in gtdt_import_sbsa_gwdt()
354 irq = map_gt_gsi(wd->timer_interrupt, wd->timer_flags); in gtdt_import_sbsa_gwdt()
358 nr_res--; in gtdt_import_sbsa_gwdt()
362 * Add a platform device named "sbsa-gwdt" to match the platform driver. in gtdt_import_sbsa_gwdt()
363 * "sbsa-gwdt": SBSA(Server Base System Architecture) Generic Watchdog in gtdt_import_sbsa_gwdt()
366 pdev = platform_device_register_simple("sbsa-gwdt", index, res, nr_res); in gtdt_import_sbsa_gwdt()
369 acpi_unregister_gsi(wd->timer_interrupt); in gtdt_import_sbsa_gwdt()
386 return -EINVAL; in gtdt_sbsa_gwdt_init()
394 * to re-initialize them with permanent mapped pointer values to let the in gtdt_sbsa_gwdt_init()