From 99f67930c27d2dcc757b90aa9f3c15639456dde2 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Mon, 26 Nov 2007 23:02:03 +0000 Subject: 2007-11-26 Joel Sherrill * sh7032/clock/ckinit.c, sh7032/delay/delay.c, sh7032/timer/timer.c, sh7045/clock/ckinit.c, sh7045/timer/timer.c, sh7750/clock/ckinit.c, sh7750/timer/timer.c: Eliminate the clicks_per_microsecond field in the SuperH CPU Table and define another mechanism for drivers to obtain this information. --- c/src/lib/libcpu/sh/ChangeLog | 8 ++++++++ c/src/lib/libcpu/sh/sh7032/clock/ckinit.c | 17 +++++++++-------- c/src/lib/libcpu/sh/sh7032/delay/delay.c | 9 +++++---- c/src/lib/libcpu/sh/sh7032/timer/timer.c | 4 +++- c/src/lib/libcpu/sh/sh7045/clock/ckinit.c | 4 +++- c/src/lib/libcpu/sh/sh7045/timer/timer.c | 4 +++- c/src/lib/libcpu/sh/sh7750/clock/ckinit.c | 5 +++-- c/src/lib/libcpu/sh/sh7750/timer/timer.c | 6 +++--- 8 files changed, 37 insertions(+), 20 deletions(-) (limited to 'c/src/lib') diff --git a/c/src/lib/libcpu/sh/ChangeLog b/c/src/lib/libcpu/sh/ChangeLog index 6cb9cab3a3..a749d1306b 100644 --- a/c/src/lib/libcpu/sh/ChangeLog +++ b/c/src/lib/libcpu/sh/ChangeLog @@ -1,3 +1,11 @@ +2007-11-26 Joel Sherrill + + * sh7032/clock/ckinit.c, sh7032/delay/delay.c, sh7032/timer/timer.c, + sh7045/clock/ckinit.c, sh7045/timer/timer.c, sh7750/clock/ckinit.c, + sh7750/timer/timer.c: Eliminate the clicks_per_microsecond field in + the SuperH CPU Table and define another mechanism for drivers to + obtain this information. + 2007-09-12 Joel Sherrill PR 1257/bsps diff --git a/c/src/lib/libcpu/sh/sh7032/clock/ckinit.c b/c/src/lib/libcpu/sh/sh7032/clock/ckinit.c index 96abdd3f46..7468d404a7 100644 --- a/c/src/lib/libcpu/sh/sh7032/clock/ckinit.c +++ b/c/src/lib/libcpu/sh/sh7032/clock/ckinit.c @@ -31,6 +31,8 @@ #include #include +extern uint32_t bsp_clicks_per_second; + #ifndef CLOCKPRIO #define CLOCKPRIO 10 #endif @@ -80,7 +82,8 @@ */ static unsigned int sh_clicks_per_tick( unsigned int clicks_per_sec, - unsigned int usec_per_tick ) + unsigned int usec_per_tick +) { #if 1 unsigned int clicks_per_tick = 0 ; @@ -195,9 +198,9 @@ void Install_clock( ) { uint8_t temp8 = 0; - uint32_t microseconds_per_tick ; - uint32_t cclicks_per_tick ; - uint16_t Clock_limit ; + uint32_t microseconds_per_tick; + uint32_t cclicks_per_tick; + uint16_t Clock_limit; /* * Initialize the clock tick device driver variables @@ -211,10 +214,8 @@ void Install_clock( microseconds_per_tick = 10000 ; /* 10000 us */ /* clock clicks per tick */ - cclicks_per_tick = - sh_clicks_per_tick( - rtems_cpu_configuration_get_clicks_per_second() / CLOCK_SCALE, - microseconds_per_tick ); + cclicks_per_tick = sh_clicks_per_tick( + bsp_clicks_per_second / CLOCK_SCALE, microseconds_per_tick ); Clock_isrs_const = cclicks_per_tick >> 16 ; if ( ( cclicks_per_tick | 0xffff ) > 0 ) diff --git a/c/src/lib/libcpu/sh/sh7032/delay/delay.c b/c/src/lib/libcpu/sh/sh7032/delay/delay.c index 41d4753908..16645ea200 100644 --- a/c/src/lib/libcpu/sh/sh7032/delay/delay.c +++ b/c/src/lib/libcpu/sh/sh7032/delay/delay.c @@ -23,6 +23,8 @@ #include +extern uint32_t bsp_clicks_per_second; + /* * Simple spin delay in microsecond units for device drivers. * This is very dependent on the clock speed of the target. @@ -38,10 +40,9 @@ void CPU_delay( uint32_t microseconds ) { - register uint32_t clicks_per_usec = - rtems_cpu_configuration_get_clicks_per_second() / 1000000 ; - register uint32_t _delay = - (microseconds) * (clicks_per_usec); + register uint32_t clicks_per_usec = bsp_clicks_per_second / 1000000; + register uint32_t _delay = (microseconds) * (clicks_per_usec); + asm volatile ( "0: add #-4,%0\n\ nop\n\ diff --git a/c/src/lib/libcpu/sh/sh7032/timer/timer.c b/c/src/lib/libcpu/sh/sh7032/timer/timer.c index 6b7a8ba335..3fb5151457 100644 --- a/c/src/lib/libcpu/sh/sh7032/timer/timer.c +++ b/c/src/lib/libcpu/sh/sh7032/timer/timer.c @@ -34,6 +34,8 @@ #include #include +extern uint32_t bsp_clicks_per_second; + #define I_CLK_PHI_1 0 #define I_CLK_PHI_2 1 #define I_CLK_PHI_4 2 @@ -77,7 +79,7 @@ void Timer_initialize( void ) rtems_interrupt_level level; rtems_isr *ignored; - Timer_HZ = rtems_cpu_configuration_get_clicks_per_second() / CLOCK_SCALE ; + Timer_HZ = bsp_clicks_per_second / CLOCK_SCALE ; /* * Timer has never overflowed. This may not be necessary on some diff --git a/c/src/lib/libcpu/sh/sh7045/clock/ckinit.c b/c/src/lib/libcpu/sh/sh7045/clock/ckinit.c index 76c08a690e..6a43c5fc54 100644 --- a/c/src/lib/libcpu/sh/sh7045/clock/ckinit.c +++ b/c/src/lib/libcpu/sh/sh7045/clock/ckinit.c @@ -43,6 +43,8 @@ #include #include +extern uint32_t bsp_clicks_per_second; + #define _MTU_COUNTER0_MICROSECOND (Clock_MHZ/16) #ifndef CLOCKPRIO @@ -161,7 +163,7 @@ void Install_clock( Clock_isrs = Clock_isrs_const; factor /= rtems_configuration_get_microseconds_per_tick(); /* minimalization of integer division error */ - Clock_MHZ = rtems_cpu_configuration_get_clicks_per_second() / factor ; + Clock_MHZ = bsp_clicks_per_second / factor ; rtems_interrupt_catch( Clock_isr, CLOCK_VECTOR, &Old_ticker ); diff --git a/c/src/lib/libcpu/sh/sh7045/timer/timer.c b/c/src/lib/libcpu/sh/sh7045/timer/timer.c index aa889f39c8..0ed7f19da8 100644 --- a/c/src/lib/libcpu/sh/sh7045/timer/timer.c +++ b/c/src/lib/libcpu/sh/sh7045/timer/timer.c @@ -33,6 +33,8 @@ #include #include +extern uint32_t bsp_clicks_per_second; + /* * We use a Phi/4 timer */ @@ -68,7 +70,7 @@ void Timer_initialize( void ) rtems_interrupt_level level; rtems_isr *ignored; - Timer_MHZ = rtems_cpu_configuration_get_clicks_per_second() / 1000000 ; + Timer_MHZ = bsp_clicks_per_second / 1000000 ; /* * Timer has never overflowed. This may not be necessary on some diff --git a/c/src/lib/libcpu/sh/sh7750/clock/ckinit.c b/c/src/lib/libcpu/sh/sh7750/clock/ckinit.c index 9fb729bec6..02c0de4262 100644 --- a/c/src/lib/libcpu/sh/sh7750/clock/ckinit.c +++ b/c/src/lib/libcpu/sh/sh7750/clock/ckinit.c @@ -24,6 +24,8 @@ #include #include +extern uint32_t bsp_clicks_per_second; + #ifndef CLOCKPRIO #define CLOCKPRIO 10 #endif @@ -176,8 +178,7 @@ Install_clock(rtems_isr_entry clock_isr) rtems_fatal_error_occurred( RTEMS_NOT_CONFIGURED); } timer_divider = - (rtems_cpu_configuration_get_clicks_per_second() * - cpudiv / (tidiv*1000000)) * + (bsp_clicks_per_second * cpudiv / (tidiv*1000000)) * rtems_configuration_get_microseconds_per_tick(); /* diff --git a/c/src/lib/libcpu/sh/sh7750/timer/timer.c b/c/src/lib/libcpu/sh/sh7750/timer/timer.c index 893e54a88f..8611bdb4fc 100644 --- a/c/src/lib/libcpu/sh/sh7750/timer/timer.c +++ b/c/src/lib/libcpu/sh/sh7750/timer/timer.c @@ -27,6 +27,8 @@ #include #include +extern uint32_t bsp_clicks_per_second; + #ifndef TIMER_PRIO #define TIMER_PRIO 15 #endif @@ -133,9 +135,7 @@ Timer_initialize(void) rtems_fatal_error_occurred( RTEMS_NOT_CONFIGURED); } - microseconds_divider = - rtems_cpu_configuration_get_clicks_per_second() * cpudiv / - (tidiv * 1000000); + microseconds_divider = bsp_clicks_per_second * cpudiv / (tidiv * 1000000); microseconds_per_int = 0xFFFFFFFF / microseconds_divider; /* -- cgit v1.2.3