Changeset eb94aaf in rtems
- Timestamp:
- 10/17/22 20:44:00 (8 months ago)
- Branches:
- master
- Children:
- cbac78a
- Parents:
- 63b21ad5
- git-author:
- Alex White <alex.white@…> (10/17/22 20:44:00)
- git-committer:
- Joel Sherrill <joel@…> (02/06/23 20:29:24)
- Location:
- bsps/microblaze/microblaze_fpga
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
bsps/microblaze/microblaze_fpga/clock/clock.c
r63b21ad5 reb94aaf 34 34 */ 35 35 36 #include <bsp.h> 36 37 #include <bsp/fatal.h> 37 38 #include <bsp/timer.h> … … 42 43 43 44 static rtems_timecounter_simple mblaze_tc; 45 static volatile Microblaze_Timer *mblaze_timer; 44 46 45 47 static uint32_t microblaze_tc_get( rtems_timecounter_simple *tc ) 46 48 { 47 volatile Microblaze_Timer *timer = _Microblaze_Timer; 48 return timer->tcr0; 49 return mblaze_timer->tcr0; 49 50 } 50 51 51 52 static bool microblaze_tc_is_pending( rtems_timecounter_simple *tc ) 52 53 { 53 volatile Microblaze_Timer *timer = _Microblaze_Timer; 54 return ( timer->tcsr0 & MICROBLAZE_TIMER_TCSR0_T0INT ) != 0; 54 return ( mblaze_timer->tcsr0 & MICROBLAZE_TIMER_TCSR0_T0INT ) != 0; 55 55 } 56 56 … … 66 66 static void microblaze_clock_initialize( void ) 67 67 { 68 volatile Microblaze_Timer *timer = _Microblaze_Timer; 68 mblaze_timer = (volatile Microblaze_Timer *) try_get_prop_from_device_tree( 69 "xlnx,xps-timer-1.00.a", 70 "reg", 71 BSP_MICROBLAZE_FPGA_TIMER_BASE 72 ); 73 69 74 /* Set load register to 0 */ 70 timer->tlr0 = 0;75 mblaze_timer->tlr0 = 0; 71 76 /* Reset the timer and interrupt */ 72 timer->tcsr0 = MICROBLAZE_TIMER_TCSR0_T0INT | MICROBLAZE_TIMER_TCSR0_LOAD0;77 mblaze_timer->tcsr0 = MICROBLAZE_TIMER_TCSR0_T0INT | MICROBLAZE_TIMER_TCSR0_LOAD0; 73 78 /* Release the reset */ 74 timer->tcsr0 = 0;79 mblaze_timer->tcsr0 = 0; 75 80 /* 76 81 * Enable interrupt, auto reload mode, external interrupt signal, 77 82 * and down counter 78 83 */ 79 timer->tcsr0 = MICROBLAZE_TIMER_TCSR0_ARHT0 | MICROBLAZE_TIMER_TCSR0_ENIT0 |84 mblaze_timer->tcsr0 = MICROBLAZE_TIMER_TCSR0_ARHT0 | MICROBLAZE_TIMER_TCSR0_ENIT0 | 80 85 MICROBLAZE_TIMER_TCSR0_GENT0 | MICROBLAZE_TIMER_TCSR0_UDT0; 81 86 82 87 uint64_t us_per_tick = rtems_configuration_get_microseconds_per_tick(); 83 uint32_t counter_frequency_in_hz = BSP_MICROBLAZE_FPGA_TIMER_FREQUENCY; 88 uint32_t counter_frequency_in_hz = try_get_prop_from_device_tree( 89 "xlnx,xps-timer-1.00.a", 90 "clock-frequency", 91 BSP_MICROBLAZE_FPGA_TIMER_FREQUENCY 92 ); 84 93 uint32_t counter_ticks_per_clock_tick = 85 94 ( counter_frequency_in_hz * us_per_tick ) / 1000000; 86 95 87 96 /* Set a reset value for the timer counter */ 88 timer->tlr0 = counter_ticks_per_clock_tick;89 uint32_t control_status_reg = timer->tcsr0;97 mblaze_timer->tlr0 = counter_ticks_per_clock_tick; 98 uint32_t control_status_reg = mblaze_timer->tcsr0; 90 99 /* Load the reset value into the counter register */ 91 timer->tcsr0 = MICROBLAZE_TIMER_TCSR0_LOAD0;100 mblaze_timer->tcsr0 = MICROBLAZE_TIMER_TCSR0_LOAD0; 92 101 /* Enable the timer */ 93 timer->tcsr0 = control_status_reg | MICROBLAZE_TIMER_TCSR0_ENT0;102 mblaze_timer->tcsr0 = control_status_reg | MICROBLAZE_TIMER_TCSR0_ENT0; 94 103 95 104 rtems_timecounter_simple_install( … … 103 112 static void microblaze_clock_at_tick( rtems_timecounter_simple *tc ) 104 113 { 105 volatile Microblaze_Timer *timer = _Microblaze_Timer; 106 if ( ( timer->tcsr0 & MICROBLAZE_TIMER_TCSR0_T0INT ) == 0 ) { 114 if ( ( mblaze_timer->tcsr0 & MICROBLAZE_TIMER_TCSR0_T0INT ) == 0 ) { 107 115 return; 108 116 } 109 117 /* Clear the interrupt */ 110 timer->tcsr0 |= MICROBLAZE_TIMER_TCSR0_T0INT;118 mblaze_timer->tcsr0 |= MICROBLAZE_TIMER_TCSR0_T0INT; 111 119 } 112 120 … … 124 132 rtems_status_code sc = RTEMS_SUCCESSFUL; 125 133 134 uint32_t clock_irq_num = try_get_prop_from_device_tree( 135 "xlnx,xps-timer-1.00.a", 136 "interrupts", 137 0 138 ); 139 126 140 sc = rtems_interrupt_handler_install( 127 0,141 clock_irq_num, 128 142 "Clock", 129 143 RTEMS_INTERRUPT_UNIQUE, -
bsps/microblaze/microblaze_fpga/include/bsp/timer.h
r63b21ad5 reb94aaf 61 61 } Microblaze_Timer; 62 62 63 #define _Microblaze_Timer ((volatile Microblaze_Timer *) BSP_MICROBLAZE_FPGA_TIMER_BASE)64 65 63 #ifdef __cplusplus 66 64 }
Note: See TracChangeset
for help on using the changeset viewer.