diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2001-10-26 19:30:11 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2001-10-26 19:30:11 +0000 |
commit | e56c35463b227b85d6a741e30a826d7ba2a71db7 (patch) | |
tree | 568f587e83eed0359e1f111dc91f826c6b10eb48 /c/src/lib/libbsp/m68k/mcf5206elite/tod/todcfg.c | |
parent | 2001-10-26 Joel Sherrill <joel@OARcorp.com> (diff) | |
download | rtems-e56c35463b227b85d6a741e30a826d7ba2a71db7.tar.bz2 |
2001-10-26 Victor V. Vengerov <vvv@oktet.ru>
* New BSP for MCF5206eLITE evaluation board BSP.
* ChangeLog, README, bsp_specs, configure.ac, console/console.c,
console/.cvsignore, i2c/i2c.c, i2c/i2cdrv.c, i2c/.cvsignore,
include/bsp.h, include/bspopts.h.in, include/coverhd.h,
include/ds1307.h, include/i2c.h, include/i2cdrv.h, include/nvram.h,
include/.cvsignore, nvram/nvram.c, nvram/.cvsignore, start/start.S,
start/.cvsignore, startup/bspclean.c, startup/bspstart.c,
startup/gdbinit, startup/init5206e.c, startup/linkcmds,
startup/linkcmds.flash, startup/.cvsignore, times, tod/ds1307.c,
tod/todcfg.c, tod/.cvsignore, tools/.cvsignore, tools/configure.ac,
tools/runtest, tools/changes, wrapup/.cvsignore, .cvsignore:
New files.
Diffstat (limited to 'c/src/lib/libbsp/m68k/mcf5206elite/tod/todcfg.c')
-rw-r--r-- | c/src/lib/libbsp/m68k/mcf5206elite/tod/todcfg.c | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/c/src/lib/libbsp/m68k/mcf5206elite/tod/todcfg.c b/c/src/lib/libbsp/m68k/mcf5206elite/tod/todcfg.c new file mode 100644 index 0000000000..ec063877f0 --- /dev/null +++ b/c/src/lib/libbsp/m68k/mcf5206elite/tod/todcfg.c @@ -0,0 +1,84 @@ +/* + * This file contains the RTC driver table for Motorola MCF5206eLITE + * ColdFire evaluation board. + * + * Copyright (C) 2000 OKTET Ltd., St.-Petersburg, Russia + * Author: Victor V. Vengerov <vvv@oktet.ru> + * + * 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 <bsp.h> +#include <libchip/rtc.h> +#include <ds1307.h> + +/* Forward function declaration */ +boolean mcf5206elite_ds1307_probe(int minor); + +extern rtc_fns ds1307_fns; + +/* The following table configures the RTC drivers used in this BSP */ +rtc_tbl RTC_Table[] = { + { + "/dev/rtc", /* sDeviceName */ + RTC_CUSTOM, /* deviceType */ + &ds1307_fns, /* pDeviceFns */ + mcf5206elite_ds1307_probe, /* deviceProbe */ + NULL, /* pDeviceParams */ + 0x00, /* ulCtrlPort1, for DS1307-I2C bus number */ + DS1307_I2C_ADDRESS, /* ulDataPort, for DS1307-I2C device addr */ + NULL, /* getRegister - not applicable to DS1307 */ + NULL /* setRegister - not applicable to DS1307 */ + } +}; + +/* 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; + +/* mcf5206elite_ds1307_probe -- + * RTC presence probe function. Return TRUE, if device is present. + * Device presence checked by probe access to RTC device over I2C bus. + * + * PARAMETERS: + * minor - minor RTC device number + * + * RETURNS: + * TRUE, if RTC device is present + */ +boolean +mcf5206elite_ds1307_probe(int minor) +{ + int try = 0; + i2c_message_status status; + rtc_tbl *rtc; + i2c_bus_number bus; + i2c_address addr; + + if (minor >= NUM_RTCS) + return FALSE; + + rtc = RTC_Table + minor; + + bus = rtc->ulCtrlPort1; + addr = rtc->ulDataPort; + do { + status = i2c_wrbyte(bus, addr, 0); + if (status == I2C_NO_DEVICE) + return FALSE; + try++; + } while ((try < 15) && (status != I2C_SUCCESSFUL)); + if (status == I2C_SUCCESSFUL) + return TRUE; + else + return FALSE; +} |