2007-06-21 Joel Sherrill <joel.sherrill@oarcorp.com>

* clock/clock.c: Add nanoseconds since last tick support.
This commit is contained in:
Joel Sherrill
2007-06-21 22:45:05 +00:00
parent d3b057906a
commit 31fe820136
2 changed files with 23 additions and 1 deletions

View File

@@ -1,3 +1,7 @@
2007-06-21 Joel Sherrill <joel.sherrill@oarcorp.com>
* clock/clock.c: Add nanoseconds since last tick support.
2007-06-20 Joel Sherrill <joel.sherrill@oarcorp.com> 2007-06-20 Joel Sherrill <joel.sherrill@oarcorp.com>
Add Embedded Planets EP5200 which is the same as the Freescale Add Embedded Planets EP5200 which is the same as the Freescale

View File

@@ -126,6 +126,8 @@ rtems_device_major_number rtems_clock_major = ~0;
rtems_device_minor_number rtems_clock_minor; rtems_device_minor_number rtems_clock_minor;
uint64_t Clock_last_TBR;
/* /*
* ISR Handlers * ISR Handlers
*/ */
@@ -141,6 +143,7 @@ void mpc5200_gpt_clock_isr(rtems_irq_hdl_param handle)
{ {
gpt->status |= GPT_STATUS_TEXP; gpt->status |= GPT_STATUS_TEXP;
Clock_last_TBR = PPC_Get_timebase_register();
Clock_driver_ticks++; Clock_driver_ticks++;
@@ -186,6 +189,18 @@ void mpc5200_set_gpt_count(uint32_t counter_value, uint32_t gpt_no)
} }
uint32_t bsp_clock_nanoseconds_since_last_tick(void)
{
uint64_t new_tbr;
uint64_t bus_cycles;
uint32_t nsecs;
new_tbr = PPC_Get_timebase_register();
bus_cycles = (new_tbr - Clock_last_TBR) * 4;
nsecs = (uint32_t) (bus_cycles / (XLB_CLOCK / 1000000)) * 1000;
return nsecs;
}
/* /*
* Enable MPC5x00 GPT interrupt * Enable MPC5x00 GPT interrupt
@@ -195,6 +210,7 @@ void mpc5200_enable_gpt_int(uint32_t gpt_no)
struct mpc5200_gpt *gpt = (struct mpc5200_gpt *)(&mpc5200.gpt[gpt_no]); struct mpc5200_gpt *gpt = (struct mpc5200_gpt *)(&mpc5200.gpt[gpt_no]);
gpt->emsel |= GPT_EMSEL_CE | GPT_EMSEL_INTEN; gpt->emsel |= GPT_EMSEL_CE | GPT_EMSEL_INTEN;
Clock_last_TBR = PPC_Get_timebase_register();
} }
@@ -227,7 +243,6 @@ void clockOn(const rtems_irq_connect_data* irq)
{ {
uint32_t gpt_no; uint32_t gpt_no;
gpt_no = BSP_SIU_IRQ_TMR0 - (irq->name); gpt_no = BSP_SIU_IRQ_TMR0 - (irq->name);
counter_value = rtems_configuration_get_microseconds_per_tick() * counter_value = rtems_configuration_get_microseconds_per_tick() *
@@ -375,6 +390,9 @@ void Install_clock(rtems_device_minor_number gpt_no)
ClockInitialized = 1; ClockInitialized = 1;
rtems_clock_set_nanoseconds_extension(
bsp_clock_nanoseconds_since_last_tick
);
atexit(Clock_exit); atexit(Clock_exit);
} }