1 /* 2 * Copyright 2007-2021, Haiku Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * François Revol <revol@free.fr> 7 * Ithamar R. Adema <ithamar@upgrade-android.com> 8 * 9 * Copyright 2001, Travis Geiselbrecht. All rights reserved. 10 * Distributed under the terms of the NewOS License. 11 */ 12 13 14 #include <boot/stage2.h> 15 #include <kernel.h> 16 #include <debug.h> 17 18 #include <timer.h> 19 #include <arch/timer.h> 20 #include <arch/cpu.h> 21 22 #include <drivers/bus/FDT.h> 23 #include "soc.h" 24 25 #include "soc_pxa.h" 26 #include "soc_omap3.h" 27 28 //#define TRACE_ARCH_TIMER 29 #ifdef TRACE_ARCH_TIMER 30 # define TRACE(x) dprintf x 31 #else 32 # define TRACE(x) ; 33 #endif 34 35 //static fdt_module_info *sFdtModule; 36 37 #if 0 38 static struct fdt_device_info intc_table[] = { 39 { 40 .compatible = "marvell,pxa-timers", // XXX not in FDT (also not in upstream!) 41 .init = PXATimer::Init, 42 }, { 43 .compatible = "ti,omap3430-timer", 44 .init = OMAP3Timer::Init, 45 } 46 }; 47 static int intc_count = sizeof(intc_table) / sizeof(struct fdt_device_info); 48 #endif 49 50 51 void 52 arch_timer_set_hardware_timer(bigtime_t timeout) 53 { 54 HardwareTimer *timer = HardwareTimer::Get(); 55 if (timer != NULL) 56 timer->SetTimeout(timeout); 57 } 58 59 60 void 61 arch_timer_clear_hardware_timer() 62 { 63 HardwareTimer *timer = HardwareTimer::Get(); 64 if (timer != NULL) 65 timer->Clear(); 66 } 67 68 int 69 arch_init_timer(kernel_args *args) 70 { 71 TRACE(("%s\n", __func__)); 72 73 #if 0 74 status_t rc = get_module(B_FDT_MODULE_NAME, (module_info**)&sFdtModule); 75 if (rc != B_OK) 76 panic("Unable to get FDT module: %08lx!\n", rc); 77 78 rc = sFdtModule->setup_devices(intc_table, intc_count, NULL); 79 if (rc != B_OK) 80 panic("No interrupt controllers found!\n"); 81 #endif 82 83 return B_OK; 84 } 85 86 bigtime_t 87 system_time(void) 88 { 89 HardwareTimer *timer = HardwareTimer::Get(); 90 if (timer != NULL) 91 return timer->Time(); 92 93 return 0; 94 } 95