bsps: Move tod.c to bsps and rename

This patch is a part of the BSP source reorganization.

Update #3285.
This commit is contained in:
Sebastian Huber
2018-04-13 08:57:30 +02:00
parent f35c3be9f8
commit 90013f59bd
15 changed files with 14 additions and 14 deletions

View File

@@ -118,7 +118,7 @@ librtemsbsp_a_SOURCES += ../shared/arm-a9mpcore-clock-config.c
librtemsbsp_a_SOURCES += i2c/i2cdrv.c
librtemsbsp_a_SOURCES += i2c/i2cdrv-config.c
# RTC
librtemsbsp_a_SOURCES += ../../shared/tod.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/rtc/rtc-support.c
librtemsbsp_a_SOURCES += rtc/rtc.c
# Cache

View File

@@ -143,7 +143,7 @@ librtemsbsp_a_SOURCES += spi/atsam_spi_init.c
librtemsbsp_a_SOURCES += spi/sc16is752.c
# RTC
librtemsbsp_a_SOURCES += ../../shared/tod.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/rtc/rtc-support.c
librtemsbsp_a_SOURCES += rtc/rtc-config.c
# Helper functions

View File

@@ -79,7 +79,7 @@ librtemsbsp_a_SOURCES += pwm/pwm.c
#RTC
librtemsbsp_a_SOURCES += rtc.c
librtemsbsp_a_SOURCES += ../../shared/tod.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/rtc/rtc-support.c
# Clock
librtemsbsp_a_SOURCES += clock.c

View File

@@ -69,7 +69,7 @@ librtemsbsp_a_SOURCES += ../shared/lpc/clock/lpc-clock-config.c
librtemsbsp_a_SOURCES += ../shared/armv7m/clock/armv7m-clock-config.c
# RTC
librtemsbsp_a_SOURCES += ../../shared/tod.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/rtc/rtc-support.c
librtemsbsp_a_SOURCES += rtc/rtc-config.c
# GPIO

View File

@@ -84,7 +84,7 @@ librtemsbsp_a_SOURCES += ../shared/lpc/clock/lpc-clock-config.c
librtemsbsp_a_SOURCES += ../shared/armv7m/clock/armv7m-clock-config.c
# RTC
librtemsbsp_a_SOURCES += ../../shared/tod.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/rtc/rtc-support.c
librtemsbsp_a_SOURCES += rtc/rtc-config.c
# Misc

View File

@@ -69,7 +69,7 @@ librtemsbsp_a_SOURCES += console/hsu.c
librtemsbsp_a_SOURCES += ../shared/lpc/clock/lpc-clock-config.c
# RTC
librtemsbsp_a_SOURCES += ../../shared/tod.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/rtc/rtc-support.c
librtemsbsp_a_SOURCES += rtc/rtc-config.c
# Misc

View File

@@ -50,7 +50,7 @@ librtemsbsp_a_SOURCES =
# clock
librtemsbsp_a_SOURCES += clock/ckinit.c
librtemsbsp_a_SOURCES += clock/todcfg.c
librtemsbsp_a_SOURCES += ../../shared/tod.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/rtc/rtc-support.c
if RTEMS_VGA
librtemsbsp_a_SOURCES += console/inch.c

View File

@@ -41,7 +41,7 @@ librtemsbsp_a_SOURCES += i2c/i2cdrv.c
# tod
librtemsbsp_a_SOURCES += tod/ds1307.c
librtemsbsp_a_SOURCES += tod/todcfg.c
librtemsbsp_a_SOURCES += ../../shared/tod.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/rtc/rtc-support.c
# nvram
librtemsbsp_a_SOURCES += nvram/nvram.c

View File

@@ -96,7 +96,7 @@ librtemsbsp_a_SOURCES += network/support/early_link_status.c
endif
# tod
librtemsbsp_a_SOURCES += ../../shared/tod.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/rtc/rtc-support.c
librtemsbsp_a_SOURCES += tod/todcfg.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/powerpc/shared/altivec/vec_sup.c

View File

@@ -84,7 +84,7 @@ librtemsbsp_a_SOURCES += slicetimer/slicetimer.c
# tod
librtemsbsp_a_SOURCES += tod/todcfg.c
librtemsbsp_a_SOURCES += tod/pcf8563.c
librtemsbsp_a_SOURCES += ../../shared/tod.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/rtc/rtc-support.c
# startup
librtemsbsp_a_SOURCES += ../../shared/getentropy-cpucounter.c

View File

@@ -49,7 +49,7 @@ librtemsbsp_a_SOURCES += startup/bspreset.c
# tod
librtemsbsp_a_SOURCES += ../../shared/tod.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/rtc/rtc-support.c
librtemsbsp_a_SOURCES += ../shared/tod/todcfg.c
# pclock
librtemsbsp_a_SOURCES += ../shared/clock/p_clock.c

View File

@@ -47,7 +47,7 @@ librtemsbsp_a_SOURCES += ../../shared/getentropy-cpucounter.c
librtemsbsp_a_SOURCES += ../../shared/bspclean.c
librtemsbsp_a_SOURCES += ../../shared/bspreset.c
# tod
librtemsbsp_a_SOURCES += ../../shared/tod.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/rtc/rtc-support.c
librtemsbsp_a_SOURCES += tod/todcfg.c
# pclock
librtemsbsp_a_SOURCES += ../shared/clock/p_clock.c

View File

@@ -44,7 +44,7 @@ librtemsbsp_a_SOURCES += irq/irq_init.c
librtemsbsp_a_SOURCES += irq/BSP_irq.c
# tod
librtemsbsp_a_SOURCES += ../../shared/tod.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/rtc/rtc-support.c
librtemsbsp_a_SOURCES += tod/todcfg.c
# vectors

View File

@@ -73,7 +73,7 @@ librtemsbsp_a_SOURCES += console/uart-bridge-slave.c
librtemsbsp_a_SOURCES += console/console-config.c
# RTC
librtemsbsp_a_SOURCES += ../../shared/tod.c
librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/rtc/rtc-support.c
librtemsbsp_a_SOURCES += rtc/rtc-config.c
# MPCI

View File

@@ -1,287 +0,0 @@
/*
* Real Time Clock Driver Wrapper for Libchip
*/
/*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.org/license/LICENSE.
*/
#include <rtems.h>
#include <rtems/rtc.h>
#include <rtems/tod.h>
#include <rtems/libio.h>
#include <libchip/rtc.h>
/*
* Configuration Information
*/
static rtems_device_minor_number RTC_Minor = UINT32_MAX;
static bool RTC_Is_present(void)
{
return RTC_Minor != UINT32_MAX;
}
/*
* rtc_initialize
*
* Initialize the RTC driver
*/
rtems_device_driver rtc_initialize(
rtems_device_major_number major,
rtems_device_minor_number minor_arg,
void *arg
)
{
rtems_device_minor_number minor;
rtems_status_code status;
for (minor=0; minor < RTC_Count ; minor++) {
/*
* First perform the configuration dependent probe, then the
* device dependent probe
*/
if (RTC_Table[minor].deviceProbe && RTC_Table[minor].deviceProbe(minor)) {
/*
* Use this device as the primary RTC
*/
RTC_Minor = minor;
break;
}
}
if ( !RTC_Is_present() ) {
/*
* Failed to find an RTC -- this is not a fatal error.
*/
return RTEMS_INVALID_NUMBER;
}
/*
* Register and initialize the primary RTC's
*/
status = rtems_io_register_name( RTC_DEVICE_NAME, major, RTC_Minor );
if (status != RTEMS_SUCCESSFUL) {
rtems_fatal_error_occurred(status);
}
RTC_Table[minor].pDeviceFns->deviceInitialize( RTC_Minor );
/*
* Now initialize any secondary RTC's
*/
for ( minor++ ; minor<RTC_Count ; minor++) {
/*
* First perform the configuration dependent probe, then the
* device dependent probe
*/
if (RTC_Table[minor].deviceProbe && RTC_Table[minor].deviceProbe(minor)) {
status = rtems_io_register_name(
RTC_Table[minor].sDeviceName,
major,
minor );
if (status != RTEMS_SUCCESSFUL) {
rtems_fatal_error_occurred(status);
}
/*
* Initialize the hardware device.
*/
RTC_Table[minor].pDeviceFns->deviceInitialize(minor);
}
}
setRealTimeToRTEMS();
return RTEMS_SUCCESSFUL;
}
rtems_device_driver rtc_read(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *arg
)
{
int rv = 0;
rtems_libio_rw_args_t *rw = arg;
rtems_time_of_day *tod = (rtems_time_of_day *) rw->buffer;
rw->offset = 0;
rw->bytes_moved = 0;
if (!RTC_Is_present()) {
return RTEMS_NOT_CONFIGURED;
}
if (rw->count != sizeof( rtems_time_of_day)) {
return RTEMS_INVALID_SIZE;
}
rv = RTC_Table [RTC_Minor].pDeviceFns->deviceGetTime(
RTC_Minor,
tod
);
if (rv != 0) {
return RTEMS_IO_ERROR;
}
rw->bytes_moved = rw->count;
return RTEMS_SUCCESSFUL;
}
rtems_device_driver rtc_write(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *arg
)
{
int rv = 0;
rtems_libio_rw_args_t *rw = arg;
const rtems_time_of_day *tod = (const rtems_time_of_day *) rw->buffer;
rw->offset = 0;
rw->bytes_moved = 0;
if (!RTC_Is_present()) {
return RTEMS_NOT_CONFIGURED;
}
if (rw->count != sizeof( rtems_time_of_day)) {
return RTEMS_INVALID_SIZE;
}
rv = RTC_Table [RTC_Minor].pDeviceFns->deviceSetTime(
RTC_Minor,
tod
);
if (rv != 0) {
return RTEMS_IO_ERROR;
}
rw->bytes_moved = rw->count;
return RTEMS_SUCCESSFUL;
}
rtems_device_driver rtc_open(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *arg
)
{
return RTEMS_SUCCESSFUL;
}
rtems_device_driver rtc_close(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *arg
)
{
return RTEMS_SUCCESSFUL;
}
rtems_device_driver rtc_control(
rtems_device_major_number major,
rtems_device_minor_number minor,
void *arg
)
{
return RTEMS_NOT_IMPLEMENTED;
}
/*
* This routine copies the time from the real time clock to RTEMS
*/
void setRealTimeToRTEMS()
{
rtems_time_of_day rtc_tod;
if (!RTC_Is_present())
return;
RTC_Table[RTC_Minor].pDeviceFns->deviceGetTime(RTC_Minor, &rtc_tod);
rtems_clock_set( &rtc_tod );
}
/*
* setRealTimeFromRTEMS
*
* This routine copies the time from RTEMS to the real time clock
*/
void setRealTimeFromRTEMS(void)
{
rtems_time_of_day rtems_tod;
if (!RTC_Is_present())
return;
rtems_clock_get_tod( &rtems_tod );
RTC_Table[RTC_Minor].pDeviceFns->deviceSetTime(RTC_Minor, &rtems_tod);
}
/*
* getRealTime
*
* This routine reads the current time from the RTC.
*/
void getRealTime(
rtems_time_of_day *tod
)
{
if (!RTC_Is_present())
return;
RTC_Table[RTC_Minor].pDeviceFns->deviceGetTime(RTC_Minor, tod);
}
/*
* setRealTime
*
* This routine sets the RTC.
*/
int setRealTime(
const rtems_time_of_day *tod
)
{
if (!RTC_Is_present())
return -1;
if ( !_TOD_Validate(tod) )
return -1;
RTC_Table[RTC_Minor].pDeviceFns->deviceSetTime(RTC_Minor, tod);
return 0;
}
/*
* checkRealTime
*
* This routine reads the returns the variance betweent the real time and
* RTEMS time.
*/
int checkRealTime(void)
{
rtems_time_of_day rtems_tod;
rtems_time_of_day rtc_tod;
uint32_t rtems_time;
uint32_t rtc_time;
if (!RTC_Is_present())
return -1;
rtems_clock_get_tod( &rtems_tod );
RTC_Table[RTC_Minor].pDeviceFns->deviceGetTime(RTC_Minor, &rtc_tod);
rtems_time = _TOD_To_seconds( &rtems_tod );
rtc_time = _TOD_To_seconds( &rtc_tod );
return rtems_time - rtc_time;
}