[e56c3546] | 1 | /* |
---|
| 2 | * This file contains the RTC driver table for Motorola MCF5206eLITE |
---|
| 3 | * ColdFire evaluation board. |
---|
| 4 | * |
---|
| 5 | * Copyright (C) 2000 OKTET Ltd., St.-Petersburg, Russia |
---|
| 6 | * Author: Victor V. Vengerov <vvv@oktet.ru> |
---|
| 7 | * |
---|
| 8 | * The license and distribution terms for this file may be |
---|
| 9 | * found in the file LICENSE in this distribution or at |
---|
| 10 | * |
---|
[acaae90] | 11 | * http://www.rtems.com/license/LICENSE. |
---|
[e56c3546] | 12 | * |
---|
| 13 | * @(#) $Id$ |
---|
| 14 | */ |
---|
| 15 | |
---|
| 16 | #include <bsp.h> |
---|
| 17 | #include <libchip/rtc.h> |
---|
| 18 | #include <ds1307.h> |
---|
| 19 | |
---|
| 20 | /* Forward function declaration */ |
---|
| 21 | boolean mcf5206elite_ds1307_probe(int minor); |
---|
| 22 | |
---|
| 23 | extern rtc_fns ds1307_fns; |
---|
| 24 | |
---|
| 25 | /* The following table configures the RTC drivers used in this BSP */ |
---|
| 26 | rtc_tbl RTC_Table[] = { |
---|
| 27 | { |
---|
| 28 | "/dev/rtc", /* sDeviceName */ |
---|
| 29 | RTC_CUSTOM, /* deviceType */ |
---|
| 30 | &ds1307_fns, /* pDeviceFns */ |
---|
| 31 | mcf5206elite_ds1307_probe, /* deviceProbe */ |
---|
| 32 | NULL, /* pDeviceParams */ |
---|
| 33 | 0x00, /* ulCtrlPort1, for DS1307-I2C bus number */ |
---|
| 34 | DS1307_I2C_ADDRESS, /* ulDataPort, for DS1307-I2C device addr */ |
---|
| 35 | NULL, /* getRegister - not applicable to DS1307 */ |
---|
| 36 | NULL /* setRegister - not applicable to DS1307 */ |
---|
| 37 | } |
---|
| 38 | }; |
---|
| 39 | |
---|
| 40 | /* Some information used by the RTC driver */ |
---|
| 41 | |
---|
| 42 | #define NUM_RTCS (sizeof(RTC_Table)/sizeof(rtc_tbl)) |
---|
| 43 | |
---|
[445f8cc] | 44 | size_t RTC_Count = NUM_RTCS; |
---|
[e56c3546] | 45 | |
---|
| 46 | rtems_device_minor_number RTC_Minor; |
---|
| 47 | |
---|
| 48 | /* mcf5206elite_ds1307_probe -- |
---|
| 49 | * RTC presence probe function. Return TRUE, if device is present. |
---|
| 50 | * Device presence checked by probe access to RTC device over I2C bus. |
---|
| 51 | * |
---|
| 52 | * PARAMETERS: |
---|
| 53 | * minor - minor RTC device number |
---|
| 54 | * |
---|
| 55 | * RETURNS: |
---|
| 56 | * TRUE, if RTC device is present |
---|
| 57 | */ |
---|
| 58 | boolean |
---|
| 59 | mcf5206elite_ds1307_probe(int minor) |
---|
| 60 | { |
---|
| 61 | int try = 0; |
---|
| 62 | i2c_message_status status; |
---|
| 63 | rtc_tbl *rtc; |
---|
| 64 | i2c_bus_number bus; |
---|
| 65 | i2c_address addr; |
---|
[6128a4a] | 66 | |
---|
[e56c3546] | 67 | if (minor >= NUM_RTCS) |
---|
| 68 | return FALSE; |
---|
[6128a4a] | 69 | |
---|
[e56c3546] | 70 | rtc = RTC_Table + minor; |
---|
[6128a4a] | 71 | |
---|
[e56c3546] | 72 | bus = rtc->ulCtrlPort1; |
---|
| 73 | addr = rtc->ulDataPort; |
---|
| 74 | do { |
---|
| 75 | status = i2c_wrbyte(bus, addr, 0); |
---|
| 76 | if (status == I2C_NO_DEVICE) |
---|
| 77 | return FALSE; |
---|
| 78 | try++; |
---|
| 79 | } while ((try < 15) && (status != I2C_SUCCESSFUL)); |
---|
| 80 | if (status == I2C_SUCCESSFUL) |
---|
| 81 | return TRUE; |
---|
| 82 | else |
---|
| 83 | return FALSE; |
---|
| 84 | } |
---|