From 9968efbc7e33ef1f13797ea131564c3d17da70fb Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Tue, 28 Jul 1998 23:16:34 +0000 Subject: First cut at configuration table for libchip RTC. At this point, we are pretending that the DMV177 has an M48T08. --- c/src/lib/libbsp/powerpc/dmv177/tod/Makefile.in | 2 +- c/src/lib/libbsp/powerpc/dmv177/tod/config.c | 58 +++++ c/src/lib/libbsp/powerpc/dmv177/tod/tod.c | 274 ------------------------ c/src/lib/libbsp/powerpc/dmv177/tod/todcfg.c | 58 +++++ 4 files changed, 117 insertions(+), 275 deletions(-) create mode 100644 c/src/lib/libbsp/powerpc/dmv177/tod/config.c delete mode 100644 c/src/lib/libbsp/powerpc/dmv177/tod/tod.c create mode 100644 c/src/lib/libbsp/powerpc/dmv177/tod/todcfg.c (limited to 'c/src/lib/libbsp/powerpc/dmv177/tod') diff --git a/c/src/lib/libbsp/powerpc/dmv177/tod/Makefile.in b/c/src/lib/libbsp/powerpc/dmv177/tod/Makefile.in index c32c5be44d..960d637bc0 100644 --- a/c/src/lib/libbsp/powerpc/dmv177/tod/Makefile.in +++ b/c/src/lib/libbsp/powerpc/dmv177/tod/Makefile.in @@ -4,7 +4,7 @@ @SET_MAKE@ srcdir = @srcdir@ -VPATH = @srcdir@ +VPATH = @srcdir@:@srcdir@/../../../shared RTEMS_ROOT = @top_srcdir@ PROJECT_ROOT = @PROJECT_ROOT@ diff --git a/c/src/lib/libbsp/powerpc/dmv177/tod/config.c b/c/src/lib/libbsp/powerpc/dmv177/tod/config.c new file mode 100644 index 0000000000..4fe5b9923c --- /dev/null +++ b/c/src/lib/libbsp/powerpc/dmv177/tod/config.c @@ -0,0 +1,58 @@ +/* + * This file contains the RTC driver table for the DY-4 DMV177. + * + * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994, 1997. + * On-Line Applications Research Corporation (OAR). + * All rights assigned to U.S. Government, 1994. + * + * $Id$ + */ + +#include + +#include +#include + +/* + * Configuration specific probe routines + * + * NOTE: There are no DMV177 specific configuration routines. These + * routines could be written to dynamically determine what type + * of real-time clock is on this board. This would be useful for + * a BSP supporting multiple board models. + */ + +/* NONE CURRENTLY PROVIDED */ + +/* + * The following table configures the RTC drivers used in this BSP. + * + * The first entry which, when probed, is available, will be named /dev/rtc, + * all others being given the name indicated. + */ + +rtc_tbl RTC_Table[] = { + { + "/dev/rtc0", /* sDeviceName */ + RTC_M48T08, /* deviceType */ + MC68681_FUNCTIONS, /* pDeviceFns */ + rtc_probe, /* deviceProbe */ + NULL, /* pDeviceParams */ + DMV170_RTC_ADDRESS, /* ulCtrlPort1 */ + NULL, /* ulCtrlPort2 */ + NULL, /* ulDataPort */ + m48t08_get_register, /* getRegister */ + m48t08_set_register, /* setRegister */ + NULL, /* unused */ /* setData */ + } +}; + +/* + * Declare some information used by the RTC driver + */ + +#define NUM_RTCS (sizeof(RTC_Table)/sizeof(rtc_tbl)) + +unsigned long RTC_Count = NUM_RTCS; + +rtems_device_minor_number RTC_Minor; diff --git a/c/src/lib/libbsp/powerpc/dmv177/tod/tod.c b/c/src/lib/libbsp/powerpc/dmv177/tod/tod.c deleted file mode 100644 index 05633a120e..0000000000 --- a/c/src/lib/libbsp/powerpc/dmv177/tod/tod.c +++ /dev/null @@ -1,274 +0,0 @@ -/* - * Real Time Clock (Harris ICM7170) for RTEMS - * - * This part is found on the second generation of this board. - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.OARcorp.com/rtems/license.html. - * - * $Id$ - */ - -#include -#include -#include - -/* - * These values are programed into a register and must not be changed. - */ - -#define ICM1770_CRYSTAL_FREQ_32K 0x00 -#define ICM1770_CRYSTAL_FREQ_1M 0x01 -#define ICM1770_CRYSTAL_FREQ_2M 0x02 -#define ICM1770_CRYSTAL_FREQ_4M 0x03 - -void ICM7170_GetTOD( - volatile unsigned char *imc1770_regs, - rtems_unsigned8 icm1770_freq, - rtems_time_of_day *rtc_tod -); -void ICM7170_SetTOD( - volatile unsigned char *imc1770_regs, - rtems_unsigned8 icm1770_freq, - rtems_time_of_day *rtc_tod -); - -/* - * This code is dependent on the boards use of the ICM7170 RTC/NVRAM - * and should remain in this file. - */ - -/* PAGE - * - * This routine copies the time from the real time clock to RTEMS - * - * Input parameters: NONE - * - * Output parameters: NONE - * - * Return values: NONE - */ - -void setRealTimeToRTEMS() -{ - rtems_time_of_day rtc_tod; - - ICM7170_GetTOD( DMV170_RTC_ADDRESS, DMV170_RTC_FREQUENCY, &rtc_tod ); - rtems_clock_set( &rtc_tod ); -} - -/* PAGE - * - * setRealTimeFromRTEMS - * - * This routine copies the time from RTEMS to the real time clock - * - * Input parameters: NONE - * - * Output parameters: NONE - * - * Return values: NONE - */ - -void setRealTimeFromRTEMS() -{ - rtems_time_of_day rtems_tod; - - rtems_clock_get( RTEMS_CLOCK_GET_TOD, &rtems_tod ); - ICM7170_SetTOD( DMV170_RTC_ADDRESS, DMV170_RTC_FREQUENCY, &rtems_tod ); -} - -/* PAGE - * - * checkRealTime - * - * This routine reads the returns the variance betweent the real time and - * rtems time. - * - * Input parameters: NONE - * - * Output parameters: NONE - * - * Return values: - * int The differance between the real time clock and rtems time or - * 9999 in the event of an error. - */ - -int checkRealTime() -{ - rtems_time_of_day rtems_tod; - rtems_time_of_day rtc_tod; - - ICM7170_GetTOD( DMV170_RTC_ADDRESS, DMV170_RTC_FREQUENCY, &rtc_tod ); - rtems_clock_get( RTEMS_CLOCK_GET_TOD, &rtems_tod ); - - if( rtems_tod.year == rtc_tod.year && - rtems_tod.month == rtc_tod.month && - rtems_tod.day == rtc_tod.day ) { - return ((rtems_tod.hour - rtc_tod.hour) * 3600) + - ((rtems_tod.minute - rtc_tod.minute) * 60) + - (rtems_tod.second - rtc_tod.second); - } - return 9999; -} - -/* - * These routines are ICM7170 should be in - * a separate support library. When the chiplib - * is created for RTEMS these routines will be moved. - */ - -/* PAGE - * - * ICM7170_GetField - * - * This routine gets a field - * - * Input parameters: - * imc1770_regs - pointer to the register base address. - * reg - register id - * - * Output parameters: NONE - * - * Return values: value of register - */ - -static int ICM7170_GetField( - volatile unsigned char *imc1770_regs, - int reg -) -{ - unsigned char x; - - x = imc1770_regs[reg*4]; - - return x; -} - -/* PAGE - * - * ICM7170_SetField - * - * This routine sets a field - * - * Input parameters: - * imc1770_regs - pointer to the register base address. - * reg - register id - * d - data to write - * - * Output parameters: NONE - * - * Return values: NONE - */ - -static void ICM7170_SetField( - volatile unsigned char *imc1770_regs, - int reg, - unsigned char d -) -{ - imc1770_regs[reg*4] = d; -} - -/* PAGE - * - * ICM7170_GetTOD - * - * This routine gets the real time clock time of day in rtems - * time of day format. - * - * Input parameters: - * imc1770_regs - pointer to the register base address. - * icm1770_freq - oscillator frequency - * - * Output parameters: - * rtc_tod - time of day by the real time clock - * - * Return values: NONE - */ - -void ICM7170_GetTOD( - volatile unsigned char *imc1770_regs, - rtems_unsigned8 icm1770_freq, - rtems_time_of_day *rtc_tod -) -{ - int year; - int usec; - static rtems_boolean init = TRUE; - - /* Initialize the clock at once prior to reading */ - if (init ) { - ICM7170_SetField( imc1770_regs, 0x11, (0x0c | icm1770_freq) ); - init = FALSE; - } - - usec = ICM7170_GetField( imc1770_regs, 0x00 ); - - year = ICM7170_GetField( imc1770_regs, 0x06 ); - if ( year >= 88 ) - year += 1900; - else - year += 2000; - - rtc_tod->year = year; - rtc_tod->month = ICM7170_GetField( imc1770_regs, 0x04 ); - rtc_tod->day = ICM7170_GetField( imc1770_regs, 0x05 ); - rtc_tod->hour = ICM7170_GetField( imc1770_regs, 0x01 ); - rtc_tod->minute = ICM7170_GetField( imc1770_regs, 0x02 ); - rtc_tod->second = ICM7170_GetField( imc1770_regs, 0x03 ); - rtc_tod->ticks = ICM7170_GetField( imc1770_regs, 0x00 ); -} - -/* PAGE - * - * ICM7170_SetTOD - * - * This routine sets the real time clock - * - * Input parameters: - * imc1770_regs - pointer to the register base address. - * icm1770_freq - oscillator frequency - * rtc_tod - time of day to set - * - * Output parameters: - * - * Return values: - */ - -void ICM7170_SetTOD( - volatile unsigned char *imc1770_regs, - rtems_unsigned8 icm1770_freq, - rtems_time_of_day *rtc_tod -) -{ - int year; - - year = rtc_tod->year; - if ( year >= 2088 ) /* plan ahead :) */ - rtems_fatal_error_occurred( 0xBAD0BAD0 ); - - if ( year >= 2000 ) - year -= 2000; - else - year -= 1900; - - ICM7170_SetField( imc1770_regs, 0x11, (0x04 |icm1770_freq ) ); - - ICM7170_SetField( imc1770_regs, 0x06, year ); - ICM7170_SetField( imc1770_regs, 0x04, rtc_tod->month ); - ICM7170_SetField( imc1770_regs, 0x05, rtc_tod->day ); - ICM7170_SetField( imc1770_regs, 0x01, rtc_tod->hour ); - ICM7170_SetField( imc1770_regs, 0x02, rtc_tod->minute ); - ICM7170_SetField( imc1770_regs, 0x03, rtc_tod->second ); - - /* - * I don't know which day of week is - * - */ - ICM7170_SetField( imc1770_regs, 0x07, 1 ); - - ICM7170_SetField( imc1770_regs, 0x11, (0x0c | icm1770_freq) ); -} - diff --git a/c/src/lib/libbsp/powerpc/dmv177/tod/todcfg.c b/c/src/lib/libbsp/powerpc/dmv177/tod/todcfg.c new file mode 100644 index 0000000000..4fe5b9923c --- /dev/null +++ b/c/src/lib/libbsp/powerpc/dmv177/tod/todcfg.c @@ -0,0 +1,58 @@ +/* + * This file contains the RTC driver table for the DY-4 DMV177. + * + * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994, 1997. + * On-Line Applications Research Corporation (OAR). + * All rights assigned to U.S. Government, 1994. + * + * $Id$ + */ + +#include + +#include +#include + +/* + * Configuration specific probe routines + * + * NOTE: There are no DMV177 specific configuration routines. These + * routines could be written to dynamically determine what type + * of real-time clock is on this board. This would be useful for + * a BSP supporting multiple board models. + */ + +/* NONE CURRENTLY PROVIDED */ + +/* + * The following table configures the RTC drivers used in this BSP. + * + * The first entry which, when probed, is available, will be named /dev/rtc, + * all others being given the name indicated. + */ + +rtc_tbl RTC_Table[] = { + { + "/dev/rtc0", /* sDeviceName */ + RTC_M48T08, /* deviceType */ + MC68681_FUNCTIONS, /* pDeviceFns */ + rtc_probe, /* deviceProbe */ + NULL, /* pDeviceParams */ + DMV170_RTC_ADDRESS, /* ulCtrlPort1 */ + NULL, /* ulCtrlPort2 */ + NULL, /* ulDataPort */ + m48t08_get_register, /* getRegister */ + m48t08_set_register, /* setRegister */ + NULL, /* unused */ /* setData */ + } +}; + +/* + * Declare some information used by the RTC driver + */ + +#define NUM_RTCS (sizeof(RTC_Table)/sizeof(rtc_tbl)) + +unsigned long RTC_Count = NUM_RTCS; + +rtems_device_minor_number RTC_Minor; -- cgit v1.2.3