1 /* 2 * Copyright 2007-2012, 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 static struct fdt_device_info intc_table[] = { 38 { 39 .compatible = "marvell,pxa-timers", // XXX not in FDT (also not in upstream!) 40 .init = PXATimer::Init, 41 }, { 42 .compatible = "ti,omap3430-timer", 43 .init = OMAP3Timer::Init, 44 } 45 }; 46 static int intc_count = sizeof(intc_table) / sizeof(struct fdt_device_info); 47 48 49 void 50 arch_timer_set_hardware_timer(bigtime_t timeout) 51 { 52 HardwareTimer *timer = HardwareTimer::Get(); 53 if (timer != NULL) 54 timer->SetTimeout(timeout); 55 } 56 57 58 void 59 arch_timer_clear_hardware_timer() 60 { 61 HardwareTimer *timer = HardwareTimer::Get(); 62 if (timer != NULL) 63 timer->Clear(); 64 } 65 66 int 67 arch_init_timer(kernel_args *args) 68 { 69 TRACE(("%s\n", __func__)); 70 71 status_t rc = get_module(B_FDT_MODULE_NAME, (module_info**)&sFdtModule); 72 if (rc != B_OK) 73 panic("Unable to get FDT module: %08lx!\n", rc); 74 75 rc = sFdtModule->setup_devices(intc_table, intc_count, NULL); 76 if (rc != B_OK) 77 panic("No interrupt controllers found!\n"); 78 79 return B_OK; 80 } 81 82 bigtime_t 83 system_time(void) 84 { 85 HardwareTimer *timer = HardwareTimer::Get(); 86 if (timer != NULL) 87 return timer->Time(); 88 89 return 0; 90 } 91