forked from Imagelibrary/rtems
2006-05-31 Joel Sherrill <joel@OARcorp.com>
* at91rm9200/clock/clock.c: Convert to using shared clock driver shell.
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
2006-05-31 Joel Sherrill <joel@OARcorp.com>
|
||||
|
||||
* at91rm9200/clock/clock.c: Convert to using shared clock driver shell.
|
||||
|
||||
2006-05-16 Ralf Corsépius <ralf.corsepius@rtems.org>
|
||||
|
||||
* configure.ac: Use RTEMS_AMPOLISH3.
|
||||
|
||||
@@ -24,110 +24,8 @@
|
||||
#include <at91rm9200_pmc.h>
|
||||
|
||||
|
||||
rtems_device_major_number rtems_clock_major = ~0;
|
||||
rtems_device_minor_number rtems_clock_minor;
|
||||
volatile uint32_t Clock_driver_ticks;
|
||||
static unsigned long st_pimr_reload;
|
||||
|
||||
rtems_isr clock_isr(rtems_vector_number vector);
|
||||
void Clock_exit(void);
|
||||
static void clock_isr_on(const rtems_irq_connect_data *unused);
|
||||
static void clock_isr_off(const rtems_irq_connect_data *unused);
|
||||
static int clock_isr_is_on(const rtems_irq_connect_data *irq);
|
||||
|
||||
/* Replace the first value with the clock's interrupt name. */
|
||||
rtems_irq_connect_data clock_isr_data = {AT91RM9200_INT_SYSIRQ,
|
||||
(rtems_irq_hdl)clock_isr,
|
||||
clock_isr_on,
|
||||
clock_isr_off,
|
||||
clock_isr_is_on,
|
||||
3, /* unused for ARM cpus */
|
||||
0 }; /* unused for ARM cpus */
|
||||
|
||||
|
||||
rtems_isr clock_isr(rtems_vector_number vector)
|
||||
{
|
||||
uint32_t st_str;
|
||||
|
||||
Clock_driver_ticks++;
|
||||
|
||||
/* read the status to clear the int */
|
||||
st_str = ST_REG(ST_SR);
|
||||
|
||||
rtems_clock_tick();
|
||||
}
|
||||
|
||||
void Install_clock(rtems_isr_entry clock_isr)
|
||||
{
|
||||
uint32_t st_str;
|
||||
int slck;
|
||||
|
||||
Clock_driver_ticks = 0;
|
||||
|
||||
BSP_install_rtems_irq_handler(&clock_isr_data);
|
||||
|
||||
/* the system timer is driven from SLCK */
|
||||
slck = at91rm9200_get_slck();
|
||||
st_pimr_reload = (((BSP_Configuration.microseconds_per_tick * slck) + (1000000/2))/
|
||||
1000000);
|
||||
|
||||
/* read the status to clear the int */
|
||||
st_str = ST_REG(ST_SR);
|
||||
|
||||
/* set priority */
|
||||
AIC_SMR_REG(AIC_SMR_SYSIRQ) = AIC_SMR_PRIOR(0x7);
|
||||
|
||||
/* set the timer value */
|
||||
ST_REG(ST_PIMR) = st_pimr_reload;
|
||||
|
||||
atexit( Clock_exit );
|
||||
}
|
||||
|
||||
void Clock_exit( void )
|
||||
{
|
||||
BSP_remove_rtems_irq_handler(&clock_isr_data);
|
||||
}
|
||||
|
||||
rtems_device_driver Clock_initialize(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *pargp
|
||||
)
|
||||
{
|
||||
Install_clock( clock_isr );
|
||||
|
||||
rtems_clock_major = major;
|
||||
rtems_clock_minor = minor;
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
rtems_device_driver Clock_control(
|
||||
rtems_device_major_number major,
|
||||
rtems_device_minor_number minor,
|
||||
void *pargp
|
||||
)
|
||||
{
|
||||
uint32_t isrlevel;
|
||||
rtems_libio_ioctl_args_t *args = pargp;
|
||||
|
||||
if (args == 0) {
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
if (args->command == rtems_build_name('I', 'S', 'R', ' ')) {
|
||||
clock_isr(0);
|
||||
} else if (args->command == rtems_build_name('N', 'E', 'W', ' ')) {
|
||||
rtems_interrupt_disable(isrlevel);
|
||||
|
||||
BSP_install_rtems_irq_handler(args->buffer);
|
||||
|
||||
rtems_interrupt_enable(isrlevel);
|
||||
}
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables clock interrupt.
|
||||
*
|
||||
@@ -162,3 +60,56 @@ static int clock_isr_is_on(const rtems_irq_connect_data *irq)
|
||||
/* check timer interrupt */
|
||||
return ST_REG(ST_IMR) & ST_SR_PITS;
|
||||
}
|
||||
|
||||
rtems_isr Clock_isr(rtems_vector_number vector);
|
||||
|
||||
/* Replace the first value with the clock's interrupt name. */
|
||||
rtems_irq_connect_data clock_isr_data = {AT91RM9200_INT_SYSIRQ,
|
||||
(rtems_irq_hdl)Clock_isr,
|
||||
clock_isr_on,
|
||||
clock_isr_off,
|
||||
clock_isr_is_on,
|
||||
3, /* unused for ARM cpus */
|
||||
0 }; /* unused for ARM cpus */
|
||||
|
||||
|
||||
#define Clock_driver_support_install_isr( _new, _old ) \
|
||||
BSP_install_rtems_irq_handler(&clock_isr_data)
|
||||
|
||||
void Clock_driver_support_initialize_hardware(void)
|
||||
{
|
||||
uint32_t st_str;
|
||||
int slck;
|
||||
|
||||
/* the system timer is driven from SLCK */
|
||||
slck = at91rm9200_get_slck();
|
||||
st_pimr_reload =
|
||||
(((BSP_Configuration.microseconds_per_tick * slck) + (1000000/2))/ 1000000);
|
||||
|
||||
/* read the status to clear the int */
|
||||
st_str = ST_REG(ST_SR);
|
||||
|
||||
/* set priority */
|
||||
AIC_SMR_REG(AIC_SMR_SYSIRQ) = AIC_SMR_PRIOR(0x7);
|
||||
|
||||
/* set the timer value */
|
||||
ST_REG(ST_PIMR) = st_pimr_reload;
|
||||
}
|
||||
|
||||
|
||||
#define CLOCK_VECTOR 0
|
||||
|
||||
#define Clock_driver_support_at_tick() \
|
||||
do { \
|
||||
uint32_t st_str; \
|
||||
\
|
||||
/* read the status to clear the int */ \
|
||||
st_str = ST_REG(ST_SR); \
|
||||
} while (0)
|
||||
|
||||
void Clock_driver_support_shutdown_hardware( void )
|
||||
{
|
||||
BSP_remove_rtems_irq_handler(&clock_isr_data);
|
||||
}
|
||||
|
||||
#include "../../../../libbsp/shared/clockdrv_shell.c"
|
||||
|
||||
Reference in New Issue
Block a user